playbook_ui 12.36.0.pre.alpha.PLAY936momentjs1058 → 12.36.0.pre.alpha.PLAY942collapsiblenav21035

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/index.js +2 -1
  3. data/app/pb_kits/playbook/pb_badge/docs/example.yml +0 -7
  4. data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +15 -13
  5. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +24 -8
  6. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -1
  7. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +15 -4
  8. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +2 -2
  9. data/app/pb_kits/playbook/pb_collapsible/useCollapsible.tsx +14 -0
  10. data/app/pb_kits/playbook/pb_date/_date.tsx +8 -7
  11. data/app/pb_kits/playbook/pb_date/docs/_date_alignment.jsx +2 -2
  12. data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +5 -29
  13. data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +2 -2
  14. data/app/pb_kits/playbook/pb_date/docs/_date_variants.jsx +5 -5
  15. data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +31 -45
  16. data/app/pb_kits/playbook/pb_date_range_stacked/_date_range_stacked.tsx +3 -5
  17. data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +21 -24
  18. data/app/pb_kits/playbook/pb_date_time/_date_time.tsx +1 -1
  19. data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +1 -1
  20. data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.tsx +2 -2
  21. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.test.js +1 -1
  22. data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.tsx +8 -6
  23. data/app/pb_kits/playbook/pb_kit/dateTime.ts +63 -146
  24. data/app/pb_kits/playbook/pb_label_value/_label_value.tsx +31 -52
  25. data/app/pb_kits/playbook/pb_logistic/_logistic.jsx +120 -0
  26. data/app/pb_kits/playbook/pb_message/_message.tsx +24 -24
  27. data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +22 -1
  28. data/app/pb_kits/playbook/pb_nav/_item.tsx +26 -2
  29. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +59 -79
  30. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom_icons.jsx +4 -6
  31. data/app/pb_kits/playbook/pb_nav/docs/example.yml +2 -2
  32. data/app/pb_kits/playbook/pb_nav/item.rb +5 -1
  33. data/app/pb_kits/playbook/pb_pill/docs/example.yml +0 -5
  34. data/app/pb_kits/playbook/pb_radio/docs/example.yml +0 -11
  35. data/app/pb_kits/playbook/pb_time/_time.tsx +11 -9
  36. data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +49 -46
  37. data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.tsx +6 -4
  38. data/app/pb_kits/playbook/pb_timestamp/_timestamp.tsx +11 -11
  39. data/app/pb_kits/playbook/pb_timestamp/docs/example.yml +0 -8
  40. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +11 -8
  41. data/dist/playbook-rails.js +7 -7
  42. data/lib/playbook/version.rb +1 -1
  43. metadata +4 -25
  44. data/app/pb_kits/playbook/pb_badge/docs/_badge_colors_swift.md +0 -33
  45. data/app/pb_kits/playbook/pb_badge/docs/_badge_default_swift.md +0 -9
  46. data/app/pb_kits/playbook/pb_badge/docs/_badge_notification_swift.md +0 -9
  47. data/app/pb_kits/playbook/pb_badge/docs/_badge_props_swift.md +0 -6
  48. data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded_swift.md +0 -9
  49. data/app/pb_kits/playbook/pb_pill/docs/_pill_default_swift.md +0 -5
  50. data/app/pb_kits/playbook/pb_pill/docs/_pill_props_swift.md +0 -5
  51. data/app/pb_kits/playbook/pb_pill/docs/_pill_variants_swift.md +0 -10
  52. data/app/pb_kits/playbook/pb_radio/docs/_radio_alignment_swift.md +0 -16
  53. data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_swift.md +0 -18
  54. data/app/pb_kits/playbook/pb_radio/docs/_radio_default_swift.md +0 -15
  55. data/app/pb_kits/playbook/pb_radio/docs/_radio_error_swift.md +0 -14
  56. data/app/pb_kits/playbook/pb_radio/docs/_radio_orientation_swift.md +0 -15
  57. data/app/pb_kits/playbook/pb_radio/docs/_radio_padding_swift.md +0 -31
  58. data/app/pb_kits/playbook/pb_radio/docs/_radio_props_swift.md +0 -10
  59. data/app/pb_kits/playbook/pb_radio/docs/_radio_spacing_swift.md +0 -36
  60. data/app/pb_kits/playbook/pb_radio/docs/_radio_subtitle_swift.md +0 -13
  61. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_align_swift.md +0 -45
  62. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default_swift.md +0 -26
  63. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed_swift.md +0 -25
  64. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_props_swift.md +0 -10
  65. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_timezones_swift.md +0 -67
  66. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_swift.md +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6ba302e7c1343468a7d972cbe86df211d78a2dab3814ff174596a0bbfbe99fc
4
- data.tar.gz: f320274ec35c2c940ed8b193ba07d98a8e88200e85f9470464e14521e08998c1
3
+ metadata.gz: 6db34cdefea717b8e05435f34ffeca2768916aafc09c5fc75fe585cf29eeed83
4
+ data.tar.gz: '079ed7c7c64c2c7ee0825b84398cb909e08d08badd9cab8fb16870c4391210f0'
5
5
  SHA512:
6
- metadata.gz: 9abd50b6c82c1141abc3746c7cc948d54041a2a0f5159b346cd78c8aeaa29155475eb6631dc07c7a6604783d3373db4ceba0ea588ab10ce16063091f54ca04e0
7
- data.tar.gz: 17d3c0565e38899df31d90a96b32038556f6f94b7c099167ae7caf02b048a52604c6d16547ee2b16eb70874fe1db0157194b266da8b2b879a50f827425576373
6
+ metadata.gz: 96a3770480378c8930a578bf3c021aebcce6cf4dd8f45b9c6de753bfa67768334db24beede7c1f24d64b522cb4607c174bd7b120a4c24eada9d71c68427d70d0
7
+ data.tar.gz: 3708ce113f29d42deeaea57d6e166676fe51d9e9618a1d11383e82a2bf8658497b62dadd111ba2a2332ca5edf69f56cab283639da997399c07b3be04cda70093
@@ -129,4 +129,5 @@ export { default as PbTypeahead } from './pb_typeahead'
129
129
  export { default as dialogHelper } from './pb_dialog/dialogHelper'
130
130
 
131
131
  //Theming
132
- export {default as mapTheme} from './pb_map/pbMapTheme'
132
+ export {default as mapTheme} from './pb_map/pbMapTheme'
133
+ export {default as useCollapsible} from './pb_collapsible/useCollapsible'
@@ -10,10 +10,3 @@ examples:
10
10
  - badge_rounded: Rounded
11
11
  - badge_colors: Colors
12
12
  - badge_notification: Notification
13
-
14
- swift:
15
- - badge_default_swift: Rectangle
16
- - badge_rounded_swift: Rounded
17
- - badge_colors_swift: Colors
18
- - badge_notification_swift: Notification
19
- - badge_props_swift: ""
@@ -1,5 +1,6 @@
1
- import React, { useState } from 'react'
1
+ import React, { useEffect } from 'react'
2
2
  import classnames from 'classnames'
3
+ import useCollapsible from './useCollapsible'
3
4
 
4
5
  import { globalProps } from '../utilities/globalProps'
5
6
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
@@ -16,20 +17,15 @@ type CollapsibleProps = {
16
17
  className?: string,
17
18
  collapsed?: boolean,
18
19
  data?: object,
19
- icon?: string | string[]
20
+ icon?: string | string[],
20
21
  iconColor?: 'default' | 'light' | 'lighter' | 'link' | 'error' | 'success',
21
- iconSize?: IconSizes
22
+ iconSize?: IconSizes,
23
+ iconClick?: ()=> void,
24
+ onClick?: ()=> void,
22
25
  id?: string,
23
26
  }
24
27
 
25
- const useCollapsible = (initial = false) => {
26
- const [collapsed, setCollapsed] = useState(initial)
27
28
 
28
- return [
29
- collapsed,
30
- () => setCollapsed((t) => !t),
31
- ]
32
- }
33
29
 
34
30
  const Collapsible = ({
35
31
  aria = {},
@@ -40,10 +36,17 @@ const Collapsible = ({
40
36
  icon,
41
37
  iconColor = 'default',
42
38
  iconSize,
39
+ iconClick,
40
+ onClick,
43
41
  id,
44
42
  ...props
45
43
  }: CollapsibleProps) => {
46
- const [isCollapsed, collapse] = useCollapsible(collapsed)
44
+ const [isCollapsed, toggle, setIsCollapsed] = useCollapsible(collapsed)
45
+
46
+ useEffect(()=> {
47
+ setIsCollapsed(collapsed)
48
+ },[collapsed])
49
+
47
50
  const CollapsibleParent = React.Children.toArray(children) as JSX.Element[]
48
51
 
49
52
  if (CollapsibleParent.length !== 2) {
@@ -62,9 +65,8 @@ const Collapsible = ({
62
65
  globalProps(props),
63
66
  className
64
67
  )
65
-
66
68
  return (
67
- <CollapsibleContext.Provider value={{ collapsed: isCollapsed, collapse, icon, iconSize, iconColor }}>
69
+ <CollapsibleContext.Provider value={{ collapsed: isCollapsed, toggle, icon, iconSize, iconColor, iconClick, onClick }}>
68
70
  <div
69
71
  {...ariaProps}
70
72
  {...dataProps}
@@ -33,7 +33,7 @@ type CollapsibleMainProps = {
33
33
  children: React.ReactNode[] | React.ReactNode,
34
34
  className?: string,
35
35
  cursor?: string,
36
-
36
+ onClick?: ()=> void
37
37
  }
38
38
  type IconColors = "default" | "light" | "lighter" | "link" | "error" | "success"
39
39
 
@@ -42,9 +42,10 @@ type IconProps = {
42
42
  icon?: string[] | string
43
43
  iconColor?: IconColors
44
44
  iconSize?: IconSizes
45
+ iconClick?: ()=> void
45
46
  }
46
47
 
47
- const ToggleIcon = ({ collapsed, icon, iconSize, iconColor }: IconProps) => {
48
+ const ToggleIcon = ({ collapsed, icon, iconSize, iconColor, iconClick }: IconProps) => {
48
49
  const color = colorMap[iconColor]
49
50
 
50
51
  const showIcon = (icon: string |string[]) => {
@@ -54,6 +55,13 @@ const ToggleIcon = ({ collapsed, icon, iconSize, iconColor }: IconProps) => {
54
55
  return icon
55
56
  }
56
57
 
58
+ const handleIconClick = (e:any) => {
59
+ if (iconClick) {
60
+ e.stopPropagation();
61
+ iconClick()
62
+ }
63
+ }
64
+
57
65
  return (
58
66
  <>
59
67
  {collapsed ? (
@@ -61,6 +69,7 @@ const ToggleIcon = ({ collapsed, icon, iconSize, iconColor }: IconProps) => {
61
69
  className="icon_wrapper"
62
70
  key={icon ? showIcon(icon)[0] : "chevron-down"}
63
71
  style={{ verticalAlign: "middle", color: color }}
72
+ onClick={(e)=> handleIconClick(e)}
64
73
  >
65
74
  <Icon icon={icon ? showIcon(icon)[0] : "chevron-down"} size={iconSize} />
66
75
  </div>
@@ -69,6 +78,7 @@ const ToggleIcon = ({ collapsed, icon, iconSize, iconColor }: IconProps) => {
69
78
  className="icon_wrapper"
70
79
  key={icon ? showIcon(icon)[1] : "chevron-up"}
71
80
  style={{ verticalAlign: "middle", color: color }}
81
+ onClick={(e)=> handleIconClick(e)}
72
82
  >
73
83
  <Icon icon={icon ? showIcon(icon)[1] : "chevron-up"} size={iconSize} />
74
84
  </div>
@@ -83,13 +93,18 @@ const CollapsibleMain = ({
83
93
  cursor = 'pointer',
84
94
  ...props
85
95
  }: CollapsibleMainProps): React.ReactElement=> {
86
- const context: {[key: string]: IconColors | (() => void)} | boolean = useContext(CollapsibleContext)
96
+ const {collapsed, toggle, icon, iconSize, iconColor, iconClick, onClick}: any = useContext(CollapsibleContext)
87
97
  const mainCSS = buildCss('pb_collapsible_main_kit')
88
98
  const mainSpacing = globalProps(props, { cursor })
89
99
 
100
+ const handleCollapsibleClick = (e:any) => {
101
+ toggle();
102
+ onClick && onClick(e)
103
+ }
104
+
90
105
  return (
91
106
  <div className={classnames(mainCSS, className, mainSpacing)}>
92
- <div onClick={context.collapse as (() => void)}>
107
+ <div onClick={(e)=>handleCollapsibleClick(e)}>
93
108
  <Flex
94
109
  spacing="between"
95
110
  vertical="center"
@@ -97,10 +112,11 @@ const CollapsibleMain = ({
97
112
  <FlexItem>{children}</FlexItem>
98
113
  <FlexItem>
99
114
  <ToggleIcon
100
- collapsed={context.collapsed as () => void}
101
- iconColor={context.iconColor as IconColors}
102
- iconSize={context.iconSize as IconSizes}
103
- icon={context.icon as string[] | string}
115
+ collapsed={collapsed as () => void}
116
+ iconColor={iconColor as IconColors}
117
+ iconSize={iconSize as IconSizes}
118
+ icon={icon as string[] | string}
119
+ iconClick={iconClick}
104
120
  />
105
121
  </FlexItem>
106
122
  </Flex>
@@ -9,7 +9,7 @@
9
9
  <%= content.presence %>
10
10
  <% end %>
11
11
  <%= pb_rails("flex/flex_item") do %>
12
- <div style="color: <%= object.icon_color %>">
12
+ <div style="color: <%= object.icon_color %>" class="icon_wrapper" >
13
13
  <% if object.icon.present? %>
14
14
  <%= pb_rails("icon", props: { icon: object.show_icon(object.icon)[0], id:"collapsible_open_icon", size: object.size }) %>
15
15
  <%= pb_rails("icon", props: { icon: object.show_icon(object.icon)[1], id:"collapsible_close_icon", size: object.size }) %>
@@ -1,8 +1,17 @@
1
1
  import React from 'react'
2
- import { Collapsible } from '../..'
2
+ import { Collapsible, useCollapsible, Button } from '../..'
3
3
 
4
- const CollapsibleIcons = () => (
5
- <Collapsible icon={['plus','minus']}>
4
+ const CollapsibleIcons = () => {
5
+ const [isCollapsed, setIsCollapsed] = useCollapsible(true)
6
+
7
+ return (
8
+ <>
9
+ <Button onClick={()=> setIsCollapsed(!isCollapsed)}>
10
+ {isCollapsed ? "Expand" : "Collapse"}
11
+ </Button>
12
+ <Collapsible collapsed={isCollapsed}
13
+ icon={['plus','minus']}
14
+ >
6
15
  <Collapsible.Main>
7
16
  <div>{'Main Section'}</div>
8
17
  </Collapsible.Main>
@@ -14,6 +23,8 @@ const CollapsibleIcons = () => (
14
23
  </div>
15
24
  </Collapsible.Content>
16
25
  </Collapsible>
17
- )
26
+ </>
27
+ )
28
+ }
18
29
 
19
30
  export default CollapsibleIcons
@@ -4,10 +4,10 @@ examples:
4
4
  - collapsible_default: Default
5
5
  - collapsible_size: Size
6
6
  - collapsible_color: Color
7
- # - collapsible_icons: Custom Icons
7
+ - collapsible_icons: Custom Icons
8
8
 
9
9
  react:
10
10
  - collapsible_default: Default
11
11
  - collapsible_size: Size
12
12
  - collapsible_color: Color
13
- # - collapsible_icons: Custom Icons
13
+ - collapsible_icons: Custom Icons
@@ -0,0 +1,14 @@
1
+ import {useState} from 'react';
2
+
3
+ const useCollapsible = (initial= true) => {
4
+ const [collapsed, setCollapsed] = useState(initial)
5
+
6
+ const toggle = () => setCollapsed((prev) => !prev)
7
+ return [
8
+ collapsed,
9
+ toggle,
10
+ setCollapsed as any,
11
+ ]
12
+ }
13
+
14
+ export default useCollapsible
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import classnames from "classnames";
3
3
 
4
+ import DateTime from "../pb_kit/dateTime";
4
5
  import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
5
6
  import { globalProps } from "../utilities/globalProps";
6
- import DateTime from '../pb_kit/dateTime';
7
7
 
8
8
  import Body from "../pb_body/_body";
9
9
  import Caption from "../pb_caption/_caption";
@@ -20,7 +20,7 @@ type PbDateProps = {
20
20
  showIcon?: boolean;
21
21
  size?: "sm" | "md" | "lg";
22
22
  unstyled?: boolean;
23
- value: Date;
23
+ value: string | Date;
24
24
  };
25
25
 
26
26
  const PbDate = (props: PbDateProps) => {
@@ -37,11 +37,12 @@ const PbDate = (props: PbDateProps) => {
37
37
  value,
38
38
  } = props;
39
39
 
40
- const weekday = DateTime.toWeekday(value);
41
- const month = DateTime.toMonth(value);
42
- const day = DateTime.toDay(value);
43
- const year = DateTime.toYear(value);
44
- const currentYear = new Date().getFullYear();
40
+ const dateTimestamp = new DateTime({ value: value });
41
+ const weekday = dateTimestamp.toWeekday();
42
+ const month = dateTimestamp.toMonth();
43
+ const day = dateTimestamp.toDay();
44
+ const year = dateTimestamp.toYear();
45
+ const currentYear = new Date().getFullYear().toString();
45
46
 
46
47
  const ariaProps = buildAriaProps(aria);
47
48
  const dataProps = buildDataProps(data);
@@ -7,7 +7,7 @@ const DateAlignment = (props) => {
7
7
  <FormattedDate
8
8
  dayOfWeek
9
9
  icon
10
- value={new Date('25 Dec 1995')}
10
+ value="1995-12-25"
11
11
  {...props}
12
12
  />
13
13
 
@@ -17,7 +17,7 @@ const DateAlignment = (props) => {
17
17
  alignment="center"
18
18
  dayOfWeek
19
19
  icon
20
- value={new Date('25 Dec 2020')}
20
+ value="2020-12-25"
21
21
  {...props}
22
22
  />
23
23
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { Date as FormattedDate, Caption, Title } from '../../'
2
+ import { Date as FormattedDate } from '../../'
3
3
 
4
4
  const DateDefault = (props) => {
5
5
  return (
@@ -12,20 +12,9 @@ const DateDefault = (props) => {
12
12
 
13
13
  <br />
14
14
 
15
- <div style={{display: "flex", columnGap: 4}}>
16
- <FormattedDate
17
- size="sm"
18
- value={"2012-08-03"}
19
- {...props}
20
- />
21
- <Caption>{"(Hyphenated Date)"}</Caption>
22
- </div>
23
-
24
- <br />
25
-
26
15
  <FormattedDate
27
16
  size="sm"
28
- value={new Date('03 Aug 2012')}
17
+ value="2012-08-03"
29
18
  {...props}
30
19
  />
31
20
 
@@ -34,7 +23,7 @@ const DateDefault = (props) => {
34
23
  <FormattedDate
35
24
  showDayOfWeek
36
25
  size="sm"
37
- value={new Date('03 Dec 2017')}
26
+ value="2017-12-03"
38
27
  {...props}
39
28
  />
40
29
 
@@ -48,21 +37,8 @@ const DateDefault = (props) => {
48
37
 
49
38
  <br />
50
39
 
51
- <div style={{display: "flex", columnGap: 4}}>
52
- <FormattedDate
53
- value={"2012-08-03"}
54
- {...props}
55
- />
56
- <Title
57
- size={4}
58
- text={"(Hyphenated Date)"}
59
- />
60
- </div>
61
-
62
- <br />
63
-
64
40
  <FormattedDate
65
- value={new Date('03 Aug 2012')}
41
+ value="2012-08-03"
66
42
  {...props}
67
43
  />
68
44
 
@@ -70,7 +46,7 @@ const DateDefault = (props) => {
70
46
 
71
47
  <FormattedDate
72
48
  showDayOfWeek
73
- value={new Date('03 Dec 2017')}
49
+ value="2017-12-03"
74
50
  {...props}
75
51
  />
76
52
  </>
@@ -21,7 +21,7 @@ const DateUnstyled = (props) => {
21
21
  <Title size={1}>
22
22
  <FormattedDate
23
23
  unstyled
24
- value={new Date('25 Dec 1995')}
24
+ value="1995-12-25"
25
25
  {...props}
26
26
  />
27
27
  </Title>
@@ -36,7 +36,7 @@ const DateUnstyled = (props) => {
36
36
  showDayOfWeek
37
37
  showIcon
38
38
  unstyled
39
- value={new Date('25 Dec 1995')}
39
+ value="1995-12-25"
40
40
  {...props}
41
41
  />
42
42
  </Caption>
@@ -7,7 +7,7 @@ const DateVariants = (props) => {
7
7
  <FormattedDate
8
8
  showIcon
9
9
  size="sm"
10
- value={new Date('25 Dec 1995')}
10
+ value="1995-12-25"
11
11
  {...props}
12
12
  />
13
13
 
@@ -15,7 +15,7 @@ const DateVariants = (props) => {
15
15
  <br />
16
16
 
17
17
  <FormattedDate
18
- value={new Date('25 Dec 1995')}
18
+ value="1995-12-25"
19
19
  {...props}
20
20
  />
21
21
 
@@ -24,7 +24,7 @@ const DateVariants = (props) => {
24
24
 
25
25
  <FormattedDate
26
26
  showIcon
27
- value={new Date('25 Dec 1995')}
27
+ value="1995-12-25"
28
28
  {...props}
29
29
  />
30
30
 
@@ -33,7 +33,7 @@ const DateVariants = (props) => {
33
33
 
34
34
  <FormattedDate
35
35
  showDayOfWeek
36
- value={new Date('25 Dec 1995')}
36
+ value="1995-12-25"
37
37
  {...props}
38
38
  />
39
39
 
@@ -43,7 +43,7 @@ const DateVariants = (props) => {
43
43
  <FormattedDate
44
44
  showDayOfWeek
45
45
  showIcon
46
- value={new Date('25 Dec 1995')}
46
+ value="1995-12-25"
47
47
  {...props}
48
48
  />
49
49
  </div>
@@ -3,7 +3,7 @@ import classnames from "classnames";
3
3
 
4
4
  import { globalProps } from "../utilities/globalProps";
5
5
  import { buildCss, buildDataProps } from "../utilities/props";
6
- import DateTime from '../pb_kit/dateTime';
6
+ import DateTime from "../pb_kit/dateTime";
7
7
 
8
8
  import Body from "../pb_body/_body";
9
9
  import Caption from "../pb_caption/_caption";
@@ -21,16 +21,18 @@ type DateRangeInlineProps = {
21
21
  endDate?: Date;
22
22
  };
23
23
 
24
- const dateTimestamp = (dateValue: Date, includeYear: boolean) => {
24
+ const dateTimestamp = (dateValue: Date | string, includeYear: boolean) => {
25
+ const date = new DateTime({ value: dateValue });
25
26
  if (includeYear) {
26
- return `${DateTime.toMonth(dateValue)} ${DateTime.toDay(dateValue)}, ${DateTime.toYear(dateValue)}`;
27
+ return `${date.toMonth()} ${date.toDay()}, ${date.toYear()}`;
27
28
  } else {
28
- return `${DateTime.toMonth(dateValue)} ${DateTime.toDay(dateValue)}`;
29
+ return `${date.toMonth()} ${date.toDay()}`;
29
30
  }
30
31
  };
31
32
 
32
- const dateTimeIso = (dateValue: Date) => {
33
- return DateTime.toIso(dateValue);
33
+ const dateTimeIso = (dateValue: Date | string) => {
34
+ const date = new DateTime({ value: dateValue });
35
+ return date.toIso();
34
36
  };
35
37
 
36
38
  const DateRangeInline = (props: DateRangeInlineProps) => {
@@ -50,17 +52,14 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
50
52
  <>
51
53
  {icon && (
52
54
  <>
53
- <Body color="light"
54
- key={Math.random()}
55
- tag="span"
56
- >
55
+ <Body color="light" key={Math.random()} tag="span">
57
56
  <Icon
58
- className="pb_date_range_inline_icon"
59
- dark={dark}
60
- fixedWidth
61
- icon="calendar-alt"
62
- size={size}
63
- tag="span"
57
+ className="pb_date_range_inline_icon"
58
+ dark={dark}
59
+ fixedWidth
60
+ icon="calendar-alt"
61
+ size={size}
62
+ tag="span"
64
63
  />
65
64
  </Body>
66
65
  </>
@@ -79,7 +78,7 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
79
78
 
80
79
  const dateRangeClasses = buildCss("pb_date_range_inline_kit", align);
81
80
  const dataProps = buildDataProps(data)
82
- const renderTime = (date: Date) => {
81
+ const renderTime = (date: Date | string) => {
83
82
  return (
84
83
  <time dateTime={dateTimeIso(date)}>
85
84
  {dateInCurrentYear() ? (
@@ -93,30 +92,24 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
93
92
 
94
93
  return (
95
94
  <div
96
- {...dataProps}
97
- className={classnames(dateRangeClasses, globalProps(props), className)}
95
+ {...dataProps}
96
+ className={classnames(dateRangeClasses, globalProps(props), className)}
98
97
  >
99
98
  <div className="pb_date_range_inline_wrapper">
100
99
  {size == "xs" && (
101
100
  <>
102
101
  {iconContent()}
103
- <Caption dark={dark}
104
- tag="span"
105
- >
102
+ <Caption dark={dark} tag="span">
106
103
  {renderTime(startDate)}
107
104
  </Caption>
108
- <Caption dark={dark}
109
- tag="span"
110
- >
105
+ <Caption dark={dark} tag="span">
111
106
  <Icon
112
- className="pb_date_range_inline_arrow"
113
- fixedWidth
114
- icon="long-arrow-right"
107
+ className="pb_date_range_inline_arrow"
108
+ fixedWidth
109
+ icon="long-arrow-right"
115
110
  />
116
111
  </Caption>
117
- <Caption dark={dark}
118
- tag="span"
119
- >
112
+ <Caption dark={dark} tag="span">
120
113
  {renderTime(endDate)}
121
114
  </Caption>
122
115
  </>
@@ -125,25 +118,18 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
125
118
  {size == "sm" && (
126
119
  <>
127
120
  {iconContent()}
128
- <Body dark={dark}
129
- tag="span"
130
- >
121
+ <Body dark={dark} tag="span">
131
122
  {renderTime(startDate)}
132
123
  </Body>
133
- <Body color="light"
134
- dark={dark}
135
- tag="span"
136
- >
124
+ <Body color="light" dark={dark} tag="span">
137
125
  <Icon
138
- className="pb_date_range_inline_arrow"
139
- dark={dark}
140
- fixedWidth
141
- icon="long-arrow-right"
126
+ className="pb_date_range_inline_arrow"
127
+ dark={dark}
128
+ fixedWidth
129
+ icon="long-arrow-right"
142
130
  />
143
131
  </Body>
144
- <Body dark={dark}
145
- tag="span"
146
- >
132
+ <Body dark={dark} tag="span">
147
133
  {renderTime(endDate)}
148
134
  </Body>
149
135
  </>
@@ -14,9 +14,9 @@ type DateRangeStackedProps = {
14
14
  className?: string | string[],
15
15
  data?: string,
16
16
  dark?: boolean,
17
- endDate: Date,
17
+ endDate: string,
18
18
  id?: string,
19
- startDate: Date,
19
+ startDate: string,
20
20
  }
21
21
 
22
22
  const DateRangeStacked = (props: DateRangeStackedProps) => {
@@ -29,9 +29,7 @@ const DateRangeStacked = (props: DateRangeStackedProps) => {
29
29
  const dataProps = buildDataProps(data)
30
30
 
31
31
  return (
32
- <div {...dataProps}
33
- className={css}
34
- >
32
+ <div {...dataProps} className={css}>
35
33
  <Flex vertical="center">
36
34
  <FlexItem>
37
35
  <DateYearStacked