@stemy/ngx-utils 19.5.22 → 19.5.24
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.
- package/fesm2022/stemy-ngx-utils.mjs +61 -33
- package/fesm2022/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/ngx-utils.imports.d.ts +1 -1
- package/ngx-utils/utils/loader.utils.d.ts +1 -0
- package/ngx-utils/utils/misc.d.ts +1 -0
- package/ngx-utils/utils/signal-utils.d.ts +14 -27
- package/package.json +1 -1
- package/public_api.d.ts +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'zone.js';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { InjectionToken, PLATFORM_ID, Inject, Injectable, Optional, Injector, untracked, computed, EventEmitter, isDevMode, ErrorHandler, createComponent, NgZone, Pipe,
|
|
4
|
+
import { InjectionToken, PLATFORM_ID, Inject, Injectable, Optional, Injector, untracked, computed, signal, inject, DestroyRef, EventEmitter, isDevMode, ErrorHandler, createComponent, NgZone, Pipe, input, output, ChangeDetectorRef, ElementRef, effect, HostListener, Directive, Input, HostBinding, Output, ChangeDetectionStrategy, ViewEncapsulation, Component, ViewChild, forwardRef, ContentChild, ContentChildren, model, contentChildren, Renderer2, APP_INITIALIZER, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
5
5
|
import * as i2 from '@angular/router';
|
|
6
6
|
import { ActivatedRouteSnapshot, Scroll, NavigationEnd, Router, DefaultUrlSerializer, UrlTree, UrlSegmentGroup, UrlSegment, UrlSerializer, ROUTES } from '@angular/router';
|
|
7
7
|
import { BehaviorSubject, Observable, firstValueFrom, Subject, Subscription, from, TimeoutError, combineLatest, lastValueFrom } from 'rxjs';
|
|
@@ -1931,24 +1931,30 @@ class LoaderUtils {
|
|
|
1931
1931
|
static { this.promises = {}; }
|
|
1932
1932
|
static loadScript(src, async = false, type = "text/javascript", parent) {
|
|
1933
1933
|
return LoaderUtils.loadElement(src, parent, () => {
|
|
1934
|
-
const time = new Date().getTime();
|
|
1935
1934
|
const script = document.createElement("script");
|
|
1936
1935
|
script.type = type;
|
|
1937
|
-
script.src = src
|
|
1936
|
+
script.src = LoaderUtils.updateSrc(src);
|
|
1938
1937
|
script.async = async;
|
|
1939
1938
|
return script;
|
|
1940
1939
|
});
|
|
1941
1940
|
}
|
|
1942
1941
|
static loadStyle(src, parent) {
|
|
1943
1942
|
return LoaderUtils.loadElement(src, parent, () => {
|
|
1944
|
-
const time = new Date().getTime();
|
|
1945
1943
|
const link = document.createElement("link");
|
|
1946
1944
|
link.rel = "stylesheet";
|
|
1947
1945
|
link.type = "text/css";
|
|
1948
|
-
link.href = src
|
|
1946
|
+
link.href = LoaderUtils.updateSrc(src);
|
|
1949
1947
|
return link;
|
|
1950
1948
|
});
|
|
1951
1949
|
}
|
|
1950
|
+
static updateSrc(src) {
|
|
1951
|
+
if (src?.startsWith("data:")) {
|
|
1952
|
+
return src;
|
|
1953
|
+
}
|
|
1954
|
+
const url = new URL(src);
|
|
1955
|
+
url.searchParams.set("time", String(Date.now()));
|
|
1956
|
+
return url.toString();
|
|
1957
|
+
}
|
|
1952
1958
|
static loadElement(src, parent, setup) {
|
|
1953
1959
|
const promises = LoaderUtils.promises;
|
|
1954
1960
|
parent = parent || document;
|
|
@@ -2029,6 +2035,9 @@ class MathUtils {
|
|
|
2029
2035
|
}
|
|
2030
2036
|
}
|
|
2031
2037
|
|
|
2038
|
+
function isBrowser() {
|
|
2039
|
+
return typeof window !== "undefined";
|
|
2040
|
+
}
|
|
2032
2041
|
function switchClass(elem, className, status) {
|
|
2033
2042
|
if (!elem?.classList)
|
|
2034
2043
|
return;
|
|
@@ -2349,33 +2358,6 @@ class SetUtils {
|
|
|
2349
2358
|
* Returns a signal that emits the previous value of the given signal.
|
|
2350
2359
|
* The first time the signal is emitted, the previous value will be the same as the current value.
|
|
2351
2360
|
*
|
|
2352
|
-
* @example
|
|
2353
|
-
* ```ts
|
|
2354
|
-
* const value = signal(0);
|
|
2355
|
-
* const previous = computedPrevious(value);
|
|
2356
|
-
*
|
|
2357
|
-
* effect(() => {
|
|
2358
|
-
* console.log("Current value:", value());
|
|
2359
|
-
* console.log("Previous value:", previous());
|
|
2360
|
-
* });
|
|
2361
|
-
*
|
|
2362
|
-
* Logs:
|
|
2363
|
-
* // Current value: 0
|
|
2364
|
-
* // Previous value: 0
|
|
2365
|
-
*
|
|
2366
|
-
* value.set(1);
|
|
2367
|
-
*
|
|
2368
|
-
* Logs:
|
|
2369
|
-
* // Current value: 1
|
|
2370
|
-
* // Previous value: 0
|
|
2371
|
-
*
|
|
2372
|
-
* value.set(2);
|
|
2373
|
-
*
|
|
2374
|
-
* Logs:
|
|
2375
|
-
* // Current value: 2
|
|
2376
|
-
* // Previous value: 1
|
|
2377
|
-
*```
|
|
2378
|
-
*
|
|
2379
2361
|
* @param s Signal to compute previous value for
|
|
2380
2362
|
* @returns Signal that emits previous value of `s`
|
|
2381
2363
|
*/
|
|
@@ -2389,6 +2371,52 @@ function computedPrevious(s) {
|
|
|
2389
2371
|
return result;
|
|
2390
2372
|
});
|
|
2391
2373
|
}
|
|
2374
|
+
/**
|
|
2375
|
+
* Returns a signal that emits css styles form an element when it gets resized
|
|
2376
|
+
*
|
|
2377
|
+
* @param elem Element to compute styles for
|
|
2378
|
+
* @returns Signal that emits the calculated styles
|
|
2379
|
+
*/
|
|
2380
|
+
function cssStyles(elem) {
|
|
2381
|
+
const styles = signal({
|
|
2382
|
+
length: 0,
|
|
2383
|
+
getPropertyValue: () => null
|
|
2384
|
+
});
|
|
2385
|
+
if (!elem || !isBrowser())
|
|
2386
|
+
return styles;
|
|
2387
|
+
styles.set(getComputedStyle(elem));
|
|
2388
|
+
const observer = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
|
|
2389
|
+
requestAnimationFrame(() => {
|
|
2390
|
+
styles.set(getComputedStyle(elem));
|
|
2391
|
+
});
|
|
2392
|
+
}) : null;
|
|
2393
|
+
const destroyRef = inject(DestroyRef, { optional: true });
|
|
2394
|
+
destroyRef?.onDestroy(() => {
|
|
2395
|
+
observer?.unobserve(elem);
|
|
2396
|
+
});
|
|
2397
|
+
observer?.observe(elem);
|
|
2398
|
+
return styles;
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* Returns a signal that emits css variables form an element when it gets resized
|
|
2402
|
+
*
|
|
2403
|
+
* @param elem Element to compute variables for
|
|
2404
|
+
* @returns Signal that emits the calculated properties
|
|
2405
|
+
*/
|
|
2406
|
+
function cssVariables(elem) {
|
|
2407
|
+
const styleSource = cssStyles(elem);
|
|
2408
|
+
return computed(() => {
|
|
2409
|
+
const styles = styleSource();
|
|
2410
|
+
const res = {};
|
|
2411
|
+
for (let i = 0; i < styles.length; i++) {
|
|
2412
|
+
const propertyName = styles[i];
|
|
2413
|
+
if (propertyName.startsWith("--")) {
|
|
2414
|
+
res[propertyName] = styles.getPropertyValue(propertyName);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
return res;
|
|
2418
|
+
});
|
|
2419
|
+
}
|
|
2392
2420
|
|
|
2393
2421
|
function uuid() {
|
|
2394
2422
|
if (typeof window !== "undefined" && typeof window.crypto !== "undefined" && typeof window.crypto.getRandomValues !== "undefined") {
|
|
@@ -8724,5 +8752,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
8724
8752
|
* Generated bundle index. Do not edit.
|
|
8725
8753
|
*/
|
|
8726
8754
|
|
|
8727
|
-
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AsyncMethodTargetDirective, AuthGuard, BASE_CONFIG, BUTTON_TYPE, BackgroundDirective, BaseDialogService, BaseHttpClient, BaseHttpService, BaseToasterService, BtnComponent, BtnDefaultComponent, CONFIG_SERVICE, CanvasColor, CanvasUtils, ChipsComponent, ChunkPipe, Circle, ComponentLoaderDirective, ComponentLoaderService, ConfigService, DIALOG_SERVICE, DateUtils, DragDropEventPlugin, DropListComponent, DropdownBoxComponent, DropdownContentDirective, DropdownDirective, DropdownToggleDirective, DynamicTableComponent, DynamicTableTemplateDirective, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FakeModuleComponent, FileSystemEntry, FileUtils, FilterPipe, FindPipe, ForbiddenZone, FormatNumberPipe, FormatterService, GenericValue, GetOffsetPipe, GetTypePipe, GetValuePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, HttpPromise, ICON_MAP, ICON_SERVICE, ICON_TYPE, IConfiguration, IconComponent, IconDefaultComponent, IconDirective, IconService, IncludesPipe, Initializer, InteractiveCanvasComponent, InteractiveCircleComponent, InteractiveItemComponent, InteractiveRectComponent, IsTypePipe, JSONfn, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, OPTIONS_TOKEN, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SocketClient, SocketService, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TabsComponent, TabsItemDirective, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UploadComponent, ValuedPromise, ValuesPipe, Vector, WASI_IMPLEMENTATION, WasmService, cachedFactory, cancelablePromise, checkTransitions, computedPrevious, getComponentDef, getCssVariables, hashCode, impatientPromise, parseSelector, provideEntryComponents, provideWithOptions, selectorMatchesList, switchClass };
|
|
8755
|
+
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AsyncMethodTargetDirective, AuthGuard, BASE_CONFIG, BUTTON_TYPE, BackgroundDirective, BaseDialogService, BaseHttpClient, BaseHttpService, BaseToasterService, BtnComponent, BtnDefaultComponent, CONFIG_SERVICE, CanvasColor, CanvasUtils, ChipsComponent, ChunkPipe, Circle, ComponentLoaderDirective, ComponentLoaderService, ConfigService, DIALOG_SERVICE, DateUtils, DragDropEventPlugin, DropListComponent, DropdownBoxComponent, DropdownContentDirective, DropdownDirective, DropdownToggleDirective, DynamicTableComponent, DynamicTableTemplateDirective, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FakeModuleComponent, FileSystemEntry, FileUtils, FilterPipe, FindPipe, ForbiddenZone, FormatNumberPipe, FormatterService, GenericValue, GetOffsetPipe, GetTypePipe, GetValuePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, HttpPromise, ICON_MAP, ICON_SERVICE, ICON_TYPE, IConfiguration, IconComponent, IconDefaultComponent, IconDirective, IconService, IncludesPipe, Initializer, InteractiveCanvasComponent, InteractiveCircleComponent, InteractiveItemComponent, InteractiveRectComponent, IsTypePipe, JSONfn, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, OPTIONS_TOKEN, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SocketClient, SocketService, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TabsComponent, TabsItemDirective, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UploadComponent, ValuedPromise, ValuesPipe, Vector, WASI_IMPLEMENTATION, WasmService, cachedFactory, cancelablePromise, checkTransitions, computedPrevious, cssStyles, cssVariables, getComponentDef, getCssVariables, hashCode, impatientPromise, isBrowser, parseSelector, provideEntryComponents, provideWithOptions, selectorMatchesList, switchClass };
|
|
8728
8756
|
//# sourceMappingURL=stemy-ngx-utils.mjs.map
|