@tylertech/forge 3.8.1 → 3.9.0-dev.0

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.
Files changed (40) hide show
  1. package/README.md +23 -0
  2. package/custom-elements.json +1263 -876
  3. package/dist/lib.js +18 -18
  4. package/dist/lib.js.map +3 -3
  5. package/dist/toolbar/forge-toolbar.css +1 -0
  6. package/dist/vscode.css-custom-data.json +37 -37
  7. package/dist/vscode.html-custom-data.json +138 -78
  8. package/esm/calendar/calendar-adapter.d.ts +24 -0
  9. package/esm/calendar/calendar-adapter.js +67 -1
  10. package/esm/calendar/calendar-constants.d.ts +34 -0
  11. package/esm/calendar/calendar-constants.js +33 -0
  12. package/esm/calendar/calendar-core.d.ts +60 -0
  13. package/esm/calendar/calendar-core.js +220 -2
  14. package/esm/calendar/calendar-dom-utils.d.ts +6 -0
  15. package/esm/calendar/calendar-dom-utils.js +36 -0
  16. package/esm/calendar/calendar.d.ts +40 -1
  17. package/esm/calendar/calendar.js +80 -2
  18. package/esm/calendar/core/calendar-base.d.ts +3 -0
  19. package/esm/calendar/core/date-range.d.ts +2 -0
  20. package/esm/calendar/core/date-range.js +1 -0
  21. package/esm/date-picker/base/base-date-picker-constants.d.ts +3 -0
  22. package/esm/date-picker/base/base-date-picker-constants.js +3 -0
  23. package/esm/date-picker/base/base-date-picker-core.d.ts +15 -0
  24. package/esm/date-picker/base/base-date-picker-core.js +30 -0
  25. package/esm/date-picker/base/base-date-picker.d.ts +12 -0
  26. package/esm/date-picker/base/base-date-picker.js +24 -0
  27. package/esm/date-picker/date-picker-core.d.ts +3 -0
  28. package/esm/date-picker/date-picker-core.js +20 -0
  29. package/esm/date-range-picker/date-range-picker-constants.d.ts +3 -0
  30. package/esm/date-range-picker/date-range-picker-constants.js +1 -0
  31. package/esm/date-range-picker/date-range-picker-core.d.ts +3 -0
  32. package/esm/date-range-picker/date-range-picker-core.js +62 -2
  33. package/esm/date-range-picker/date-range-picker.d.ts +3 -0
  34. package/esm/date-range-picker/date-range-picker.js +3 -0
  35. package/esm/split-view/split-view-panel/split-view-panel.js +1 -1
  36. package/esm/toolbar/toolbar.js +1 -1
  37. package/package.json +2 -2
  38. package/sass/calendar/_mixins.scss +3 -2
  39. package/sass/toolbar/_core.scss +5 -0
  40. package/sass/toolbar/toolbar.scss +4 -0
@@ -29,6 +29,12 @@ export declare const CALENDAR_CONSTANTS: {
29
29
  SHOW_OTHER_MONTHS: string;
30
30
  SHOW_TODAY: string;
31
31
  TODAY_BUTTON: string;
32
+ SHOW_YESTERDAY: string;
33
+ YESTERDAY_BUTTON: string;
34
+ SHOW_LAST_SEVEN_DAYS: string;
35
+ LAST_SEVEN_DAYS_BUTTON: string;
36
+ SHOW_LAST_THIRTY_DAYS: string;
37
+ LAST_THIRTY_DAYS_BUTTON: string;
32
38
  VIEW: string;
33
39
  YEAR: string;
34
40
  YEAR_RANGE: string;
@@ -42,6 +48,7 @@ export declare const CALENDAR_CONSTANTS: {
42
48
  DATE_SPACER: string;
43
49
  DATE_SELECTED: string;
44
50
  DATE_TODAY: string;
51
+ DATE_YESTERDAY: string;
45
52
  DATE_VIEW: string;
46
53
  DATE_VIEW_ROW: string;
47
54
  DATE_WRAPPER: string;
@@ -58,10 +65,15 @@ export declare const CALENDAR_CONSTANTS: {
58
65
  RANGE_END: string;
59
66
  RANGE_START: string;
60
67
  RANGE_TARGET: string;
68
+ RANGE_LAST_SEVEN_DAYS: string;
69
+ RANGE_LAST_THIRTY_DAYS: string;
61
70
  READONLY: string;
62
71
  RTL: string;
63
72
  SHOW_OTHER_MONTHS: string;
64
73
  SHOW_TODAY: string;
74
+ SHOW_YESTERDAY: string;
75
+ SHOW_LAST_SEVEN_DAYS: string;
76
+ SHOW_LAST_THIRTY_DAYS: string;
65
77
  VIEW: string;
66
78
  YEAR_MENU_OPEN: string;
67
79
  };
@@ -82,6 +94,9 @@ export declare const CALENDAR_CONSTANTS: {
82
94
  PREVIOUS_BUTTON: string;
83
95
  PREVIOUS_BUTTON_TOOLTIP: string;
84
96
  TODAY_BUTTON: string;
97
+ YESTERDAY_BUTTON: string;
98
+ LAST_SEVEN_DAYS_BUTTON: string;
99
+ LAST_THIRTY_DAYS_BUTTON: string;
85
100
  YEAR_BUTTON: string;
86
101
  };
87
102
  slots: {
@@ -92,6 +107,9 @@ export declare const CALENDAR_CONSTANTS: {
92
107
  PREVIOUS_YEARS_BUTTON_TEXT: string;
93
108
  NEXT_YEARS_BUTTON_TEXT: string;
94
109
  TODAY_BUTTON_TEXT: string;
110
+ YESTERDAY_BUTTON_TEXT: string;
111
+ LAST_SEVEN_DAYS_BUTTON_TEXT: string;
112
+ LAST_THIRTY_DAYS_BUTTON_TEXT: string;
95
113
  CLEAR_BUTTON_TEXT: string;
96
114
  };
97
115
  parts: {
@@ -114,6 +132,12 @@ export declare const CALENDAR_CONSTANTS: {
114
132
  RANGE_START: string;
115
133
  TODAY: string;
116
134
  TODAY_BUTTON: string;
135
+ YESTERDAY: string;
136
+ YESTERDAY_BUTTON: string;
137
+ LAST_SEVEN_DAYS: string;
138
+ LAST_SEVEN_DAYS_BUTTON: string;
139
+ LAST_THIRTY_DAYS: string;
140
+ LAST_THIRTY_DAYS_BUTTON: string;
117
141
  WEEKEND: string;
118
142
  YEAR_BUTTON: string;
119
143
  YEAR_BUTTON_ELEMENT: string;
@@ -138,6 +162,7 @@ export declare const CALENDAR_CONSTANTS: {
138
162
  DATE_SPACER: string;
139
163
  DATE_SELECTED: string;
140
164
  DATE_TODAY: string;
165
+ DATE_YESTERDAY: string;
141
166
  DATE_VIEW: string;
142
167
  DATE_WRAPPER: string;
143
168
  DAY_ROW: string;
@@ -153,7 +178,12 @@ export declare const CALENDAR_CONSTANTS: {
153
178
  RANGE: string;
154
179
  RANGE_END: string;
155
180
  RANGE_START: string;
181
+ RANGE_LAST_SEVEN_DAYS: string;
182
+ RANGE_LAST_THIRTY_DAYS: string;
156
183
  TODAY_BUTTON: string;
184
+ YESTERDAY_BUTTON: string;
185
+ LAST_SEVEN_DAYS_BUTTON: string;
186
+ LAST_THIRTY_DAYS_BUTTON: string;
157
187
  TOOLTIP: "forge-tooltip";
158
188
  VIEW: string;
159
189
  YEAR_BUTTON: string;
@@ -172,6 +202,9 @@ export declare const CALENDAR_CONSTANTS: {
172
202
  DEFAULT_PREVIOUS_YEARS_BUTTON_TEXT: string;
173
203
  DEFAULT_NEXT_YEARS_BUTTON_TEXT: string;
174
204
  DEFAULT_TODAY_BUTTON_TEXT: string;
205
+ DEFAULT_YESTERDAY_BUTTON_TEXT: string;
206
+ DEFAULT_LAST_SEVEN_DAYS_BUTTON_TEXT: string;
207
+ DEFAULT_LAST_THIRTY_DAYS_BUTTON_TEXT: string;
175
208
  DEFAULT_CLEAR_BUTTON_TEXT: string;
176
209
  };
177
210
  numbers: {
@@ -226,6 +259,7 @@ export interface ICalendarDateSelectEventData {
226
259
  range?: DateRange;
227
260
  rangeSelectionState?: RangeSelectionState;
228
261
  type: CalendarView;
262
+ rangeName?: string;
229
263
  }
230
264
  export interface ICalendarMonthChangeEventData {
231
265
  month: number;
@@ -27,6 +27,12 @@ const observedAttributes = {
27
27
  SHOW_OTHER_MONTHS: 'show-other-months',
28
28
  SHOW_TODAY: 'show-today',
29
29
  TODAY_BUTTON: 'today-button',
30
+ SHOW_YESTERDAY: 'show-yesterday',
31
+ YESTERDAY_BUTTON: 'yesterday-button',
32
+ SHOW_LAST_SEVEN_DAYS: 'show-last-seven-days',
33
+ LAST_SEVEN_DAYS_BUTTON: 'last-seven-days-button',
34
+ SHOW_LAST_THIRTY_DAYS: 'show-last-thirty-days',
35
+ LAST_THIRTY_DAYS_BUTTON: 'last-thirty-days-button',
30
36
  VIEW: 'view',
31
37
  YEAR: 'year',
32
38
  YEAR_RANGE: 'year-range'
@@ -46,6 +52,7 @@ const classes = {
46
52
  DATE_SPACER: 'forge-calendar__date-spacer',
47
53
  DATE_SELECTED: 'forge-calendar__date--selected',
48
54
  DATE_TODAY: 'forge-calendar__date--today',
55
+ DATE_YESTERDAY: 'forge-calendar__date--yesterday',
49
56
  DATE_VIEW: 'forge-calendar__date-view',
50
57
  DATE_VIEW_ROW: 'forge-calendar__date-view__row',
51
58
  DATE_WRAPPER: 'forge-calendar__date-wrapper',
@@ -62,10 +69,15 @@ const classes = {
62
69
  RANGE_END: 'forge-calendar__range--end',
63
70
  RANGE_START: 'forge-calendar__range--start',
64
71
  RANGE_TARGET: 'forge-calendar__range__target',
72
+ RANGE_LAST_SEVEN_DAYS: 'forge-calendar__range__last-seven-days',
73
+ RANGE_LAST_THIRTY_DAYS: 'forge-calendar__range__last-thirty-days',
65
74
  READONLY: 'forge-calendar--readonly',
66
75
  RTL: 'forge-calendar--rtl',
67
76
  SHOW_OTHER_MONTHS: 'forge-calendar--show-other-months',
68
77
  SHOW_TODAY: 'forge-calendar--show-today',
78
+ SHOW_YESTERDAY: 'forge-calendar--show-yesterday',
79
+ SHOW_LAST_SEVEN_DAYS: 'forge-calendar--show-last-seven-days',
80
+ SHOW_LAST_THIRTY_DAYS: 'forge-calendar--show-last-thirty-days',
69
81
  VIEW: 'forge-calendar__view',
70
82
  YEAR_MENU_OPEN: 'forge-calendar--year-menu-open'
71
83
  };
@@ -86,6 +98,9 @@ const ids = {
86
98
  PREVIOUS_BUTTON: 'previous-button',
87
99
  PREVIOUS_BUTTON_TOOLTIP: 'previous-button-tooltip',
88
100
  TODAY_BUTTON: 'today-button',
101
+ YESTERDAY_BUTTON: 'yesterday-button',
102
+ LAST_SEVEN_DAYS_BUTTON: 'last-seven-days-button',
103
+ LAST_THIRTY_DAYS_BUTTON: 'last-thirty-days-button',
89
104
  YEAR_BUTTON: 'year-button'
90
105
  };
91
106
  const slots = {
@@ -96,6 +111,9 @@ const slots = {
96
111
  PREVIOUS_YEARS_BUTTON_TEXT: 'previous-years-button-text',
97
112
  NEXT_YEARS_BUTTON_TEXT: 'next-years-button-text',
98
113
  TODAY_BUTTON_TEXT: 'today-button-text',
114
+ YESTERDAY_BUTTON_TEXT: 'yesterday-button-text',
115
+ LAST_SEVEN_DAYS_BUTTON_TEXT: 'last-seven-days-button-text',
116
+ LAST_THIRTY_DAYS_BUTTON_TEXT: 'last-thirty-days-button-text',
99
117
  CLEAR_BUTTON_TEXT: 'clear-button-text'
100
118
  };
101
119
  const weekdayParts = {
@@ -128,6 +146,12 @@ const parts = {
128
146
  RANGE_START: 'range-start',
129
147
  TODAY: 'today',
130
148
  TODAY_BUTTON: 'today-button',
149
+ YESTERDAY: 'yesterday',
150
+ YESTERDAY_BUTTON: 'yesterday-button',
151
+ LAST_SEVEN_DAYS: 'last-seven-days',
152
+ LAST_SEVEN_DAYS_BUTTON: 'last-seven-days-button',
153
+ LAST_THIRTY_DAYS: 'last-thirty-days',
154
+ LAST_THIRTY_DAYS_BUTTON: 'last-thirty-days-button',
131
155
  WEEKEND: 'weekend',
132
156
  YEAR_BUTTON: 'year-button',
133
157
  YEAR_BUTTON_ELEMENT: 'year-button-element'
@@ -145,6 +169,7 @@ const selectors = {
145
169
  DATE_SPACER: `.${classes.DATE_SPACER}`,
146
170
  DATE_SELECTED: `.${classes.DATE_SELECTED}`,
147
171
  DATE_TODAY: `.${classes.DATE_TODAY}`,
172
+ DATE_YESTERDAY: `.${classes.DATE_YESTERDAY}`,
148
173
  DATE_VIEW: `#${ids.DATE_VIEW}`,
149
174
  DATE_WRAPPER: `.${classes.DATE_WRAPPER}`,
150
175
  DAY_ROW: `#${ids.DAY_ROW}`,
@@ -160,7 +185,12 @@ const selectors = {
160
185
  RANGE: `.${classes.RANGE}`,
161
186
  RANGE_END: `.${classes.RANGE_END}`,
162
187
  RANGE_START: `.${classes.RANGE_START}`,
188
+ RANGE_LAST_SEVEN_DAYS: `.${classes.RANGE_LAST_SEVEN_DAYS}`,
189
+ RANGE_LAST_THIRTY_DAYS: `.${classes.RANGE_LAST_THIRTY_DAYS}`,
163
190
  TODAY_BUTTON: `#${ids.TODAY_BUTTON}`,
191
+ YESTERDAY_BUTTON: `#${ids.YESTERDAY_BUTTON}`,
192
+ LAST_SEVEN_DAYS_BUTTON: `#${ids.LAST_SEVEN_DAYS_BUTTON}`,
193
+ LAST_THIRTY_DAYS_BUTTON: `#${ids.LAST_THIRTY_DAYS_BUTTON}`,
164
194
  TOOLTIP: TOOLTIP_CONSTANTS.elementName,
165
195
  VIEW: '#view',
166
196
  YEAR_BUTTON: `#${ids.YEAR_BUTTON}`
@@ -179,6 +209,9 @@ const strings = {
179
209
  DEFAULT_PREVIOUS_YEARS_BUTTON_TEXT: 'Previous years',
180
210
  DEFAULT_NEXT_YEARS_BUTTON_TEXT: 'Next years',
181
211
  DEFAULT_TODAY_BUTTON_TEXT: 'Today',
212
+ DEFAULT_YESTERDAY_BUTTON_TEXT: 'Yesterday',
213
+ DEFAULT_LAST_SEVEN_DAYS_BUTTON_TEXT: 'Last 7 days',
214
+ DEFAULT_LAST_THIRTY_DAYS_BUTTON_TEXT: 'Last 30 days',
182
215
  DEFAULT_CLEAR_BUTTON_TEXT: 'Clear'
183
216
  };
184
217
  const numbers = {
@@ -17,11 +17,20 @@ export interface ICalendarCore extends ICalendarBase {
17
17
  menuAnimation: CalendarMenuAnimationType;
18
18
  clearButton: boolean;
19
19
  todayButton: boolean;
20
+ yesterdayButton: boolean;
21
+ lastSevenDaysButton: boolean;
22
+ lastThirtyDaysButton: boolean;
20
23
  clearCallback: (() => void) | undefined;
21
24
  todayCallback: (() => void) | undefined;
25
+ yesterdayCallback: (() => void) | undefined;
26
+ lastSevenDaysCallback: (() => void) | undefined;
27
+ lastThirtyDaysCallback: (() => void) | undefined;
22
28
  tooltipBuilder: CalendarTooltipBuilder | undefined;
23
29
  clear(): void;
24
30
  today(): void;
31
+ yesterday(): void;
32
+ lastSevenDays(): void;
33
+ lastThirtyDays(): void;
25
34
  selectDate(date: Date, setFocus?: boolean): void;
26
35
  deselectDate(date: Date, setFocus?: boolean): void;
27
36
  toggleDate(date: Date, force?: boolean): void;
@@ -37,6 +46,9 @@ export declare class CalendarCore implements ICalendarCore {
37
46
  private _year;
38
47
  private _focusedDate;
39
48
  private _showToday;
49
+ private _showYesterday;
50
+ private _showLastSevenDays;
51
+ private _showLastThirtyDays;
40
52
  private _showOtherMonths;
41
53
  private _fixedHeight;
42
54
  private _events;
@@ -63,8 +75,14 @@ export declare class CalendarCore implements ICalendarCore {
63
75
  private _showHeader;
64
76
  private _clearButton;
65
77
  private _todayButton;
78
+ private _yesterdayButton;
79
+ private _lastSevenDaysButton;
80
+ private _lastThirtyDaysButton;
66
81
  private _clearCallback;
67
82
  private _todayCallback;
83
+ private _yesterdayCallback;
84
+ private _lastSevenDaysCallback;
85
+ private _lastThirtyDaysCallback;
68
86
  private _view;
69
87
  private _menuAnimation;
70
88
  private _menuYear;
@@ -93,6 +111,9 @@ export declare class CalendarCore implements ICalendarCore {
93
111
  private _preventFocusListener;
94
112
  private _previousButtonListener;
95
113
  private _todayButtonListener;
114
+ private _yesterdayButtonListener;
115
+ private _lastSevenDaysButtonListener;
116
+ private _lastThirtyDaysButtonListener;
96
117
  private _yearButtonListener;
97
118
  constructor(_adapter: ICalendarAdapter);
98
119
  initialize(): void;
@@ -126,6 +147,9 @@ export declare class CalendarCore implements ICalendarCore {
126
147
  private _onYearSelected;
127
148
  private _onClearClicked;
128
149
  private _onTodayClicked;
150
+ private _onYesterdayClicked;
151
+ private _onLastSevenDaysClicked;
152
+ private _onLastThirtyDaysClicked;
129
153
  /** Attempts to the month and year of the value in single mode, then emits a selection event */
130
154
  private _trySetValueMonthAndYear;
131
155
  /** Sets initial date tabindex and focus to today or the first enabled date in view */
@@ -414,6 +438,12 @@ export declare class CalendarCore implements ICalendarCore {
414
438
  private _applyShowOtherMonths;
415
439
  private _applyShowToday;
416
440
  private _applyTodayButton;
441
+ private _applyShowYesterday;
442
+ private _applyYesterdayButton;
443
+ private _applyShowLastSevenDays;
444
+ private _applyLastSevenDaysButton;
445
+ private _applyShowLastThirtyDays;
446
+ private _applyLastThirtyDaysButton;
417
447
  private _applyTooltipBuilder;
418
448
  private _applyWeekendDays;
419
449
  private _applyValue;
@@ -507,6 +537,30 @@ export declare class CalendarCore implements ICalendarCore {
507
537
  set todayButton(value: boolean);
508
538
  get todayCallback(): (() => void) | undefined;
509
539
  set todayCallback(value: (() => void) | undefined);
540
+ /** Get/set show yesterday */
541
+ get showYesterday(): boolean;
542
+ set showYesterday(value: boolean);
543
+ /** Get/set whether to show the yesterday button */
544
+ get yesterdayButton(): boolean;
545
+ set yesterdayButton(value: boolean);
546
+ get yesterdayCallback(): (() => void) | undefined;
547
+ set yesterdayCallback(value: (() => void) | undefined);
548
+ /** Get/set show last seven days */
549
+ get showLastSevenDays(): boolean;
550
+ set showLastSevenDays(value: boolean);
551
+ /** Get/set whether to show the last seven days button */
552
+ get lastSevenDaysButton(): boolean;
553
+ set lastSevenDaysButton(value: boolean);
554
+ get lastSevenDaysCallback(): (() => void) | undefined;
555
+ set lastSevenDaysCallback(value: (() => void) | undefined);
556
+ /** Get/set show last thirty days */
557
+ get showLastThirtyDays(): boolean;
558
+ set showLastThirtyDays(value: boolean);
559
+ /** Get/set whether to show the last thirty days button */
560
+ get lastThirtyDaysButton(): boolean;
561
+ set lastThirtyDaysButton(value: boolean);
562
+ get lastThirtyDaysCallback(): (() => void) | undefined;
563
+ set lastThirtyDaysCallback(value: (() => void) | undefined);
510
564
  /** Get/set the tooltip builder */
511
565
  get tooltipBuilder(): CalendarTooltipBuilder | undefined;
512
566
  set tooltipBuilder(value: CalendarTooltipBuilder | undefined);
@@ -541,6 +595,12 @@ export declare class CalendarCore implements ICalendarCore {
541
595
  setActiveDate(date: Date, setFocus?: boolean): boolean;
542
596
  /** Go to today */
543
597
  today(): void;
598
+ /** Go to yesterday */
599
+ yesterday(): void;
600
+ /** Go to last seven days */
601
+ lastSevenDays(): void;
602
+ /** Go to last thirty days */
603
+ lastThirtyDays(): void;
544
604
  /** Toggles a date selected or unselected */
545
605
  toggleDate(date: Date, force?: boolean): void;
546
606
  }
@@ -18,6 +18,9 @@ export class CalendarCore {
18
18
  this._month = new Date().getMonth();
19
19
  this._year = new Date().getFullYear();
20
20
  this._showToday = true;
21
+ this._showYesterday = true;
22
+ this._showLastSevenDays = true;
23
+ this._showLastThirtyDays = true;
21
24
  this._showOtherMonths = false;
22
25
  this._fixedHeight = false;
23
26
  this._events = [];
@@ -40,6 +43,9 @@ export class CalendarCore {
40
43
  this._showHeader = true;
41
44
  this._clearButton = false;
42
45
  this._todayButton = false;
46
+ this._yesterdayButton = false;
47
+ this._lastSevenDaysButton = false;
48
+ this._lastThirtyDaysButton = false;
43
49
  // Menu
44
50
  this._view = 'date';
45
51
  this._menuAnimation = 'scale';
@@ -66,6 +72,9 @@ export class CalendarCore {
66
72
  this._preventFocusListener = evt => evt.preventDefault();
67
73
  this._previousButtonListener = () => this._onPreviousButtonClicked();
68
74
  this._todayButtonListener = () => this._onTodayClicked();
75
+ this._yesterdayButtonListener = () => this._onYesterdayClicked();
76
+ this._lastSevenDaysButtonListener = () => this._onLastSevenDaysClicked();
77
+ this._lastThirtyDaysButtonListener = () => this._onLastThirtyDaysClicked();
69
78
  this._yearButtonListener = () => this._onYearButtonClicked();
70
79
  }
71
80
  initialize() {
@@ -77,6 +86,9 @@ export class CalendarCore {
77
86
  this._applyFixedHeight();
78
87
  this._applyReadOnly();
79
88
  this._applyShowToday();
89
+ this._applyShowYesterday();
90
+ this._applyShowLastSevenDays();
91
+ this._applyShowLastThirtyDays();
80
92
  this._applyPreventFocus();
81
93
  this._applyShowHeader();
82
94
  this._applyMonth();
@@ -86,6 +98,9 @@ export class CalendarCore {
86
98
  this._applyLocale();
87
99
  this._applyClearButton();
88
100
  this._applyTodayButton();
101
+ this._applyYesterdayButton();
102
+ this._applyLastSevenDaysButton();
103
+ this._applyLastThirtyDaysButton();
89
104
  this._applyFirstDayOfWeek();
90
105
  this._applyShowOtherMonths();
91
106
  this._createDateView();
@@ -415,6 +430,15 @@ export class CalendarCore {
415
430
  _onTodayClicked() {
416
431
  this.today();
417
432
  }
433
+ _onYesterdayClicked() {
434
+ this.yesterday();
435
+ }
436
+ _onLastSevenDaysClicked() {
437
+ this.lastSevenDays();
438
+ }
439
+ _onLastThirtyDaysClicked() {
440
+ this.lastThirtyDays();
441
+ }
418
442
  /** Attempts to the month and year of the value in single mode, then emits a selection event */
419
443
  _trySetValueMonthAndYear(month, year, type = 'date') {
420
444
  if (!this.selectionFollowsMonth || this._mode !== 'single' || !this._value?.length) {
@@ -1360,7 +1384,7 @@ export class CalendarCore {
1360
1384
  if (!this._clearButton) {
1361
1385
  this._adapter.unregisterClearButtonListener(this._clearButtonListener);
1362
1386
  this._adapter.removeClearButton();
1363
- if (!this._todayButton) {
1387
+ if (!this._todayButton && !this._yesterdayButton && !this._lastSevenDaysButton && !this._lastThirtyDaysButton) {
1364
1388
  this._adapter.removeFooter();
1365
1389
  }
1366
1390
  }
@@ -1657,7 +1681,7 @@ export class CalendarCore {
1657
1681
  if (!this._todayButton) {
1658
1682
  this._adapter.unregisterTodayButtonListener(this._todayButtonListener);
1659
1683
  this._adapter.removeTodayButton();
1660
- if (!this._clearButton) {
1684
+ if (!this._clearButton && !this._yesterdayButton && !this._lastSevenDaysButton && !this._lastThirtyDaysButton) {
1661
1685
  this._adapter.removeFooter();
1662
1686
  }
1663
1687
  }
@@ -1667,6 +1691,63 @@ export class CalendarCore {
1667
1691
  this._adapter.registerTodayButtonListener(this._todayButtonListener);
1668
1692
  }
1669
1693
  }
1694
+ _applyShowYesterday() {
1695
+ this._adapter.toggleHostAttribute(CALENDAR_CONSTANTS.attributes.SHOW_YESTERDAY, this._showYesterday);
1696
+ this._adapter.setContainerClass(CALENDAR_CONSTANTS.classes.SHOW_YESTERDAY, this._showYesterday);
1697
+ }
1698
+ _applyYesterdayButton() {
1699
+ this._adapter.toggleHostAttribute(CALENDAR_CONSTANTS.attributes.YESTERDAY_BUTTON, true, this._yesterdayButton.toString());
1700
+ if (!this._yesterdayButton) {
1701
+ this._adapter.unregisterYesterdayButtonListener(this._yesterdayButtonListener);
1702
+ this._adapter.removeYesterdayButton();
1703
+ if (!this._clearButton && !this._todayButton && !this._lastSevenDaysButton && !this._lastThirtyDaysButton) {
1704
+ this._adapter.removeFooter();
1705
+ }
1706
+ }
1707
+ else {
1708
+ this._adapter.setFooter();
1709
+ this._adapter.setYesterdayButton();
1710
+ this._adapter.registerYesterdayButtonListener(this._yesterdayButtonListener);
1711
+ }
1712
+ }
1713
+ _applyShowLastSevenDays() {
1714
+ this._adapter.toggleHostAttribute(CALENDAR_CONSTANTS.attributes.SHOW_LAST_SEVEN_DAYS, this._showLastSevenDays);
1715
+ this._adapter.setContainerClass(CALENDAR_CONSTANTS.classes.SHOW_LAST_SEVEN_DAYS, this._showLastSevenDays);
1716
+ }
1717
+ _applyLastSevenDaysButton() {
1718
+ this._adapter.toggleHostAttribute(CALENDAR_CONSTANTS.attributes.LAST_SEVEN_DAYS_BUTTON, true, this._lastSevenDaysButton.toString());
1719
+ if (!this._lastSevenDaysButton) {
1720
+ this._adapter.unregisterLastSevenDaysButtonListener(this._lastSevenDaysButtonListener);
1721
+ this._adapter.removeLastSevenDaysButton();
1722
+ if (!this._clearButton && !this._todayButton && !this._yesterdayButton) {
1723
+ this._adapter.removeFooter();
1724
+ }
1725
+ }
1726
+ else {
1727
+ this._adapter.setFooter();
1728
+ this._adapter.setLastSevenDaysButton();
1729
+ this._adapter.registerLastSevenDaysButtonListener(this._lastSevenDaysButtonListener);
1730
+ }
1731
+ }
1732
+ _applyShowLastThirtyDays() {
1733
+ this._adapter.toggleHostAttribute(CALENDAR_CONSTANTS.attributes.SHOW_LAST_THIRTY_DAYS, this._showLastThirtyDays);
1734
+ this._adapter.setContainerClass(CALENDAR_CONSTANTS.classes.SHOW_LAST_THIRTY_DAYS, this._showLastThirtyDays);
1735
+ }
1736
+ _applyLastThirtyDaysButton() {
1737
+ this._adapter.toggleHostAttribute(CALENDAR_CONSTANTS.attributes.LAST_THIRTY_DAYS_BUTTON, true, this._lastThirtyDaysButton.toString());
1738
+ if (!this._lastThirtyDaysButton) {
1739
+ this._adapter.unregisterLastThirtyDaysButtonListener(this._lastThirtyDaysButtonListener);
1740
+ this._adapter.removeLastThirtyDaysButton();
1741
+ if (!this._clearButton && !this._todayButton && !this._yesterdayButton && !this.lastSevenDaysButton) {
1742
+ this._adapter.removeFooter();
1743
+ }
1744
+ }
1745
+ else {
1746
+ this._adapter.setFooter();
1747
+ this._adapter.setLastThirtyDaysButton();
1748
+ this._adapter.registerLastThirtyDaysButtonListener(this._lastThirtyDaysButtonListener);
1749
+ }
1750
+ }
1670
1751
  _applyTooltipBuilder() {
1671
1752
  if (this._view === 'date') {
1672
1753
  this._dates.forEach(d => {
@@ -2065,6 +2146,99 @@ export class CalendarCore {
2065
2146
  set todayCallback(value) {
2066
2147
  this._todayCallback = value;
2067
2148
  }
2149
+ /** Get/set show yesterday */
2150
+ get showYesterday() {
2151
+ return this._showYesterday;
2152
+ }
2153
+ set showYesterday(value) {
2154
+ if (this._showYesterday !== value) {
2155
+ this._showYesterday = value;
2156
+ if (this._isInitialized) {
2157
+ this._applyShowYesterday();
2158
+ }
2159
+ }
2160
+ }
2161
+ /** Get/set whether to show the yesterday button */
2162
+ get yesterdayButton() {
2163
+ return this._yesterdayButton;
2164
+ }
2165
+ set yesterdayButton(value) {
2166
+ if (this._yesterdayButton !== value) {
2167
+ this._yesterdayButton = value;
2168
+ if (this._isInitialized) {
2169
+ this._applyYesterdayButton();
2170
+ }
2171
+ }
2172
+ }
2173
+ /* Get/set the yesterday button callback */
2174
+ get yesterdayCallback() {
2175
+ return this._yesterdayCallback;
2176
+ }
2177
+ set yesterdayCallback(value) {
2178
+ this._yesterdayCallback = value;
2179
+ }
2180
+ /** Get/set show last seven days */
2181
+ get showLastSevenDays() {
2182
+ return this._showLastSevenDays;
2183
+ }
2184
+ set showLastSevenDays(value) {
2185
+ if (this._showLastSevenDays !== value) {
2186
+ this._showLastSevenDays = value;
2187
+ if (this._isInitialized) {
2188
+ this._applyShowLastSevenDays();
2189
+ }
2190
+ }
2191
+ }
2192
+ /** Get/set whether to show the last seven days button */
2193
+ get lastSevenDaysButton() {
2194
+ return this._lastSevenDaysButton;
2195
+ }
2196
+ set lastSevenDaysButton(value) {
2197
+ if (this._lastSevenDaysButton !== value) {
2198
+ this._lastSevenDaysButton = value;
2199
+ if (this._isInitialized) {
2200
+ this._applyLastSevenDaysButton();
2201
+ }
2202
+ }
2203
+ }
2204
+ /* Get/set the last seven days button callback */
2205
+ get lastSevenDaysCallback() {
2206
+ return this._lastSevenDaysCallback;
2207
+ }
2208
+ set lastSevenDaysCallback(value) {
2209
+ this._lastSevenDaysCallback = value;
2210
+ }
2211
+ /** Get/set show last thirty days */
2212
+ get showLastThirtyDays() {
2213
+ return this._showLastThirtyDays;
2214
+ }
2215
+ set showLastThirtyDays(value) {
2216
+ if (this._showLastThirtyDays !== value) {
2217
+ this._showLastThirtyDays = value;
2218
+ if (this._isInitialized) {
2219
+ this._applyShowLastThirtyDays();
2220
+ }
2221
+ }
2222
+ }
2223
+ /** Get/set whether to show the last thirty days button */
2224
+ get lastThirtyDaysButton() {
2225
+ return this._lastThirtyDaysButton;
2226
+ }
2227
+ set lastThirtyDaysButton(value) {
2228
+ if (this._lastThirtyDaysButton !== value) {
2229
+ this._lastThirtyDaysButton = value;
2230
+ if (this._isInitialized) {
2231
+ this._applyLastThirtyDaysButton();
2232
+ }
2233
+ }
2234
+ }
2235
+ /* Get/set the last thirty days button callback */
2236
+ get lastThirtyDaysCallback() {
2237
+ return this._lastThirtyDaysCallback;
2238
+ }
2239
+ set lastThirtyDaysCallback(value) {
2240
+ this._lastThirtyDaysCallback = value;
2241
+ }
2068
2242
  /** Get/set the tooltip builder */
2069
2243
  get tooltipBuilder() {
2070
2244
  return this._tooltipBuilder;
@@ -2213,11 +2387,55 @@ export class CalendarCore {
2213
2387
  today() {
2214
2388
  const today = new Date();
2215
2389
  today.setHours(0, 0, 0, 0);
2390
+ const endOfToday = new Date();
2391
+ endOfToday.setHours(23, 59, 59, 0);
2216
2392
  this._goToDate(today, true);
2217
2393
  if (this._todayCallback) {
2218
2394
  this._todayCallback();
2219
2395
  }
2220
2396
  }
2397
+ /** Go to yesterday */
2398
+ yesterday() {
2399
+ const today = new Date();
2400
+ const yesterdayFrom = new Date(today.setDate(today.getDate() - 1));
2401
+ yesterdayFrom.setHours(0, 0, 0, 0);
2402
+ const yesterdayTo = new Date(yesterdayFrom);
2403
+ yesterdayTo.setHours(23, 59, 59, 0);
2404
+ const dateRange = [yesterdayFrom, yesterdayTo];
2405
+ this._adapter.setRange(dateRange);
2406
+ this._goToDate(yesterdayFrom, true);
2407
+ if (this._yesterdayCallback) {
2408
+ this._yesterdayCallback();
2409
+ }
2410
+ }
2411
+ /** Go to last seven days */
2412
+ lastSevenDays() {
2413
+ const today = new Date();
2414
+ const lastSevenDaysFrom = new Date(today.setDate(today.getDate() - 7));
2415
+ lastSevenDaysFrom.setHours(0, 0, 0, 0);
2416
+ const lastSevenDaysTo = new Date();
2417
+ lastSevenDaysTo.setHours(23, 59, 59, 0);
2418
+ const dateRange = [lastSevenDaysFrom, lastSevenDaysTo];
2419
+ this._adapter.setRange(dateRange);
2420
+ this._applyValue(dateRange);
2421
+ if (this._lastSevenDaysCallback) {
2422
+ this._lastSevenDaysCallback();
2423
+ }
2424
+ }
2425
+ /** Go to last thirty days */
2426
+ lastThirtyDays() {
2427
+ const today = new Date();
2428
+ const lastThirtyDaysFrom = new Date(today.setDate(today.getDate() - 30));
2429
+ lastThirtyDaysFrom.setHours(0, 0, 0, 0);
2430
+ const lastThirtyDaysTo = new Date();
2431
+ lastThirtyDaysTo.setHours(23, 59, 59, 0);
2432
+ const dateRange = [lastThirtyDaysFrom, lastThirtyDaysTo];
2433
+ this._adapter.setRange(dateRange);
2434
+ this._applyValue(dateRange);
2435
+ if (this._lastThirtyDaysCallback) {
2436
+ this._lastThirtyDaysCallback();
2437
+ }
2438
+ }
2221
2439
  /** Toggles a date selected or unselected */
2222
2440
  toggleDate(date, force) {
2223
2441
  this._onDateSelected(date);
@@ -38,6 +38,12 @@ export declare function getFooter(): HTMLElement;
38
38
  export declare function getClearButton(): HTMLElement;
39
39
  /** Returns a today button. */
40
40
  export declare function getTodayButton(): HTMLElement;
41
+ /** Returns a yesterday button. */
42
+ export declare function getYesterdayButton(): HTMLElement;
43
+ /** Returns a last seven days button. */
44
+ export declare function getLastSevenDaysButton(): HTMLElement;
45
+ /** Returns a last thirty days button. */
46
+ export declare function getLastThirtyDaysButton(): HTMLElement;
41
47
  /** Checks whether an event originated from a date element, returning the element if it did. */
42
48
  export declare function eventIncludesDate(evt: Event, includeDisabled?: boolean): HTMLElement | null;
43
49
  /** Checks whether an event originated from an element with the given id, returning the element if it did. */
@@ -270,6 +270,42 @@ export function getTodayButton() {
270
270
  todayButton.appendChild(slot);
271
271
  return todayButton;
272
272
  }
273
+ /** Returns a yesterday button. */
274
+ export function getYesterdayButton() {
275
+ const yesterdayButton = document.createElement('forge-button');
276
+ yesterdayButton.id = CALENDAR_CONSTANTS.ids.YESTERDAY_BUTTON;
277
+ yesterdayButton.setAttribute('part', CALENDAR_CONSTANTS.parts.YESTERDAY_BUTTON);
278
+ yesterdayButton.type = 'button';
279
+ const slot = document.createElement('slot');
280
+ slot.name = CALENDAR_CONSTANTS.slots.YESTERDAY_BUTTON_TEXT;
281
+ slot.innerText = CALENDAR_CONSTANTS.strings.DEFAULT_YESTERDAY_BUTTON_TEXT;
282
+ yesterdayButton.appendChild(slot);
283
+ return yesterdayButton;
284
+ }
285
+ /** Returns a last seven days button. */
286
+ export function getLastSevenDaysButton() {
287
+ const lastSevenDaysButton = document.createElement('forge-button');
288
+ lastSevenDaysButton.id = CALENDAR_CONSTANTS.ids.LAST_SEVEN_DAYS_BUTTON;
289
+ lastSevenDaysButton.setAttribute('part', CALENDAR_CONSTANTS.parts.LAST_SEVEN_DAYS_BUTTON);
290
+ lastSevenDaysButton.type = 'button';
291
+ const slot = document.createElement('slot');
292
+ slot.name = CALENDAR_CONSTANTS.slots.LAST_SEVEN_DAYS_BUTTON_TEXT;
293
+ slot.innerText = CALENDAR_CONSTANTS.strings.DEFAULT_LAST_SEVEN_DAYS_BUTTON_TEXT;
294
+ lastSevenDaysButton.appendChild(slot);
295
+ return lastSevenDaysButton;
296
+ }
297
+ /** Returns a last thirty days button. */
298
+ export function getLastThirtyDaysButton() {
299
+ const lastThirtyDaysButton = document.createElement('forge-button');
300
+ lastThirtyDaysButton.id = CALENDAR_CONSTANTS.ids.LAST_THIRTY_DAYS_BUTTON;
301
+ lastThirtyDaysButton.setAttribute('part', CALENDAR_CONSTANTS.parts.LAST_THIRTY_DAYS_BUTTON);
302
+ lastThirtyDaysButton.type = 'button';
303
+ const slot = document.createElement('slot');
304
+ slot.name = CALENDAR_CONSTANTS.slots.LAST_THIRTY_DAYS_BUTTON_TEXT;
305
+ slot.innerText = CALENDAR_CONSTANTS.strings.DEFAULT_LAST_THIRTY_DAYS_BUTTON_TEXT;
306
+ lastThirtyDaysButton.appendChild(slot);
307
+ return lastThirtyDaysButton;
308
+ }
273
309
  /** Checks whether an event originated from a date element, returning the element if it did. */
274
310
  export function eventIncludesDate(evt, includeDisabled) {
275
311
  const element = getEventPath(evt).find(p => p.classList && p.classList.contains(CALENDAR_CONSTANTS.classes.DATE));