@stemy/ngx-utils 19.5.22 → 19.5.23

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.
@@ -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, signal, input, output, inject, 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';
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';
@@ -2029,6 +2029,9 @@ class MathUtils {
2029
2029
  }
2030
2030
  }
2031
2031
 
2032
+ function isBrowser() {
2033
+ return typeof window !== "undefined";
2034
+ }
2032
2035
  function switchClass(elem, className, status) {
2033
2036
  if (!elem?.classList)
2034
2037
  return;
@@ -2349,33 +2352,6 @@ class SetUtils {
2349
2352
  * Returns a signal that emits the previous value of the given signal.
2350
2353
  * The first time the signal is emitted, the previous value will be the same as the current value.
2351
2354
  *
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
2355
  * @param s Signal to compute previous value for
2380
2356
  * @returns Signal that emits previous value of `s`
2381
2357
  */
@@ -2389,6 +2365,52 @@ function computedPrevious(s) {
2389
2365
  return result;
2390
2366
  });
2391
2367
  }
2368
+ /**
2369
+ * Returns a signal that emits css styles form an element when it gets resized
2370
+ *
2371
+ * @param elem Element to compute styles for
2372
+ * @returns Signal that emits the calculated styles
2373
+ */
2374
+ function cssStyles(elem) {
2375
+ const styles = signal({
2376
+ length: 0,
2377
+ getPropertyValue: () => null
2378
+ });
2379
+ if (!elem || !isBrowser())
2380
+ return styles;
2381
+ styles.set(getComputedStyle(elem));
2382
+ const observer = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
2383
+ requestAnimationFrame(() => {
2384
+ styles.set(getComputedStyle(elem));
2385
+ });
2386
+ }) : null;
2387
+ const destroyRef = inject(DestroyRef, { optional: true });
2388
+ destroyRef?.onDestroy(() => {
2389
+ observer?.unobserve(elem);
2390
+ });
2391
+ observer?.observe(elem);
2392
+ return styles;
2393
+ }
2394
+ /**
2395
+ * Returns a signal that emits css variables form an element when it gets resized
2396
+ *
2397
+ * @param elem Element to compute variables for
2398
+ * @returns Signal that emits the calculated properties
2399
+ */
2400
+ function cssVariables(elem) {
2401
+ const styleSource = cssStyles(elem);
2402
+ return computed(() => {
2403
+ const styles = styleSource();
2404
+ const res = {};
2405
+ for (let i = 0; i < styles.length; i++) {
2406
+ const propertyName = styles[i];
2407
+ if (propertyName.startsWith("--")) {
2408
+ res[propertyName] = styles.getPropertyValue(propertyName);
2409
+ }
2410
+ }
2411
+ return res;
2412
+ });
2413
+ }
2392
2414
 
2393
2415
  function uuid() {
2394
2416
  if (typeof window !== "undefined" && typeof window.crypto !== "undefined" && typeof window.crypto.getRandomValues !== "undefined") {
@@ -8724,5 +8746,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
8724
8746
  * Generated bundle index. Do not edit.
8725
8747
  */
8726
8748
 
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 };
8749
+ 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
8750
  //# sourceMappingURL=stemy-ngx-utils.mjs.map