@sarasanalytics-com/design-system 0.0.9 → 0.0.10

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 (160) hide show
  1. package/esm2022/interfaces/avatar-interface.mjs +2 -0
  2. package/esm2022/interfaces/button-interface.mjs +2 -0
  3. package/esm2022/interfaces/chip-interface.mjs +2 -0
  4. package/esm2022/interfaces/grid-interface.mjs +2 -0
  5. package/esm2022/interfaces/select-interface.mjs +2 -0
  6. package/esm2022/interfaces/tab-interface.mjs +2 -0
  7. package/esm2022/lib/avatar/avatar.component.mjs +56 -0
  8. package/esm2022/lib/button/button.component.mjs +84 -0
  9. package/esm2022/lib/calendar-header/calendar-header.component.mjs +168 -0
  10. package/esm2022/lib/card/card-footer-actions/card-footer-actions.component.mjs +11 -0
  11. package/esm2022/lib/card/card-icon/card-icon.component.mjs +11 -0
  12. package/esm2022/lib/card/card-title-actions/card-title-actions.component.mjs +11 -0
  13. package/esm2022/lib/card/card.component.mjs +53 -0
  14. package/esm2022/lib/chips/chips.component.mjs +62 -0
  15. package/esm2022/lib/component-library.component.mjs +19 -0
  16. package/esm2022/lib/component-library.service.mjs +14 -0
  17. package/esm2022/lib/datepicker/datepicker.component.mjs +40 -0
  18. package/esm2022/lib/form-input/form-input.component.mjs +152 -0
  19. package/esm2022/lib/form-select/form-select.component.mjs +59 -0
  20. package/esm2022/lib/grid-cell/grid-cell.component.mjs +84 -0
  21. package/esm2022/lib/header/header.component.mjs +37 -0
  22. package/esm2022/lib/icon/icon.component.mjs +50 -0
  23. package/esm2022/lib/icon/icon.service.mjs +29 -0
  24. package/esm2022/lib/left-nav/left-nav.component.mjs +117 -0
  25. package/esm2022/lib/stepper/stepper.component.mjs +64 -0
  26. package/esm2022/lib/tabs/tabs.component.mjs +38 -0
  27. package/esm2022/lib/toast/toast.component.mjs +100 -0
  28. package/esm2022/lib/tool-tip/tool-tip.component.mjs +41 -0
  29. package/esm2022/public-api.mjs +30 -0
  30. package/esm2022/sarasanalytics-com-design-system.mjs +5 -0
  31. package/esm2022/utils/validators.mjs +70 -0
  32. package/fesm2022/sarasanalytics-com-design-system.mjs +1274 -0
  33. package/fesm2022/sarasanalytics-com-design-system.mjs.map +1 -0
  34. package/index.d.ts +5 -0
  35. package/interfaces/avatar-interface.d.ts +6 -0
  36. package/interfaces/button-interface.d.ts +12 -0
  37. package/interfaces/chip-interface.d.ts +11 -0
  38. package/interfaces/grid-interface.d.ts +24 -0
  39. package/interfaces/select-interface.d.ts +20 -0
  40. package/interfaces/tab-interface.d.ts +6 -0
  41. package/lib/avatar/avatar.component.d.ts +18 -0
  42. package/lib/button/button.component.d.ts +26 -0
  43. package/lib/calendar-header/calendar-header.component.d.ts +31 -0
  44. package/lib/card/card-footer-actions/card-footer-actions.component.d.ts +5 -0
  45. package/lib/card/card-icon/card-icon.component.d.ts +5 -0
  46. package/lib/card/card-title-actions/card-title-actions.component.d.ts +5 -0
  47. package/lib/card/card.component.d.ts +17 -0
  48. package/lib/chips/chips.component.d.ts +22 -0
  49. package/lib/component-library.component.d.ts +5 -0
  50. package/lib/component-library.service.d.ts +6 -0
  51. package/lib/datepicker/datepicker.component.d.ts +9 -0
  52. package/lib/form-input/form-input.component.d.ts +62 -0
  53. package/lib/form-select/form-select.component.d.ts +17 -0
  54. package/lib/grid-cell/grid-cell.component.d.ts +20 -0
  55. package/lib/header/header.component.d.ts +14 -0
  56. package/lib/icon/icon.component.d.ts +16 -0
  57. package/lib/icon/icon.service.d.ts +11 -0
  58. package/lib/left-nav/left-nav.component.d.ts +38 -0
  59. package/lib/stepper/stepper.component.d.ts +17 -0
  60. package/lib/tabs/tabs.component.d.ts +15 -0
  61. package/lib/toast/toast.component.d.ts +33 -0
  62. package/lib/tool-tip/tool-tip.component.d.ts +15 -0
  63. package/package.json +15 -2
  64. package/{src/public-api.ts → public-api.d.ts} +1 -8
  65. package/utils/validators.d.ts +3 -0
  66. package/ng-package.json +0 -8
  67. package/src/interfaces/avatar-interface.ts +0 -6
  68. package/src/interfaces/button-interface.ts +0 -12
  69. package/src/interfaces/chip-interface.ts +0 -11
  70. package/src/interfaces/grid-interface.ts +0 -24
  71. package/src/interfaces/select-interface.ts +0 -20
  72. package/src/interfaces/tab-interface.ts +0 -6
  73. package/src/lib/avatar/avatar.component.css +0 -48
  74. package/src/lib/avatar/avatar.component.html +0 -5
  75. package/src/lib/avatar/avatar.component.spec.ts +0 -23
  76. package/src/lib/avatar/avatar.component.ts +0 -50
  77. package/src/lib/button/button.component.css +0 -145
  78. package/src/lib/button/button.component.html +0 -11
  79. package/src/lib/button/button.component.spec.ts +0 -23
  80. package/src/lib/button/button.component.ts +0 -68
  81. package/src/lib/calendar-header/calendar-header.component.css +0 -67
  82. package/src/lib/calendar-header/calendar-header.component.html +0 -20
  83. package/src/lib/calendar-header/calendar-header.component.spec.ts +0 -23
  84. package/src/lib/calendar-header/calendar-header.component.ts +0 -191
  85. package/src/lib/card/card-body/card-body.component.css +0 -0
  86. package/src/lib/card/card-body/card-body.component.html +0 -1
  87. package/src/lib/card/card-body/card-body.component.spec.ts +0 -23
  88. package/src/lib/card/card-body/card-body.component.ts +0 -12
  89. package/src/lib/card/card-footer-actions/card-footer-actions.component.css +0 -4
  90. package/src/lib/card/card-footer-actions/card-footer-actions.component.html +0 -3
  91. package/src/lib/card/card-footer-actions/card-footer-actions.component.spec.ts +0 -23
  92. package/src/lib/card/card-footer-actions/card-footer-actions.component.ts +0 -12
  93. package/src/lib/card/card-icon/card-icon.component.css +0 -0
  94. package/src/lib/card/card-icon/card-icon.component.html +0 -1
  95. package/src/lib/card/card-icon/card-icon.component.spec.ts +0 -23
  96. package/src/lib/card/card-icon/card-icon.component.ts +0 -12
  97. package/src/lib/card/card-title-actions/card-title-actions.component.css +0 -3
  98. package/src/lib/card/card-title-actions/card-title-actions.component.html +0 -1
  99. package/src/lib/card/card-title-actions/card-title-actions.component.spec.ts +0 -23
  100. package/src/lib/card/card-title-actions/card-title-actions.component.ts +0 -12
  101. package/src/lib/card/card.component.css +0 -84
  102. package/src/lib/card/card.component.html +0 -34
  103. package/src/lib/card/card.component.spec.ts +0 -23
  104. package/src/lib/card/card.component.ts +0 -33
  105. package/src/lib/chips/chips.component.css +0 -129
  106. package/src/lib/chips/chips.component.html +0 -17
  107. package/src/lib/chips/chips.component.spec.ts +0 -23
  108. package/src/lib/chips/chips.component.ts +0 -54
  109. package/src/lib/component-library.component.spec.ts +0 -23
  110. package/src/lib/component-library.component.ts +0 -16
  111. package/src/lib/component-library.service.spec.ts +0 -16
  112. package/src/lib/component-library.service.ts +0 -9
  113. package/src/lib/datepicker/datepicker.component.css +0 -33
  114. package/src/lib/datepicker/datepicker.component.html +0 -11
  115. package/src/lib/datepicker/datepicker.component.spec.ts +0 -23
  116. package/src/lib/datepicker/datepicker.component.ts +0 -36
  117. package/src/lib/form-input/form-input.component.css +0 -109
  118. package/src/lib/form-input/form-input.component.html +0 -27
  119. package/src/lib/form-input/form-input.component.spec.ts +0 -23
  120. package/src/lib/form-input/form-input.component.ts +0 -196
  121. package/src/lib/form-select/form-select.component.css +0 -157
  122. package/src/lib/form-select/form-select.component.html +0 -38
  123. package/src/lib/form-select/form-select.component.spec.ts +0 -23
  124. package/src/lib/form-select/form-select.component.ts +0 -54
  125. package/src/lib/grid-cell/grid-cell.component.css +0 -78
  126. package/src/lib/grid-cell/grid-cell.component.html +0 -31
  127. package/src/lib/grid-cell/grid-cell.component.spec.ts +0 -23
  128. package/src/lib/grid-cell/grid-cell.component.ts +0 -89
  129. package/src/lib/header/header.component.css +0 -62
  130. package/src/lib/header/header.component.html +0 -23
  131. package/src/lib/header/header.component.spec.ts +0 -23
  132. package/src/lib/header/header.component.ts +0 -28
  133. package/src/lib/icon/icon.component.css +0 -21
  134. package/src/lib/icon/icon.component.html +0 -5
  135. package/src/lib/icon/icon.component.ts +0 -49
  136. package/src/lib/icon/icon.service.ts +0 -27
  137. package/src/lib/left-nav/left-nav.component.css +0 -106
  138. package/src/lib/left-nav/left-nav.component.html +0 -48
  139. package/src/lib/left-nav/left-nav.component.spec.ts +0 -23
  140. package/src/lib/left-nav/left-nav.component.ts +0 -146
  141. package/src/lib/stepper/stepper.component.css +0 -96
  142. package/src/lib/stepper/stepper.component.html +0 -14
  143. package/src/lib/stepper/stepper.component.spec.ts +0 -23
  144. package/src/lib/stepper/stepper.component.ts +0 -61
  145. package/src/lib/tabs/tabs.component.css +0 -100
  146. package/src/lib/tabs/tabs.component.html +0 -16
  147. package/src/lib/tabs/tabs.component.spec.ts +0 -23
  148. package/src/lib/tabs/tabs.component.ts +0 -37
  149. package/src/lib/toast/toast.component.css +0 -107
  150. package/src/lib/toast/toast.component.html +0 -29
  151. package/src/lib/toast/toast.component.spec.ts +0 -23
  152. package/src/lib/toast/toast.component.ts +0 -87
  153. package/src/lib/tool-tip/tool-tip.component.css +0 -139
  154. package/src/lib/tool-tip/tool-tip.component.html +0 -31
  155. package/src/lib/tool-tip/tool-tip.component.spec.ts +0 -23
  156. package/src/lib/tool-tip/tool-tip.component.ts +0 -37
  157. package/src/utils/validators.ts +0 -68
  158. package/tsconfig.lib.json +0 -14
  159. package/tsconfig.lib.prod.json +0 -10
  160. package/tsconfig.spec.json +0 -14
@@ -1,145 +0,0 @@
1
- .primary {
2
- --default-bg: var(--primary-500);
3
- --default-color: var(--text-white);
4
- --default-border: transparent;
5
- --hover-bg: var(--primary-700);
6
- --hover-color: var(--text-white);
7
- --hover-border: transparent;
8
- --disabled-bg: var(--grey-100);
9
- --disabled-color: var(--text-white);
10
- --disabled-border: transparent;
11
- --error-default-bg: var(--semantic-error-500);
12
- --error-hover-bg: var(--semantic-error-600);
13
- --error-default-color: var(--text-white);
14
- --error-hover-color: var(--text-white);
15
- --error-default-border: var(--semantic-error-500);
16
- --error-hover-border: var(--semantic-error-500);
17
- --svg-icon-color: var(--default-color);
18
- }
19
-
20
- .outline {
21
- --default-bg: none;
22
- --default-color: var(--primary-500);
23
- --default-border: var(--primary-500);
24
- --hover-bg: var(--primary-50);
25
- --hover-color: var(--primary-700);
26
- --hover-border: var(--primary-700);
27
- --disabled-bg: none;
28
- --disabled-color: var(--grey-100);
29
- --disabled-border: var(--grey-100);
30
- --error-default-bg: none;
31
- --error-hover-bg: var(--semantic-error-50);
32
- --error-default-color: var(--semantic-error-500);
33
- --error-hover-color: var(--semantic-error-600);
34
- --error-default-border: var(--semantic-error-500);
35
- --error-hover-border: var(--semantic-error-600);
36
- --svg-icon-color: var(--default-color);
37
- }
38
-
39
- .transparent {
40
- --default-bg: none;
41
- --default-color: var(--primary-500);
42
- --default-border: transparent;
43
- --hover-bg: var(--primary-50);
44
- --hover-color: var(--primary-700);
45
- --hover-border: transparent;
46
- --disabled-bg: none;
47
- --disabled-color: var(--grey-100);
48
- --disabled-border: transparent;
49
- --error-default-bg: none;
50
- --error-hover-bg: var(--semantic-error-50);
51
- --error-default-color: var(--semantic-error-500);
52
- --error-hover-color: var(--semantic-error-600);
53
- --error-default-border: transparent;
54
- --error-hover-border: transparent;
55
- --svg-icon-color: var(--default-color);
56
- }
57
-
58
- .large {
59
- --sizing-1: var(--small-8px);
60
- --sizing-2: var(--small-16px);
61
- --sizing-3: var(--small-8px);
62
- --height: var(--medium-36px);
63
- --font-size: var(--small-14px);
64
- }
65
-
66
- .medium {
67
- --sizing-1: var(--small-6px);
68
- --sizing-2: var(--small-12px);
69
- --sizing-3: var(--small-8px);
70
- --height: var(--medium-32px);
71
- --font-size: var(--small-14px);
72
- }
73
-
74
- .small {
75
- --sizing-1: var(--small-4px);
76
- --sizing-2: var(--small-8px);
77
- --sizing-3: var(--small-8px);
78
- --height: var(--medium-24px);
79
- --font-size: var(--small-12px);
80
- }
81
-
82
- .disabled {
83
- background-color: var(--disabled-bg) !important;
84
- color: var(--disabled-color) !important;
85
- border: 1px solid var(--disabled-border) !important;
86
- cursor: default !important;
87
- --svg-icon-color: var(--disabled-color) !important;
88
- }
89
-
90
- .error {
91
- background-color: var(--error-default-bg) !important;
92
- color: var(--error-default-color) !important;
93
- border: 1px solid var(--error-default-border) !important;
94
- --svg-icon-color: var(--error-default-color) !important;
95
- }
96
-
97
- .error:hover {
98
- background-color: var(--error-hover-bg) !important;
99
- color: var(--error-hover-color) !important;
100
- --svg-icon-color: var(--error-hover-color) !important;
101
- }
102
-
103
- .sa-button {
104
- display: flex;
105
- width: max-content;
106
- padding: var(--sizing-1) var(--sizing-2);
107
- justify-content: center;
108
- align-items: center;
109
- gap: var(--sizing-3);
110
- box-sizing: border-box;
111
- height: var(--height);
112
-
113
- border-radius: 4px;
114
- font-family: var(--font);
115
- font-size: var(--font-size);
116
- cursor: pointer;
117
-
118
- background-color: var(--default-bg);
119
- border: 1px solid var(--default-border);
120
- color: var(--default-color);
121
-
122
- -webkit-user-select: none;
123
- -khtml-user-select: none;
124
- -moz-user-select: none;
125
- -o-user-select: none;
126
- user-select: none;
127
- }
128
-
129
- .sa-button:hover {
130
- background-color: var(--hover-bg);
131
- border: 1px solid var(--hover-border);
132
- color: var(--hover-color);
133
- --svg-icon-color: var(--hover-color);
134
- }
135
-
136
- .svg-icon {
137
- mask-size: contain;
138
- width: 16px;
139
- height: 16px;
140
- background-color: var(--svg-icon-color);
141
- }
142
-
143
- .btn-hide {
144
- display: none;
145
- }
@@ -1,11 +0,0 @@
1
- <button (click)="buttonClicked($event)" id="sa-button-{{uuid}}" class="btn-hide"
2
- [type]="isSubmit ? 'submit' : 'button'"></button>
3
- <!-- (click)="buttonClicked()" on button instead of label breaks whole thing -->
4
- <label for="sa-button-{{uuid}}" role="button" tabindex="0" (mouseenter)="mouseIn()" (mouseleave)="mouseOut()"
5
- (keydown.enter)="buttonClicked($event)" for="sa-button" class="sa-button {{state}} {{type}} {{size}}">
6
- <div class="svg-icon" [style]="svgStyle"
7
- [style.display]="(iconPosition == 'left' || iconPosition == 'both') ? 'block' : 'none'"></div>
8
- {{text}}
9
- <div class="svg-icon" [style]="svgStyle"
10
- [style.display]="(iconPosition == 'right' || iconPosition == 'both') ? 'block' : 'none'"></div>
11
- </label>
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ButtonComponent } from './button.component';
4
-
5
- describe('ButtonComponent', () => {
6
- let component: ButtonComponent;
7
- let fixture: ComponentFixture<ButtonComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ButtonComponent]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(ButtonComponent);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,68 +0,0 @@
1
- import { Component, Output } from '@angular/core';
2
- import { Input } from '@angular/core';
3
- import { EventEmitter } from '@angular/core';
4
- import { NgIf } from '@angular/common';
5
- import { NgStyle } from '@angular/common';
6
-
7
- let nextId = 0; // used to give unique ids to inputs used in html
8
-
9
- @Component({
10
- selector: 'sa-button',
11
- standalone: true,
12
- imports: [NgIf, NgStyle],
13
- templateUrl: './button.component.html',
14
- styleUrl: './button.component.css'
15
- })
16
-
17
- export class ButtonComponent {
18
- @Input() id: string | number;
19
- @Input() type: string;
20
- @Input() state: string;
21
- @Input() size: string;
22
- @Input() text: string | number;
23
- @Input() ImagePath: string;
24
- @Input() iconPosition: string;
25
- @Input() href: string;
26
- @Input() hrefTarget: string;
27
- @Input() isSubmit: boolean = false;
28
-
29
- @Output() onClickEvent = new EventEmitter();
30
- @Output() onMouseInEvent = new EventEmitter();
31
- @Output() onMouseOutEvent = new EventEmitter();
32
-
33
- svgStyle = {}
34
- eventEmitObject = {}
35
- uuid: number = nextId++;
36
-
37
- ngOnChanges(): void {
38
- this.svgStyle = {
39
- '-webkit-mask-image': `url(${this.ImagePath})`,
40
- 'mask-image': `url(${this.ImagePath})`,
41
- }
42
- this.eventEmitObject = {
43
- id: this.id
44
- }
45
- }
46
-
47
- buttonClicked(evt: Event) {
48
- if (this.state == "disabled") return;
49
- this.onClickEvent.emit({
50
- ...this.eventEmitObject,
51
- evt
52
- });
53
- if (this.href != "") {
54
- if (this.hrefTarget == "blank") window.open(this.href);
55
- else if (this.hrefTarget == "self") location.href = this.href;
56
- }
57
- }
58
-
59
- mouseIn() {
60
- if (this.state == "disabled") return;
61
- this.onMouseInEvent.emit();
62
- }
63
-
64
- mouseOut() {
65
- if (this.state == "disabled") return;
66
- this.onMouseOutEvent.emit();
67
- }
68
- }
@@ -1,67 +0,0 @@
1
- .header {
2
- display: flex;
3
- justify-content: space-between;
4
- align-items: center;
5
- border-bottom: 1px solid var(--grey-50);
6
- margin-top: -4px;
7
- margin-bottom: var(--small-8px, 8px);
8
- }
9
-
10
- .header-label {
11
- font-family: Roboto;
12
- font-size: 14px;
13
- font-style: normal;
14
- font-weight: 400;
15
- line-height: 20px;
16
- letter-spacing: 0.25px;
17
- }
18
-
19
- .range-preset {
20
- width: 180px;
21
- position: absolute;
22
-
23
- padding: var(--small-12px, 12px) 0 0 var(--medium-24px, 24px);
24
- box-sizing: border-box;
25
-
26
-
27
- margin-top: -9px;
28
- margin-left: -180px;
29
-
30
- height: 356px;
31
- background-color: white;
32
- border-top: 1px solid var(--grey-50);
33
- border-left: 1px solid var(--grey-50);
34
- border-bottom: 1px solid var(--grey-50);
35
- border-bottom-left-radius: var(--small-8px, 8px);
36
- border-top-left-radius: var(--small-8px, 8px);
37
-
38
- gap: var(--small-8px, 8px);
39
-
40
- display: flex;
41
- flex-direction: column;
42
- }
43
-
44
- .preset {
45
- padding: var(--small-8px, 8px);
46
- display: flex;
47
- gap: var(--small-4px, 4px);
48
- font-size: 14px;
49
- font-style: normal;
50
- font-weight: 400;
51
- line-height: 20px;
52
- letter-spacing: 0.25px;
53
- color: var(--text-mediumemphasis);
54
- margin-bottom: -5px;
55
- }
56
-
57
- .preset-radio {
58
- cursor: pointer;
59
- }
60
-
61
- .preset-label {
62
- cursor: pointer;
63
- }
64
-
65
- .preset-selected {
66
- color: var(--primary-500);
67
- }
@@ -1,20 +0,0 @@
1
- <div class="range-preset">
2
- <div class="preset" *ngFor="let preset of presets, let i = index">
3
- <label class="preset-label {{preset == selectedPreset ? 'preset-selected' : ''}}"
4
- for="preset-radio-{{i}}">{{preset}}</label>
5
- <input class="preset-radio" (change)="presetChanged($event)" [checked]="preset == selectedPreset"
6
- id="preset-radio-{{i}}" type="radio" name="preset-radios-{{uuid}}" value="{{preset}}">
7
- </div>
8
- </div>
9
-
10
- <div class="header">
11
- <button mat-icon-button (click)="previousClicked('month')">
12
- <mat-icon>keyboard_arrow_left</mat-icon>
13
- </button>
14
-
15
- <button mat-button class="header-label" (click)="changeView()">{{ periodLabel }}</button>
16
-
17
- <button mat-icon-button (click)="nextClicked('month')">
18
- <mat-icon>keyboard_arrow_right</mat-icon>
19
- </button>
20
- </div>
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { CalendarHeaderComponent } from './calendar-header.component';
4
-
5
- describe('CalendarHeaderComponent', () => {
6
- let component: CalendarHeaderComponent;
7
- let fixture: ComponentFixture<CalendarHeaderComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [CalendarHeaderComponent]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(CalendarHeaderComponent);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,191 +0,0 @@
1
- import {
2
- ChangeDetectorRef,
3
- Component,
4
- Inject,
5
- OnDestroy,
6
- } from '@angular/core';
7
- import {
8
- DateAdapter,
9
- MatDateFormats,
10
- MAT_DATE_FORMATS,
11
- } from '@angular/material/core';
12
- import { MatCalendar } from '@angular/material/datepicker';
13
- import { Subject } from 'rxjs';
14
- import { takeUntil } from 'rxjs/operators';
15
- import { MatIconModule } from '@angular/material/icon';
16
- import { MatButton } from '@angular/material/button';
17
- import { NgFor } from '@angular/common';
18
- import { MatDateRangePicker } from '@angular/material/datepicker';
19
-
20
-
21
- let nextId = 0; // used to give unique ids to inputs used in html
22
-
23
- @Component({
24
- templateUrl: './calendar-header.component.html',
25
- styleUrls: ['./calendar-header.component.css'],
26
- standalone: true,
27
- imports: [
28
- NgFor,
29
- MatIconModule,
30
- MatButton
31
- ],
32
- // changeDetection: ChangeDetectionStrategy.OnPush,
33
- })
34
- export class CalendarHeaderComponent<D> implements OnDestroy {
35
- uuid: number = nextId++;
36
-
37
- private readonly destroy$ = new Subject<void>();
38
-
39
- constructor(
40
- private calendar: MatCalendar<D>, // calendar instance of picker
41
- private dateAdapter: DateAdapter<D>, // native or moment date adapter
42
- private picker: MatDateRangePicker<D>,
43
- @Inject(MAT_DATE_FORMATS) private dateFormats: MatDateFormats, // for formatting
44
- cdr: ChangeDetectorRef
45
- ) {
46
- // make sure your header stays in sync with the calendar:
47
- calendar.stateChanges
48
- .pipe(takeUntil(this.destroy$)) // unsubscribe when destroyed
49
- .subscribe(() => cdr.markForCheck());
50
-
51
- }
52
-
53
- selectedPreset = "Custom"
54
- presets = [
55
- "This Quarter",
56
- "Last Quarter",
57
- "Last 6 Months",
58
- "This Year",
59
- "Last Year",
60
- "Custom"
61
- ]
62
- // active date label rendered between the arrow buttons
63
-
64
- ngOnInit() {
65
- const currentRange: any = this.calendar.selected;
66
-
67
- currentRange?.start.setHours(0, 0, 0, 0);
68
- currentRange?.end.setHours(0, 0, 0, 0);
69
-
70
- // To pre-select a preset when the calendar opens.
71
- // Match the already selected date range with the date-ranges of all presets.
72
- // If already selected date range matches with a preset, pre-select it.
73
-
74
- for (let i = 0; i < this.presets.length; i++) {
75
- const tempRange = this.findDate(this.presets[i]);
76
- if (tempRange.newStart.getTime() == currentRange.start.getTime() && tempRange.newEnd.getTime() == currentRange.end.getTime()) {
77
- this.selectedPreset = this.presets[i];
78
- break;
79
- }
80
- }
81
- }
82
-
83
- get periodLabel(): string {
84
- // use date adapter to format the label, e.g. "SEP 2020"
85
- return this.dateAdapter
86
- .format(this.calendar.activeDate, this.dateFormats.display.monthYearLabel)
87
- .toLocaleUpperCase();
88
- }
89
-
90
- previousClicked(mode: 'month' | 'year'): void {
91
- this.changeDate(mode, -1);
92
- }
93
-
94
- nextClicked(mode: 'month' | 'year'): void {
95
- this.changeDate(mode, 1);
96
- }
97
-
98
- changeView() {
99
- this.calendar.currentView =
100
- this.calendar.currentView == "month"
101
- ? "year"
102
- : this.calendar.currentView == "year"
103
- ? "multi-year"
104
- : "month";
105
- }
106
-
107
- today = new Date();
108
-
109
- presetChanged(evt: any) {
110
- const newRange: any = this.findDate(evt.target.value);
111
- this.calendar.activeDate = newRange.newStart;
112
- this.picker.select(newRange.newStart);
113
- this.picker.select(newRange.newEnd);
114
- }
115
-
116
- findDate(selected: string) {
117
- const date = this.today.getDate();
118
- const month = this.today.getMonth();
119
- const year = this.today.getFullYear();
120
- let newRange: any;
121
- this.selectedPreset = selected;
122
- switch (selected) {
123
- case "This Quarter": {
124
- const thisQuarterMonth = Math.floor(month / 3) * 3;
125
- const start = this.dateAdapter.createDate(year, thisQuarterMonth, 1);
126
- const end = this.dateAdapter.createDate(year, thisQuarterMonth + 3, 1);
127
- newRange = {
128
- newStart: start,
129
- newEnd: end,
130
- }
131
- break;
132
- }
133
- case "Last Quarter": {
134
- const lastQuarterMonth = (Math.floor(month / 3) * 3) - 3;
135
- const start = this.dateAdapter.createDate(year, lastQuarterMonth, 1);
136
- const end = this.dateAdapter.createDate(year, lastQuarterMonth + 3, 1);
137
- newRange = {
138
- newStart: start,
139
- newEnd: end,
140
- }
141
- break;
142
- }
143
- case "Last 6 Months": {
144
- const end = this.dateAdapter.createDate(year, month, date);
145
- const start = this.dateAdapter.addCalendarMonths(end, -6);
146
- newRange = {
147
- newStart: start,
148
- newEnd: end,
149
- }
150
- break;
151
- }
152
- case "This Year": {
153
- const start = this.dateAdapter.createDate(year, 0, 1);
154
- const end = this.dateAdapter.createDate(year, 11, 31);
155
- newRange = {
156
- newStart: start,
157
- newEnd: end,
158
- }
159
- break;
160
- }
161
- case "Last Year": {
162
- const start = this.dateAdapter.createDate(year - 1, 0, 1);
163
- const end = this.dateAdapter.createDate(year - 1, 11, 31);
164
- newRange = {
165
- newStart: start,
166
- newEnd: end,
167
- }
168
- break;
169
- }
170
- default: {
171
- newRange = {
172
- newStart: new Date(),
173
- newEnd: new Date(),
174
- }
175
- }
176
- }
177
- return newRange;
178
- }
179
-
180
- private changeDate(mode: 'month' | 'year', amount: -1 | 1): void {
181
- // increment or decrement month or year
182
- this.calendar.activeDate =
183
- mode === 'month'
184
- ? this.dateAdapter.addCalendarMonths(this.calendar.activeDate, amount)
185
- : this.dateAdapter.addCalendarYears(this.calendar.activeDate, amount);
186
- }
187
-
188
- ngOnDestroy(): void {
189
- this.destroy$.next(); // will trigger unsubscription in takeUntil
190
- }
191
- }
File without changes
@@ -1 +0,0 @@
1
- <p>card-body works!</p>
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { CardBodyComponent } from './card-body.component';
4
-
5
- describe('CardBodyComponent', () => {
6
- let component: CardBodyComponent;
7
- let fixture: ComponentFixture<CardBodyComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [CardBodyComponent]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(CardBodyComponent);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,12 +0,0 @@
1
- import { Component } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'lib-card-body',
5
- standalone: true,
6
- imports: [],
7
- templateUrl: './card-body.component.html',
8
- styleUrl: './card-body.component.css'
9
- })
10
- export class CardBodyComponent {
11
-
12
- }
@@ -1,4 +0,0 @@
1
- .sa-card-footer-actions {
2
- display: flex;
3
- justify-content: end;
4
- }
@@ -1,3 +0,0 @@
1
- <div class="sa-card-footer-actions">
2
- <ng-content></ng-content>
3
- </div>
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { CardFooterActionsComponent } from './card-footer-actions.component';
4
-
5
- describe('CardFooterActionsComponent', () => {
6
- let component: CardFooterActionsComponent;
7
- let fixture: ComponentFixture<CardFooterActionsComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [CardFooterActionsComponent]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(CardFooterActionsComponent);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,12 +0,0 @@
1
- import { Component } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'sa-card-footer-actions',
5
- standalone: true,
6
- imports: [],
7
- templateUrl: './card-footer-actions.component.html',
8
- styleUrl: './card-footer-actions.component.css'
9
- })
10
- export class CardFooterActionsComponent {
11
-
12
- }
File without changes
@@ -1 +0,0 @@
1
- <ng-content></ng-content>
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { CardIconComponent } from './card-icon.component';
4
-
5
- describe('CardIconComponent', () => {
6
- let component: CardIconComponent;
7
- let fixture: ComponentFixture<CardIconComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [CardIconComponent]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(CardIconComponent);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,12 +0,0 @@
1
- import { Component } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'sa-card-icon',
5
- standalone: true,
6
- imports: [],
7
- templateUrl: './card-icon.component.html',
8
- styleUrl: './card-icon.component.css'
9
- })
10
- export class CardIconComponent {
11
-
12
- }