playbook_ui 12.38.0.pre.alpha.playbook123801077 → 12.39.0.pre.alpha.salesbookmismatchingdate1114
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +6 -0
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +3 -3
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +10 -9
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_color.jsx +2 -2
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.jsx +2 -2
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +4 -8
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.md +1 -1
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_size.jsx +5 -5
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.jsx +75 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.md +3 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +7 -6
- data/app/pb_kits/playbook/pb_collapsible/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_kit/dateTime.ts +41 -36
- data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +280 -17
- data/app/pb_kits/playbook/pb_nav/_horizontal_nav.scss +6 -0
- data/app/pb_kits/playbook/pb_nav/_item.tsx +35 -22
- data/app/pb_kits/playbook/pb_nav/_mixins.scss +5 -0
- data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +6 -7
- data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +85 -58
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.md +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.jsx +58 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.md +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.html.erb +23 -0
- data/app/pb_kits/playbook/pb_nav/docs/{_collapsible_nav_custom_icons.jsx → _collapsible_nav_emphasize.jsx} +14 -5
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.md +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +5 -3
- data/app/pb_kits/playbook/pb_nav/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_nav/item.html.erb +5 -4
- data/app/pb_kits/playbook/pb_nav/item.rb +29 -3
- data/app/pb_kits/playbook/pb_select/_select.scss +76 -0
- data/app/pb_kits/playbook/pb_select/_select.tsx +9 -5
- data/app/pb_kits/playbook/pb_select/docs/_select_attributes.html.erb +26 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_attributes.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_multiple.html.erb +36 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_multiple.jsx +50 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_multiple.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_select/select.html.erb +5 -9
- data/app/pb_kits/playbook/pb_select/select.rb +14 -0
- data/app/pb_kits/playbook/pb_select/select.test.js +17 -0
- data/app/pb_kits/playbook/pb_time/_time.tsx +1 -1
- data/dist/playbook-rails.js +2 -2
- data/lib/playbook/version.rb +2 -2
- metadata +16 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e1efed14125432de973864540db434bd15d7ca728af5bfd7facb459c42f3a5
|
4
|
+
data.tar.gz: 8ea21f9bdf376162e82ab98a9d14b3f186e8438d81a979faa663ffad1f3b57f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b78591f4053df9f189134735a3689c5e010f823220d0217c65f222240a1aed961f8cdb79df3f91e771f7336717031dfd2594064388e3f9478549d0281f78724
|
7
|
+
data.tar.gz: 93d06173adcc6db7672b2580de009a31d530c0135802524b0d5514d09939737230c38dd845f47c862a9be503eb6c42916372498afc5481d54f7c2afe495f6644
|
@@ -20,7 +20,7 @@ type CollapsibleProps = {
|
|
20
20
|
icon?: string | string[],
|
21
21
|
iconColor?: 'default' | 'light' | 'lighter' | 'link' | 'error' | 'success',
|
22
22
|
iconSize?: IconSizes,
|
23
|
-
|
23
|
+
onIconClick?: ()=> void,
|
24
24
|
onClick?: ()=> void,
|
25
25
|
id?: string,
|
26
26
|
}
|
@@ -36,7 +36,7 @@ const Collapsible = ({
|
|
36
36
|
icon,
|
37
37
|
iconColor = 'default',
|
38
38
|
iconSize,
|
39
|
-
|
39
|
+
onIconClick,
|
40
40
|
onClick,
|
41
41
|
id,
|
42
42
|
...props
|
@@ -66,7 +66,7 @@ const Collapsible = ({
|
|
66
66
|
className
|
67
67
|
)
|
68
68
|
return (
|
69
|
-
<CollapsibleContext.Provider value={{ collapsed: isCollapsed, toggle, icon, iconSize, iconColor,
|
69
|
+
<CollapsibleContext.Provider value={{ collapsed: isCollapsed, toggle, icon, iconSize, iconColor, onIconClick, onClick }}>
|
70
70
|
<div
|
71
71
|
{...ariaProps}
|
72
72
|
{...dataProps}
|
@@ -33,6 +33,7 @@ type CollapsibleMainProps = {
|
|
33
33
|
children: React.ReactNode[] | React.ReactNode,
|
34
34
|
className?: string,
|
35
35
|
cursor?: string,
|
36
|
+
dark?: boolean,
|
36
37
|
onClick?: ()=> void
|
37
38
|
}
|
38
39
|
type IconColors = "default" | "light" | "lighter" | "link" | "error" | "success"
|
@@ -42,10 +43,10 @@ type IconProps = {
|
|
42
43
|
icon?: string[] | string
|
43
44
|
iconColor?: IconColors
|
44
45
|
iconSize?: IconSizes
|
45
|
-
|
46
|
+
onIconClick?: ()=> void
|
46
47
|
}
|
47
48
|
|
48
|
-
const ToggleIcon = ({ collapsed, icon, iconSize, iconColor,
|
49
|
+
const ToggleIcon = ({ collapsed, icon, iconSize, iconColor, onIconClick }: IconProps) => {
|
49
50
|
const color = colorMap[iconColor]
|
50
51
|
|
51
52
|
const showIcon = (icon: string |string[]) => {
|
@@ -56,9 +57,9 @@ const ToggleIcon = ({ collapsed, icon, iconSize, iconColor, iconClick }: IconPro
|
|
56
57
|
}
|
57
58
|
|
58
59
|
const handleIconClick = (e:any) => {
|
59
|
-
if (
|
60
|
+
if (onIconClick) {
|
60
61
|
e.stopPropagation();
|
61
|
-
|
62
|
+
onIconClick()
|
62
63
|
}
|
63
64
|
}
|
64
65
|
|
@@ -93,18 +94,18 @@ const CollapsibleMain = ({
|
|
93
94
|
cursor = 'pointer',
|
94
95
|
...props
|
95
96
|
}: CollapsibleMainProps): React.ReactElement=> {
|
96
|
-
const {collapsed, toggle, icon, iconSize, iconColor,
|
97
|
+
const {collapsed, toggle, icon, iconSize, iconColor, onIconClick, onClick}: any = useContext(CollapsibleContext)
|
97
98
|
const mainCSS = buildCss('pb_collapsible_main_kit')
|
98
99
|
const mainSpacing = globalProps(props, { cursor })
|
99
100
|
|
100
|
-
const handleCollapsibleClick = (
|
101
|
+
const handleCollapsibleClick = () => {
|
101
102
|
toggle();
|
102
|
-
onClick && onClick(
|
103
|
+
onClick && onClick()
|
103
104
|
}
|
104
105
|
|
105
106
|
return (
|
106
107
|
<div className={classnames(mainCSS, className, mainSpacing)}>
|
107
|
-
<div onClick={
|
108
|
+
<div onClick={handleCollapsibleClick}>
|
108
109
|
<Flex
|
109
110
|
spacing="between"
|
110
111
|
vertical="center"
|
@@ -116,7 +117,7 @@ const CollapsibleMain = ({
|
|
116
117
|
iconColor={iconColor as IconColors}
|
117
118
|
iconSize={iconSize as IconSizes}
|
118
119
|
icon={icon as string[] | string}
|
119
|
-
|
120
|
+
onIconClick={onIconClick}
|
120
121
|
/>
|
121
122
|
</FlexItem>
|
122
123
|
</Flex>
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Collapsible } from '../..'
|
3
3
|
|
4
|
-
const CollapsibleColor = () => (
|
4
|
+
const CollapsibleColor = (props) => (
|
5
5
|
<div>
|
6
6
|
<Collapsible
|
7
7
|
iconColor='default'
|
8
8
|
marginBottom="xs"
|
9
9
|
>
|
10
|
-
<Collapsible.Main>
|
10
|
+
<Collapsible.Main {...props}>
|
11
11
|
<div>{'Default Section'}</div>
|
12
12
|
</Collapsible.Main>
|
13
13
|
<Collapsible.Content>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Collapsible } from '../..'
|
3
3
|
|
4
|
-
const CollapsibleDefault = () => (
|
4
|
+
const CollapsibleDefault = (props) => (
|
5
5
|
<Collapsible >
|
6
|
-
<Collapsible.Main>
|
6
|
+
<Collapsible.Main {...props}>
|
7
7
|
<div>{'Main Section'}</div>
|
8
8
|
</Collapsible.Main>
|
9
9
|
<Collapsible.Content>
|
@@ -1,18 +1,14 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import { Collapsible
|
2
|
+
import { Collapsible } from '../..'
|
3
3
|
|
4
|
-
const CollapsibleIcons = () => {
|
5
|
-
const [isCollapsed, setIsCollapsed] = useCollapsible(true)
|
4
|
+
const CollapsibleIcons = (props) => {
|
6
5
|
|
7
6
|
return (
|
8
7
|
<>
|
9
|
-
<
|
10
|
-
{isCollapsed ? "Expand" : "Collapse"}
|
11
|
-
</Button>
|
12
|
-
<Collapsible collapsed={isCollapsed}
|
8
|
+
<Collapsible
|
13
9
|
icon={['plus','minus']}
|
14
10
|
>
|
15
|
-
<Collapsible.Main>
|
11
|
+
<Collapsible.Main {...props}>
|
16
12
|
<div>{'Main Section'}</div>
|
17
13
|
</Collapsible.Main>
|
18
14
|
<Collapsible.Content>
|
@@ -1,2 +1,2 @@
|
|
1
1
|
##### Prop
|
2
|
-
|
2
|
+
The `icon` prop allows you to customize your icon sets by passing it an array of any comma-separated pair of icon values. The first icon value will replace the kit's default icon when collapsed (chevron-down), and the second value will replace the default icon when expanded (chevron-up). `icon` also allows you to pass it a single icon as a string, in which case the icon will not toggle with the collapsible state.
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Collapsible } from '../..'
|
3
3
|
|
4
|
-
const CollapsibleSize = () => (
|
4
|
+
const CollapsibleSize = (props) => (
|
5
5
|
<div>
|
6
6
|
<Collapsible
|
7
7
|
iconSize="xs"
|
8
8
|
marginBottom="xs"
|
9
9
|
>
|
10
|
-
<Collapsible.Main>
|
10
|
+
<Collapsible.Main {...props}>
|
11
11
|
<div>{'Extra Small Section'}</div>
|
12
12
|
</Collapsible.Main>
|
13
13
|
<Collapsible.Content>
|
@@ -22,7 +22,7 @@ const CollapsibleSize = () => (
|
|
22
22
|
iconSize="sm"
|
23
23
|
marginBottom="xs"
|
24
24
|
>
|
25
|
-
<Collapsible.Main>
|
25
|
+
<Collapsible.Main {...props}>
|
26
26
|
<div>{'Small Section'}</div>
|
27
27
|
</Collapsible.Main>
|
28
28
|
<Collapsible.Content>
|
@@ -36,7 +36,7 @@ const CollapsibleSize = () => (
|
|
36
36
|
<Collapsible
|
37
37
|
marginBottom="xs"
|
38
38
|
>
|
39
|
-
<Collapsible.Main>
|
39
|
+
<Collapsible.Main {...props}>
|
40
40
|
<div>{'Default Section'}</div>
|
41
41
|
</Collapsible.Main>
|
42
42
|
<Collapsible.Content>
|
@@ -51,7 +51,7 @@ const CollapsibleSize = () => (
|
|
51
51
|
iconSize="lg"
|
52
52
|
marginBottom="xs"
|
53
53
|
>
|
54
|
-
<Collapsible.Main>
|
54
|
+
<Collapsible.Main {...props}>
|
55
55
|
<div>{'Large Section'}</div>
|
56
56
|
</Collapsible.Main>
|
57
57
|
<Collapsible.Content>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Collapsible, useCollapsible, Button } from '../..'
|
3
|
+
|
4
|
+
const CollapsibleState = (props) => {
|
5
|
+
const [isCollapsed, setIsCollapsed] = useCollapsible(true)
|
6
|
+
|
7
|
+
return (
|
8
|
+
<>
|
9
|
+
<Button
|
10
|
+
onClick={() => setIsCollapsed(!isCollapsed)}
|
11
|
+
padding="none"
|
12
|
+
variant="link"
|
13
|
+
>
|
14
|
+
{isCollapsed ? "Expand All" : "Collapse All"}
|
15
|
+
</Button>
|
16
|
+
|
17
|
+
<Collapsible
|
18
|
+
collapsed={isCollapsed}
|
19
|
+
icon={["plus", "minus"]}
|
20
|
+
padding="none"
|
21
|
+
>
|
22
|
+
<Collapsible.Main padding="sm"
|
23
|
+
{...props}
|
24
|
+
>
|
25
|
+
<div>{"Main Section"}</div>
|
26
|
+
</Collapsible.Main>
|
27
|
+
<Collapsible.Content>
|
28
|
+
<div>
|
29
|
+
{
|
30
|
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel erat sed purus hendrerit viverra. Duis et vestibulum metus. Sed consequat ut ante non vehicula. Etiam nunc massa, pharetra vel quam id, posuere rhoncus quam. Quisque imperdiet arcu enim, nec aliquet justo auctor eget. Curabitur in metus nec nunc rhoncus faucibus vitae ac elit."
|
31
|
+
}
|
32
|
+
</div>
|
33
|
+
</Collapsible.Content>
|
34
|
+
</Collapsible>
|
35
|
+
<Collapsible
|
36
|
+
collapsed={isCollapsed}
|
37
|
+
icon={["plus", "minus"]}
|
38
|
+
padding="none"
|
39
|
+
>
|
40
|
+
<Collapsible.Main padding="sm"
|
41
|
+
{...props}
|
42
|
+
>
|
43
|
+
<div>{"Main Section"}</div>
|
44
|
+
</Collapsible.Main>
|
45
|
+
<Collapsible.Content>
|
46
|
+
<div>
|
47
|
+
{
|
48
|
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel erat sed purus hendrerit viverra. Duis et vestibulum metus. Sed consequat ut ante non vehicula. Etiam nunc massa, pharetra vel quam id, posuere rhoncus quam. Quisque imperdiet arcu enim, nec aliquet justo auctor eget. Curabitur in metus nec nunc rhoncus faucibus vitae ac elit."
|
49
|
+
}
|
50
|
+
</div>
|
51
|
+
</Collapsible.Content>
|
52
|
+
</Collapsible>
|
53
|
+
<Collapsible
|
54
|
+
collapsed={isCollapsed}
|
55
|
+
icon={["plus", "minus"]}
|
56
|
+
padding="none"
|
57
|
+
>
|
58
|
+
<Collapsible.Main padding="sm"
|
59
|
+
{...props}
|
60
|
+
>
|
61
|
+
<div>{"Main Section"}</div>
|
62
|
+
</Collapsible.Main>
|
63
|
+
<Collapsible.Content>
|
64
|
+
<div>
|
65
|
+
{
|
66
|
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel erat sed purus hendrerit viverra. Duis et vestibulum metus. Sed consequat ut ante non vehicula. Etiam nunc massa, pharetra vel quam id, posuere rhoncus quam. Quisque imperdiet arcu enim, nec aliquet justo auctor eget. Curabitur in metus nec nunc rhoncus faucibus vitae ac elit."
|
67
|
+
}
|
68
|
+
</div>
|
69
|
+
</Collapsible.Content>
|
70
|
+
</Collapsible>
|
71
|
+
</>
|
72
|
+
)
|
73
|
+
}
|
74
|
+
|
75
|
+
export default CollapsibleState
|
@@ -0,0 +1,3 @@
|
|
1
|
+
The `collapsed` prop allows you to toggle the collapsible with external controls (like buttons) when used in conjunction with our `useCollapsible` hook.
|
2
|
+
|
3
|
+
NOTE: you must import and declare the `useCollapsible` hook then pass its state to the collapsed prop of any Collapsible you wish to manage with the external control. See our code example for details.
|
@@ -2,12 +2,13 @@ examples:
|
|
2
2
|
|
3
3
|
rails:
|
4
4
|
- collapsible_default: Default
|
5
|
-
- collapsible_size: Size
|
6
|
-
- collapsible_color: Color
|
7
|
-
|
5
|
+
- collapsible_size: Icon Size
|
6
|
+
- collapsible_color: Icon Color
|
7
|
+
- collapsible_icons: Custom Icons
|
8
8
|
|
9
9
|
react:
|
10
10
|
- collapsible_default: Default
|
11
|
-
- collapsible_size: Size
|
12
|
-
- collapsible_color: Color
|
13
|
-
|
11
|
+
- collapsible_size: Icon Size
|
12
|
+
- collapsible_color: Icon Color
|
13
|
+
- collapsible_icons: Custom Icons
|
14
|
+
- collapsible_state: useCollapsible Hook
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export { default as CollapsibleDefault } from './_collapsible_default.jsx'
|
2
2
|
export { default as CollapsibleSize } from './_collapsible_size.jsx'
|
3
3
|
export { default as CollapsibleColor } from './_collapsible_color.jsx'
|
4
|
-
export { default as CollapsibleIcons } from './_collapsible_icons.jsx'
|
4
|
+
export { default as CollapsibleIcons } from './_collapsible_icons.jsx'
|
5
|
+
export {default as CollapsibleState } from './_collapsible_state.jsx'
|
@@ -17,6 +17,7 @@ const formatDate = (newDate: Date | string) => {
|
|
17
17
|
|
18
18
|
export const toMinute = (newDate: Date | string, timeZone?: string): string => {
|
19
19
|
const date = formatDate(newDate)
|
20
|
+
|
20
21
|
if (timeZone) {
|
21
22
|
return date.toLocaleTimeString(undefined, { timeZone, hour: "2-digit", minute: "2-digit" }).slice(3, 5);
|
22
23
|
} else {
|
@@ -26,6 +27,7 @@ export const toMinute = (newDate: Date | string, timeZone?: string): string => {
|
|
26
27
|
|
27
28
|
export const toHour = (newDate: Date | string, timeZone?: string): string => {
|
28
29
|
const date = formatDate(newDate)
|
30
|
+
|
29
31
|
if (timeZone) {
|
30
32
|
return date.toLocaleTimeString(undefined, { timeZone, hour: "numeric" }).split(' ')[0];
|
31
33
|
} else {
|
@@ -34,52 +36,53 @@ export const toHour = (newDate: Date | string, timeZone?: string): string => {
|
|
34
36
|
}
|
35
37
|
|
36
38
|
export const toDay = (newDate: Date | string, timeZone?: string): number => {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
if (timeZone) {
|
40
|
+
const date = new Date(formatDate(newDate).toLocaleString(undefined, { timeZone }));
|
41
|
+
return date.getDate()
|
42
|
+
} else {
|
43
|
+
const date = formatDate(newDate)
|
44
|
+
return date.getDate()
|
45
|
+
}
|
44
46
|
}
|
45
47
|
|
46
48
|
export const toDayAbbr = (newDate: Date | string): string => {
|
47
49
|
const date = formatDate(newDate)
|
48
|
-
return ABBR_DAYS[date.
|
50
|
+
return ABBR_DAYS[date.getDay()]
|
49
51
|
}
|
50
52
|
|
51
53
|
export const toWeekday = (newDate: Date | string): string => {
|
52
|
-
|
53
|
-
|
54
|
+
const date = formatDate(newDate)
|
55
|
+
return days[date.getDay()]
|
54
56
|
}
|
55
57
|
|
56
58
|
export const toMonth = (newDate: Date | string, timeZone?: string): string => {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
if (timeZone) {
|
60
|
+
const date = new Date(formatDate(newDate).toLocaleString(undefined, { timeZone }));
|
61
|
+
return months[date.getMonth()]
|
62
|
+
} else {
|
63
|
+
const date = formatDate(newDate)
|
64
|
+
return months[date.getMonth()]
|
65
|
+
}
|
64
66
|
}
|
65
67
|
|
66
68
|
export const toMonthNum = (newDate: Date | string): number => {
|
67
69
|
const date = formatDate(newDate)
|
68
|
-
return date.
|
70
|
+
return date.getMonth() + 1
|
69
71
|
}
|
70
72
|
|
71
73
|
export const toYear = (newDate: Date | string, timeZone?: string): number => {
|
72
74
|
if (timeZone) {
|
73
|
-
const date = new Date(newDate.toLocaleString(undefined, { timeZone }));
|
74
|
-
return date.
|
75
|
+
const date = new Date(formatDate(newDate).toLocaleString(undefined, { timeZone }));
|
76
|
+
return date.getFullYear()
|
75
77
|
} else {
|
76
|
-
const date =
|
77
|
-
return date.
|
78
|
+
const date = formatDate(newDate)
|
79
|
+
return date.getFullYear()
|
78
80
|
}
|
79
81
|
}
|
80
82
|
|
81
83
|
export const toTime = (newDate: Date | string, timeZone?: string): string => {
|
82
84
|
const date = formatDate(newDate)
|
85
|
+
|
83
86
|
if (timeZone) {
|
84
87
|
return date.toLocaleTimeString(undefined, { timeZone, timeStyle: "short" }).split(' ')[0];
|
85
88
|
} else {
|
@@ -88,21 +91,23 @@ export const toTime = (newDate: Date | string, timeZone?: string): string => {
|
|
88
91
|
}
|
89
92
|
|
90
93
|
export const toMeridiem = (newDate: Date | string, timeZone?: string): string => {
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
}
|
94
|
+
const date = formatDate(newDate)
|
95
|
+
|
96
|
+
if (timeZone) {
|
97
|
+
return date.toLocaleString(undefined, { timeZone, hour12: true }).slice(-2).charAt(0).toLocaleLowerCase();
|
98
|
+
} else {
|
99
|
+
return date.toLocaleString(undefined, { hour12: true }).slice(-2).charAt(0).toLocaleLowerCase();
|
100
|
+
}
|
97
101
|
}
|
98
102
|
|
99
103
|
export const toTimeZone = (newDate: Date | string, timeZone?: string): string => {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
}
|
104
|
+
const date = formatDate(newDate)
|
105
|
+
|
106
|
+
if (timeZone) {
|
107
|
+
return date.toLocaleString(undefined, { timeZone, timeZoneName: "short" }).split(' ')[3];
|
108
|
+
} else {
|
109
|
+
return date.toLocaleString(undefined, { timeZoneName: "short" }).split(' ')[3];
|
110
|
+
}
|
106
111
|
}
|
107
112
|
|
108
113
|
export const toTimeWithMeridiem = (newDate: Date | string, timeZone: string): string => {
|
@@ -111,8 +116,8 @@ export const toTimeWithMeridiem = (newDate: Date | string, timeZone: string): st
|
|
111
116
|
}
|
112
117
|
|
113
118
|
export const toIso = (newDate: Date | string): string => {
|
114
|
-
|
115
|
-
|
119
|
+
const date = formatDate(newDate)
|
120
|
+
return date.toISOString()
|
116
121
|
}
|
117
122
|
|
118
123
|
export const fromNow = (newDate: Date | string): string => {
|