{"version":3,"file":"realsoft-reusable-components-core.mjs","sources":["../../../src/reusable-components/core/src/id-generator/id-generator.ts","../../../src/reusable-components/core/src/internal-form-field/internal-form-field.ts","../../../src/reusable-components/core/src/error-state-matcher/error-state-matcher.ts","../../../src/reusable-components/core/realsoft-reusable-components-core.ts"],"sourcesContent":["import { APP_ID, inject, Injectable } from \"@angular/core\";\r\n//Use APP_ID \"Built-in Angular token\" to represent the Application ID. Since each application gets a unique APP_ID when running in the same environment.\r\n\r\n//The service is provided at root level which means it's available throughout the application\r\n@Injectable({\r\n    providedIn: 'root'\r\n})\r\nexport class UniqueIdGeneratorService {\r\n    //Retrieve the APP_ID using the inject function. This value is used to differentiate IDs across different Angular Applications running on the same page. \r\n    private readonly _appId = inject(APP_ID);\r\n\r\n    //counters map to keep track of the count of IDs generated for each prefix. It ensures that IDs generated with the same prefix remain unique.\r\n    private readonly _counters = new Map<string, number>();\r\n\r\n    //Generate a Unique ID with a prefix\r\n    generateID(prefix: string): string {\r\n        //If the appId is not the default `ng` then adjust the prefix to include the appId otherwise just return the prefix. \r\n        const effectivePrefix = this._appId !== 'ng' ? `${prefix}${this._appId}` : prefix;\r\n\r\n        //Get the current count for this prefix or initialize it.\r\n        const currentCount = this._counters.get(effectivePrefix) || 0;\r\n\r\n        //Increment the counter and update the map to ensure future calls generate unique IDs\r\n        this._counters.set(effectivePrefix, currentCount + 1);\r\n\r\n        //Return the generated Unique ID by concatenating the counter's value to the prefix\r\n        return `${effectivePrefix}${currentCount}`;\r\n    }\r\n}","import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from \"@angular/core\";\r\n\r\n@Component({\r\n    selector: '[realsoft-internal-form-field]',\r\n    template: `<ng-content></ng-content>`,\r\n    styleUrl: './internal-form-field.scss',\r\n    encapsulation: ViewEncapsulation.None,\r\n    changeDetection: ChangeDetectionStrategy.OnPush,\r\n    standalone: true,\r\n    host: {\r\n        'class': 'realsoft-internal-form-field', \r\n        '[class.realsoft-form-field-align-end]' : 'labelPosition === \"before\"'\r\n    }\r\n})\r\nexport class RealsoftInternalFormField {\r\n    @Input({required: true}) labelPosition : 'before' | 'after' = 'after';\r\n}","\r\n\r\n\r\nimport { Injectable } from \"@angular/core\";\r\nimport { AbstractControl, FormGroupDirective, NgControl, NgForm } from \"@angular/forms\";\r\nimport { Subject } from 'rxjs';\r\n\r\nexport interface RealsoftErrorState extends ErrorStateMatcher {}\r\n\r\n\r\n//This code defines an Angular service called ErrorState which is used to determine whether a form control should be displayed in an error state. It's designed to work with Angular's form validation system, particularly is scenarios where you want to customize error display logic.\r\n@Injectable({providedIn: 'root'})\r\nexport class ErrorStateMatcher {\r\n\r\n  //The method determines if a form control should be marked as having an error, it takes two parameters: control is the form control being checked, and the parent form which is optional\r\n  //The method returns a boolan where if true => This means that the control is an an error state, and if false the control is valid\r\n  isErrorState(control: AbstractControl | null, form: FormGroupDirective | NgForm | null): boolean {\r\n    //contol && control.invalid => Ensures the control exists and has validation errors where invalid is true\r\n    //(control.touched || (form && form.submitted)) => Ensures the user has interacted with the control or the form has been submitted\r\n    //The !! ensures the result is a boolean value\r\n    return !!(control && control.invalid && (control.touched || (form && form.submitted)));\r\n  }\r\n}\r\n\r\nexport class ErrorState {\r\n    errorState = false;\r\n    matcher: ErrorStateMatcher;\r\n\r\n    constructor(\r\n        private _defaultMatcher: ErrorStateMatcher | null,\r\n        public ngControl: NgControl | null,\r\n        private _parentFormGroup: FormGroupDirective | null,\r\n        private _parentForm: NgForm | null,\r\n        private _stateChanges: Subject<void>,\r\n    ) {}\r\n\r\n    updateErrorState() {\r\n        const oldState = this.errorState;\r\n        const parent = this._parentFormGroup || this._parentForm;\r\n        const matcher = this._defaultMatcher || this.matcher;\r\n        const control = this.ngControl?.control as AbstractControl ?? null;\r\n        const newState = matcher?.isErrorState(control, parent) ?? false;\r\n\r\n        if(newState !== oldState) {\r\n            this.errorState = newState;\r\n            this._stateChanges.next();\r\n        }\r\n    }\r\n\r\n}\r\n\r\n","/**\n * Generated bundle index.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