playbook_ui_docs 14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5341 → 14.11.1.pre.alpha.PLAY17445539

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.md +2 -2
  3. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.md +1 -1
  4. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.html.erb +3 -9
  5. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.md +5 -0
  6. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.html.erb +38 -0
  7. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.md +3 -0
  8. data/app/pb_kits/playbook/pb_draggable/docs/example.yml +1 -0
  9. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.jsx +38 -0
  10. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -45
  11. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +0 -1
  12. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.jsx +9 -16
  13. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +44 -19
  14. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.md +21 -3
  15. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +16 -21
  16. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.jsx +2 -19
  17. data/app/pb_kits/playbook/pb_drawer/docs/example.yml +2 -1
  18. data/app/pb_kits/playbook/pb_drawer/docs/index.js +1 -0
  19. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subtle_variant.md +1 -1
  20. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.html.erb +15 -0
  21. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.jsx +24 -0
  22. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.md +1 -0
  23. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -1
  24. data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
  25. data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.jsx +8 -3
  26. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.html.erb +74 -0
  27. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_rails.md +3 -0
  28. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_rails.md +2 -2
  29. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.html.erb +74 -0
  30. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_rails.md +3 -0
  31. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  32. data/dist/playbook-doc.js +1 -1
  33. metadata +16 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b87aa30f33e7b108b4e005b9abe1fa36f76f435ba0425261e2b1efeffcbea44
4
- data.tar.gz: '05822f0b929223ef65c7c00512bdd6aa804f94eb545d54b99cb69cad8573627f'
3
+ metadata.gz: '090f195e5c1d632daff7a380a997fa713796b9f3fe91b57716e4f47f2009127e'
4
+ data.tar.gz: 564f6568f7c77fb7b11528ee81690486d00ec53dffe1ba829e4bc37aaa69a9c9
5
5
  SHA512:
6
- metadata.gz: 7fe509985ac4eee981ffc5b477f986a23ec6eca428b59b1e3b0aac9e7572337e3e94d125af83c98b766f35a19f01bf7f2683fac4641ce27a4e8295cd3d7b1320
7
- data.tar.gz: 983b9bd19890c4d1c056b636220c68ab570ff01d700c32d7d3892b0d6bff05842c7f26db0ffaf98fea092e9b4f4b1b6557572babf58186ae155d2442353b8262
6
+ metadata.gz: a768c323ef00fb1bc7dad3728d146a71f1be7ea69c2bc592ed9337bccc0374f0bd7b4dcdcc967328e81354608474199048a14d6caab13842180c262c0d97225d
7
+ data.tar.gz: 301d2159ace035f984951c9eafcfc43ace554798fd5730bfc383ccc2763c1a6ae7d1c074a72ca87af790cbfddaa007746d7cadff6768b7f6032b0d48e6800de1
@@ -1,3 +1,3 @@
1
- `sortControl` is an optional prop that can be used to gain greater control over the sort state of the Advanced Table. Tanstack handles sort itself, however it does provide for a way to handle the state manually if needed. Usecases for this include needing to store the sort state so it persists on page reload, set an initial sort state, etc.
1
+ `sortControl` is an optional prop that can be used to gain greater control over the sort state of the Advanced Table. Tanstack handles sort itself, however it does provide for a way to handle the state manually if needed. Usecases for this include needing to store the sort state so it persists on page reload, set an initial sort state, etc.
2
2
 
3
- The sort state must be an object with a single key/value pair, with the key being "desc" and the value being a boolean. The default for sort directino is `desc: true`.
3
+ The sort state must be an object with a single key/value pair, with the key being "desc" and the value being a boolean. The default for sort direction is `desc: true`.
@@ -2,4 +2,4 @@ The `defaultDate`/`default_date` prop has a null or empty string value by defaul
2
2
 
3
3
  If you use a Date object without UTC time standardization the Date Picker kit may misinterpret that date as yesterdays date (consequence of timezone differentials and the Javascript Date Object constructor). See [this GitHub issue for more information](https://github.com/powerhome/playbook/issues/1167) and the anti-pattern examples below.
4
4
 
5
-
5
+ You can leverage the `defaultDate`/`default_date` prop with custom logic in your filter or controller files where the determination of the default value changes based on user interaction. The page can load with an initial default date picker value or placeholder text, then after filter submission save the submitted values as the "new default" (via state or params).
@@ -6,14 +6,8 @@
6
6
 
7
7
  ] %>
8
8
 
9
- <%= pb_rails("draggable", props: {initial_items: initial_items}) do %>
10
- <%= pb_rails("draggable/draggable_container") do %>
11
- <%= pb_rails("list", props: {ordered: false}) do %>
12
- <% initial_items.each do |item| %>
13
- <%= pb_rails("draggable/draggable_item", props:{drag_id: item[:id]}) do %>
14
- <%= pb_rails("list/item") do %><%= item[:name] %><% end %>
15
- <% end %>
16
- <% end %>
17
- <% end %>
9
+ <%= pb_rails("list", props: { enable_drag: true, items: initial_items }) do %>
10
+ <% initial_items.each do |item| %>
11
+ <%= pb_rails("list/item", props:{drag_id: item[:id]}) do %><%= item[:name] %><% end %>
18
12
  <% end %>
19
13
  <% end %>
@@ -0,0 +1,5 @@
1
+ For a simplified version of the Draggable API for the List kit, you can do the following:
2
+
3
+ The List kit is optimized to work with the draggable kit. To enable drag, use the `enable_drag` prop on List kit with an array of the included items AND `drag_id` prop on ListItems. You will also need to include the `items` prop containing your array of listed items for the Draggable API.
4
+
5
+ An additional optional boolean prop (set to true by default) of `drag_handle` is also available on ListItem kit to show the drag handle icon.
@@ -0,0 +1,38 @@
1
+ <%= pb_rails("selectable_list",
2
+ props: {
3
+ enable_drag: true,
4
+ variant: "radio",
5
+ items: [
6
+ { drag_id: "41",
7
+ text: "Task 1",
8
+ input_options: {
9
+ value: "1",
10
+ name: "radio-name",
11
+ }
12
+ },
13
+ { drag_id: "42",
14
+ text: "Task 2",
15
+ checked: true,
16
+ input_options: {
17
+ value: "2",
18
+ name: "radio-name",
19
+ }
20
+ },
21
+ { drag_id: "43",
22
+ text: "Task 3",
23
+ input_options: {
24
+ value: "3",
25
+ name: "radio-name",
26
+ }
27
+ },
28
+ { drag_id: "44",
29
+ text: "Task 4",
30
+ input_options: {
31
+ value: "4",
32
+ name: "radio-name",
33
+ }
34
+ }
35
+ ]
36
+ }
37
+ )
38
+ %>
@@ -0,0 +1,3 @@
1
+ For a simplified version of the Draggable API for the SelectableList kit, you can do the following:
2
+
3
+ The SelectableList kit is optimized to work with the draggable kit. To enable drag, use the `enable_drag` prop on SelectableList kit AND `drag_id` prop within the SelectableList kit prop. An additional optional boolean prop (set to true by default) of `drag_handle` is also available on SelectableList kit to show the drag handle icon.
@@ -11,6 +11,7 @@ examples:
11
11
  rails:
12
12
  - draggable_default_rails: Default
13
13
  - draggable_with_list_rails: Draggable with List Kit
14
+ - draggable_with_selectable_list_rails: Draggable with SelectableList Kit
14
15
  - draggable_with_cards_rails: Draggable with Cards
15
16
 
16
17
 
@@ -0,0 +1,38 @@
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 DrawerBehavior = () => {
12
+ const [drawerOpen, toggleDrawerOpen] = useDrawer()
13
+
14
+ return (
15
+ <>
16
+ <Flex wrap>
17
+ <Button id='sm'
18
+ marginRight='md'
19
+ onClick={toggleDrawerOpen}
20
+ >
21
+ {"Push Behavior"}
22
+ </Button>
23
+ </Flex>
24
+ <Flex>
25
+ <Drawer
26
+ behavior={"push"}
27
+ onClose={toggleDrawerOpen}
28
+ opened={drawerOpen}
29
+ size={"lg"}
30
+ >
31
+ Test me (Push Behavior)
32
+ </Drawer>
33
+ </Flex>
34
+ </>
35
+ )
36
+ }
37
+
38
+ export default DrawerBehavior
@@ -6,19 +6,15 @@ const DrawerBorders = () => {
6
6
  const [openedBRightDrawer, setOpenedBRightDrawer] = useState(false);
7
7
  const [openedBLeftDrawer, setOpenedBLeftDrawer] = useState(false);
8
8
  const [openedBFullDrawer, setOpenedBFullDrawer] = useState(false);
9
- const [openedBDefaultDrawer, setOpenedBDefaultDrawer] = useState(false);
10
- const [openedBRoundedDrawer, setOpenedBRoundedDrawer] = useState(false);
11
9
 
12
10
  // Toggle functions for each drawer
13
11
  const toggleBRightDrawer = () => setOpenedBRightDrawer(!openedBRightDrawer);
14
12
  const toggleBLeftDrawer = () => setOpenedBLeftDrawer(!openedBLeftDrawer);
15
13
  const toggleBFullDrawer = () => setOpenedBFullDrawer(!openedBFullDrawer);
16
- const toggleBDefaultDrawer = () => setOpenedBDefaultDrawer(!openedBDefaultDrawer);
17
- const toggleBRoundedDrawer = () => setOpenedBRoundedDrawer(!openedBRoundedDrawer);
18
14
 
19
15
  return (
20
16
  <>
21
- <Flex padding="md"
17
+ <Flex
22
18
  wrap
23
19
  >
24
20
  <Button marginRight="md"
@@ -36,23 +32,12 @@ const DrawerBorders = () => {
36
32
  >
37
33
  Drawer with border full
38
34
  </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
35
  </Flex>
50
36
 
51
37
  {/* Drawers for each size */}
52
38
  <Drawer
53
39
  behavior="float"
54
40
  border="right"
55
- fullHeight
56
41
  onClose={toggleBRightDrawer}
57
42
  opened={openedBRightDrawer}
58
43
  overlay={false}
@@ -64,11 +49,10 @@ const DrawerBorders = () => {
64
49
  <Drawer
65
50
  behavior="float"
66
51
  border="left"
67
- fullHeight
68
52
  onClose={toggleBLeftDrawer}
69
53
  opened={openedBLeftDrawer}
70
54
  overlay={false}
71
- placement="right"
55
+ placement="left"
72
56
  size="lg"
73
57
  >
74
58
  This is a Drawer with border left
@@ -76,40 +60,14 @@ const DrawerBorders = () => {
76
60
  <Drawer
77
61
  behavior="float"
78
62
  border="full"
79
- fullHeight
80
63
  onClose={toggleBFullDrawer}
81
64
  opened={openedBFullDrawer}
82
65
  overlay={false}
83
- placement="right"
66
+ placement="left"
84
67
  size="lg"
85
68
  >
86
69
  This is a Drawer with border full
87
70
  </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
71
  </>
114
72
  );
115
73
  };
@@ -26,7 +26,6 @@ const DrawerBreakpoints = () => {
26
26
  <Drawer
27
27
  behavior={"push"}
28
28
  breakpoint="sm"
29
- fullHeight
30
29
  onClose={toggleSmallDrawer}
31
30
  opened={smallDrawerOpened}
32
31
  overlay={false}
@@ -9,8 +9,8 @@ const useDrawer = (visible = false) => {
9
9
  };
10
10
 
11
11
  const DrawerDefault = () => {
12
- const [headerSeparatorDrawerOpened, toggleHeaderSeparatorDrawer] = useDrawer();
13
- const [bothSeparatorsDrawerOpened, toggleBothSeparatorsDrawer] = useDrawer();
12
+ const [drawerLeftOpen, toggleDrawerLeftOpen] = useDrawer();
13
+ const [drawerRightOpen, toggleDrawerRightOpen ] = useDrawer();
14
14
 
15
15
  return (
16
16
  <>
@@ -18,13 +18,13 @@ const DrawerDefault = () => {
18
18
  <Button
19
19
  id="sm"
20
20
  marginRight="md"
21
- onClick={toggleHeaderSeparatorDrawer}
21
+ onClick={toggleDrawerLeftOpen}
22
22
  >
23
23
  {"Left Drawer"}
24
24
  </Button>
25
25
  <Button
26
26
  marginRight="xl"
27
- onClick={toggleBothSeparatorsDrawer}
27
+ onClick={toggleDrawerRightOpen}
28
28
  >
29
29
  {"Right Drawer"}
30
30
  </Button>
@@ -32,12 +32,8 @@ const DrawerDefault = () => {
32
32
  <Flex>
33
33
  {/* Left Drawer */}
34
34
  <Drawer
35
- behavior={"push"}
36
- fullHeight
37
- onClose={toggleHeaderSeparatorDrawer}
38
- opened={headerSeparatorDrawerOpened}
39
- overlay
40
- placement={"left"}
35
+ onClose={toggleDrawerLeftOpen}
36
+ opened={drawerLeftOpen}
41
37
  size={"lg"}
42
38
  >
43
39
  Test me (Left Drawer)
@@ -45,11 +41,8 @@ const DrawerDefault = () => {
45
41
 
46
42
  {/* Right Drawer */}
47
43
  <Drawer
48
- behavior={"push"}
49
- fullHeight
50
- onClose={toggleBothSeparatorsDrawer}
51
- opened={bothSeparatorsDrawerOpened}
52
- overlay
44
+ onClose={toggleDrawerRightOpen}
45
+ opened={drawerRightOpen}
53
46
  placement={"right"}
54
47
  size={"lg"}
55
48
  >
@@ -60,4 +53,4 @@ const DrawerDefault = () => {
60
53
  );
61
54
  };
62
55
 
63
- export default DrawerDefault;
56
+ export default DrawerDefault;
@@ -1,31 +1,56 @@
1
- import React from "react";
2
- import { Button, Drawer, Icon, Title } from "playbook-ui";
1
+ import React, { useState, useEffect } from "react"
2
+ import { Button, Drawer, Icon, Nav, NavItem } from "playbook-ui"
3
3
 
4
4
  const DrawerMenu = () => {
5
+ const [isSmallScreen, setIsSmallScreen] = useState(false)
6
+
7
+ useEffect(() => {
8
+ const mediaQuery = window.matchMedia("(max-width: 600px)")
9
+ setIsSmallScreen(mediaQuery.matches)
10
+ const handler = (e) => setIsSmallScreen(e.matches)
11
+ mediaQuery.addEventListener('change', handler)
12
+ return () => mediaQuery.removeEventListener('change', handler)
13
+ }, [])
5
14
 
6
15
  return (
7
- <>
8
- <Button id="menuButton"
9
- padding="sm"
16
+ <div>
17
+ <Button id='menuButton'
18
+ padding='xs'
10
19
  >
11
- <Icon icon="bars"
12
- size="3x"
20
+ <Icon icon='bars'
21
+ size='2x'
13
22
  />
14
23
  </Button>
15
24
  <Drawer
16
- behavior="push"
17
- closeBreakpoint="md"
18
- menuButtonID="menuButton"
19
- overlay={false}
20
- placement="left"
21
- size="lg"
25
+ breakpoint="md"
26
+ placement='bottom'
27
+ size='full'
28
+ triggerId='menuButton'
22
29
  withinElement
23
30
  >
24
- <Title paddingBottom="md">A really neat menu</Title>
25
- <Button text="This Button does nothing" />
31
+ <Nav
32
+ highlight={false}
33
+ link='#'
34
+ orientation={isSmallScreen ? 'vertical' : 'horizontal'}
35
+ padding={isSmallScreen ? 'none' : 'sm'}
36
+ >
37
+ <NavItem link='#'
38
+ text='About'
39
+ />
40
+ <NavItem active
41
+ link='#'
42
+ text='Case Studies'
43
+ />
44
+ <NavItem link='#'
45
+ text='Service'
46
+ />
47
+ <NavItem link='#'
48
+ text='Contacts'
49
+ />
50
+ </Nav>
26
51
  </Drawer>
27
- </>
28
- );
29
- };
52
+ </div>
53
+ )
54
+ }
30
55
 
31
- export default DrawerMenu;
56
+ export default DrawerMenu
@@ -1,6 +1,24 @@
1
- Our drawer kit can fulfill your responsive menu needs! Using the `closeBreakpoint` prop you can have the menu close on smaller screens like phones/tablets.
1
+ The Drawer component can be used to create responsive navigation menus and sidebars. It provides flexible options for controlling when and how the drawer appears based on screen size.
2
+
3
+ ### Within Element
4
+ The `withinElement` prop allows you to render the drawer within its parent container:
5
+ - The drawer will be positioned relative to its parent element
6
+ - Useful for creating nested navigation structures
7
+ - This must be used in conjunction with the `triggerId` prop
8
+
9
+ This provides a clean way to create responsive navigation patterns that adapt to different screen sizes while maintaining a consistent user experience.
10
+
11
+ ### Trigger Id
12
+ The `triggerId` prop allows you to connect an element to control the drawer:
13
+ - The specified element will toggle the drawer open/closed
14
+ - The element is automatically hidden when the drawer is opened via breakpoint
15
+ - The element reappears when the drawer is closed via breakpoint
16
+
17
+ ### Breakpoint
18
+ Use the `breakpoint` prop to control when the drawer automatically opens or closes based on screen size. For example, setting `breakpoint="md"` will:
19
+ - Close the drawer on screens smaller than the medium breakpoint (992px)
20
+ - Automatically open the drawer on screens larger than or equal to the medium breakpoint
21
+
2
22
 
3
- Set a menu button with the `menuButtonID` props. When the Drawer is open, the menu button will be hidden. But when your Brakpoint closes the drawer, you can toggle the Drawer open/close with your menu butotn.
4
23
 
5
- Also use the `withinElement` props to have the Drawer open within a specific element, instead of the default behavior of it taking up the entire screen size.
6
24
 
@@ -1,24 +1,25 @@
1
- import React, { useState } from "react";
2
- import { Button, Drawer, Flex } from "playbook-ui";
1
+ import React, { useState } from "react"
2
+ import { Button, Drawer, Flex } from "playbook-ui"
3
3
 
4
4
  const DrawerSizes = () => {
5
5
  // Individual state variables for each drawer size
6
- const [openedNoOverlayDrawer, setOpenedNoOverlayDrawer] = useState(false);
7
- const [openedOverlayDrawer, setOpenedOverlayDrawer] = useState(false);
6
+ const [openedNoOverlayDrawer, setOpenedNoOverlayDrawer] = useState(false)
7
+ const [openedOverlayDrawer, setOpenedOverlayDrawer] = useState(false)
8
8
 
9
9
  // Toggle functions for each drawer
10
- const toggleNoOverlayDrawer = () => setOpenedNoOverlayDrawer(!openedNoOverlayDrawer);
11
- const toggleOverlayDrawer = () => setOpenedOverlayDrawer(!openedOverlayDrawer);
10
+ const toggleNoOverlayDrawer = () =>
11
+ setOpenedNoOverlayDrawer(!openedNoOverlayDrawer)
12
+ const toggleOverlayDrawer = () => setOpenedOverlayDrawer(!openedOverlayDrawer)
12
13
 
13
14
  return (
14
15
  <>
15
16
  <Flex wrap>
16
- <Button marginRight="md"
17
+ <Button marginRight='md'
17
18
  onClick={toggleNoOverlayDrawer}
18
19
  >
19
20
  No Overlay Drawer
20
21
  </Button>
21
- <Button marginRight="md"
22
+ <Button marginRight='md'
22
23
  onClick={toggleOverlayDrawer}
23
24
  >
24
25
  Overlay Drawer
@@ -27,29 +28,23 @@ const DrawerSizes = () => {
27
28
 
28
29
  {/* Drawers for each size */}
29
30
  <Drawer
30
- behavior="push"
31
- fullHeight
32
31
  onClose={toggleNoOverlayDrawer}
33
32
  opened={openedNoOverlayDrawer}
34
33
  overlay={false}
35
- placement="right"
36
- size="lg"
34
+ size='lg'
37
35
  >
38
36
  This is a Drawer with no overlay
39
37
  </Drawer>
40
38
  <Drawer
41
- behavior="push"
42
- fullHeight
43
39
  onClose={toggleOverlayDrawer}
44
40
  opened={openedOverlayDrawer}
45
- overlay
46
- placement="right"
47
- size="lg"
41
+ placement='right'
42
+ size='lg'
48
43
  >
49
- This is a Drawer with an overlay
44
+ This is a Drawer with an overlay
50
45
  </Drawer>
51
46
  </>
52
- );
53
- };
47
+ )
48
+ }
54
49
 
55
- export default DrawerSizes;
50
+ export default DrawerSizes
@@ -19,7 +19,8 @@ const DrawerSizes = () => {
19
19
  return (
20
20
  <>
21
21
  <Flex wrap>
22
- <Button marginRight="md"
22
+ <Button
23
+ marginRight="md"
23
24
  onClick={toggleXsDrawer}
24
25
  >
25
26
  XS Drawer
@@ -48,11 +49,8 @@ const DrawerSizes = () => {
48
49
 
49
50
  {/* Drawers for each size */}
50
51
  <Drawer
51
- behavior="push"
52
- fullHeight
53
52
  onClose={toggleXsDrawer}
54
53
  opened={openedXsDrawer}
55
- overlay
56
54
  placement="right"
57
55
  size="xs"
58
56
  >
@@ -60,47 +58,32 @@ const DrawerSizes = () => {
60
58
  </Drawer>
61
59
 
62
60
  <Drawer
63
- behavior="push"
64
- fullHeight
65
61
  onClose={toggleSmDrawer}
66
62
  opened={openedSmDrawer}
67
- overlay
68
- placement="right"
69
63
  size="sm"
70
64
  >
71
65
  This is an SM Drawer
72
66
  </Drawer>
73
67
 
74
68
  <Drawer
75
- behavior="push"
76
- fullHeight
77
69
  onClose={toggleMdDrawer}
78
70
  opened={openedMdDrawer}
79
- overlay
80
71
  placement="right"
81
- size="md"
82
72
  >
83
73
  This is an MD Drawer
84
74
  </Drawer>
85
75
 
86
76
  <Drawer
87
- behavior="push"
88
- fullHeight
89
77
  onClose={toggleLgDrawer}
90
78
  opened={openedLgDrawer}
91
- overlay
92
- placement="right"
93
79
  size="lg"
94
80
  >
95
81
  This is an LG Drawer
96
82
  </Drawer>
97
83
 
98
84
  <Drawer
99
- behavior="push"
100
- fullHeight
101
85
  onClose={toggleXlDrawer}
102
86
  opened={openedXlDrawer}
103
- overlay
104
87
  placement="right"
105
88
  size="xl"
106
89
  >
@@ -6,7 +6,8 @@ examples:
6
6
 
7
7
  react:
8
8
  - drawer_default: Default
9
- - drawer_menu: Menu Behavior
9
+ - drawer_behavior: Push Behavior
10
+ - drawer_menu: Within Element
10
11
  - drawer_sizes: Sizes
11
12
  - drawer_overlay: Overlay
12
13
  - drawer_borders: Borders
@@ -4,3 +4,4 @@ export { default as DrawerOverlay } from './_drawer_overlay.jsx'
4
4
  export { default as DrawerBorders } from './_drawer_borders.jsx'
5
5
  export { default as DrawerBreakpoints } from './_drawer_breakpoints.jsx'
6
6
  export { default as DrawerMenu } from './_drawer_menu.jsx'
7
+ export { default as DrawerBehavior } from './_drawer_behavior.jsx'
@@ -1 +1 @@
1
- For the `subtle` variant, it is recommended that you set the `Separators` prop to `false` to remove the separator lines between the options for a more cleaner look.
1
+ For the `subtle` variant, it is recommended that you set the `Separators` prop to `false` to remove the separator lines between the options for a cleaner look.
@@ -0,0 +1,15 @@
1
+ <%= pb_rails("phone_number_input", props: {
2
+ id: "phone_number_input",
3
+ format_as_you_type: true
4
+ }) %>
5
+
6
+ <%= pb_rails("button", props: {id: "clickable", text: "Save Phone Number"}) %>
7
+
8
+ <%= javascript_tag do %>
9
+ document.querySelector('#clickable').addEventListener('click', () => {
10
+ const formattedPhoneNumber = document.querySelector('#phone_number_input').value
11
+ const unformattedPhoneNumber = formattedPhoneNumber.replace(/\D/g, "")
12
+
13
+ alert(`Formatted: ${formattedPhoneNumber}. Unformatted: ${unformattedPhoneNumber}`)
14
+ })
15
+ <% end %>
@@ -0,0 +1,24 @@
1
+ import React, { useState } from "react";
2
+ import { PhoneNumberInput, Body } from "playbook-ui";
3
+
4
+ const PhoneNumberInputFormat = (props) => {
5
+ const [phoneNumber, setPhoneNumber] = useState("");
6
+
7
+ const handleOnChange = ({ number }) => {
8
+ setPhoneNumber(number);
9
+ };
10
+
11
+ return (
12
+ <>
13
+ <PhoneNumberInput
14
+ formatAsYouType
15
+ id="format"
16
+ onChange={handleOnChange}
17
+ {...props}
18
+ />
19
+ {phoneNumber && <Body>Unformatted number: {phoneNumber}</Body>}
20
+ </>
21
+ );
22
+ };
23
+
24
+ export default PhoneNumberInputFormat;
@@ -0,0 +1 @@
1
+ NOTE: the `number` in the React `onChange` event will not include formatting (no spaces, dashes, and parentheses). For Rails, the `value` will include formatting and its value must be sanitized manually.
@@ -8,10 +8,12 @@ examples:
8
8
  - phone_number_input_validation: Form Validation
9
9
  - phone_number_input_clear_field: Clearing the Input Field
10
10
  - phone_number_input_access_input_element: Accessing the Input Element
11
+ - phone_number_input_format: Format as You Type
11
12
 
12
13
  rails:
13
14
  - phone_number_input_default: Default
14
15
  - phone_number_input_preferred_countries: Preferred Countries
15
16
  - phone_number_input_initial_country: Initial Country
16
17
  - phone_number_input_only_countries: Limited Countries
17
- - phone_number_input_validation: Form Validation
18
+ - phone_number_input_validation: Form Validation
19
+ - phone_number_input_format: Format as You Type
@@ -5,3 +5,4 @@ export { default as PhoneNumberInputOnlyCountries } from './_phone_number_input_
5
5
  export { default as PhoneNumberInputValidation } from './_phone_number_input_validation'
6
6
  export { default as PhoneNumberInputClearField } from './_phone_number_input_clear_field'
7
7
  export { default as PhoneNumberInputAccessInputElement } from './_phone_number_input_access_input_element'
8
+ export { default as PhoneNumberInputFormat } from './_phone_number_input_format'