playbook_ui 15.1.0.pre.rc.4 → 15.1.0.pre.rc.5

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +12 -11
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +7 -7
  4. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +7 -2
  5. data/app/pb_kits/playbook/pb_contact/_contact.tsx +5 -0
  6. data/app/pb_kits/playbook/pb_contact/contact.rb +4 -0
  7. data/app/pb_kits/playbook/pb_contact/contact.test.js +21 -1
  8. data/app/pb_kits/playbook/pb_contact/docs/_contact_default.html.erb +16 -1
  9. data/app/pb_kits/playbook/pb_contact/docs/_contact_default.jsx +15 -0
  10. data/app/pb_kits/playbook/pb_contact/docs/_contact_default.md +5 -0
  11. data/app/pb_kits/playbook/pb_contact/docs/_contact_with_detail.html.erb +6 -0
  12. data/app/pb_kits/playbook/pb_contact/docs/_contact_with_detail.jsx +6 -0
  13. data/app/pb_kits/playbook/pb_section_separator/_section_separator.scss +13 -5
  14. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_children.html.erb +23 -0
  15. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_children.jsx +45 -7
  16. data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +4 -1
  17. data/app/pb_kits/playbook/pb_section_separator/section_separator.test.js +165 -0
  18. data/app/pb_kits/playbook/pb_timestamp/_timestamp.tsx +24 -8
  19. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_align.html.erb +0 -10
  20. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_align.jsx +0 -9
  21. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_align.md +1 -0
  22. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default.html.erb +3 -17
  23. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default.jsx +0 -15
  24. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default.md +1 -0
  25. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed.html.erb +0 -2
  26. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed.jsx +0 -2
  27. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed.md +5 -0
  28. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_current_year.html.erb +12 -0
  29. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_current_year.jsx +25 -0
  30. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_current_year.md +1 -0
  31. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_date.html.erb +4 -0
  32. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_date.jsx +17 -0
  33. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_date.md +1 -0
  34. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_time.html.erb +18 -0
  35. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_time.jsx +44 -0
  36. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_time.md +1 -0
  37. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_timezones.html.erb +0 -14
  38. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_timezones.jsx +0 -14
  39. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_timezones.md +1 -0
  40. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_unstyled.html.erb +0 -4
  41. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_unstyled.jsx +0 -4
  42. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated.jsx +0 -1
  43. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated.md +5 -0
  44. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_current_year.html.erb +16 -0
  45. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_current_year.jsx +30 -0
  46. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_current_year.md +1 -0
  47. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_date.html.erb +16 -0
  48. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_date.jsx +30 -0
  49. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_date.md +1 -0
  50. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_time.html.erb +26 -0
  51. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_time.jsx +41 -0
  52. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_time.md +1 -0
  53. data/app/pb_kits/playbook/pb_timestamp/docs/example.yml +18 -6
  54. data/app/pb_kits/playbook/pb_timestamp/docs/index.js +6 -0
  55. data/app/pb_kits/playbook/pb_timestamp/timestamp.rb +29 -7
  56. data/app/pb_kits/playbook/pb_timestamp/timestamp.test.js +69 -4
  57. data/dist/chunks/{_weekday_stacked-YwRTPuBs.js → _weekday_stacked-qrsOsOR9.js} +2 -2
  58. data/dist/chunks/vendor.js +1 -1
  59. data/dist/playbook-doc.js +2 -2
  60. data/dist/playbook.css +1 -1
  61. data/lib/playbook/version.rb +1 -1
  62. metadata +28 -4
  63. data/app/pb_kits/playbook/pb_timestamp/docs/_time_stamp_default.md +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 781c39ad9c1ce4cc93b33c4b8e8c1942922316fba49d5d4041c6bf432fd614e6
4
- data.tar.gz: 4a35169f2420a0a8c7cf62128ceec089057b426d8f1afb4ec1de23199f42c467
3
+ metadata.gz: be07820eae48f55751ee29b773175ce6a997726cfc93fd85c641b0b52e3522ba
4
+ data.tar.gz: b6336435bb6e7682901c6d01b93f3e23d4dbbb4dd693432561528858eeed30ee
5
5
  SHA512:
6
- metadata.gz: ffe7f4d984d663bcacf8250915d4146f1e3c35b124a432cc45e98ed779c9f9ddc92389c2020e76beaa531b23b4cfe9f29e86543f212afc84bcaf8a892549d68a
7
- data.tar.gz: 12e04d9185e482e6938b55252794c988b3b52d5fbcd168ba3d17ada9131e611036f7dc888410c1469a6d50229df70bd70df60ff6a428960af0ff876981f8ec7e
6
+ metadata.gz: f9f46ecb93d48913e5a9dc8758ea1e23bdff305741e4f0a7f0ce00692a098034ccbfba2acc78781df0375281eb092a6a17b8ee6481528ed074b501a9c8cae80c
7
+ data.tar.gz: 7549d29737a7ecfa6acba26b5c622d5ee35d6164961c762012d867f1009539933ba45f4778a7b3c792c315ddc1a648fa1090cb61aee29055068801754a813023
@@ -5,6 +5,7 @@ import { flexRender, Row, Cell } from "@tanstack/react-table"
5
5
  import { GenericObject } from "../../types"
6
6
  import { isChrome } from "../Utilities/BrowserCheck"
7
7
  import { findColumnDefByAccessor } from "../Utilities/ColumnStylingHelper"
8
+ import { getRowColorClass, shouldShowLoadingIndicator } from "../Utilities/RowUtils"
8
9
 
9
10
  import LoadingInline from "../../pb_loading_inline/_loading_inline"
10
11
  import Checkbox from "../../pb_checkbox/_checkbox"
@@ -60,7 +61,7 @@ const TableCellRenderer = ({
60
61
  const cellAlignment = colDef?.columnStyling?.cellAlignment ?? "right"
61
62
  const paddingValue = colDef?.columnStyling?.cellPadding ?? customRowStyle?.cellPadding
62
63
  const paddingClass = paddingValue ? `p_${paddingValue}` : undefined
63
-
64
+
64
65
  return (
65
66
  <td
66
67
  align={cellAlignment}
@@ -132,6 +133,7 @@ export const RegularTableView = ({
132
133
 
133
134
  const columnPinning = table.getState().columnPinning || { left: [] };
134
135
  const columnDefinitions = table.options.meta?.columnDefinitions || [];
136
+
135
137
  // Row pinning
136
138
  function PinnedRow({ row }: { row: Row<any> }) {
137
139
  const customRowStyle = rowStyling?.length > 0 && rowStyling?.find((s: GenericObject) => s?.rowId === row.id);
@@ -144,7 +146,7 @@ export const RegularTableView = ({
144
146
  backgroundColor: customRowStyle?.backgroundColor ? customRowStyle?.backgroundColor : 'white',
145
147
  color: customRowStyle?.fontColor,
146
148
  position: 'sticky',
147
- top:
149
+ top:
148
150
  row.getIsPinned() === 'top'
149
151
  ? `${row.getPinnedIndex() * rowHeight + headerHeight}px`
150
152
  : undefined,
@@ -169,21 +171,20 @@ export const RegularTableView = ({
169
171
  return (
170
172
  <>
171
173
  {pinnedRows && table.getTopRows().map((row: Row<GenericObject>) => (
172
- <PinnedRow key={row.id}
173
- row={row}
174
+ <PinnedRow key={row.id}
175
+ row={row}
174
176
  />
175
177
  ))}
176
178
  {totalRows.map((row: Row<GenericObject>, rowIndex: number) => {
177
- const isExpandable = row.getIsExpanded();
178
179
  const isFirstChildofSubrow = row.depth > 0 && row.index === 0;
179
- const rowHasNoChildren = row.original?.children && !row.original.children.length ? true : false;
180
180
  const numberOfColumns = table.getAllFlatColumns().length;
181
- const isDataLoading = isExpandable && (inlineRowLoading && rowHasNoChildren) && (row.depth < columnDefinitions[0]?.cellAccessors?.length);
182
- const rowBackground = isExpandable && ((!inlineRowLoading && row.getCanExpand()) || (inlineRowLoading && rowHasNoChildren));
183
- const rowColor = row.getIsSelected() ? "bg-row-selection" : rowBackground ? "bg-silver" : "bg-white";
184
181
  const isFirstRegularRow = rowIndex === 0 && !row.getIsPinned();
185
182
  const customRowStyle = rowStyling?.length > 0 && rowStyling?.find((s: GenericObject) => s?.rowId === row.id);
186
183
 
184
+ // Use functions from RowUtils for consistent cell coloring
185
+ const rowColor = getRowColorClass(row, inlineRowLoading || false);
186
+ const isDataLoading = shouldShowLoadingIndicator(row, inlineRowLoading || false, columnDefinitions[0]?.cellAccessors?.length || 0);
187
+
187
188
  return (
188
189
  <React.Fragment key={`${row.index}-${row.id}-${row.depth}-row`}>
189
190
  {isFirstChildofSubrow && subRowHeaders && (
@@ -228,7 +229,7 @@ export const RegularTableView = ({
228
229
 
229
230
  {/* Display LoadingInline if Row Data is querying and there are no children already */}
230
231
  {isDataLoading && (
231
- <tr key={`${row.id}-row`}>
232
+ <tr key={`${row.id}-loading-row`}>
232
233
  <td colSpan={numberOfColumns}
233
234
  style={{ paddingLeft: `${row.depth === 0 ? 0.5 : (row.depth * 2)}em` }}
234
235
  >
@@ -243,4 +244,4 @@ export const RegularTableView = ({
243
244
  );
244
245
  }
245
246
 
246
- export default RegularTableView;
247
+ export default RegularTableView;
@@ -7,6 +7,7 @@ import { GenericObject } from "../../types"
7
7
 
8
8
  import { isChrome } from "../Utilities/BrowserCheck"
9
9
  import { getVirtualizedRowStyle } from "../Utilities/TableContainerStyles"
10
+ import { getRowColorClass } from "../Utilities/RowUtils"
10
11
 
11
12
  import LoadingInline from "../../pb_loading_inline/_loading_inline"
12
13
  import Checkbox from "../../pb_checkbox/_checkbox"
@@ -45,10 +46,10 @@ export const VirtualizedTableView = ({
45
46
 
46
47
  const columnPinning = table.getState().columnPinning || { left: [] };
47
48
  const sortingState = JSON.stringify(table.getState().sorting || []);
48
-
49
+
49
50
  // Store column widths extracted from header
50
51
  const [columnWidths, setColumnWidths] = useState<{[key: string]: string}>({});
51
-
52
+
52
53
  // Function to get header cell widths
53
54
  const getHeaderCellWidths = () => {
54
55
  const widths: {[key: string]: string} = {};
@@ -136,7 +137,7 @@ export const VirtualizedTableView = ({
136
137
  </tr>
137
138
  );
138
139
  }
139
-
140
+
140
141
  // Establish # of Parent Rows (so that Footer count does not include every single row)
141
142
  const topLevelRowCount = table.getRowModel().flatRows.filter((row: Row<GenericObject>) => row.depth === 0).length;
142
143
 
@@ -172,10 +173,9 @@ export const VirtualizedTableView = ({
172
173
 
173
174
  if (item.type === 'row') {
174
175
  const row = item.row;
175
- const isExpandable = row.getIsExpanded();
176
- const rowHasNoChildren = row.original?.children && !row.original.children.length;
177
- const rowBackground = isExpandable && ((!inlineRowLoading && row.getCanExpand()) || (inlineRowLoading && rowHasNoChildren));
178
- const rowColor = row.getIsSelected() ? "bg-row-selection" : rowBackground ? "bg-silver" : "bg-white";
176
+
177
+ // Use the utility function to get consistent row color
178
+ const rowColor = getRowColorClass(row, inlineRowLoading || false);
179
179
 
180
180
  return (
181
181
  <tr
@@ -10,9 +10,14 @@ export const getRowColorClass = (
10
10
  ): string => {
11
11
  const isExpandable = row.getIsExpanded();
12
12
  const rowHasNoChildren = row.original?.children && !row.original.children.length ? true : false;
13
- const rowBackground = isExpandable && ((!inlineRowLoading && row.getCanExpand()) || (inlineRowLoading && rowHasNoChildren));
14
13
 
15
- return row.getIsSelected() ? "bg-row-selection" : rowBackground ? "bg-silver" : "bg-white";
14
+ // Check if row can expand or is currently expanded
15
+ const shouldShowExpandedBackground = isExpandable && (
16
+ (!inlineRowLoading && row.getCanExpand()) ||
17
+ (inlineRowLoading && (rowHasNoChildren || row.getCanExpand()))
18
+ );
19
+
20
+ return row.getIsSelected() ? "bg-row-selection" : shouldShowExpandedBackground ? "bg-silver" : "bg-white";
16
21
  }
17
22
 
18
23
  /**
@@ -17,6 +17,7 @@ const contactTypeMap: { [key: string]: string } = {
17
17
  'work': 'phone-office',
18
18
  'work-cell': 'phone-laptop',
19
19
  'wrong-phone': 'phone-slash',
20
+ 'international': 'globe',
20
21
  }
21
22
 
22
23
  const envelopeIcon = getAllIcons()["envelope"].icon as unknown as { [key: string]: SVGElement }
@@ -24,6 +25,10 @@ const envelopeIcon = getAllIcons()["envelope"].icon as unknown as { [key: string
24
25
  const formatContact = (contactString: string, contactType: string) => {
25
26
  if (contactType === 'email') return contactString
26
27
 
28
+ // International phone numbers are unformatted
29
+ if (contactType === 'international') return contactString
30
+
31
+ // Format US numbers
27
32
  const cleaned = contactString.replace(/\D/g, '')
28
33
  const phoneNumber = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/)
29
34
 
@@ -29,6 +29,8 @@ module Playbook
29
29
  "phone-slash"
30
30
  when "extension"
31
31
  "phone-plus"
32
+ when "international"
33
+ "globe"
32
34
  else # "unknown" || "other"
33
35
  "phone"
34
36
  end
@@ -39,6 +41,8 @@ module Playbook
39
41
  contact_value
40
42
  elsif contact_type == "extension" && contact_value.match(/^\d{4}$/)
41
43
  contact_value
44
+ elsif contact_type == "international"
45
+ contact_value
42
46
  else
43
47
  number_to_phone(formatted_value, area_code: true)
44
48
  end
@@ -66,6 +66,12 @@ test('returns correct icon', () => {
66
66
  contactValue="1234"
67
67
  data={{ testid: 'test-extension' }}
68
68
  />
69
+ <Contact
70
+ contactDetail="International"
71
+ contactType="international"
72
+ contactValue="+44 20 7946 0958"
73
+ data={{ testid: 'test-international' }}
74
+ />
69
75
  <Contact
70
76
  contactDetail=""
71
77
  contactType=""
@@ -83,10 +89,11 @@ test('returns correct icon', () => {
83
89
  expect(screen.getByTestId('test-wrong-phone').querySelector('.pb_custom_icon')).toBeInTheDocument()
84
90
  expect(screen.getByTestId('test-wrong-type').querySelector('.pb_custom_icon')).toBeInTheDocument()
85
91
  expect(screen.getByTestId('test-extension').querySelector('.pb_custom_icon')).toBeInTheDocument()
92
+ expect(screen.getByTestId('test-international').querySelector('.pb_custom_icon')).toBeInTheDocument()
86
93
  expect(screen.getByTestId('test-empty').querySelector('.pb_custom_icon')).toBeInTheDocument()
87
94
  })
88
95
 
89
- test("not compliant values return null in phone related contact types", () => {
96
+ test("not compliant values return null in US phone related contact types", () => {
90
97
  const notCompliantValues = [
91
98
  "349-185-998223",
92
99
  "349-1858",
@@ -129,3 +136,16 @@ test("not compliant values return null in phone related contact types", () => {
129
136
  )
130
137
  })
131
138
  })
139
+
140
+ test('international contact type preserves original format', () => {
141
+ render(
142
+ <Contact
143
+ contactType="international"
144
+ contactValue="+44 20 7946 0958"
145
+ data={{ testid: 'test-international-format' }}
146
+ />
147
+ )
148
+
149
+ const kit = screen.getByTestId('test-international-format')
150
+ expect(kit).toHaveTextContent('+44 20 7946 0958')
151
+ })
@@ -13,7 +13,7 @@
13
13
  }) %>
14
14
 
15
15
  <%= pb_rails("contact", props: {
16
- contact_type: "wrong number",
16
+ contact_type: "work",
17
17
  contact_value: "3245627482",
18
18
  }) %>
19
19
 
@@ -21,3 +21,18 @@
21
21
  contact_type: "work-cell",
22
22
  contact_value: "349-185-9988",
23
23
  }) %>
24
+
25
+ <%= pb_rails("contact", props: {
26
+ contact_type: "wrong-phone",
27
+ contact_value: "2124396666",
28
+ }) %>
29
+
30
+ <%= pb_rails("contact", props: {
31
+ contact_type: "extension",
32
+ contact_value: "1233",
33
+ }) %>
34
+
35
+ <%= pb_rails("contact", props: {
36
+ contact_type: "international",
37
+ contact_value: "+44 7700 900461",
38
+ }) %>
@@ -28,6 +28,21 @@ const ContactDefault = (props) => {
28
28
  contactValue="3245627482"
29
29
  {...props}
30
30
  />
31
+ <Contact
32
+ contactType="wrong-phone"
33
+ contactValue="2124396666"
34
+ {...props}
35
+ />
36
+ <Contact
37
+ contactType='extension'
38
+ contactValue="1234"
39
+ {...props}
40
+ />
41
+ <Contact
42
+ contactType="international"
43
+ contactValue="+44 7700 900461"
44
+ {...props}
45
+ />
31
46
  </div>
32
47
  )
33
48
  }
@@ -0,0 +1,5 @@
1
+ The Contact kit automatically formats US phone numbers when the `contactType` / `contact_type` is one of: `home` (default), `work`, `cell`, `work-cell`, `wrong-phone`.
2
+
3
+ - Use `email` to display emails.
4
+ - Use `international` to display International phone numbers exactly as provided (no formatting applied).
5
+ - Use `extension` to display four digit phone extensions.
@@ -26,3 +26,9 @@
26
26
  contact_value: "1233",
27
27
  contact_detail: "Ext",
28
28
  }) %>
29
+
30
+ <%= pb_rails("contact", props: {
31
+ contact_type: "international",
32
+ contact_value: "+44 7700 900461",
33
+ contact_detail: "International",
34
+ }) %>
@@ -33,6 +33,12 @@ const ContactDefault = (props) => {
33
33
  contactValue="1234"
34
34
  {...props}
35
35
  />
36
+ <Contact
37
+ contactDetail="International"
38
+ contactType="international"
39
+ contactValue="+44 7700 900461"
40
+ {...props}
41
+ />
36
42
  </div>
37
43
  )
38
44
  }
@@ -53,10 +53,13 @@ $section_colors_dark: (
53
53
  .pb_section_separator_vertical {
54
54
  margin-left: $space_xs;
55
55
  margin-right: $space_xs;
56
+ flex-direction: column;
56
57
  &::before {
57
- display: none;
58
+ flex: 1;
59
+ @include section_separator_vertical(false);
58
60
  }
59
61
  &::after {
62
+ flex: 1;
60
63
  @include section_separator_vertical(false);
61
64
  }
62
65
  }
@@ -87,7 +90,7 @@ $section_colors_dark: (
87
90
  background: none;
88
91
  }
89
92
  &.pb_section_separator_vertical {
90
- &::after {
93
+ &::before, &::after {
91
94
  border: 1px dashed $color_value;
92
95
  background: none;
93
96
  }
@@ -106,7 +109,7 @@ $section_colors_dark: (
106
109
  }
107
110
 
108
111
  &.pb_section_separator_vertical {
109
- &::after {
112
+ &::before, &::after {
110
113
  @include section_separator_vertical(true);
111
114
  }
112
115
  }
@@ -115,6 +118,11 @@ $section_colors_dark: (
115
118
  &::before, &::after {
116
119
  @include section_separator_dashed(true);
117
120
  }
121
+ &.pb_section_separator_vertical {
122
+ &::before, &::after {
123
+ @include section_separator_dashed(true);
124
+ }
125
+ }
118
126
  }
119
127
  }
120
128
 
@@ -126,7 +134,7 @@ $section_colors_dark: (
126
134
  }
127
135
 
128
136
  &.pb_section_separator_vertical {
129
- &::after {
137
+ &::before, &::after {
130
138
  @include section_separator_vertical(false);
131
139
  background: $color_value;
132
140
  }
@@ -138,7 +146,7 @@ $section_colors_dark: (
138
146
  background: none;
139
147
  }
140
148
  &.pb_section_separator_vertical {
141
- &::after {
149
+ &::before, &::after {
142
150
  border: 1px dashed $color_value;
143
151
  background: none;
144
152
  }
@@ -11,4 +11,27 @@
11
11
  padding_right: "xs"
12
12
  }) %>
13
13
  <% end %>
14
+ <% end %>
15
+
16
+ <%= pb_rails("flex", props: { classname: "flex-container", margin_top: "lg", vertical: "stretch" }) do %>
17
+ <%= pb_rails("body", props: { classname: "flex-item" }) do %>
18
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
19
+ <% end %>
20
+ <%= pb_rails("section_separator", props: { orientation: "vertical" }) do %>
21
+ <%= pb_rails("card", props: {
22
+ border_radius: "rounded",
23
+ justify_content: "center",
24
+ padding: "none"
25
+ }) do %>
26
+ <%= pb_rails("caption", props: {
27
+ text: "TODAY",
28
+ size: "xs",
29
+ padding_left: "xs",
30
+ padding_right: "xs"
31
+ }) %>
32
+ <% end %>
33
+ <% end %>
34
+ <%= pb_rails("body", props: { classname: "flex-item" }) do %>
35
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
36
+ <% end %>
14
37
  <% end %>
@@ -2,8 +2,25 @@ import React from 'react'
2
2
  import Card from '../../pb_card/_card'
3
3
  import Caption from '../../pb_caption/_caption'
4
4
  import SectionSeparator from '../../pb_section_separator/_section_separator'
5
+ import Flex from '../../pb_flex/_flex'
6
+ import FlexItem from '../../pb_flex/_flex_item'
5
7
 
6
- const children = (
8
+ const childrenHorizontal = (
9
+ <Card
10
+ borderRadius="rounded"
11
+ justifyContent="center"
12
+ padding="none"
13
+ >
14
+ <Caption
15
+ paddingLeft="xs"
16
+ paddingRight="xs"
17
+ size="xs"
18
+ text="TODAY"
19
+ />
20
+ </Card>
21
+ )
22
+
23
+ const childrenVertical = (
7
24
  <Card
8
25
  borderRadius="rounded"
9
26
  justifyContent="center"
@@ -20,12 +37,33 @@ const children = (
20
37
 
21
38
  const SectionSeparatorChildren = (props) => {
22
39
  return (
23
- <SectionSeparator
24
- {...props}
25
- lineStyle='dashed'
26
- >
27
- {children}
28
- </SectionSeparator>
40
+ <>
41
+ <SectionSeparator
42
+ {...props}
43
+ lineStyle='dashed'
44
+ >
45
+ {childrenHorizontal}
46
+ </SectionSeparator>
47
+ <Flex
48
+ inline="flex-container"
49
+ marginTop="lg"
50
+ vertical="stretch"
51
+ >
52
+ <FlexItem>
53
+ {'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua'}
54
+ </FlexItem>
55
+ <SectionSeparator
56
+ orientation="vertical"
57
+ {...props}
58
+ >
59
+ {childrenVertical}
60
+ </SectionSeparator>
61
+ <FlexItem>
62
+ {'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua'}
63
+ </FlexItem>
64
+ </Flex>
65
+ </>
66
+
29
67
  )
30
68
  }
31
69
 
@@ -7,7 +7,10 @@
7
7
  <% end %>
8
8
  <% end %>
9
9
  <% if object.orientation === 'vertical' %>
10
- <%= pb_rails("flex", props: { orientation: "column"}) do %>
10
+ <% if content %>
11
+ <%= content %>
12
+ <% elsif object.text %>
13
+ <span><%= pb_rails("caption", props: { text: object.text }) %></span>
11
14
  <% end %>
12
15
  <%end%>
13
16
  <% end %>
@@ -0,0 +1,165 @@
1
+ import React from 'react'
2
+ import { render, screen } from '../utilities/test-utils'
3
+
4
+ import SectionSeparator from './_section_separator'
5
+
6
+ const testId = "section-separator-kit"
7
+
8
+ describe("Section Separator Kit", () => {
9
+ test("renders basic section separator with default props", () => {
10
+ render(
11
+ <SectionSeparator
12
+ data={{ testid: testId }}
13
+ />
14
+ )
15
+
16
+ const kit = screen.getByTestId(testId)
17
+ expect(kit).toHaveClass("pb_section_separator_kit pb_section_separator_card pb_section_separator_horizontal pb_section_separator_solid pb_section_separator_color_default")
18
+ })
19
+
20
+ test("renders with text prop", () => {
21
+ const text = "Section Title"
22
+ render(
23
+ <SectionSeparator
24
+ data={{ testid: testId }}
25
+ text={text}
26
+ />
27
+ )
28
+
29
+ const kit = screen.getByTestId(testId)
30
+ const textElement = screen.getByText(text)
31
+
32
+ expect(kit).toHaveClass("pb_section_separator_kit")
33
+ expect(textElement).toBeInTheDocument()
34
+ })
35
+
36
+ test("renders with children", () => {
37
+ const childText = "Custom Content"
38
+ render(
39
+ <SectionSeparator
40
+ data={{ testid: testId }}
41
+ >
42
+ <span>{childText}</span>
43
+ </SectionSeparator>
44
+ )
45
+
46
+ const kit = screen.getByTestId(testId)
47
+ const childElement = screen.getByText(childText)
48
+
49
+ expect(kit).toHaveClass("pb_section_separator_kit")
50
+ expect(childElement).toBeInTheDocument()
51
+ })
52
+
53
+ test("renders vertical orientation", () => {
54
+ render(
55
+ <SectionSeparator
56
+ data={{ testid: testId }}
57
+ orientation="vertical"
58
+ />
59
+ )
60
+
61
+ const kit = screen.getByTestId(testId)
62
+ expect(kit).toHaveClass("pb_section_separator_kit pb_section_separator_card pb_section_separator_vertical pb_section_separator_solid pb_section_separator_color_default")
63
+ })
64
+
65
+ test("renders background variant", () => {
66
+ render(
67
+ <SectionSeparator
68
+ data={{ testid: testId }}
69
+ variant="background"
70
+ />
71
+ )
72
+
73
+ const kit = screen.getByTestId(testId)
74
+ expect(kit).toHaveClass("pb_section_separator_kit pb_section_separator_background pb_section_separator_horizontal pb_section_separator_solid pb_section_separator_color_default")
75
+ })
76
+
77
+ test("renders dashed line style", () => {
78
+ render(
79
+ <SectionSeparator
80
+ data={{ testid: testId }}
81
+ lineStyle="dashed"
82
+ />
83
+ )
84
+
85
+ const kit = screen.getByTestId(testId)
86
+ expect(kit).toHaveClass("pb_section_separator_kit pb_section_separator_card pb_section_separator_horizontal pb_section_separator_dashed pb_section_separator_color_default")
87
+ })
88
+
89
+ test("renders primary color", () => {
90
+ render(
91
+ <SectionSeparator
92
+ color="primary"
93
+ data={{ testid: testId }}
94
+ />
95
+ )
96
+
97
+ const kit = screen.getByTestId(testId)
98
+ expect(kit).toHaveClass("pb_section_separator_kit pb_section_separator_card pb_section_separator_horizontal pb_section_separator_solid pb_section_separator_color_primary")
99
+ })
100
+
101
+ test("renders dark mode", () => {
102
+ render(
103
+ <SectionSeparator
104
+ dark
105
+ data={{ testid: testId }}
106
+ />
107
+ )
108
+
109
+ const kit = screen.getByTestId(testId)
110
+ expect(kit).toHaveClass("pb_section_separator_kit pb_section_separator_card pb_section_separator_horizontal pb_section_separator_solid pb_section_separator_color_default")
111
+ })
112
+
113
+ test("renders with custom className", () => {
114
+ const customClass = "custom-class"
115
+ render(
116
+ <SectionSeparator
117
+ className={customClass}
118
+ data={{ testid: testId }}
119
+ />
120
+ )
121
+
122
+ const kit = screen.getByTestId(testId)
123
+ expect(kit).toHaveClass("pb_section_separator_kit pb_section_separator_card pb_section_separator_horizontal pb_section_separator_solid pb_section_separator_color_default custom-class")
124
+ })
125
+
126
+ test("renders vertical with children", () => {
127
+ const childText = "Vertical Content"
128
+ render(
129
+ <SectionSeparator
130
+ data={{ testid: testId }}
131
+ orientation="vertical"
132
+ >
133
+ <span>{childText}</span>
134
+ </SectionSeparator>
135
+ )
136
+
137
+ const kit = screen.getByTestId(testId)
138
+ const childElement = screen.getByText(childText)
139
+
140
+ expect(kit).toHaveClass("pb_section_separator_kit pb_section_separator_card pb_section_separator_vertical pb_section_separator_solid pb_section_separator_color_default")
141
+ expect(childElement).toBeInTheDocument()
142
+ })
143
+
144
+ test("renders all props combined", () => {
145
+ const text = "Combined Props"
146
+ render(
147
+ <SectionSeparator
148
+ color="primary"
149
+ dark
150
+ data={{ testid: testId }}
151
+ lineStyle="dashed"
152
+ orientation="vertical"
153
+ variant="background"
154
+ >
155
+ <span>{text}</span>
156
+ </SectionSeparator>
157
+ )
158
+
159
+ const kit = screen.getByTestId(testId)
160
+ const childElement = screen.getByText(text)
161
+
162
+ expect(kit).toHaveClass("pb_section_separator_kit pb_section_separator_background pb_section_separator_vertical pb_section_separator_dashed pb_section_separator_color_primary")
163
+ expect(childElement).toBeInTheDocument()
164
+ })
165
+ })