@smartsoft001-mobilems/angular 2.31.0 → 2.33.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.
|
@@ -1995,6 +1995,94 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
|
|
|
1995
1995
|
}]
|
|
1996
1996
|
}], ctorParameters: () => [] });
|
|
1997
1997
|
|
|
1998
|
+
/**
|
|
1999
|
+
* Directive that detects when a click occurs outside of an element.
|
|
2000
|
+
*
|
|
2001
|
+
* When a click is detected outside the element, the `smartClickOutside` output
|
|
2002
|
+
* signal emits a `ClickOutsideEvent` containing the click event and target element.
|
|
2003
|
+
*
|
|
2004
|
+
* The directive respects the `isActive` input signal. When `isActive` is false,
|
|
2005
|
+
* outside clicks are not detected.
|
|
2006
|
+
*
|
|
2007
|
+
* @example
|
|
2008
|
+
* ```typescript
|
|
2009
|
+
* import { Component, signal } from '@angular/core';
|
|
2010
|
+
* import { ClickOutsideDirective } from '@smartsoft001-mobilems/angular';
|
|
2011
|
+
*
|
|
2012
|
+
* @Component({
|
|
2013
|
+
* selector: 'app-example',
|
|
2014
|
+
* imports: [ClickOutsideDirective],
|
|
2015
|
+
* template: `\n * <div
|
|
2016
|
+
* smartClickOutside
|
|
2017
|
+
* [isActive]="isActive()"
|
|
2018
|
+
* (smartClickOutside)="onClickOutside()"
|
|
2019
|
+
* class="smart-border smart-p-4"
|
|
2020
|
+
* >
|
|
2021
|
+
* Content inside
|
|
2022
|
+
* </div>
|
|
2023
|
+
* `,
|
|
2024
|
+
* })
|
|
2025
|
+
* export class ExampleComponent {
|
|
2026
|
+
* isActive = signal(true);
|
|
2027
|
+
*
|
|
2028
|
+
* onClickOutside(): void {
|
|
2029
|
+
* console.log('Clicked outside!');
|
|
2030
|
+
* }
|
|
2031
|
+
* }
|
|
2032
|
+
* ```
|
|
2033
|
+
*/
|
|
2034
|
+
class ClickOutsideDirective {
|
|
2035
|
+
constructor() {
|
|
2036
|
+
this.elementRef = inject(ElementRef);
|
|
2037
|
+
/**
|
|
2038
|
+
* Controls whether the directive responds to click events.
|
|
2039
|
+
* When false, no outside clicks are detected.
|
|
2040
|
+
*/
|
|
2041
|
+
this.isActive = input(true, ...(ngDevMode ? [{ debugName: "isActive" }] : []));
|
|
2042
|
+
/**
|
|
2043
|
+
* Emits when a click outside the element is detected while isActive is true.
|
|
2044
|
+
*/
|
|
2045
|
+
this.smartClickOutside = output();
|
|
2046
|
+
this.clickEffect = effect(() => {
|
|
2047
|
+
// Access the isActive signal to track changes
|
|
2048
|
+
this.isActive();
|
|
2049
|
+
}, ...(ngDevMode ? [{ debugName: "clickEffect" }] : []));
|
|
2050
|
+
}
|
|
2051
|
+
/**
|
|
2052
|
+
* Handles document click events and checks if the click was outside the element.
|
|
2053
|
+
*/
|
|
2054
|
+
onClick(event) {
|
|
2055
|
+
if (!event) {
|
|
2056
|
+
return;
|
|
2057
|
+
}
|
|
2058
|
+
if (!this.isActive()) {
|
|
2059
|
+
return;
|
|
2060
|
+
}
|
|
2061
|
+
const target = event.target;
|
|
2062
|
+
if (!target) {
|
|
2063
|
+
return;
|
|
2064
|
+
}
|
|
2065
|
+
const isClickInsideElement = this.elementRef.nativeElement.contains(target);
|
|
2066
|
+
if (!isClickInsideElement) {
|
|
2067
|
+
this.smartClickOutside.emit({
|
|
2068
|
+
event,
|
|
2069
|
+
target: event.target,
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ClickOutsideDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2074
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.0", type: ClickOutsideDirective, isStandalone: true, selector: "[smartClickOutside]", inputs: { isActive: { classPropertyName: "isActive", publicName: "isActive", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { smartClickOutside: "smartClickOutside" }, host: { listeners: { "document:click": "onClick($event)" } }, ngImport: i0 }); }
|
|
2075
|
+
}
|
|
2076
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ClickOutsideDirective, decorators: [{
|
|
2077
|
+
type: Directive,
|
|
2078
|
+
args: [{
|
|
2079
|
+
selector: '[smartClickOutside]',
|
|
2080
|
+
}]
|
|
2081
|
+
}], propDecorators: { onClick: [{
|
|
2082
|
+
type: HostListener,
|
|
2083
|
+
args: ['document:click', ['$event']]
|
|
2084
|
+
}] } });
|
|
2085
|
+
|
|
1998
2086
|
const DIRECTIVES = [];
|
|
1999
2087
|
|
|
2000
2088
|
function initializeApp(configsFacade) {
|
|
@@ -2087,5 +2175,5 @@ const unauthorizedGuard = () => {
|
|
|
2087
2175
|
* Generated bundle index. Do not edit.
|
|
2088
2176
|
*/
|
|
2089
2177
|
|
|
2090
|
-
export { AppComponent, AuthStorageService, COMPONENTS, ConfigsFacade, ConfigsService, ContrastService, CrudBaseService, DIRECTIVES, DictionaryService, FileUrlService, FiltersBaseComponent, FiltersContext, FooterComponent, GameType, GlobalService, HeaderComponent, HoverDirective, ImageBox, ListMode, MenuComponent, MetaService, ModalContainerComponent, ModalRef, ModalService, PageComponent, QueryFilterService, SERVICES, ScrollTopComponent, ScrollableDirective, SearchService, SeoService, SettingsService, SharedConfig, SharedModule, StyleService, TRANSLATE_DATA_PL, TranslationService, WcagService, authenticationGuard, environment, setTranslationsAndLang, unauthorizedGuard };
|
|
2178
|
+
export { AppComponent, AuthStorageService, COMPONENTS, ClickOutsideDirective, ConfigsFacade, ConfigsService, ContrastService, CrudBaseService, DIRECTIVES, DictionaryService, FileUrlService, FiltersBaseComponent, FiltersContext, FooterComponent, GameType, GlobalService, HeaderComponent, HoverDirective, ImageBox, ListMode, MenuComponent, MetaService, ModalContainerComponent, ModalRef, ModalService, PageComponent, QueryFilterService, SERVICES, ScrollTopComponent, ScrollableDirective, SearchService, SeoService, SettingsService, SharedConfig, SharedModule, StyleService, TRANSLATE_DATA_PL, TranslationService, WcagService, authenticationGuard, environment, setTranslationsAndLang, unauthorizedGuard };
|
|
2091
2179
|
//# sourceMappingURL=smartsoft001-mobilems-angular.mjs.map
|