playbook_ui 15.0.0.pre.alpha.removewebpacker10589 → 15.0.0.pre.alpha.renovatenpmtrixvulnerability10692
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +12 -11
- data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +7 -2
- data/app/pb_kits/playbook/pb_contact/_contact.tsx +5 -0
- data/app/pb_kits/playbook/pb_contact/contact.rb +4 -0
- data/app/pb_kits/playbook/pb_contact/contact.test.js +21 -1
- data/app/pb_kits/playbook/pb_contact/docs/_contact_default.html.erb +16 -1
- data/app/pb_kits/playbook/pb_contact/docs/_contact_default.jsx +15 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_default.md +5 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_with_detail.html.erb +6 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_with_detail.jsx +6 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.html.erb +3 -3
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.html.erb +3 -3
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.html.erb +3 -3
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.html.erb +3 -3
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.html.erb +3 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.html.erb +2 -2
- data/app/pb_kits/playbook/pb_section_separator/_section_separator.scss +13 -5
- data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_children.html.erb +23 -0
- data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_children.jsx +45 -7
- data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +4 -1
- data/app/pb_kits/playbook/pb_section_separator/section_separator.test.js +165 -0
- data/app/pb_kits/playbook/pb_timestamp/_timestamp.tsx +24 -8
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_align.html.erb +0 -10
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_align.jsx +0 -9
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_align.md +1 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default.html.erb +3 -17
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default.jsx +0 -15
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default.md +1 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed.html.erb +0 -2
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed.jsx +0 -2
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed.md +5 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_current_year.html.erb +12 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_current_year.jsx +25 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_current_year.md +1 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_date.html.erb +4 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_date.jsx +17 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_date.md +1 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_time.html.erb +18 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_time.jsx +44 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_show_time.md +1 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_timezones.html.erb +0 -14
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_timezones.jsx +0 -14
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_timezones.md +1 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_unstyled.html.erb +0 -4
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_unstyled.jsx +0 -4
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated.jsx +0 -1
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated.md +5 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_current_year.html.erb +16 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_current_year.jsx +30 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_current_year.md +1 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_date.html.erb +16 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_date.jsx +30 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_date.md +1 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_time.html.erb +26 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_time.jsx +41 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_show_time.md +1 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/example.yml +18 -6
- data/app/pb_kits/playbook/pb_timestamp/docs/index.js +6 -0
- data/app/pb_kits/playbook/pb_timestamp/timestamp.rb +29 -7
- data/app/pb_kits/playbook/pb_timestamp/timestamp.test.js +69 -4
- data/dist/chunks/{_line_graph-DeH7NK-i.js → _line_graph-CUfJ7E4h.js} +1 -1
- data/dist/chunks/{_typeahead-CCGp0OQe.js → _typeahead-DCp1lVJx.js} +1 -1
- data/dist/chunks/{_weekday_stacked-BHLwECdV.js → _weekday_stacked-qrsOsOR9.js} +3 -3
- data/dist/chunks/{lib-QZuu1ltS.js → lib-BTs5acfO.js} +1 -1
- data/dist/chunks/{pb_form_validation-CleM960_.js → pb_form_validation-CKkaQFX3.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/engine.rb +1 -0
- data/lib/playbook/kit_base.rb +2 -23
- data/lib/playbook/version.rb +1 -1
- metadata +51 -14
- data/app/pb_kits/playbook/pb_timestamp/docs/_time_stamp_default.md +0 -1
- data/dist/chunks/componentRegistry-DzmmLR2x.js +0 -1
@@ -3,37 +3,30 @@
|
|
3
3
|
show_date: false,
|
4
4
|
show_timezone: true,
|
5
5
|
timezone: "America/New_York",
|
6
|
-
align: "left"
|
7
6
|
}) %>
|
8
7
|
|
9
8
|
<br>
|
10
9
|
|
11
10
|
<%= pb_rails("timestamp", props: {
|
12
11
|
timestamp: DateTime.now,
|
13
|
-
show_date: true,
|
14
12
|
show_timezone: true,
|
15
13
|
timezone: "America/New_York",
|
16
|
-
align: "left"
|
17
14
|
}) %>
|
18
15
|
|
19
16
|
<br>
|
20
17
|
|
21
18
|
<%= pb_rails("timestamp", props: {
|
22
19
|
timestamp: DateTime.now + 4.years,
|
23
|
-
show_date: true,
|
24
20
|
show_timezone: true,
|
25
21
|
timezone: "America/New_York",
|
26
|
-
align: "left"
|
27
22
|
}) %>
|
28
23
|
|
29
24
|
<br>
|
30
25
|
|
31
26
|
<%= pb_rails("timestamp", props: {
|
32
27
|
timestamp: DateTime.now - 1.year,
|
33
|
-
show_date: true,
|
34
28
|
show_timezone: true,
|
35
29
|
timezone: "America/New_York",
|
36
|
-
align: "left"
|
37
30
|
}) %>
|
38
31
|
|
39
32
|
<br>
|
@@ -43,37 +36,30 @@
|
|
43
36
|
show_date: false,
|
44
37
|
show_timezone: true,
|
45
38
|
timezone: "Asia/Hong_Kong",
|
46
|
-
align: "left"
|
47
39
|
}) %>
|
48
40
|
|
49
41
|
<br>
|
50
42
|
|
51
43
|
<%= pb_rails("timestamp", props: {
|
52
44
|
timestamp: DateTime.now,
|
53
|
-
show_date: true,
|
54
45
|
show_timezone: true,
|
55
46
|
timezone: "Asia/Hong_Kong",
|
56
|
-
align: "left"
|
57
47
|
}) %>
|
58
48
|
|
59
49
|
<br>
|
60
50
|
|
61
51
|
<%= pb_rails("timestamp", props: {
|
62
52
|
timestamp: DateTime.now + 4.years,
|
63
|
-
show_date: true,
|
64
53
|
show_timezone: true,
|
65
54
|
timezone: "Asia/Hong_Kong",
|
66
|
-
align: "left"
|
67
55
|
}) %>
|
68
56
|
|
69
57
|
<br>
|
70
58
|
|
71
59
|
<%= pb_rails("timestamp", props: {
|
72
60
|
timestamp: DateTime.now - 1.year,
|
73
|
-
show_date: true,
|
74
61
|
show_timezone: true,
|
75
62
|
timezone: "Asia/Hong_Kong",
|
76
|
-
align: "left"
|
77
63
|
}) %>
|
78
64
|
|
79
65
|
<br>
|
@@ -15,7 +15,6 @@ const TimestampTimezones = (props) => {
|
|
15
15
|
return (
|
16
16
|
<div>
|
17
17
|
<Timestamp
|
18
|
-
align="left"
|
19
18
|
showDate={false}
|
20
19
|
showTimezone
|
21
20
|
timestamp={todaysDate}
|
@@ -26,8 +25,6 @@ const TimestampTimezones = (props) => {
|
|
26
25
|
<br />
|
27
26
|
|
28
27
|
<Timestamp
|
29
|
-
align="left"
|
30
|
-
showDate
|
31
28
|
showTimezone
|
32
29
|
timestamp={todaysDate}
|
33
30
|
timezone="America/New_York"
|
@@ -37,8 +34,6 @@ const TimestampTimezones = (props) => {
|
|
37
34
|
<br />
|
38
35
|
|
39
36
|
<Timestamp
|
40
|
-
align="left"
|
41
|
-
showDate
|
42
37
|
showTimezone
|
43
38
|
timestamp={futureDate}
|
44
39
|
timezone="America/New_York"
|
@@ -48,8 +43,6 @@ const TimestampTimezones = (props) => {
|
|
48
43
|
<br />
|
49
44
|
|
50
45
|
<Timestamp
|
51
|
-
align="left"
|
52
|
-
showDate
|
53
46
|
showTimezone
|
54
47
|
timestamp={pastDate}
|
55
48
|
timezone="America/New_York"
|
@@ -59,7 +52,6 @@ const TimestampTimezones = (props) => {
|
|
59
52
|
<br />
|
60
53
|
|
61
54
|
<Timestamp
|
62
|
-
align="left"
|
63
55
|
showDate={false}
|
64
56
|
showTimezone
|
65
57
|
timestamp={todaysDate}
|
@@ -70,8 +62,6 @@ const TimestampTimezones = (props) => {
|
|
70
62
|
<br />
|
71
63
|
|
72
64
|
<Timestamp
|
73
|
-
align="left"
|
74
|
-
showDate
|
75
65
|
showTimezone
|
76
66
|
timestamp={todaysDate}
|
77
67
|
timezone="Asia/Hong_Kong"
|
@@ -81,8 +71,6 @@ const TimestampTimezones = (props) => {
|
|
81
71
|
<br />
|
82
72
|
|
83
73
|
<Timestamp
|
84
|
-
align="left"
|
85
|
-
showDate
|
86
74
|
showTimezone
|
87
75
|
timestamp={futureDate}
|
88
76
|
timezone="Asia/Hong_Kong"
|
@@ -92,8 +80,6 @@ const TimestampTimezones = (props) => {
|
|
92
80
|
<br />
|
93
81
|
|
94
82
|
<Timestamp
|
95
|
-
align="left"
|
96
|
-
showDate
|
97
83
|
showTimezone
|
98
84
|
timestamp={pastDate}
|
99
85
|
timezone="Asia/Hong_Kong"
|
@@ -0,0 +1 @@
|
|
1
|
+
The `showTimezone`/`show_timezone` prop can be used to show the timezone as well. This is set to false by default. **NOTE**: This prop must be used in conjunction with the `timezone` prop to specify which timezone to display.
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
<%= pb_rails("timestamp", props: {
|
4
4
|
timestamp: DateTime.now,
|
5
|
-
show_date: true,
|
6
|
-
align: "left",
|
7
5
|
unstyled: true,
|
8
6
|
}) %>
|
9
7
|
|
@@ -14,8 +12,6 @@
|
|
14
12
|
<%= pb_rails("title", props: { size: 1 }) do %>
|
15
13
|
<%= pb_rails("timestamp", props: {
|
16
14
|
timestamp: DateTime.now,
|
17
|
-
show_date: true,
|
18
|
-
align: "left",
|
19
15
|
unstyled: true,
|
20
16
|
}) %>
|
21
17
|
<% end %>
|
@@ -10,8 +10,6 @@ const TimestampUnstyled = (props) => {
|
|
10
10
|
text="Basic unstyled example"
|
11
11
|
/>
|
12
12
|
<Timestamp
|
13
|
-
align="left"
|
14
|
-
showDate
|
15
13
|
timestamp={new Date()}
|
16
14
|
unstyled
|
17
15
|
{...props}
|
@@ -24,8 +22,6 @@ const TimestampUnstyled = (props) => {
|
|
24
22
|
/>
|
25
23
|
<Title size={1}>
|
26
24
|
<Timestamp
|
27
|
-
align="left"
|
28
|
-
showDate
|
29
25
|
timestamp={new Date()}
|
30
26
|
unstyled
|
31
27
|
{...props}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
Use variant `updated` to show last updated at timestamp.
|
2
|
+
|
3
|
+
This variant can be customized using the optional `showUser`/`show_user` prop to show user as part of the text. When showing the user, pass in the user name using the `text` prop as shown.
|
4
|
+
|
5
|
+
`showUser`/`show_user` is set to false by default.
|
@@ -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
|
-
-
|
7
|
-
- timestamp_updated: Last Updated by
|
8
|
-
-
|
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
|
-
-
|
15
|
-
- timestamp_updated: Last Updated by
|
16
|
-
-
|
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
|
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
|
-
|
88
|
+
if show_time
|
89
|
+
"#{format_date_string} · #{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
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
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
|
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
|
+
|
@@ -1 +1 @@
|
|
1
|
-
import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{d as buildAriaProps,e as buildDataProps,f as buildHtmlProps,H as HighchartsReact,g as Highcharts,h as classnames,i as globalProps,j as HighchartsMore,S as SolidGauge,k as buildCss}from"./_typeahead-CCGp0OQe.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-QZuu1ltS.js";const mapColors=array=>{const regex=/(data)\-[1-8]/;const newArray=array.map((item=>regex.test(item)?`${colors[`data_${item[item.length-1]}`]}`:item));return newArray};const BarGraph=({aria:aria={},data:data={},align:align="center",axisTitle:axisTitle,dark:dark=false,chartData:chartData,className:className="pb_bar_graph",colors:colors2,htmlOptions:htmlOptions={},customOptions:customOptions={},axisFormat:axisFormat,id:id,pointStart:pointStart,stacking:stacking,subTitle:subTitle,type:type="column",title:title="Title",xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,legend:legend=false,toggleLegendClick:toggleLegendClick=true,height:height,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:[{labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat&&axisFormat[0]?axisFormat[0].format:""},min:yAxisMin,max:yAxisMax,opposite:false,title:{text:Array.isArray(axisTitle)?axisTitle.length>0?axisTitle[0].name:null:axisTitle},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]}],xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{stacking:stacking,pointStart:pointStart,borderWidth:stacking?0:"",events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(Array.isArray(axisTitle)&&axisTitle.length>1&&axisTitle[1].name){staticOptions.yAxis.push({labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat[1].format},min:yAxisMin,max:yAxisMax,opposite:true,title:{text:axisTitle[1].name},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]})}if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const alignBlockElement=event=>{const itemToMove=document.querySelector(`#wrapper-circle-chart-${event.target.renderTo.id} .pb-circle-chart-block`);const chartContainer=document.querySelector(`#${event.target.renderTo.id}`);if(itemToMove!==null&&chartContainer!==null){itemToMove.style.height=`${event.target.chartHeight}px`;itemToMove.style.width=`${event.target.chartWidth}px`;if(chartContainer.firstChild!==null){chartContainer.firstChild.before(itemToMove)}}};const CircleChart=({align:align="center",aria:aria={},rounded:rounded=false,borderColor:borderColor=(rounded?null:""),borderWidth:borderWidth=(rounded?20:null),chartData:chartData,children:children,className:className,colors:colors2=[],customOptions:customOptions={},dark:dark=false,data:data={},dataLabelHtml:dataLabelHtml="<div>{point.name}</div>",dataLabels:dataLabels=false,height:height,htmlOptions:htmlOptions={},id:id,innerSize:innerSize="md",legend:legend=false,maxPointSize:maxPointSize=null,minPointSize:minPointSize=null,startAngle:startAngle=null,style:style="pie",title:title,tooltipHtml:tooltipHtml,useHtml:useHtml=false,zMin:zMin=null,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{headerFormat:null,pointFormat:tooltipHtml?tooltipHtml:'<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',useHTML:useHtml}});const innerSizes={sm:"35%",md:"50%",lg:"85%",none:"0%"};const innerSizeFormat=size=>innerSizes[size];const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={title:{text:title},chart:{height:height,type:style,events:{render:event=>alignBlockElement(event),redraw:event=>alignBlockElement(event)}},legend:{align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},plotOptions:{pie:{colors:colors2.length>0?mapColors(colors2):highchartsTheme.colors,dataLabels:{enabled:dataLabels,connectorShape:"straight",connectorWidth:3,format:dataLabelHtml},showInLegend:legend}},series:[{minPointSize:minPointSize,maxPointSize:maxPointSize,innerSize:borderWidth==20?"100%":innerSizeFormat(innerSize),data:formattedChartData,zMin:zMin,startAngle:startAngle,borderWidth:borderWidth,borderColor:borderColor}],credits:false};setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(Fragment,{children:children?jsxs("div",{id:`wrapper-circle-chart-${id}`,children:[jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options}),jsx("div",{className:"pb-circle-chart-block",children:children})]}):jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})})};const Gauge=({aria:aria={},chartData:chartData,customOptions:customOptions={},dark:dark=false,data:data={},disableAnimation:disableAnimation=false,fullCircle:fullCircle=false,height:height=null,htmlOptions:htmlOptions={},id:id,max:max=100,min:min=0,prefix:prefix="",showLabels:showLabels=false,style:style="solidgauge",suffix:suffix="",title:title="",tooltipHtml:tooltipHtml='<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',colors:colors$1=[],minorTickInterval:minorTickInterval=null,circumference:circumference=(fullCircle?[0,360]:[-100,100]),...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);SolidGauge(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{pointFormat:tooltipHtml,followPointer:true}});const css=buildCss({pb_gauge_kit:true});const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={chart:{events:{load(){setTimeout(this.reflow.bind(this),0)}},type:style,height:height},title:{text:title},yAxis:{min:min,max:max,lineWidth:0,tickWidth:0,minorTickInterval:minorTickInterval,tickAmount:2,tickPositions:[min,max],labels:{y:26,enabled:showLabels}},credits:false,series:[{data:formattedChartData}],pane:{center:["50%","50%"],size:"90%",startAngle:circumference[0],endAngle:circumference[1],background:{borderWidth:20,innerRadius:"90%",outerRadius:"90%",shape:"arc",className:"gauge-pane"}},colors:colors$1!==void 0&&colors$1.length>0?mapColors(colors$1):highchartsTheme.colors,plotOptions:{series:{animation:!disableAnimation},solidgauge:{borderColor:colors$1!==void 0&&colors$1.length===1?mapColors(colors$1).join():highchartsTheme.colors[0],borderWidth:20,radius:90,innerRadius:"90%",dataLabels:{borderWidth:0,color:colors.text_lt_default,enabled:true,format:`<span class="prefix${dark?" dark":""}">${prefix}</span><span class="fix${dark?" dark":""}">{y:,f}</span><span class="suffix${dark?" dark":""}">${suffix}</span>`,style:{fontFamily:typography.font_family_base,fontWeight:typography.regular,fontSize:typography.heading_2},y:-26}}}};setOptions(merge(staticOptions,customOptions));if(document.querySelector(".prefix")){document.querySelectorAll(".prefix").forEach((prefix2=>{prefix2.setAttribute("y","28")}));document.querySelectorAll(".fix").forEach((fix=>fix.setAttribute("y","38")))}}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(css,globalProps(props)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const LineGraph=({aria:aria={},data:data={},align:align="center",className:className="pb_bar_graph",customOptions:customOptions={},dark:dark=false,gradient:gradient=false,type:type="line",htmlOptions:htmlOptions={},id:id,legend:legend=false,toggleLegendClick:toggleLegendClick=true,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,axisTitle:axisTitle,xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,chartData:chartData,pointStart:pointStart,subTitle:subTitle,title:title,height:height,colors:colors2=[],...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:{min:yAxisMin,max:yAxisMax,title:{text:axisTitle}},xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{pointStart:pointStart,events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};export{BarGraph as B,CircleChart as C,Gauge as G,LineGraph as L};
|
1
|
+
import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{d as buildAriaProps,e as buildDataProps,f as buildHtmlProps,H as HighchartsReact,g as Highcharts,h as classnames,i as globalProps,j as HighchartsMore,S as SolidGauge,k as buildCss}from"./_typeahead-DCp1lVJx.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-BTs5acfO.js";const mapColors=array=>{const regex=/(data)\-[1-8]/;const newArray=array.map((item=>regex.test(item)?`${colors[`data_${item[item.length-1]}`]}`:item));return newArray};const BarGraph=({aria:aria={},data:data={},align:align="center",axisTitle:axisTitle,dark:dark=false,chartData:chartData,className:className="pb_bar_graph",colors:colors2,htmlOptions:htmlOptions={},customOptions:customOptions={},axisFormat:axisFormat,id:id,pointStart:pointStart,stacking:stacking,subTitle:subTitle,type:type="column",title:title="Title",xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,legend:legend=false,toggleLegendClick:toggleLegendClick=true,height:height,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:[{labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat&&axisFormat[0]?axisFormat[0].format:""},min:yAxisMin,max:yAxisMax,opposite:false,title:{text:Array.isArray(axisTitle)?axisTitle.length>0?axisTitle[0].name:null:axisTitle},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]}],xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{stacking:stacking,pointStart:pointStart,borderWidth:stacking?0:"",events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(Array.isArray(axisTitle)&&axisTitle.length>1&&axisTitle[1].name){staticOptions.yAxis.push({labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat[1].format},min:yAxisMin,max:yAxisMax,opposite:true,title:{text:axisTitle[1].name},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]})}if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const alignBlockElement=event=>{const itemToMove=document.querySelector(`#wrapper-circle-chart-${event.target.renderTo.id} .pb-circle-chart-block`);const chartContainer=document.querySelector(`#${event.target.renderTo.id}`);if(itemToMove!==null&&chartContainer!==null){itemToMove.style.height=`${event.target.chartHeight}px`;itemToMove.style.width=`${event.target.chartWidth}px`;if(chartContainer.firstChild!==null){chartContainer.firstChild.before(itemToMove)}}};const CircleChart=({align:align="center",aria:aria={},rounded:rounded=false,borderColor:borderColor=(rounded?null:""),borderWidth:borderWidth=(rounded?20:null),chartData:chartData,children:children,className:className,colors:colors2=[],customOptions:customOptions={},dark:dark=false,data:data={},dataLabelHtml:dataLabelHtml="<div>{point.name}</div>",dataLabels:dataLabels=false,height:height,htmlOptions:htmlOptions={},id:id,innerSize:innerSize="md",legend:legend=false,maxPointSize:maxPointSize=null,minPointSize:minPointSize=null,startAngle:startAngle=null,style:style="pie",title:title,tooltipHtml:tooltipHtml,useHtml:useHtml=false,zMin:zMin=null,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{headerFormat:null,pointFormat:tooltipHtml?tooltipHtml:'<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',useHTML:useHtml}});const innerSizes={sm:"35%",md:"50%",lg:"85%",none:"0%"};const innerSizeFormat=size=>innerSizes[size];const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={title:{text:title},chart:{height:height,type:style,events:{render:event=>alignBlockElement(event),redraw:event=>alignBlockElement(event)}},legend:{align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},plotOptions:{pie:{colors:colors2.length>0?mapColors(colors2):highchartsTheme.colors,dataLabels:{enabled:dataLabels,connectorShape:"straight",connectorWidth:3,format:dataLabelHtml},showInLegend:legend}},series:[{minPointSize:minPointSize,maxPointSize:maxPointSize,innerSize:borderWidth==20?"100%":innerSizeFormat(innerSize),data:formattedChartData,zMin:zMin,startAngle:startAngle,borderWidth:borderWidth,borderColor:borderColor}],credits:false};setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(Fragment,{children:children?jsxs("div",{id:`wrapper-circle-chart-${id}`,children:[jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options}),jsx("div",{className:"pb-circle-chart-block",children:children})]}):jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})})};const Gauge=({aria:aria={},chartData:chartData,customOptions:customOptions={},dark:dark=false,data:data={},disableAnimation:disableAnimation=false,fullCircle:fullCircle=false,height:height=null,htmlOptions:htmlOptions={},id:id,max:max=100,min:min=0,prefix:prefix="",showLabels:showLabels=false,style:style="solidgauge",suffix:suffix="",title:title="",tooltipHtml:tooltipHtml='<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',colors:colors$1=[],minorTickInterval:minorTickInterval=null,circumference:circumference=(fullCircle?[0,360]:[-100,100]),...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);SolidGauge(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{pointFormat:tooltipHtml,followPointer:true}});const css=buildCss({pb_gauge_kit:true});const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={chart:{events:{load(){setTimeout(this.reflow.bind(this),0)}},type:style,height:height},title:{text:title},yAxis:{min:min,max:max,lineWidth:0,tickWidth:0,minorTickInterval:minorTickInterval,tickAmount:2,tickPositions:[min,max],labels:{y:26,enabled:showLabels}},credits:false,series:[{data:formattedChartData}],pane:{center:["50%","50%"],size:"90%",startAngle:circumference[0],endAngle:circumference[1],background:{borderWidth:20,innerRadius:"90%",outerRadius:"90%",shape:"arc",className:"gauge-pane"}},colors:colors$1!==void 0&&colors$1.length>0?mapColors(colors$1):highchartsTheme.colors,plotOptions:{series:{animation:!disableAnimation},solidgauge:{borderColor:colors$1!==void 0&&colors$1.length===1?mapColors(colors$1).join():highchartsTheme.colors[0],borderWidth:20,radius:90,innerRadius:"90%",dataLabels:{borderWidth:0,color:colors.text_lt_default,enabled:true,format:`<span class="prefix${dark?" dark":""}">${prefix}</span><span class="fix${dark?" dark":""}">{y:,f}</span><span class="suffix${dark?" dark":""}">${suffix}</span>`,style:{fontFamily:typography.font_family_base,fontWeight:typography.regular,fontSize:typography.heading_2},y:-26}}}};setOptions(merge(staticOptions,customOptions));if(document.querySelector(".prefix")){document.querySelectorAll(".prefix").forEach((prefix2=>{prefix2.setAttribute("y","28")}));document.querySelectorAll(".fix").forEach((fix=>fix.setAttribute("y","38")))}}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(css,globalProps(props)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const LineGraph=({aria:aria={},data:data={},align:align="center",className:className="pb_bar_graph",customOptions:customOptions={},dark:dark=false,gradient:gradient=false,type:type="line",htmlOptions:htmlOptions={},id:id,legend:legend=false,toggleLegendClick:toggleLegendClick=true,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,axisTitle:axisTitle,xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,chartData:chartData,pointStart:pointStart,subTitle:subTitle,title:title,height:height,colors:colors2=[],...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:{min:yAxisMin,max:yAxisMax,title:{text:axisTitle}},xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{pointStart:pointStart,events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};export{BarGraph as B,CircleChart as C,Gauge as G,LineGraph as L};
|