@zeedhi/common 1.86.1 → 1.87.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.
@@ -7301,6 +7301,10 @@ class Select extends TextInput {
7301
7301
  * Field used to display values
7302
7302
  */
7303
7303
  this.dataText = '';
7304
+ /**
7305
+ * Field used to display values when the select is closed
7306
+ */
7307
+ this.dataTextDiscrete = '';
7304
7308
  /**
7305
7309
  * Value used to join display values
7306
7310
  */
@@ -7396,6 +7400,7 @@ class Select extends TextInput {
7396
7400
  this.debounceSearch = debounce(this.doSearch, 500);
7397
7401
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'expand');
7398
7402
  this.dataText = this.getInitValue('dataText', props.dataText, this.dataText);
7403
+ this.dataTextDiscrete = this.getInitValue('dataTextDiscrete', props.dataTextDiscrete, this.dataTextDiscrete);
7399
7404
  this.dataTextSeparator = this.getInitValue('dataTextSeparator', props.dataTextSeparator, this.dataTextSeparator);
7400
7405
  this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
7401
7406
  this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
@@ -7414,6 +7419,12 @@ class Select extends TextInput {
7414
7419
  }
7415
7420
  if (this.dataText && !Array.isArray(this.dataText))
7416
7421
  this.dataText = [this.dataText];
7422
+ if (this.dataTextDiscrete && !Array.isArray(this.dataTextDiscrete))
7423
+ this.dataTextDiscrete = [this.dataTextDiscrete];
7424
+ this.discreteProps = {
7425
+ dataText: this.dataTextDiscrete,
7426
+ dataTextSeparator: this.dataTextSeparator,
7427
+ };
7417
7428
  const defaultDatasource = this.getDefaultDatasource(props);
7418
7429
  this.datasource = DatasourceFactory.factory(defaultDatasource);
7419
7430
  this.overrideGet();
@@ -7464,7 +7475,10 @@ class Select extends TextInput {
7464
7475
  }
7465
7476
  set search(value) {
7466
7477
  this.searchValue = value || '';
7467
- if (this.searchValue === '' || this.searchValue !== this.formatter(this.selectValue)) {
7478
+ const searchValue = this.dataTextDiscrete.length === 0
7479
+ ? this.formatter(this.selectValue)
7480
+ : this.formatter(this.selectValue, this.discreteProps);
7481
+ if (this.searchValue === '' || this.searchValue !== searchValue) {
7468
7482
  this.dirtySearchValue = this.searchValue;
7469
7483
  if (this.isFocused)
7470
7484
  this.debounceSearch(this.searchValue);
@@ -7595,7 +7609,7 @@ class Select extends TextInput {
7595
7609
  /**
7596
7610
  * Returns the currentRow in the dataText key
7597
7611
  */
7598
- formatter(value) { return this.formatterFn(value, this); }
7612
+ formatter(value, props) { return this.formatterFn(value, props !== null && props !== void 0 ? props : this); }
7599
7613
  setFieldValue(value) {
7600
7614
  return __awaiter(this, void 0, void 0, function* () {
7601
7615
  let filterValue;
@@ -10565,6 +10579,10 @@ class SelectTree extends TextInput {
10565
10579
  * Defines if the node tree has child
10566
10580
  */
10567
10581
  this.fieldHasChild = '';
10582
+ /**
10583
+ * Automatically select option if only one is filtered
10584
+ */
10585
+ this.autoSelection = true;
10568
10586
  this.savedNodes = undefined;
10569
10587
  this.debounceSearch = debounce(this.searchChange, 500);
10570
10588
  this.nodes = this.getInitValue('nodes', props.nodes, this.nodes);
@@ -10588,6 +10606,7 @@ class SelectTree extends TextInput {
10588
10606
  this.fetchOnDemand = this.getInitValue('fetchOnDemand', props.fetchOnDemand, this.fetchOnDemand);
10589
10607
  this.fieldHasChild = this.getInitValue('fieldHasChild', props.fieldHasChild, this.fieldHasChild);
10590
10608
  this.menuMaxWidth = this.getInitValue('menuMaxWidth', props.menuMaxWidth, this.menuMaxWidth);
10609
+ this.autoSelection = this.getInitValue('autoSelection', props.autoSelection, this.autoSelection);
10591
10610
  if (props.datasource && Object.keys(props.datasource).length) {
10592
10611
  this.lazyLoad = props.datasource.lazyLoad !== false;
10593
10612
  const searchFields = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
@@ -10851,6 +10870,14 @@ class SelectTree extends TextInput {
10851
10870
  });
10852
10871
  });
10853
10872
  }
10873
+ checkAutoSelection() {
10874
+ if (!this.getFilteredNodes)
10875
+ return;
10876
+ const filteredNode = this.getFilteredNodes();
10877
+ if (this.autoSelection && filteredNode) {
10878
+ this.setValue(filteredNode.id);
10879
+ }
10880
+ }
10854
10881
  }
10855
10882
 
10856
10883
  /**
@@ -7308,6 +7308,10 @@
7308
7308
  * Field used to display values
7309
7309
  */
7310
7310
  this.dataText = '';
7311
+ /**
7312
+ * Field used to display values when the select is closed
7313
+ */
7314
+ this.dataTextDiscrete = '';
7311
7315
  /**
7312
7316
  * Value used to join display values
7313
7317
  */
@@ -7403,6 +7407,7 @@
7403
7407
  this.debounceSearch = debounce__default["default"](this.doSearch, 500);
7404
7408
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'expand');
7405
7409
  this.dataText = this.getInitValue('dataText', props.dataText, this.dataText);
7410
+ this.dataTextDiscrete = this.getInitValue('dataTextDiscrete', props.dataTextDiscrete, this.dataTextDiscrete);
7406
7411
  this.dataTextSeparator = this.getInitValue('dataTextSeparator', props.dataTextSeparator, this.dataTextSeparator);
7407
7412
  this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
7408
7413
  this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
@@ -7421,6 +7426,12 @@
7421
7426
  }
7422
7427
  if (this.dataText && !Array.isArray(this.dataText))
7423
7428
  this.dataText = [this.dataText];
7429
+ if (this.dataTextDiscrete && !Array.isArray(this.dataTextDiscrete))
7430
+ this.dataTextDiscrete = [this.dataTextDiscrete];
7431
+ this.discreteProps = {
7432
+ dataText: this.dataTextDiscrete,
7433
+ dataTextSeparator: this.dataTextSeparator,
7434
+ };
7424
7435
  const defaultDatasource = this.getDefaultDatasource(props);
7425
7436
  this.datasource = core.DatasourceFactory.factory(defaultDatasource);
7426
7437
  this.overrideGet();
@@ -7471,7 +7482,10 @@
7471
7482
  }
7472
7483
  set search(value) {
7473
7484
  this.searchValue = value || '';
7474
- if (this.searchValue === '' || this.searchValue !== this.formatter(this.selectValue)) {
7485
+ const searchValue = this.dataTextDiscrete.length === 0
7486
+ ? this.formatter(this.selectValue)
7487
+ : this.formatter(this.selectValue, this.discreteProps);
7488
+ if (this.searchValue === '' || this.searchValue !== searchValue) {
7475
7489
  this.dirtySearchValue = this.searchValue;
7476
7490
  if (this.isFocused)
7477
7491
  this.debounceSearch(this.searchValue);
@@ -7602,7 +7616,7 @@
7602
7616
  /**
7603
7617
  * Returns the currentRow in the dataText key
7604
7618
  */
7605
- formatter(value) { return this.formatterFn(value, this); }
7619
+ formatter(value, props) { return this.formatterFn(value, props !== null && props !== void 0 ? props : this); }
7606
7620
  setFieldValue(value) {
7607
7621
  return __awaiter(this, void 0, void 0, function* () {
7608
7622
  let filterValue;
@@ -10572,6 +10586,10 @@
10572
10586
  * Defines if the node tree has child
10573
10587
  */
10574
10588
  this.fieldHasChild = '';
10589
+ /**
10590
+ * Automatically select option if only one is filtered
10591
+ */
10592
+ this.autoSelection = true;
10575
10593
  this.savedNodes = undefined;
10576
10594
  this.debounceSearch = debounce__default["default"](this.searchChange, 500);
10577
10595
  this.nodes = this.getInitValue('nodes', props.nodes, this.nodes);
@@ -10595,6 +10613,7 @@
10595
10613
  this.fetchOnDemand = this.getInitValue('fetchOnDemand', props.fetchOnDemand, this.fetchOnDemand);
10596
10614
  this.fieldHasChild = this.getInitValue('fieldHasChild', props.fieldHasChild, this.fieldHasChild);
10597
10615
  this.menuMaxWidth = this.getInitValue('menuMaxWidth', props.menuMaxWidth, this.menuMaxWidth);
10616
+ this.autoSelection = this.getInitValue('autoSelection', props.autoSelection, this.autoSelection);
10598
10617
  if (props.datasource && Object.keys(props.datasource).length) {
10599
10618
  this.lazyLoad = props.datasource.lazyLoad !== false;
10600
10619
  const searchFields = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
@@ -10858,6 +10877,14 @@
10858
10877
  });
10859
10878
  });
10860
10879
  }
10880
+ checkAutoSelection() {
10881
+ if (!this.getFilteredNodes)
10882
+ return;
10883
+ const filteredNode = this.getFilteredNodes();
10884
+ if (this.autoSelection && filteredNode) {
10885
+ this.setValue(filteredNode.id);
10886
+ }
10887
+ }
10861
10888
  }
10862
10889
 
10863
10890
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.86.1",
3
+ "version": "1.87.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -43,5 +43,5 @@
43
43
  "lodash.times": "4.3.*",
44
44
  "mockdate": "3.0.*"
45
45
  },
46
- "gitHead": "96c1d8fad419409f16c17a3ec72f0bca1748002c"
46
+ "gitHead": "528e43ff67f44973feb379818ae80f0c8c02a379"
47
47
  }
@@ -7,6 +7,7 @@ export interface ISelect extends ITextInput {
7
7
  autoSelection?: boolean;
8
8
  datasource?: IDatasource;
9
9
  dataText?: string | any[];
10
+ dataTextDiscrete?: string | any[];
10
11
  dataTextSeparator?: string;
11
12
  dataValue?: string;
12
13
  dataDisabled?: string;
@@ -14,6 +14,10 @@ export declare class Select extends TextInput implements ISelect {
14
14
  * Field used to display values
15
15
  */
16
16
  dataText: string | any[];
17
+ /**
18
+ * Field used to display values when the select is closed
19
+ */
20
+ dataTextDiscrete: string | any[];
17
21
  /**
18
22
  * Value used to join display values
19
23
  */
@@ -105,6 +109,7 @@ export declare class Select extends TextInput implements ISelect {
105
109
  protected cachedTotal: number;
106
110
  protected formatterFn: Function;
107
111
  private pushedValue;
112
+ private discreteProps?;
108
113
  protected loadMoreQtty: number;
109
114
  /**
110
115
  * Create a new Select.
@@ -149,7 +154,10 @@ export declare class Select extends TextInput implements ISelect {
149
154
  /**
150
155
  * Returns the currentRow in the dataText key
151
156
  */
152
- formatter(value?: string | IDictionary<any>): any;
157
+ formatter(value?: string | IDictionary<any>, props?: {
158
+ dataText: string | any[];
159
+ dataTextSeparator: string;
160
+ }): any;
153
161
  protected setFieldValue(value: any): Promise<boolean>;
154
162
  /**
155
163
  * Set value accessors
@@ -32,6 +32,7 @@ export interface ISelectTree extends IComponentRender {
32
32
  fetchOnDemand?: boolean;
33
33
  fieldHasChild?: string;
34
34
  menuMaxWidth?: number;
35
+ autoSelection?: boolean;
35
36
  }
36
37
  export interface ISelectTreeCloseEvent extends IEventParam<SelectTree> {
37
38
  selectedNodes: ISelectTreeNode<IDictionary>[];
@@ -98,6 +98,11 @@ export declare class SelectTree extends TextInput implements ISelectTree {
98
98
  * Defines if the node tree has child
99
99
  */
100
100
  fieldHasChild: string;
101
+ /**
102
+ * Automatically select option if only one is filtered
103
+ */
104
+ autoSelection: boolean;
105
+ getFilteredNodes?: () => boolean | Object;
101
106
  /**
102
107
  * Creates a new instance of SelectTree
103
108
  * @param props
@@ -149,4 +154,5 @@ export declare class SelectTree extends TextInput implements ISelectTree {
149
154
  set value(value: any);
150
155
  setValue(value: any): void;
151
156
  loadChildren(parentNode: ISelectTreeNode<IDictionary>): Promise<void>;
157
+ checkAutoSelection(): void;
152
158
  }