@globalpayments/vega 2.57.1 → 2.58.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 (53) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/vega-calendar_3.cjs.entry.js +197 -114
  3. package/dist/cjs/vega-dropdown_5.cjs.entry.js +28 -4
  4. package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
  5. package/dist/cjs/vega-input-phone-number.cjs.entry.js +1 -1
  6. package/dist/cjs/vega-input-select.cjs.entry.js +6 -3
  7. package/dist/cjs/vega-selection-tile_2.cjs.entry.js +26 -2
  8. package/dist/cjs/vega.cjs.js +1 -1
  9. package/dist/collection/components/vega-calendar/slimmers/common/controllers/vega-calendar-post-operation-date-controller.js +48 -0
  10. package/dist/collection/components/vega-calendar/slimmers/common/renderers/vega-calendar-switch-panel.js +8 -2
  11. package/dist/collection/components/vega-calendar/vega-calendar.js +42 -1
  12. package/dist/collection/components/vega-dropdown/vega-dropdown-item/slimmers/renderers/vega-dropdown-item-renderer.js +27 -3
  13. package/dist/collection/components/vega-dropdown/vega-dropdown-item/vega-dropdown-item.css +6 -0
  14. package/dist/collection/components/vega-input-phone-number/vega-input-phone-number.css +4 -0
  15. package/dist/collection/components/vega-input-select/slimmers/renderers/vega-input-select-dropdown-renderer.js +5 -2
  16. package/dist/collection/components/vega-input-select/vega-input-select.css +0 -3
  17. package/dist/collection/components/vega-selection-tile/slimmers/controllers/vega-selection-tile-state-controller.js +7 -0
  18. package/dist/collection/components/vega-selection-tile/vega-selection-tile-group/vega-selection-tile-group.js +37 -0
  19. package/dist/collection/components/vega-selection-tile/vega-selection-tile.css +12 -0
  20. package/dist/collection/components/vega-selection-tile/vega-selection-tile.js +7 -2
  21. package/dist/collection/helpers/calendar/calendar-period/month-period.js +15 -1
  22. package/dist/collection/helpers/calendar/calendar-period/week-period.js +6 -7
  23. package/dist/collection/helpers/calendar/test/calendar-period/month-period.test.js +12 -4
  24. package/dist/collection/helpers/calendar/test/calendar-period/week-period.test.js +2 -2
  25. package/dist/esm/loader.js +1 -1
  26. package/dist/esm/vega-calendar_3.entry.js +197 -114
  27. package/dist/esm/vega-dropdown_5.entry.js +28 -4
  28. package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
  29. package/dist/esm/vega-input-phone-number.entry.js +1 -1
  30. package/dist/esm/vega-input-select.entry.js +6 -3
  31. package/dist/esm/vega-selection-tile_2.entry.js +26 -2
  32. package/dist/esm/vega.js +1 -1
  33. package/dist/types/components/vega-calendar/slimmers/common/controllers/vega-calendar-post-operation-date-controller.d.ts +23 -0
  34. package/dist/types/components/vega-calendar/slimmers/common/renderers/vega-calendar-switch-panel.d.ts +2 -0
  35. package/dist/types/components/vega-calendar/vega-calendar.d.ts +15 -1
  36. package/dist/types/components/vega-dropdown/vega-dropdown-item/slimmers/renderers/vega-dropdown-item-renderer.d.ts +4 -0
  37. package/dist/types/components/vega-selection-tile/slimmers/controllers/vega-selection-tile-state-controller.d.ts +1 -0
  38. package/dist/types/components/vega-selection-tile/vega-selection-tile-group/vega-selection-tile-group.d.ts +8 -0
  39. package/dist/types/components/vega-selection-tile/vega-selection-tile.d.ts +4 -0
  40. package/dist/types/components.d.ts +20 -0
  41. package/dist/types/helpers/calendar/calendar-period/calendar-period.abstract.d.ts +3 -3
  42. package/dist/types/helpers/calendar/calendar-period/month-period.d.ts +7 -1
  43. package/dist/vega/{p-f3ab00ad.entry.js → p-27a9ad35.entry.js} +1 -1
  44. package/dist/vega/p-5f377954.js +1 -1
  45. package/dist/vega/p-8e2b1dae.entry.js +1 -0
  46. package/dist/vega/p-9540e3ed.entry.js +1 -0
  47. package/dist/vega/p-997a2064.entry.js +1 -0
  48. package/dist/vega/{p-39906ad2.entry.js → p-d661a5aa.entry.js} +1 -1
  49. package/dist/vega/vega.esm.js +1 -1
  50. package/package.json +1 -1
  51. package/dist/vega/p-080db42b.entry.js +0 -1
  52. package/dist/vega/p-45eb1e01.entry.js +0 -1
  53. package/dist/vega/p-9ca7467d.entry.js +0 -1
@@ -15,6 +15,7 @@ import { VegaCalendarViewWithTimeRenderer } from './slimmers/day-view/renderers/
15
15
  import { VegaCalendarTimeLineRenderer } from './slimmers/day-view/renderers/vega-calendar-time-line-renderer';
16
16
  import { createEventEmitSlimmer, } from '../../helpers/event-manager/slimmers/event-emit-slimmer';
17
17
  import { VegaChange, VegaDateDblClick, VegaEventClick, VegaMoreActionClick, } from '../../helpers/event-manager/event-id/vega-event-id';
18
+ import { CalendarDate } from '../../helpers/calendar';
18
19
  import { VegaCalendarViewController } from './slimmers/common/controllers/vega-calendar-view-controller';
19
20
  import { VegaCalendarCurrentPeriodController } from './slimmers/common/controllers/vega-calendar-current-period-controller';
20
21
  import { ChildNodesEventPreventSlimmer } from '../../helpers/event-manager/slimmers/child-nodes-event-prevent-slimmer';
@@ -31,6 +32,7 @@ import { createSubStateNotifySlimmer } from '../../helpers/slimmers/sub-state/su
31
32
  import { VegaCalendarFullDayEventMoreButtonRenderer } from './slimmers/day-view/renderers/full-day-event/vega-calendar-full-day-event-more-button-renderer';
32
33
  import { TranslationSlimmer } from '../../helpers/slimmers/translation';
33
34
  import { VegaCalendarTimeMarkerRenderer } from './slimmers/day-view/renderers/vega-calendar-time-marker-renderer';
35
+ import { VegaCalendarPostOperationDateController } from './slimmers/common/controllers/vega-calendar-post-operation-date-controller';
34
36
  /**
35
37
  * @vegaVersion 2.14.0
36
38
  */
@@ -47,9 +49,11 @@ export class VegaCalendar {
47
49
  this.timeLineRenderer = new VegaCalendarTimeLineRenderer();
48
50
  this.timeMarkerRenderer = new VegaCalendarTimeMarkerRenderer();
49
51
  this.monthEventRenderer = new VegaCalendarMonthEventRenderer();
50
- //The current period controller should be before the calendar view controller because the initial current period should be before the initial calendar view
52
+ // The current period controller should be before the calendar view controller because the initial current period should be before the initial calendar view
51
53
  this.currentPeriodController = new VegaCalendarCurrentPeriodController();
52
54
  this.calendarViewController = new VegaCalendarViewController();
55
+ // Date after recording the operation
56
+ this.postOperationDateController = new VegaCalendarPostOperationDateController();
53
57
  this.dayViewFullDayEventRenderer = new VegaCalendarFullDayEventRenderer();
54
58
  this.dayViewFullDayEventMoreButtonRenderer = new VegaCalendarFullDayEventMoreButtonRenderer();
55
59
  this.dayViewTimedEventRenderer = new VegaCalendarTimedEventRenderer();
@@ -65,6 +69,12 @@ export class VegaCalendar {
65
69
  this.changeEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange], () => this.switchPanelRenderer.getSwitchPanelRef());
66
70
  this.timeFormatNotifySlimmer = createSubStateNotifySlimmer(VegaCalendar, 'timeFormat', 'watchTimeFormat');
67
71
  this.showEventColorBarNotifySlimmer = createSubStateNotifySlimmer(VegaCalendar, 'showEventColorBar', 'watchShowEventColorBar');
72
+ /**
73
+ * This postOperationDate will record the time after the operation, which will affect the calculation of day/week/month, making the generated interval accurate
74
+ *
75
+ * @type {CalendarDate}
76
+ */
77
+ this.postOperationDate = CalendarDate.from(new Date());
68
78
  this.showAllEventsInDayOrWeekView = false;
69
79
  this.calendarEvents = [];
70
80
  /**
@@ -99,6 +109,12 @@ export class VegaCalendar {
99
109
  * @vegaVersion 2.21.0
100
110
  */
101
111
  this.showEventColorBar = true;
112
+ /**
113
+ * Controls whether the switch view is displayed.
114
+ *
115
+ * @vegaVersion 2.58.0
116
+ */
117
+ this.showSwitchView = true;
102
118
  /**
103
119
  * Controls the visibility of the weekend columns in the calendar.
104
120
  *
@@ -314,6 +330,27 @@ export class VegaCalendar {
314
330
  "reflect": false,
315
331
  "defaultValue": "true"
316
332
  },
333
+ "showSwitchView": {
334
+ "type": "boolean",
335
+ "mutable": false,
336
+ "complexType": {
337
+ "original": "boolean",
338
+ "resolved": "boolean",
339
+ "references": {}
340
+ },
341
+ "required": false,
342
+ "optional": false,
343
+ "docs": {
344
+ "tags": [{
345
+ "name": "vegaVersion",
346
+ "text": "2.58.0"
347
+ }],
348
+ "text": "Controls whether the switch view is displayed."
349
+ },
350
+ "attribute": "show-switch-view",
351
+ "reflect": false,
352
+ "defaultValue": "true"
353
+ },
317
354
  "showWeekends": {
318
355
  "type": "boolean",
319
356
  "mutable": false,
@@ -339,6 +376,7 @@ export class VegaCalendar {
339
376
  static get states() { return {
340
377
  "calendarView": {},
341
378
  "currentPeriod": {},
379
+ "postOperationDate": {},
342
380
  "showAllEventsInDayOrWeekView": {},
343
381
  "calendarEvents": {}
344
382
  }; }
@@ -589,6 +627,9 @@ __decorate([
589
627
  __decorate([
590
628
  InjectVegaSlimmer()
591
629
  ], VegaCalendar.prototype, "calendarViewController", void 0);
630
+ __decorate([
631
+ InjectVegaSlimmer()
632
+ ], VegaCalendar.prototype, "postOperationDateController", void 0);
592
633
  __decorate([
593
634
  InjectVegaSlimmer()
594
635
  ], VegaCalendar.prototype, "dayViewFullDayEventRenderer", void 0);
@@ -8,6 +8,14 @@ import { Fragment, h } from '@stencil/core';
8
8
  import { MapToComponentField, VegaSlimmer } from 'vega-slimmer/core';
9
9
  import { createEnterKeyHandlerToTriggerClick } from '../../../../../utils/accessibility';
10
10
  export class VegaDropdownItemRenderer extends VegaSlimmer {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.setLabelRef = (ref) => {
14
+ if (ref) {
15
+ this.labelRef = ref;
16
+ }
17
+ };
18
+ }
11
19
  render() {
12
20
  return (h("li", { key: this.label, role: "menuitem", "aria-label": this.label, class: {
13
21
  'vega-dropdown-item-selected': this.selected,
@@ -23,7 +31,7 @@ export class VegaDropdownItemRenderer extends VegaSlimmer {
23
31
  } },
24
32
  this.renderSelectIcon(),
25
33
  this.renderPrefixIcon(),
26
- this.renderLabel(),
34
+ this.itemDisplayRule === 'ellipsis' ? this.renderLabelWithTooltip() : this.renderLabel(),
27
35
  this.renderCounter()));
28
36
  }
29
37
  renderSelectIcon() {
@@ -47,12 +55,12 @@ export class VegaDropdownItemRenderer extends VegaSlimmer {
47
55
  // We prioritize slots, and when both slots and labels are defined, we can collect label information for component display,
48
56
  // such as input select selected item display
49
57
  if (this.host.childElementCount > 0 || this.host.textContent.trim() !== '') {
50
- return (h("span", { class: "vega-dropdown-item-label" },
58
+ return (h("span", { class: "vega-dropdown-item-label", ref: this.setLabelRef },
51
59
  h("slot", null)));
52
60
  }
53
61
  else {
54
62
  return (h(Fragment, null,
55
- h("span", { innerHTML: this.label, class: "vega-dropdown-item-label" }),
63
+ h("span", { innerHTML: this.label, class: "vega-dropdown-item-label", ref: this.setLabelRef }),
56
64
  h("span", { class: "v-hidden" },
57
65
  h("slot", null))));
58
66
  }
@@ -64,6 +72,22 @@ export class VegaDropdownItemRenderer extends VegaSlimmer {
64
72
  onSelect(e) {
65
73
  this.vegaDropdownItemClickController.handleClick(e);
66
74
  }
75
+ renderLabelWithTooltip() {
76
+ if (!this.label) {
77
+ return this.renderLabel();
78
+ }
79
+ return (h("vega-tooltip", { ref: (ref) => {
80
+ if (ref) {
81
+ this.tooltipRef = ref;
82
+ }
83
+ }, text: this.label.replace(/<b>(.*?)<\/b>/g, '$1'), trigger: "none", placement: ['bottom', 'top'], alignment: "center",
84
+ /* eslint-disable-next-line react/jsx-no-bind */
85
+ onMouseEnter: (e) => {
86
+ e.preventDefault();
87
+ const isTextTruncated = this.labelRef.scrollWidth > this.labelRef.clientWidth;
88
+ this.tooltipRef.trigger = isTextTruncated ? 'hover' : 'none';
89
+ } }, this.renderLabel()));
90
+ }
67
91
  }
68
92
  __decorate([
69
93
  MapToComponentField()
@@ -124,6 +124,12 @@
124
124
  overflow: hidden;
125
125
  text-overflow: ellipsis;
126
126
  white-space: nowrap;
127
+ pointer-events: none;
128
+ }
129
+ :host .vega-dropdown-item-display-ellipsis vega-tooltip {
130
+ flex-grow: 1;
131
+ display: block;
132
+ overflow: hidden;
127
133
  }
128
134
 
129
135
  :host .v-hidden {
@@ -15,6 +15,10 @@
15
15
  padding-right: 8px;
16
16
  }
17
17
 
18
+ .vega-input-phone-number-container vega-input-select {
19
+ white-space: nowrap;
20
+ }
21
+
18
22
  :host .vega-input-phone-number-container.error vega-input::part(input-container) {
19
23
  border: 1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1));
20
24
  }
@@ -35,7 +35,9 @@ export class VegaInputSelectDropdownRenderer extends VegaSlimmer {
35
35
  };
36
36
  this.renderMultipleSelected = () => {
37
37
  if (this.value.length > 0) {
38
- return (h("span", { class: "vega-input-select-selected" }, this.selectedLabel(this.value)));
38
+ const selectedLabelStr = this.selectedLabel(this.value);
39
+ return (h("span", { class: "vega-input-select-selected" },
40
+ h("vega-text", { overflow: "ellipsis", tooltip: { placement: 'bottom' }, key: selectedLabelStr }, selectedLabelStr)));
39
41
  }
40
42
  else {
41
43
  return (h("div", { class: "vega-input-select-placeholder" }, this.translationSlimmer.t(this.placeholder)));
@@ -44,7 +46,8 @@ export class VegaInputSelectDropdownRenderer extends VegaSlimmer {
44
46
  this.renderSingleSelected = () => {
45
47
  const item = this.sourceController.getItem(this.value);
46
48
  if (item) {
47
- return (h("span", { class: "vega-input-select-selected", part: "selected-box" }, item.displayName));
49
+ return (h("span", { class: "vega-input-select-selected", part: "selected-box" },
50
+ h("vega-text", { overflow: "ellipsis", tooltip: { placement: 'bottom' }, key: item.displayName }, item.displayName)));
48
51
  }
49
52
  else {
50
53
  return (h("div", { class: "vega-input-select-placeholder", part: "placeholder" }, this.translationSlimmer.t(this.placeholder)));
@@ -132,9 +132,6 @@
132
132
  line-height: 24px;
133
133
  letter-spacing: 0px;
134
134
  color: rgba(var(--v-text-primary, 32, 54, 69, 1));
135
- overflow: hidden;
136
- text-overflow: ellipsis;
137
- white-space: nowrap;
138
135
  display: block;
139
136
  min-height: 24px;
140
137
  }
@@ -49,6 +49,10 @@ export class VegaSelectionTileStateController extends SubStateObserverSlimmer {
49
49
  : groupValue === this.value);
50
50
  },
51
51
  },
52
+ {
53
+ subStateName: 'distributeEvenly',
54
+ parentStateName: 'distributeEvenly',
55
+ },
52
56
  ],
53
57
  });
54
58
  }
@@ -71,3 +75,6 @@ __decorate([
71
75
  __decorate([
72
76
  MapToComponentField()
73
77
  ], VegaSelectionTileStateController.prototype, "checkedController", void 0);
78
+ __decorate([
79
+ MapToComponentField({ writable: true })
80
+ ], VegaSelectionTileStateController.prototype, "distributeEvenly", void 0);
@@ -47,6 +47,7 @@ export class VegaSelectionTileGroup {
47
47
  this.selectTypeNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'selectType', 'watchSelectType');
48
48
  this.disabledNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'disabled', 'watchDisabled');
49
49
  this.valueNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'value', 'watchValue');
50
+ this.distributeEvenlyNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'distributeEvenly', 'watchDistributeEvenly');
50
51
  this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
51
52
  /**
52
53
  * Specifies the label or title for the selection tile group.
@@ -56,6 +57,12 @@ export class VegaSelectionTileGroup {
56
57
  * @vegaVersion 2.7.0
57
58
  */
58
59
  this.label = '';
60
+ /**
61
+ * Distribute vega-selection-tile components evenly to always cover the entire available width of the vega-selection-tile-group
62
+ *
63
+ * @vegaVersion 2.58.0
64
+ */
65
+ this.distributeEvenly = false;
59
66
  /**
60
67
  * Determines the selection method for the tile group. Options are:
61
68
  *
@@ -96,6 +103,9 @@ export class VegaSelectionTileGroup {
96
103
  /* eslint-disable-next-line @stencil/strict-mutable */
97
104
  this.isValid = null;
98
105
  }
106
+ watchDistributeEvenly() {
107
+ methodPlaceholder();
108
+ }
99
109
  watchSelectType() {
100
110
  methodPlaceholder();
101
111
  }
@@ -161,6 +171,27 @@ export class VegaSelectionTileGroup {
161
171
  "attribute": "hint",
162
172
  "reflect": false
163
173
  },
174
+ "distributeEvenly": {
175
+ "type": "boolean",
176
+ "mutable": false,
177
+ "complexType": {
178
+ "original": "boolean",
179
+ "resolved": "boolean",
180
+ "references": {}
181
+ },
182
+ "required": false,
183
+ "optional": false,
184
+ "docs": {
185
+ "tags": [{
186
+ "name": "vegaVersion",
187
+ "text": "2.58.0"
188
+ }],
189
+ "text": "Distribute vega-selection-tile components evenly to always cover the entire available width of the vega-selection-tile-group"
190
+ },
191
+ "attribute": "distribute-evenly",
192
+ "reflect": false,
193
+ "defaultValue": "false"
194
+ },
164
195
  "selectType": {
165
196
  "type": "string",
166
197
  "mutable": false,
@@ -352,6 +383,9 @@ export class VegaSelectionTileGroup {
352
383
  }]; }
353
384
  static get elementRef() { return "host"; }
354
385
  static get watchers() { return [{
386
+ "propName": "distributeEvenly",
387
+ "methodName": "watchDistributeEvenly"
388
+ }, {
355
389
  "propName": "selectType",
356
390
  "methodName": "watchSelectType"
357
391
  }, {
@@ -398,6 +432,9 @@ __decorate([
398
432
  __decorate([
399
433
  InjectVegaSlimmer()
400
434
  ], VegaSelectionTileGroup.prototype, "valueNotifySlimmer", void 0);
435
+ __decorate([
436
+ InjectVegaSlimmer()
437
+ ], VegaSelectionTileGroup.prototype, "distributeEvenlyNotifySlimmer", void 0);
401
438
  __decorate([
402
439
  InjectVegaSlimmer()
403
440
  ], VegaSelectionTileGroup.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
@@ -3,6 +3,18 @@
3
3
  * Deprecated. Not for use in new websites.
4
4
  * https://developer.mozilla.org/en-US/docs/Web/CSS/word-break#break-word
5
5
  */
6
+ :host::not(.distribute-evenly) {
7
+ display: block;
8
+ }
9
+
10
+ :host(.distribute-evenly) {
11
+ display: flex;
12
+ width: 100%;
13
+ }
14
+ :host(.distribute-evenly) .selection-tile {
15
+ flex: 1;
16
+ }
17
+
6
18
  :host {
7
19
  display: block;
8
20
  }
@@ -40,6 +40,10 @@ export class VegaSelectionTile {
40
40
  * Indicates whether the parent selection tile group shows error message.
41
41
  */
42
42
  this.showError = false;
43
+ /**
44
+ * Distribute vega-selection-tile components evenly to always cover the entire available width of the parent
45
+ */
46
+ this.distributeEvenly = false;
43
47
  /**
44
48
  * Specifies the text content of the title displayed
45
49
  * within the selection tile.
@@ -68,7 +72,7 @@ export class VegaSelectionTile {
68
72
  this.selectType = 'radio';
69
73
  }
70
74
  render() {
71
- return sanitizeVegaComponent(h(Host, null, this.renderer.render()), this.host);
75
+ return sanitizeVegaComponent(h(Host, { class: { 'distribute-evenly': this.distributeEvenly } }, this.renderer.render()), this.host);
72
76
  }
73
77
  static get is() { return "vega-selection-tile"; }
74
78
  static get encapsulation() { return "shadow"; }
@@ -224,7 +228,8 @@ export class VegaSelectionTile {
224
228
  }
225
229
  }; }
226
230
  static get states() { return {
227
- "showError": {}
231
+ "showError": {},
232
+ "distributeEvenly": {}
228
233
  }; }
229
234
  static get events() { return [{
230
235
  "method": "vegaChange",
@@ -1,11 +1,12 @@
1
1
  import { CalendarPeriod } from './calendar-period.abstract';
2
2
  import { CalendarDate } from '../calendar-date';
3
+ import { getWeekdays } from '../utils';
3
4
  /**
4
5
  * Period of month
5
6
  */
6
7
  export class MonthPeriod extends CalendarPeriod {
7
8
  constructor(current, showWeekends) {
8
- super(MonthPeriod.DISPLAY_DATE_COUNT, MonthPeriod.getMonthFirstDay(current));
9
+ super(MonthPeriod.DISPLAY_DATE_COUNT, current);
9
10
  this._type = 'month';
10
11
  this._showWeekends = true;
11
12
  this._showWeekends = showWeekends === false ? false : true;
@@ -24,6 +25,19 @@ export class MonthPeriod extends CalendarPeriod {
24
25
  const date = calendarDate || CalendarDate.from(new Date());
25
26
  return new CalendarDate(date.year, date.month, 1);
26
27
  }
28
+ /**
29
+ * Calculate the period start date and end date.
30
+ *
31
+ * @param {CalendarDate} date - The date to calculate the period from.
32
+ */
33
+ calculatePeriod(date) {
34
+ const firstDay = MonthPeriod.getMonthFirstDay(date);
35
+ const cursor = firstDay.toDate();
36
+ cursor.setDate(cursor.getDate() - getWeekdays().indexOf(cursor.getDay()));
37
+ this._startDate = CalendarDate.from(cursor);
38
+ cursor.setDate(cursor.getDate() + this.count - 1);
39
+ this._endDate = CalendarDate.from(cursor);
40
+ }
27
41
  /**
28
42
  * @inheritDoc
29
43
  */
@@ -1,5 +1,4 @@
1
1
  import { CalendarPeriod } from './calendar-period.abstract';
2
- import { getWeekdays } from '../utils';
3
2
  import { CalendarDate } from '../calendar-date';
4
3
  /**
5
4
  * Period of the week
@@ -15,17 +14,17 @@ export class WeekPeriod extends CalendarPeriod {
15
14
  * @inheritDoc
16
15
  */
17
16
  next() {
18
- const nextWeekStartDate = this.current.toDate();
19
- nextWeekStartDate.setDate(nextWeekStartDate.getDate() - getWeekdays().indexOf(nextWeekStartDate.getDay()) + 7);
20
- return this.createBy(CalendarDate.from(nextWeekStartDate));
17
+ const currentDate = this.current.toDate();
18
+ currentDate.setDate(currentDate.getDate() + 7);
19
+ return this.createBy(CalendarDate.from(currentDate));
21
20
  }
22
21
  /**
23
22
  * @inheritDoc
24
23
  */
25
24
  previous() {
26
- const previousWeekStartDate = this.current.toDate();
27
- previousWeekStartDate.setDate(previousWeekStartDate.getDate() - getWeekdays().indexOf(previousWeekStartDate.getDay()) - 7);
28
- return this.createBy(CalendarDate.from(previousWeekStartDate));
25
+ const currentDate = this.current.toDate();
26
+ currentDate.setDate(currentDate.getDate() - 7);
27
+ return this.createBy(CalendarDate.from(currentDate));
29
28
  }
30
29
  /**
31
30
  * @inheritDoc
@@ -12,7 +12,7 @@ describe('month-period', () => {
12
12
  const { current, count, startDate, endDate } = new MonthPeriod();
13
13
  expect({ current, count, startDate, endDate }).toEqual({
14
14
  count: 42,
15
- current: new CalendarDate(2020, 4, 1),
15
+ current: new CalendarDate(2020, 4, 3),
16
16
  startDate: new CalendarDate(2020, 3, 29),
17
17
  endDate: new CalendarDate(2020, 5, 9),
18
18
  });
@@ -32,7 +32,7 @@ describe('month-period', () => {
32
32
  const { current, count, startDate, endDate } = monthPeriod.now();
33
33
  expect({ current, count, startDate, endDate }).toEqual({
34
34
  count: 42,
35
- current: new CalendarDate(2020, 4, 1),
35
+ current: new CalendarDate(2020, 4, 3),
36
36
  startDate: new CalendarDate(2020, 3, 29),
37
37
  endDate: new CalendarDate(2020, 5, 9),
38
38
  });
@@ -42,7 +42,7 @@ describe('month-period', () => {
42
42
  const { current, count, startDate, endDate } = monthPeriod.next();
43
43
  expect({ current, count, startDate, endDate }).toEqual({
44
44
  count: 42,
45
- current: new CalendarDate(2020, 5, 1),
45
+ current: new CalendarDate(2020, 5, 3),
46
46
  startDate: new CalendarDate(2020, 4, 26),
47
47
  endDate: new CalendarDate(2020, 6, 6),
48
48
  });
@@ -52,9 +52,17 @@ describe('month-period', () => {
52
52
  const { current, count, startDate, endDate } = monthPeriod.previous();
53
53
  expect({ current, count, startDate, endDate }).toEqual({
54
54
  count: 42,
55
- current: new CalendarDate(2020, 3, 1),
55
+ current: new CalendarDate(2020, 3, 3),
56
56
  startDate: new CalendarDate(2020, 3, 1),
57
57
  endDate: new CalendarDate(2020, 4, 11),
58
58
  });
59
59
  });
60
+ it('should work when get month first day', () => {
61
+ const { year, month, date } = MonthPeriod.getMonthFirstDay();
62
+ expect({ year, month, date }).toEqual({
63
+ year: 2020,
64
+ month: 4,
65
+ date: 1,
66
+ });
67
+ });
60
68
  });
@@ -42,7 +42,7 @@ describe('week-period', () => {
42
42
  const { current, count, startDate, endDate } = weekPeriod.next();
43
43
  expect({ current, count, startDate, endDate }).toEqual({
44
44
  count: 7,
45
- current: new CalendarDate(2020, 4, 5),
45
+ current: new CalendarDate(2020, 4, 10),
46
46
  startDate: new CalendarDate(2020, 4, 5),
47
47
  endDate: new CalendarDate(2020, 4, 11),
48
48
  });
@@ -52,7 +52,7 @@ describe('week-period', () => {
52
52
  const { current, count, startDate, endDate } = weekPeriod.previous();
53
53
  expect({ current, count, startDate, endDate }).toEqual({
54
54
  count: 7,
55
- current: new CalendarDate(2020, 3, 22),
55
+ current: new CalendarDate(2020, 3, 27),
56
56
  startDate: new CalendarDate(2020, 3, 22),
57
57
  endDate: new CalendarDate(2020, 3, 28),
58
58
  });