@zeedhi/common 1.87.0 → 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)
@@ -8782,6 +8790,7 @@ class Menu extends ComponentRender {
8782
8790
  this.searchValue = '';
8783
8791
  /** Store the current item focused */
8784
8792
  this.currentItem = null;
8793
+ this.cache = false;
8785
8794
  this.app = this.getInitValue('app', props.app, this.app);
8786
8795
  this.absolute = this.getInitValue('absolute', props.absolute, this.absolute);
8787
8796
  this.clipped = this.getInitValue('clipped', props.clipped, this.clipped);
@@ -8800,6 +8809,7 @@ class Menu extends ComponentRender {
8800
8809
  this.closeToMini = this.getInitValue('closeToMini', props.closeToMini, this.closeToMini);
8801
8810
  this.showSearch = this.getInitValue('showSearch', props.showSearch, this.showSearch);
8802
8811
  this.width = this.getInitValue('width', props.width, this.width);
8812
+ this.cache = this.getInitValue('cache', props.cache, this.cache);
8803
8813
  this.mobileBreakpoint = this.getInitValue('mobileBreakpoint', props.mobileBreakpoint, this.mobileBreakpoint);
8804
8814
  this.drawer = window.innerWidth > this.mobileBreakpoint;
8805
8815
  this.openedInitialValue = this.getInitValue('opened', props.opened, this.opened);
@@ -8862,7 +8872,7 @@ class Menu extends ComponentRender {
8862
8872
  */
8863
8873
  loadMetadata(url) {
8864
8874
  return __awaiter(this, void 0, void 0, function* () {
8865
- this.items = (yield Metadata.get(url, Boolean(this.isLocal)));
8875
+ this.items = (yield Metadata.get(url, Boolean(this.isLocal), this.cache));
8866
8876
  });
8867
8877
  }
8868
8878
  /**
@@ -10017,6 +10027,9 @@ class SelectMultiple extends Select {
10017
10027
  yield this.datasource.get();
10018
10028
  }
10019
10029
  this.setValue(this.datasource.data);
10030
+ if (!this.datasource.search) {
10031
+ this.setCache();
10032
+ }
10020
10033
  });
10021
10034
  }
10022
10035
  unSelectAllItems() {
@@ -10544,6 +10557,10 @@ class SelectTree extends TextInput {
10544
10557
  * Field used to display values
10545
10558
  */
10546
10559
  this.dataText = '';
10560
+ /**
10561
+ * Field used to display values when the select is closed
10562
+ */
10563
+ this.dataTextDiscrete = '';
10547
10564
  /**
10548
10565
  * Value used to join display values
10549
10566
  */
@@ -10598,6 +10615,7 @@ class SelectTree extends TextInput {
10598
10615
  this.returnObject = this.getInitValue('returnObject', props.returnObject, this.returnObject);
10599
10616
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
10600
10617
  this.dataText = this.getInitValue('dataText', props.dataText, this.dataText);
10618
+ this.dataTextDiscrete = this.getInitValue('dataTextDiscrete', props.dataTextDiscrete, this.dataTextDiscrete);
10601
10619
  this.dataTextSeparator = this.getInitValue('dataTextSeparator', props.dataTextSeparator, this.dataTextSeparator);
10602
10620
  this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
10603
10621
  this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
@@ -10674,7 +10692,29 @@ class SelectTree extends TextInput {
10674
10692
  children = undefined;
10675
10693
  }
10676
10694
  }
10677
- 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];
10678
10718
  const dataTextNames = [];
10679
10719
  const masks = [];
10680
10720
  dataTextArr.forEach((text) => {
@@ -10693,7 +10733,7 @@ class SelectTree extends TextInput {
10693
10733
  }
10694
10734
  }
10695
10735
  });
10696
- const dataText = dataTextNames.reduce((result, column, index) => {
10736
+ const rowText = dataTextNames.reduce((result, column, index) => {
10697
10737
  if (row[column]) {
10698
10738
  const separator = index > 0 ? this.dataTextSeparator : '';
10699
10739
  let masked = row[column];
@@ -10705,23 +10745,7 @@ class SelectTree extends TextInput {
10705
10745
  }
10706
10746
  return result;
10707
10747
  }, '');
10708
- return {
10709
- id: row[this.dataValue],
10710
- label: dataText,
10711
- children,
10712
- row,
10713
- };
10714
- }
10715
- createChildrenNodes(rows) {
10716
- const newNodes = [];
10717
- rows.forEach((row) => {
10718
- if (Object.keys(row).length > 0) {
10719
- const newNode = this.createNodeFromRow(row);
10720
- row.tree__node = newNode;
10721
- newNodes.push(newNode);
10722
- }
10723
- });
10724
- return newNodes;
10748
+ return rowText;
10725
10749
  }
10726
10750
  /**
10727
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)
@@ -8789,6 +8797,7 @@
8789
8797
  this.searchValue = '';
8790
8798
  /** Store the current item focused */
8791
8799
  this.currentItem = null;
8800
+ this.cache = false;
8792
8801
  this.app = this.getInitValue('app', props.app, this.app);
8793
8802
  this.absolute = this.getInitValue('absolute', props.absolute, this.absolute);
8794
8803
  this.clipped = this.getInitValue('clipped', props.clipped, this.clipped);
@@ -8807,6 +8816,7 @@
8807
8816
  this.closeToMini = this.getInitValue('closeToMini', props.closeToMini, this.closeToMini);
8808
8817
  this.showSearch = this.getInitValue('showSearch', props.showSearch, this.showSearch);
8809
8818
  this.width = this.getInitValue('width', props.width, this.width);
8819
+ this.cache = this.getInitValue('cache', props.cache, this.cache);
8810
8820
  this.mobileBreakpoint = this.getInitValue('mobileBreakpoint', props.mobileBreakpoint, this.mobileBreakpoint);
8811
8821
  this.drawer = window.innerWidth > this.mobileBreakpoint;
8812
8822
  this.openedInitialValue = this.getInitValue('opened', props.opened, this.opened);
@@ -8869,7 +8879,7 @@
8869
8879
  */
8870
8880
  loadMetadata(url) {
8871
8881
  return __awaiter(this, void 0, void 0, function* () {
8872
- this.items = (yield core.Metadata.get(url, Boolean(this.isLocal)));
8882
+ this.items = (yield core.Metadata.get(url, Boolean(this.isLocal), this.cache));
8873
8883
  });
8874
8884
  }
8875
8885
  /**
@@ -10024,6 +10034,9 @@
10024
10034
  yield this.datasource.get();
10025
10035
  }
10026
10036
  this.setValue(this.datasource.data);
10037
+ if (!this.datasource.search) {
10038
+ this.setCache();
10039
+ }
10027
10040
  });
10028
10041
  }
10029
10042
  unSelectAllItems() {
@@ -10551,6 +10564,10 @@
10551
10564
  * Field used to display values
10552
10565
  */
10553
10566
  this.dataText = '';
10567
+ /**
10568
+ * Field used to display values when the select is closed
10569
+ */
10570
+ this.dataTextDiscrete = '';
10554
10571
  /**
10555
10572
  * Value used to join display values
10556
10573
  */
@@ -10605,6 +10622,7 @@
10605
10622
  this.returnObject = this.getInitValue('returnObject', props.returnObject, this.returnObject);
10606
10623
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
10607
10624
  this.dataText = this.getInitValue('dataText', props.dataText, this.dataText);
10625
+ this.dataTextDiscrete = this.getInitValue('dataTextDiscrete', props.dataTextDiscrete, this.dataTextDiscrete);
10608
10626
  this.dataTextSeparator = this.getInitValue('dataTextSeparator', props.dataTextSeparator, this.dataTextSeparator);
10609
10627
  this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
10610
10628
  this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
@@ -10681,7 +10699,29 @@
10681
10699
  children = undefined;
10682
10700
  }
10683
10701
  }
10684
- 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];
10685
10725
  const dataTextNames = [];
10686
10726
  const masks = [];
10687
10727
  dataTextArr.forEach((text) => {
@@ -10700,7 +10740,7 @@
10700
10740
  }
10701
10741
  }
10702
10742
  });
10703
- const dataText = dataTextNames.reduce((result, column, index) => {
10743
+ const rowText = dataTextNames.reduce((result, column, index) => {
10704
10744
  if (row[column]) {
10705
10745
  const separator = index > 0 ? this.dataTextSeparator : '';
10706
10746
  let masked = row[column];
@@ -10712,23 +10752,7 @@
10712
10752
  }
10713
10753
  return result;
10714
10754
  }, '');
10715
- return {
10716
- id: row[this.dataValue],
10717
- label: dataText,
10718
- children,
10719
- row,
10720
- };
10721
- }
10722
- createChildrenNodes(rows) {
10723
- const newNodes = [];
10724
- rows.forEach((row) => {
10725
- if (Object.keys(row).length > 0) {
10726
- const newNode = this.createNodeFromRow(row);
10727
- row.tree__node = newNode;
10728
- newNodes.push(newNode);
10729
- }
10730
- });
10731
- return newNodes;
10755
+ return rowText;
10732
10756
  }
10733
10757
  /**
10734
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.0",
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": "528e43ff67f44973feb379818ae80f0c8c02a379"
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.
@@ -26,6 +26,7 @@ export interface IMenu extends IComponentRender {
26
26
  topSlot?: IComponentRender[];
27
27
  width?: number | string;
28
28
  mobileBreakpoint?: number | string;
29
+ cache?: boolean;
29
30
  }
30
31
  /**
31
32
  * Interface for menu itens
@@ -117,6 +117,7 @@ export declare class Menu extends ComponentRender implements IMenu {
117
117
  private searchValue;
118
118
  /** Store the current item focused */
119
119
  currentItem: IMenuItem | null;
120
+ cache?: boolean;
120
121
  /**
121
122
  * Creates a new Menu.
122
123
  * @param props Menu properties
@@ -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
  */