@zeedhi/common 1.97.0 → 1.97.1

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.
@@ -2004,8 +2004,9 @@ class Input extends ComponentRender {
2004
2004
  updateRules() {
2005
2005
  this.rules = Object.values(this.parsedValidations)
2006
2006
  .map((validation) => (value) => {
2007
- const isValueDefined = value !== undefined && value !== '';
2008
- const testValue = isValueDefined ? value : this.value;
2007
+ const parsedValue = this.parser(value);
2008
+ const isValueDefined = parsedValue !== undefined && parsedValue !== '';
2009
+ const testValue = isValueDefined ? parsedValue : this.value;
2009
2010
  return validation(testValue);
2010
2011
  });
2011
2012
  }
@@ -3982,6 +3983,16 @@ class Date$1 extends TextInput {
3982
3983
  });
3983
3984
  }
3984
3985
  }
3986
+ get value() {
3987
+ return this.internalValue;
3988
+ }
3989
+ set value(value) {
3990
+ if (this.internalValue !== value) {
3991
+ this.internalDisplayValue = this.formatter(value);
3992
+ this.internalValue = value;
3993
+ this.change(undefined, undefined, false);
3994
+ }
3995
+ }
3985
3996
  get displayValue() {
3986
3997
  return this.internalDisplayValue;
3987
3998
  }
@@ -4018,14 +4029,14 @@ class Date$1 extends TextInput {
4018
4029
  this.internalValue = this.parser(displayValue);
4019
4030
  this.dateError = false;
4020
4031
  if (lastValue !== this.displayValue)
4021
- this.change(this.value);
4032
+ this.changeEvent();
4022
4033
  }
4023
4034
  else {
4024
4035
  if (!displayValue) {
4025
4036
  this.internalDisplayValue = displayValue;
4026
4037
  this.internalValue = null;
4027
4038
  if (lastValue !== this.displayValue)
4028
- this.change(this.value);
4039
+ this.changeEvent();
4029
4040
  }
4030
4041
  this.dateError = !!displayValue;
4031
4042
  }
@@ -4064,7 +4075,7 @@ class Date$1 extends TextInput {
4064
4075
  this.dateError = false;
4065
4076
  this.value = this.parseISODateValue(newValue);
4066
4077
  if (lastValue !== this.value)
4067
- this.change(this.value);
4078
+ this.changeEvent();
4068
4079
  }
4069
4080
  formatISODateValue(value) {
4070
4081
  if (value && this.isValidFormatDate(value, this.dateFormat)) {
@@ -4159,15 +4170,19 @@ class Date$1 extends TextInput {
4159
4170
  this.persistentHint = true;
4160
4171
  }
4161
4172
  }
4162
- change(event, element) {
4163
- if (this.lastChangeValue && this.lastChangeValue === this.value)
4164
- return;
4165
- this.lastChangeValue = this.value;
4173
+ changeEvent(event, element) {
4166
4174
  super.change(event, element);
4167
4175
  this.helperValue = '';
4168
4176
  this.hint = this.previousHint;
4169
4177
  this.persistentHint = this.previousPersistentHint;
4170
4178
  }
4179
+ change(event, element, callEvent = true) {
4180
+ if (this.lastChangeValue && this.lastChangeValue === this.value)
4181
+ return;
4182
+ this.lastChangeValue = this.value;
4183
+ if (callEvent)
4184
+ this.changeEvent(event, element);
4185
+ }
4171
4186
  }
4172
4187
  FormatterParserProvider.registerFormatter('ZdDate', (value, { dateFormat = Config.dateFormat, displayFormat = Config.displayFormat, inputFormat = Config.dateInputFormat, mask = '', initialMask, isSimpleDisplay = false, } = {}) => {
4173
4188
  if (!value) {
@@ -5561,7 +5576,7 @@ class Iterable extends ComponentRender {
5561
5576
  * @param props Iterable properties
5562
5577
  */
5563
5578
  constructor(props) {
5564
- var _a, _b;
5579
+ var _a;
5565
5580
  super(props);
5566
5581
  /**
5567
5582
  * Iterable columns
@@ -5592,12 +5607,26 @@ class Iterable extends ComponentRender {
5592
5607
  this.defaultSearchVisibleOnly = (_a = Config.iterableSearchVisibleOnly) !== null && _a !== void 0 ? _a : true;
5593
5608
  this.columns = this.getColumns(props.columns || this.columns);
5594
5609
  this.createController();
5595
- this.datasource = DatasourceFactory.factory(Object.assign(Object.assign({}, props.datasource), { searchIn: ((_b = props.datasource) === null || _b === void 0 ? void 0 : _b.searchIn) || `{{IterableController_${this.name}.searchIn}}` }));
5610
+ this.initializeDatasource(props);
5596
5611
  this.pageSizes = this.getInitValue('pageSizes', props.pageSizes, this.pageSizes);
5597
5612
  this.searchVisibleOnly = this.getInitValue('searchVisibleOnly', props.searchVisibleOnly, this.defaultSearchVisibleOnly);
5598
5613
  this.virtualScroll = this.getInitValue('virtualScroll', props.virtualScroll, this.virtualScroll);
5599
5614
  this.virtualScrollCache = this.getInitValue('virtualScrollCache', props.virtualScrollCache, this.virtualScrollCache);
5600
5615
  }
5616
+ getDatasourceDefaults() {
5617
+ return {};
5618
+ }
5619
+ initializeDatasource(props) {
5620
+ var _a;
5621
+ let datasourceProps = props.datasource;
5622
+ // if using accessor, get props from the controller
5623
+ if (typeof props.datasource === 'string' && Accessor.isAccessorDefinition(props.datasource)) {
5624
+ const [controller, accessor] = Accessor.getAccessor(props.datasource);
5625
+ const instance = Loader.getInstance(controller);
5626
+ datasourceProps = instance[accessor];
5627
+ }
5628
+ this.datasource = DatasourceFactory.factory(Object.assign(Object.assign(Object.assign({}, datasourceProps), this.getDatasourceDefaults()), { searchIn: ((_a = props.datasource) === null || _a === void 0 ? void 0 : _a.searchIn) || `{{IterableController_${this.name}.searchIn}}` }));
5629
+ }
5601
5630
  createController() {
5602
5631
  const controller = new IterableController(this);
5603
5632
  Loader.addController(`IterableController_${this.name}`, controller);
@@ -6901,7 +6930,10 @@ class GridEditable extends Grid {
6901
6930
  }
6902
6931
  let allValid = true;
6903
6932
  this.datasource.data.forEach((row) => this.columns.forEach((column) => {
6904
- if (!column.isVisible || !column.editable)
6933
+ const rowKey = row[this.datasource.uniqueKey];
6934
+ const cellsApplied = (this.cellsApplied[rowKey] || {})[column.name];
6935
+ const columnWithConditions = Object.assign(Object.assign({}, column), cellsApplied);
6936
+ if (!column.isVisible || !columnWithConditions.editable)
6905
6937
  return;
6906
6938
  if (!this.isValid(column, row, true))
6907
6939
  allValid = false;
@@ -7737,10 +7769,9 @@ class Select extends TextInput {
7737
7769
  }
7738
7770
  set search(value) {
7739
7771
  this.searchValue = value || '';
7740
- const searchValue = this.dataTextDiscrete.length === 0
7741
- ? this.formatter(this.selectValue)
7742
- : this.formatter(this.selectValue, this.discreteProps);
7743
- if (this.searchValue === '' || this.searchValue !== searchValue) {
7772
+ const searchValue = this.formatter(this.selectValue);
7773
+ const searchDiscrete = this.formatter(this.selectValue, this.discreteProps);
7774
+ if (this.searchValue === '' || (this.searchValue !== searchValue && this.searchValue !== searchDiscrete)) {
7744
7775
  this.dirtySearchValue = this.searchValue;
7745
7776
  if (this.isFocused)
7746
7777
  this.debounceSearch(this.searchValue);
@@ -12892,7 +12923,7 @@ class TreeGrid extends Grid {
12892
12923
  */
12893
12924
  constructor(props) {
12894
12925
  var _a;
12895
- super(Object.assign(Object.assign({}, props), { datasource: Object.assign(Object.assign({}, props.datasource), { lazyLoad: true, loadAll: true }) }));
12926
+ super(props);
12896
12927
  /**
12897
12928
  * Parent field name
12898
12929
  */
@@ -12947,6 +12978,9 @@ class TreeGrid extends Grid {
12947
12978
  this.treeDataStructure = new TreeDataStructure(this);
12948
12979
  this.createAccessors();
12949
12980
  }
12981
+ getDatasourceDefaults() {
12982
+ return { lazyLoad: true, loadAll: true };
12983
+ }
12950
12984
  onMounted(element) {
12951
12985
  super.onMounted(element);
12952
12986
  if (!this.lazyLoad || this.datasource.data.length) {
@@ -2011,8 +2011,9 @@
2011
2011
  updateRules() {
2012
2012
  this.rules = Object.values(this.parsedValidations)
2013
2013
  .map((validation) => (value) => {
2014
- const isValueDefined = value !== undefined && value !== '';
2015
- const testValue = isValueDefined ? value : this.value;
2014
+ const parsedValue = this.parser(value);
2015
+ const isValueDefined = parsedValue !== undefined && parsedValue !== '';
2016
+ const testValue = isValueDefined ? parsedValue : this.value;
2016
2017
  return validation(testValue);
2017
2018
  });
2018
2019
  }
@@ -3989,6 +3990,16 @@
3989
3990
  });
3990
3991
  }
3991
3992
  }
3993
+ get value() {
3994
+ return this.internalValue;
3995
+ }
3996
+ set value(value) {
3997
+ if (this.internalValue !== value) {
3998
+ this.internalDisplayValue = this.formatter(value);
3999
+ this.internalValue = value;
4000
+ this.change(undefined, undefined, false);
4001
+ }
4002
+ }
3992
4003
  get displayValue() {
3993
4004
  return this.internalDisplayValue;
3994
4005
  }
@@ -4025,14 +4036,14 @@
4025
4036
  this.internalValue = this.parser(displayValue);
4026
4037
  this.dateError = false;
4027
4038
  if (lastValue !== this.displayValue)
4028
- this.change(this.value);
4039
+ this.changeEvent();
4029
4040
  }
4030
4041
  else {
4031
4042
  if (!displayValue) {
4032
4043
  this.internalDisplayValue = displayValue;
4033
4044
  this.internalValue = null;
4034
4045
  if (lastValue !== this.displayValue)
4035
- this.change(this.value);
4046
+ this.changeEvent();
4036
4047
  }
4037
4048
  this.dateError = !!displayValue;
4038
4049
  }
@@ -4071,7 +4082,7 @@
4071
4082
  this.dateError = false;
4072
4083
  this.value = this.parseISODateValue(newValue);
4073
4084
  if (lastValue !== this.value)
4074
- this.change(this.value);
4085
+ this.changeEvent();
4075
4086
  }
4076
4087
  formatISODateValue(value) {
4077
4088
  if (value && this.isValidFormatDate(value, this.dateFormat)) {
@@ -4166,15 +4177,19 @@
4166
4177
  this.persistentHint = true;
4167
4178
  }
4168
4179
  }
4169
- change(event, element) {
4170
- if (this.lastChangeValue && this.lastChangeValue === this.value)
4171
- return;
4172
- this.lastChangeValue = this.value;
4180
+ changeEvent(event, element) {
4173
4181
  super.change(event, element);
4174
4182
  this.helperValue = '';
4175
4183
  this.hint = this.previousHint;
4176
4184
  this.persistentHint = this.previousPersistentHint;
4177
4185
  }
4186
+ change(event, element, callEvent = true) {
4187
+ if (this.lastChangeValue && this.lastChangeValue === this.value)
4188
+ return;
4189
+ this.lastChangeValue = this.value;
4190
+ if (callEvent)
4191
+ this.changeEvent(event, element);
4192
+ }
4178
4193
  }
4179
4194
  core.FormatterParserProvider.registerFormatter('ZdDate', (value, { dateFormat = core.Config.dateFormat, displayFormat = core.Config.displayFormat, inputFormat = core.Config.dateInputFormat, mask = '', initialMask, isSimpleDisplay = false, } = {}) => {
4180
4195
  if (!value) {
@@ -5568,7 +5583,7 @@
5568
5583
  * @param props Iterable properties
5569
5584
  */
5570
5585
  constructor(props) {
5571
- var _a, _b;
5586
+ var _a;
5572
5587
  super(props);
5573
5588
  /**
5574
5589
  * Iterable columns
@@ -5599,12 +5614,26 @@
5599
5614
  this.defaultSearchVisibleOnly = (_a = core.Config.iterableSearchVisibleOnly) !== null && _a !== void 0 ? _a : true;
5600
5615
  this.columns = this.getColumns(props.columns || this.columns);
5601
5616
  this.createController();
5602
- this.datasource = core.DatasourceFactory.factory(Object.assign(Object.assign({}, props.datasource), { searchIn: ((_b = props.datasource) === null || _b === void 0 ? void 0 : _b.searchIn) || `{{IterableController_${this.name}.searchIn}}` }));
5617
+ this.initializeDatasource(props);
5603
5618
  this.pageSizes = this.getInitValue('pageSizes', props.pageSizes, this.pageSizes);
5604
5619
  this.searchVisibleOnly = this.getInitValue('searchVisibleOnly', props.searchVisibleOnly, this.defaultSearchVisibleOnly);
5605
5620
  this.virtualScroll = this.getInitValue('virtualScroll', props.virtualScroll, this.virtualScroll);
5606
5621
  this.virtualScrollCache = this.getInitValue('virtualScrollCache', props.virtualScrollCache, this.virtualScrollCache);
5607
5622
  }
5623
+ getDatasourceDefaults() {
5624
+ return {};
5625
+ }
5626
+ initializeDatasource(props) {
5627
+ var _a;
5628
+ let datasourceProps = props.datasource;
5629
+ // if using accessor, get props from the controller
5630
+ if (typeof props.datasource === 'string' && core.Accessor.isAccessorDefinition(props.datasource)) {
5631
+ const [controller, accessor] = core.Accessor.getAccessor(props.datasource);
5632
+ const instance = core.Loader.getInstance(controller);
5633
+ datasourceProps = instance[accessor];
5634
+ }
5635
+ this.datasource = core.DatasourceFactory.factory(Object.assign(Object.assign(Object.assign({}, datasourceProps), this.getDatasourceDefaults()), { searchIn: ((_a = props.datasource) === null || _a === void 0 ? void 0 : _a.searchIn) || `{{IterableController_${this.name}.searchIn}}` }));
5636
+ }
5608
5637
  createController() {
5609
5638
  const controller = new IterableController(this);
5610
5639
  core.Loader.addController(`IterableController_${this.name}`, controller);
@@ -6908,7 +6937,10 @@
6908
6937
  }
6909
6938
  let allValid = true;
6910
6939
  this.datasource.data.forEach((row) => this.columns.forEach((column) => {
6911
- if (!column.isVisible || !column.editable)
6940
+ const rowKey = row[this.datasource.uniqueKey];
6941
+ const cellsApplied = (this.cellsApplied[rowKey] || {})[column.name];
6942
+ const columnWithConditions = Object.assign(Object.assign({}, column), cellsApplied);
6943
+ if (!column.isVisible || !columnWithConditions.editable)
6912
6944
  return;
6913
6945
  if (!this.isValid(column, row, true))
6914
6946
  allValid = false;
@@ -7744,10 +7776,9 @@
7744
7776
  }
7745
7777
  set search(value) {
7746
7778
  this.searchValue = value || '';
7747
- const searchValue = this.dataTextDiscrete.length === 0
7748
- ? this.formatter(this.selectValue)
7749
- : this.formatter(this.selectValue, this.discreteProps);
7750
- if (this.searchValue === '' || this.searchValue !== searchValue) {
7779
+ const searchValue = this.formatter(this.selectValue);
7780
+ const searchDiscrete = this.formatter(this.selectValue, this.discreteProps);
7781
+ if (this.searchValue === '' || (this.searchValue !== searchValue && this.searchValue !== searchDiscrete)) {
7751
7782
  this.dirtySearchValue = this.searchValue;
7752
7783
  if (this.isFocused)
7753
7784
  this.debounceSearch(this.searchValue);
@@ -12899,7 +12930,7 @@
12899
12930
  */
12900
12931
  constructor(props) {
12901
12932
  var _a;
12902
- super(Object.assign(Object.assign({}, props), { datasource: Object.assign(Object.assign({}, props.datasource), { lazyLoad: true, loadAll: true }) }));
12933
+ super(props);
12903
12934
  /**
12904
12935
  * Parent field name
12905
12936
  */
@@ -12954,6 +12985,9 @@
12954
12985
  this.treeDataStructure = new TreeDataStructure(this);
12955
12986
  this.createAccessors();
12956
12987
  }
12988
+ getDatasourceDefaults() {
12989
+ return { lazyLoad: true, loadAll: true };
12990
+ }
12957
12991
  onMounted(element) {
12958
12992
  super.onMounted(element);
12959
12993
  if (!this.lazyLoad || this.datasource.data.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.97.0",
3
+ "version": "1.97.1",
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": "4cbf0b1966af294da09421e7bfc7e28f7e42d14c"
46
+ "gitHead": "be2b1ea788cbea322e237b4360caf19b1125a5eb"
47
47
  }
@@ -96,6 +96,8 @@ export declare class Date extends TextInput implements IDate {
96
96
  * @param element
97
97
  */
98
98
  selectDate(date: string, event?: Event, element?: any): void;
99
+ get value(): any;
100
+ set value(value: any);
99
101
  get displayValue(): string;
100
102
  set displayValue(newValue: string);
101
103
  /**
@@ -147,5 +149,6 @@ export declare class Date extends TextInput implements IDate {
147
149
  private previousPersistentHint;
148
150
  updateHelperHint(): void;
149
151
  private lastChangeValue;
150
- change(event?: Event, element?: any): void;
152
+ changeEvent(event?: Event, element?: any): void;
153
+ change(event?: Event, element?: any, callEvent?: boolean): void;
151
154
  }
@@ -50,6 +50,8 @@ export declare class Iterable extends ComponentRender implements IIterable {
50
50
  * @param props Iterable properties
51
51
  */
52
52
  constructor(props: IIterable);
53
+ protected getDatasourceDefaults(): {};
54
+ protected initializeDatasource(props: IIterable): void;
53
55
  protected createController(): void;
54
56
  /**
55
57
  * Retrieves columns instances
@@ -49,6 +49,10 @@ export declare class TreeGrid extends Grid implements ITreeGrid {
49
49
  * @param props Tree Grid properties
50
50
  */
51
51
  constructor(props: ITreeGrid);
52
+ protected getDatasourceDefaults(): {
53
+ lazyLoad: boolean;
54
+ loadAll: boolean;
55
+ };
52
56
  private navigationTreeKeyMapping;
53
57
  onMounted(element: any): void;
54
58
  /**
@@ -1,12 +0,0 @@
1
- export interface IJSONObject {
2
- path: string;
3
- }
4
- export declare class JsonCacheService {
5
- /**
6
- * jsons collection
7
- */
8
- static jsonCollection: IJSONObject[];
9
- static saveJSONCache(jsonCollection: IJSONObject[]): Promise<void>;
10
- static getJSONCache(path: string): any;
11
- static clearJSONCache(jsonCollection: IJSONObject[]): void;
12
- }