@olenbetong/synergi-react 0.6.46 → 0.7.1
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.
- package/dist/esm/ob.react.js +1 -17
- package/dist/esm/ob.react.min.css.map +1 -1
- package/dist/esm/ob.react.min.js +1 -1
- package/dist/esm/ob.react.min.js.map +4 -4
- package/dist/iife/ob.react.js +1 -14
- package/dist/iife/ob.react.min.css.map +1 -1
- package/dist/iife/ob.react.min.js +1 -1
- package/dist/iife/ob.react.min.js.map +4 -4
- package/dist/styles/styles.css.map +1 -1
- package/es/DateNavigator/index.js +2 -2
- package/es/Portal/index.js +1 -1
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -1
- package/package.json +3 -4
- package/src/Checkbox/index.scss +78 -78
- package/src/Checkbox/index.tsx +62 -62
- package/src/ColorCard/index.scss +135 -135
- package/src/ColorCard/index.tsx +38 -38
- package/src/DateNavigator/index.scss +33 -33
- package/src/DateNavigator/index.tsx +66 -66
- package/src/LinkedCardList/index.scss +49 -49
- package/src/LinkedCardList/index.tsx +24 -24
- package/src/PageBanner/index.scss +71 -71
- package/src/PageBanner/index.tsx +41 -41
- package/src/Portal/index.tsx +24 -24
- package/src/ProgressBar/index.scss +76 -76
- package/src/ProgressBar/index.tsx +3 -3
- package/src/Sidebar/index.scss +41 -41
- package/src/Sidebar/index.tsx +107 -107
- package/src/Spinner/index.scss +45 -45
- package/src/Spinner/index.tsx +11 -11
- package/src/SplitContainer/index.scss +23 -23
- package/src/SplitContainer/index.tsx +222 -222
- package/src/ValueToggle/index.scss +37 -37
- package/src/ValueToggle/index.tsx +54 -54
- package/src/global.d.ts +1 -1
- package/src/index.ts +10 -11
- package/src/styles/_mixins.scss +16 -16
- package/src/useTranslation/index.ts +58 -58
package/src/ColorCard/index.scss
CHANGED
|
@@ -1,154 +1,154 @@
|
|
|
1
1
|
@import "../styles/variables";
|
|
2
2
|
|
|
3
3
|
.ObColorCard-root {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
4
|
+
--bg-color-border: black;
|
|
5
|
+
--bg-color-main: white;
|
|
6
|
+
--bg-size: 0.75rem;
|
|
7
|
+
--card-color: rgb(0, 0, 0);
|
|
8
|
+
|
|
9
|
+
align-items: stretch;
|
|
10
|
+
background-image: linear-gradient(to right, $brand-primary, $brand-primary 0.75rem, white 0.75rem, white);
|
|
11
|
+
background-image: linear-gradient(
|
|
12
|
+
to right,
|
|
13
|
+
var(--bg-color-border),
|
|
14
|
+
var(--bg-color-border) var(--bg-size),
|
|
15
|
+
var(--bg-color-main) var(--bg-size),
|
|
16
|
+
var(--bg-color-main)
|
|
17
|
+
);
|
|
18
|
+
border-radius: 0.25rem;
|
|
19
|
+
box-shadow: 0 1px 12px rgba(0, 0, 0, 0.15), 0 1px 6px rgba(0, 0, 0, 0.25);
|
|
20
|
+
color: #666;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
display: flex;
|
|
23
|
+
font-family: "Variable Bahnschrift", "Bahnschrift", "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
24
|
+
"Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
|
25
|
+
font-size: 1rem;
|
|
26
|
+
min-height: 10rem;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
transition: all ease-in-out 300ms;
|
|
29
|
+
|
|
30
|
+
&:nth-of-type(5n + 1) {
|
|
31
|
+
--bg-color-border: rgb(178, 108, 190);
|
|
32
|
+
}
|
|
33
|
+
&:nth-of-type(5n + 2) {
|
|
34
|
+
--bg-color-border: rgb(79, 164, 61);
|
|
35
|
+
}
|
|
36
|
+
&:nth-of-type(5n + 3) {
|
|
37
|
+
--bg-color-border: rgb(246, 170, 23);
|
|
38
|
+
}
|
|
39
|
+
&:nth-of-type(5n + 4) {
|
|
40
|
+
--bg-color-border: rgb(218, 93, 83);
|
|
41
|
+
}
|
|
42
|
+
&:nth-of-type(5n + 5) {
|
|
43
|
+
--bg-color-border: rgb(23, 162, 184);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&:hover,
|
|
47
|
+
&:focus {
|
|
48
|
+
/*--bg-size: 1rem;*/
|
|
49
|
+
--bg-color-main: #f5f5f5;
|
|
50
|
+
|
|
51
|
+
box-shadow: 0 3px 18px rgba(0, 0, 0, 0.15), 0 3px 12px rgba(0, 0, 0, 0.25);
|
|
52
|
+
color: #666;
|
|
53
|
+
text-decoration: none;
|
|
54
|
+
/*transform: scale(1.03) translateY(-3px);*/
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@media screen and (min-width: 48rem) {
|
|
58
|
+
font-size: 1.2rem;
|
|
59
|
+
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
.ObColorCard-column {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
63
|
+
display: flex;
|
|
64
|
+
flex: 1 1 100%;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
justify-content: space-between;
|
|
67
|
+
margin: 1rem 0;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
padding: 0.5rem 1.5rem 0.5rem 1rem;
|
|
70
|
+
text-overflow: ellipsis;
|
|
71
|
+
|
|
72
|
+
&:first-child {
|
|
73
|
+
margin-left: 0.75rem;
|
|
74
|
+
margin-left: var(--bg-size);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&.ObColorCard-minor {
|
|
78
|
+
border-right: 1px solid #e3e3e3;
|
|
79
|
+
flex: 0 0 4rem;
|
|
80
|
+
transition: margin ease-in-out 300ms;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@media screen and (min-width: 48rem) {
|
|
84
|
+
&.ObColorCard-minor {
|
|
85
|
+
flex: 0 0 8rem;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
.ObColorCard-detailLabel {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
color: #ccc;
|
|
92
|
+
font-size: 0.8rem;
|
|
93
|
+
text-transform: uppercase;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
.ObColorCard-detail {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
97
|
+
&:not(:last-child) {
|
|
98
|
+
margin-right: 1.5rem;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&.ObColorCard-primary,
|
|
102
|
+
&.ObColorCard-primary .ObColorCard-detailValue {
|
|
103
|
+
font-size: 1.25rem;
|
|
104
|
+
font-weight: 300;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&.ObColorCard-primary .ObColorCard-detailValue {
|
|
108
|
+
color: unset;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@media screen and (min-width: 48rem) {
|
|
112
|
+
font-size: 1rem;
|
|
113
|
+
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
.ObColorCard-detailValue {
|
|
117
|
-
|
|
117
|
+
color: #999;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
.ObColorCard-label {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
121
|
+
position: relative;
|
|
122
|
+
padding-left: 1.5rem;
|
|
123
|
+
/* white-space: nowrap; */
|
|
124
|
+
|
|
125
|
+
&:not(:last-child) {
|
|
126
|
+
margin-bottom: 1rem;
|
|
127
|
+
|
|
128
|
+
&::after {
|
|
129
|
+
content: "";
|
|
130
|
+
position: absolute;
|
|
131
|
+
width: 0.2rem;
|
|
132
|
+
height: calc(100% + 1rem);
|
|
133
|
+
border-left: 0.2rem dotted #666;
|
|
134
|
+
left: 0.25rem;
|
|
135
|
+
top: 0.5rem;
|
|
136
|
+
z-index: 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&::before {
|
|
141
|
+
background: white;
|
|
142
|
+
border: 0.2rem solid $brand-primary;
|
|
143
|
+
border: 0.2rem solid var(--bg-color-border);
|
|
144
|
+
border-radius: 50%;
|
|
145
|
+
content: "";
|
|
146
|
+
display: block;
|
|
147
|
+
height: 0.75rem;
|
|
148
|
+
left: 0;
|
|
149
|
+
position: absolute;
|
|
150
|
+
top: 0.3rem;
|
|
151
|
+
width: 0.75rem;
|
|
152
|
+
z-index: 1;
|
|
153
|
+
}
|
|
154
154
|
}
|
package/src/ColorCard/index.tsx
CHANGED
|
@@ -3,56 +3,56 @@ import "./index.scss";
|
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
|
|
5
5
|
export function ColorCard({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
as: Component,
|
|
7
|
+
children,
|
|
8
|
+
className,
|
|
9
|
+
href,
|
|
10
|
+
...other
|
|
11
11
|
}: Pick<React.HTMLAttributes<HTMLDivElement>, "id" | "className" | "children"> & {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
as?: "a" | "div" | "button" | "span" | "section" | "article";
|
|
13
|
+
href?: string;
|
|
14
14
|
}) {
|
|
15
|
-
|
|
15
|
+
const BaseElement = Component ? Component : href ? "a" : "div";
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
return (
|
|
18
|
+
<BaseElement className={clsx("ObColorCard-root", className)} href={href} {...other}>
|
|
19
|
+
{children}
|
|
20
|
+
</BaseElement>
|
|
21
|
+
);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function CardColumn({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
minor,
|
|
28
|
+
...other
|
|
29
29
|
}: React.HTMLAttributes<HTMLDivElement> & { minor?: boolean }) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
return (
|
|
31
|
+
<div className={clsx("ObColorCard-column", minor && "ObColorCard-minor", className)} {...other}>
|
|
32
|
+
{children}
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export function CardDetail({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
children,
|
|
39
|
+
className,
|
|
40
|
+
label,
|
|
41
|
+
primary,
|
|
42
|
+
...other
|
|
43
43
|
}: React.HTMLAttributes<HTMLDivElement> & { label?: React.ReactNode; primary?: boolean }) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
return (
|
|
45
|
+
<div className={clsx("ObColorCard-detail", primary && "ObColorCard-primary", className)} {...other}>
|
|
46
|
+
{label && <div className="ObColorCard-detailLabel">{label}</div>}
|
|
47
|
+
<div className="ObColorCard-detailValue">{children}</div>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export function CardLabel({ children, className, ...other }: React.HTMLAttributes<HTMLDivElement>) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
return (
|
|
54
|
+
<div className={clsx("ObColorCard-label", className)} {...other}>
|
|
55
|
+
{children}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
58
|
}
|
|
@@ -3,58 +3,58 @@
|
|
|
3
3
|
$date-select-height: 3rem;
|
|
4
4
|
|
|
5
5
|
.ObDateNavigator-icon {
|
|
6
|
-
|
|
6
|
+
display: inline-block;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
svg {
|
|
9
|
+
width: 0.625em;
|
|
10
|
+
position: relative;
|
|
11
|
+
top: -1px;
|
|
12
|
+
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.ObDateNavigator-root {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
background-color: hsl(220, 20%, 96%);
|
|
17
|
+
background-color: var(--block-header-color-bg);
|
|
18
|
+
display: flex;
|
|
19
|
+
font-size: 1rem;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
.ObDateNavigator-arrow {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
@include btn-reset;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
flex: 0 0 $date-select-height;
|
|
27
|
+
justify-content: center;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
height: $date-select-height;
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
text-align: center;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
&:hover {
|
|
35
|
+
background-color: #e3e3e3;
|
|
36
|
+
background-color: var(--block-header-button-hover);
|
|
37
|
+
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
.ObDateNavigator-arrowLeft {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
border-right: 1px solid #dddddd;
|
|
42
|
+
order: 1;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
.ObDateNavigator-arrowRight {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
border-left: 1px solid #dddddd;
|
|
47
|
+
order: 3;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
.ObDateNavigator-date {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
display: flex;
|
|
52
|
+
flex: 1 1 100%;
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
order: 2;
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
height: $date-select-height;
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
text-align: center;
|
|
60
60
|
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
import "./index.scss";
|
|
2
2
|
|
|
3
|
+
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
|
+
|
|
3
5
|
import clsx from "clsx";
|
|
4
6
|
import { useState } from "react";
|
|
5
7
|
|
|
6
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
7
|
-
|
|
8
8
|
function getUiCulture() {
|
|
9
|
-
|
|
9
|
+
return af?.userSession?.culture ?? "default";
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
function Arrow(props) {
|
|
13
|
-
|
|
13
|
+
const { direction, ...rest } = props;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
15
|
+
return (
|
|
16
|
+
<button
|
|
17
|
+
className={clsx(
|
|
18
|
+
"ObDateNavigator-arrow",
|
|
19
|
+
direction === "left" ? "ObDateNavigator-arrowLeft" : "ObDateNavigator-arrowRight"
|
|
20
|
+
)}
|
|
21
|
+
{...rest}
|
|
22
|
+
>
|
|
23
|
+
<span className="ObDateNavigator-icon">
|
|
24
|
+
{direction === "left" ? (
|
|
25
|
+
<svg aria-hidden="true" focusable="false" role="img" viewBox="0 0 320 512">
|
|
26
|
+
<path
|
|
27
|
+
fill="currentColor"
|
|
28
|
+
d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"
|
|
29
|
+
/>
|
|
30
|
+
</svg>
|
|
31
|
+
) : (
|
|
32
|
+
<svg aria-hidden="true" focusable="false" role="img" viewBox="0 0 320 512">
|
|
33
|
+
<path
|
|
34
|
+
fill="currentColor"
|
|
35
|
+
d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"
|
|
36
|
+
/>
|
|
37
|
+
</svg>
|
|
38
|
+
)}
|
|
39
|
+
</span>
|
|
40
|
+
</button>
|
|
41
|
+
);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const formatter = new Intl.DateTimeFormat(getUiCulture(), {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
weekday: "short",
|
|
46
|
+
day: "numeric",
|
|
47
|
+
month: "short",
|
|
48
|
+
year: "numeric",
|
|
49
|
+
timeZone: "utc",
|
|
50
50
|
});
|
|
51
51
|
const today = new Date();
|
|
52
52
|
const todayUtc = Date.UTC(today.getFullYear(), today.getMonth(), today.getDate());
|
|
@@ -54,39 +54,39 @@ const todayUtc = Date.UTC(today.getFullYear(), today.getMonth(), today.getDate()
|
|
|
54
54
|
const oneDay = 24 * 60 * 60 * 1000;
|
|
55
55
|
|
|
56
56
|
export function DateNavigator({ date: dateProp, onChange }: { date?: Date; onChange?: (date: Date) => void }) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
let [internalDate, setInternalDate] = useState(new Date());
|
|
58
|
+
const date = dateProp ?? internalDate;
|
|
59
|
+
const dateUtc = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
|
|
60
|
+
let dateValue = new Date(dateUtc);
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
let text = formatter.format(dateValue);
|
|
63
|
+
let altText;
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
if (todayUtc === dateUtc) {
|
|
66
|
+
altText = getLocalizedString("Today");
|
|
67
|
+
} else if (todayUtc === dateUtc + oneDay) {
|
|
68
|
+
altText = getLocalizedString("Yesterday");
|
|
69
|
+
} else if (todayUtc === dateUtc - oneDay) {
|
|
70
|
+
altText = getLocalizedString("Tomorrow");
|
|
71
|
+
}
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
if (altText) {
|
|
74
|
+
text = `${altText}, ${text}`;
|
|
75
|
+
}
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
function handleDateChanged(date: Date) {
|
|
78
|
+
if (typeof onChange === "function") {
|
|
79
|
+
onChange(date);
|
|
80
|
+
} else {
|
|
81
|
+
setInternalDate(date);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
return (
|
|
86
|
+
<div className="ObDateNavigator-root">
|
|
87
|
+
<Arrow direction="left" onClick={() => handleDateChanged(new Date(dateUtc - oneDay))} />
|
|
88
|
+
<div className="ObDateNavigator-date">{text}</div>
|
|
89
|
+
<Arrow direction="right" onClick={() => handleDateChanged(new Date(dateUtc + oneDay))} />
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
92
|
}
|