playbook_ui 13.17.0 → 13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2173

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_reset.scss +2 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +5 -4
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +9 -4
  5. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +18 -13
  6. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +27 -4
  7. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +18 -4
  8. data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +3 -4
  9. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +18 -7
  10. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +328 -3
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.jsx +52 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.md +1 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +7 -2
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.jsx +59 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.md +18 -0
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.jsx +60 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.md +3 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx +1 -6
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.md +5 -0
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx +63 -0
  21. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.md +3 -0
  22. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.jsx +57 -0
  23. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.md +3 -0
  24. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.jsx +61 -0
  25. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.md +3 -0
  26. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +55 -0
  27. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.md +1 -0
  28. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +10 -4
  29. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +7 -0
  30. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_loading.scss +4 -3
  31. data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +2 -2
  32. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +1 -1
  33. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.html.erb +5 -7
  34. data/app/pb_kits/playbook/pb_popover/_popover.tsx +12 -14
  35. data/app/pb_kits/playbook/pb_popover/docs/_popover_actionable_content.html.erb +30 -0
  36. data/app/pb_kits/playbook/pb_popover/docs/_popover_actionable_content.jsx +57 -0
  37. data/app/pb_kits/playbook/pb_popover/docs/example.yml +2 -1
  38. data/app/pb_kits/playbook/pb_popover/docs/index.js +1 -0
  39. data/app/pb_kits/playbook/pb_popover/popover.test.js +29 -31
  40. data/app/pb_kits/playbook/pb_table/_table.tsx +3 -0
  41. data/app/pb_kits/playbook/pb_table/docs/_table_striped.html.erb +48 -0
  42. data/app/pb_kits/playbook/pb_table/docs/_table_striped.jsx +58 -0
  43. data/app/pb_kits/playbook/pb_table/docs/_table_striped.md +1 -0
  44. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  45. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  46. data/app/pb_kits/playbook/pb_table/styles/_all.scss +1 -0
  47. data/app/pb_kits/playbook/pb_table/styles/_striped.scss +19 -0
  48. data/app/pb_kits/playbook/pb_table/table.rb +7 -1
  49. data/app/pb_kits/playbook/pb_table/table.test.js +5 -0
  50. data/dist/menu.yml +102 -3
  51. data/dist/playbook-rails.js +7 -7
  52. data/dist/reset.css +1 -2
  53. data/lib/playbook/version.rb +2 -2
  54. metadata +28 -7
@@ -0,0 +1,57 @@
1
+ import React from "react";
2
+ import { AdvancedTable } from "../..";
3
+ import { MOCK_DATA } from "./_mock_data";
4
+
5
+ const AdvancedTableSubrowHeaders = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ];
37
+
38
+ //Render the subRow header rows
39
+ const subRowHeaders = ["Quarter", "Month", "Day"]
40
+
41
+
42
+ return (
43
+ <div>
44
+ <AdvancedTable
45
+ columnDefinitions={columnDefinitions}
46
+ enableToggleExpansion="all"
47
+ tableData={MOCK_DATA}
48
+ {...props}
49
+ >
50
+ <AdvancedTable.Header />
51
+ <AdvancedTable.Body subRowHeaders={subRowHeaders}/>
52
+ </AdvancedTable>
53
+ </div>
54
+ );
55
+ };
56
+
57
+ export default AdvancedTableSubrowHeaders;
@@ -0,0 +1,3 @@
1
+ `subRowHeaders` is an optional prop that if present will add header rows at each level of the nested data. The prop takes an array of strings, each string being the text for each header row. The array of strings must be in the order in which they need to be rendered in the UI according to depth.
2
+
3
+ `enableToggleExpansion` is an additional optional prop that can be used in conjunction with the subRowHeaders prop. `enableToggleExpansion` is a string that can be 'all' or 'header". If set to 'all', the toggle exapansion button will appear in the table header as well as in the subRow headers. If set to 'header' button will only appear in header and NOT in subRow headers. This is set to 'headeer' by default.
@@ -0,0 +1,61 @@
1
+ import React from "react";
2
+ import { AdvancedTable } from "../../";
3
+ import { MOCK_DATA } from "./_mock_data";
4
+
5
+ const AdvancedTableTableOptions = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ];
37
+
38
+ const tableOptions = {
39
+ initialState: {
40
+ sorting: [
41
+ {
42
+ id: "year",
43
+ desc: true,
44
+ },
45
+ ],
46
+ },
47
+ }
48
+
49
+ return (
50
+ <div>
51
+ <AdvancedTable
52
+ columnDefinitions={columnDefinitions}
53
+ tableData={MOCK_DATA}
54
+ tableOptions={tableOptions}
55
+ {...props}
56
+ />
57
+ </div>
58
+ );
59
+ };
60
+
61
+ export default AdvancedTableTableOptions;
@@ -0,0 +1,3 @@
1
+ The Tanstack table consumes the useReactTable hook to create the table. This hook takes an object that can contain any of the functions that the Tanstack table provides. The advancedTable's optional `tableOptions` can be used to pass tanstack options to the kit.
2
+
3
+ In the above example, we are using the initialState option provided by tanstack that takes sort as one of it's values. Setting it to true for the first column is reversing the sort order on first render of the table. For a complete list of possible options and hoe to use them, see [here](https://tanstack.com/table/v8/docs/api/core/table#usereacttable--createsolidtable--usevuetable--createsveltetable)
@@ -0,0 +1,55 @@
1
+ import React from "react";
2
+ import { AdvancedTable } from "../../";
3
+ import { MOCK_DATA } from "./_mock_data";
4
+
5
+ const AdvancedTableTableProps = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ];
37
+
38
+ const tableProps = {
39
+ container: false,
40
+ sticky: true
41
+ }
42
+
43
+ return (
44
+ <div>
45
+ <AdvancedTable
46
+ columnDefinitions={columnDefinitions}
47
+ tableData={MOCK_DATA}
48
+ tableProps={tableProps}
49
+ {...props}
50
+ />
51
+ </div>
52
+ );
53
+ };
54
+
55
+ export default AdvancedTableTableProps;
@@ -0,0 +1 @@
1
+ This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table/react) under the hood which comes with it's own set of props. If you want to apply certain Table props to that underlying kit, you can do so by using the optional `tableProps` prop. This prop must be an object that contains valid Table props. For a full list of Table props, see [here](https://playbook.powerapp.cloud/kits/table/react).
@@ -1,6 +1,12 @@
1
1
  examples:
2
2
  react:
3
- - advanced_table_default: Default
4
- # - advanced_table_sort: enableSorting
5
-
6
-
3
+ - advanced_table_default: Default (Required Props)
4
+ - advanced_table_loading: Loading State
5
+ - advanced_table_sort: enable Sorting
6
+ - advanced_table_sort_control: Sort Control
7
+ - advanced_table_expanded_control: Expanded Control
8
+ - advanced_table_subrow_headers: SubRow Headers
9
+ - advanced_table_collapsible_trail: Collapsible Trail
10
+ - advanced_table_table_options: Table Options
11
+ - advanced_table_table_props: Table Props
12
+
@@ -1,2 +1,9 @@
1
1
  export { default as AdvancedTableDefault } from './_advanced_table_default.jsx'
2
2
  export { default as AdvancedTableSort } from './_advanced_table_sort.jsx'
3
+ export { default as AdvancedTableSortControl } from './_advanced_table_sort_control.jsx'
4
+ export { default as AdvancedTableLoading } from './_advanced_table_loading.jsx'
5
+ export { default as AdvancedTableExpandedControl } from './_advanced_table_expanded_control.jsx'
6
+ export { default as AdvancedTableSubrowHeaders } from './_advanced_table_subrow_headers.jsx'
7
+ export { default as AdvancedTableCollapsibleTrail } from './_advanced_table_collapsible_trail.jsx'
8
+ export { default as AdvancedTableTableOptions } from './_advanced_table_table_options.jsx'
9
+ export { default as AdvancedTableTableProps } from './_advanced_table_table_props.jsx'
@@ -55,11 +55,12 @@
55
55
  }
56
56
 
57
57
  .loading-toggle-icon {
58
- width: $space_sm - 1;
59
- height: $space_sm - 1;
58
+ width: $space_sm - 3;
59
+ height: $space_sm - 4;
60
+ margin-right: $space_xxs;
60
61
  margin-bottom: $space_xxs + 2;
61
62
  &::after {
62
- height: $space_sm - 1;
63
+ height: $space_sm - 4;
63
64
  border-radius: $border_radius_rounded;
64
65
  }
65
66
  }
@@ -1,5 +1,5 @@
1
- @import "./tokens/colors";
2
- @import "./tokens/spacing";
1
+ @import "tokens/colors";
2
+ @import "tokens/spacing";
3
3
 
4
4
  [class^=pb_collapsible_kit] {
5
5
  padding: $space_md;
@@ -1,5 +1,5 @@
1
1
  // Manual Import -- Flatpickr Styles
2
- @import "./tokens/typography";
2
+ @import "tokens/typography";
3
3
 
4
4
  .flatpickr-calendar {
5
5
  background: transparent;
@@ -3,12 +3,10 @@
3
3
  <%= pb_rails("button", props: {html_type: "submit", text: "Save Phone Number"}) %>
4
4
  </form>
5
5
 
6
- <% content_for(:pb_js) do %>
7
- <%= javascript_tag do %>
8
- document.addEventListener('DOMContentLoaded', function () {
9
- document.querySelector('#example-form-validation').addEventListener('submit', function (e) {
10
- if (e.target.querySelectorAll('[error]:not([error=""])').length > 0) e.preventDefault();
11
- })
6
+ <%= javascript_tag do %>
7
+ document.addEventListener('DOMContentLoaded', function () {
8
+ document.querySelector('#example-form-validation').addEventListener('submit', function (e) {
9
+ if (e.target.querySelectorAll('[error]:not([error=""])').length > 0) e.preventDefault();
12
10
  })
13
- <% end %>
11
+ })
14
12
  <% end %>
@@ -171,29 +171,27 @@ const PbReactPopover = (props: PbPopoverProps): React.ReactElement => {
171
171
 
172
172
  document.body.addEventListener(
173
173
  "click",
174
- ({ target }) => {
174
+ (e: MouseEvent) => {
175
+ const target = e.target as HTMLElement
176
+
175
177
  const targetIsPopover =
176
- (target as HTMLElement).closest("#" + targetId) !==
177
- null;
178
+ target.closest("#" + targetId) !== null;
178
179
  const targetIsReference =
179
- (target as HTMLElement).closest("#reference-" + targetId) !==
180
- null;
180
+ target.closest("#reference-" + targetId) !== null;
181
+
182
+ const shouldClose = () => {
183
+ setTimeout(() => shouldClosePopover(true), 0);
184
+ }
181
185
 
182
186
  switch (closeOnClick) {
183
187
  case "outside":
184
- if (!targetIsPopover && !targetIsReference) {
185
- shouldClosePopover(true);
186
- }
188
+ if (!targetIsPopover && !targetIsReference) shouldClose();
187
189
  break;
188
190
  case "inside":
189
- if (targetIsPopover) {
190
- shouldClosePopover(true);
191
- }
191
+ if (targetIsPopover) shouldClose();
192
192
  break;
193
193
  case "any":
194
- if (targetIsPopover || !targetIsPopover && !targetIsReference) {
195
- shouldClosePopover(true);
196
- }
194
+ if (targetIsPopover || !targetIsPopover && !targetIsReference) shouldClose();
197
195
  break;
198
196
  }
199
197
  },
@@ -0,0 +1,30 @@
1
+ <%= pb_rails("flex", props: {
2
+ dark: true,
3
+ orientation: "row",
4
+ vertical: "center"
5
+ }) do %>
6
+ <%= pb_rails("body", props: { text: "Click info for more details" }) %>
7
+ &nbsp;
8
+ <%= pb_rails("circle_icon_button", props: {
9
+ variant: "secondary",
10
+ icon: "info",
11
+ id: "actionable-popover-1"
12
+ }) %>
13
+ <%= pb_rails("popover", props: {
14
+ close_on_click: "any",
15
+ trigger_element_id: "actionable-popover-1",
16
+ tooltip_id: "actionable-tooltip-1",
17
+ offset: true,
18
+ position: "top"
19
+ }) do %>
20
+ <%= pb_rails("button", props: { id: "actionable-tooltip-button", text: "Learn more" }) %>
21
+ <% end %>
22
+ <% end %>
23
+
24
+ <%= javascript_tag do %>
25
+ document.addEventListener('DOMContentLoaded', function () {
26
+ document.querySelector('#actionable-tooltip-button').addEventListener('click', function (e) {
27
+ alert("Let's do this")
28
+ }, { once: true })
29
+ })
30
+ <% end %>
@@ -0,0 +1,57 @@
1
+ import React, { useState } from 'react'
2
+ import {
3
+ Body,
4
+ Button,
5
+ CircleIconButton,
6
+ Flex,
7
+ PbReactPopover,
8
+ } from '../..'
9
+
10
+ const PopoverActionableContent = (props) => {
11
+ const [showPopover, setShowPopover] = useState(false)
12
+
13
+ const handleTogglePopover = () => {
14
+ setShowPopover(!showPopover)
15
+ }
16
+
17
+ const handleShouldClosePopover = (shouldClose) => {
18
+ setShowPopover(!shouldClose)
19
+ }
20
+
21
+ const popoverReference = (
22
+ <CircleIconButton
23
+ icon="info"
24
+ onClick={handleTogglePopover}
25
+ variant="secondary"
26
+ />
27
+ )
28
+
29
+ return (
30
+ <Flex
31
+ orientation="row"
32
+ vertical="center"
33
+ {...props}
34
+ >
35
+ <Body text="Click info for more details" />
36
+ &nbsp;
37
+ <PbReactPopover
38
+ closeOnClick="inside"
39
+ offset
40
+ placement="top"
41
+ reference={popoverReference}
42
+ shouldClosePopover={handleShouldClosePopover}
43
+ show={showPopover}
44
+ {...props}
45
+ >
46
+ <Body textAlign="center">
47
+ <Button
48
+ onClick={() => {alert("Let's do this!")}}
49
+ text="Learn More"
50
+ />
51
+ </Body>
52
+ </PbReactPopover>
53
+ </Flex>
54
+ )
55
+ }
56
+
57
+ export default PopoverActionableContent
@@ -5,6 +5,7 @@ examples:
5
5
  - popover_close: Close Options
6
6
  - popover_z_index: Set Z-Index
7
7
  - popover_scroll_height: Scroll and Height Settings
8
+ - popover_actionable_content: With Actionable Content
8
9
 
9
10
  react:
10
11
  - popover_default: Default
@@ -12,4 +13,4 @@ examples:
12
13
  - popover_close: Close Options
13
14
  - popover_z_index: Set Z-Index
14
15
  - popover_scroll_height: Scroll and Height Settings
15
-
16
+ - popover_actionable_content: With Actionable Content
@@ -3,3 +3,4 @@ export { default as PopoverList } from './_popover_list.jsx'
3
3
  export { default as PopoverClose } from './_popover_close.jsx'
4
4
  export { default as PopoverZIndex } from './_popover_z_index.jsx'
5
5
  export { default as PopoverScrollHeight } from './_popover_scroll_height.jsx'
6
+ export { default as PopoverActionableContent } from './_popover_actionable_content.jsx'
@@ -12,9 +12,9 @@ const PopoverTest = () => {
12
12
  }
13
13
 
14
14
  const popoverReference = (
15
- <Button onClick={togglePopover}
15
+ <Button onClick={togglePopover}
16
16
  text="Click Me"
17
- />
17
+ />
18
18
  );
19
19
  return (
20
20
  <PbReactPopover
@@ -34,9 +34,9 @@ const PopoverTestZIndex = () => {
34
34
  }
35
35
 
36
36
  const popoverReference = (
37
- <Button onClick={togglePopover}
37
+ <Button onClick={togglePopover}
38
38
  text="Click Me"
39
- />
39
+ />
40
40
  );
41
41
  return (
42
42
  <PbReactPopover
@@ -58,9 +58,9 @@ const PopoverTestHeight = () => {
58
58
  }
59
59
 
60
60
  const popoverReference = (
61
- <Button onClick={togglePopover}
61
+ <Button onClick={togglePopover}
62
62
  text="Click Me"
63
- />
63
+ />
64
64
  );
65
65
  return (
66
66
  <PbReactPopover
@@ -75,7 +75,7 @@ const PopoverTestHeight = () => {
75
75
  )
76
76
  };
77
77
 
78
- //Test Popover with click to close 'anywhere'
78
+ //Test Popover with click to close 'anywhere'
79
79
  const PopoverTestClicktoClose = () => {
80
80
  const [mockState, setMockState] = React.useState(false)
81
81
  const togglePopover = () => {
@@ -86,9 +86,9 @@ const PopoverTestClicktoClose = () => {
86
86
  }
87
87
 
88
88
  const popoverReference = (
89
- <Button onClick={togglePopover}
89
+ <Button onClick={togglePopover}
90
90
  text="Click Me"
91
- />
91
+ />
92
92
  );
93
93
  return (
94
94
  <PbReactPopover
@@ -103,7 +103,7 @@ const PopoverTestClicktoClose = () => {
103
103
  )
104
104
  };
105
105
 
106
- //Test Popover with click to close 'inside'
106
+ //Test Popover with click to close 'inside'
107
107
  const PopoverTestClicktoClose2 = () => {
108
108
  const [mockState, setMockState] = React.useState(false)
109
109
  const togglePopover = () => {
@@ -114,9 +114,9 @@ const PopoverTestClicktoClose2 = () => {
114
114
  }
115
115
 
116
116
  const popoverReference = (
117
- <Button onClick={togglePopover}
117
+ <Button onClick={togglePopover}
118
118
  text="Click Me"
119
- />
119
+ />
120
120
  );
121
121
  return (
122
122
  <PbReactPopover
@@ -131,7 +131,7 @@ const PopoverTestClicktoClose2 = () => {
131
131
  )
132
132
  };
133
133
 
134
- //Test Popover with click to close 'outside'
134
+ //Test Popover with click to close 'outside'
135
135
  const PopoverTestClicktoClose3 = () => {
136
136
  const [mockState, setMockState] = React.useState(false)
137
137
  const togglePopover = () => {
@@ -142,9 +142,9 @@ const PopoverTestClicktoClose3 = () => {
142
142
  }
143
143
 
144
144
  const popoverReference = (
145
- <Button onClick={togglePopover}
145
+ <Button onClick={togglePopover}
146
146
  text="Click Me"
147
- />
147
+ />
148
148
  );
149
149
  return (
150
150
  <PbReactPopover
@@ -165,7 +165,7 @@ const PopoverTestClicktoClose3 = () => {
165
165
  const btn = screen.getByText(/click me/i)
166
166
  fireEvent.click(btn);
167
167
  const kit = screen.getByText("Click Anywhere");
168
- expect(kit).toBeInTheDocument();
168
+ expect(kit).toBeInTheDocument();
169
169
  });
170
170
 
171
171
  test("renders Popover with z index", () => {
@@ -173,7 +173,7 @@ const PopoverTestClicktoClose3 = () => {
173
173
  const btn = screen.getByText(/click me/i)
174
174
  fireEvent.click(btn);
175
175
  const kit = screen.getByText("Click Anywhere");
176
- expect(kit).toHaveClass("pb_popover_body z_index_3");
176
+ expect(kit).toHaveClass("pb_popover_body z_index_3");
177
177
  });
178
178
 
179
179
  test("renders Popover with max height and max width", () => {
@@ -181,42 +181,40 @@ const PopoverTestClicktoClose3 = () => {
181
181
  const btn = screen.getByText(/click me/i)
182
182
  fireEvent.click(btn);
183
183
  const kit = screen.getByText("Click Anywhere");
184
- expect(kit).toHaveClass("pb_popover_body max_width_240px overflow_handling");
184
+ expect(kit).toHaveClass("pb_popover_body max_width_240px overflow_handling");
185
185
  });
186
186
 
187
- test("closes Popover on click anywhere", () => {
187
+ test("closes Popover on click anywhere", async () => {
188
188
  render(<PopoverTestClicktoClose data={{ testid: testId}}/>)
189
189
  const btn = screen.getByText(/click me/i)
190
190
  fireEvent.click(btn);
191
191
  const kit = screen.getByText("Click Anywhere");
192
- expect(kit).toBeInTheDocument();
193
- fireEvent.click(kit);
194
-
195
- expect(kit).not.toBeInTheDocument();
192
+ expect(kit).toBeInTheDocument();
193
+ fireEvent.click(document.body);
196
194
 
195
+ expect(kit).not.toBeInTheDocument;
197
196
  });
198
197
 
199
- test("closes Popover on click inside", () => {
198
+ test("closes Popover on click inside", async () => {
200
199
  render(<PopoverTestClicktoClose2 data={{ testid: testId}}/>)
201
200
  const btn = screen.getByText(/click me/i)
202
201
  fireEvent.click(btn);
203
202
  const kit = screen.getByText("Click Inside");
204
- expect(kit).toBeInTheDocument();
203
+ expect(kit).toBeInTheDocument();
205
204
  fireEvent.click(kit);
206
-
207
- expect(kit).not.toBeInTheDocument();
208
205
 
206
+ expect(kit).not.toBeInTheDocument;
209
207
  });
210
208
 
211
- test("closes Popover on click outside", () => {
209
+ test("closes Popover on click outside", async () => {
212
210
  render(<PopoverTestClicktoClose3 data={{ testid: testId}}/>)
213
211
  const btn = screen.getByText(/click me/i)
214
212
  fireEvent.click(btn);
215
213
  const kit = screen.getByText("Click Outside");
216
- expect(kit).toBeInTheDocument();
214
+ expect(kit).toBeInTheDocument();
217
215
  fireEvent.click(kit);
218
- expect(kit).toBeInTheDocument();
216
+ expect(kit).toBeInTheDocument();
219
217
  fireEvent.click(btn);
220
- expect(kit).not.toBeInTheDocument();
221
218
 
219
+ expect(kit).not.toBeInTheDocument;
222
220
  });
@@ -20,6 +20,7 @@ type TableProps = {
20
20
  singleLine?: boolean,
21
21
  size?: "sm" | "md" | "lg",
22
22
  sticky?: boolean,
23
+ striped?: boolean,
23
24
  verticalBorder?: boolean,
24
25
  } & GlobalProps
25
26
 
@@ -40,6 +41,7 @@ const Table = (props: TableProps) => {
40
41
  singleLine = false,
41
42
  size = 'sm',
42
43
  sticky = false,
44
+ striped = false,
43
45
  verticalBorder = false,
44
46
  } = props
45
47
 
@@ -70,6 +72,7 @@ const Table = (props: TableProps) => {
70
72
  'single-line': singleLine,
71
73
  'no-hover': disableHover,
72
74
  'sticky-header': sticky,
75
+ 'striped': striped,
73
76
  },
74
77
  globalProps(props),
75
78
  tableCollapseCss,
@@ -0,0 +1,48 @@
1
+ <%= pb_rails("table", props: { size: "sm", striped: true }) do %>
2
+ <thead>
3
+ <tr>
4
+ <th>Column 1</th>
5
+ <th>Column 2</th>
6
+ <th>Column 3</th>
7
+ <th>Column 4</th>
8
+ <th>Column 5</th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <tr>
13
+ <td>Value 1</td>
14
+ <td>Value 2</td>
15
+ <td>Value 3</td>
16
+ <td>Value 4</td>
17
+ <td>Value 5</td>
18
+ </tr>
19
+ <tr>
20
+ <td>Value 1</td>
21
+ <td>Value 2</td>
22
+ <td>Value 3</td>
23
+ <td>Value 4</td>
24
+ <td>Value 5</td>
25
+ </tr>
26
+ <tr>
27
+ <td>Value 1</td>
28
+ <td>Value 2</td>
29
+ <td>Value 3</td>
30
+ <td>Value 4</td>
31
+ <td>Value 5</td>
32
+ </tr>
33
+ <tr>
34
+ <td>Value 1</td>
35
+ <td>Value 2</td>
36
+ <td>Value 3</td>
37
+ <td>Value 4</td>
38
+ <td>Value 5</td>
39
+ </tr>
40
+ <tr>
41
+ <td>Value 1</td>
42
+ <td>Value 2</td>
43
+ <td>Value 3</td>
44
+ <td>Value 4</td>
45
+ <td>Value 5</td>
46
+ </tr>
47
+ </tbody>
48
+ <% end %>