playbook_ui 12.37.0 → 12.38.0.pre.alpha.PLAY932removemomentqp1088
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_date/_date.tsx +7 -8
- data/app/pb_kits/playbook/pb_date/docs/_date_alignment.jsx +2 -2
- data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +29 -5
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +2 -2
- data/app/pb_kits/playbook/pb_date/docs/_date_variants.jsx +5 -5
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +18 -8
- data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +45 -39
- data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +45 -31
- data/app/pb_kits/playbook/pb_date_range_stacked/_date_range_stacked.tsx +5 -3
- data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +24 -21
- data/app/pb_kits/playbook/pb_date_time/_date_time.tsx +1 -1
- data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +1 -1
- data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.tsx +2 -2
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.test.js +1 -1
- data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.tsx +6 -8
- data/app/pb_kits/playbook/pb_kit/dateTime.ts +347 -61
- data/app/pb_kits/playbook/pb_label_value/_label_value.tsx +52 -31
- data/app/pb_kits/playbook/pb_message/_message.tsx +24 -24
- data/app/pb_kits/playbook/pb_time/_time.tsx +9 -11
- data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +46 -49
- data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.tsx +4 -6
- data/app/pb_kits/playbook/pb_timestamp/_timestamp.tsx +11 -11
- data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +8 -11
- data/dist/playbook-rails.js +7 -279
- data/lib/playbook/version.rb +2 -2
- metadata +7 -8
- data/app/pb_kits/playbook/pb_logistic/_logistic.jsx +0 -120
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1acc22a656ca63996a3b72d620ec59eb2fd323be9c3d6672449495c8c6781e3
|
4
|
+
data.tar.gz: 9029b42a09b0db1639360ae2addb2f6f35fd9ec488af53d829dd241e88cce167
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faf876a9e1a26091d6cc292382e99220ca51b8937616cf96d793dbf886572daff5dc7a65bb4ce9c8d2e4c53dc2674acc61dc6e03a2e41db70e1ee2868f9f2a39
|
7
|
+
data.tar.gz: a5c43e9e88c057548d4bc656352ae3a4fa92f6d8119ff6c339933d25e0baea9aa39e45888826a720489b1b3a38efb82823e01d94130301b09c27d7eb10c90013
|
@@ -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";
|
5
4
|
import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
|
6
5
|
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:
|
23
|
+
value: Date;
|
24
24
|
};
|
25
25
|
|
26
26
|
const PbDate = (props: PbDateProps) => {
|
@@ -37,12 +37,11 @@ const PbDate = (props: PbDateProps) => {
|
|
37
37
|
value,
|
38
38
|
} = props;
|
39
39
|
|
40
|
-
const
|
41
|
-
const
|
42
|
-
const
|
43
|
-
const
|
44
|
-
const
|
45
|
-
const currentYear = new Date().getFullYear().toString();
|
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();
|
46
45
|
|
47
46
|
const ariaProps = buildAriaProps(aria);
|
48
47
|
const dataProps = buildDataProps(data);
|
@@ -7,7 +7,7 @@ const DateAlignment = (props) => {
|
|
7
7
|
<FormattedDate
|
8
8
|
dayOfWeek
|
9
9
|
icon
|
10
|
-
value=
|
10
|
+
value={new Date('25 Dec 1995')}
|
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=
|
20
|
+
value={new Date('25 Dec 2020')}
|
21
21
|
{...props}
|
22
22
|
/>
|
23
23
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import { Date as FormattedDate } from '../../'
|
2
|
+
import { Date as FormattedDate, Caption, Title } from '../../'
|
3
3
|
|
4
4
|
const DateDefault = (props) => {
|
5
5
|
return (
|
@@ -12,9 +12,20 @@ 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
|
+
|
15
26
|
<FormattedDate
|
16
27
|
size="sm"
|
17
|
-
value=
|
28
|
+
value={new Date('03 Aug 2012')}
|
18
29
|
{...props}
|
19
30
|
/>
|
20
31
|
|
@@ -23,7 +34,7 @@ const DateDefault = (props) => {
|
|
23
34
|
<FormattedDate
|
24
35
|
showDayOfWeek
|
25
36
|
size="sm"
|
26
|
-
value=
|
37
|
+
value={new Date('03 Dec 2017')}
|
27
38
|
{...props}
|
28
39
|
/>
|
29
40
|
|
@@ -37,8 +48,21 @@ const DateDefault = (props) => {
|
|
37
48
|
|
38
49
|
<br />
|
39
50
|
|
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
|
+
|
40
64
|
<FormattedDate
|
41
|
-
value=
|
65
|
+
value={new Date('03 Aug 2012')}
|
42
66
|
{...props}
|
43
67
|
/>
|
44
68
|
|
@@ -46,7 +70,7 @@ const DateDefault = (props) => {
|
|
46
70
|
|
47
71
|
<FormattedDate
|
48
72
|
showDayOfWeek
|
49
|
-
value=
|
73
|
+
value={new Date('03 Dec 2017')}
|
50
74
|
{...props}
|
51
75
|
/>
|
52
76
|
</>
|
@@ -21,7 +21,7 @@ const DateUnstyled = (props) => {
|
|
21
21
|
<Title size={1}>
|
22
22
|
<FormattedDate
|
23
23
|
unstyled
|
24
|
-
value=
|
24
|
+
value={new Date('25 Dec 1995')}
|
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=
|
39
|
+
value={new Date('25 Dec 1995')}
|
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=
|
10
|
+
value={new Date('25 Dec 1995')}
|
11
11
|
{...props}
|
12
12
|
/>
|
13
13
|
|
@@ -15,7 +15,7 @@ const DateVariants = (props) => {
|
|
15
15
|
<br />
|
16
16
|
|
17
17
|
<FormattedDate
|
18
|
-
value=
|
18
|
+
value={new Date('25 Dec 1995')}
|
19
19
|
{...props}
|
20
20
|
/>
|
21
21
|
|
@@ -24,7 +24,7 @@ const DateVariants = (props) => {
|
|
24
24
|
|
25
25
|
<FormattedDate
|
26
26
|
showIcon
|
27
|
-
value=
|
27
|
+
value={new Date('25 Dec 1995')}
|
28
28
|
{...props}
|
29
29
|
/>
|
30
30
|
|
@@ -33,7 +33,7 @@ const DateVariants = (props) => {
|
|
33
33
|
|
34
34
|
<FormattedDate
|
35
35
|
showDayOfWeek
|
36
|
-
value=
|
36
|
+
value={new Date('25 Dec 1995')}
|
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=
|
46
|
+
value={new Date('25 Dec 1995')}
|
47
47
|
{...props}
|
48
48
|
/>
|
49
49
|
</div>
|
@@ -1,16 +1,26 @@
|
|
1
1
|
/* eslint-disable no-console */
|
2
2
|
import React from 'react'
|
3
|
-
import moment from 'moment'
|
4
3
|
import { fireEvent, render, screen, waitFor, within } from '../utilities/test-utils'
|
5
4
|
|
6
5
|
import DatePicker from './_date_picker'
|
6
|
+
import DateTime from "../pb_kit/dateTime.ts"
|
7
7
|
import { getTimezoneText } from './plugins/timeSelect'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
9
|
jest.setSystemTime(new Date('01/01/2020'));
|
12
10
|
const DEFAULT_DATE = new Date()
|
13
11
|
|
12
|
+
const formatDate = (date) => {
|
13
|
+
const month = (date.getMonth() + 1).toString().padStart(2, "0")
|
14
|
+
const day = (date.getDate()).toString().padStart(2, "0")
|
15
|
+
const year = date.getFullYear()
|
16
|
+
|
17
|
+
return `${month}/${day}/${year}`
|
18
|
+
}
|
19
|
+
|
20
|
+
Date.prototype.formatDate = function () {
|
21
|
+
return formatDate(this)
|
22
|
+
}
|
23
|
+
|
14
24
|
describe('DatePicker Kit', () => {
|
15
25
|
beforeEach(() => {
|
16
26
|
jest.spyOn(console, 'error').mockImplementation(() => { });
|
@@ -158,6 +168,7 @@ describe('DatePicker Kit', () => {
|
|
158
168
|
expect(input).toHaveValue('01/01/2020 at 12:00 PM')
|
159
169
|
})
|
160
170
|
})
|
171
|
+
|
161
172
|
test('shows DatePicker QuickPick dropdown and adds correct date to input', async () => {
|
162
173
|
const testId = 'datepicker-quick-pick'
|
163
174
|
render(
|
@@ -197,10 +208,10 @@ describe('DatePicker Kit', () => {
|
|
197
208
|
)
|
198
209
|
|
199
210
|
await waitFor(() => {
|
200
|
-
expect(input).toHaveValue(
|
211
|
+
expect(input).toHaveValue(DateTime.getYearStartDate(new Date()).formatDate() + " to " + DateTime.getYearEndDate(new Date()).formatDate())
|
201
212
|
})
|
202
|
-
|
203
213
|
})
|
214
|
+
|
204
215
|
test('shows DatePicker QuickPick ranges ending today', async () => {
|
205
216
|
const testId = 'datepicker-quick-pick-ends-today'
|
206
217
|
render(
|
@@ -225,7 +236,7 @@ describe('DatePicker Kit', () => {
|
|
225
236
|
cancelable: true,
|
226
237
|
}),
|
227
238
|
)
|
228
|
-
|
239
|
+
|
229
240
|
const thisYear = within(kit).getByText('This year')
|
230
241
|
|
231
242
|
fireEvent(
|
@@ -237,8 +248,7 @@ describe('DatePicker Kit', () => {
|
|
237
248
|
)
|
238
249
|
|
239
250
|
await waitFor(() => {
|
240
|
-
expect(input).toHaveValue(
|
251
|
+
expect(input).toHaveValue(DateTime.getYearStartDate(new Date()).formatDate() + " to " + new Date().formatDate())
|
241
252
|
})
|
242
|
-
|
243
253
|
})
|
244
254
|
})
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import DateTime from '../../pb_kit/dateTime';
|
2
2
|
|
3
3
|
type FpTypes = {
|
4
4
|
setDate: (arg0: any, arg1: boolean) => void,
|
@@ -23,37 +23,44 @@ let activeLabel = ""
|
|
23
23
|
|
24
24
|
const quickPickPlugin = (thisRangesEndToday: boolean) => {
|
25
25
|
return function (fp: FpTypes & any): any {
|
26
|
-
const
|
27
|
-
const
|
28
|
-
|
29
|
-
const
|
26
|
+
const today = new Date()
|
27
|
+
const yesterday = DateTime.getYesterdayDate(new Date())
|
28
|
+
|
29
|
+
const thisWeekStartDate = DateTime.getFirstDayOfWeek(new Date())
|
30
|
+
const thisWeekEndDate = thisRangesEndToday ? new Date() : DateTime.getLastDayOfWeek(new Date())
|
31
|
+
const lastWeekStartDate = DateTime.getPreviousWeekStartDate(new Date())
|
32
|
+
const lastWeekEndDate = DateTime.getPreviousWeekEndDate(new Date())
|
33
|
+
|
34
|
+
const thisMonthStartDate = DateTime.getMonthStartDate(new Date())
|
35
|
+
const thisMonthEndDate = thisRangesEndToday ? new Date() : DateTime.getMonthEndDate(new Date())
|
36
|
+
const lastMonthStartDate = DateTime.getPreviousMonthStartDate(new Date())
|
37
|
+
const lastMonthEndDate = DateTime.getPreviousMonthEndDate(new Date())
|
38
|
+
|
39
|
+
const thisQuarterStartDate = DateTime.getQuarterStartDate(new Date())
|
40
|
+
const thisQuarterEndDate = thisRangesEndToday ? new Date() : DateTime.getQuarterEndDate(new Date())
|
41
|
+
const lastQuarterStartDate = DateTime.getPreviousQuarterStartDate(new Date())
|
42
|
+
const lastQuarterEndDate = DateTime.getPreviousQuarterEndDate(new Date())
|
43
|
+
|
44
|
+
const thisYearStartDate = DateTime.getYearStartDate(new Date())
|
45
|
+
const thisYearEndDate = thisRangesEndToday ? new Date() : DateTime.getYearEndDate(new Date())
|
46
|
+
const lastYearStartDate = DateTime.getPreviousYearStartDate(new Date())
|
47
|
+
const lastYearEndDate = DateTime.getPreviousYearEndDate(new Date())
|
30
48
|
|
31
49
|
// variable that holds the ranges available
|
32
50
|
const ranges = {
|
33
|
-
'Today': [
|
34
|
-
'Yesterday': [
|
35
|
-
'This week': [
|
36
|
-
'This month': [
|
37
|
-
'This quarter': [
|
38
|
-
'This year': [
|
39
|
-
'Last week': [
|
40
|
-
|
41
|
-
|
42
|
-
]
|
43
|
-
'Last month': [
|
44
|
-
moment().subtract(1, 'month').startOf('month').toDate(),
|
45
|
-
moment().subtract(1, 'month').endOf('month').toDate()
|
46
|
-
],
|
47
|
-
'Last quarter': [
|
48
|
-
moment().subtract(1, 'quarter').startOf('quarter').toDate(),
|
49
|
-
moment().subtract(1, 'quarter').endOf('quarter').toDate()
|
50
|
-
],
|
51
|
-
'Last year': [
|
52
|
-
moment().subtract(1, 'year').startOf('year').toDate(),
|
53
|
-
moment().subtract(1, 'year').endOf('year').toDate()
|
54
|
-
]
|
51
|
+
'Today': [today, today],
|
52
|
+
'Yesterday': [yesterday, yesterday],
|
53
|
+
'This week': [thisWeekStartDate, thisWeekEndDate],
|
54
|
+
'This month': [thisMonthStartDate, thisMonthEndDate],
|
55
|
+
'This quarter': [thisQuarterStartDate, thisQuarterEndDate],
|
56
|
+
'This year': [thisYearStartDate, thisYearEndDate],
|
57
|
+
'Last week': [lastWeekStartDate, lastWeekEndDate],
|
58
|
+
'Last month': [lastMonthStartDate, lastMonthEndDate],
|
59
|
+
'Last quarter': [lastQuarterStartDate, lastQuarterEndDate],
|
60
|
+
'Last year': [lastYearStartDate, lastYearEndDate]
|
55
61
|
}
|
56
|
-
|
62
|
+
|
63
|
+
// creating the ul element for the nav dropdown and giving it classnames
|
57
64
|
const rangesNav = document.createElement('ul');
|
58
65
|
|
59
66
|
// creating the pluginData object that will hold the properties of this plugin
|
@@ -64,11 +71,11 @@ const quickPickPlugin = (thisRangesEndToday: boolean) => {
|
|
64
71
|
};
|
65
72
|
|
66
73
|
/**
|
67
|
-
|
68
|
-
|
69
|
-
|
74
|
+
* @param {string} label
|
75
|
+
* @returns HTML Element
|
76
|
+
*/
|
70
77
|
|
71
|
-
//function for creating the range buttons in the nav
|
78
|
+
// function for creating the range buttons in the nav
|
72
79
|
const addRangeButton = (label: string) => {
|
73
80
|
|
74
81
|
// creating new elements to mimick selectable card component
|
@@ -88,7 +95,7 @@ const quickPickPlugin = (thisRangesEndToday: boolean) => {
|
|
88
95
|
// append the li item to the ul rangeNav prop
|
89
96
|
pluginData.rangesNav.appendChild(item);
|
90
97
|
|
91
|
-
// return the ranges
|
98
|
+
// return the ranges button prop
|
92
99
|
return pluginData.rangesButtons[label];
|
93
100
|
};
|
94
101
|
|
@@ -98,7 +105,7 @@ const quickPickPlugin = (thisRangesEndToday: boolean) => {
|
|
98
105
|
if (current) {
|
99
106
|
current.classList.remove('active');
|
100
107
|
}
|
101
|
-
|
108
|
+
|
102
109
|
if (selectedDates.length > 0 && activeLabel) {
|
103
110
|
pluginData.rangesButtons[activeLabel].classList.add('active');
|
104
111
|
}
|
@@ -109,16 +116,15 @@ const quickPickPlugin = (thisRangesEndToday: boolean) => {
|
|
109
116
|
selectedDates[1].toDateString() === pluginData.ranges[activeLabel][1].toDateString()
|
110
117
|
}
|
111
118
|
|
112
|
-
|
113
119
|
return {
|
114
|
-
// onReady is a hook from flatpickr that runs when
|
120
|
+
// onReady is a hook from flatpickr that runs when calendar is in a ready state
|
115
121
|
onReady(selectedDates: Array<Date>) {
|
116
122
|
// loop through the ranges and create an anchor tag for each range and add an event listener to set the date when user clicks on a date range
|
117
123
|
for (const [label, range] of Object.entries(pluginData.ranges)) {
|
118
124
|
addRangeButton(label).addEventListener('click', function () {
|
119
125
|
|
120
|
-
const start =
|
121
|
-
const end =
|
126
|
+
const start = new Date(range[0]);
|
127
|
+
const end = new Date(range[1]);
|
122
128
|
|
123
129
|
if (!start) {
|
124
130
|
fp.clear();
|
@@ -170,4 +176,4 @@ const quickPickPlugin = (thisRangesEndToday: boolean) => {
|
|
170
176
|
};
|
171
177
|
}
|
172
178
|
|
173
|
-
export default quickPickPlugin;
|
179
|
+
export default quickPickPlugin;
|
@@ -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
|
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,18 +21,16 @@ type DateRangeInlineProps = {
|
|
21
21
|
endDate?: Date;
|
22
22
|
};
|
23
23
|
|
24
|
-
const dateTimestamp = (dateValue: Date
|
25
|
-
const date = new DateTime({ value: dateValue });
|
24
|
+
const dateTimestamp = (dateValue: Date, includeYear: boolean) => {
|
26
25
|
if (includeYear) {
|
27
|
-
return `${
|
26
|
+
return `${DateTime.toMonth(dateValue)} ${DateTime.toDay(dateValue)}, ${DateTime.toYear(dateValue)}`;
|
28
27
|
} else {
|
29
|
-
return `${
|
28
|
+
return `${DateTime.toMonth(dateValue)} ${DateTime.toDay(dateValue)}`;
|
30
29
|
}
|
31
30
|
};
|
32
31
|
|
33
|
-
const dateTimeIso = (dateValue: Date
|
34
|
-
|
35
|
-
return date.toIso();
|
32
|
+
const dateTimeIso = (dateValue: Date) => {
|
33
|
+
return DateTime.toIso(dateValue);
|
36
34
|
};
|
37
35
|
|
38
36
|
const DateRangeInline = (props: DateRangeInlineProps) => {
|
@@ -52,14 +50,17 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
|
|
52
50
|
<>
|
53
51
|
{icon && (
|
54
52
|
<>
|
55
|
-
<Body color="light"
|
56
|
-
|
57
|
-
className="pb_date_range_inline_icon"
|
58
|
-
dark={dark}
|
59
|
-
fixedWidth
|
60
|
-
icon="calendar-alt"
|
61
|
-
size={size}
|
53
|
+
<Body color="light"
|
54
|
+
key={Math.random()}
|
62
55
|
tag="span"
|
56
|
+
>
|
57
|
+
<Icon
|
58
|
+
className="pb_date_range_inline_icon"
|
59
|
+
dark={dark}
|
60
|
+
fixedWidth
|
61
|
+
icon="calendar-alt"
|
62
|
+
size={size}
|
63
|
+
tag="span"
|
63
64
|
/>
|
64
65
|
</Body>
|
65
66
|
</>
|
@@ -78,7 +79,7 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
|
|
78
79
|
|
79
80
|
const dateRangeClasses = buildCss("pb_date_range_inline_kit", align);
|
80
81
|
const dataProps = buildDataProps(data)
|
81
|
-
const renderTime = (date: Date
|
82
|
+
const renderTime = (date: Date) => {
|
82
83
|
return (
|
83
84
|
<time dateTime={dateTimeIso(date)}>
|
84
85
|
{dateInCurrentYear() ? (
|
@@ -92,24 +93,30 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
|
|
92
93
|
|
93
94
|
return (
|
94
95
|
<div
|
95
|
-
|
96
|
-
|
96
|
+
{...dataProps}
|
97
|
+
className={classnames(dateRangeClasses, globalProps(props), className)}
|
97
98
|
>
|
98
99
|
<div className="pb_date_range_inline_wrapper">
|
99
100
|
{size == "xs" && (
|
100
101
|
<>
|
101
102
|
{iconContent()}
|
102
|
-
<Caption dark={dark}
|
103
|
+
<Caption dark={dark}
|
104
|
+
tag="span"
|
105
|
+
>
|
103
106
|
{renderTime(startDate)}
|
104
107
|
</Caption>
|
105
|
-
<Caption dark={dark}
|
108
|
+
<Caption dark={dark}
|
109
|
+
tag="span"
|
110
|
+
>
|
106
111
|
<Icon
|
107
|
-
|
108
|
-
|
109
|
-
|
112
|
+
className="pb_date_range_inline_arrow"
|
113
|
+
fixedWidth
|
114
|
+
icon="long-arrow-right"
|
110
115
|
/>
|
111
116
|
</Caption>
|
112
|
-
<Caption dark={dark}
|
117
|
+
<Caption dark={dark}
|
118
|
+
tag="span"
|
119
|
+
>
|
113
120
|
{renderTime(endDate)}
|
114
121
|
</Caption>
|
115
122
|
</>
|
@@ -118,18 +125,25 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
|
|
118
125
|
{size == "sm" && (
|
119
126
|
<>
|
120
127
|
{iconContent()}
|
121
|
-
<Body dark={dark}
|
128
|
+
<Body dark={dark}
|
129
|
+
tag="span"
|
130
|
+
>
|
122
131
|
{renderTime(startDate)}
|
123
132
|
</Body>
|
124
|
-
<Body color="light"
|
125
|
-
<Icon
|
126
|
-
className="pb_date_range_inline_arrow"
|
133
|
+
<Body color="light"
|
127
134
|
dark={dark}
|
128
|
-
|
129
|
-
|
135
|
+
tag="span"
|
136
|
+
>
|
137
|
+
<Icon
|
138
|
+
className="pb_date_range_inline_arrow"
|
139
|
+
dark={dark}
|
140
|
+
fixedWidth
|
141
|
+
icon="long-arrow-right"
|
130
142
|
/>
|
131
143
|
</Body>
|
132
|
-
<Body dark={dark}
|
144
|
+
<Body dark={dark}
|
145
|
+
tag="span"
|
146
|
+
>
|
133
147
|
{renderTime(endDate)}
|
134
148
|
</Body>
|
135
149
|
</>
|
@@ -14,9 +14,9 @@ type DateRangeStackedProps = {
|
|
14
14
|
className?: string | string[],
|
15
15
|
data?: string,
|
16
16
|
dark?: boolean,
|
17
|
-
endDate:
|
17
|
+
endDate: Date,
|
18
18
|
id?: string,
|
19
|
-
startDate:
|
19
|
+
startDate: Date,
|
20
20
|
}
|
21
21
|
|
22
22
|
const DateRangeStacked = (props: DateRangeStackedProps) => {
|
@@ -29,7 +29,9 @@ const DateRangeStacked = (props: DateRangeStackedProps) => {
|
|
29
29
|
const dataProps = buildDataProps(data)
|
30
30
|
|
31
31
|
return (
|
32
|
-
<div {...dataProps}
|
32
|
+
<div {...dataProps}
|
33
|
+
className={css}
|
34
|
+
>
|
33
35
|
<Flex vertical="center">
|
34
36
|
<FlexItem>
|
35
37
|
<DateYearStacked
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React from "react";
|
2
2
|
|
3
3
|
import classnames from "classnames";
|
4
|
-
import DateTime from "../pb_kit/dateTime";
|
5
4
|
import { buildCss, buildDataProps } from "../utilities/props";
|
6
5
|
import { globalProps } from "../utilities/globalProps";
|
6
|
+
import DateTime from '../pb_kit/dateTime';
|
7
7
|
|
8
8
|
import Caption from "../pb_caption/_caption";
|
9
9
|
import Title from "../pb_title/_title";
|
@@ -14,7 +14,7 @@ type DateStackedProps = {
|
|
14
14
|
className?: string | string[];
|
15
15
|
dark?: boolean;
|
16
16
|
data?: string;
|
17
|
-
date:
|
17
|
+
date: Date;
|
18
18
|
size?: "sm" | "md";
|
19
19
|
id?: string;
|
20
20
|
reverse?: boolean;
|
@@ -45,39 +45,42 @@ const DateStacked = (props: DateStackedProps) => {
|
|
45
45
|
className
|
46
46
|
);
|
47
47
|
|
48
|
-
const currentYear = new Date().getFullYear()
|
49
|
-
const
|
50
|
-
const inputYear = dateTimestamp.toYear().toString();
|
48
|
+
const currentYear = new Date().getFullYear()
|
49
|
+
const inputYear = DateTime.toYear(date);
|
51
50
|
const dataProps = buildDataProps(data)
|
52
51
|
|
53
52
|
return (
|
54
53
|
<>
|
55
54
|
{bold == false ? (
|
56
|
-
<div {...dataProps}
|
55
|
+
<div {...dataProps}
|
56
|
+
className={classes}
|
57
|
+
>
|
57
58
|
<div className="pb_date_stacked_day_month">
|
58
|
-
<Caption text={
|
59
|
+
<Caption text={DateTime.toMonth(date).toUpperCase()} />
|
59
60
|
<Title
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
dark={dark}
|
62
|
+
size={sizes[size]}
|
63
|
+
text={DateTime.toDay(date).toString()}
|
63
64
|
/>
|
64
65
|
</div>
|
65
66
|
{currentYear != inputYear && <Caption size="xs">{inputYear}</Caption>}
|
66
67
|
</div>
|
67
68
|
) : (
|
68
|
-
<div {...dataProps}
|
69
|
+
<div {...dataProps}
|
70
|
+
className={classes}
|
71
|
+
>
|
69
72
|
<div className="pb_date_stacked_day_month">
|
70
|
-
<Title
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
<Title
|
74
|
+
bold
|
75
|
+
dark={dark}
|
76
|
+
size="4"
|
77
|
+
text={DateTime.toMonth(date)}
|
75
78
|
/>
|
76
|
-
<Title
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
<Title
|
80
|
+
bold
|
81
|
+
dark={dark}
|
82
|
+
size="4"
|
83
|
+
text={DateTime.toDay(date).toString()}
|
81
84
|
/>
|
82
85
|
{currentYear != inputYear && <Title size="4">{inputYear}</Title>}
|
83
86
|
</div>
|
@@ -89,7 +89,7 @@ describe('DateTime Kit', () => {
|
|
89
89
|
const kit = screen.getByTestId(testId)
|
90
90
|
const text = kit.querySelector('.pb_time_kit_md.ml_sm')
|
91
91
|
|
92
|
-
expect(text.textContent).toEqual('2:00p
|
92
|
+
expect(text.textContent).toEqual('2:00p GMT+9')
|
93
93
|
})
|
94
94
|
test('renders DatePicker size', () => {
|
95
95
|
render(
|