playbook_ui 12.39.0.pre.alpha.PLAY966collapsiblenav41115 → 12.39.0.pre.alpha.salesbookmismatchingdate1117

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf4167e4358045e1ef6c706b26d0e1893336ef2e673212b907abf2e2bfd7d37f
4
- data.tar.gz: f43205d27b1ceffd14ba706a9faf3285b650e220a71e889a78c0f55d41356737
3
+ metadata.gz: 6650ac3fb53a1c1a6d57ea4d4c08d61741e60c7aedd7149994b5f6a239a669e5
4
+ data.tar.gz: 0b0a15f6fe4e1d400bc78b5b74638c3ac6be8c9ef0804773edde1a3711fef286
5
5
  SHA512:
6
- metadata.gz: 2f2ecc613d9a31db4877c93101a664ddf9922ad0b46361971792336e51ee8f36f9b5aaa325893b26530a6ccf1b2dfb13af5f8f87309ad3e0c8bdc6501d8214da
7
- data.tar.gz: c4b92e867f72479651eee9d82afa551fd717fd66d7ced9a4997dbcec133d6e3b1e2916f5197ccc5e9c6c9b8c8a16db1931f6aca42dd758427e5a2c076abfc7f1
6
+ metadata.gz: 5eb5a4c90549d5f7f4dafb4455ff212573749b54c9734b09daa79a6a2d924587b820a8883fc6e340e31571515b935476e872344207b6e88b7be4f98ac1f25815
7
+ data.tar.gz: 8986120162f91c579c0574dd70ef13fb0bc190b687548edd456b33e2d9ff4447c9b122bf431719376390a2dc49e21d6c8714c4b53da362204b908b01ccd2b3d0
@@ -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(moment().startOf('year').format('MM/DD/YYYY') + " to " + moment().endOf('year').format('MM/DD/YYYY'))
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(moment().startOf('year').format('MM/DD/YYYY') + " to " + moment().format('MM/DD/YYYY'))
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 moment from 'moment'
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 thisWeekEndDate = thisRangesEndToday ? new Date() : moment().endOf('isoWeek').toDate()
27
- const thisMonthEndDate = thisRangesEndToday ? new Date() : moment().endOf('month').toDate()
28
- const thisQuarterEndDate = thisRangesEndToday ? new Date() : moment().endOf('quarter').toDate()
29
- const thisYearEndDate = thisRangesEndToday ? new Date() : moment().endOf('year').toDate()
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': [new Date(), new Date()],
34
- 'Yesterday': [moment().subtract(1, 'days').toDate(), moment().subtract(1, 'days').toDate()],
35
- 'This week': [moment().startOf('isoWeek').toDate(), thisWeekEndDate],
36
- 'This month': [moment().startOf('month').toDate(), thisMonthEndDate],
37
- 'This quarter': [moment().startOf('quarter').toDate(), thisQuarterEndDate],
38
- 'This year': [moment().startOf('year').toDate(), thisYearEndDate],
39
- 'Last week': [
40
- moment().subtract(1, 'week').startOf('isoWeek').toDate(),
41
- moment().subtract(1, 'week').endOf('isoWeek').toDate()
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
- //creating the ul element for the nav dropdown and giving it classnames
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
- * @param {string} label
68
- * @returns HTML Element
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 buton prop
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 calender is in a ready state
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 = moment(range[0]).toDate();
121
- const end = moment(range[1]).toDate();
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;
@@ -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
- if (timeZone) {
38
- const date = new Date(formatDate(newDate).toLocaleString(undefined, { timeZone }));
39
- return date.getDate()
40
- } else {
41
- const date = formatDate(newDate)
42
- return date.getDate()
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.getUTCDay()]
50
+ return ABBR_DAYS[date.getDay()]
49
51
  }
50
52
 
51
53
  export const toWeekday = (newDate: Date | string): string => {
52
- const date = formatDate(newDate)
53
- return days[date.getUTCDay()]
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
- if (timeZone) {
58
- const date = new Date(formatDate(newDate).toLocaleString(undefined, { timeZone }));
59
- return months[date.getUTCMonth()]
60
- } else {
61
- const date = formatDate(newDate)
62
- return months[date.getUTCMonth()]
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.getUTCMonth() +1
70
+ return date.getMonth() + 1
69
71
  }
70
72
 
71
73
  export const toYear = (newDate: Date | string, timeZone?: string): number => {
72
- if (timeZone) {
73
- const date = new Date(newDate.toLocaleString(undefined, { timeZone }));
74
- return date.getUTCFullYear()
75
- } else {
76
- const date = new Date(newDate)
77
- return date.getUTCFullYear()
78
- }
74
+ if (timeZone) {
75
+ const date = new Date(formatDate(newDate).toLocaleString(undefined, { timeZone }));
76
+ return date.getFullYear()
77
+ } else {
78
+ const date = formatDate(newDate)
79
+ return date.getFullYear()
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
- const date = formatDate(newDate)
92
- if (timeZone) {
93
- return date.toLocaleString(undefined, { timeZone, hour12: true }).slice(-2).charAt(0).toLocaleLowerCase();
94
- } else {
95
- return date.toLocaleString(undefined, { hour12: true }).slice(-2).charAt(0).toLocaleLowerCase();
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
- const date = formatDate(newDate)
101
- if (timeZone) {
102
- return date.toLocaleString(undefined, { timeZone, timeZoneName: "short" }).split(' ')[3];
103
- } else {
104
- return date.toLocaleString(undefined, { timeZoneName: "short" }).split(' ')[3];
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,16 +116,17 @@ export const toTimeWithMeridiem = (newDate: Date | string, timeZone: string): st
111
116
  }
112
117
 
113
118
  export const toIso = (newDate: Date | string): string => {
114
- const date = formatDate(newDate)
115
- return date.toISOString()
119
+ const date = formatDate(newDate)
120
+ return date.toISOString()
116
121
  }
117
122
 
118
123
  export const fromNow = (newDate: Date | string): string => {
119
-
120
124
  const startDate = formatDate(newDate).getTime()
121
125
  const endDate = new Date().getTime()
122
126
  const elapsedTime = endDate - startDate
123
- let elapsedTimeString = `${Math.round(elapsedTime / (365.25 * 24 * 60 * 60 * 1000))} years ago.`; // 730+ days
127
+ let elapsedTimeString = `${Math.round(elapsedTime / (365.25 * 24 * 60 * 60 * 1000))} years ago`; // 730+ days
128
+
129
+ const MILLISECONDS_IN_A_MONTH = 30.44 * 24 * 60 * 60 * 1000
124
130
 
125
131
  const elapsedTimeData = [
126
132
  { min: 0, max: 44999, value: "a few seconds ago" }, // 0-44 seconds
@@ -131,7 +137,7 @@ export const fromNow = (newDate: Date | string): string => {
131
137
  { min: 75700000, max: 172899999, value: "a day ago" }, // 22-48 hours
132
138
  { min: 172900000, max: 2169999999, value: `${Math.round(elapsedTime / 86400000)} days ago`}, // 2-25 days
133
139
  { min: 2170000000, max: 5184999999, value: "a month ago"}, // 26-60 days
134
- { min: 5185000000, max: 27561699999, value: `${Math.round(elapsedTime / 30.44 * 24 * 60 * 60 * 1000)} months ago`}, // 60-319 days
140
+ { min: 5185000000, max: 27561699999, value: `${Math.round(elapsedTime / MILLISECONDS_IN_A_MONTH)} months ago`}, // 60-319 days
135
141
  { min: 27561700000, max: 63072999999, value: "a year ago"}, // 320-730 days
136
142
  ];
137
143
 
@@ -154,6 +160,193 @@ export const toCustomFormat = (newDate: Date | string, format = 'month_day'): st
154
160
  }
155
161
  }
156
162
 
163
+ // For quickPick.tsx
164
+ // Yesterday
165
+ export const getYesterdayDate = (newDate: Date | string): Date => {
166
+ const today = formatDate(newDate)
167
+ const yesterday = new Date()
168
+ yesterday.setDate(today.getDate() - 1)
169
+
170
+ return yesterday
171
+ }
172
+
173
+ // Weeks
174
+ export const getFirstDayOfWeek = (newDate: Date | string): Date => {
175
+ const today = formatDate(newDate)
176
+ const dayOfWeek = today.getDay()
177
+ // Replicate Moment.js: Start of week (Monday) has a time of 00:00:00
178
+ const firstDayOfWeek = new Date(today.setHours(0, 0, 0))
179
+ const isSunday = dayOfWeek === 0
180
+
181
+ const daysToSubtract = isSunday ? 6 : (dayOfWeek - 1)
182
+ firstDayOfWeek.setDate(today.getDate() - daysToSubtract)
183
+
184
+ return firstDayOfWeek
185
+ }
186
+
187
+ export const getLastDayOfWeek = (newDate: Date | string): Date => {
188
+ const today = formatDate(newDate)
189
+ const dayOfWeek = today.getDay()
190
+ // Replicate Moment.js: End of week (Sunday) has a time of 23:59:59
191
+ const lastDayOfWeek = new Date(today.setHours(23, 59, 59, 0))
192
+ const isSunday = dayOfWeek === 0
193
+
194
+ const daysToAdd = isSunday ? 0 : (7 - dayOfWeek)
195
+ lastDayOfWeek.setDate(today.getDate() + daysToAdd)
196
+
197
+ return lastDayOfWeek
198
+ }
199
+
200
+ export const getPreviousWeekStartDate = (newDate: Date | string): Date => {
201
+ const firstDayOfWeek = getFirstDayOfWeek(newDate)
202
+ const firstDayOfPreviousWeek = new Date(
203
+ firstDayOfWeek.getFullYear(),
204
+ firstDayOfWeek.getMonth(),
205
+ firstDayOfWeek.getDate() - 7
206
+ )
207
+
208
+ return firstDayOfPreviousWeek
209
+ }
210
+
211
+ export const getPreviousWeekEndDate = (newDate: Date | string): Date => {
212
+ const lastDayOfWeek = getLastDayOfWeek(newDate)
213
+ const lastDayOfPreviousWeek = new Date(
214
+ lastDayOfWeek.getFullYear(),
215
+ lastDayOfWeek.getMonth(),
216
+ lastDayOfWeek.getDate() - 7,
217
+ lastDayOfWeek.getHours(),
218
+ lastDayOfWeek.getMinutes(),
219
+ lastDayOfWeek.getSeconds()
220
+ )
221
+
222
+ return lastDayOfPreviousWeek
223
+ }
224
+
225
+ // Months
226
+ export const getMonthStartDate = (newDate: Date | string): Date => {
227
+ const date = formatDate(newDate)
228
+ const firstDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1)
229
+
230
+ return firstDayOfMonth
231
+ }
232
+
233
+ export const getMonthEndDate = (newDate: Date | string): Date => {
234
+ const date = formatDate(newDate)
235
+ // Replicate Moment.js: End of month has a time of 23:59:59
236
+ const lastDayOfMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0, 23, 59, 59)
237
+
238
+ return lastDayOfMonth
239
+ }
240
+
241
+ export const getPreviousMonthStartDate = (newDate: Date | string): Date => {
242
+ const firstDayOfMonth = getMonthStartDate(newDate)
243
+ const firstDayOfPreviousMonth = new Date(
244
+ firstDayOfMonth.getFullYear(),
245
+ firstDayOfMonth.getMonth() - 1,
246
+ firstDayOfMonth.getDate()
247
+ )
248
+
249
+ return firstDayOfPreviousMonth
250
+ }
251
+
252
+ export const getPreviousMonthEndDate = (newDate: Date | string): Date => {
253
+ const lastDayOfMonth = getMonthEndDate(newDate)
254
+ const lastDayOfPreviousMonth = new Date(
255
+ lastDayOfMonth.getFullYear(),
256
+ lastDayOfMonth.getMonth() - 1,
257
+ lastDayOfMonth.getDate(),
258
+ lastDayOfMonth.getHours(),
259
+ lastDayOfMonth.getMinutes(),
260
+ lastDayOfMonth.getSeconds()
261
+ )
262
+
263
+ return lastDayOfPreviousMonth
264
+ }
265
+
266
+ // Quarters
267
+ export const getQuarterStartDate = (newDate: Date | string): Date => {
268
+ const date = formatDate(newDate)
269
+ const quarter = Math.floor(date.getMonth() / 3)
270
+ const startOfQuarter = new Date(date.getFullYear(), quarter * 3, 1)
271
+
272
+ return startOfQuarter
273
+ }
274
+
275
+ export const getQuarterEndDate = (newDate: Date | string): Date => {
276
+ const date = formatDate(newDate)
277
+ const quarter = Math.floor(date.getMonth() / 3)
278
+ const startOfNextQuarter = new Date(date.getFullYear(), (quarter + 1) * 3, 1)
279
+ // Replicate Moment.js: End of quarter has a time of 23:59:59
280
+ const endOfQuarter = new Date(startOfNextQuarter.getTime() - 1)
281
+
282
+ return endOfQuarter
283
+ }
284
+
285
+ export const getPreviousQuarterStartDate = (newDate: Date | string): Date => {
286
+ const startOfQuarter = getQuarterStartDate(newDate)
287
+ const firstDayOfPreviousQuarter = new Date(
288
+ startOfQuarter.getFullYear(),
289
+ startOfQuarter.getMonth() - 3,
290
+ startOfQuarter.getDate()
291
+ )
292
+
293
+ return firstDayOfPreviousQuarter
294
+ }
295
+
296
+ export const getPreviousQuarterEndDate = (newDate: Date | string): Date => {
297
+ const endOfQuarter = getQuarterEndDate(newDate)
298
+ const lastDayOfPreviousQuarter = new Date(
299
+ endOfQuarter.getFullYear(),
300
+ endOfQuarter.getMonth() - 3,
301
+ endOfQuarter.getDate(),
302
+ endOfQuarter.getHours(),
303
+ endOfQuarter.getMinutes(),
304
+ endOfQuarter.getSeconds()
305
+ )
306
+
307
+ return lastDayOfPreviousQuarter
308
+ }
309
+
310
+ // Years
311
+ export const getYearStartDate = (newDate: Date | string): Date => {
312
+ const date = formatDate(newDate)
313
+ const startOfYear = new Date(date.getFullYear(), 0, 1)
314
+
315
+ return startOfYear
316
+ }
317
+
318
+ export const getYearEndDate = (newDate: Date | string): Date => {
319
+ const date = formatDate(newDate)
320
+ const endOfYear = new Date(date.getFullYear(), 11, 31, 23, 59, 59)
321
+
322
+ return endOfYear
323
+ }
324
+
325
+ export const getPreviousYearStartDate = (newDate: Date | string): Date => {
326
+ const startOfYear = getYearStartDate(newDate)
327
+ const firstDayOfPreviousYear = new Date(
328
+ startOfYear.getFullYear() - 1,
329
+ startOfYear.getMonth(),
330
+ startOfYear.getDate()
331
+ )
332
+
333
+ return firstDayOfPreviousYear
334
+ }
335
+
336
+ export const getPreviousYearEndDate = (newDate: Date | string): Date => {
337
+ const endOfYear = getYearEndDate(newDate)
338
+ const lastDayOfPreviousYear = new Date(
339
+ endOfYear.getFullYear() - 1,
340
+ endOfYear.getMonth(),
341
+ endOfYear.getDate(),
342
+ endOfYear.getHours(),
343
+ endOfYear.getMinutes(),
344
+ endOfYear.getSeconds()
345
+ )
346
+
347
+ return lastDayOfPreviousYear
348
+ }
349
+
157
350
  export default {
158
351
  toMinute,
159
352
  toHour,
@@ -170,4 +363,21 @@ export default {
170
363
  toIso,
171
364
  fromNow,
172
365
  toCustomFormat,
366
+ getYesterdayDate,
367
+ getFirstDayOfWeek,
368
+ getLastDayOfWeek,
369
+ getPreviousWeekStartDate,
370
+ getPreviousWeekEndDate,
371
+ getMonthStartDate,
372
+ getMonthEndDate,
373
+ getPreviousMonthStartDate,
374
+ getPreviousMonthEndDate,
375
+ getQuarterStartDate,
376
+ getQuarterEndDate,
377
+ getPreviousQuarterStartDate,
378
+ getPreviousQuarterEndDate,
379
+ getYearStartDate,
380
+ getYearEndDate,
381
+ getPreviousYearStartDate,
382
+ getPreviousYearEndDate
173
383
  }
@@ -116,9 +116,6 @@
116
116
  font-weight: $regular !important;
117
117
  }
118
118
  }
119
- .icon_wrapper:hover {
120
- background-color: mix($primary, $card_light, 40%);
121
- }
122
119
  }
123
120
  }
124
121
  }
@@ -128,25 +125,30 @@
128
125
  [class*="pb_collapsible_nav_item"] {
129
126
  &[class*="_active"] {
130
127
  .pb_collapsible_main_kit {
131
- background-color: $active_light;
128
+ background-color: $primary !important;
132
129
  border-radius: $border_rad_heavier;
133
130
  .pb_nav_list_item_text_collapsible,
134
- .pb_nav_list_item_icon_collapsible
135
- {
136
- color: $primary;
131
+ .pb_nav_list_item_icon_collapsible,
132
+ .icon_wrapper,
133
+ .pb_icon_kit {
134
+ color: $white !important;
137
135
  }
138
136
  }
137
+
139
138
  &:hover {
140
139
  background-color: unset;
141
140
  }
142
- }
143
- &.dark {
144
- &[class*="_active"] {
145
- .pb_collapsible_main_kit {
146
- background-color: mix($white, $card_dark, 20%);
147
- .pb_nav_list_item_text_collapsible,
148
- svg {
149
- color: $white !important;
141
+ .pb_collapsible_main_kit:hover {
142
+ .pb_nav_list_item_text_collapsible {
143
+ color: $white !important;
144
+ }
145
+ }
146
+
147
+ .icon_wrapper {
148
+ &:hover {
149
+ background-color: mix($primary, $card_light, 40%);
150
+ .pb_icon_kit {
151
+ color: $primary !important;
150
152
  }
151
153
  }
152
154
  }
@@ -195,6 +197,7 @@
195
197
  // vertical line on left of collapsible content
196
198
  .pb_collapsible_content_kit {
197
199
  margin-left: $space_sm + 2;
200
+ border-left: 1px solid transparent;
198
201
  }
199
202
 
200
203
  .pb_collapsible_main_kit {
@@ -271,12 +274,15 @@
271
274
  .icon_wrapper:hover {
272
275
  background-color: mix($white, $card_dark, 40%);
273
276
  }
277
+ &[class*="_active"] {
278
+ .icon_wrapper:hover {
279
+ background-color: mix($primary, $card_light, 40%);
280
+ }
281
+ }
274
282
 
275
283
  &[class*="pb_collapsible_nav_item"][class*="_collapsible_trail"] {
276
284
  .pb_collapsible_content_kit {
277
- &::after {
278
- background-color: $border_dark;
279
- }
285
+ border-color: $border_dark;
280
286
  }
281
287
  }
282
288
  }
@@ -44,7 +44,7 @@ $selector: ".pb_nav_list";
44
44
 
45
45
  [class*=_text] {
46
46
  font-size: $font_base;
47
- // font-weight: $bold;
47
+ font-weight: $bold;
48
48
  color: $text_lt_default;
49
49
  }
50
50