@zeedhi/common 1.87.1 → 1.87.2

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.
@@ -5259,6 +5259,7 @@ class Column extends Component {
5259
5259
  this.factoredConditions = {};
5260
5260
  /* Action children conditions */
5261
5261
  this.actionFactoredConditions = {};
5262
+ this.helperText = '';
5262
5263
  this.defaultData = [];
5263
5264
  this.lookup = debounce((lookupColumn) => {
5264
5265
  this.loading = true;
@@ -5290,6 +5291,7 @@ class Column extends Component {
5290
5291
  this.componentProps = this.getInitValue('componentProps', props.componentProps, this.componentProps);
5291
5292
  this.xlsType = this.getInitValue('xlsType', props.xlsType, this.xlsType);
5292
5293
  this.conditions = this.getInitValue('conditions', props.conditions, this.conditions);
5294
+ this.helperText = this.getInitValue('', props.helperText, this.helperText);
5293
5295
  this.createConditions();
5294
5296
  this.createActionConditions();
5295
5297
  if (this.componentProps.datasource) {
@@ -6364,6 +6366,7 @@ class GridEditable extends Grid {
6364
6366
  * @private
6365
6367
  */
6366
6368
  this.invalidComponents = {};
6369
+ this.editingNewRows = false;
6367
6370
  this.cancelEditedRowsKeyMapping = {
6368
6371
  esc: {
6369
6372
  event: this.cancelEditedRows.bind(this),
@@ -6375,6 +6378,7 @@ class GridEditable extends Grid {
6375
6378
  this.newRowIdentifier = '__added_row';
6376
6379
  this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
6377
6380
  this.canEditRow = this.getInitValue('canEditRow', props.canEditRow, this.canEditRow);
6381
+ this.editingNewRows = this.getInitValue('editingNewRows', props.editingNewRows, this.editingNewRows);
6378
6382
  this.createAccessors();
6379
6383
  }
6380
6384
  onMounted(element) {
@@ -6840,6 +6844,9 @@ class GridEditable extends Grid {
6840
6844
  }
6841
6845
  }
6842
6846
  callCanEditRow(row) {
6847
+ if (this.editingNewRows) {
6848
+ return row[this.newRowIdentifier];
6849
+ }
6843
6850
  return !this.canEditRow || typeof this.canEditRow !== 'function' || this.canEditRow({ row, component: this });
6844
6851
  }
6845
6852
  }
@@ -7766,7 +7773,8 @@ class Select extends TextInput {
7766
7773
  */
7767
7774
  blur(event, element) {
7768
7775
  if (this.autocomplete) {
7769
- if (this.search && this.autoSelection && this.datasource.data.length === 1) {
7776
+ const isSameValue = () => this.getValue(this.datasource.data[0]) === this.value;
7777
+ if (this.search && this.autoSelection && this.datasource.data.length === 1 && !isSameValue()) {
7770
7778
  this.setValue(this.datasource.data[0]);
7771
7779
  }
7772
7780
  this.datasource.search = '';
@@ -7780,7 +7788,7 @@ class Select extends TextInput {
7780
7788
  super.blur(event, element);
7781
7789
  }
7782
7790
  checkValueOnBlur() {
7783
- if (!this.search) {
7791
+ if (!this.search && this.value !== null) {
7784
7792
  this.setValue(null);
7785
7793
  }
7786
7794
  if (this.manualMode)
@@ -10019,6 +10027,9 @@ class SelectMultiple extends Select {
10019
10027
  yield this.datasource.get();
10020
10028
  }
10021
10029
  this.setValue(this.datasource.data);
10030
+ if (!this.datasource.search) {
10031
+ this.setCache();
10032
+ }
10022
10033
  });
10023
10034
  }
10024
10035
  unSelectAllItems() {
@@ -10546,6 +10557,10 @@ class SelectTree extends TextInput {
10546
10557
  * Field used to display values
10547
10558
  */
10548
10559
  this.dataText = '';
10560
+ /**
10561
+ * Field used to display values when the select is closed
10562
+ */
10563
+ this.dataTextDiscrete = '';
10549
10564
  /**
10550
10565
  * Value used to join display values
10551
10566
  */
@@ -10600,6 +10615,7 @@ class SelectTree extends TextInput {
10600
10615
  this.returnObject = this.getInitValue('returnObject', props.returnObject, this.returnObject);
10601
10616
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
10602
10617
  this.dataText = this.getInitValue('dataText', props.dataText, this.dataText);
10618
+ this.dataTextDiscrete = this.getInitValue('dataTextDiscrete', props.dataTextDiscrete, this.dataTextDiscrete);
10603
10619
  this.dataTextSeparator = this.getInitValue('dataTextSeparator', props.dataTextSeparator, this.dataTextSeparator);
10604
10620
  this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
10605
10621
  this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
@@ -10676,7 +10692,29 @@ class SelectTree extends TextInput {
10676
10692
  children = undefined;
10677
10693
  }
10678
10694
  }
10679
- const dataTextArr = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
10695
+ const dataText = this.formatRow(this.dataText, row);
10696
+ const dataTextDiscrete = this.formatRow(this.dataTextDiscrete, row);
10697
+ return {
10698
+ id: row[this.dataValue],
10699
+ label: dataText,
10700
+ discreteLabel: (dataTextDiscrete || dataText),
10701
+ children,
10702
+ row,
10703
+ };
10704
+ }
10705
+ createChildrenNodes(rows) {
10706
+ const newNodes = [];
10707
+ rows.forEach((row) => {
10708
+ if (Object.keys(row).length > 0) {
10709
+ const newNode = this.createNodeFromRow(row);
10710
+ row.tree__node = newNode;
10711
+ newNodes.push(newNode);
10712
+ }
10713
+ });
10714
+ return newNodes;
10715
+ }
10716
+ formatRow(dataText, row) {
10717
+ const dataTextArr = Array.isArray(dataText) ? dataText : [dataText];
10680
10718
  const dataTextNames = [];
10681
10719
  const masks = [];
10682
10720
  dataTextArr.forEach((text) => {
@@ -10695,7 +10733,7 @@ class SelectTree extends TextInput {
10695
10733
  }
10696
10734
  }
10697
10735
  });
10698
- const dataText = dataTextNames.reduce((result, column, index) => {
10736
+ const rowText = dataTextNames.reduce((result, column, index) => {
10699
10737
  if (row[column]) {
10700
10738
  const separator = index > 0 ? this.dataTextSeparator : '';
10701
10739
  let masked = row[column];
@@ -10707,23 +10745,7 @@ class SelectTree extends TextInput {
10707
10745
  }
10708
10746
  return result;
10709
10747
  }, '');
10710
- return {
10711
- id: row[this.dataValue],
10712
- label: dataText,
10713
- children,
10714
- row,
10715
- };
10716
- }
10717
- createChildrenNodes(rows) {
10718
- const newNodes = [];
10719
- rows.forEach((row) => {
10720
- if (Object.keys(row).length > 0) {
10721
- const newNode = this.createNodeFromRow(row);
10722
- row.tree__node = newNode;
10723
- newNodes.push(newNode);
10724
- }
10725
- });
10726
- return newNodes;
10748
+ return rowText;
10727
10749
  }
10728
10750
  /**
10729
10751
  * Triggered when the menu opens
@@ -5266,6 +5266,7 @@
5266
5266
  this.factoredConditions = {};
5267
5267
  /* Action children conditions */
5268
5268
  this.actionFactoredConditions = {};
5269
+ this.helperText = '';
5269
5270
  this.defaultData = [];
5270
5271
  this.lookup = debounce__default["default"]((lookupColumn) => {
5271
5272
  this.loading = true;
@@ -5297,6 +5298,7 @@
5297
5298
  this.componentProps = this.getInitValue('componentProps', props.componentProps, this.componentProps);
5298
5299
  this.xlsType = this.getInitValue('xlsType', props.xlsType, this.xlsType);
5299
5300
  this.conditions = this.getInitValue('conditions', props.conditions, this.conditions);
5301
+ this.helperText = this.getInitValue('', props.helperText, this.helperText);
5300
5302
  this.createConditions();
5301
5303
  this.createActionConditions();
5302
5304
  if (this.componentProps.datasource) {
@@ -6371,6 +6373,7 @@
6371
6373
  * @private
6372
6374
  */
6373
6375
  this.invalidComponents = {};
6376
+ this.editingNewRows = false;
6374
6377
  this.cancelEditedRowsKeyMapping = {
6375
6378
  esc: {
6376
6379
  event: this.cancelEditedRows.bind(this),
@@ -6382,6 +6385,7 @@
6382
6385
  this.newRowIdentifier = '__added_row';
6383
6386
  this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
6384
6387
  this.canEditRow = this.getInitValue('canEditRow', props.canEditRow, this.canEditRow);
6388
+ this.editingNewRows = this.getInitValue('editingNewRows', props.editingNewRows, this.editingNewRows);
6385
6389
  this.createAccessors();
6386
6390
  }
6387
6391
  onMounted(element) {
@@ -6847,6 +6851,9 @@
6847
6851
  }
6848
6852
  }
6849
6853
  callCanEditRow(row) {
6854
+ if (this.editingNewRows) {
6855
+ return row[this.newRowIdentifier];
6856
+ }
6850
6857
  return !this.canEditRow || typeof this.canEditRow !== 'function' || this.canEditRow({ row, component: this });
6851
6858
  }
6852
6859
  }
@@ -7773,7 +7780,8 @@
7773
7780
  */
7774
7781
  blur(event, element) {
7775
7782
  if (this.autocomplete) {
7776
- if (this.search && this.autoSelection && this.datasource.data.length === 1) {
7783
+ const isSameValue = () => this.getValue(this.datasource.data[0]) === this.value;
7784
+ if (this.search && this.autoSelection && this.datasource.data.length === 1 && !isSameValue()) {
7777
7785
  this.setValue(this.datasource.data[0]);
7778
7786
  }
7779
7787
  this.datasource.search = '';
@@ -7787,7 +7795,7 @@
7787
7795
  super.blur(event, element);
7788
7796
  }
7789
7797
  checkValueOnBlur() {
7790
- if (!this.search) {
7798
+ if (!this.search && this.value !== null) {
7791
7799
  this.setValue(null);
7792
7800
  }
7793
7801
  if (this.manualMode)
@@ -10026,6 +10034,9 @@
10026
10034
  yield this.datasource.get();
10027
10035
  }
10028
10036
  this.setValue(this.datasource.data);
10037
+ if (!this.datasource.search) {
10038
+ this.setCache();
10039
+ }
10029
10040
  });
10030
10041
  }
10031
10042
  unSelectAllItems() {
@@ -10553,6 +10564,10 @@
10553
10564
  * Field used to display values
10554
10565
  */
10555
10566
  this.dataText = '';
10567
+ /**
10568
+ * Field used to display values when the select is closed
10569
+ */
10570
+ this.dataTextDiscrete = '';
10556
10571
  /**
10557
10572
  * Value used to join display values
10558
10573
  */
@@ -10607,6 +10622,7 @@
10607
10622
  this.returnObject = this.getInitValue('returnObject', props.returnObject, this.returnObject);
10608
10623
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
10609
10624
  this.dataText = this.getInitValue('dataText', props.dataText, this.dataText);
10625
+ this.dataTextDiscrete = this.getInitValue('dataTextDiscrete', props.dataTextDiscrete, this.dataTextDiscrete);
10610
10626
  this.dataTextSeparator = this.getInitValue('dataTextSeparator', props.dataTextSeparator, this.dataTextSeparator);
10611
10627
  this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
10612
10628
  this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
@@ -10683,7 +10699,29 @@
10683
10699
  children = undefined;
10684
10700
  }
10685
10701
  }
10686
- const dataTextArr = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
10702
+ const dataText = this.formatRow(this.dataText, row);
10703
+ const dataTextDiscrete = this.formatRow(this.dataTextDiscrete, row);
10704
+ return {
10705
+ id: row[this.dataValue],
10706
+ label: dataText,
10707
+ discreteLabel: (dataTextDiscrete || dataText),
10708
+ children,
10709
+ row,
10710
+ };
10711
+ }
10712
+ createChildrenNodes(rows) {
10713
+ const newNodes = [];
10714
+ rows.forEach((row) => {
10715
+ if (Object.keys(row).length > 0) {
10716
+ const newNode = this.createNodeFromRow(row);
10717
+ row.tree__node = newNode;
10718
+ newNodes.push(newNode);
10719
+ }
10720
+ });
10721
+ return newNodes;
10722
+ }
10723
+ formatRow(dataText, row) {
10724
+ const dataTextArr = Array.isArray(dataText) ? dataText : [dataText];
10687
10725
  const dataTextNames = [];
10688
10726
  const masks = [];
10689
10727
  dataTextArr.forEach((text) => {
@@ -10702,7 +10740,7 @@
10702
10740
  }
10703
10741
  }
10704
10742
  });
10705
- const dataText = dataTextNames.reduce((result, column, index) => {
10743
+ const rowText = dataTextNames.reduce((result, column, index) => {
10706
10744
  if (row[column]) {
10707
10745
  const separator = index > 0 ? this.dataTextSeparator : '';
10708
10746
  let masked = row[column];
@@ -10714,23 +10752,7 @@
10714
10752
  }
10715
10753
  return result;
10716
10754
  }, '');
10717
- return {
10718
- id: row[this.dataValue],
10719
- label: dataText,
10720
- children,
10721
- row,
10722
- };
10723
- }
10724
- createChildrenNodes(rows) {
10725
- const newNodes = [];
10726
- rows.forEach((row) => {
10727
- if (Object.keys(row).length > 0) {
10728
- const newNode = this.createNodeFromRow(row);
10729
- row.tree__node = newNode;
10730
- newNodes.push(newNode);
10731
- }
10732
- });
10733
- return newNodes;
10755
+ return rowText;
10734
10756
  }
10735
10757
  /**
10736
10758
  * Triggered when the menu opens
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.87.1",
3
+ "version": "1.87.2",
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": "52e489cc86beba6f24fc8120e8ea641edc9d7cdf"
46
+ "gitHead": "ba49509e8854ec02eb5615c7197e7cad12d1cabe"
47
47
  }
@@ -40,6 +40,7 @@ export declare class GridEditable extends Grid implements IGridEditable {
40
40
  * @private
41
41
  */
42
42
  private invalidComponents;
43
+ editingNewRows: boolean;
43
44
  protected cancelEditedRowsKeyMapping: any;
44
45
  constructor(props: IGridEditable);
45
46
  onMounted(element: any): void;
@@ -190,5 +191,5 @@ export declare class GridEditable extends Grid implements IGridEditable {
190
191
  * @param value Value to be set in the cell
191
192
  */
192
193
  private changeCell;
193
- callCanEditRow(row: IDictionary<any>): boolean;
194
+ callCanEditRow(row: IDictionary<any>): any;
194
195
  }
@@ -40,6 +40,7 @@ export declare class Column extends Component implements IColumn {
40
40
  * Method to get the current column width, assigned by view layer.
41
41
  */
42
42
  private viewGetWidth?;
43
+ helperText: string;
43
44
  protected defaultData: IDictionary[];
44
45
  /**
45
46
  * Creates a new Column.
@@ -4,6 +4,7 @@ import { SelectTree } from './select-tree';
4
4
  export interface ISelectTreeNode<T> {
5
5
  id: string | number;
6
6
  label: string;
7
+ discreteLabel?: string;
7
8
  isDisabled?: boolean;
8
9
  isDefaultExpanded?: boolean;
9
10
  children?: ISelectTreeNode<T>[] | null;
@@ -27,6 +28,7 @@ export interface ISelectTree extends IComponentRender {
27
28
  parentField?: string;
28
29
  dataValue?: string;
29
30
  dataText?: string | any[];
31
+ dataTextDiscrete?: string | any[];
30
32
  dataDisabled?: string;
31
33
  disabledItems?: any[];
32
34
  fetchOnDemand?: boolean;
@@ -60,6 +60,10 @@ export declare class SelectTree extends TextInput implements ISelectTree {
60
60
  * Field used to display values
61
61
  */
62
62
  dataText: string | any[];
63
+ /**
64
+ * Field used to display values when the select is closed
65
+ */
66
+ dataTextDiscrete: string | any[];
63
67
  /**
64
68
  * Value used to join display values
65
69
  */
@@ -115,6 +119,7 @@ export declare class SelectTree extends TextInput implements ISelectTree {
115
119
  createNodesFromDatasource(buildTree?: boolean): void;
116
120
  private createNodeFromRow;
117
121
  private createChildrenNodes;
122
+ private formatRow;
118
123
  /**
119
124
  * Triggered when the menu opens
120
125
  */