dce-reactkit 4.2.2 → 4.2.4-beta-timestamp.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/cjs/index.js +41 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/TabBox.d.ts +1 -0
- package/dist/esm/index.js +41 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/TabBox.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/TabBox.tsx +7 -1
- package/src/helpers/getTimestampFromTimeInfoInET.ts +42 -9
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -21,6 +21,8 @@ type Props = {
|
|
|
21
21
|
noBottomMargin?: boolean,
|
|
22
22
|
// If true, don't add padding to bottom of tab box
|
|
23
23
|
noBottomPadding?: boolean,
|
|
24
|
+
// Minimum width of the tab part of the box that contains the title (css units)
|
|
25
|
+
minTitleWidth?: string,
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
/*------------------------------------------------------------------------*/
|
|
@@ -121,6 +123,7 @@ const TabBox: React.FC<Props> = (props) => {
|
|
|
121
123
|
topRightChildren,
|
|
122
124
|
noBottomPadding,
|
|
123
125
|
noBottomMargin,
|
|
126
|
+
minTitleWidth,
|
|
124
127
|
} = props;
|
|
125
128
|
|
|
126
129
|
/*------------------------------------------------------------------------*/
|
|
@@ -134,7 +137,10 @@ const TabBox: React.FC<Props> = (props) => {
|
|
|
134
137
|
|
|
135
138
|
{/* Title Row with Left and Right sections */}
|
|
136
139
|
<div className="TabBox-title-container">
|
|
137
|
-
<div
|
|
140
|
+
<div
|
|
141
|
+
className="TabBox-title"
|
|
142
|
+
style={{ minWidth: minTitleWidth }}
|
|
143
|
+
>
|
|
138
144
|
{title}
|
|
139
145
|
</div>
|
|
140
146
|
{topRightChildren && (
|
|
@@ -36,21 +36,54 @@ const getTimestampFromTimeInfoInET = (
|
|
|
36
36
|
minute,
|
|
37
37
|
} = opts;
|
|
38
38
|
|
|
39
|
-
// Determine if the date is in DST in Eastern Time
|
|
40
|
-
const tempDate = new Date(year, month - 1, day);
|
|
41
|
-
const janOffset = new Date(year, 0, 1).getTimezoneOffset();
|
|
42
|
-
const isDST = tempDate.getTimezoneOffset() < janOffset;
|
|
43
|
-
const etOffset = isDST ? '-04:00' : '-05:00';
|
|
44
|
-
|
|
45
39
|
// Format with leading zeroes
|
|
46
40
|
const mm = padZerosLeft(month, 2);
|
|
47
41
|
const dd = padZerosLeft(day, 2);
|
|
48
42
|
const hh = padZerosLeft(hour, 2);
|
|
49
43
|
const min = padZerosLeft(minute, 2);
|
|
50
44
|
|
|
51
|
-
//
|
|
52
|
-
const
|
|
53
|
-
const
|
|
45
|
+
// Use Intl.DateTimeFormat to get the ET offset for the given date
|
|
46
|
+
const dateForET = new Date(Date.UTC(year, month - 1, day, hour, minute, 0));
|
|
47
|
+
const options: Intl.DateTimeFormatOptions = {
|
|
48
|
+
timeZone: 'America/New_York',
|
|
49
|
+
year: 'numeric',
|
|
50
|
+
month: '2-digit',
|
|
51
|
+
day: '2-digit',
|
|
52
|
+
hour: '2-digit',
|
|
53
|
+
minute: '2-digit',
|
|
54
|
+
second: '2-digit',
|
|
55
|
+
hour12: false,
|
|
56
|
+
};
|
|
57
|
+
const parts: Intl.DateTimeFormatPart[] = new Intl.DateTimeFormat('en-US', options).formatToParts(dateForET);
|
|
58
|
+
const etYear: string | undefined = parts.find((p: Intl.DateTimeFormatPart) => {
|
|
59
|
+
return p.type === 'year';
|
|
60
|
+
})?.value;
|
|
61
|
+
const etMonth: string | undefined = parts.find((p: Intl.DateTimeFormatPart) => {
|
|
62
|
+
return p.type === 'month';
|
|
63
|
+
})?.value;
|
|
64
|
+
const etDay: string | undefined = parts.find((p: Intl.DateTimeFormatPart) => {
|
|
65
|
+
return p.type === 'day';
|
|
66
|
+
})?.value;
|
|
67
|
+
const etHour: string | undefined = parts.find((p: Intl.DateTimeFormatPart) => {
|
|
68
|
+
return p.type === 'hour';
|
|
69
|
+
})?.value;
|
|
70
|
+
const etMinute: string | undefined = parts.find((p: Intl.DateTimeFormatPart) => {
|
|
71
|
+
return p.type === 'minute';
|
|
72
|
+
})?.value;
|
|
73
|
+
const etSecond: string | undefined = parts.find((p: Intl.DateTimeFormatPart) => {
|
|
74
|
+
return p.type === 'second';
|
|
75
|
+
})?.value;
|
|
76
|
+
|
|
77
|
+
// Build ET date string and parse as if local, then get UTC timestamp
|
|
78
|
+
if (!etYear || !etMonth || !etDay || !etHour || !etMinute || !etSecond) {
|
|
79
|
+
throw new ErrorWithCode(
|
|
80
|
+
'Failed to parse date parts from Intl.DateTimeFormat',
|
|
81
|
+
ReactKitErrorCode.ETTimestampInvalid,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
const etDateString: string = `${etYear}-${etMonth}-${etDay}T${etHour}:${etMinute}:${etSecond}`;
|
|
85
|
+
const etDate: Date = new Date(etDateString);
|
|
86
|
+
const timestamp: number = etDate.getTime();
|
|
54
87
|
|
|
55
88
|
// Verify that the timestamp is correct
|
|
56
89
|
const timeInfoInET = getTimeInfoInET(timestamp);
|