@zeedhi/common 1.80.0 → 1.81.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.
@@ -350,6 +350,7 @@ class Alert extends Component {
350
350
  * Stacks alert content vertically (mobile)
351
351
  */
352
352
  this.vertical = false;
353
+ this.id = 0;
353
354
  this.defaultValues = {
354
355
  name: this.name,
355
356
  dark: this.dark,
@@ -367,6 +368,7 @@ class Alert extends Component {
367
368
  showDismiss: this.showDismiss,
368
369
  dismissColor: this.dismissColor,
369
370
  buttonsSlot: this.buttonsSlot,
371
+ id: this.id,
370
372
  };
371
373
  this.assignAlertProperties(props);
372
374
  this.createAccessors();
@@ -392,6 +394,7 @@ class Alert extends Component {
392
394
  this.showDismiss = this.getInitValue('showDismiss', alert.showDismiss, this.defaultValues.showDismiss);
393
395
  this.dismissColor = this.getInitValue('dismissColor', alert.dismissColor, this.defaultValues.dismissColor);
394
396
  this.buttonsSlot = alert.buttonsSlot || this.defaultValues.buttonsSlot;
397
+ this.id = alert.id || this.defaultValues.id;
395
398
  this.isVisible = false;
396
399
  }
397
400
  /**
@@ -2794,12 +2797,7 @@ class Number$1 extends TextInput {
2794
2797
  */
2795
2798
  constructor(props) {
2796
2799
  super(props);
2797
- this.defaultMask = Config.masks.numberMask || {
2798
- decimalCharacter: ',',
2799
- decimalCharacterAlternative: '.',
2800
- decimalPlaces: 2,
2801
- digitGroupSeparator: '.',
2802
- };
2800
+ this.defaultMask = Config.masks.numberMask || {};
2803
2801
  /*
2804
2802
  * Defines how the field content should be aligned.
2805
2803
  */
@@ -2826,7 +2824,7 @@ class Number$1 extends TextInput {
2826
2824
  this.localValue = value;
2827
2825
  if (this.maskValid && this.localValue !== undefined && this.localValue !== null) {
2828
2826
  this.formattedValue = AutoNumeric.format(this.localValue, this.mask);
2829
- if (this.autoNumericObj) {
2827
+ if (this.autoNumericObj && value !== this.autoNumericObj.rawValue) {
2830
2828
  this.autoNumericObj.setValue(value);
2831
2829
  }
2832
2830
  }
@@ -2896,7 +2894,7 @@ FormatterParserProvider.registerParser('ZdNumber', (value, { mask = Config.masks
2896
2894
  class Currency extends Number$1 {
2897
2895
  constructor(props) {
2898
2896
  super(props);
2899
- this.defaultMask = Config.masks.currencyMask;
2897
+ this.defaultMask = Object.assign(Object.assign({}, Config.masks.numberMask), Config.masks.currencyMask);
2900
2898
  this.formatterFn = FormatterParserProvider.getFormatter('ZdCurrency');
2901
2899
  this.parserFn = FormatterParserProvider.getParser('ZdCurrency');
2902
2900
  this.mask = this.getInitValue('mask', props.mask, this.defaultMask);
@@ -2904,46 +2902,146 @@ class Currency extends Number$1 {
2904
2902
  this.validateMask();
2905
2903
  }
2906
2904
  }
2907
- FormatterParserProvider.registerFormatter('ZdCurrency', (value, { mask = Config.masks.currencyMask, } = {}) => (value === null ? '' : AutoNumeric.format(value, mask)));
2908
- FormatterParserProvider.registerParser('ZdCurrency', (value, { mask = Config.masks.currencyMask, } = {}) => (value === '' ? null : AutoNumeric.unformat(value, mask)));
2905
+ FormatterParserProvider.registerFormatter('ZdCurrency', (value, { mask = Object.assign(Object.assign({}, Config.masks.numberMask), Config.masks.currencyMask), } = {}) => {
2906
+ let maskDef = mask;
2907
+ if (Accessor.isAccessorDefinition(maskDef)) {
2908
+ const [controller, accessor] = Accessor.getAccessor(maskDef);
2909
+ maskDef = Loader.getInstance(controller)[accessor];
2910
+ }
2911
+ const maskValue = typeof (maskDef) === 'function' ? maskDef(AutoNumeric.unformat(value)) : maskDef;
2912
+ return value === null ? '' : AutoNumeric.format(value, maskValue);
2913
+ });
2914
+ FormatterParserProvider.registerParser('ZdCurrency', (value, { mask = Object.assign(Object.assign({}, Config.masks.numberMask), Config.masks.currencyMask), } = {}) => {
2915
+ let maskDef = mask;
2916
+ if (Accessor.isAccessorDefinition(maskDef)) {
2917
+ const [controller, accessor] = Accessor.getAccessor(maskDef);
2918
+ maskDef = Loader.getInstance(controller)[accessor];
2919
+ }
2920
+ const maskValue = typeof (maskDef) === 'function' ? maskDef(AutoNumeric.format(value)) : maskDef;
2921
+ return value === '' ? null : AutoNumeric.unformat(value, maskValue);
2922
+ });
2923
+
2924
+ class AlertQueue {
2925
+ constructor() {
2926
+ this.queue = [];
2927
+ this.visibleInstances = [];
2928
+ }
2929
+ show(alert) {
2930
+ this.queue.push(alert);
2931
+ if ((this.visibleInstances.length === 0 || !this.visibleInstances[0].isVisible)
2932
+ && this.queue.length === 1) {
2933
+ this.display(alert);
2934
+ }
2935
+ return 0;
2936
+ }
2937
+ /**
2938
+ * Displays an alert
2939
+ * @param alert Alert Structure
2940
+ */
2941
+ display(alert) {
2942
+ if (this.visibleInstances.length === 0) {
2943
+ this.visibleInstances.push(new Alert({ name: 'alert-instance', id: 0 }));
2944
+ }
2945
+ this.visibleInstances[0].assignAlertProperties(alert);
2946
+ this.visibleInstances[0].show();
2947
+ return 0;
2948
+ }
2949
+ remove(index) {
2950
+ this.queue.splice(index, 1);
2951
+ if (index === 0 && this.queue[0]) {
2952
+ setTimeout(() => this.display(this.queue[0]), 200);
2953
+ }
2954
+ }
2955
+ }
2956
+
2957
+ class AlertReplace extends AlertQueue {
2958
+ show(alert) {
2959
+ super.show(alert);
2960
+ this.visibleInstances[0].hide();
2961
+ this.remove(0);
2962
+ setTimeout(() => this.display(alert), 200);
2963
+ return 0;
2964
+ }
2965
+ }
2966
+
2967
+ class AlertStack {
2968
+ constructor() {
2969
+ this.queue = [];
2970
+ this.visibleInstances = [];
2971
+ }
2972
+ show(alert) {
2973
+ this.queue.push(alert);
2974
+ return this.display(alert);
2975
+ }
2976
+ display(alert) {
2977
+ const lastAlert = this.visibleInstances.slice(-1)[0];
2978
+ const lastId = (lastAlert === null || lastAlert === void 0 ? void 0 : lastAlert.id) || 0;
2979
+ const id = lastId + 1;
2980
+ const instance = new Alert(Object.assign(Object.assign({}, alert), { id }));
2981
+ this.visibleInstances.push(instance);
2982
+ instance.show();
2983
+ return id;
2984
+ }
2985
+ remove(index) {
2986
+ this.queue.splice(index, 1);
2987
+ this.visibleInstances.splice(index, 1);
2988
+ }
2989
+ }
2909
2990
 
2910
2991
  /**
2911
2992
  * Alert Service Class
2912
2993
  */
2913
2994
  class AlertService {
2995
+ static instantiateManager(multiple) {
2996
+ if (multiple === 'queue') {
2997
+ this.alertsManager = new AlertQueue();
2998
+ return;
2999
+ }
3000
+ if (multiple === 'stack') {
3001
+ this.alertsManager = new AlertStack();
3002
+ return;
3003
+ }
3004
+ this.alertsManager = new AlertReplace();
3005
+ }
2914
3006
  /**
2915
3007
  * Displays an alert.
2916
3008
  * If has an opened alert it will be closed.
2917
3009
  * @param alert Alert structure
2918
3010
  */
2919
3011
  static show(alert) {
2920
- if (this.instance.isVisible) {
2921
- this.hide();
2922
- setTimeout(() => this.display(alert), 200);
2923
- }
2924
- else {
2925
- this.display(alert);
2926
- }
3012
+ return this.alertsManager.show(alert);
2927
3013
  }
2928
3014
  /**
2929
- * Hides current alert
3015
+ * Hides alert by index. Default index is 0
2930
3016
  */
2931
- static hide() {
2932
- this.instance.hide();
3017
+ static hide(index = 0) {
3018
+ this.alertsManager.visibleInstances[index].hide();
3019
+ this.remove(index);
2933
3020
  }
2934
3021
  /**
2935
- * Displays an alert
2936
- * @param alert Alert Structure
3022
+ * Hides alert by alert id (returned by the `show` method)
3023
+ * @param id
2937
3024
  */
2938
- static display(alert) {
2939
- this.instance.assignAlertProperties(alert);
2940
- this.instance.show();
3025
+ static hideById(id) {
3026
+ const index = this.alertsManager.visibleInstances.findIndex((instance) => instance.id === id);
3027
+ this.hide(index);
2941
3028
  }
2942
- }
2943
- /**
2944
- * Current alert
2945
- */
2946
- AlertService.instance = new Alert({ name: 'alert-instance' });
3029
+ /**
3030
+ * Hides all of the alerts
3031
+ */
3032
+ static hideAll() {
3033
+ const { length } = this.alertsManager.visibleInstances;
3034
+ for (let i = 0; i < length; i += 1)
3035
+ this.remove(0);
3036
+ }
3037
+ /**
3038
+ * Removes an alert from the alert queue
3039
+ * @param index index of the alert to be removed
3040
+ */
3041
+ static remove(index) {
3042
+ this.alertsManager.remove(index);
3043
+ }
3044
+ }
2947
3045
 
2948
3046
  /**
2949
3047
  * Base class for Dialog component.
@@ -6122,6 +6220,7 @@ class Grid extends Iterable {
6122
6220
  const instance = Metadata.updateInstance(instanceName, updatedComponent);
6123
6221
  if (newClickEvt)
6124
6222
  instance.events.click = newClickEvt;
6223
+ return instance;
6125
6224
  }
6126
6225
  catch (e) {
6127
6226
  if (!newComponent.events) {
@@ -6129,8 +6228,8 @@ class Grid extends Iterable {
6129
6228
  }
6130
6229
  if (newClickEvt)
6131
6230
  newComponent.events.click = newClickEvt;
6231
+ return newComponent;
6132
6232
  }
6133
- return newComponent;
6134
6233
  }
6135
6234
  changeDefaultSlotNames(slot) {
6136
6235
  const strMetadata = JSON.stringify(slot);
@@ -10385,6 +10484,7 @@ class SelectTree extends TextInput {
10385
10484
  */
10386
10485
  this.fieldHasChild = '';
10387
10486
  this.savedNodes = undefined;
10487
+ this.debounceSearch = debounce(this.searchChange, 500);
10388
10488
  this.nodes = this.getInitValue('nodes', props.nodes, this.nodes);
10389
10489
  this.alwaysOpen = this.getInitValue('alwaysOpen', props.alwaysOpen, this.alwaysOpen);
10390
10490
  this.flattenSearchResults = this.getInitValue('flattenSearchResults', props.flattenSearchResults, this.flattenSearchResults);
@@ -10612,7 +10712,7 @@ class SelectTree extends TextInput {
10612
10712
  if (value !== this.lastInputValue) {
10613
10713
  this.lastInputValue = value;
10614
10714
  this.callInputEvent({ element, component: this });
10615
- this.searchChange(value, element);
10715
+ this.debounceSearch(value, element);
10616
10716
  }
10617
10717
  }
10618
10718
  get searchValue() {
@@ -357,6 +357,7 @@
357
357
  * Stacks alert content vertically (mobile)
358
358
  */
359
359
  this.vertical = false;
360
+ this.id = 0;
360
361
  this.defaultValues = {
361
362
  name: this.name,
362
363
  dark: this.dark,
@@ -374,6 +375,7 @@
374
375
  showDismiss: this.showDismiss,
375
376
  dismissColor: this.dismissColor,
376
377
  buttonsSlot: this.buttonsSlot,
378
+ id: this.id,
377
379
  };
378
380
  this.assignAlertProperties(props);
379
381
  this.createAccessors();
@@ -399,6 +401,7 @@
399
401
  this.showDismiss = this.getInitValue('showDismiss', alert.showDismiss, this.defaultValues.showDismiss);
400
402
  this.dismissColor = this.getInitValue('dismissColor', alert.dismissColor, this.defaultValues.dismissColor);
401
403
  this.buttonsSlot = alert.buttonsSlot || this.defaultValues.buttonsSlot;
404
+ this.id = alert.id || this.defaultValues.id;
402
405
  this.isVisible = false;
403
406
  }
404
407
  /**
@@ -2801,12 +2804,7 @@
2801
2804
  */
2802
2805
  constructor(props) {
2803
2806
  super(props);
2804
- this.defaultMask = core.Config.masks.numberMask || {
2805
- decimalCharacter: ',',
2806
- decimalCharacterAlternative: '.',
2807
- decimalPlaces: 2,
2808
- digitGroupSeparator: '.',
2809
- };
2807
+ this.defaultMask = core.Config.masks.numberMask || {};
2810
2808
  /*
2811
2809
  * Defines how the field content should be aligned.
2812
2810
  */
@@ -2833,7 +2831,7 @@
2833
2831
  this.localValue = value;
2834
2832
  if (this.maskValid && this.localValue !== undefined && this.localValue !== null) {
2835
2833
  this.formattedValue = AutoNumeric.format(this.localValue, this.mask);
2836
- if (this.autoNumericObj) {
2834
+ if (this.autoNumericObj && value !== this.autoNumericObj.rawValue) {
2837
2835
  this.autoNumericObj.setValue(value);
2838
2836
  }
2839
2837
  }
@@ -2903,7 +2901,7 @@
2903
2901
  class Currency extends Number$1 {
2904
2902
  constructor(props) {
2905
2903
  super(props);
2906
- this.defaultMask = core.Config.masks.currencyMask;
2904
+ this.defaultMask = Object.assign(Object.assign({}, core.Config.masks.numberMask), core.Config.masks.currencyMask);
2907
2905
  this.formatterFn = core.FormatterParserProvider.getFormatter('ZdCurrency');
2908
2906
  this.parserFn = core.FormatterParserProvider.getParser('ZdCurrency');
2909
2907
  this.mask = this.getInitValue('mask', props.mask, this.defaultMask);
@@ -2911,46 +2909,146 @@
2911
2909
  this.validateMask();
2912
2910
  }
2913
2911
  }
2914
- core.FormatterParserProvider.registerFormatter('ZdCurrency', (value, { mask = core.Config.masks.currencyMask, } = {}) => (value === null ? '' : AutoNumeric.format(value, mask)));
2915
- core.FormatterParserProvider.registerParser('ZdCurrency', (value, { mask = core.Config.masks.currencyMask, } = {}) => (value === '' ? null : AutoNumeric.unformat(value, mask)));
2912
+ core.FormatterParserProvider.registerFormatter('ZdCurrency', (value, { mask = Object.assign(Object.assign({}, core.Config.masks.numberMask), core.Config.masks.currencyMask), } = {}) => {
2913
+ let maskDef = mask;
2914
+ if (core.Accessor.isAccessorDefinition(maskDef)) {
2915
+ const [controller, accessor] = core.Accessor.getAccessor(maskDef);
2916
+ maskDef = core.Loader.getInstance(controller)[accessor];
2917
+ }
2918
+ const maskValue = typeof (maskDef) === 'function' ? maskDef(AutoNumeric.unformat(value)) : maskDef;
2919
+ return value === null ? '' : AutoNumeric.format(value, maskValue);
2920
+ });
2921
+ core.FormatterParserProvider.registerParser('ZdCurrency', (value, { mask = Object.assign(Object.assign({}, core.Config.masks.numberMask), core.Config.masks.currencyMask), } = {}) => {
2922
+ let maskDef = mask;
2923
+ if (core.Accessor.isAccessorDefinition(maskDef)) {
2924
+ const [controller, accessor] = core.Accessor.getAccessor(maskDef);
2925
+ maskDef = core.Loader.getInstance(controller)[accessor];
2926
+ }
2927
+ const maskValue = typeof (maskDef) === 'function' ? maskDef(AutoNumeric.format(value)) : maskDef;
2928
+ return value === '' ? null : AutoNumeric.unformat(value, maskValue);
2929
+ });
2930
+
2931
+ class AlertQueue {
2932
+ constructor() {
2933
+ this.queue = [];
2934
+ this.visibleInstances = [];
2935
+ }
2936
+ show(alert) {
2937
+ this.queue.push(alert);
2938
+ if ((this.visibleInstances.length === 0 || !this.visibleInstances[0].isVisible)
2939
+ && this.queue.length === 1) {
2940
+ this.display(alert);
2941
+ }
2942
+ return 0;
2943
+ }
2944
+ /**
2945
+ * Displays an alert
2946
+ * @param alert Alert Structure
2947
+ */
2948
+ display(alert) {
2949
+ if (this.visibleInstances.length === 0) {
2950
+ this.visibleInstances.push(new Alert({ name: 'alert-instance', id: 0 }));
2951
+ }
2952
+ this.visibleInstances[0].assignAlertProperties(alert);
2953
+ this.visibleInstances[0].show();
2954
+ return 0;
2955
+ }
2956
+ remove(index) {
2957
+ this.queue.splice(index, 1);
2958
+ if (index === 0 && this.queue[0]) {
2959
+ setTimeout(() => this.display(this.queue[0]), 200);
2960
+ }
2961
+ }
2962
+ }
2963
+
2964
+ class AlertReplace extends AlertQueue {
2965
+ show(alert) {
2966
+ super.show(alert);
2967
+ this.visibleInstances[0].hide();
2968
+ this.remove(0);
2969
+ setTimeout(() => this.display(alert), 200);
2970
+ return 0;
2971
+ }
2972
+ }
2973
+
2974
+ class AlertStack {
2975
+ constructor() {
2976
+ this.queue = [];
2977
+ this.visibleInstances = [];
2978
+ }
2979
+ show(alert) {
2980
+ this.queue.push(alert);
2981
+ return this.display(alert);
2982
+ }
2983
+ display(alert) {
2984
+ const lastAlert = this.visibleInstances.slice(-1)[0];
2985
+ const lastId = (lastAlert === null || lastAlert === void 0 ? void 0 : lastAlert.id) || 0;
2986
+ const id = lastId + 1;
2987
+ const instance = new Alert(Object.assign(Object.assign({}, alert), { id }));
2988
+ this.visibleInstances.push(instance);
2989
+ instance.show();
2990
+ return id;
2991
+ }
2992
+ remove(index) {
2993
+ this.queue.splice(index, 1);
2994
+ this.visibleInstances.splice(index, 1);
2995
+ }
2996
+ }
2916
2997
 
2917
2998
  /**
2918
2999
  * Alert Service Class
2919
3000
  */
2920
3001
  class AlertService {
3002
+ static instantiateManager(multiple) {
3003
+ if (multiple === 'queue') {
3004
+ this.alertsManager = new AlertQueue();
3005
+ return;
3006
+ }
3007
+ if (multiple === 'stack') {
3008
+ this.alertsManager = new AlertStack();
3009
+ return;
3010
+ }
3011
+ this.alertsManager = new AlertReplace();
3012
+ }
2921
3013
  /**
2922
3014
  * Displays an alert.
2923
3015
  * If has an opened alert it will be closed.
2924
3016
  * @param alert Alert structure
2925
3017
  */
2926
3018
  static show(alert) {
2927
- if (this.instance.isVisible) {
2928
- this.hide();
2929
- setTimeout(() => this.display(alert), 200);
2930
- }
2931
- else {
2932
- this.display(alert);
2933
- }
3019
+ return this.alertsManager.show(alert);
2934
3020
  }
2935
3021
  /**
2936
- * Hides current alert
3022
+ * Hides alert by index. Default index is 0
2937
3023
  */
2938
- static hide() {
2939
- this.instance.hide();
3024
+ static hide(index = 0) {
3025
+ this.alertsManager.visibleInstances[index].hide();
3026
+ this.remove(index);
2940
3027
  }
2941
3028
  /**
2942
- * Displays an alert
2943
- * @param alert Alert Structure
3029
+ * Hides alert by alert id (returned by the `show` method)
3030
+ * @param id
2944
3031
  */
2945
- static display(alert) {
2946
- this.instance.assignAlertProperties(alert);
2947
- this.instance.show();
3032
+ static hideById(id) {
3033
+ const index = this.alertsManager.visibleInstances.findIndex((instance) => instance.id === id);
3034
+ this.hide(index);
2948
3035
  }
2949
- }
2950
- /**
2951
- * Current alert
2952
- */
2953
- AlertService.instance = new Alert({ name: 'alert-instance' });
3036
+ /**
3037
+ * Hides all of the alerts
3038
+ */
3039
+ static hideAll() {
3040
+ const { length } = this.alertsManager.visibleInstances;
3041
+ for (let i = 0; i < length; i += 1)
3042
+ this.remove(0);
3043
+ }
3044
+ /**
3045
+ * Removes an alert from the alert queue
3046
+ * @param index index of the alert to be removed
3047
+ */
3048
+ static remove(index) {
3049
+ this.alertsManager.remove(index);
3050
+ }
3051
+ }
2954
3052
 
2955
3053
  /**
2956
3054
  * Base class for Dialog component.
@@ -6129,6 +6227,7 @@
6129
6227
  const instance = core.Metadata.updateInstance(instanceName, updatedComponent);
6130
6228
  if (newClickEvt)
6131
6229
  instance.events.click = newClickEvt;
6230
+ return instance;
6132
6231
  }
6133
6232
  catch (e) {
6134
6233
  if (!newComponent.events) {
@@ -6136,8 +6235,8 @@
6136
6235
  }
6137
6236
  if (newClickEvt)
6138
6237
  newComponent.events.click = newClickEvt;
6238
+ return newComponent;
6139
6239
  }
6140
- return newComponent;
6141
6240
  }
6142
6241
  changeDefaultSlotNames(slot) {
6143
6242
  const strMetadata = JSON.stringify(slot);
@@ -10392,6 +10491,7 @@
10392
10491
  */
10393
10492
  this.fieldHasChild = '';
10394
10493
  this.savedNodes = undefined;
10494
+ this.debounceSearch = debounce__default["default"](this.searchChange, 500);
10395
10495
  this.nodes = this.getInitValue('nodes', props.nodes, this.nodes);
10396
10496
  this.alwaysOpen = this.getInitValue('alwaysOpen', props.alwaysOpen, this.alwaysOpen);
10397
10497
  this.flattenSearchResults = this.getInitValue('flattenSearchResults', props.flattenSearchResults, this.flattenSearchResults);
@@ -10619,7 +10719,7 @@
10619
10719
  if (value !== this.lastInputValue) {
10620
10720
  this.lastInputValue = value;
10621
10721
  this.callInputEvent({ element, component: this });
10622
- this.searchChange(value, element);
10722
+ this.debounceSearch(value, element);
10623
10723
  }
10624
10724
  }
10625
10725
  get searchValue() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.80.0",
3
+ "version": "1.81.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -41,5 +41,5 @@
41
41
  "lodash.times": "4.3.*",
42
42
  "mockdate": "3.0.*"
43
43
  },
44
- "gitHead": "475e792a47bd61e8b083078ea84dbae954992339"
44
+ "gitHead": "895b0c66924cfd9a800ce45074822e4994f7cda8"
45
45
  }
@@ -60,6 +60,7 @@ export declare class Alert extends Component implements IAlert {
60
60
  * Stacks alert content vertically (mobile)
61
61
  */
62
62
  vertical: boolean;
63
+ id: number;
63
64
  protected defaultValues: {
64
65
  name: string;
65
66
  dark: boolean;
@@ -77,6 +78,7 @@ export declare class Alert extends Component implements IAlert {
77
78
  showDismiss: boolean;
78
79
  dismissColor: string;
79
80
  buttonsSlot: IButton[];
81
+ id: number;
80
82
  };
81
83
  /**
82
84
  * Creates a new Alert
@@ -1,6 +1,7 @@
1
1
  import { IComponent } from '../zd-component/interfaces';
2
2
  import { IButton } from '../zd-button/interfaces';
3
3
  export interface IAlert extends IComponent {
4
+ id?: number;
4
5
  color?: string;
5
6
  text?: string;
6
7
  timeout?: number;
@@ -140,6 +140,7 @@ export declare class SelectTree extends TextInput implements ISelectTree {
140
140
  * @param element Element focused
141
141
  */
142
142
  searchInput(value: string, element?: any): void;
143
+ private debounceSearch;
143
144
  get searchValue(): any;
144
145
  protected clearRow(row: IDictionary<any>): {
145
146
  [x: string]: any;
@@ -0,0 +1,13 @@
1
+ import { Alert, IAlert } from '../../components';
2
+ import { IAlertsManager } from './interfaces';
3
+ export declare class AlertQueue implements IAlertsManager {
4
+ protected queue: IAlert[];
5
+ visibleInstances: Alert[];
6
+ show(alert: IAlert): number;
7
+ /**
8
+ * Displays an alert
9
+ * @param alert Alert Structure
10
+ */
11
+ protected display(alert: IAlert): number;
12
+ remove(index: number): void;
13
+ }
@@ -0,0 +1,5 @@
1
+ import { IAlert } from '../../components';
2
+ import { AlertQueue } from './alert-queue';
3
+ export declare class AlertReplace extends AlertQueue {
4
+ show(alert: IAlert): number;
5
+ }
@@ -1,26 +1,34 @@
1
- import { Alert } from '../../components/zd-alert/alert';
2
1
  import { IAlert } from '../../components/zd-alert/interfaces';
2
+ import { IAlertsManager } from './interfaces';
3
+ export declare type Multiple = 'replace' | 'stack' | 'queue';
3
4
  /**
4
5
  * Alert Service Class
5
6
  */
6
7
  export declare class AlertService {
7
- /**
8
- * Current alert
9
- */
10
- static instance: Alert;
8
+ static alertsManager: IAlertsManager;
9
+ static instantiateManager(multiple: Multiple): void;
11
10
  /**
12
11
  * Displays an alert.
13
12
  * If has an opened alert it will be closed.
14
13
  * @param alert Alert structure
15
14
  */
16
- static show(alert: IAlert): void;
15
+ static show(alert: IAlert): number;
16
+ /**
17
+ * Hides alert by index. Default index is 0
18
+ */
19
+ static hide(index?: number): void;
20
+ /**
21
+ * Hides alert by alert id (returned by the `show` method)
22
+ * @param id
23
+ */
24
+ static hideById(id: number): void;
17
25
  /**
18
- * Hides current alert
26
+ * Hides all of the alerts
19
27
  */
20
- static hide(): void;
28
+ static hideAll(): void;
21
29
  /**
22
- * Displays an alert
23
- * @param alert Alert Structure
30
+ * Removes an alert from the alert queue
31
+ * @param index index of the alert to be removed
24
32
  */
25
- private static display;
33
+ static remove(index: number): void;
26
34
  }
@@ -0,0 +1,9 @@
1
+ import { Alert, IAlert } from '../../components';
2
+ import { IAlertsManager } from './interfaces';
3
+ export declare class AlertStack implements IAlertsManager {
4
+ protected queue: IAlert[];
5
+ visibleInstances: Alert[];
6
+ show(alert: IAlert): number;
7
+ private display;
8
+ remove(index: number): void;
9
+ }
@@ -0,0 +1,6 @@
1
+ import { Alert, IAlert } from '../../components';
2
+ export interface IAlertsManager {
3
+ visibleInstances: Alert[];
4
+ show(alert: IAlert): number;
5
+ remove(index: number): void;
6
+ }