@esfaenza/extensions 20.3.7 → 20.3.8

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/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { PipeTransform, ModuleWithProviders, Injector, EventEmitter, Type, InjectionToken } from '@angular/core';
2
+ import { PipeTransform, ViewContainerRef, Injector, ComponentRef, NgZone, OnDestroy, ApplicationRef, ModuleWithProviders, EventEmitter, Type, InjectionToken } from '@angular/core';
3
3
  import * as i2 from '@esfaenza/localizations';
4
4
  import { BaseLocalization, LocalizationService } from '@esfaenza/localizations';
5
- import { ReplaySubject, Subject, Observable } from 'rxjs';
5
+ import { ReplaySubject, Observable, Subscription, Subject } from 'rxjs';
6
6
  import { Location } from '@angular/common';
7
7
  import { Router, ActivatedRoute } from '@angular/router';
8
8
  import { NgForm } from '@angular/forms';
@@ -140,10 +140,414 @@ declare class LocDatePipe implements PipeTransform {
140
140
  static ɵpipe: i0.ɵɵPipeDeclaration<LocDatePipe, "loc_date", false>;
141
141
  }
142
142
 
143
+ type ComponentType<T> = new (...args: unknown[]) => T;
144
+ /**
145
+ * A `ComponentPortal` is a portal that instantiates some Component upon attachment.
146
+ */
147
+ declare class ComponentPortal<T> {
148
+ private _attachedHost?;
149
+ /** The type of the component that will be instantiated for attachment. */
150
+ component: ComponentType<T>;
151
+ /**
152
+ * [Optional] Where the attached component should live in Angular's *logical* component tree.
153
+ * This is different from where the component *renders*, which is determined by the PortalHost.
154
+ * The origin necessary when the host is outside of the Angular application context.
155
+ */
156
+ viewContainerRef: ViewContainerRef;
157
+ /** Injector used for the instantiation of the component. */
158
+ injector: Injector;
159
+ constructor(component: ComponentType<T>, injector: Injector);
160
+ /** Attach this portal to a host. */
161
+ attach(host: BasePortalHost, newestOnTop: boolean): ComponentRef<unknown>;
162
+ /** Detach this portal from its host */
163
+ detach(): void;
164
+ /** Whether this portal is attached to a host. */
165
+ get isAttached(): boolean;
166
+ /**
167
+ * Sets the PortalHost reference without performing `attach()`. This is used directly by
168
+ * the PortalHost when it is performing an `attach()` or `detach()`.
169
+ */
170
+ setAttachedHost(host?: BasePortalHost): void;
171
+ }
172
+ /**
173
+ * Partial implementation of PortalHost that only deals with attaching a
174
+ * ComponentPortal
175
+ */
176
+ declare abstract class BasePortalHost {
177
+ /** The portal currently attached to the host. */
178
+ private _attachedPortal?;
179
+ /** A function that will permanently dispose this host. */
180
+ private _disposeFn?;
181
+ attach(portal: ComponentPortal<unknown>, newestOnTop: boolean): ComponentRef<unknown>;
182
+ abstract attachComponentPortal<T>(portal: ComponentPortal<T>, newestOnTop: boolean): ComponentRef<T>;
183
+ detach(): void;
184
+ setDisposeFn(fn: () => void): void;
185
+ }
186
+
187
+ /**
188
+ * Reference to an overlay that has been created with the Overlay service.
189
+ * Used to manipulate or dispose of said overlay.
190
+ */
191
+ declare class OverlayRef {
192
+ private _portalHost;
193
+ constructor(_portalHost: BasePortalHost);
194
+ attach(portal: ComponentPortal<unknown>, newestOnTop?: boolean): ComponentRef<unknown>;
195
+ /**
196
+ * Detaches an overlay from a portal.
197
+ * @returns Resolves when the overlay has been detached.
198
+ */
199
+ detach(): void;
200
+ }
201
+
202
+ /**
203
+ * Reference to a toast opened via the Toastr service.
204
+ */
205
+ declare class ToastRef<T> {
206
+ private _overlayRef;
207
+ /** The instance of component opened into the toast. */
208
+ componentInstance: T;
209
+ /** Count of duplicates of this toast */
210
+ private duplicatesCount;
211
+ /** Subject for notifying the user that the toast has finished closing. */
212
+ private _afterClosed;
213
+ /** triggered when toast is activated */
214
+ private _activate;
215
+ /** notifies the toast that it should close before the timeout */
216
+ private _manualClose;
217
+ /** notifies the toast that it should reset the timeouts */
218
+ private _resetTimeout;
219
+ /** notifies the toast that it should count a duplicate toast */
220
+ private _countDuplicate;
221
+ constructor(_overlayRef: OverlayRef);
222
+ manualClose(): void;
223
+ manualClosed(): Observable<unknown>;
224
+ timeoutReset(): Observable<unknown>;
225
+ countDuplicate(): Observable<number>;
226
+ /**
227
+ * Close the toast.
228
+ */
229
+ close(): void;
230
+ /** Gets an observable that is notified when the toast is finished closing. */
231
+ afterClosed(): Observable<void>;
232
+ isInactive(): boolean;
233
+ activate(): void;
234
+ /** Gets an observable that is notified when the toast has started opening. */
235
+ afterActivate(): Observable<void>;
236
+ /** Reset the toast timouts and count duplicates */
237
+ onDuplicate(resetTimeout: boolean, countDuplicate: boolean): void;
238
+ }
239
+
240
+ type ProgressAnimationType = 'increasing' | 'decreasing';
241
+ type DisableTimoutType = boolean | 'timeOut' | 'extendedTimeOut';
242
+ /**
243
+ * Configuration for an individual toast.
244
+ */
245
+ interface IndividualConfig<ConfigPayload = unknown> {
246
+ /**
247
+ * disable both timeOut and extendedTimeOut
248
+ * default: false
249
+ */
250
+ disableTimeOut: DisableTimoutType;
251
+ /**
252
+ * toast time to live in milliseconds
253
+ * default: 5000
254
+ */
255
+ timeOut: number;
256
+ /**
257
+ * toast show close button
258
+ * default: false
259
+ */
260
+ closeButton: boolean;
261
+ /**
262
+ * time to close after a user hovers over toast
263
+ * default: 1000
264
+ */
265
+ extendedTimeOut: number;
266
+ /**
267
+ * show toast progress bar
268
+ * default: false
269
+ */
270
+ progressBar: boolean;
271
+ /**
272
+ * changes toast progress bar animation
273
+ * default: decreasing
274
+ */
275
+ progressAnimation: ProgressAnimationType;
276
+ /**
277
+ * render html in toast message (possibly unsafe)
278
+ * default: false
279
+ */
280
+ enableHtml: boolean;
281
+ /**
282
+ * css class on toast component
283
+ * default: ngx-toastr
284
+ */
285
+ toastClass: string;
286
+ /**
287
+ * css class on toast container
288
+ * default: toast-top-right
289
+ */
290
+ positionClass: string;
291
+ /**
292
+ * css class on toast title
293
+ * default: toast-title
294
+ */
295
+ titleClass: string;
296
+ /**
297
+ * css class on toast message
298
+ * default: toast-message
299
+ */
300
+ messageClass: string;
301
+ /**
302
+ * animation easing on toast
303
+ * default: ease-in
304
+ */
305
+ easing: string;
306
+ /**
307
+ * animation ease time on toast
308
+ * default: 300
309
+ */
310
+ easeTime: string | number;
311
+ /**
312
+ * clicking on toast dismisses it
313
+ * default: true
314
+ */
315
+ tapToDismiss: boolean;
316
+ /**
317
+ * Angular toast component to be shown
318
+ * default: Toast
319
+ */
320
+ toastComponent?: ComponentType<unknown>;
321
+ /**
322
+ * Helps show toast from a websocket or from event outside Angular
323
+ * default: false
324
+ */
325
+ onActivateTick: boolean;
326
+ /**
327
+ * New toast placement
328
+ * default: true
329
+ */
330
+ newestOnTop: boolean;
331
+ /**
332
+ * Payload to pass to the toast component
333
+ */
334
+ payload?: ConfigPayload;
335
+ }
336
+ interface ToastrIconClasses {
337
+ error: string;
338
+ info: string;
339
+ success: string;
340
+ warning: string;
341
+ [key: string]: string;
342
+ }
343
+ /**
344
+ * Global Toast configuration
345
+ * Includes all IndividualConfig
346
+ */
347
+ interface GlobalConfig<C = unknown> extends IndividualConfig<C> {
348
+ /**
349
+ * max toasts opened. Toasts will be queued
350
+ * Zero is unlimited
351
+ * default: 0
352
+ */
353
+ maxOpened: number;
354
+ /**
355
+ * dismiss current toast when max is reached
356
+ * default: false
357
+ */
358
+ autoDismiss: boolean;
359
+ iconClasses: Partial<ToastrIconClasses>;
360
+ /**
361
+ * block duplicate messages
362
+ * default: false
363
+ */
364
+ preventDuplicates: boolean;
365
+ /**
366
+ * display the number of duplicate messages
367
+ * default: false
368
+ */
369
+ countDuplicates: boolean;
370
+ /**
371
+ * Reset toast timeout when there's a duplicate (preventDuplicates needs to be set to true)
372
+ * default: false
373
+ */
374
+ resetTimeoutOnDuplicate: boolean;
375
+ /**
376
+ * consider the title of a toast when checking if duplicate
377
+ * default: false
378
+ */
379
+ includeTitleDuplicates: boolean;
380
+ }
381
+ /**
382
+ * Everything a toast needs to launch
383
+ */
384
+ declare class ToastPackage<ConfigPayload = unknown> {
385
+ toastId: number;
386
+ config: IndividualConfig<ConfigPayload>;
387
+ message: string | null | undefined;
388
+ title: string | undefined;
389
+ toastType: string;
390
+ toastRef: ToastRef<unknown>;
391
+ private _onTap;
392
+ private _onAction;
393
+ constructor(toastId: number, config: IndividualConfig<ConfigPayload>, message: string | null | undefined, title: string | undefined, toastType: string, toastRef: ToastRef<unknown>);
394
+ /** Fired on click */
395
+ triggerTap(): void;
396
+ onTap(): Observable<void>;
397
+ /** available for use in custom toast */
398
+ triggerAction(action?: unknown): void;
399
+ onAction(): Observable<unknown>;
400
+ }
401
+
402
+ declare class ToastContainerDirective {
403
+ private el;
404
+ getContainerElement(): HTMLElement;
405
+ static ɵfac: i0.ɵɵFactoryDeclaration<ToastContainerDirective, never>;
406
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ToastContainerDirective, "[toastContainer]", ["toastContainer"], {}, {}, never, never, true, never>;
407
+ }
408
+
409
+ interface ActiveToast<C> {
410
+ /** Your Toast ID. Use this to close it individually */
411
+ toastId: number;
412
+ /** the title of your toast. Stored to prevent duplicates */
413
+ title: string;
414
+ /** the message of your toast. Stored to prevent duplicates */
415
+ message: string;
416
+ /** a reference to the component see portal.ts */
417
+ portal: ComponentRef<C>;
418
+ /** a reference to your toast */
419
+ toastRef: ToastRef<C>;
420
+ /** triggered when toast is active */
421
+ onShown: Observable<void>;
422
+ /** triggered when toast is destroyed */
423
+ onHidden: Observable<void>;
424
+ /** triggered on toast click */
425
+ onTap: Observable<void>;
426
+ /** available for your use in custom toast */
427
+ onAction: Observable<unknown>;
428
+ }
429
+ declare class ToastrService {
430
+ private overlay;
431
+ private _injector;
432
+ private sanitizer;
433
+ private ngZone;
434
+ toastrConfig: GlobalConfig;
435
+ currentlyActive: number;
436
+ toasts: ActiveToast<unknown>[];
437
+ overlayContainer?: ToastContainerDirective;
438
+ previousToastMessage: string | undefined;
439
+ private index;
440
+ constructor();
441
+ /** show toast */
442
+ show<C extends ToastBase = ToastBase, ConfigPayload = unknown>(message?: string, title?: string, override?: Partial<IndividualConfig<ConfigPayload>>, type?: string): ActiveToast<C> | null;
443
+ /** show successful toast */
444
+ success<ConfigPayload = unknown>(message?: string, title?: string, override?: Partial<IndividualConfig<ConfigPayload>>): ActiveToast<unknown>;
445
+ /** show error toast */
446
+ error<ConfigPayload = unknown>(message?: string, title?: string, override?: Partial<IndividualConfig<ConfigPayload>>): ActiveToast<unknown>;
447
+ /** show info toast */
448
+ info<ConfigPayload = unknown>(message?: string, title?: string, override?: Partial<IndividualConfig<ConfigPayload>>): ActiveToast<unknown>;
449
+ /** show warning toast */
450
+ warning<ConfigPayload = unknown>(message?: string, title?: string, override?: Partial<IndividualConfig<ConfigPayload>>): ActiveToast<unknown>;
451
+ /**
452
+ * Remove all or a single toast by id
453
+ */
454
+ clear(toastId?: number): void;
455
+ /**
456
+ * Remove and destroy a single toast by id
457
+ */
458
+ remove(toastId: number): boolean;
459
+ /**
460
+ * Determines if toast message is already shown
461
+ */
462
+ findDuplicate(title: string, message: string, resetOnDuplicate: boolean, countDuplicates: boolean): ActiveToast<unknown>;
463
+ /** create a clone of global config and apply individual settings */
464
+ private applyConfig;
465
+ /**
466
+ * Find toast object by id
467
+ */
468
+ private _findToast;
469
+ /**
470
+ * Determines the need to run inside angular's zone then builds the toast
471
+ */
472
+ private _preBuildNotification;
473
+ /**
474
+ * Creates and attaches toast data to component
475
+ * returns the active toast, or in case preventDuplicates is enabled the original/non-duplicate active toast.
476
+ */
477
+ private _buildNotification;
478
+ static ɵfac: i0.ɵɵFactoryDeclaration<ToastrService, never>;
479
+ static ɵprov: i0.ɵɵInjectableDeclaration<ToastrService>;
480
+ }
481
+
482
+ declare class TimeoutsService {
483
+ protected ngZone?: NgZone;
484
+ setInterval(func: () => unknown, timeout: number): number;
485
+ setTimeout(func: () => unknown, timeout?: number): number;
486
+ protected runInsideAngular(func: () => unknown): void;
487
+ static ɵfac: i0.ɵɵFactoryDeclaration<TimeoutsService, never>;
488
+ static ɵprov: i0.ɵɵInjectableDeclaration<TimeoutsService>;
489
+ }
490
+
491
+ declare class ToastBase<ConfigPayload = unknown> implements OnDestroy {
492
+ toastPackage: ToastPackage<any>;
493
+ protected toastrService: ToastrService;
494
+ protected appRef: ApplicationRef;
495
+ protected timeoutsService: TimeoutsService;
496
+ duplicatesCount: number;
497
+ protected hideTime: number;
498
+ /** width of progress bar */
499
+ readonly width: i0.WritableSignal<number>;
500
+ readonly state: i0.WritableSignal<"inactive" | "active" | "removed">;
501
+ /** hides component when waiting to be displayed */
502
+ readonly displayStyle: i0.Signal<string>;
503
+ readonly message: i0.Signal<string>;
504
+ readonly title: i0.Signal<string>;
505
+ readonly options: i0.WritableSignal<IndividualConfig<ConfigPayload>>;
506
+ readonly originalTimeout: i0.Signal<number>;
507
+ readonly toastClasses: i0.Signal<string>;
508
+ protected timeout: number | undefined;
509
+ protected intervalId: number | undefined;
510
+ protected afterActivateSubscription: Subscription;
511
+ protected manualClosedSubscription: Subscription;
512
+ protected timeoutResetSubscription: Subscription;
513
+ protected countDuplicateSubscription: Subscription;
514
+ constructor();
515
+ ngOnDestroy(): void;
516
+ /**
517
+ * activates toast and sets timeout
518
+ */
519
+ activateToast(): void;
520
+ /**
521
+ * updates progress bar width
522
+ */
523
+ updateProgress(): void;
524
+ resetTimeout(): void;
525
+ /**
526
+ * tells toastrService to remove this toast after animation time
527
+ */
528
+ remove(): void;
529
+ tapToast(): void;
530
+ stickAround(): void;
531
+ delayedHideToast(): void;
532
+ static ɵfac: i0.ɵɵFactoryDeclaration<ToastBase<any>, never>;
533
+ static ɵcmp: i0.ɵɵComponentDeclaration<ToastBase<any>, "[toast-component]", never, {}, {}, never, never, true, never>;
534
+ }
535
+
536
+ declare class Toast<ConfigPayload = unknown> extends ToastBase<ConfigPayload> {
537
+ readonly params: {
538
+ easeTime: string | number;
539
+ easing: string;
540
+ };
541
+ private elementRef;
542
+ remove(): void;
543
+ static ɵfac: i0.ɵɵFactoryDeclaration<Toast<any>, never>;
544
+ static ɵcmp: i0.ɵɵComponentDeclaration<Toast<any>, "[toast-component]", never, {}, {}, never, never, true, never>;
545
+ }
546
+
143
547
  declare class ExtensionsModule {
144
548
  static forRoot(config?: ExtensionsModuleConfig): ModuleWithProviders<ExtensionsModule>;
145
549
  static ɵfac: i0.ɵɵFactoryDeclaration<ExtensionsModule, never>;
146
- static ɵmod: i0.ɵɵNgModuleDeclaration<ExtensionsModule, [typeof LocDatePipe], [typeof i2.LocalizationModule], [typeof LocDatePipe]>;
550
+ static ɵmod: i0.ɵɵNgModuleDeclaration<ExtensionsModule, [typeof LocDatePipe], [typeof i2.LocalizationModule, typeof Toast], [typeof LocDatePipe]>;
147
551
  static ɵinj: i0.ɵɵInjectorDeclaration<ExtensionsModule>;
148
552
  }
149
553
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esfaenza/extensions",
3
- "version": "20.3.7",
3
+ "version": "20.3.8",
4
4
  "dependencies": {
5
5
  "tslib": "^2.0.0"
6
6
  },
@@ -9,7 +9,6 @@
9
9
  "@angular/core": "^20.3.24",
10
10
  "@esfaenza/localizations": "^20.3.6",
11
11
  "sweetalert2": "11.26.25",
12
- "ngx-toastr": "20.0.5",
13
12
  "dayjs": "1.11.21",
14
13
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
15
14
  },