@zeedhi/common 1.38.1 → 1.39.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.
@@ -4317,7 +4317,7 @@ class Column extends Component {
4317
4317
  const appliedConditions = {};
4318
4318
  Object.keys(this.factoredConditions).forEach((condition) => {
4319
4319
  const conditionFunction = this.factoredConditions[condition];
4320
- set(appliedConditions, condition, conditionFunction({ row }));
4320
+ set(appliedConditions, condition, conditionFunction({ row, column: this }));
4321
4321
  });
4322
4322
  return appliedConditions;
4323
4323
  }
@@ -5068,7 +5068,6 @@ class GridEditable extends Grid {
5068
5068
  if (this.editing)
5069
5069
  return;
5070
5070
  if (column.editable) {
5071
- this.selectedRows = [];
5072
5071
  this.editing = true;
5073
5072
  this.preventRowClick = true;
5074
5073
  this.datasource.currentRow = row;
@@ -5138,7 +5137,7 @@ class GridEditable extends Grid {
5138
5137
  else {
5139
5138
  colValue = row[column.name];
5140
5139
  }
5141
- const componentProps = merge({}, column.componentProps, cellProps.componentProps);
5140
+ const componentProps = merge({}, column.componentProps, cellProps === null || cellProps === void 0 ? void 0 : cellProps.componentProps);
5142
5141
  let compEvents = {};
5143
5142
  if (componentProps && componentProps.events) {
5144
5143
  compEvents = Event.factory(componentProps.events);
@@ -5931,6 +5930,7 @@ class Select extends TextInput {
5931
5930
  this.cachedData = [];
5932
5931
  this.cachedTotal = 0;
5933
5932
  this.formatterFn = FormatterParserProvider.getFormatter('ZdSelect');
5933
+ this.pushedValue = null;
5934
5934
  this.loadMoreQtty = 0;
5935
5935
  this.debounceSearch = debounce(this.doSearch, 500);
5936
5936
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'expand');
@@ -5952,6 +5952,7 @@ class Select extends TextInput {
5952
5952
  this.dataText = [this.dataText];
5953
5953
  const defaultDatasource = this.getDefaultDatasource(props);
5954
5954
  this.datasource = DatasourceFactory.factory(defaultDatasource);
5955
+ this.overrideGet();
5955
5956
  let defaultValue = props.value;
5956
5957
  if (Accessor.isAccessorDefinition(props.value)) {
5957
5958
  defaultValue = this.getAccessorValue(props.value);
@@ -5982,6 +5983,16 @@ class Select extends TextInput {
5982
5983
  const searchIn = (((_a = field.datasource) === null || _a === void 0 ? void 0 : _a.searchIn) || []).concat(searchInDefault);
5983
5984
  return Object.assign(Object.assign({}, field.datasource), { searchIn, lazyLoad: (field.value !== '' && field.value !== undefined) || (field.datasource && field.datasource.lazyLoad) });
5984
5985
  }
5986
+ overrideGet() {
5987
+ const oldGet = this.datasource.get;
5988
+ this.datasource.get = () => __awaiter(this, void 0, void 0, function* () {
5989
+ yield oldGet.call(this.datasource);
5990
+ if (this.indexOf(this.value) !== -1 || this.datasource.search || this.isFocused)
5991
+ return;
5992
+ yield this.setValue(this.value, false);
5993
+ this.removePushedValue();
5994
+ });
5995
+ }
5985
5996
  get search() {
5986
5997
  return this.searchValue;
5987
5998
  }
@@ -6008,7 +6019,7 @@ class Select extends TextInput {
6008
6019
  }
6009
6020
  if (this.manualMode)
6010
6021
  return;
6011
- this.cachedData = this.datasource.data;
6022
+ this.cachedData = [...this.datasource.data];
6012
6023
  this.cachedTotal = this.datasource.total;
6013
6024
  if (pushed) {
6014
6025
  this.pushedValue = this.selectedData;
@@ -6067,10 +6078,14 @@ class Select extends TextInput {
6067
6078
  if (!this.pushedValue && this.isFilledObj(this.selectValue) && this.indexOf(this.selectValue) === -1) {
6068
6079
  this.pushedValue = this.selectValue;
6069
6080
  }
6070
- if (this.isFilledObj(this.pushedValue) && this.indexOf(this.pushedValue) === -1) {
6081
+ const index = this.indexOf(this.pushedValue);
6082
+ if (this.isFilledObj(this.pushedValue) && index === -1) {
6071
6083
  this.datasource.data.unshift(this.pushedValue);
6072
6084
  }
6073
- this.cachedData = this.datasource.data;
6085
+ else if (index !== 0) {
6086
+ this.pushedValue = null;
6087
+ }
6088
+ this.cachedData = [...this.datasource.data];
6074
6089
  this.cachedTotal = this.datasource.total;
6075
6090
  }
6076
6091
  /**
@@ -6129,6 +6144,7 @@ class Select extends TextInput {
6129
6144
  }
6130
6145
  if (!searchValue) {
6131
6146
  this.setFieldRowValue(null);
6147
+ this.selectValue = this.selectedData;
6132
6148
  return false;
6133
6149
  }
6134
6150
  this.setFieldRowValue(searchValue);
@@ -6239,7 +6255,7 @@ class Select extends TextInput {
6239
6255
  else {
6240
6256
  this.removePushedValue();
6241
6257
  this.datasource.search = this.searchValue;
6242
- this.datasource.data = this.cachedData;
6258
+ this.datasource.data = [...this.cachedData];
6243
6259
  this.datasource.total = this.cachedTotal;
6244
6260
  }
6245
6261
  });
@@ -6252,6 +6268,11 @@ class Select extends TextInput {
6252
6268
  yield this.datasource.setLimit(this.datasource.limit + this.loadMoreQtty);
6253
6269
  if (!this.datasource.search) {
6254
6270
  this.afterLoad();
6271
+ const { dataValue } = this;
6272
+ const isSelected = this.selectValue && this.pushedValue && this.selectValue[dataValue] === this.pushedValue[dataValue];
6273
+ if (isSelected)
6274
+ return;
6275
+ this.removePushedValue();
6255
6276
  }
6256
6277
  });
6257
6278
  }
@@ -6265,7 +6286,7 @@ class Select extends TextInput {
6265
6286
  this.datasource.search = '';
6266
6287
  this.dirtySearchValue = '';
6267
6288
  if (!this.manualMode) {
6268
- this.datasource.data = this.cachedData;
6289
+ this.datasource.data = [...this.cachedData];
6269
6290
  this.datasource.total = this.cachedTotal;
6270
6291
  }
6271
6292
  this.checkValueOnBlur();
@@ -6278,13 +6299,17 @@ class Select extends TextInput {
6278
6299
  }
6279
6300
  if (this.manualMode)
6280
6301
  return;
6281
- if (this.isFilledObj(this.selectValue)) {
6282
- if (this.indexOf(this.selectValue) === -1) {
6283
- this.datasource.data.unshift(this.selectValue);
6284
- this.pushedValue = this.selectValue;
6302
+ if (this.isFilledObj(this.selectValue) && this.indexOf(this.selectValue) === -1) {
6303
+ if (this.pushedValue) {
6304
+ this.removePushedValue();
6285
6305
  }
6306
+ this.datasource.data.unshift(this.selectValue);
6307
+ this.pushedValue = this.selectValue;
6286
6308
  return;
6287
6309
  }
6310
+ const { dataValue } = this;
6311
+ if (this.pushedValue && this.selectValue && this.selectValue[dataValue] === this.pushedValue[dataValue])
6312
+ return;
6288
6313
  this.removePushedValue();
6289
6314
  }
6290
6315
  showLoadMore() {
@@ -7929,20 +7954,23 @@ class SelectMultiple extends Select {
7929
7954
  set selectValue(rows) {
7930
7955
  if (!Array.isArray(rows))
7931
7956
  return;
7932
- if (!this.manualMode && this.insertedValues.length > 0) {
7933
- this.insertsRemoved = [];
7957
+ if (!this.manualMode) {
7934
7958
  const values = rows.map((row) => row[this.dataValue]);
7935
- this.insertedValues = this.insertedValues.filter((inserted) => {
7936
- const removed = !values.includes(inserted[this.dataValue]);
7937
- if (removed) {
7938
- this.insertsRemoved.push(inserted);
7939
- }
7940
- return !removed;
7941
- });
7959
+ this.cutFromAToB(this.insertedValues, this.insertsRemoved, (value) => !values.includes(value[this.dataValue]));
7960
+ this.cutFromAToB(this.insertsRemoved, this.insertedValues, (value) => values.includes(value[this.dataValue]));
7942
7961
  }
7943
7962
  this.selectedValue = rows;
7944
7963
  this.setFieldValue(this.getValues(rows));
7945
7964
  }
7965
+ /**
7966
+ * Removes item from array a and add it to array b if condition is satisfied
7967
+ */
7968
+ cutFromAToB(a, b, condition) {
7969
+ const indices = a.reduce((result, value, index) => (condition(value) ? [...result, index] : result), []);
7970
+ indices.forEach((index) => {
7971
+ b.push(a.splice(index)[0]);
7972
+ });
7973
+ }
7946
7974
  setFieldValue(value) {
7947
7975
  return __awaiter(this, void 0, void 0, function* () {
7948
7976
  const promises = [];
@@ -8119,7 +8147,7 @@ class SelectMultiple extends Select {
8119
8147
  showLoadMore() {
8120
8148
  return !!this.datasource.data.length
8121
8149
  && !this.datasource.loadAll
8122
- && (this.datasource.data.length - this.insertedValues.length) < this.datasource.total;
8150
+ && (this.datasource.data.length - this.insertedValues.length - this.insertsRemoved.length) < this.datasource.total;
8123
8151
  }
8124
8152
  /**
8125
8153
  * Load more data
@@ -8127,10 +8155,16 @@ class SelectMultiple extends Select {
8127
8155
  loadMore() {
8128
8156
  return __awaiter(this, void 0, void 0, function* () {
8129
8157
  yield this.datasource.setLimit(this.datasource.limit + this.loadMoreQtty);
8158
+ this.insertsRemoved = this.insertsRemoved.filter((insert) => {
8159
+ const value = insert[this.dataValue];
8160
+ const foundInData = this.datasource.data.find(this.getCondition(value));
8161
+ return !foundInData;
8162
+ });
8163
+ this.insertSelected();
8130
8164
  if (!this.datasource.search) {
8131
8165
  this.setCache();
8132
8166
  }
8133
- this.insertSelected();
8167
+ this.removePushedValue();
8134
8168
  });
8135
8169
  }
8136
8170
  /**
@@ -8324,6 +8358,9 @@ class TreeDataStructure {
8324
8358
  }
8325
8359
  return item;
8326
8360
  });
8361
+ if (parent) { // remove all existing children to add new ones
8362
+ this.treeData = this.treeData.filter((item) => item.tree__parent !== parent);
8363
+ }
8327
8364
  if (!parent) {
8328
8365
  this.treeData = childData;
8329
8366
  }
@@ -8507,7 +8544,7 @@ class TreeDataStructure {
8507
8544
  this.treeStructure = {};
8508
8545
  const childData = this.originalDatasource.data.map((row) => (Object.assign(Object.assign({}, row), { tree__children: [], tree__opened: false, tree__searched: true, tree__level: 1, tree__parent: undefined })));
8509
8546
  this.treeData = childData;
8510
- this.treeStructure['no-parent'] = this.originalDatasource.data;
8547
+ this.treeStructure['no-parent'] = childData;
8511
8548
  }
8512
8549
  /**
8513
8550
  * Search value against a memory datasource
@@ -10184,7 +10221,6 @@ class TreeGridEditable extends TreeGrid {
10184
10221
  if (this.editing)
10185
10222
  return;
10186
10223
  if (column.editable) {
10187
- this.selectedRows = [];
10188
10224
  this.editing = true;
10189
10225
  this.preventRowClick = true;
10190
10226
  this.datasource.currentRow = row;
@@ -11133,17 +11169,37 @@ class PDFReport extends BaseReport {
11133
11169
  }
11134
11170
 
11135
11171
  class XLSReport extends BaseReport {
11136
- constructor() {
11137
- super(...arguments);
11172
+ constructor(type) {
11173
+ super();
11138
11174
  this.route = '/generateXLS';
11175
+ this.expressionZeedhiToXls = {
11176
+ AVG: 'AVERAGE',
11177
+ COUNT: 'COUNTA',
11178
+ MAX: 'MAX',
11179
+ MIN: 'MIN',
11180
+ SUM: 'SUM',
11181
+ };
11182
+ this.colunmXLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
11183
+ this.type = type || 'xls';
11139
11184
  }
11140
- buildDataset(data, columns) {
11185
+ buildDataset(data, columns, metadata) {
11186
+ let result;
11187
+ if (this.type === 'xls') {
11188
+ result = this.formatRawDataSet(data, columns);
11189
+ }
11190
+ else if (metadata) {
11191
+ result = this.formatDataSet(metadata, data);
11192
+ }
11193
+ return JSON.stringify(result);
11194
+ }
11195
+ // formata o dataset para o formato "cru" xls
11196
+ formatRawDataSet(data, columns) {
11141
11197
  const columnNames = columns.map((col) => col.name);
11142
11198
  const result = data.reduce((reduced, row) => {
11143
11199
  const values = columnNames.map((col) => row[col] || '');
11144
11200
  return [...reduced, values];
11145
11201
  }, [columnNames]);
11146
- return JSON.stringify(result);
11202
+ return result;
11147
11203
  }
11148
11204
  buildMetadata(name, title, columns, filter) {
11149
11205
  const builtCols = this.buildColumns(columns);
@@ -11172,9 +11228,215 @@ class XLSReport extends BaseReport {
11172
11228
  orientation: 'PORTRAIT',
11173
11229
  columns: builtCols,
11174
11230
  filter: builtFilters,
11231
+ reportXLS: true,
11232
+ xlsMergedCell: [],
11175
11233
  };
11176
11234
  return Promise.resolve(JSON.stringify(metadataObj));
11177
11235
  }
11236
+ isFormat3(format) {
11237
+ return format === 'xls3';
11238
+ }
11239
+ // Ordenar o nome das colunas de acordo com seu index, excluindo o nome das colunas agrupadas
11240
+ getColumnsNameFormat3(columns, metaData) {
11241
+ const columnsNameGroup = metaData.groups.map((row) => row.field);
11242
+ let columnsName = [];
11243
+ Object.entries(columns).forEach((row) => {
11244
+ const columnName = row[0];
11245
+ if (columnsNameGroup.indexOf(columnName) === -1) {
11246
+ const index = row[1].sequence;
11247
+ columnsName[index] = columnName;
11248
+ }
11249
+ });
11250
+ columnsName = columnsName.filter((columnName) => typeof columnName === 'string');
11251
+ return columnsName;
11252
+ }
11253
+ // Ordenar o nome das colunas de acordo com seu index, e sempre deixando as colunas agrupadas nas primeiras posições
11254
+ getColumnsName(columns, metaData, lengthGroup) {
11255
+ const columnsNameGroup = metaData.groups.map((row) => row.field);
11256
+ let columnsName = [];
11257
+ Object.entries(columns).forEach((row) => {
11258
+ const columnName = row[0];
11259
+ const index = row[1].sequence;
11260
+ if (columnsNameGroup.indexOf(columnName) === -1) {
11261
+ columnsName[index + lengthGroup] = columnName;
11262
+ }
11263
+ else {
11264
+ columnsName[index] = columnName;
11265
+ }
11266
+ });
11267
+ columnsName = columnsName.filter((columnName) => typeof columnName === 'string');
11268
+ return columnsName;
11269
+ }
11270
+ // Inicializa alguns valores auxiliares
11271
+ initVars(metaData, type) {
11272
+ metaData.xlsMergedCell = [];
11273
+ const { columns } = metaData;
11274
+ const lengthGroup = metaData.groups.length;
11275
+ const indexLastGroup = lengthGroup - 1;
11276
+ let columnsName = [];
11277
+ if (this.isFormat3(type)) {
11278
+ columnsName = this.getColumnsNameFormat3(columns, metaData);
11279
+ }
11280
+ else {
11281
+ columnsName = this.getColumnsName(columns, metaData, lengthGroup);
11282
+ }
11283
+ const rowValues = [];
11284
+ const formatedDataSet = [];
11285
+ const groups = [];
11286
+ groups.groupEnd = {};
11287
+ groups.groupEnd.cellsfunc = {};
11288
+ return {
11289
+ columns, indexLastGroup, columnsName, rowValues, formatedDataSet, groups,
11290
+ };
11291
+ }
11292
+ // formata a linha do grupo de acordo com o formato xls3
11293
+ setRowGroupFormat3(row, rowValuesParam, groups, formatedDataSet, columnsName, columns, indexLastGroup) {
11294
+ let rowValues = rowValuesParam;
11295
+ const label = `${row.groupLabel}:${row.groupValue}`;
11296
+ const index = row.groupIndex;
11297
+ if (row.groupHeader) {
11298
+ rowValues[index] = label;
11299
+ groups[index] = { init: null, end: null };
11300
+ formatedDataSet.push(rowValues);
11301
+ rowValues = [];
11302
+ }
11303
+ else if (row.groupFooter) {
11304
+ if (!row.groupLabel) {
11305
+ rowValues.push('Total');
11306
+ }
11307
+ else {
11308
+ rowValues.push(`Total (${label})`);
11309
+ }
11310
+ formatedDataSet.push(rowValues);
11311
+ rowValues = [];
11312
+ const funcXls = null;
11313
+ columnsName.forEach((column) => {
11314
+ this.formatRowFunc(column, columns, row, index, rowValues, funcXls, groups, indexLastGroup);
11315
+ });
11316
+ }
11317
+ return rowValues;
11318
+ }
11319
+ // formata as expressões da linha
11320
+ formatRowFunc(column, columns, row, index, rowValues, funcXlsParam, groups, indexLastGroup) {
11321
+ let funcXls = funcXlsParam;
11322
+ if ((row[column] === 0 || row[column]) && index !== undefined) {
11323
+ const letter = this.colunmXLS[rowValues.length];
11324
+ funcXls = this.expressionZeedhiToXls[columns[column].expression];
11325
+ const cellsfunc = `${letter + groups[index].init}:${letter}${groups[index].end}`;
11326
+ let expression = '';
11327
+ if (indexLastGroup === index) {
11328
+ expression = `=${funcXls}(${cellsfunc})`;
11329
+ }
11330
+ else {
11331
+ expression = `=${funcXls}(${groups[index].cellsfunc[column]})`;
11332
+ if (index === 0) {
11333
+ if (groups.groupEnd.cellsfunc[column]) {
11334
+ groups.groupEnd.cellsfunc[column] += `,${groups[index].cellsfunc[column]}`;
11335
+ }
11336
+ else {
11337
+ groups.groupEnd.cellsfunc[column] = groups[index].cellsfunc[column];
11338
+ }
11339
+ }
11340
+ groups[index].cellsfunc[column] = null;
11341
+ }
11342
+ rowValues.push(expression);
11343
+ groups.forEach((group, indexGroup) => {
11344
+ if (indexGroup !== indexLastGroup) {
11345
+ if (!group.cellsfunc) {
11346
+ group.cellsfunc = {};
11347
+ }
11348
+ if (group.cellsfunc[column]) {
11349
+ group.cellsfunc[column] += `,${cellsfunc}`;
11350
+ }
11351
+ else {
11352
+ group.cellsfunc[column] = cellsfunc;
11353
+ }
11354
+ }
11355
+ });
11356
+ }
11357
+ else {
11358
+ let cell = row[column];
11359
+ if (row.groupSummary) {
11360
+ const groupEndFunc = groups.groupEnd.cellsfunc;
11361
+ if (groupEndFunc[column]) {
11362
+ funcXls = this.expressionZeedhiToXls[columns[column].expression];
11363
+ cell = `=${funcXls}(${groupEndFunc[column]})`;
11364
+ }
11365
+ }
11366
+ rowValues.push(cell);
11367
+ }
11368
+ }
11369
+ // formata a linha de grupo de acordo com o formato xls2
11370
+ setRowGroup(row, rowValues, groups, metaData, formatedDataSet, columnsName, columns, indexLastGroup) {
11371
+ const label = `${row.groupLabel}:${row.groupValue}`;
11372
+ const index = row.groupIndex;
11373
+ if (row.groupHeader) {
11374
+ rowValues[index] = label;
11375
+ groups[index] = { init: null, end: null };
11376
+ }
11377
+ else if (row.groupFooter) {
11378
+ if (!row.groupLabel) {
11379
+ rowValues.push('Total');
11380
+ }
11381
+ else {
11382
+ rowValues.push(`Total (${label})`);
11383
+ }
11384
+ const funcXls = null;
11385
+ if (groups[index]) {
11386
+ metaData.xlsMergedCell.push({
11387
+ start_row: groups[index].init,
11388
+ start_col: this.colunmXLS[index],
11389
+ end_row: formatedDataSet.length + 2,
11390
+ end_col: this.colunmXLS[index],
11391
+ });
11392
+ }
11393
+ columnsName.forEach((column, columnIndex) => {
11394
+ if (!(row.groupFooter && columnIndex === 0)) {
11395
+ this.formatRowFunc(column, columns, row, index, rowValues, funcXls, groups, indexLastGroup);
11396
+ }
11397
+ });
11398
+ }
11399
+ return rowValues;
11400
+ }
11401
+ // Defina o index dos grupos
11402
+ setIndexGroups(groups, formatedDataSet) {
11403
+ groups.forEach((group) => {
11404
+ if (!group.init) {
11405
+ group.init = formatedDataSet.length + 2;
11406
+ }
11407
+ group.end = formatedDataSet.length + 2;
11408
+ });
11409
+ }
11410
+ // Preenche uma linha "normal"
11411
+ setRowNormal(columnsName, rowValues, row) {
11412
+ columnsName.forEach((column) => {
11413
+ rowValues.push(row[column]);
11414
+ });
11415
+ }
11416
+ formatDataSet(metaData, dataSet) {
11417
+ const initVars = this.initVars(metaData, this.type);
11418
+ const { columns, indexLastGroup, columnsName, formatedDataSet, groups, } = initVars;
11419
+ let { rowValues } = initVars;
11420
+ dataSet.forEach((row) => {
11421
+ if (row.group || row.groupFooter) {
11422
+ if (this.isFormat3(this.type)) {
11423
+ rowValues = this.setRowGroupFormat3(row, rowValues, groups, formatedDataSet, columnsName, columns, indexLastGroup);
11424
+ }
11425
+ else {
11426
+ rowValues = this.setRowGroup(row, rowValues, groups, metaData, formatedDataSet, columnsName, columns, indexLastGroup);
11427
+ }
11428
+ }
11429
+ else {
11430
+ this.setIndexGroups(groups, formatedDataSet);
11431
+ this.setRowNormal(columnsName, rowValues, row);
11432
+ }
11433
+ if (!row.groupHeader) {
11434
+ formatedDataSet.push(rowValues);
11435
+ }
11436
+ rowValues = [];
11437
+ });
11438
+ return [columnsName].concat(formatedDataSet);
11439
+ }
11178
11440
  }
11179
11441
 
11180
11442
  class Report {
@@ -11210,8 +11472,8 @@ class Report {
11210
11472
  if (type === 'pdf') {
11211
11473
  return new PDFReport();
11212
11474
  }
11213
- if (type === 'xls') {
11214
- return new XLSReport();
11475
+ if (type === 'xls' || type === 'xls2' || type === 'xls3') {
11476
+ return new XLSReport(type);
11215
11477
  }
11216
11478
  throw new Error(`Invalid report type: ${type}`);
11217
11479
  }
@@ -11226,9 +11488,18 @@ class Report {
11226
11488
  const reportType = this.getReportType(type);
11227
11489
  const { route } = reportType;
11228
11490
  const { name, columns, datasource } = this.iterable;
11491
+ const { groupedData } = Object.assign({}, this.iterable);
11229
11492
  const formattedColumns = this.removeActionColumns(columns);
11230
- const dataset = reportType.buildDataset(data, formattedColumns);
11231
11493
  const metadataObj = yield reportType.buildMetadata(name, this.title, formattedColumns, datasource.filter, portrait);
11494
+ let dataset;
11495
+ if ((reportType.type === 'xls2' || reportType.type === 'xls3') && groupedData) {
11496
+ const rowMetadata = rowObj.metaData;
11497
+ const metadataObjClone = merge(rowMetadata, JSON.parse(metadataObj));
11498
+ dataset = reportType.buildDataset(groupedData, formattedColumns, metadataObjClone);
11499
+ }
11500
+ else {
11501
+ dataset = reportType.buildDataset(data, formattedColumns);
11502
+ }
11232
11503
  const filter = '[]';
11233
11504
  let row = {};
11234
11505
  if (rowObj) {
@@ -4324,7 +4324,7 @@
4324
4324
  const appliedConditions = {};
4325
4325
  Object.keys(this.factoredConditions).forEach((condition) => {
4326
4326
  const conditionFunction = this.factoredConditions[condition];
4327
- set__default["default"](appliedConditions, condition, conditionFunction({ row }));
4327
+ set__default["default"](appliedConditions, condition, conditionFunction({ row, column: this }));
4328
4328
  });
4329
4329
  return appliedConditions;
4330
4330
  }
@@ -5075,7 +5075,6 @@
5075
5075
  if (this.editing)
5076
5076
  return;
5077
5077
  if (column.editable) {
5078
- this.selectedRows = [];
5079
5078
  this.editing = true;
5080
5079
  this.preventRowClick = true;
5081
5080
  this.datasource.currentRow = row;
@@ -5145,7 +5144,7 @@
5145
5144
  else {
5146
5145
  colValue = row[column.name];
5147
5146
  }
5148
- const componentProps = merge__default["default"]({}, column.componentProps, cellProps.componentProps);
5147
+ const componentProps = merge__default["default"]({}, column.componentProps, cellProps === null || cellProps === void 0 ? void 0 : cellProps.componentProps);
5149
5148
  let compEvents = {};
5150
5149
  if (componentProps && componentProps.events) {
5151
5150
  compEvents = core.Event.factory(componentProps.events);
@@ -5938,6 +5937,7 @@
5938
5937
  this.cachedData = [];
5939
5938
  this.cachedTotal = 0;
5940
5939
  this.formatterFn = core.FormatterParserProvider.getFormatter('ZdSelect');
5940
+ this.pushedValue = null;
5941
5941
  this.loadMoreQtty = 0;
5942
5942
  this.debounceSearch = debounce__default["default"](this.doSearch, 500);
5943
5943
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'expand');
@@ -5959,6 +5959,7 @@
5959
5959
  this.dataText = [this.dataText];
5960
5960
  const defaultDatasource = this.getDefaultDatasource(props);
5961
5961
  this.datasource = core.DatasourceFactory.factory(defaultDatasource);
5962
+ this.overrideGet();
5962
5963
  let defaultValue = props.value;
5963
5964
  if (core.Accessor.isAccessorDefinition(props.value)) {
5964
5965
  defaultValue = this.getAccessorValue(props.value);
@@ -5989,6 +5990,16 @@
5989
5990
  const searchIn = (((_a = field.datasource) === null || _a === void 0 ? void 0 : _a.searchIn) || []).concat(searchInDefault);
5990
5991
  return Object.assign(Object.assign({}, field.datasource), { searchIn, lazyLoad: (field.value !== '' && field.value !== undefined) || (field.datasource && field.datasource.lazyLoad) });
5991
5992
  }
5993
+ overrideGet() {
5994
+ const oldGet = this.datasource.get;
5995
+ this.datasource.get = () => __awaiter(this, void 0, void 0, function* () {
5996
+ yield oldGet.call(this.datasource);
5997
+ if (this.indexOf(this.value) !== -1 || this.datasource.search || this.isFocused)
5998
+ return;
5999
+ yield this.setValue(this.value, false);
6000
+ this.removePushedValue();
6001
+ });
6002
+ }
5992
6003
  get search() {
5993
6004
  return this.searchValue;
5994
6005
  }
@@ -6015,7 +6026,7 @@
6015
6026
  }
6016
6027
  if (this.manualMode)
6017
6028
  return;
6018
- this.cachedData = this.datasource.data;
6029
+ this.cachedData = [...this.datasource.data];
6019
6030
  this.cachedTotal = this.datasource.total;
6020
6031
  if (pushed) {
6021
6032
  this.pushedValue = this.selectedData;
@@ -6074,10 +6085,14 @@
6074
6085
  if (!this.pushedValue && this.isFilledObj(this.selectValue) && this.indexOf(this.selectValue) === -1) {
6075
6086
  this.pushedValue = this.selectValue;
6076
6087
  }
6077
- if (this.isFilledObj(this.pushedValue) && this.indexOf(this.pushedValue) === -1) {
6088
+ const index = this.indexOf(this.pushedValue);
6089
+ if (this.isFilledObj(this.pushedValue) && index === -1) {
6078
6090
  this.datasource.data.unshift(this.pushedValue);
6079
6091
  }
6080
- this.cachedData = this.datasource.data;
6092
+ else if (index !== 0) {
6093
+ this.pushedValue = null;
6094
+ }
6095
+ this.cachedData = [...this.datasource.data];
6081
6096
  this.cachedTotal = this.datasource.total;
6082
6097
  }
6083
6098
  /**
@@ -6136,6 +6151,7 @@
6136
6151
  }
6137
6152
  if (!searchValue) {
6138
6153
  this.setFieldRowValue(null);
6154
+ this.selectValue = this.selectedData;
6139
6155
  return false;
6140
6156
  }
6141
6157
  this.setFieldRowValue(searchValue);
@@ -6246,7 +6262,7 @@
6246
6262
  else {
6247
6263
  this.removePushedValue();
6248
6264
  this.datasource.search = this.searchValue;
6249
- this.datasource.data = this.cachedData;
6265
+ this.datasource.data = [...this.cachedData];
6250
6266
  this.datasource.total = this.cachedTotal;
6251
6267
  }
6252
6268
  });
@@ -6259,6 +6275,11 @@
6259
6275
  yield this.datasource.setLimit(this.datasource.limit + this.loadMoreQtty);
6260
6276
  if (!this.datasource.search) {
6261
6277
  this.afterLoad();
6278
+ const { dataValue } = this;
6279
+ const isSelected = this.selectValue && this.pushedValue && this.selectValue[dataValue] === this.pushedValue[dataValue];
6280
+ if (isSelected)
6281
+ return;
6282
+ this.removePushedValue();
6262
6283
  }
6263
6284
  });
6264
6285
  }
@@ -6272,7 +6293,7 @@
6272
6293
  this.datasource.search = '';
6273
6294
  this.dirtySearchValue = '';
6274
6295
  if (!this.manualMode) {
6275
- this.datasource.data = this.cachedData;
6296
+ this.datasource.data = [...this.cachedData];
6276
6297
  this.datasource.total = this.cachedTotal;
6277
6298
  }
6278
6299
  this.checkValueOnBlur();
@@ -6285,13 +6306,17 @@
6285
6306
  }
6286
6307
  if (this.manualMode)
6287
6308
  return;
6288
- if (this.isFilledObj(this.selectValue)) {
6289
- if (this.indexOf(this.selectValue) === -1) {
6290
- this.datasource.data.unshift(this.selectValue);
6291
- this.pushedValue = this.selectValue;
6309
+ if (this.isFilledObj(this.selectValue) && this.indexOf(this.selectValue) === -1) {
6310
+ if (this.pushedValue) {
6311
+ this.removePushedValue();
6292
6312
  }
6313
+ this.datasource.data.unshift(this.selectValue);
6314
+ this.pushedValue = this.selectValue;
6293
6315
  return;
6294
6316
  }
6317
+ const { dataValue } = this;
6318
+ if (this.pushedValue && this.selectValue && this.selectValue[dataValue] === this.pushedValue[dataValue])
6319
+ return;
6295
6320
  this.removePushedValue();
6296
6321
  }
6297
6322
  showLoadMore() {
@@ -7936,20 +7961,23 @@
7936
7961
  set selectValue(rows) {
7937
7962
  if (!Array.isArray(rows))
7938
7963
  return;
7939
- if (!this.manualMode && this.insertedValues.length > 0) {
7940
- this.insertsRemoved = [];
7964
+ if (!this.manualMode) {
7941
7965
  const values = rows.map((row) => row[this.dataValue]);
7942
- this.insertedValues = this.insertedValues.filter((inserted) => {
7943
- const removed = !values.includes(inserted[this.dataValue]);
7944
- if (removed) {
7945
- this.insertsRemoved.push(inserted);
7946
- }
7947
- return !removed;
7948
- });
7966
+ this.cutFromAToB(this.insertedValues, this.insertsRemoved, (value) => !values.includes(value[this.dataValue]));
7967
+ this.cutFromAToB(this.insertsRemoved, this.insertedValues, (value) => values.includes(value[this.dataValue]));
7949
7968
  }
7950
7969
  this.selectedValue = rows;
7951
7970
  this.setFieldValue(this.getValues(rows));
7952
7971
  }
7972
+ /**
7973
+ * Removes item from array a and add it to array b if condition is satisfied
7974
+ */
7975
+ cutFromAToB(a, b, condition) {
7976
+ const indices = a.reduce((result, value, index) => (condition(value) ? [...result, index] : result), []);
7977
+ indices.forEach((index) => {
7978
+ b.push(a.splice(index)[0]);
7979
+ });
7980
+ }
7953
7981
  setFieldValue(value) {
7954
7982
  return __awaiter(this, void 0, void 0, function* () {
7955
7983
  const promises = [];
@@ -8126,7 +8154,7 @@
8126
8154
  showLoadMore() {
8127
8155
  return !!this.datasource.data.length
8128
8156
  && !this.datasource.loadAll
8129
- && (this.datasource.data.length - this.insertedValues.length) < this.datasource.total;
8157
+ && (this.datasource.data.length - this.insertedValues.length - this.insertsRemoved.length) < this.datasource.total;
8130
8158
  }
8131
8159
  /**
8132
8160
  * Load more data
@@ -8134,10 +8162,16 @@
8134
8162
  loadMore() {
8135
8163
  return __awaiter(this, void 0, void 0, function* () {
8136
8164
  yield this.datasource.setLimit(this.datasource.limit + this.loadMoreQtty);
8165
+ this.insertsRemoved = this.insertsRemoved.filter((insert) => {
8166
+ const value = insert[this.dataValue];
8167
+ const foundInData = this.datasource.data.find(this.getCondition(value));
8168
+ return !foundInData;
8169
+ });
8170
+ this.insertSelected();
8137
8171
  if (!this.datasource.search) {
8138
8172
  this.setCache();
8139
8173
  }
8140
- this.insertSelected();
8174
+ this.removePushedValue();
8141
8175
  });
8142
8176
  }
8143
8177
  /**
@@ -8331,6 +8365,9 @@
8331
8365
  }
8332
8366
  return item;
8333
8367
  });
8368
+ if (parent) { // remove all existing children to add new ones
8369
+ this.treeData = this.treeData.filter((item) => item.tree__parent !== parent);
8370
+ }
8334
8371
  if (!parent) {
8335
8372
  this.treeData = childData;
8336
8373
  }
@@ -8514,7 +8551,7 @@
8514
8551
  this.treeStructure = {};
8515
8552
  const childData = this.originalDatasource.data.map((row) => (Object.assign(Object.assign({}, row), { tree__children: [], tree__opened: false, tree__searched: true, tree__level: 1, tree__parent: undefined })));
8516
8553
  this.treeData = childData;
8517
- this.treeStructure['no-parent'] = this.originalDatasource.data;
8554
+ this.treeStructure['no-parent'] = childData;
8518
8555
  }
8519
8556
  /**
8520
8557
  * Search value against a memory datasource
@@ -10191,7 +10228,6 @@
10191
10228
  if (this.editing)
10192
10229
  return;
10193
10230
  if (column.editable) {
10194
- this.selectedRows = [];
10195
10231
  this.editing = true;
10196
10232
  this.preventRowClick = true;
10197
10233
  this.datasource.currentRow = row;
@@ -11140,17 +11176,37 @@
11140
11176
  }
11141
11177
 
11142
11178
  class XLSReport extends BaseReport {
11143
- constructor() {
11144
- super(...arguments);
11179
+ constructor(type) {
11180
+ super();
11145
11181
  this.route = '/generateXLS';
11182
+ this.expressionZeedhiToXls = {
11183
+ AVG: 'AVERAGE',
11184
+ COUNT: 'COUNTA',
11185
+ MAX: 'MAX',
11186
+ MIN: 'MIN',
11187
+ SUM: 'SUM',
11188
+ };
11189
+ this.colunmXLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
11190
+ this.type = type || 'xls';
11146
11191
  }
11147
- buildDataset(data, columns) {
11192
+ buildDataset(data, columns, metadata) {
11193
+ let result;
11194
+ if (this.type === 'xls') {
11195
+ result = this.formatRawDataSet(data, columns);
11196
+ }
11197
+ else if (metadata) {
11198
+ result = this.formatDataSet(metadata, data);
11199
+ }
11200
+ return JSON.stringify(result);
11201
+ }
11202
+ // formata o dataset para o formato "cru" xls
11203
+ formatRawDataSet(data, columns) {
11148
11204
  const columnNames = columns.map((col) => col.name);
11149
11205
  const result = data.reduce((reduced, row) => {
11150
11206
  const values = columnNames.map((col) => row[col] || '');
11151
11207
  return [...reduced, values];
11152
11208
  }, [columnNames]);
11153
- return JSON.stringify(result);
11209
+ return result;
11154
11210
  }
11155
11211
  buildMetadata(name, title, columns, filter) {
11156
11212
  const builtCols = this.buildColumns(columns);
@@ -11179,9 +11235,215 @@
11179
11235
  orientation: 'PORTRAIT',
11180
11236
  columns: builtCols,
11181
11237
  filter: builtFilters,
11238
+ reportXLS: true,
11239
+ xlsMergedCell: [],
11182
11240
  };
11183
11241
  return Promise.resolve(JSON.stringify(metadataObj));
11184
11242
  }
11243
+ isFormat3(format) {
11244
+ return format === 'xls3';
11245
+ }
11246
+ // Ordenar o nome das colunas de acordo com seu index, excluindo o nome das colunas agrupadas
11247
+ getColumnsNameFormat3(columns, metaData) {
11248
+ const columnsNameGroup = metaData.groups.map((row) => row.field);
11249
+ let columnsName = [];
11250
+ Object.entries(columns).forEach((row) => {
11251
+ const columnName = row[0];
11252
+ if (columnsNameGroup.indexOf(columnName) === -1) {
11253
+ const index = row[1].sequence;
11254
+ columnsName[index] = columnName;
11255
+ }
11256
+ });
11257
+ columnsName = columnsName.filter((columnName) => typeof columnName === 'string');
11258
+ return columnsName;
11259
+ }
11260
+ // Ordenar o nome das colunas de acordo com seu index, e sempre deixando as colunas agrupadas nas primeiras posições
11261
+ getColumnsName(columns, metaData, lengthGroup) {
11262
+ const columnsNameGroup = metaData.groups.map((row) => row.field);
11263
+ let columnsName = [];
11264
+ Object.entries(columns).forEach((row) => {
11265
+ const columnName = row[0];
11266
+ const index = row[1].sequence;
11267
+ if (columnsNameGroup.indexOf(columnName) === -1) {
11268
+ columnsName[index + lengthGroup] = columnName;
11269
+ }
11270
+ else {
11271
+ columnsName[index] = columnName;
11272
+ }
11273
+ });
11274
+ columnsName = columnsName.filter((columnName) => typeof columnName === 'string');
11275
+ return columnsName;
11276
+ }
11277
+ // Inicializa alguns valores auxiliares
11278
+ initVars(metaData, type) {
11279
+ metaData.xlsMergedCell = [];
11280
+ const { columns } = metaData;
11281
+ const lengthGroup = metaData.groups.length;
11282
+ const indexLastGroup = lengthGroup - 1;
11283
+ let columnsName = [];
11284
+ if (this.isFormat3(type)) {
11285
+ columnsName = this.getColumnsNameFormat3(columns, metaData);
11286
+ }
11287
+ else {
11288
+ columnsName = this.getColumnsName(columns, metaData, lengthGroup);
11289
+ }
11290
+ const rowValues = [];
11291
+ const formatedDataSet = [];
11292
+ const groups = [];
11293
+ groups.groupEnd = {};
11294
+ groups.groupEnd.cellsfunc = {};
11295
+ return {
11296
+ columns, indexLastGroup, columnsName, rowValues, formatedDataSet, groups,
11297
+ };
11298
+ }
11299
+ // formata a linha do grupo de acordo com o formato xls3
11300
+ setRowGroupFormat3(row, rowValuesParam, groups, formatedDataSet, columnsName, columns, indexLastGroup) {
11301
+ let rowValues = rowValuesParam;
11302
+ const label = `${row.groupLabel}:${row.groupValue}`;
11303
+ const index = row.groupIndex;
11304
+ if (row.groupHeader) {
11305
+ rowValues[index] = label;
11306
+ groups[index] = { init: null, end: null };
11307
+ formatedDataSet.push(rowValues);
11308
+ rowValues = [];
11309
+ }
11310
+ else if (row.groupFooter) {
11311
+ if (!row.groupLabel) {
11312
+ rowValues.push('Total');
11313
+ }
11314
+ else {
11315
+ rowValues.push(`Total (${label})`);
11316
+ }
11317
+ formatedDataSet.push(rowValues);
11318
+ rowValues = [];
11319
+ const funcXls = null;
11320
+ columnsName.forEach((column) => {
11321
+ this.formatRowFunc(column, columns, row, index, rowValues, funcXls, groups, indexLastGroup);
11322
+ });
11323
+ }
11324
+ return rowValues;
11325
+ }
11326
+ // formata as expressões da linha
11327
+ formatRowFunc(column, columns, row, index, rowValues, funcXlsParam, groups, indexLastGroup) {
11328
+ let funcXls = funcXlsParam;
11329
+ if ((row[column] === 0 || row[column]) && index !== undefined) {
11330
+ const letter = this.colunmXLS[rowValues.length];
11331
+ funcXls = this.expressionZeedhiToXls[columns[column].expression];
11332
+ const cellsfunc = `${letter + groups[index].init}:${letter}${groups[index].end}`;
11333
+ let expression = '';
11334
+ if (indexLastGroup === index) {
11335
+ expression = `=${funcXls}(${cellsfunc})`;
11336
+ }
11337
+ else {
11338
+ expression = `=${funcXls}(${groups[index].cellsfunc[column]})`;
11339
+ if (index === 0) {
11340
+ if (groups.groupEnd.cellsfunc[column]) {
11341
+ groups.groupEnd.cellsfunc[column] += `,${groups[index].cellsfunc[column]}`;
11342
+ }
11343
+ else {
11344
+ groups.groupEnd.cellsfunc[column] = groups[index].cellsfunc[column];
11345
+ }
11346
+ }
11347
+ groups[index].cellsfunc[column] = null;
11348
+ }
11349
+ rowValues.push(expression);
11350
+ groups.forEach((group, indexGroup) => {
11351
+ if (indexGroup !== indexLastGroup) {
11352
+ if (!group.cellsfunc) {
11353
+ group.cellsfunc = {};
11354
+ }
11355
+ if (group.cellsfunc[column]) {
11356
+ group.cellsfunc[column] += `,${cellsfunc}`;
11357
+ }
11358
+ else {
11359
+ group.cellsfunc[column] = cellsfunc;
11360
+ }
11361
+ }
11362
+ });
11363
+ }
11364
+ else {
11365
+ let cell = row[column];
11366
+ if (row.groupSummary) {
11367
+ const groupEndFunc = groups.groupEnd.cellsfunc;
11368
+ if (groupEndFunc[column]) {
11369
+ funcXls = this.expressionZeedhiToXls[columns[column].expression];
11370
+ cell = `=${funcXls}(${groupEndFunc[column]})`;
11371
+ }
11372
+ }
11373
+ rowValues.push(cell);
11374
+ }
11375
+ }
11376
+ // formata a linha de grupo de acordo com o formato xls2
11377
+ setRowGroup(row, rowValues, groups, metaData, formatedDataSet, columnsName, columns, indexLastGroup) {
11378
+ const label = `${row.groupLabel}:${row.groupValue}`;
11379
+ const index = row.groupIndex;
11380
+ if (row.groupHeader) {
11381
+ rowValues[index] = label;
11382
+ groups[index] = { init: null, end: null };
11383
+ }
11384
+ else if (row.groupFooter) {
11385
+ if (!row.groupLabel) {
11386
+ rowValues.push('Total');
11387
+ }
11388
+ else {
11389
+ rowValues.push(`Total (${label})`);
11390
+ }
11391
+ const funcXls = null;
11392
+ if (groups[index]) {
11393
+ metaData.xlsMergedCell.push({
11394
+ start_row: groups[index].init,
11395
+ start_col: this.colunmXLS[index],
11396
+ end_row: formatedDataSet.length + 2,
11397
+ end_col: this.colunmXLS[index],
11398
+ });
11399
+ }
11400
+ columnsName.forEach((column, columnIndex) => {
11401
+ if (!(row.groupFooter && columnIndex === 0)) {
11402
+ this.formatRowFunc(column, columns, row, index, rowValues, funcXls, groups, indexLastGroup);
11403
+ }
11404
+ });
11405
+ }
11406
+ return rowValues;
11407
+ }
11408
+ // Defina o index dos grupos
11409
+ setIndexGroups(groups, formatedDataSet) {
11410
+ groups.forEach((group) => {
11411
+ if (!group.init) {
11412
+ group.init = formatedDataSet.length + 2;
11413
+ }
11414
+ group.end = formatedDataSet.length + 2;
11415
+ });
11416
+ }
11417
+ // Preenche uma linha "normal"
11418
+ setRowNormal(columnsName, rowValues, row) {
11419
+ columnsName.forEach((column) => {
11420
+ rowValues.push(row[column]);
11421
+ });
11422
+ }
11423
+ formatDataSet(metaData, dataSet) {
11424
+ const initVars = this.initVars(metaData, this.type);
11425
+ const { columns, indexLastGroup, columnsName, formatedDataSet, groups, } = initVars;
11426
+ let { rowValues } = initVars;
11427
+ dataSet.forEach((row) => {
11428
+ if (row.group || row.groupFooter) {
11429
+ if (this.isFormat3(this.type)) {
11430
+ rowValues = this.setRowGroupFormat3(row, rowValues, groups, formatedDataSet, columnsName, columns, indexLastGroup);
11431
+ }
11432
+ else {
11433
+ rowValues = this.setRowGroup(row, rowValues, groups, metaData, formatedDataSet, columnsName, columns, indexLastGroup);
11434
+ }
11435
+ }
11436
+ else {
11437
+ this.setIndexGroups(groups, formatedDataSet);
11438
+ this.setRowNormal(columnsName, rowValues, row);
11439
+ }
11440
+ if (!row.groupHeader) {
11441
+ formatedDataSet.push(rowValues);
11442
+ }
11443
+ rowValues = [];
11444
+ });
11445
+ return [columnsName].concat(formatedDataSet);
11446
+ }
11185
11447
  }
11186
11448
 
11187
11449
  class Report {
@@ -11217,8 +11479,8 @@
11217
11479
  if (type === 'pdf') {
11218
11480
  return new PDFReport();
11219
11481
  }
11220
- if (type === 'xls') {
11221
- return new XLSReport();
11482
+ if (type === 'xls' || type === 'xls2' || type === 'xls3') {
11483
+ return new XLSReport(type);
11222
11484
  }
11223
11485
  throw new Error(`Invalid report type: ${type}`);
11224
11486
  }
@@ -11233,9 +11495,18 @@
11233
11495
  const reportType = this.getReportType(type);
11234
11496
  const { route } = reportType;
11235
11497
  const { name, columns, datasource } = this.iterable;
11498
+ const { groupedData } = Object.assign({}, this.iterable);
11236
11499
  const formattedColumns = this.removeActionColumns(columns);
11237
- const dataset = reportType.buildDataset(data, formattedColumns);
11238
11500
  const metadataObj = yield reportType.buildMetadata(name, this.title, formattedColumns, datasource.filter, portrait);
11501
+ let dataset;
11502
+ if ((reportType.type === 'xls2' || reportType.type === 'xls3') && groupedData) {
11503
+ const rowMetadata = rowObj.metaData;
11504
+ const metadataObjClone = merge__default["default"](rowMetadata, JSON.parse(metadataObj));
11505
+ dataset = reportType.buildDataset(groupedData, formattedColumns, metadataObjClone);
11506
+ }
11507
+ else {
11508
+ dataset = reportType.buildDataset(data, formattedColumns);
11509
+ }
11239
11510
  const filter = '[]';
11240
11511
  let row = {};
11241
11512
  if (rowObj) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.38.1",
3
+ "version": "1.39.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -37,5 +37,5 @@
37
37
  "lodash.times": "^4.3.2",
38
38
  "mockdate": "^3.0.2"
39
39
  },
40
- "gitHead": "42488b369e2e54bf20d39a3bb5bd66462bfec5e4"
40
+ "gitHead": "71a699db31a055a0ea5102b6903c97f80bc34edd"
41
41
  }
@@ -78,7 +78,7 @@ export declare class GridEditable extends Grid implements IGridEditable {
78
78
  * @param cellProps Column conditional props
79
79
  * @param events Component events
80
80
  */
81
- getEditableComponent(column: IGridColumnEditable, row: IDictionary<any>, cellProps: IDictionary<any>, events: any): {
81
+ getEditableComponent(column: IGridColumnEditable, row: IDictionary<any>, cellProps: IDictionary<any> | null, events: any): {
82
82
  name: string;
83
83
  parent: GridEditable;
84
84
  align: "left" | "center" | "right" | undefined;
@@ -105,6 +105,7 @@ export declare class Select extends TextInput implements ISelect {
105
105
  * @param field Field structure
106
106
  */
107
107
  private getDefaultDatasource;
108
+ overrideGet(): void;
108
109
  get search(): string;
109
110
  set search(value: string);
110
111
  /**
@@ -28,6 +28,10 @@ export declare class SelectMultiple extends Select implements ISelectMultiple {
28
28
  */
29
29
  get selectValue(): IDictionary<any>[];
30
30
  set selectValue(rows: IDictionary<any>[]);
31
+ /**
32
+ * Removes item from array a and add it to array b if condition is satisfied
33
+ */
34
+ private cutFromAToB;
31
35
  protected setFieldValue(value: any[]): Promise<boolean>;
32
36
  /**
33
37
  * Set value accessors
@@ -1,6 +1,8 @@
1
- import { IGrid } from '../zd-grid/interfaces';
1
+ import { IGrid, IGridEditable } from '../zd-grid/interfaces';
2
2
  export interface ITreeGrid extends IGrid {
3
3
  parentField?: string;
4
4
  openLevelOnLoad?: number | boolean;
5
5
  fetchOnDemand?: boolean;
6
6
  }
7
+ export interface ITreeGridEditable extends IGridEditable {
8
+ }
@@ -1,8 +1,9 @@
1
1
  import { IDictionary } from '@zeedhi/core';
2
2
  import { TreeGrid } from './tree-grid';
3
3
  import { GridColumnEditable } from '../zd-grid/grid-column-editable';
4
- import { IGridColumnEditable, IGridEditable } from '../zd-grid/interfaces';
5
- export declare class TreeGridEditable extends TreeGrid implements IGridEditable {
4
+ import { IGridColumnEditable } from '../zd-grid/interfaces';
5
+ import { ITreeGridEditable } from './interfaces';
6
+ export declare class TreeGridEditable extends TreeGrid implements ITreeGridEditable {
6
7
  /**
7
8
  * Editable columns
8
9
  */
@@ -25,7 +26,7 @@ export declare class TreeGridEditable extends TreeGrid implements IGridEditable
25
26
  * Enter edit mode on double click
26
27
  */
27
28
  doubleClickEdit: boolean;
28
- constructor(props: IGridEditable);
29
+ constructor(props: ITreeGridEditable);
29
30
  /**
30
31
  * Get Grid columns objects
31
32
  * @param columns Grid columns parameter
@@ -2,7 +2,8 @@ import { IDictionary } from '@zeedhi/core';
2
2
  import { IColumn } from '../../../components';
3
3
  export interface IReportType {
4
4
  readonly route: string;
5
- buildDataset(data: IDictionary[], columns?: IColumn[]): any;
5
+ type?: string;
6
+ buildDataset(data: IDictionary[], columns?: IColumn[], metadata?: any): any;
6
7
  buildMetadata(name: string, title: string, columns: IColumn[], filter?: IDictionary, portrait?: boolean): Promise<any>;
7
8
  }
8
9
  export declare type MetadataColumn = IDictionary<{
@@ -10,6 +11,7 @@ export declare type MetadataColumn = IDictionary<{
10
11
  description: string;
11
12
  sequence: number;
12
13
  size: string;
14
+ expression?: string;
13
15
  }>;
14
16
  export declare type MetadataFilter = {
15
17
  label: string;
@@ -34,5 +36,8 @@ export interface IMetadataObj {
34
36
  Version: string;
35
37
  };
36
38
  staticData: {};
37
- groups: [];
39
+ groups: Array<any>;
40
+ reportXLS?: boolean;
41
+ type?: string;
42
+ xlsMergedCell?: any[];
38
43
  }
@@ -1,8 +1,24 @@
1
1
  import { IDictionary } from '@zeedhi/core';
2
2
  import { IColumn } from '../../../components';
3
3
  import { BaseReport } from './base-report';
4
+ import { IMetadataObj } from './interfaces';
4
5
  export declare class XLSReport extends BaseReport {
5
6
  readonly route: string;
6
- buildDataset(data: IDictionary<any>[], columns: IColumn[]): string;
7
+ type: string;
8
+ constructor(type?: string);
9
+ buildDataset(data: IDictionary<any>[], columns: IColumn[], metadata?: IMetadataObj): string;
10
+ private formatRawDataSet;
7
11
  buildMetadata(name: string, title: string, columns: IColumn[], filter?: IDictionary<any>): Promise<string>;
12
+ private expressionZeedhiToXls;
13
+ private isFormat3;
14
+ private colunmXLS;
15
+ private getColumnsNameFormat3;
16
+ private getColumnsName;
17
+ private initVars;
18
+ private setRowGroupFormat3;
19
+ private formatRowFunc;
20
+ private setRowGroup;
21
+ private setIndexGroups;
22
+ private setRowNormal;
23
+ formatDataSet(metaData: IMetadataObj, dataSet: IDictionary[]): any[];
8
24
  }