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
@@ -0,0 +1,16 @@
1
+ <%= pb_rails("timestamp", props: {
2
+ timestamp: DateTime.now,
3
+ variant: "updated",
4
+ show_user: true,
5
+ show_current_year: true,
6
+ text: "Maricris Nonato"
7
+ }) %>
8
+
9
+ <br>
10
+
11
+ <%= pb_rails("timestamp", props: {
12
+ timestamp: DateTime.now,
13
+ variant: "updated",
14
+ show_user: false,
15
+ show_current_year: true
16
+ }) %>
@@ -0,0 +1,30 @@
1
+ import React from 'react'
2
+ import Timestamp from '../_timestamp'
3
+
4
+ const todaysDate = new Date()
5
+
6
+ const TimestampUpdatedShowCurrentYear = (props) => {
7
+ return (
8
+ <div>
9
+ <Timestamp
10
+ showCurrentYear
11
+ showUser
12
+ text="Maricris Nonato"
13
+ timestamp={todaysDate}
14
+ variant="updated"
15
+ {...props}
16
+ />
17
+
18
+ <br />
19
+
20
+ <Timestamp
21
+ showCurrentYear
22
+ timestamp={todaysDate}
23
+ variant="updated"
24
+ {...props}
25
+ />
26
+ </div>
27
+ )
28
+ }
29
+
30
+ export default TimestampUpdatedShowCurrentYear
@@ -0,0 +1 @@
1
+ The `updated` variant can also be used in conjunction with the `showCurrentYear`/`show_current_year` prop to show the year even if it is the current year.
@@ -0,0 +1,16 @@
1
+ <%= pb_rails("timestamp", props: {
2
+ timestamp: DateTime.now,
3
+ variant: "updated",
4
+ show_user: true,
5
+ show_date: false,
6
+ text: "Maricris Nonato"
7
+ }) %>
8
+
9
+ <br>
10
+
11
+ <%= pb_rails("timestamp", props: {
12
+ timestamp: DateTime.now,
13
+ variant: "updated",
14
+ show_user: false,
15
+ show_date: false
16
+ }) %>
@@ -0,0 +1,30 @@
1
+ import React from 'react'
2
+ import Timestamp from '../_timestamp'
3
+
4
+ const todaysDate = new Date()
5
+
6
+ const TimestampUpdatedShowDate = (props) => {
7
+ return (
8
+ <div>
9
+ <Timestamp
10
+ showDate={false}
11
+ showUser
12
+ text="Maricris Nonato"
13
+ timestamp={todaysDate}
14
+ variant="updated"
15
+ {...props}
16
+ />
17
+
18
+ <br />
19
+
20
+ <Timestamp
21
+ showDate={false}
22
+ timestamp={todaysDate}
23
+ variant="updated"
24
+ {...props}
25
+ />
26
+ </div>
27
+ )
28
+ }
29
+
30
+ export default TimestampUpdatedShowDate
@@ -0,0 +1 @@
1
+ The `updated` variant can also be used in conjunction with the `showDate`/`show_date` prop. This prop is set to true by default but can be set to false to hide the date.
@@ -0,0 +1,26 @@
1
+ <%= pb_rails("timestamp", props: {
2
+ timestamp: DateTime.now,
3
+ variant: "updated",
4
+ show_user: true,
5
+ show_time: false,
6
+ text: "Maricris Nonato"
7
+ }) %>
8
+
9
+ <br>
10
+
11
+ <%= pb_rails("timestamp", props: {
12
+ timestamp: DateTime.now,
13
+ variant: "updated",
14
+ show_user: false,
15
+ show_time: false
16
+ }) %>
17
+
18
+ <br>
19
+
20
+ <%= pb_rails("timestamp", props: {
21
+ timestamp: DateTime.now,
22
+ variant: "updated",
23
+ show_current_year: true,
24
+ show_user: false,
25
+ show_time: false
26
+ }) %>
@@ -0,0 +1,41 @@
1
+ import React from 'react'
2
+ import Timestamp from '../_timestamp'
3
+
4
+ const todaysDate = new Date()
5
+
6
+ const TimestampUpdatedShowTime = (props) => {
7
+ return (
8
+ <div>
9
+ <Timestamp
10
+ showTime={false}
11
+ showUser
12
+ text="Maricris Nonato"
13
+ timestamp={todaysDate}
14
+ variant="updated"
15
+ {...props}
16
+ />
17
+
18
+ <br />
19
+
20
+ <Timestamp
21
+ showTime={false}
22
+ timestamp={todaysDate}
23
+ variant="updated"
24
+ {...props}
25
+ />
26
+
27
+ <br />
28
+
29
+ <Timestamp
30
+ showCurrentYear
31
+ showTime={false}
32
+ timestamp={todaysDate}
33
+ variant="updated"
34
+ {...props}
35
+ />
36
+
37
+ </div>
38
+ )
39
+ }
40
+
41
+ export default TimestampUpdatedShowTime
@@ -0,0 +1 @@
1
+ The `updated` variant can also be used in conjunction with the `showTime`/`show_time` prop. This prop is set to true by default but can be set to false to hide the time. This can also be used in conjunction with `showCurrentYear`/`show_current_year` to show the year even if it is the current year.
@@ -2,18 +2,30 @@ examples:
2
2
 
3
3
  rails:
4
4
  - timestamp_default: Default
5
+ - timestamp_show_date: Hide Date
6
+ - timestamp_show_time: Hide Time
7
+ - timestamp_show_current_year: Show Current Year
8
+ - timestamp_timezones: Show Timezones
5
9
  - timestamp_align: Alignments
6
- - timestamp_timezones: Timezones
7
- - timestamp_updated: Last Updated by
8
- - timestamp_elapsed: Time Ago
10
+ - timestamp_elapsed: Time Ago (Elapsed Variant)
11
+ - timestamp_updated: Last Updated by (Updated Variant)
12
+ - timestamp_updated_show_current_year: Last Updated by (Updated Variant) - Show Current Year
13
+ - timestamp_updated_show_date: Last Updated by (Updated Variant) - Hide Date
14
+ - timestamp_updated_show_time: Last Updated by (Updated Variant) - Hide Time
9
15
  - timestamp_unstyled: Unstyled
10
16
 
11
17
  react:
12
18
  - timestamp_default: Default
19
+ - timestamp_show_date: Hide Date
20
+ - timestamp_show_time: Hide Time
21
+ - timestamp_show_current_year: Show Current Year
22
+ - timestamp_timezones: Show Timezones
13
23
  - timestamp_align: Alignments
14
- - timestamp_timezones: Timezones
15
- - timestamp_updated: Last Updated by
16
- - timestamp_elapsed: Time Ago
24
+ - timestamp_elapsed: Time Ago (Elapsed Variant)
25
+ - timestamp_updated: Last Updated by (Updated Variant)
26
+ - timestamp_updated_show_current_year: Last Updated by (Updated Variant) - Show Current Year
27
+ - timestamp_updated_show_date: Last Updated by (Updated Variant) - Hide Date
28
+ - timestamp_updated_show_time: Last Updated by (Updated Variant) - Hide Time
17
29
  - timestamp_unstyled: Unstyled
18
30
 
19
31
  swift:
@@ -4,3 +4,9 @@ export { default as TimestampTimezones } from './_timestamp_timezones.jsx'
4
4
  export { default as TimestampUpdated } from './_timestamp_updated.jsx'
5
5
  export { default as TimestampElapsed } from './_timestamp_elapsed.jsx'
6
6
  export { default as TimestampUnstyled } from './_timestamp_unstyled.jsx'
7
+ export { default as TimestampShowDate } from './_timestamp_show_date.jsx'
8
+ export { default as TimestampShowTime } from './_timestamp_show_time.jsx'
9
+ export { default as TimestampShowCurrentYear } from './_timestamp_show_current_year.jsx'
10
+ export { default as TimestampUpdatedShowCurrentYear } from './_timestamp_updated_show_current_year.jsx'
11
+ export { default as TimestampUpdatedShowDate } from './_timestamp_updated_show_date.jsx'
12
+ export { default as TimestampUpdatedShowTime } from './_timestamp_updated_show_time.jsx'
@@ -14,8 +14,12 @@ module Playbook
14
14
  default: "left"
15
15
  prop :hide_updated, type: Playbook::Props::Boolean,
16
16
  default: false
17
+ prop :show_current_year, type: Playbook::Props::Boolean,
18
+ default: false
17
19
  prop :show_date, type: Playbook::Props::Boolean,
18
20
  default: true
21
+ prop :show_time, type: Playbook::Props::Boolean,
22
+ default: true
19
23
  prop :show_timezone, type: Playbook::Props::Boolean,
20
24
  default: false
21
25
  prop :show_user, type: Playbook::Props::Boolean,
@@ -50,14 +54,22 @@ module Playbook
50
54
  when "elapsed"
51
55
  format_elapsed_string
52
56
  else
53
- show_date ? datetime_or_text : format_time_string
57
+ if show_date && show_time
58
+ datetime_or_text
59
+ elsif show_date && !show_time
60
+ timestamp ? format_date_string : text
61
+ elsif !show_date && show_time
62
+ format_time_string
63
+ else
64
+ text
65
+ end
54
66
  end
55
67
  end
56
68
 
57
69
  private
58
70
 
59
71
  def format_year_string
60
- pb_date_time.to_year != DateTime.now.year.to_s ? ", #{pb_date_time.to_year}" : ""
72
+ pb_date_time.to_year != DateTime.now.year.to_s || show_current_year ? ", #{pb_date_time.to_year}" : ""
61
73
  end
62
74
 
63
75
  def format_time_string
@@ -73,14 +85,24 @@ module Playbook
73
85
  end
74
86
 
75
87
  def format_datetime_string
76
- "#{format_date_string} &middot; #{format_time_string}".html_safe
88
+ if show_time
89
+ "#{format_date_string} &middot; #{format_time_string}".html_safe
90
+ else
91
+ format_date_string
92
+ end
77
93
  end
78
94
 
79
95
  def format_updated_string
80
- user_string = show_user ? " by #{text}" : ""
81
- datetime_string = " on #{format_date_string} at #{format_time_string}"
82
-
83
- "Last updated#{user_string}#{datetime_string}"
96
+ final_updated_string = []
97
+ final_updated_string << "by #{text}" if show_user && text.present?
98
+ if show_date && !show_time
99
+ final_updated_string << "on #{format_date_string}"
100
+ elsif show_date && show_time
101
+ final_updated_string << "on #{format_date_string} at #{format_time_string}"
102
+ elsif show_time && !show_date
103
+ final_updated_string << "at #{format_time_string}"
104
+ end
105
+ "Last updated #{final_updated_string.join(' ')}"
84
106
  end
85
107
 
86
108
  def format_elapsed_string
@@ -102,7 +102,6 @@ describe("Timestamp Kit", () => {
102
102
  render(
103
103
  <Timestamp
104
104
  data={{ testid: testId }}
105
- showDate={false}
106
105
  showUser
107
106
  text="Maricris Nonato"
108
107
  timestamp={new Date()}
@@ -112,7 +111,7 @@ describe("Timestamp Kit", () => {
112
111
  const kit = screen.getByTestId(testId);
113
112
  const text = kit.querySelector(".pb_caption_kit_xs");
114
113
  expect(text.textContent).toEqual(
115
- "Last updated by Maricris Nonato on Jan 1 at 12:00a"
114
+ "Last updated by Maricris Nonato on Jan 1 at 12:00a"
116
115
  );
117
116
  });
118
117
 
@@ -120,14 +119,13 @@ describe("Timestamp Kit", () => {
120
119
  render(
121
120
  <Timestamp
122
121
  data={{ testid: testId }}
123
- showDate={false}
124
122
  timestamp={new Date()}
125
123
  variant="updated"
126
124
  />
127
125
  );
128
126
  const kit = screen.getByTestId(testId);
129
127
  const text = kit.querySelector(".pb_caption_kit_xs");
130
- expect(text.textContent).toEqual("Last updated on Jan 1 at 12:00a");
128
+ expect(text.textContent).toEqual("Last updated on Jan 1 at 12:00a");
131
129
  });
132
130
 
133
131
  test("renders Timestamp elapsed variant with user", () => {
@@ -162,3 +160,70 @@ describe("Timestamp Kit", () => {
162
160
  expect(text.textContent).toEqual(" a few seconds ago");
163
161
  });
164
162
  });
163
+
164
+ test("default variant: time only when showDate=false", () => {
165
+ render(
166
+ <Timestamp
167
+ data={{ testid: testId }}
168
+ showDate={false}
169
+ showTime
170
+ timestamp={new Date()}
171
+ />
172
+ )
173
+ const text = screen.getByTestId(testId).querySelector(".pb_caption_kit_xs")
174
+ expect(text?.textContent).toEqual("12:00a")
175
+ })
176
+
177
+ test("default variant: date only when showTime=false (no year for current year)", () => {
178
+ render(
179
+ <Timestamp
180
+ data={{ testid: testId }}
181
+ showTime={false}
182
+ timestamp={new Date()}
183
+ />
184
+ )
185
+ const text = screen.getByTestId(testId).querySelector(".pb_caption_kit_xs")
186
+ expect(text?.textContent).toEqual("Jan 1")
187
+ })
188
+
189
+ test("default variant: date only with showCurrentYear=true forces year", () => {
190
+ render(
191
+ <Timestamp
192
+ data={{ testid: testId }}
193
+ showCurrentYear
194
+ showTime={false}
195
+ timestamp={new Date()}
196
+ />
197
+ )
198
+ const text = screen.getByTestId(testId).querySelector(".pb_caption_kit_xs")
199
+ expect(text?.textContent).toEqual("Jan 1, 2020")
200
+ })
201
+
202
+ test('updated variant: "by user" + date only when showDate=true and showTime=false', () => {
203
+ render(
204
+ <Timestamp
205
+ data={{ testid: testId }}
206
+ showTime={false}
207
+ showUser
208
+ text="Maricris Nonato"
209
+ timestamp={new Date()}
210
+ variant="updated"
211
+ />
212
+ )
213
+ const text = screen.getByTestId(testId).querySelector(".pb_caption_kit_xs")
214
+ expect(text?.textContent).toEqual("Last updated by Maricris Nonato on Jan 1")
215
+ })
216
+
217
+ test('updated variant: "at time" only when showDate=false and showTime=true', () => {
218
+ render(
219
+ <Timestamp
220
+ data={{ testid: testId }}
221
+ showDate={false}
222
+ timestamp={new Date()}
223
+ variant="updated"
224
+ />
225
+ )
226
+ const text = screen.getByTestId(testId).querySelector(".pb_caption_kit_xs")
227
+ expect(text?.textContent).toEqual("Last updated at 12:00a")
228
+ })
229
+