@carefirst/library 1.3.8 → 1.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. package/.eslintrc.json +31 -0
  2. package/ng-package.json +8 -0
  3. package/package.json +11 -14
  4. package/public/styles/colors.scss +2 -2
  5. package/public/styles/font.scss +2 -2
  6. package/src/lib/components/alert/alert.component.html +0 -0
  7. package/src/lib/components/alert/alert.component.scss +63 -0
  8. package/src/lib/components/alert/alert.component.spec.ts +23 -0
  9. package/src/lib/components/alert/alert.component.ts +73 -0
  10. package/src/lib/components/badge/badge.component.html +5 -0
  11. package/src/lib/components/badge/badge.component.scss +96 -0
  12. package/src/lib/components/badge/badge.component.spec.ts +23 -0
  13. package/src/lib/components/badge/badge.component.ts +61 -0
  14. package/src/lib/components/button/button.component.html +20 -0
  15. package/src/lib/components/button/button.component.scss +153 -0
  16. package/src/lib/components/button/button.component.spec.ts +21 -0
  17. package/src/lib/components/button/button.component.ts +94 -0
  18. package/src/lib/components/calendar/calendar.component.html +9 -0
  19. package/src/lib/components/calendar/calendar.component.scss +34 -0
  20. package/src/lib/components/calendar/calendar.component.spec.ts +23 -0
  21. package/src/lib/components/calendar/calendar.component.ts +53 -0
  22. package/src/lib/components/chat-bubble/chat-bubble.component.html +9 -0
  23. package/src/lib/components/chat-bubble/chat-bubble.component.scss +31 -0
  24. package/src/lib/components/chat-bubble/chat-bubble.component.spec.ts +23 -0
  25. package/src/lib/components/chat-bubble/chat-bubble.component.ts +43 -0
  26. package/src/lib/components/form-input/form-input.component.html +37 -0
  27. package/src/lib/components/form-input/form-input.component.scss +23 -0
  28. package/src/lib/components/form-input/form-input.component.spec.ts +23 -0
  29. package/src/lib/components/form-input/form-input.component.ts +95 -0
  30. package/src/lib/components/form-input-select/form-input-select.component.html +27 -0
  31. package/src/lib/components/form-input-select/form-input-select.component.scss +40 -0
  32. package/src/lib/components/form-input-select/form-input-select.component.spec.ts +23 -0
  33. package/src/lib/components/form-input-select/form-input-select.component.ts +61 -0
  34. package/src/lib/components/form-input-text-area/form-input-text-area.component.html +29 -0
  35. package/src/lib/components/form-input-text-area/form-input-text-area.component.scss +19 -0
  36. package/src/lib/components/form-input-text-area/form-input-text-area.component.spec.ts +23 -0
  37. package/src/lib/components/form-input-text-area/form-input-text-area.component.ts +76 -0
  38. package/src/lib/components/form-validation/form-validation.component.html +8 -0
  39. package/src/lib/components/form-validation/form-validation.component.scss +8 -0
  40. package/src/lib/components/form-validation/form-validation.component.spec.ts +23 -0
  41. package/src/lib/components/form-validation/form-validation.component.ts +34 -0
  42. package/src/lib/components/icon/icon.component.html +529 -0
  43. package/src/lib/components/icon/icon.component.scss +61 -0
  44. package/src/lib/components/icon/icon.component.spec.ts +21 -0
  45. package/src/lib/components/icon/icon.component.ts +40 -0
  46. package/src/lib/components/logo/logo.component.html +10 -0
  47. package/src/lib/components/logo/logo.component.scss +5 -0
  48. package/src/lib/components/logo/logo.component.spec.ts +23 -0
  49. package/src/lib/components/logo/logo.component.ts +21 -0
  50. package/src/lib/components/notification/notification.component.html +39 -0
  51. package/src/lib/components/notification/notification.component.scss +20 -0
  52. package/src/lib/components/notification/notification.component.spec.ts +21 -0
  53. package/src/lib/components/notification/notification.component.ts +23 -0
  54. package/src/lib/components/page/page.component.html +5 -0
  55. package/src/lib/components/page/page.component.scss +35 -0
  56. package/src/lib/components/page/page.component.spec.ts +21 -0
  57. package/src/lib/components/page/page.component.ts +42 -0
  58. package/src/lib/components/spacer/spacer.component.html +4 -0
  59. package/src/lib/components/spacer/spacer.component.scss +27 -0
  60. package/src/lib/components/spacer/spacer.component.spec.ts +21 -0
  61. package/src/lib/components/spacer/spacer.component.ts +43 -0
  62. package/src/lib/components/spinner/spinner.component.html +1 -0
  63. package/src/lib/components/spinner/spinner.component.scss +14 -0
  64. package/src/lib/components/spinner/spinner.component.spec.ts +23 -0
  65. package/src/lib/components/spinner/spinner.component.ts +33 -0
  66. package/src/lib/directives/button-loader.directive.spec.ts +8 -0
  67. package/src/lib/directives/button-loader.directive.ts +77 -0
  68. package/src/lib/interfaces/alert.interface.ts +20 -0
  69. package/src/lib/interfaces/icon.interface.ts +62 -0
  70. package/src/lib/interfaces/input.interface.ts +8 -0
  71. package/src/lib/interfaces/notification.interface.ts +15 -0
  72. package/src/lib/interfaces/spacer.interface.ts +6 -0
  73. package/src/lib/library.module.ts +66 -0
  74. package/src/lib/utils/attribute.util.ts +66 -0
  75. package/src/lib/utils/form-validators-utility.ts +186 -0
  76. package/{public-api.d.ts → src/public-api.ts} +21 -0
  77. package/tsconfig.lib.json +12 -0
  78. package/tsconfig.lib.prod.json +10 -0
  79. package/tsconfig.spec.json +14 -0
  80. package/esm2022/carefirst-library.mjs +0 -2
  81. package/esm2022/lib/components/alert/alert.component.mjs +0 -56
  82. package/esm2022/lib/components/button/button.component.mjs +0 -87
  83. package/esm2022/lib/components/calendar/calendar.component.mjs +0 -39
  84. package/esm2022/lib/components/form-input/form-input.component.mjs +0 -87
  85. package/esm2022/lib/components/form-input-select/form-input-select.component.mjs +0 -46
  86. package/esm2022/lib/components/form-input-text-area/form-input-text-area.component.mjs +0 -61
  87. package/esm2022/lib/components/form-validation/form-validation.component.mjs +0 -20
  88. package/esm2022/lib/components/icon/icon.component.mjs +0 -29
  89. package/esm2022/lib/components/logo/logo.component.mjs +0 -18
  90. package/esm2022/lib/components/notification/notification.component.mjs +0 -22
  91. package/esm2022/lib/components/page/page.component.mjs +0 -31
  92. package/esm2022/lib/components/spacer/spacer.component.mjs +0 -30
  93. package/esm2022/lib/directives/button-loader.directive.mjs +0 -41
  94. package/esm2022/lib/interfaces/alert.interface.mjs +0 -2
  95. package/esm2022/lib/interfaces/icon.interface.mjs +0 -52
  96. package/esm2022/lib/interfaces/input.interface.mjs +0 -2
  97. package/esm2022/lib/interfaces/notification.interface.mjs +0 -2
  98. package/esm2022/lib/interfaces/spacer.interface.mjs +0 -2
  99. package/esm2022/lib/library.module.mjs +0 -85
  100. package/esm2022/lib/utils/attribute.util.mjs +0 -34
  101. package/esm2022/lib/utils/form-validators-utility.mjs +0 -113
  102. package/esm2022/public-api.mjs +0 -21
  103. package/fesm2022/carefirst-library.mjs +0 -799
  104. package/fesm2022/carefirst-library.mjs.map +0 -1
  105. package/index.d.ts +0 -2
  106. package/lib/components/alert/alert.component.d.ts +0 -14
  107. package/lib/components/button/button.component.d.ts +0 -30
  108. package/lib/components/calendar/calendar.component.d.ts +0 -15
  109. package/lib/components/form-input/form-input.component.d.ts +0 -37
  110. package/lib/components/form-input-select/form-input-select.component.d.ts +0 -21
  111. package/lib/components/form-input-text-area/form-input-text-area.component.d.ts +0 -27
  112. package/lib/components/form-validation/form-validation.component.d.ts +0 -9
  113. package/lib/components/icon/icon.component.d.ts +0 -13
  114. package/lib/components/logo/logo.component.d.ts +0 -7
  115. package/lib/components/notification/notification.component.d.ts +0 -9
  116. package/lib/components/page/page.component.d.ts +0 -13
  117. package/lib/components/spacer/spacer.component.d.ts +0 -14
  118. package/lib/directives/button-loader.directive.d.ts +0 -12
  119. package/lib/interfaces/alert.interface.d.ts +0 -11
  120. package/lib/interfaces/icon.interface.d.ts +0 -4
  121. package/lib/interfaces/input.interface.d.ts +0 -4
  122. package/lib/interfaces/notification.interface.d.ts +0 -11
  123. package/lib/interfaces/spacer.interface.d.ts +0 -3
  124. package/lib/library.module.d.ts +0 -22
  125. package/lib/utils/attribute.util.d.ts +0 -4
  126. package/lib/utils/form-validators-utility.d.ts +0 -8
@@ -0,0 +1,27 @@
1
+ //--- Screen size breakpoint
2
+ $desktop-breakpoint: 768px; //--- Same as ionic md breakpoint
3
+
4
+ /*===============================================
5
+ ============== Mobile Only Spacer ===============
6
+ ===============================================*/
7
+ @media not (min-width: $desktop-breakpoint) {
8
+ div.mobile-only {
9
+ display: block;
10
+ }
11
+ div.desktop-only {
12
+ display: none;
13
+ }
14
+ }
15
+
16
+ /*===============================================
17
+ ============== Desktop Only Spacer ==============
18
+ ===============================================*/
19
+
20
+ @media (min-width: $desktop-breakpoint) {
21
+ div.mobile-only {
22
+ display: none;
23
+ }
24
+ div.desktop-only {
25
+ display: block;
26
+ }
27
+ }
@@ -0,0 +1,21 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { SpacerComponent } from './spacer.component';
4
+
5
+ describe('SpacerComponent', () => {
6
+ let component: SpacerComponent;
7
+ let fixture: ComponentFixture<SpacerComponent>;
8
+
9
+ beforeEach(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [SpacerComponent]
12
+ });
13
+ fixture = TestBed.createComponent(SpacerComponent);
14
+ component = fixture.componentInstance;
15
+ fixture.detectChanges();
16
+ });
17
+
18
+ it('should create', () => {
19
+ expect(component).toBeTruthy();
20
+ });
21
+ });
@@ -0,0 +1,43 @@
1
+ /**
2
+ * CareFirst Library - Spacer
3
+ *
4
+ * @file spacer.component
5
+ * @description Contains all the logic for generating a CareFirst Div Spacer
6
+ * @author Jacques Coetzee
7
+ * @since 2023 - 11 - 07
8
+ * @usage <cf-spacer %default=""% %mobile=""% %desktop=""%>CONTENT</cf-spacer>
9
+ */
10
+
11
+ import { Component, Input, type OnChanges, type SimpleChanges } from '@angular/core';
12
+ import { validateNumberValue } from '../../utils/attribute.util';
13
+ import type { SpacerNumberT, SpacerStringT } from '../../interfaces/spacer.interface';
14
+
15
+ @Component({
16
+ selector: 'cf-spacer',
17
+ templateUrl: './spacer.component.html',
18
+ styleUrls: ['./spacer.component.scss'],
19
+ })
20
+ export class SpacerComponent implements OnChanges {
21
+ @Input() default?: SpacerStringT | SpacerNumberT | undefined;
22
+ @Input() mobile?: SpacerStringT | SpacerNumberT | undefined;
23
+ @Input() desktop?: SpacerStringT | SpacerNumberT | undefined;
24
+
25
+ //--- Local variables
26
+ inputDefault: number | undefined = undefined;
27
+ inputMobile: number | undefined = undefined;
28
+ inputDesktop: number | undefined = undefined;
29
+
30
+ /**----------------------------------------------------------------
31
+ * @name ngOnChanges
32
+ * @description Update various values on input changes
33
+ * @returns {void}
34
+ */
35
+ ngOnChanges(changes: SimpleChanges): void {
36
+ //--- Default
37
+ this.inputDefault = validateNumberValue(changes, 'default', this.inputDefault);
38
+ //--- Mobile
39
+ this.inputMobile = validateNumberValue(changes, 'mobile', this.inputMobile);
40
+ //--- Desktop
41
+ this.inputDesktop = validateNumberValue(changes, 'desktop', this.inputDesktop);
42
+ }
43
+ }
@@ -0,0 +1 @@
1
+ <div id="spinner" [style]="'font-size: ' + inputSize + 'px'"></div>
@@ -0,0 +1,14 @@
1
+ #spinner {
2
+ width: 1em;
3
+ height: 1em;
4
+ border: 0.15em solid var(--cf-app-system-color-outline);
5
+ border-radius: 50%;
6
+ border-top-color: var(--cf-app-color-accent);
7
+ animation: spin 1s linear infinite;
8
+
9
+ @keyframes spin {
10
+ to {
11
+ transform: rotate(360deg);
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { SpinnerComponent } from './spinner.component';
4
+
5
+ describe('SpinnerComponent', () => {
6
+ let component: SpinnerComponent;
7
+ let fixture: ComponentFixture<SpinnerComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [SpinnerComponent]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(SpinnerComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,33 @@
1
+ /**
2
+ * CareFirst Library - Spinner
3
+ *
4
+ * @file spinner.component
5
+ * @description Contains all the logic for generating a CareFirst Spinner
6
+ * @author Jacques Coetzee
7
+ * @since 2024 - 02 - 23
8
+ */
9
+
10
+ import { Component, Input, type OnChanges, type SimpleChanges } from '@angular/core';
11
+ import { validateNumberValue } from '../../utils/attribute.util';
12
+
13
+ @Component({
14
+ selector: 'cf-spinner',
15
+ templateUrl: './spinner.component.html',
16
+ styleUrl: './spinner.component.scss',
17
+ })
18
+ export class SpinnerComponent implements OnChanges {
19
+ @Input() size: number | string = 20;
20
+
21
+ //--- Local variables
22
+ inputSize: number = 20;
23
+
24
+ /**----------------------------------------------------------------
25
+ * @name ngOnChanges
26
+ * @description Update various values on input changes
27
+ * @returns {void}
28
+ */
29
+ ngOnChanges(changes: SimpleChanges): void {
30
+ //--- Size
31
+ this.inputSize = validateNumberValue(changes, 'size', this.inputSize) || this.inputSize;
32
+ }
33
+ }
@@ -0,0 +1,8 @@
1
+ import { ButtonLoaderDirective } from './button-loader.directive';
2
+
3
+ describe('ButtonLoaderDirective', () => {
4
+ it('should create an instance', () => {
5
+ const directive = new ButtonLoaderDirective();
6
+ expect(directive).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Button Loader Directive
3
+ *
4
+ * @file button-loader.directive
5
+ * @description HTML directive used to disable a button while loading
6
+ * @author Jacques Coetzee
7
+ * @since 2022 - 07 - 22
8
+ * @usage Add to any HTML tag: *cfButtonLoader="true"
9
+ */
10
+
11
+ import { Component, Directive, Input, Renderer2, TemplateRef, ViewContainerRef, ElementRef } from '@angular/core';
12
+
13
+ @Directive({
14
+ selector: '[cfButtonLoader]',
15
+ })
16
+ export class ButtonLoaderDirective {
17
+ /**----------------------------------------------------------------
18
+ * @name Constructor
19
+ */
20
+ constructor(
21
+ private templateRef: TemplateRef<HTMLElement>,
22
+ private renderer: Renderer2,
23
+ private viewContainer: ViewContainerRef,
24
+ private elementRef: ElementRef<HTMLElement>
25
+ ) {}
26
+
27
+ /**----------------------------------------------------------------
28
+ * @name cfButtonLoader
29
+ * @description Displays a loading overlay and disables a button
30
+ * @param {boolean} loading
31
+ */
32
+ @Input() set cfButtonLoader(loading: boolean) {
33
+ //--- Clear HTML container
34
+ this.viewContainer.clear();
35
+ //--- Reattach element as child
36
+ this.viewContainer.createEmbeddedView(this.templateRef);
37
+ if (loading) {
38
+ //--- Add loading spinner
39
+ this.viewContainer.createComponent(SpinnerComponent);
40
+ //--- Set parent container position to relative
41
+ this.renderer.setStyle(this.elementRef.nativeElement.parentElement, 'position', 'relative');
42
+ }
43
+ }
44
+ }
45
+
46
+ /**==================================================================
47
+ * @class SpinnerComponent
48
+ * @description The spinner component used to render an ion-spinner on the button
49
+ * @author Jacques Coetzee
50
+ * @since 2022 - 07 - 22
51
+ * ===== */
52
+
53
+ @Component({
54
+ template: '<div class="loading-spinner"></div>',
55
+ styles: [
56
+ `
57
+ @keyframes spinner {
58
+ to {
59
+ transform: rotate(360deg);
60
+ }
61
+ }
62
+
63
+ .loading-spinner {
64
+ position: absolute;
65
+ top: calc(50% - 1em);
66
+ left: calc(50% - 1em);
67
+ width: 2em;
68
+ height: 2em;
69
+ border-radius: 50%;
70
+ border: 3px solid var(--cf-app-system-color-outline);
71
+ border-top-color: var(--cf-app-color-accent);
72
+ animation: spinner 1s linear infinite;
73
+ }
74
+ `,
75
+ ],
76
+ })
77
+ class SpinnerComponent {}
@@ -0,0 +1,20 @@
1
+ /**==============================================
2
+ * @interface AlertDataI
3
+ * @description Defines the properties needed to show a care first alert
4
+ */
5
+ export interface AlertDataI {
6
+ heading: string;
7
+ message: string;
8
+ alertIdentifier: string | number;
9
+ buttonTrue?: string; //--- Default to 'OK'
10
+ buttonFalse?: string; //--- Default to 'Cancel'
11
+ }
12
+
13
+ /**==============================================
14
+ * @interface AlertEventI
15
+ * @description Defines the structure of the returned event from the alert when a button is clicked
16
+ */
17
+ export interface AlertEventI {
18
+ identifier: string | number;
19
+ status: boolean;
20
+ }
@@ -0,0 +1,62 @@
1
+ /**==============================================
2
+ * @interface IconsT
3
+ * @description Short description
4
+ */
5
+ export const iconsC = [
6
+ 'home',
7
+ 'cog',
8
+ 'profile',
9
+ 'scan',
10
+ 'person',
11
+ 'appointment',
12
+ 'clock',
13
+ 'calendar',
14
+ 'email',
15
+ 'phone',
16
+ 'sign-out',
17
+ 'sign-in',
18
+ 'close',
19
+ 'check-mark',
20
+ 'rating-star-blank',
21
+ 'rating-star-filled',
22
+ 'back-arrow',
23
+ 'lock',
24
+ 'show-password',
25
+ 'hide-password',
26
+ 'circle-check',
27
+ 'circle-alert',
28
+ 'direction-switch',
29
+ 'chat-bubbles',
30
+ 'phone-down',
31
+ 'mic',
32
+ 'no-mic',
33
+ 'button-forward-arrow',
34
+ 'button-check-box',
35
+ 'social-media-whatsapp',
36
+ 'social-media-facebook',
37
+ 'social-media-linkedin',
38
+ 'social-media-instagram',
39
+ 'social-media-google-mail',
40
+ 'instant-video-service',
41
+ 'instant-telephonic-service',
42
+ 'scheduled-video-service',
43
+ 'scheduled-telephonic-service',
44
+ 'vital-scan-service',
45
+ 'open-back-arrow',
46
+ 'open-forward-arrow',
47
+ 'open-up-arrow',
48
+ 'open-down-arrow',
49
+ 'single-document',
50
+ 'lightning',
51
+ 'microsoft-365',
52
+ 'user-dependent',
53
+ 'plus',
54
+ ] as const;
55
+ export type IconsT = (typeof iconsC)[number];
56
+
57
+ /**==============================================
58
+ * @interface IconColorT
59
+ * @description All available colors in CSS classes
60
+ */
61
+ export const iconColorC = ['primary', 'secondary', 'success', 'warning', 'error', 'white', 'accent'] as const;
62
+ export type IconColorT = (typeof iconColorC)[number];
@@ -0,0 +1,8 @@
1
+ /**==============================================
2
+ * @interface FormInputSelectOptionsI
3
+ * @description Structure for the input select options
4
+ */
5
+ export interface FormInputSelectOptionsI<T> {
6
+ displayName: string | number;
7
+ value: T;
8
+ }
@@ -0,0 +1,15 @@
1
+ /**==============================================
2
+ * @interface NotificationPayloadI
3
+ * @description Setup needed to show a notification
4
+ */
5
+ export interface NotificationPayloadI {
6
+ heading: string;
7
+ status: 'success' | 'warning' | 'error'; //--- success=green, warning=yellow, error=red
8
+ message?: string;
9
+ canClose?: true; //--- Adds a clickable x to hide notification
10
+ button?: {
11
+ buttonText: string;
12
+ buttonClickIdentifier: string | number; //--- user set identifier used to know witch notifications button has been clicked
13
+ buttonHeading?: string;
14
+ };
15
+ }
@@ -0,0 +1,6 @@
1
+ /**==============================================
2
+ * @description Available Spacer Values
3
+ */
4
+ export const spacerNumberArray = [4, 8, 12, 16, 24, 32, 38, 48, 72] as const;
5
+ export type SpacerNumberT = (typeof spacerNumberArray)[number];
6
+ export type SpacerStringT = `${SpacerNumberT}`;
@@ -0,0 +1,66 @@
1
+ import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ //--- Modules
4
+ import { IonicModule } from '@ionic/angular';
5
+ import { ReactiveFormsModule } from '@angular/forms';
6
+ //--- Directives
7
+ import { ButtonLoaderDirective } from './directives/button-loader.directive';
8
+ //--- Components
9
+ import { PageComponent } from './components/page/page.component';
10
+ import { ButtonComponent } from './components/button/button.component';
11
+ import { SpacerComponent } from './components/spacer/spacer.component';
12
+ import { IconComponent } from './components/icon/icon.component';
13
+ import { NotificationComponent } from './components/notification/notification.component';
14
+ import { AlertComponent } from './components/alert/alert.component';
15
+ import { LogoComponent } from './components/logo/logo.component';
16
+ import { CalendarComponent } from './components/calendar/calendar.component';
17
+ import { FormValidationComponent } from './components/form-validation/form-validation.component';
18
+ import { FormInputComponent } from './components/form-input/form-input.component';
19
+ import { FormInputSelectComponent } from './components/form-input-select/form-input-select.component';
20
+ import { FormInputTextAreaComponent } from './components/form-input-text-area/form-input-text-area.component';
21
+ import { ChatBubbleComponent } from './components/chat-bubble/chat-bubble.component';
22
+ import { BadgeComponent } from './components/badge/badge.component';
23
+ import { SpinnerComponent } from './components/spinner/spinner.component';
24
+
25
+ @NgModule({
26
+ declarations: [
27
+ PageComponent,
28
+ ButtonComponent,
29
+ SpacerComponent,
30
+ IconComponent,
31
+ ButtonLoaderDirective,
32
+ NotificationComponent,
33
+ AlertComponent,
34
+ LogoComponent,
35
+ CalendarComponent,
36
+ FormValidationComponent,
37
+ FormInputComponent,
38
+ FormInputSelectComponent,
39
+ FormInputTextAreaComponent,
40
+ ChatBubbleComponent,
41
+ BadgeComponent,
42
+ SpinnerComponent,
43
+ ],
44
+
45
+ imports: [IonicModule, CommonModule, ReactiveFormsModule],
46
+ exports: [
47
+ PageComponent,
48
+ ButtonComponent,
49
+ SpacerComponent,
50
+ IconComponent,
51
+ ButtonLoaderDirective,
52
+ NotificationComponent,
53
+ AlertComponent,
54
+ LogoComponent,
55
+ CalendarComponent,
56
+ FormValidationComponent,
57
+ FormInputComponent,
58
+ FormInputSelectComponent,
59
+ FormInputTextAreaComponent,
60
+ ChatBubbleComponent,
61
+ BadgeComponent,
62
+ SpinnerComponent,
63
+ ],
64
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
65
+ })
66
+ export class CareFirstLibraryModule {}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Attribute Utility
3
+ *
4
+ * @file attribute.util
5
+ * @description Contains various utility functions pertaining to attribute handling
6
+ * @author Jacques Coetzee
7
+ * @since 2023 - 11 - 08
8
+ */
9
+
10
+ import type { SimpleChanges } from '@angular/core';
11
+
12
+ /**----------------------------------------------------------------
13
+ * @name checkTruthAttribute
14
+ * @description Check whether an attribute is either just available or specifically set to boolean value
15
+ * @param {SimpleChanges} changes
16
+ * @param {string} attribute
17
+ * @param {boolean} curVal
18
+ * @returns {boolean}
19
+ */
20
+ export function checkTruthAttribute(changes: SimpleChanges, attribute: string, curVal: boolean): boolean {
21
+ if (!(attribute in changes)) return curVal;
22
+ const valueChanged = changes[attribute]?.currentValue;
23
+ if (typeof valueChanged === 'boolean') {
24
+ return valueChanged;
25
+ } else if (typeof valueChanged === 'string' && ['true', ''].includes(valueChanged)) {
26
+ return true;
27
+ }
28
+ return false;
29
+ }
30
+
31
+ /**----------------------------------------------------------------
32
+ * @name validateStringValue
33
+ * @description Validate whether an attribute is set and contains a specific string option
34
+ * @param {SimpleChanges} changes
35
+ * @param {string} attribute
36
+ * @param {string[]} options
37
+ * @param {T | undefined} curVal
38
+ * @returns {string | undefined} Returns correct string value or undefined if either not available or not in list
39
+ */
40
+ export function validateStringValue<T>(changes: SimpleChanges, attribute: string, options: T[], curVal: T | undefined): T | undefined {
41
+ if (!(attribute in changes)) return curVal;
42
+ const valueChanged = changes[attribute]?.currentValue;
43
+ if (valueChanged && options.includes(valueChanged)) {
44
+ return valueChanged as T;
45
+ }
46
+ return undefined;
47
+ }
48
+
49
+ /**----------------------------------------------------------------
50
+ * @name validateNumberValue
51
+ * @description Validate whether an attribute is set and contains a specific number value
52
+ * @param {SimpleChanges} changes
53
+ * @param {string} attribute
54
+ * @param {number | undefined} curVal
55
+ * @returns {number | undefined} Returns correct number value or undefined if either not available or not a number
56
+ */
57
+ export function validateNumberValue(changes: SimpleChanges, attribute: string, curVal: number | undefined): number | undefined {
58
+ if (!(attribute in changes)) return curVal;
59
+ const valueChanged = changes[attribute]?.currentValue;
60
+ if (typeof valueChanged === 'number' && valueChanged >= 0) {
61
+ return valueChanged;
62
+ } else if (typeof valueChanged === 'string' && +valueChanged >= 0) {
63
+ return +valueChanged;
64
+ }
65
+ return undefined;
66
+ }