playbook_ui 14.4.0 → 14.5.0.pre.alpha.PBNTR568dropdowncleaning4041
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +23 -4
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/index.js +60 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +1 -9
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.html.erb +1 -9
- data/app/pb_kits/playbook/pb_button/_button.tsx +6 -2
- data/app/pb_kits/playbook/pb_contact/_contact.tsx +17 -5
- data/app/pb_kits/playbook/pb_contact/contact.html.erb +14 -6
- data/app/pb_kits/playbook/pb_contact/contact.rb +4 -0
- data/app/pb_kits/playbook/pb_contact/contact.test.js +1 -1
- data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.ts +2 -6
- data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.ts +2 -7
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +4 -3
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +4 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +6 -3
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.html.erb +1 -1
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_header_styles.scss +6 -2
- data/app/pb_kits/playbook/pb_dialog/_dialog.scss +2 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +1 -1
- data/app/pb_kits/playbook/pb_drawer/_close_icon.tsx +25 -0
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +465 -0
- data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +195 -0
- data/app/pb_kits/playbook/pb_drawer/_drawer_context.tsx +3 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +117 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +43 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.jsx +63 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +55 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.jsx +113 -0
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +12 -0
- data/app/pb_kits/playbook/pb_drawer/docs/index.js +5 -0
- data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +12 -0
- data/app/pb_kits/playbook/pb_drawer/drawer.rb +8 -0
- data/app/pb_kits/playbook/pb_drawer/drawer.test.jsx +77 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +20 -4
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_clear_selection.jsx +45 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_filter/docs/_filter_default.html.erb +10 -2
- data/app/pb_kits/playbook/pb_filter/docs/_filter_max_height.html.erb +5 -1
- data/app/pb_kits/playbook/pb_filter/docs/_filter_max_width.html.erb +5 -1
- data/app/pb_kits/playbook/pb_filter/docs/_filter_no_background.html.erb +5 -1
- data/app/pb_kits/playbook/pb_filter/docs/_filter_no_sort.html.erb +5 -1
- data/app/pb_kits/playbook/pb_filter/docs/_filter_only.html.erb +5 -1
- data/app/pb_kits/playbook/pb_filter/docs/_filter_placement.html.erb +5 -1
- data/app/pb_kits/playbook/pb_filter/docs/_filter_single.html.erb +5 -1
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +9 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.html.erb +19 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.jsx +27 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.md +1 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_map/_map_controls.tsx +7 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +210 -232
- data/app/pb_kits/playbook/pb_multi_level_select/context/index.tsx +5 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_children.jsx +105 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_children.md +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_children_with_radios.jsx +106 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_children_with_radios.md +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select_options.tsx +149 -0
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx +12 -1
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change_react.md +3 -1
- data/app/pb_kits/playbook/pb_passphrase/_passphrase.tsx +10 -2
- data/app/pb_kits/playbook/pb_popover/docs/_popover_list.html.erb +14 -13
- data/app/pb_kits/playbook/pb_popover/docs/_popover_list.jsx +4 -4
- data/app/pb_kits/playbook/pb_radio/_radio.tsx +92 -33
- data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.html.erb +2 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.jsx +62 -0
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_radio/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +12 -5
- data/app/pb_kits/playbook/pb_select/_select.tsx +5 -2
- data/app/pb_kits/playbook/pb_select/select.html.erb +1 -1
- data/app/pb_kits/playbook/pb_select/select.rb +4 -0
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +0 -1
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +17 -13
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +0 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +14 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +7 -1
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +6 -5
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +3 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_margin_bottom.html.erb +88 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_margin_bottom.jsx +60 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +2 -1
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +9 -2
- data/app/pb_kits/playbook/utilities/icons/allicons.tsx +136 -13
- data/app/pb_kits/playbook/utilities/icons/angle-down.svg +3 -0
- data/app/pb_kits/playbook/utilities/icons/envelope.svg +3 -0
- data/dist/chunks/_typeahead-CT2ByCBK.js +22 -0
- data/dist/chunks/_weekday_stacked-CwIBeloD.js +45 -0
- data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
- data/dist/chunks/lib-CEpcaI8y.js +29 -0
- data/dist/chunks/{pb_form_validation-zV9OpdSt.js → pb_form_validation-D9zkwt2b.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +3 -1
- data/dist/playbook-doc.js +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/pagination_renderer.rb +10 -2
- data/lib/playbook/pb_doc_helper.rb +5 -5
- data/lib/playbook/version.rb +2 -2
- metadata +40 -10
- data/dist/chunks/_typeahead-B2zRxReA.js +0 -22
- data/dist/chunks/_weekday_stacked-BIfZDNDm.js +0 -45
- data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
- data/dist/chunks/lib-D2U4I1U6.js +0 -16
@@ -0,0 +1,117 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Button, Drawer, Flex } from "playbook-ui";
|
3
|
+
|
4
|
+
const DrawerBorders = () => {
|
5
|
+
// Individual state variables for each drawer size
|
6
|
+
const [openedBRightDrawer, setOpenedBRightDrawer] = useState(false);
|
7
|
+
const [openedBLeftDrawer, setOpenedBLeftDrawer] = useState(false);
|
8
|
+
const [openedBFullDrawer, setOpenedBFullDrawer] = useState(false);
|
9
|
+
const [openedBDefaultDrawer, setOpenedBDefaultDrawer] = useState(false);
|
10
|
+
const [openedBRoundedDrawer, setOpenedBRoundedDrawer] = useState(false);
|
11
|
+
|
12
|
+
// Toggle functions for each drawer
|
13
|
+
const toggleBRightDrawer = () => setOpenedBRightDrawer(!openedBRightDrawer);
|
14
|
+
const toggleBLeftDrawer = () => setOpenedBLeftDrawer(!openedBLeftDrawer);
|
15
|
+
const toggleBFullDrawer = () => setOpenedBFullDrawer(!openedBFullDrawer);
|
16
|
+
const toggleBDefaultDrawer = () => setOpenedBDefaultDrawer(!openedBDefaultDrawer);
|
17
|
+
const toggleBRoundedDrawer = () => setOpenedBRoundedDrawer(!openedBRoundedDrawer);
|
18
|
+
|
19
|
+
return (
|
20
|
+
<>
|
21
|
+
<Flex padding="md"
|
22
|
+
wrap
|
23
|
+
>
|
24
|
+
<Button marginRight="md"
|
25
|
+
onClick={toggleBRightDrawer}
|
26
|
+
>
|
27
|
+
Drawer with border right
|
28
|
+
</Button>
|
29
|
+
<Button marginRight="md"
|
30
|
+
onClick={toggleBLeftDrawer}
|
31
|
+
>
|
32
|
+
Drawer with border left
|
33
|
+
</Button>
|
34
|
+
<Button marginRight="md"
|
35
|
+
onClick={toggleBFullDrawer}
|
36
|
+
>
|
37
|
+
Drawer with border full
|
38
|
+
</Button>
|
39
|
+
<Button marginRight="md"
|
40
|
+
onClick={toggleBDefaultDrawer}
|
41
|
+
>
|
42
|
+
Default Drawer
|
43
|
+
</Button>
|
44
|
+
<Button marginRight="md"
|
45
|
+
onClick={toggleBRoundedDrawer}
|
46
|
+
>
|
47
|
+
Rounded Drawer
|
48
|
+
</Button>
|
49
|
+
</Flex>
|
50
|
+
|
51
|
+
{/* Drawers for each size */}
|
52
|
+
<Drawer
|
53
|
+
behavior="float"
|
54
|
+
border="right"
|
55
|
+
fullHeight
|
56
|
+
onClose={toggleBRightDrawer}
|
57
|
+
opened={openedBRightDrawer}
|
58
|
+
overlay={false}
|
59
|
+
placement="left"
|
60
|
+
size="lg"
|
61
|
+
>
|
62
|
+
This is a Drawer with border right
|
63
|
+
</Drawer>
|
64
|
+
<Drawer
|
65
|
+
behavior="float"
|
66
|
+
border="left"
|
67
|
+
fullHeight
|
68
|
+
onClose={toggleBLeftDrawer}
|
69
|
+
opened={openedBLeftDrawer}
|
70
|
+
overlay={false}
|
71
|
+
placement="right"
|
72
|
+
size="lg"
|
73
|
+
>
|
74
|
+
This is a Drawer with border left
|
75
|
+
</Drawer>
|
76
|
+
<Drawer
|
77
|
+
behavior="float"
|
78
|
+
border="full"
|
79
|
+
fullHeight
|
80
|
+
onClose={toggleBFullDrawer}
|
81
|
+
opened={openedBFullDrawer}
|
82
|
+
overlay={false}
|
83
|
+
placement="right"
|
84
|
+
size="lg"
|
85
|
+
>
|
86
|
+
This is a Drawer with border full
|
87
|
+
</Drawer>
|
88
|
+
<Drawer
|
89
|
+
behavior="float"
|
90
|
+
fullHeight
|
91
|
+
onClose={toggleBDefaultDrawer}
|
92
|
+
opened={openedBDefaultDrawer}
|
93
|
+
overlay={false}
|
94
|
+
placement="right"
|
95
|
+
size="lg"
|
96
|
+
>
|
97
|
+
This is a Default Drawer
|
98
|
+
</Drawer>
|
99
|
+
<Drawer
|
100
|
+
behavior="float"
|
101
|
+
borderRadius="rounded"
|
102
|
+
fullHeight
|
103
|
+
onClose={toggleBRoundedDrawer}
|
104
|
+
opened={openedBRoundedDrawer}
|
105
|
+
overlay={false}
|
106
|
+
placement="right"
|
107
|
+
size="lg"
|
108
|
+
>
|
109
|
+
<div style={{ paddingTop: '100px', paddingLeft: '12px' }}>
|
110
|
+
This is a Rounded Drawer
|
111
|
+
</div>
|
112
|
+
</Drawer>
|
113
|
+
</>
|
114
|
+
);
|
115
|
+
};
|
116
|
+
|
117
|
+
export default DrawerBorders;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Button, Drawer, Flex } from "playbook-ui";
|
3
|
+
|
4
|
+
const useDrawer = (visible = false) => {
|
5
|
+
const [opened, setOpened] = useState(visible);
|
6
|
+
const toggle = () => setOpened(!opened);
|
7
|
+
|
8
|
+
return [opened, toggle];
|
9
|
+
};
|
10
|
+
|
11
|
+
const DrawerBreakpoints = () => {
|
12
|
+
const [smallDrawerOpened, toggleSmallDrawer] = useDrawer();
|
13
|
+
|
14
|
+
return (
|
15
|
+
<>
|
16
|
+
<Flex wrap>
|
17
|
+
<Button
|
18
|
+
id="sm"
|
19
|
+
marginRight="md"
|
20
|
+
onClick={toggleSmallDrawer}
|
21
|
+
>
|
22
|
+
{"Will open at small breakpoint"}
|
23
|
+
</Button>
|
24
|
+
</Flex>
|
25
|
+
<Flex>
|
26
|
+
<Drawer
|
27
|
+
behavior={"push"}
|
28
|
+
breakpoint="sm"
|
29
|
+
fullHeight
|
30
|
+
onClose={toggleSmallDrawer}
|
31
|
+
opened={smallDrawerOpened}
|
32
|
+
overlay={false}
|
33
|
+
placement={"right"}
|
34
|
+
size={"lg"}
|
35
|
+
>
|
36
|
+
Open because small breakpoint
|
37
|
+
</Drawer>
|
38
|
+
</Flex>
|
39
|
+
</>
|
40
|
+
);
|
41
|
+
};
|
42
|
+
|
43
|
+
export default DrawerBreakpoints;
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= pb_rails("drawer") %>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Button, Drawer, Flex } from "playbook-ui";
|
3
|
+
|
4
|
+
const useDrawer = (visible = false) => {
|
5
|
+
const [opened, setOpened] = useState(visible);
|
6
|
+
const toggle = () => setOpened(!opened);
|
7
|
+
|
8
|
+
return [opened, toggle];
|
9
|
+
};
|
10
|
+
|
11
|
+
const DrawerDefault = () => {
|
12
|
+
const [headerSeparatorDrawerOpened, toggleHeaderSeparatorDrawer] = useDrawer();
|
13
|
+
const [bothSeparatorsDrawerOpened, toggleBothSeparatorsDrawer] = useDrawer();
|
14
|
+
|
15
|
+
return (
|
16
|
+
<>
|
17
|
+
<Flex wrap>
|
18
|
+
<Button
|
19
|
+
id="sm"
|
20
|
+
marginRight="md"
|
21
|
+
onClick={toggleHeaderSeparatorDrawer}
|
22
|
+
>
|
23
|
+
{"Left Drawer"}
|
24
|
+
</Button>
|
25
|
+
<Button
|
26
|
+
marginRight="xl"
|
27
|
+
onClick={toggleBothSeparatorsDrawer}
|
28
|
+
>
|
29
|
+
{"Right Drawer"}
|
30
|
+
</Button>
|
31
|
+
</Flex>
|
32
|
+
<Flex>
|
33
|
+
{/* Left Drawer */}
|
34
|
+
<Drawer
|
35
|
+
behavior={"push"}
|
36
|
+
fullHeight
|
37
|
+
onClose={toggleHeaderSeparatorDrawer}
|
38
|
+
opened={headerSeparatorDrawerOpened}
|
39
|
+
overlay
|
40
|
+
placement={"left"}
|
41
|
+
size={"lg"}
|
42
|
+
>
|
43
|
+
Test me (Left Drawer)
|
44
|
+
</Drawer>
|
45
|
+
|
46
|
+
{/* Right Drawer */}
|
47
|
+
<Drawer
|
48
|
+
behavior={"push"}
|
49
|
+
fullHeight
|
50
|
+
onClose={toggleBothSeparatorsDrawer}
|
51
|
+
opened={bothSeparatorsDrawerOpened}
|
52
|
+
overlay
|
53
|
+
placement={"right"}
|
54
|
+
size={"lg"}
|
55
|
+
>
|
56
|
+
Test me (Right Drawer)
|
57
|
+
</Drawer>
|
58
|
+
</Flex>
|
59
|
+
</>
|
60
|
+
);
|
61
|
+
};
|
62
|
+
|
63
|
+
export default DrawerDefault;
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Button, Drawer, Flex } from "playbook-ui";
|
3
|
+
|
4
|
+
const DrawerSizes = () => {
|
5
|
+
// Individual state variables for each drawer size
|
6
|
+
const [openedNoOverlayDrawer, setOpenedNoOverlayDrawer] = useState(false);
|
7
|
+
const [openedOverlayDrawer, setOpenedOverlayDrawer] = useState(false);
|
8
|
+
|
9
|
+
// Toggle functions for each drawer
|
10
|
+
const toggleNoOverlayDrawer = () => setOpenedNoOverlayDrawer(!openedNoOverlayDrawer);
|
11
|
+
const toggleOverlayDrawer = () => setOpenedOverlayDrawer(!openedOverlayDrawer);
|
12
|
+
|
13
|
+
return (
|
14
|
+
<>
|
15
|
+
<Flex wrap>
|
16
|
+
<Button marginRight="md"
|
17
|
+
onClick={toggleNoOverlayDrawer}
|
18
|
+
>
|
19
|
+
No Overlay Drawer
|
20
|
+
</Button>
|
21
|
+
<Button marginRight="md"
|
22
|
+
onClick={toggleOverlayDrawer}
|
23
|
+
>
|
24
|
+
Overlay Drawer
|
25
|
+
</Button>
|
26
|
+
</Flex>
|
27
|
+
|
28
|
+
{/* Drawers for each size */}
|
29
|
+
<Drawer
|
30
|
+
behavior="push"
|
31
|
+
fullHeight
|
32
|
+
onClose={toggleNoOverlayDrawer}
|
33
|
+
opened={openedNoOverlayDrawer}
|
34
|
+
overlay={false}
|
35
|
+
placement="right"
|
36
|
+
size="lg"
|
37
|
+
>
|
38
|
+
This is a Drawer with no overlay
|
39
|
+
</Drawer>
|
40
|
+
<Drawer
|
41
|
+
behavior="push"
|
42
|
+
fullHeight
|
43
|
+
onClose={toggleOverlayDrawer}
|
44
|
+
opened={openedOverlayDrawer}
|
45
|
+
overlay
|
46
|
+
placement="right"
|
47
|
+
size="lg"
|
48
|
+
>
|
49
|
+
This is a Drawer with an overlay
|
50
|
+
</Drawer>
|
51
|
+
</>
|
52
|
+
);
|
53
|
+
};
|
54
|
+
|
55
|
+
export default DrawerSizes;
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Button, Drawer, Flex } from "playbook-ui";
|
3
|
+
|
4
|
+
const DrawerSizes = () => {
|
5
|
+
// Individual state variables for each drawer size
|
6
|
+
const [openedXsDrawer, setOpenedXsDrawer] = useState(false);
|
7
|
+
const [openedSmDrawer, setOpenedSmDrawer] = useState(false);
|
8
|
+
const [openedMdDrawer, setOpenedMdDrawer] = useState(false);
|
9
|
+
const [openedLgDrawer, setOpenedLgDrawer] = useState(false);
|
10
|
+
const [openedXlDrawer, setOpenedXlDrawer] = useState(false);
|
11
|
+
|
12
|
+
// Toggle functions for each drawer
|
13
|
+
const toggleXsDrawer = () => setOpenedXsDrawer(!openedXsDrawer);
|
14
|
+
const toggleSmDrawer = () => setOpenedSmDrawer(!openedSmDrawer);
|
15
|
+
const toggleMdDrawer = () => setOpenedMdDrawer(!openedMdDrawer);
|
16
|
+
const toggleLgDrawer = () => setOpenedLgDrawer(!openedLgDrawer);
|
17
|
+
const toggleXlDrawer = () => setOpenedXlDrawer(!openedXlDrawer);
|
18
|
+
|
19
|
+
return (
|
20
|
+
<>
|
21
|
+
<Flex wrap>
|
22
|
+
<Button marginRight="md"
|
23
|
+
onClick={toggleXsDrawer}
|
24
|
+
>
|
25
|
+
XS Drawer
|
26
|
+
</Button>
|
27
|
+
<Button marginRight="md"
|
28
|
+
onClick={toggleSmDrawer}
|
29
|
+
>
|
30
|
+
SM Drawer
|
31
|
+
</Button>
|
32
|
+
<Button marginRight="md"
|
33
|
+
onClick={toggleMdDrawer}
|
34
|
+
>
|
35
|
+
MD Drawer
|
36
|
+
</Button>
|
37
|
+
<Button marginRight="md"
|
38
|
+
onClick={toggleLgDrawer}
|
39
|
+
>
|
40
|
+
LG Drawer
|
41
|
+
</Button>
|
42
|
+
<Button marginRight="md"
|
43
|
+
onClick={toggleXlDrawer}
|
44
|
+
>
|
45
|
+
XL Drawer
|
46
|
+
</Button>
|
47
|
+
</Flex>
|
48
|
+
|
49
|
+
{/* Drawers for each size */}
|
50
|
+
<Drawer
|
51
|
+
behavior="push"
|
52
|
+
fullHeight
|
53
|
+
onClose={toggleXsDrawer}
|
54
|
+
opened={openedXsDrawer}
|
55
|
+
overlay
|
56
|
+
placement="right"
|
57
|
+
size="xs"
|
58
|
+
>
|
59
|
+
XS
|
60
|
+
</Drawer>
|
61
|
+
|
62
|
+
<Drawer
|
63
|
+
behavior="push"
|
64
|
+
fullHeight
|
65
|
+
onClose={toggleSmDrawer}
|
66
|
+
opened={openedSmDrawer}
|
67
|
+
overlay
|
68
|
+
placement="right"
|
69
|
+
size="sm"
|
70
|
+
>
|
71
|
+
This is an SM Drawer
|
72
|
+
</Drawer>
|
73
|
+
|
74
|
+
<Drawer
|
75
|
+
behavior="push"
|
76
|
+
fullHeight
|
77
|
+
onClose={toggleMdDrawer}
|
78
|
+
opened={openedMdDrawer}
|
79
|
+
overlay
|
80
|
+
placement="right"
|
81
|
+
size="md"
|
82
|
+
>
|
83
|
+
This is an MD Drawer
|
84
|
+
</Drawer>
|
85
|
+
|
86
|
+
<Drawer
|
87
|
+
behavior="push"
|
88
|
+
fullHeight
|
89
|
+
onClose={toggleLgDrawer}
|
90
|
+
opened={openedLgDrawer}
|
91
|
+
overlay
|
92
|
+
placement="right"
|
93
|
+
size="lg"
|
94
|
+
>
|
95
|
+
This is an LG Drawer
|
96
|
+
</Drawer>
|
97
|
+
|
98
|
+
<Drawer
|
99
|
+
behavior="push"
|
100
|
+
fullHeight
|
101
|
+
onClose={toggleXlDrawer}
|
102
|
+
opened={openedXlDrawer}
|
103
|
+
overlay
|
104
|
+
placement="right"
|
105
|
+
size="xl"
|
106
|
+
>
|
107
|
+
This is an XL Drawer
|
108
|
+
</Drawer>
|
109
|
+
</>
|
110
|
+
);
|
111
|
+
};
|
112
|
+
|
113
|
+
export default DrawerSizes;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { default as DrawerDefault } from './_drawer_default.jsx'
|
2
|
+
export { default as DrawerSizes } from './_drawer_sizes.jsx'
|
3
|
+
export { default as DrawerOverlay } from './_drawer_overlay.jsx'
|
4
|
+
export { default as DrawerBorders } from './_drawer_borders.jsx'
|
5
|
+
export { default as DrawerBreakpoints } from './_drawer_breakpoints.jsx'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<!-- Go to pb_content_tag definition in kit_base.rb for usage information. Commented out options are default (showing the default shape), and each can be deleted if not customizing that param. -->
|
2
|
+
<!-- If using nonstandard params please un-comment out and replace with your custom params. -->
|
3
|
+
<%= pb_content_tag(
|
4
|
+
# :div,
|
5
|
+
# aria: object.aria,
|
6
|
+
# class: object.classname,
|
7
|
+
# data: object.data,
|
8
|
+
# id: object.id,
|
9
|
+
# **combined_html_options
|
10
|
+
) do %>
|
11
|
+
<span>DRAWER CONTENT</span>
|
12
|
+
<% end %>
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import { render, cleanup, fireEvent, screen } from '../utilities/test-utils';
|
3
|
+
import { Drawer, Button } from 'playbook-ui';
|
4
|
+
|
5
|
+
const size = 'sm';
|
6
|
+
|
7
|
+
function DrawerTest({ props }) {
|
8
|
+
const [isOpen, setIsOpen] = useState(false);
|
9
|
+
const close = () => setIsOpen(false);
|
10
|
+
const open = () => setIsOpen(true);
|
11
|
+
|
12
|
+
return (
|
13
|
+
<>
|
14
|
+
<Button onClick={open}>{'Open Drawer'}</Button>
|
15
|
+
<Drawer
|
16
|
+
className="wrapper"
|
17
|
+
onClose={close}
|
18
|
+
opened={isOpen}
|
19
|
+
placement="left"
|
20
|
+
portalClassName="portal"
|
21
|
+
size={size}
|
22
|
+
{...props}
|
23
|
+
>
|
24
|
+
{props && props.children}
|
25
|
+
</Drawer>
|
26
|
+
</>
|
27
|
+
);
|
28
|
+
}
|
29
|
+
|
30
|
+
afterEach(cleanup);
|
31
|
+
|
32
|
+
test('renders with the right border class when border prop is right', async () => {
|
33
|
+
render(<DrawerTest props={{ border: 'right' }} />);
|
34
|
+
|
35
|
+
fireEvent.click(screen.getByText('Open Drawer'));
|
36
|
+
|
37
|
+
const drawer = await screen.findByRole('dialog');
|
38
|
+
expect(drawer).toHaveClass('drawer_border_right');
|
39
|
+
});
|
40
|
+
|
41
|
+
test('renders with the left border class when border prop is left', async () => {
|
42
|
+
render(<DrawerTest props={{ border: 'left' }} />);
|
43
|
+
|
44
|
+
fireEvent.click(screen.getByText('Open Drawer'));
|
45
|
+
|
46
|
+
const drawer = await screen.findByRole('dialog');
|
47
|
+
expect(drawer).toHaveClass('drawer_border_left');
|
48
|
+
});
|
49
|
+
|
50
|
+
test('renders with the full border class when border prop is full', async () => {
|
51
|
+
render(<DrawerTest props={{ border: 'full' }} />);
|
52
|
+
|
53
|
+
fireEvent.click(screen.getByText('Open Drawer'));
|
54
|
+
|
55
|
+
const drawer = await screen.findByRole('dialog');
|
56
|
+
expect(drawer).toHaveClass('drawer_border_full');
|
57
|
+
});
|
58
|
+
|
59
|
+
test('does not have a border class when border prop is none', async () => {
|
60
|
+
render(<DrawerTest props={{ border: 'none' }} />);
|
61
|
+
|
62
|
+
fireEvent.click(screen.getByText('Open Drawer'));
|
63
|
+
|
64
|
+
const drawer = await screen.findByRole('dialog');
|
65
|
+
expect(drawer).not.toHaveClass('drawer_border_right');
|
66
|
+
expect(drawer).not.toHaveClass('drawer_border_left');
|
67
|
+
expect(drawer).not.toHaveClass('drawer_border_full');
|
68
|
+
});
|
69
|
+
|
70
|
+
test('renders the correct size class for a large drawer', async () => {
|
71
|
+
render(<DrawerTest props={{ size: 'lg' }} />);
|
72
|
+
|
73
|
+
fireEvent.click(screen.getByText('Open Drawer'));
|
74
|
+
|
75
|
+
const drawer = await screen.findByRole('dialog');
|
76
|
+
expect(drawer).toHaveClass('pb_drawer pb_drawer_lg_left');
|
77
|
+
});
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useState, useRef, useEffect } from "react";
|
1
|
+
import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from "react";
|
2
2
|
import classnames from "classnames";
|
3
3
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
4
4
|
import { globalProps } from "../utilities/globalProps";
|
@@ -38,7 +38,14 @@ type DropdownProps = {
|
|
38
38
|
triggerRef?: any;
|
39
39
|
};
|
40
40
|
|
41
|
-
|
41
|
+
interface DropdownComponent
|
42
|
+
extends React.ForwardRefExoticComponent<DropdownProps & React.RefAttributes<unknown>> {
|
43
|
+
Option: typeof DropdownOption;
|
44
|
+
Trigger: typeof DropdownTrigger;
|
45
|
+
Container: typeof DropdownContainer;
|
46
|
+
}
|
47
|
+
|
48
|
+
const Dropdown = forwardRef((props: DropdownProps, ref: any) => {
|
42
49
|
const {
|
43
50
|
aria = {},
|
44
51
|
autocomplete = false,
|
@@ -125,7 +132,7 @@ const Dropdown = (props: DropdownProps) => {
|
|
125
132
|
const filteredOptions = optionsWithBlankSelection?.filter((option: GenericObject) => {
|
126
133
|
const label = typeof option.label === 'string' ? option.label.toLowerCase() : option.label;
|
127
134
|
return String(label).toLowerCase().includes(filterItem.toLowerCase());
|
128
|
-
});
|
135
|
+
});
|
129
136
|
|
130
137
|
// For keyboard accessibility: Set focus within dropdown to selected item if it exists
|
131
138
|
useEffect(() => {
|
@@ -175,6 +182,14 @@ const Dropdown = (props: DropdownProps) => {
|
|
175
182
|
dark
|
176
183
|
});
|
177
184
|
|
185
|
+
useImperativeHandle(ref, () => ({
|
186
|
+
clearSelected: () => {
|
187
|
+
setSelected({});
|
188
|
+
setFilterItem("");
|
189
|
+
setIsDropDownClosed(true);
|
190
|
+
onSelect && onSelect(null);
|
191
|
+
},
|
192
|
+
}));
|
178
193
|
|
179
194
|
return (
|
180
195
|
<div {...ariaProps}
|
@@ -258,8 +273,9 @@ const Dropdown = (props: DropdownProps) => {
|
|
258
273
|
</DropdownContext.Provider>
|
259
274
|
</div>
|
260
275
|
)
|
261
|
-
}
|
276
|
+
}) as DropdownComponent
|
262
277
|
|
278
|
+
Dropdown.displayName = "Dropdown";
|
263
279
|
Dropdown.Option = DropdownOption;
|
264
280
|
Dropdown.Trigger = DropdownTrigger;
|
265
281
|
Dropdown.Container = DropdownContainer;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import React, { useRef } from 'react'
|
2
|
+
import { Button, Dropdown } from 'playbook-ui'
|
3
|
+
|
4
|
+
const options = [
|
5
|
+
{
|
6
|
+
label: "United States",
|
7
|
+
value: "United States",
|
8
|
+
},
|
9
|
+
{
|
10
|
+
label: "Canada",
|
11
|
+
value: "Canada",
|
12
|
+
},
|
13
|
+
{
|
14
|
+
label: "Pakistan",
|
15
|
+
value: "Pakistan",
|
16
|
+
}
|
17
|
+
]
|
18
|
+
|
19
|
+
const DropdownClearSelection = (props) => {
|
20
|
+
const dropdownRef = useRef(null)
|
21
|
+
|
22
|
+
const handleReset = () => {
|
23
|
+
if (dropdownRef.current) {
|
24
|
+
dropdownRef.current.clearSelected()
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
return (
|
29
|
+
<>
|
30
|
+
<Dropdown
|
31
|
+
defaultValue={options[2]}
|
32
|
+
options={options}
|
33
|
+
ref={dropdownRef}
|
34
|
+
{...props}
|
35
|
+
/>
|
36
|
+
<Button
|
37
|
+
marginTop="md"
|
38
|
+
onClick={handleReset}
|
39
|
+
text="Reset"
|
40
|
+
/>
|
41
|
+
</>
|
42
|
+
)
|
43
|
+
}
|
44
|
+
|
45
|
+
export default DropdownClearSelection
|
@@ -22,6 +22,7 @@ examples:
|
|
22
22
|
- dropdown_error: Dropdown with Error
|
23
23
|
- dropdown_default_value: Default Value
|
24
24
|
- dropdown_blank_selection: Blank Selection
|
25
|
+
- dropdown_clear_selection: Clear Selection
|
25
26
|
# - dropdown_with_autocomplete: Autocomplete
|
26
27
|
# - dropdown_with_autocomplete_and_custom_display: Autocomplete with Custom Display
|
27
28
|
# - dropdown_with_external_control: useDropdown Hook
|
@@ -12,3 +12,4 @@ export { default as DropdownSubcomponentStructure } from './_dropdown_subcompone
|
|
12
12
|
export { default as DropdownError } from './_dropdown_error.jsx'
|
13
13
|
export { default as DropdownDefaultValue } from './_dropdown_default_value.jsx'
|
14
14
|
export { default as DropdownBlankSelection } from './_dropdown_blank_selection.jsx'
|
15
|
+
export { default as DropdownClearSelection } from './_dropdown_clear_selection.jsx'
|
@@ -30,7 +30,11 @@
|
|
30
30
|
<%= form.collection_select :example_collection_select, example_collection, :value, :name, props: { label: true } %>
|
31
31
|
|
32
32
|
<%= form.actions do |action| %>
|
33
|
-
<%= action.submit props: {
|
33
|
+
<%= action.submit props: {
|
34
|
+
text: "Apply",
|
35
|
+
data: {
|
36
|
+
disable_with: "pb_rails('icon', props: { icon: 'spinner', spin: true, fixed_width: true })Searching...".html_safe
|
37
|
+
},}%>
|
34
38
|
<%= action.button props: { type: "reset", text: "Clear", variant: "secondary" } %>
|
35
39
|
<% end %>
|
36
40
|
<% end %>
|
@@ -64,7 +68,11 @@
|
|
64
68
|
<%= form.collection_select :example_collection_select, example_collection, :value, :name, props: { label: true } %>
|
65
69
|
|
66
70
|
<%= form.actions do |action| %>
|
67
|
-
<%= action.submit props: {
|
71
|
+
<%= action.submit props: {
|
72
|
+
text: "Apply",
|
73
|
+
data: {
|
74
|
+
disable_with: "pb_rails('icon', props: { icon: 'spinner', spin: true, fixed_width: true })Searching...".html_safe
|
75
|
+
},}%>
|
68
76
|
<%= action.button props: { type: "reset", text: "Clear", variant: "secondary" } %>
|
69
77
|
<% end %>
|
70
78
|
<% end %>
|
@@ -35,7 +35,11 @@
|
|
35
35
|
<%= form.collection_select :example_collection_select, example_collection, :value, :name, props: {max_width: "sm", label: true } %>
|
36
36
|
|
37
37
|
<%= form.actions do |action| %>
|
38
|
-
<%= action.submit props: {
|
38
|
+
<%= action.submit props: {
|
39
|
+
text: "Apply",
|
40
|
+
data: {
|
41
|
+
disable_with: "pb_rails('icon', props: { icon: 'spinner', spin: true, fixed_width: true })Searching...".html_safe
|
42
|
+
},}%>
|
39
43
|
<%= action.button props: { type: "reset", text: "Clear", variant: "secondary" } %>
|
40
44
|
<% end %>
|
41
45
|
<% end %>
|