@stemy/ngx-utils 19.9.37 → 19.9.39

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.
@@ -762,7 +762,7 @@ class StateService {
762
762
  return this.router.config;
763
763
  }
764
764
  get $observable() {
765
- return this.$snapshot.pipe(skipWhile(snapshot => snapshot === emptySnapshot), debounceTime(25));
765
+ return this.$snapshot.pipe(skipWhile(snapshot => snapshot === emptySnapshot), debounceTime(10));
766
766
  }
767
767
  constructor(injector, zone, universal, router = null, contexts = null) {
768
768
  this.injector = injector;
@@ -2761,62 +2761,6 @@ function diffEntities(current, incoming) {
2761
2761
  };
2762
2762
  }
2763
2763
 
2764
- class TimerUtils {
2765
- static createTimeout(func, time) {
2766
- // @dynamic
2767
- const run = (timer) => {
2768
- timer.clear();
2769
- // If the time is zero or less, we run the function immediately because setTimeout puts it into the next "frame"
2770
- if (timer.time <= 0) {
2771
- timer.func();
2772
- return;
2773
- }
2774
- timer.id = setTimeout(() => {
2775
- timer.id = null;
2776
- timer.func();
2777
- }, timer.time);
2778
- };
2779
- // @dynamic
2780
- const clear = (timer) => {
2781
- if (!timer.id)
2782
- return;
2783
- clearTimeout(timer.id);
2784
- timer.id = null;
2785
- };
2786
- return TimerUtils.createTimer(run, clear, func, time);
2787
- }
2788
- static createInterval(func, time) {
2789
- // @dynamic
2790
- const run = (timer) => {
2791
- timer.clear();
2792
- timer.id = setInterval(timer.func, Math.max(timer.time, 5));
2793
- };
2794
- // @dynamic
2795
- const clear = (timer) => {
2796
- if (!timer.id)
2797
- return;
2798
- clearInterval(timer.id);
2799
- timer.id = null;
2800
- };
2801
- return TimerUtils.createTimer(run, clear, func, time);
2802
- }
2803
- static createTimer(run, clear, func, time) {
2804
- const timer = {};
2805
- const setParams = (func, time) => {
2806
- timer.func = !ObjectUtils.isFunction(func) ? (() => { }) : func;
2807
- timer.time = !ObjectUtils.isNumber(time) ? 100 : time;
2808
- };
2809
- timer.run = () => run(timer);
2810
- timer.clear = () => clear(timer);
2811
- timer.set = (func, time) => {
2812
- setParams(func, time);
2813
- timer.run();
2814
- };
2815
- setParams(func, time);
2816
- return timer;
2817
- }
2818
- }
2819
-
2820
2764
  class ObservableUtils {
2821
2765
  static toSearch(search) {
2822
2766
  return mergeMap(
@@ -2839,20 +2783,24 @@ class ObservableUtils {
2839
2783
  static subscribe(...subscribers) {
2840
2784
  const subscriptions = [];
2841
2785
  subscribers.forEach(info => {
2786
+ const timeout = info.timeout ?? 15;
2842
2787
  let alreadyCalled = false;
2843
- const timer = TimerUtils.createTimeout();
2844
2788
  info.subjects.forEach(subject => {
2845
- const ss = subject.subscribe((value) => {
2789
+ const ss = subject
2790
+ .pipe(map(v => {
2846
2791
  alreadyCalled = true;
2847
- timer.set(() => {
2848
- info.cb(subject, value);
2849
- }, info.timeout ?? 0);
2792
+ return v;
2793
+ }), debounceTime(timeout))
2794
+ .subscribe((value) => {
2795
+ info.cb(subject, value);
2850
2796
  });
2851
2797
  subscriptions.push(ss);
2852
2798
  });
2853
- if (alreadyCalled)
2854
- return;
2855
- info.cb();
2799
+ setTimeout(() => {
2800
+ if (alreadyCalled)
2801
+ return;
2802
+ info.cb();
2803
+ }, timeout);
2856
2804
  });
2857
2805
  return ObservableUtils.multiSubscription(...subscriptions);
2858
2806
  }
@@ -3171,6 +3119,62 @@ class SocketClient {
3171
3119
  }
3172
3120
  }
3173
3121
 
3122
+ class TimerUtils {
3123
+ static createTimeout(func, time) {
3124
+ // @dynamic
3125
+ const run = (timer) => {
3126
+ timer.clear();
3127
+ // If the time is zero or less, we run the function immediately because setTimeout puts it into the next "frame"
3128
+ if (timer.time <= 0) {
3129
+ timer.func();
3130
+ return;
3131
+ }
3132
+ timer.id = setTimeout(() => {
3133
+ timer.id = null;
3134
+ timer.func();
3135
+ }, timer.time);
3136
+ };
3137
+ // @dynamic
3138
+ const clear = (timer) => {
3139
+ if (!timer.id)
3140
+ return;
3141
+ clearTimeout(timer.id);
3142
+ timer.id = null;
3143
+ };
3144
+ return TimerUtils.createTimer(run, clear, func, time);
3145
+ }
3146
+ static createInterval(func, time) {
3147
+ // @dynamic
3148
+ const run = (timer) => {
3149
+ timer.clear();
3150
+ timer.id = setInterval(timer.func, Math.max(timer.time, 5));
3151
+ };
3152
+ // @dynamic
3153
+ const clear = (timer) => {
3154
+ if (!timer.id)
3155
+ return;
3156
+ clearInterval(timer.id);
3157
+ timer.id = null;
3158
+ };
3159
+ return TimerUtils.createTimer(run, clear, func, time);
3160
+ }
3161
+ static createTimer(run, clear, func, time) {
3162
+ const timer = {};
3163
+ const setParams = (func, time) => {
3164
+ timer.func = !ObjectUtils.isFunction(func) ? (() => { }) : func;
3165
+ timer.time = !ObjectUtils.isNumber(time) ? 100 : time;
3166
+ };
3167
+ timer.run = () => run(timer);
3168
+ timer.clear = () => clear(timer);
3169
+ timer.set = (func, time) => {
3170
+ setParams(func, time);
3171
+ timer.run();
3172
+ };
3173
+ setParams(func, time);
3174
+ return timer;
3175
+ }
3176
+ }
3177
+
3174
3178
  class UniqueUtils {
3175
3179
  static uuid() {
3176
3180
  if (typeof window !== "undefined" && typeof window.crypto !== "undefined" && typeof window.crypto.getRandomValues !== "undefined") {
@@ -9630,7 +9634,7 @@ class UploadComponent {
9630
9634
  });
9631
9635
  return process;
9632
9636
  });
9633
- const baseUrl = this.baseUrl || this.api.url("assets");
9637
+ const baseUrl = this.uploadUrl || this.baseUrl || this.api.url("assets");
9634
9638
  const requests = this.processing.map(async (p) => {
9635
9639
  await p.promise;
9636
9640
  if (this.inline) {
@@ -9673,7 +9677,7 @@ class UploadComponent {
9673
9677
  return this.acceptTypes.includes(type);
9674
9678
  }
9675
9679
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: UploadComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: API_SERVICE }, { token: TOASTER_SERVICE }], target: i0.ɵɵFactoryTarget.Component }); }
9676
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.22", type: UploadComponent, isStandalone: false, selector: "upload", inputs: { value: "value", disabled: "disabled", inline: "inline", accept: "accept", baseUrl: "baseUrl", message: "message", multiple: "multiple", buttonText: "buttonText", makeUpload: "makeUpload", preProcess: "preProcess" }, outputs: { onUploaded: "onUploaded", onRemove: "onRemove" }, providers: [
9680
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.22", type: UploadComponent, isStandalone: false, selector: "upload", inputs: { value: "value", disabled: "disabled", inline: "inline", accept: "accept", baseUrl: "baseUrl", uploadUrl: "uploadUrl", message: "message", multiple: "multiple", buttonText: "buttonText", makeUpload: "makeUpload", preProcess: "preProcess" }, outputs: { onUploaded: "onUploaded", onRemove: "onRemove" }, providers: [
9677
9681
  { provide: NG_VALUE_ACCESSOR, useExisting: UploadComponent, multi: true }
9678
9682
  ], viewQueries: [{ propertyName: "uploadBtn", first: true, predicate: ["uploadBtn"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<ng-template #itemBgTemplate let-bg=\"bg\">\r\n @if (bg) {\r\n <div class=\"upload-item-bg\" [ngStyle]=\"{backgroundImage: `url('${bg}')`}\">\r\n <div>\r\n <img alt=\"item image\" [src]=\"bg | safe: 'url'\" />\r\n </div>\r\n </div>\r\n }\r\n</ng-template>\r\n<ng-template #itemTemplate let-item=\"item\" let-index=\"index\">\r\n <div class=\"upload-item\">\r\n <ng-container [ngTemplateOutlet]=\"itemBgTemplate\"\r\n [ngTemplateOutletContext]=\"{bg: isImage || (item | isType: 'file') ? getUrl(item) : null}\">\r\n </ng-container>\r\n @if (!disabled) {\r\n <close-btn class=\"remove-item-btn\" (click)=\"removeItem(index)\"></close-btn>\r\n }\r\n<!-- <btn size=\"small\" class=\"download-item-btn\" icon=\"download\"></btn>-->\r\n </div>\r\n</ng-template>\r\n\r\n<div class=\"file-upload\" [ngClass]=\"{disabled: disabled}\">\r\n <div class=\"upload-input\" [ngClass]=\"{'drop-allowed': dropAllowed}\">\r\n <input type=\"file\"\r\n #input\r\n [disabled]=\"disabled\"\r\n [multiple]=\"multiple\"\r\n [accept]=\"acceptAttr\"\r\n (dragenter)=\"onDragEnter($event)\"\r\n (dragleave)=\"onDrop()\"\r\n (drop)=\"onDrop()\"\r\n (click)=\"onInputClick($event)\"\r\n (blur)=\"onTouched($event)\"\r\n (change)=\"onInputChange($event)\"/>\r\n @if (message) {\r\n <div class=\"upload-message\"\r\n [ngClass]=\"{'has-value': $any(value)?.length}\"\r\n [innerHTML]=\"message | translate | safe:'html'\">\r\n </div>\r\n }\r\n <div class=\"upload-container\">\r\n\r\n <ng-container [ngTemplateOutlet]=\"itemTemplate\"\r\n [ngTemplateOutletContext]=\"{item: value, index: 0}\"\r\n *ngIf=\"!multiple && value\">\r\n </ng-container>\r\n <ng-container *ngIf=\"multiple\">\r\n <ng-container [ngTemplateOutlet]=\"itemTemplate\"\r\n [ngTemplateOutletContext]=\"{item: item, index: ix}\"\r\n *ngFor=\"let item of $any(value); let ix = index\">\r\n </ng-container>\r\n </ng-container>\r\n\r\n <div class=\"upload-item\" *ngFor=\"let proc of processing\">\r\n <ng-container [ngTemplateOutlet]=\"itemBgTemplate\"\r\n [ngTemplateOutletContext]=\"{bg: proc.preview}\">\r\n </ng-container>\r\n <div class=\"upload-progress\">\r\n <div class=\"upload-progress-num\">{{ proc.progress }}%</div>\r\n <div class=\"upload-progress-bar\" [ngStyle]=\"{width: proc.progress + '%'}\">\r\n\r\n </div>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n @if (!disabled) {\r\n <btn class=\"upload-btn\" #uploadBtn [label]=\"buttonText\" (click)=\"input.click()\"></btn>\r\n }\r\n </div>\r\n</div>\r\n", styles: [".file-upload{--upload-bg-lightness: 85%;--upload-bg-opacity: 1;--upload-padding: 5px;--upload-border-width: 2px;--upload-border-color: rgba(0, 0, 0, .25);--upload-progress-bg: var(--primary-color, var(--mat-sys-primary, black));--upload-progress-text: var(--text-color, var(--mat-sys-on-primary, white));--upload-item-size: 120px;--upload-item-radius: 5px;--message-size: 20px;--message-color: #7e7e7e;--message-drop-color: #474747;--btn-distance: 3px;--btn-top-distance: var(--btn-distance);--btn-left-distance: var(--btn-distance);--btn-right-distance: var(--btn-distance);margin:5px 0}.file-upload *{box-sizing:border-box}.file-upload.disabled{--upload-bg-lightness: 75%}.file-upload input[type=file]{display:block;position:absolute;inset:0;opacity:0}.file-upload input[type=file]::file-selector-button{width:100%;height:100%}.file-upload .upload-input{width:100%;border:var(--upload-border-width) var(--upload-border-color) dashed;border-radius:var(--upload-item-radius);background-color:hsl(0,0%,var(--upload-bg-lightness),var(--upload-bg-opacity));transition:.2s;flex-wrap:wrap;position:relative;padding:var(--upload-padding)}.file-upload .upload-input .upload-message{position:absolute;display:flex;align-items:center;justify-content:center;width:100%;height:100%;top:0;left:0;pointer-events:none;font-size:var(--message-size);color:var(--message-color);transition:.2s}.file-upload .upload-input .upload-message.has-value{display:none}.file-upload .upload-input .upload-container{position:relative;pointer-events:none;min-height:var(--upload-item-size);display:flex;gap:10px;flex-wrap:wrap;margin-bottom:10px}.file-upload .upload-input .upload-item{position:relative;pointer-events:auto;width:var(--upload-item-size);height:var(--upload-item-size);border-radius:var(--upload-item-radius);border:2px solid white;overflow:hidden;display:flex;align-items:center;justify-content:center}.file-upload .upload-input .upload-item-bg{background:#fff center center no-repeat;background-size:cover;position:absolute;inset:0}.file-upload .upload-input .upload-item-bg div{width:100%;height:100%;display:flex;justify-content:center;align-items:center;backdrop-filter:blur(15px)}.file-upload .upload-input .upload-item-bg img{max-width:100%;max-height:100%;object-fit:contain;background:#ffffffbf}.file-upload .upload-input .upload-progress{position:relative;width:90%;height:15px;border:1px solid darkgrey;background:#ffffff80}.file-upload .upload-input .upload-progress-bar{position:absolute;height:15px;background:var(--upload-progress-bg);top:0}.file-upload .upload-input .upload-progress-num{position:relative;z-index:1;font-size:12px;line-height:15px;text-align:center;color:var(--upload-progress-text)}.file-upload .upload-input.drop-allowed{--upload-bg-lightness: 95%}.file-upload .upload-input.drop-allowed .upload-message{color:var(--message-drop-color)}.file-upload .upload-btn{position:relative;margin-top:5px;width:fit-content;display:block}.file-upload .remove-item-btn{position:absolute;top:var(--btn-top-distance);right:var(--btn-right-distance)}.file-upload .download-item-btn{position:absolute;top:var(--btn-top-distance);left:var(--btn-left-distance)}\n"], dependencies: [{ kind: "directive", type: i1$3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1$3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: BtnComponent, selector: "btn", inputs: ["label", "tooltip", "icon", "disabled", "path", "type", "size"] }, { kind: "component", type: CloseBtnComponent, selector: "close-btn" }, { kind: "pipe", type: IsTypePipe, name: "isType" }, { kind: "pipe", type: SafeHtmlPipe, name: "safe" }, { kind: "pipe", type: TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None }); }
9679
9683
  }
@@ -9698,6 +9702,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.22", ngImpo
9698
9702
  type: Input
9699
9703
  }], baseUrl: [{
9700
9704
  type: Input
9705
+ }], uploadUrl: [{
9706
+ type: Input
9701
9707
  }], message: [{
9702
9708
  type: Input
9703
9709
  }], multiple: [{