@zeedhi/common 1.95.1 → 1.96.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.
@@ -1,4 +1,4 @@
1
- import { AccessorManager, Event, KeyMap, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, MethodNotAssignedError, Loader, Config, dayjs, Utils, DateHelper, Router, InstanceNotFoundError, MemoryDatasource, Cookie, Http, URL as URL$1, VersionService } from '@zeedhi/core';
1
+ import { AccessorManager, Event, KeyMap, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, MethodNotAssignedError, Loader, Config, dayjs, Utils, DateHelper, Router, InstanceNotFoundError, ViewService, MemoryDatasource, Cookie, Http, URL as URL$1, VersionService } from '@zeedhi/core';
2
2
  import merge from 'lodash.merge';
3
3
  import cloneDeep from 'lodash.clonedeep';
4
4
  import debounce from 'lodash.debounce';
@@ -1975,7 +1975,9 @@ class Input extends ComponentRender {
1975
1975
  */
1976
1976
  addValidation(name, config) {
1977
1977
  const validation = Validation.get(name)(config);
1978
- this.validations[name] = config;
1978
+ if (config) {
1979
+ this.validations[name] = config;
1980
+ }
1979
1981
  this.parsedValidations[name] = validation;
1980
1982
  this.updateRules();
1981
1983
  }
@@ -2001,7 +2003,10 @@ class Input extends ComponentRender {
2001
2003
  */
2002
2004
  updateRules() {
2003
2005
  this.rules = Object.values(this.parsedValidations)
2004
- .map((validation) => () => validation(this.value));
2006
+ .map((validation) => (value) => {
2007
+ const testValue = value !== undefined ? value : this.value;
2008
+ return validation(testValue);
2009
+ });
2005
2010
  }
2006
2011
  /**
2007
2012
  * Input value.
@@ -2054,8 +2059,11 @@ class Input extends ComponentRender {
2054
2059
  * Checks the input value are valid to all applied rules.
2055
2060
  * @returns Input is valid
2056
2061
  */
2057
- isValid() {
2058
- return this.rules.every((rule) => typeof rule(this.value) !== 'string');
2062
+ isValid(value) {
2063
+ return this.rules.every((rule) => {
2064
+ const testValue = value !== undefined ? value : this.value;
2065
+ return typeof rule(testValue) !== 'string';
2066
+ });
2059
2067
  }
2060
2068
  /**
2061
2069
  * Triggered when the input value changes.
@@ -2140,6 +2148,19 @@ class Toggleable extends Input {
2140
2148
  }
2141
2149
  }
2142
2150
 
2151
+ class InputFactory {
2152
+ static register(className, inputClass) {
2153
+ if (!this.inputClasses[className])
2154
+ this.inputClasses[className] = inputClass;
2155
+ }
2156
+ static factory(props) {
2157
+ if (!this.inputClasses[props.component])
2158
+ return undefined;
2159
+ return new this.inputClasses[props.component](props);
2160
+ }
2161
+ }
2162
+ InputFactory.inputClasses = {};
2163
+
2143
2164
  /**
2144
2165
  * Base class for Checkbox component.
2145
2166
  */
@@ -2154,7 +2175,8 @@ class Checkbox extends Toggleable {
2154
2175
  this.showHelper = false;
2155
2176
  this.createAccessors();
2156
2177
  }
2157
- }
2178
+ }
2179
+ InputFactory.register('ZdCheckbox', Checkbox);
2158
2180
 
2159
2181
  /**
2160
2182
  * Base class for Checkbox multiple component.
@@ -2207,7 +2229,8 @@ class CheckboxMultiple extends Input {
2207
2229
  super.onBeforeDestroy();
2208
2230
  this.datasource.destroy();
2209
2231
  }
2210
- }
2232
+ }
2233
+ InputFactory.register('ZdCheckboxMultiple', CheckboxMultiple);
2211
2234
 
2212
2235
  /**
2213
2236
  * Base class for Chip component.
@@ -2694,10 +2717,15 @@ class TextInput extends Input {
2694
2717
  * Defines text input value should concat the suffix text.
2695
2718
  */
2696
2719
  this.valueWithSuffix = textInputDefaults.valueWithSuffix;
2720
+ /**
2721
+ * Defines clicks on outer icon should focus the component.
2722
+ */
2723
+ this.focusOnOuterIconClick = true;
2697
2724
  this.formatterFn = FormatterParserProvider.getFormatter('ZdTextInput');
2698
2725
  this.parserFn = FormatterParserProvider.getParser('ZdTextInput');
2699
2726
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, this.appendIcon);
2700
2727
  this.appendOuterIcon = this.getInitValue('appendOuterIcon', props.appendOuterIcon, this.appendOuterIcon);
2728
+ this.focusOnOuterIconClick = this.getInitValue('focusOnOuterIconClick', props.focusOnOuterIconClick, this.focusOnOuterIconClick);
2701
2729
  this.prefix = this.getInitValue('prefix', props.prefix, this.prefix);
2702
2730
  this.prependIcon = this.getInitValue('prependIcon', props.prependIcon, this.prependIcon);
2703
2731
  this.prependOuterIcon = this.getInitValue('prependOuterIcon', props.prependOuterIcon, this.prependOuterIcon);
@@ -2803,7 +2831,8 @@ FormatterParserProvider.registerParser('ZdTextInput', (value, { valueWithPrefix
2803
2831
  formatted = prefixValue + formatted + suffixValue;
2804
2832
  }
2805
2833
  return formatted;
2806
- });
2834
+ });
2835
+ InputFactory.register('ZdTextInput', TextInput);
2807
2836
 
2808
2837
  /**
2809
2838
  * Base class for Number component
@@ -2913,7 +2942,8 @@ FormatterParserProvider.registerParser('ZdNumber', (value, { mask = {}, } = {})
2913
2942
  let maskValue = typeof (maskDef) === 'function' ? maskDef(AutoNumeric.format(value)) : maskDef;
2914
2943
  maskValue = Object.assign(Object.assign({}, Config.masks.numberMask), maskValue);
2915
2944
  return value === '' ? null : AutoNumeric.unformat(value, maskValue);
2916
- });
2945
+ });
2946
+ InputFactory.register('ZdNumber', Number$1);
2917
2947
 
2918
2948
  /**
2919
2949
  * Base class for Currency component
@@ -2949,7 +2979,8 @@ FormatterParserProvider.registerParser('ZdCurrency', (value, { mask = {}, } = {}
2949
2979
  let maskValue = typeof (maskDef) === 'function' ? maskDef(AutoNumeric.format(value)) : maskDef;
2950
2980
  maskValue = Object.assign(Object.assign(Object.assign({}, Config.masks.numberMask), Config.masks.currencyMask), maskValue);
2951
2981
  return value === '' ? null : AutoNumeric.unformat(value, maskValue);
2952
- });
2982
+ });
2983
+ InputFactory.register('ZdCurrency', Currency);
2953
2984
 
2954
2985
  class AlertQueue {
2955
2986
  constructor() {
@@ -4207,7 +4238,8 @@ FormatterParserProvider.registerParser('ZdDateTime', (value, { dateTimeFormat =
4207
4238
  return dayjs(value, displayFormat).format(dateTimeFormat);
4208
4239
  }
4209
4240
  return value;
4210
- });
4241
+ });
4242
+ InputFactory.register('ZdDate', Date$1);
4211
4243
 
4212
4244
  class DateRange extends TextInput {
4213
4245
  /* istanbul ignore next */
@@ -4671,7 +4703,8 @@ FormatterParserProvider.registerParser('ZdDateRange', (value, { dateFormat = Con
4671
4703
  }
4672
4704
  });
4673
4705
  return formattedValue;
4674
- });
4706
+ });
4707
+ InputFactory.register('ZdDateRange', DateRange);
4675
4708
 
4676
4709
  /**
4677
4710
  * Base class for Divider component.
@@ -4933,7 +4966,41 @@ class FileInput extends TextInput {
4933
4966
  }
4934
4967
  }
4935
4968
  }
4936
- }
4969
+ setViewGetFileSizes(getFileSizes) {
4970
+ this.viewGetFileSizes = getFileSizes;
4971
+ }
4972
+ updateRules() {
4973
+ this.rules = Object.keys(this.parsedValidations)
4974
+ .map((key) => {
4975
+ const validation = this.parsedValidations[key];
4976
+ if (key !== 'maxFileSize')
4977
+ return (value) => {
4978
+ const testValue = value !== undefined ? value : this.value;
4979
+ return validation(testValue);
4980
+ };
4981
+ return () => {
4982
+ if (this.viewGetFileSizes) {
4983
+ const fileSizes = this.viewGetFileSizes();
4984
+ return validation(fileSizes);
4985
+ }
4986
+ return true;
4987
+ };
4988
+ });
4989
+ }
4990
+ }
4991
+ Validation.register('maxFileSize', (config) => (fileSizes) => {
4992
+ let fileError = '';
4993
+ Object.keys(fileSizes).some((fileName) => {
4994
+ if (fileSizes[fileName] > config.limit) {
4995
+ fileError = fileName;
4996
+ return true;
4997
+ }
4998
+ return false;
4999
+ });
5000
+ const message = I18n.translate((config.message || 'VALIDATION_FILE_SIZE'), { fileError });
5001
+ return (fileError === '') || message;
5002
+ });
5003
+ InputFactory.register('ZdFileInput', FileInput);
4937
5004
 
4938
5005
  /**
4939
5006
  * Base class for Footer component.
@@ -5976,7 +6043,7 @@ class Grid extends Iterable {
5976
6043
  },
5977
6044
  tab: {
5978
6045
  event: this.navigateRight.bind(this),
5979
- prevent: true,
6046
+ prevent: false,
5980
6047
  active: true,
5981
6048
  index: 99,
5982
6049
  input: true,
@@ -5984,7 +6051,7 @@ class Grid extends Iterable {
5984
6051
  },
5985
6052
  'shift+tab': {
5986
6053
  event: this.navigateLeft.bind(this),
5987
- prevent: true,
6054
+ prevent: false,
5988
6055
  active: true,
5989
6056
  index: 99,
5990
6057
  input: true,
@@ -6235,51 +6302,58 @@ class Grid extends Iterable {
6235
6302
  arrSelection.splice(index, 1);
6236
6303
  }
6237
6304
  }
6238
- navigateLeft() {
6305
+ navigateLeft({ event }) {
6239
6306
  if (!this.viewNavigate)
6240
6307
  return;
6241
- this.viewNavigate('left');
6308
+ this.viewNavigate('left', event);
6242
6309
  }
6243
- navigateRight() {
6310
+ navigateRight({ event }) {
6244
6311
  if (!this.viewNavigate)
6245
6312
  return;
6246
- this.viewNavigate('right');
6313
+ this.viewNavigate('right', event);
6247
6314
  }
6248
6315
  navigateUp() {
6249
- if (this.cellSelection && this.viewNavigate) {
6250
- this.viewNavigate('up');
6251
- return;
6252
- }
6253
- const { uniqueKey, currentRow } = this.datasource;
6254
- const rowIndex = this.datasource.data.findIndex((row) => row[uniqueKey] === currentRow[uniqueKey]);
6255
- if (rowIndex === -1) {
6256
- this.datasource.currentRow = this.datasource.data[this.datasource.data.length - 1];
6257
- [this.currentColumn] = this.columns;
6258
- return;
6259
- }
6260
- if (rowIndex === 0) {
6261
- this.navigatePageDown();
6316
+ if (!this.viewNavigate)
6262
6317
  return;
6263
- }
6264
- this.datasource.currentRow = this.datasource.data[rowIndex - 1];
6318
+ this.viewNavigate('up');
6265
6319
  }
6266
6320
  navigateDown() {
6267
- if (this.cellSelection && this.viewNavigate) {
6268
- this.viewNavigate('down');
6321
+ if (!this.viewNavigate)
6269
6322
  return;
6270
- }
6323
+ this.viewNavigate('down');
6324
+ }
6325
+ navigateDatasource(up) {
6271
6326
  const { uniqueKey, currentRow } = this.datasource;
6272
6327
  const rowIndex = this.datasource.data.findIndex((row) => row[uniqueKey] === currentRow[uniqueKey]);
6273
6328
  if (rowIndex === -1) {
6274
- [this.datasource.currentRow] = this.datasource.data;
6275
- [this.currentColumn] = this.columns;
6276
- return;
6329
+ return this.navigateInitial(up);
6330
+ }
6331
+ if (up && rowIndex === 0) {
6332
+ return this.navigatePageDown();
6277
6333
  }
6278
- if (rowIndex === this.datasource.data.length - 1) {
6279
- this.navigatePageUp();
6334
+ if (!up && rowIndex === this.datasource.data.length - 1) {
6335
+ return this.navigatePageUp();
6336
+ }
6337
+ return this.navigateCurrentRow(up, rowIndex);
6338
+ }
6339
+ navigateCurrentRow(up, rowIndex) {
6340
+ const addIndex = up ? -1 : 1;
6341
+ this.datasource.currentRow = this.datasource.data[rowIndex + addIndex];
6342
+ }
6343
+ navigateInitial(up) {
6344
+ if (up) {
6345
+ this.navigateLast();
6280
6346
  return;
6281
6347
  }
6282
- this.datasource.currentRow = this.datasource.data[rowIndex + 1];
6348
+ this.navigateFirst();
6349
+ }
6350
+ navigateFirst() {
6351
+ [this.datasource.currentRow] = this.datasource.data;
6352
+ [this.currentColumn] = this.columns;
6353
+ }
6354
+ navigateLast() {
6355
+ this.datasource.currentRow = this.datasource.data[this.datasource.data.length - 1];
6356
+ [this.currentColumn] = this.columns;
6283
6357
  }
6284
6358
  navigatePageUp() {
6285
6359
  if (this.datasource.page < Math.ceil(this.datasource.total / this.datasource.limit)) {
@@ -6814,6 +6888,9 @@ class GridEditable extends Grid {
6814
6888
  if (!revalidate) {
6815
6889
  return Object.keys(this.invalidComponents).length === 0;
6816
6890
  }
6891
+ if (!this.editing) {
6892
+ return this.isViewGridValid();
6893
+ }
6817
6894
  let allValid = true;
6818
6895
  this.datasource.data.forEach((row) => this.columns.forEach((column) => {
6819
6896
  if (!column.isVisible || !column.editable)
@@ -6823,6 +6900,38 @@ class GridEditable extends Grid {
6823
6900
  }));
6824
6901
  return allValid;
6825
6902
  }
6903
+ /**
6904
+ * Checks whether the grid is valid while not in editing mode
6905
+ */
6906
+ isViewGridValid(forceEditing = true) {
6907
+ const invalidCompNames = [];
6908
+ const componentInstances = {};
6909
+ const editableColumns = this.columns.filter((column) => column.editable && column.isVisible);
6910
+ editableColumns.forEach((column) => {
6911
+ const compName = this.getCompName('temp', column.name);
6912
+ const componentProps = Object.assign(Object.assign({}, column.componentProps), { name: compName });
6913
+ componentInstances[column.name] = InputFactory.factory(componentProps);
6914
+ });
6915
+ this.datasource.data.forEach((row) => {
6916
+ const key = row[this.datasource.uniqueKey];
6917
+ editableColumns.forEach((column) => {
6918
+ const instance = componentInstances[column.name];
6919
+ if (!instance.isValid(row[column.name])) {
6920
+ invalidCompNames.push(this.getCompName(key, column.name));
6921
+ }
6922
+ });
6923
+ });
6924
+ if (invalidCompNames.length > 0 && forceEditing) {
6925
+ this.editing = true;
6926
+ ViewService.nextTick(() => {
6927
+ invalidCompNames.forEach((compName) => {
6928
+ const invalidComponent = Metadata.getInstance(compName);
6929
+ invalidComponent.validate();
6930
+ });
6931
+ });
6932
+ }
6933
+ return invalidCompNames.length === 0;
6934
+ }
6826
6935
  /**
6827
6936
  * Adds new row to the datasource data and pushes it to the editedRows
6828
6937
  * @param row Row
@@ -7308,7 +7417,8 @@ class Increment extends Number$1 {
7308
7417
  this.value -= this.step;
7309
7418
  }
7310
7419
  }
7311
- }
7420
+ }
7421
+ InputFactory.register('ZdIncrement', Increment);
7312
7422
 
7313
7423
  class IterableColumnsButtonController {
7314
7424
  constructor(iterableComponent) {
@@ -7499,6 +7609,12 @@ class Select extends TextInput {
7499
7609
  [searchIn]: value,
7500
7610
  },
7501
7611
  }),
7612
+ DYNAMIC_FILTER: (value, search_in) => {
7613
+ const arrayValue = Array.isArray(value) ? value : Array.of(value);
7614
+ const filter = arrayValue.map((item) => ({ operation: 'EQUALS', relation: 'OR', value: item }));
7615
+ const dynamicFilter = { [search_in]: filter };
7616
+ return { dynamicFilter };
7617
+ },
7502
7618
  };
7503
7619
  /**
7504
7620
  * Input search value
@@ -7641,13 +7757,16 @@ class Select extends TextInput {
7641
7757
  */
7642
7758
  getItemsBySearchValue(value, searchIn) {
7643
7759
  return __awaiter(this, void 0, void 0, function* () {
7644
- const config = Object.assign(Object.assign(Object.assign({}, this.datasource.clone()), this.dsSearch[this.searchParam](value, searchIn)), { lazyLoad: true });
7760
+ const config = Object.assign(Object.assign(Object.assign({}, this.datasource.clone()), this.dsSearch[this.searchParam](value, searchIn)), { lazyLoad: true, loadAll: Array.isArray(value) });
7645
7761
  this.datasource.loading = true;
7646
7762
  const datasource = DatasourceFactory.factory(config);
7647
7763
  const items = yield datasource.get();
7648
7764
  this.datasource.loading = false;
7649
7765
  datasource.destroy();
7650
- return items.find(this.getCondition(value));
7766
+ if (Array.isArray(value)) {
7767
+ return items.filter((item) => value.includes(item[this.dataValue]));
7768
+ }
7769
+ return items.filter(this.getCondition(value));
7651
7770
  });
7652
7771
  }
7653
7772
  getCondition(filterValue) {
@@ -7752,7 +7871,7 @@ class Select extends TextInput {
7752
7871
  const foundInData = this.datasource.data.find(this.getCondition(filterValue));
7753
7872
  let searchValue = foundInData;
7754
7873
  if (!foundInData && !this.manualMode) {
7755
- searchValue = yield this.getItemsBySearchValue(filterValue, searchIn);
7874
+ [searchValue] = yield this.getItemsBySearchValue(filterValue, searchIn);
7756
7875
  }
7757
7876
  if (!searchValue) {
7758
7877
  this.setFieldRowValue(null);
@@ -7984,7 +8103,8 @@ FormatterParserProvider.registerFormatter('ZdSelect', (value, { dataText, dataTe
7984
8103
  }
7985
8104
  return result;
7986
8105
  }, '');
7987
- });
8106
+ });
8107
+ InputFactory.register('ZdSelect', Select);
7988
8108
 
7989
8109
  /**
7990
8110
  * Base class for Iterable Page Size component
@@ -8151,7 +8271,8 @@ class Search extends TextInput {
8151
8271
  yield this.iterableComponent.setSearch(search);
8152
8272
  });
8153
8273
  }
8154
- }
8274
+ }
8275
+ InputFactory.register('ZdSearch', Search);
8155
8276
 
8156
8277
  /**
8157
8278
  * Base class for IterableComponentRender component.
@@ -9409,12 +9530,14 @@ class Modal extends Component {
9409
9530
  */
9410
9531
  show() {
9411
9532
  this.isVisible = true;
9533
+ ViewService.nextTick(() => this.callEvent('onShow', { component: this }));
9412
9534
  }
9413
9535
  /**
9414
9536
  * Closes modal
9415
9537
  */
9416
9538
  hide() {
9417
9539
  this.isVisible = false;
9540
+ ViewService.nextTick(() => this.callEvent('onHide', { component: this }));
9418
9541
  }
9419
9542
  }
9420
9543
 
@@ -9585,7 +9708,8 @@ class Password extends TextInput {
9585
9708
  }
9586
9709
  }
9587
9710
  }
9588
- FormatterParserProvider.registerFormatter('ZdPassword', (value) => (value || '').replace(/./g, '*'));
9711
+ FormatterParserProvider.registerFormatter('ZdPassword', (value) => (value || '').replace(/./g, '*'));
9712
+ InputFactory.register('ZdPassword', Password);
9589
9713
 
9590
9714
  /**
9591
9715
  * Base class for Progress component
@@ -9680,7 +9804,8 @@ class Radio extends Input {
9680
9804
  super.onBeforeDestroy();
9681
9805
  this.datasource.destroy();
9682
9806
  }
9683
- }
9807
+ }
9808
+ InputFactory.register('ZdRadio', Radio);
9684
9809
 
9685
9810
  /**
9686
9811
  * Base class for Range Slider component
@@ -9777,7 +9902,8 @@ class RangeSlider extends Input {
9777
9902
  set value(value) {
9778
9903
  this.rangeSliderValue = value;
9779
9904
  }
9780
- }
9905
+ }
9906
+ InputFactory.register('ZdRangeSlider', RangeSlider);
9781
9907
 
9782
9908
  /**
9783
9909
  * Base class for Row component.
@@ -9852,12 +9978,16 @@ class SelectMultiple extends Select {
9852
9978
  */
9853
9979
  this.limit = null;
9854
9980
  this.showSelectAll = false;
9981
+ this.showCheckboxAll = false;
9982
+ this.checkboxAllValue = false;
9855
9983
  if (!this.selectedValue) {
9856
9984
  this.selectedValue = [];
9857
9985
  }
9858
9986
  this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
9859
9987
  this.maxRows = this.getInitValue('maxRows', props.maxRows, this.maxRows);
9860
9988
  this.limit = this.getInitValue('limit', props.limit, this.limit);
9989
+ this.showCheckboxAll = this.getInitValue('showCheckboxAll', props.showCheckboxAll, this.showCheckboxAll);
9990
+ this.checkboxAll = this.getInitValue('checkboxAll', props.checkboxAll, this.checkboxAll);
9861
9991
  if (!Array.isArray(this.dataText))
9862
9992
  this.dataText = [this.dataText];
9863
9993
  this.internalDisplayValue = this.getDisplayValue();
@@ -9887,6 +10017,13 @@ class SelectMultiple extends Select {
9887
10017
  this.selectedValue = rows;
9888
10018
  this.setFieldValue(this.getValues(rows));
9889
10019
  }
10020
+ get checkboxAll() {
10021
+ return this.checkboxAllValue;
10022
+ }
10023
+ set checkboxAll(value) {
10024
+ this.disabled = value;
10025
+ this.checkboxAllValue = value;
10026
+ }
9890
10027
  /**
9891
10028
  * Removes item from array a and add it to array b if condition is satisfied
9892
10029
  */
@@ -9898,8 +10035,8 @@ class SelectMultiple extends Select {
9898
10035
  }
9899
10036
  setFieldValue(value) {
9900
10037
  return __awaiter(this, void 0, void 0, function* () {
9901
- const promises = [];
9902
- const searchValues = [];
10038
+ const foundValues = [];
10039
+ const searchedValues = [];
9903
10040
  let pushed = false;
9904
10041
  value.forEach((row) => {
9905
10042
  let filterValue;
@@ -9909,27 +10046,37 @@ class SelectMultiple extends Select {
9909
10046
  else {
9910
10047
  filterValue = row;
9911
10048
  }
9912
- const searchIn = this.dataValue;
9913
10049
  const foundInData = this.datasource.data.find(this.getCondition(filterValue));
9914
10050
  if (foundInData) {
9915
- searchValues.push(foundInData);
10051
+ foundValues.push(foundInData);
9916
10052
  }
9917
10053
  else if (!this.manualMode) {
9918
- promises.push(this.getItemsBySearchValue(filterValue, searchIn).then((item) => {
9919
- if (item) {
9920
- searchValues.push(item);
9921
- this.datasource.data.unshift(item);
9922
- this.insertedValues.push(item);
9923
- pushed = true;
9924
- }
9925
- }));
10054
+ searchedValues.push(filterValue);
9926
10055
  }
9927
10056
  });
9928
- if (promises.length) {
10057
+ const insertItem = (item) => __awaiter(this, void 0, void 0, function* () {
10058
+ if (!item)
10059
+ return;
10060
+ foundValues.push(item);
10061
+ this.datasource.data.unshift(item);
10062
+ this.insertedValues.push(item);
10063
+ pushed = true;
10064
+ });
10065
+ // using filter/find/dynamicFilter should make only 1 request
10066
+ // using normal search should make one request per search value
10067
+ if (this.searchParam !== 'SEARCH') {
10068
+ const items = yield this.getItemsBySearchValue(searchedValues, this.dataValue);
10069
+ items.forEach(insertItem);
10070
+ }
10071
+ else {
10072
+ const promises = searchedValues.map((searchedValue) => __awaiter(this, void 0, void 0, function* () {
10073
+ const [item] = yield this.getItemsBySearchValue(searchedValue, this.dataValue);
10074
+ insertItem(item);
10075
+ }));
9929
10076
  yield Promise.all(promises);
9930
10077
  }
9931
- if (searchValues.length > 0) {
9932
- this.setFieldRowValue(searchValues);
10078
+ if (foundValues.length > 0) {
10079
+ this.setFieldRowValue(foundValues);
9933
10080
  }
9934
10081
  else {
9935
10082
  this.setFieldRowValue([]);
@@ -10178,6 +10325,19 @@ class SelectMultiple extends Select {
10178
10325
  }
10179
10326
  this.cachedTotal = this.datasource.total;
10180
10327
  }
10328
+ /**
10329
+ * Updates input rules.
10330
+ */
10331
+ updateRules() {
10332
+ this.rules = Object.keys(this.parsedValidations)
10333
+ .map((key) => (value) => {
10334
+ const testValue = value !== undefined ? value : this.value;
10335
+ const validation = this.parsedValidations[key];
10336
+ if (key !== 'required')
10337
+ return validation(testValue);
10338
+ return validation((this.checkboxAll && 'all') || testValue);
10339
+ });
10340
+ }
10181
10341
  }
10182
10342
 
10183
10343
  class TreeDataStructure {
@@ -11005,7 +11165,8 @@ class SelectTree extends TextInput {
11005
11165
  this.setValue(filteredNode.id);
11006
11166
  }
11007
11167
  }
11008
- }
11168
+ }
11169
+ InputFactory.register('ZdSelectTree', SelectTree);
11009
11170
 
11010
11171
  /**
11011
11172
  * Base class for Select Tree Multiple component.
@@ -11455,7 +11616,8 @@ class Switch extends Toggleable {
11455
11616
  this.inset = this.getInitValue('inset', props.inset, this.inset);
11456
11617
  this.createAccessors();
11457
11618
  }
11458
- }
11619
+ }
11620
+ InputFactory.register('ZdSwitch', Switch);
11459
11621
 
11460
11622
  /**
11461
11623
  * Base class for Table component.
@@ -11793,7 +11955,8 @@ class Textarea extends TextInput {
11793
11955
  this.addValidation('maxLength', { limit: parseInt(this.counter.toString(), 10) });
11794
11956
  }
11795
11957
  }
11796
- }
11958
+ }
11959
+ InputFactory.register('ZdTextarea', Textarea);
11797
11960
 
11798
11961
  /**
11799
11962
  * Selects the time format by the rule:
@@ -12181,7 +12344,8 @@ FormatterParserProvider.registerParser('ZdTime', (value, { displayFormat = Confi
12181
12344
  }
12182
12345
  }
12183
12346
  return value;
12184
- });
12347
+ });
12348
+ InputFactory.register('ZdTime', Time);
12185
12349
 
12186
12350
  /**
12187
12351
  * Base class for Tooltip component.
@@ -12826,45 +12990,28 @@ class TreeGrid extends Grid {
12826
12990
  navigateToggle(collapse) {
12827
12991
  this.treeDataStructure.navigateToggle(collapse);
12828
12992
  }
12829
- /**
12830
- * Navigate upwards
12831
- */
12832
- navigateUp() {
12833
- if (this.cellSelection && this.viewNavigate) {
12834
- this.viewNavigate('up');
12835
- return;
12836
- }
12993
+ navigateDatasource(up) {
12837
12994
  const { uniqueKey, currentRow } = this.datasource;
12838
12995
  const rowIndex = this.treeDataStructure.findDataIndex(this.datasource.data, currentRow[uniqueKey]);
12839
- if (rowIndex === -1) {
12840
- const lastOpenedRowIdx = this.treeDataStructure.previousOpenedRow(this.datasource.data.length);
12841
- this.datasource.currentRow = this.datasource.data[lastOpenedRowIdx];
12842
- }
12843
- else {
12996
+ if (up) {
12997
+ if (rowIndex === -1) {
12998
+ const lastOpenedRowIdx = this.treeDataStructure.previousOpenedRow(this.datasource.data.length);
12999
+ this.datasource.currentRow = this.datasource.data[lastOpenedRowIdx];
13000
+ return;
13001
+ }
12844
13002
  const previousRowIdx = this.treeDataStructure.previousOpenedRow(rowIndex);
12845
13003
  if (previousRowIdx > -1) {
12846
13004
  this.datasource.currentRow = this.datasource.data[previousRowIdx];
12847
13005
  }
12848
- }
12849
- }
12850
- /**
12851
- * Navigate downwards
12852
- */
12853
- navigateDown() {
12854
- if (this.cellSelection && this.viewNavigate) {
12855
- this.viewNavigate('down');
12856
13006
  return;
12857
13007
  }
12858
- const { uniqueKey, currentRow } = this.datasource;
12859
- const rowIndex = this.treeDataStructure.findDataIndex(this.datasource.data, currentRow[uniqueKey]);
12860
13008
  if (rowIndex === -1) {
12861
13009
  [this.datasource.currentRow] = this.datasource.data;
13010
+ return;
12862
13011
  }
12863
- else {
12864
- const nextRowIdx = this.treeDataStructure.nextOpenedRow(rowIndex);
12865
- if (nextRowIdx > -1) {
12866
- this.datasource.currentRow = this.datasource.data[nextRowIdx];
12867
- }
13012
+ const nextRowIdx = this.treeDataStructure.nextOpenedRow(rowIndex);
13013
+ if (nextRowIdx > -1) {
13014
+ this.datasource.currentRow = this.datasource.data[nextRowIdx];
12868
13015
  }
12869
13016
  }
12870
13017
  removeDuplicates(arr, key) {
@@ -14591,6 +14738,52 @@ class XLS3Report extends BaseReport {
14591
14738
  }
14592
14739
  }
14593
14740
 
14741
+ /**
14742
+ * Class used to format grouped data into the ZhReports format
14743
+ */
14744
+ class GroupedPDFFormatter {
14745
+ format(data) {
14746
+ return data.map((item) => {
14747
+ if (this.isGroupHeader(item)) {
14748
+ return {
14749
+ __group: item.group,
14750
+ __groupHeader: item.groupHeader,
14751
+ __groupFooter: false,
14752
+ __groupIndex: item.groupIndex,
14753
+ __groupLabel: item.groupLabel,
14754
+ __groupValue: item.groupValue,
14755
+ __groupOpened: item.groupOpened,
14756
+ };
14757
+ }
14758
+ if (this.isGroupFooter(item)) {
14759
+ const groupKeys = ['groupFooter', 'groupIndex', 'groupHeaders', 'groupLabel', 'groupValue', 'groupSummary'];
14760
+ const totalColumnNames = Object.keys(item).filter((key) => !groupKeys.includes(key));
14761
+ const result = {
14762
+ __group: true,
14763
+ __groupFooter: item.groupFooter,
14764
+ __groupIndex: item.groupIndex,
14765
+ __groupLabel: item.groupLabel,
14766
+ __groupValue: item.groupValue,
14767
+ __groupSummary: !!item.groupSummary,
14768
+ };
14769
+ totalColumnNames.forEach((name) => {
14770
+ result[name] = item[name];
14771
+ });
14772
+ return result;
14773
+ }
14774
+ const dataItem = Object.assign({}, item);
14775
+ delete dataItem.groupHeaders;
14776
+ return dataItem;
14777
+ });
14778
+ }
14779
+ isGroupHeader(entry) {
14780
+ return entry.groupHeader === true;
14781
+ }
14782
+ isGroupFooter(entry) {
14783
+ return entry.groupFooter === true;
14784
+ }
14785
+ }
14786
+
14594
14787
  class Report {
14595
14788
  constructor(iterable, title) {
14596
14789
  this.endPoint = Config.reportsEndPoint;
@@ -14647,7 +14840,7 @@ class Report {
14647
14840
  const { route } = reportType;
14648
14841
  const { name, columns, datasource } = this.iterable;
14649
14842
  const { groupedData } = Object.assign({}, this.iterable);
14650
- const formattedColumns = this.removeColumns(columns);
14843
+ const formattedColumns = this.filterColumns(columns);
14651
14844
  const metadataObj = yield reportType.buildMetadata(name, this.title, formattedColumns, datasource.filter, portrait);
14652
14845
  let dataset;
14653
14846
  if ((reportType instanceof XLS2Report || reportType instanceof XLS3Report) && groupedData) {
@@ -14655,6 +14848,11 @@ class Report {
14655
14848
  const metadataObjClone = merge(rowMetadata, JSON.parse(metadataObj));
14656
14849
  dataset = reportType.buildDataset(groupedData, metadataObjClone);
14657
14850
  }
14851
+ else if (reportType instanceof PDFReport && groupedData && groupedData.length > 0) {
14852
+ const formatter = new GroupedPDFFormatter();
14853
+ const pdfGroupedData = formatter.format(groupedData);
14854
+ dataset = reportType.buildDataset(pdfGroupedData);
14855
+ }
14658
14856
  else {
14659
14857
  dataset = reportType.buildDataset(data, formattedColumns);
14660
14858
  }
@@ -14685,7 +14883,7 @@ class Report {
14685
14883
  return new URL(reportFile, this.fileEndPoint).href;
14686
14884
  });
14687
14885
  }
14688
- removeColumns(columns) {
14886
+ filterColumns(columns) {
14689
14887
  return columns.filter((item) => (item.type !== 'action' && item.isVisible));
14690
14888
  }
14691
14889
  }
@@ -14694,4 +14892,4 @@ const AutoNumeric = require('@zeedhi/autonumeric/dist/autoNumeric');
14694
14892
  const packageContent = require('../package.json');
14695
14893
  VersionService.addPackageVersion(packageContent.name, packageContent.version);
14696
14894
 
14697
- export { Alert, AlertService, ApexChart, AutoNumeric, Badge, Breadcrumbs, Button, ButtonGroup, CSVReport, Card, Carousel, Checkbox, CheckboxMultiple, ChildNotFoundError, Chip, CodeEditor, Col, CollapseCard, Column, ColumnNotFoundError, Component, ComponentRender, Container, Currency, Dashboard, Date$1 as Date, DateRange, Dialog, DialogService, Divider, Dropdown, FileInput, Footer, Form, Frame, FramePage, Grid, GridColumn, GridColumnEditable, GridEditable, Header, Icon, Icons, Image, Increment, Input, Iterable, IterableColumnsButton, IterableColumnsButtonController, IterableComponentRender, IterablePageComponent, IterablePageInfo, IterablePageSize, IterablePagination, List, ListGroup, ListItem, Loading, LoadingService, Login, LoginButton, MasterDetail, Menu, MenuButton, MenuGroup, MenuLink, MenuSeparator, Modal, ModalCloseButton, ModalService, Month, Number$1 as Number, PDFReport, Password, Progress, Radio, RangeSlider, Report, Row, Search, Select, SelectMultiple, SelectTree, SelectTreeMultiple, SelectableList, SpeedDial, Steppers, SvgMap, Switch, Tab, Table, Tabs, Tag, Text, TextInput, Textarea, Time, Toggleable, Tooltip, Tree, TreeDataStructure, TreeGrid, TreeGridEditable, WatchURL, XLS2Report, XLS3Report, XLSReport, initTheme };
14895
+ export { Alert, AlertService, ApexChart, AutoNumeric, Badge, Breadcrumbs, Button, ButtonGroup, CSVReport, Card, Carousel, Checkbox, CheckboxMultiple, ChildNotFoundError, Chip, CodeEditor, Col, CollapseCard, Column, ColumnNotFoundError, Component, ComponentRender, Container, Currency, Dashboard, Date$1 as Date, DateRange, Dialog, DialogService, Divider, Dropdown, FileInput, Footer, Form, Frame, FramePage, Grid, GridColumn, GridColumnEditable, GridEditable, GroupedPDFFormatter, Header, Icon, Icons, Image, Increment, Input, InputFactory, Iterable, IterableColumnsButton, IterableColumnsButtonController, IterableComponentRender, IterablePageComponent, IterablePageInfo, IterablePageSize, IterablePagination, List, ListGroup, ListItem, Loading, LoadingService, Login, LoginButton, MasterDetail, Menu, MenuButton, MenuGroup, MenuLink, MenuSeparator, Modal, ModalCloseButton, ModalService, Month, Number$1 as Number, PDFReport, Password, Progress, Radio, RangeSlider, Report, Row, Search, Select, SelectMultiple, SelectTree, SelectTreeMultiple, SelectableList, SpeedDial, Steppers, SvgMap, Switch, Tab, Table, Tabs, Tag, Text, TextInput, Textarea, Time, Toggleable, Tooltip, Tree, TreeDataStructure, TreeGrid, TreeGridEditable, WatchURL, XLS2Report, XLS3Report, XLSReport, initTheme };