@zeedhi/common 1.38.0 → 1.40.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.
Files changed (52) hide show
  1. package/dist/style.css +1 -1
  2. package/dist/zd-common.esm.js +590 -169
  3. package/dist/zd-common.umd.js +591 -168
  4. package/package.json +2 -2
  5. package/types/components/zd-alert/alert.d.ts +2 -0
  6. package/types/components/zd-breadcrumbs/breadcrumbs.d.ts +0 -8
  7. package/types/components/zd-button/button.d.ts +0 -8
  8. package/types/components/zd-button/interfaces.d.ts +0 -2
  9. package/types/components/zd-button-group/button-group.d.ts +0 -8
  10. package/types/components/zd-button-group/interfaces.d.ts +0 -2
  11. package/types/components/zd-card/card.d.ts +0 -8
  12. package/types/components/zd-card/interfaces.d.ts +0 -2
  13. package/types/components/zd-carousel/carousel.d.ts +0 -8
  14. package/types/components/zd-carousel/interfaces.d.ts +0 -2
  15. package/types/components/zd-component/component.d.ts +8 -0
  16. package/types/components/zd-component/interfaces.d.ts +2 -0
  17. package/types/components/zd-divider/divider.d.ts +0 -8
  18. package/types/components/zd-divider/interfaces.d.ts +0 -2
  19. package/types/components/zd-footer/footer.d.ts +0 -8
  20. package/types/components/zd-footer/interfaces.d.ts +0 -2
  21. package/types/components/zd-form/form.d.ts +10 -1
  22. package/types/components/zd-grid/grid-column.d.ts +2 -0
  23. package/types/components/zd-grid/grid-editable.d.ts +1 -1
  24. package/types/components/zd-grid/grid.d.ts +4 -0
  25. package/types/components/zd-grid/interfaces.d.ts +1 -0
  26. package/types/components/zd-header/header.d.ts +0 -8
  27. package/types/components/zd-icon/icon.d.ts +0 -8
  28. package/types/components/zd-icon/interfaces.d.ts +0 -2
  29. package/types/components/zd-input/input.d.ts +0 -8
  30. package/types/components/zd-iterable/column.d.ts +4 -2
  31. package/types/components/zd-list/interfaces.d.ts +0 -2
  32. package/types/components/zd-list/list.d.ts +0 -8
  33. package/types/components/zd-login/interfaces.d.ts +0 -1
  34. package/types/components/zd-login/login.d.ts +0 -4
  35. package/types/components/zd-menu/interfaces.d.ts +0 -1
  36. package/types/components/zd-menu/menu.d.ts +0 -4
  37. package/types/components/zd-progress/progress.d.ts +0 -8
  38. package/types/components/zd-select/select.d.ts +1 -0
  39. package/types/components/zd-select-multiple/select-multiple.d.ts +4 -0
  40. package/types/components/zd-select-tree/interfaces.d.ts +1 -0
  41. package/types/components/zd-select-tree/select-tree.d.ts +13 -1
  42. package/types/components/zd-select-tree-multiple/select-tree-multiple.d.ts +4 -0
  43. package/types/components/zd-steppers/interfaces.d.ts +0 -2
  44. package/types/components/zd-steppers/steppers.d.ts +0 -8
  45. package/types/components/zd-tree-grid/interfaces.d.ts +3 -1
  46. package/types/components/zd-tree-grid/tree-grid-editable.d.ts +4 -3
  47. package/types/utils/report/index.d.ts +2 -0
  48. package/types/utils/report/report-type/base-report.d.ts +3 -1
  49. package/types/utils/report/report-type/interfaces.d.ts +8 -2
  50. package/types/utils/report/report-type/xls-report.d.ts +1 -0
  51. package/types/utils/report/report-type/xls2-report.d.ts +16 -0
  52. package/types/utils/report/report-type/xls3-report.d.ts +16 -0
@@ -55,6 +55,14 @@
55
55
  * Controls component visibility.
56
56
  */
57
57
  this.isVisible = true;
58
+ /**
59
+ * Applies the dark theme variant to the component.
60
+ */
61
+ this.dark = false;
62
+ /**
63
+ * Applies the light theme variant to the component.
64
+ */
65
+ this.light = false;
58
66
  /**
59
67
  * Define component key mapping
60
68
  */
@@ -70,6 +78,8 @@
70
78
  this.cssClass = this.getInitValue('cssClass', props.cssClass, this.cssClass);
71
79
  this.cssStyle = this.getInitValue('cssStyle', props.cssStyle, this.cssStyle);
72
80
  this.isVisible = this.getInitValue('isVisible', props.isVisible, this.isVisible);
81
+ this.dark = this.getInitValue('dark', props.dark, this.dark);
82
+ this.light = this.getInitValue('light', props.light, this.light);
73
83
  this.children = Array.isArray(props.children) ? props.children : this.children;
74
84
  this.keyMap = core.KeyMap.factory(props.keyMap || this.keyMap);
75
85
  this.createAccessors();
@@ -305,6 +315,8 @@
305
315
  this.vertical = false;
306
316
  this.defaultValues = {
307
317
  name: this.name,
318
+ dark: this.dark,
319
+ light: this.light,
308
320
  color: this.color,
309
321
  text: this.text,
310
322
  timeout: this.timeout,
@@ -329,6 +341,8 @@
329
341
  assignAlertProperties(alert) {
330
342
  this.name = this.getInitValue('name', alert.name, this.defaultValues.name);
331
343
  this.color = this.getInitValue('color', alert.color, this.defaultValues.color);
344
+ this.dark = this.getInitValue('dark', alert.dark, this.defaultValues.dark);
345
+ this.light = this.getInitValue('light', alert.light, this.defaultValues.light);
332
346
  this.text = this.getInitValue('text', alert.text, this.defaultValues.text);
333
347
  this.timeout = this.getInitValue('timeout', alert.timeout, this.defaultValues.timeout);
334
348
  this.type = this.getInitValue('type', alert.type, this.defaultValues.type);
@@ -499,10 +513,6 @@
499
513
  */
500
514
  constructor(props) {
501
515
  super(props);
502
- /**
503
- * Applies the dark theme variant to the component.
504
- */
505
- this.dark = false;
506
516
  /**
507
517
  * Specifies the dividing string between items.
508
518
  */
@@ -519,19 +529,13 @@
519
529
  * Increase the font-size of the breadcrumb item text to 16px.
520
530
  */
521
531
  this.large = false;
522
- /**
523
- * Applies the light theme variant to the component.
524
- */
525
- this.light = true;
526
532
  /**
527
533
  * Decrease the font-size of the breadcrumb item text to 12px.
528
534
  */
529
535
  this.small = false;
530
- this.dark = this.getInitValue('dark', props.dark, this.dark);
531
536
  this.divider = this.getInitValue('divider', props.divider, this.divider);
532
537
  this.items = this.getInitValue('items', props.items, this.items);
533
538
  this.large = this.getInitValue('large', props.large, this.large);
534
- this.light = this.getInitValue('light', props.light, this.light);
535
539
  this.iconName = this.getInitValue('iconName', props.iconName, this.iconName);
536
540
  this.small = this.getInitValue('small', props.small, this.small);
537
541
  this.createAccessors();
@@ -567,10 +571,6 @@
567
571
  * It can be the name of material or css color in hexa
568
572
  */
569
573
  this.color = 'primary';
570
- /**
571
- * Applies the dark theme variant to the button
572
- */
573
- this.dark = false;
574
574
  /**
575
575
  * Removes the ability to click or target the button
576
576
  */
@@ -612,10 +612,6 @@
612
612
  * This should be used with the absolute or fixed props
613
613
  */
614
614
  this.left = false;
615
- /**
616
- * Applies the light theme variant to the button
617
- */
618
- this.light = false;
619
615
  /**
620
616
  * Makes the background transparent and applies a thin border
621
617
  */
@@ -718,10 +714,6 @@
718
714
  * It can be the name of material or css color in hexa
719
715
  */
720
716
  this.color = 'primary';
721
- /**
722
- * Applies the dark theme variant to the component.
723
- */
724
- this.dark = false;
725
717
  /**
726
718
  * Reduces the button size and padding.
727
719
  */
@@ -731,10 +723,6 @@
731
723
  * space between the buttons
732
724
  */
733
725
  this.group = false;
734
- /**
735
- * Applies the light theme variant to the component.
736
- */
737
- this.light = false;
738
726
  /**
739
727
  * Applies mandatory selected button
740
728
  */
@@ -768,10 +756,8 @@
768
756
  this.backgroundColor = this.getInitValue('backgroundColor', props.backgroundColor, this.backgroundColor);
769
757
  this.borderless = this.getInitValue('block', props.borderless, this.borderless);
770
758
  this.color = this.getInitValue('color', props.color, this.color);
771
- this.dark = this.getInitValue('dark', props.dark, this.dark);
772
759
  this.dense = this.getInitValue('disabled', props.dense, this.dense);
773
760
  this.group = this.getInitValue('group', props.group, this.group);
774
- this.light = this.getInitValue('light', props.light, this.light);
775
761
  this.mandatory = this.getInitValue('mandatory', props.mandatory, this.mandatory);
776
762
  this.multiple = this.getInitValue('multiple', props.multiple, this.multiple);
777
763
  this.rounded = this.getInitValue('rounded', props.rounded, this.rounded);
@@ -825,10 +811,6 @@
825
811
  * a non-integer number in slidesPerView, like 1.5)
826
812
  */
827
813
  this.center = false;
828
- /**
829
- * Applies the dark theme variant to the carousel pagination
830
- */
831
- this.dark = false;
832
814
  /**
833
815
  * Displays the pagination as a fraction in the following format: currentSlide/slidesCount.
834
816
  * Only works when <code>showPagination</code> property is true
@@ -855,10 +837,6 @@
855
837
  * Allows controlling the carousel using the keyboard arrow keys
856
838
  */
857
839
  this.keysControl = true;
858
- /**
859
- * Applies the light theme variant to the carousel
860
- */
861
- this.light = true;
862
840
  /**
863
841
  * Allows controlling the carousel using mouse drag
864
842
  */
@@ -933,14 +911,12 @@
933
911
  this.autoPlay = this.getInitValue('autoPlay', props.autoPlay, this.autoPlay);
934
912
  this.buttonsOutside = this.getInitValue('buttonsOutside', props.buttonsOutside, this.buttonsOutside);
935
913
  this.center = this.getInitValue('center', props.center, this.center);
936
- this.dark = this.getInitValue('dark', props.dark, this.dark);
937
914
  this.height = this.getInitValue('height', props.height, this.height);
938
915
  this.infiniteScroll = this.getInitValue('infiniteScroll', props.infiniteScroll, this.infiniteScroll);
939
916
  this.initialSlide = this.getInitValue('initialSlide', props.initialSlide, this.initialSlide);
940
917
  this.currentSlide = this.getInitValue('currentSlide', props.currentSlide, this.initialSlide);
941
918
  this.interval = this.getInitValue('interval', props.interval, this.interval);
942
919
  this.keysControl = this.getInitValue('keysControl', props.keysControl, this.keysControl);
943
- this.light = this.getInitValue('light', props.light, this.light);
944
920
  this.mouseControl = this.getInitValue('mouseControl', props.mouseControl, this.mouseControl);
945
921
  this.nextButton = props.nextButton || this.nextButton;
946
922
  this.fractionPagination = this.getInitValue('fractionPagination', props.fractionPagination, this.fractionPagination);
@@ -1055,10 +1031,6 @@
1055
1031
  * Applies specified color to the control. It can be the name of material color
1056
1032
  */
1057
1033
  this.color = '';
1058
- /**
1059
- * Applies the dark theme variant to the component
1060
- */
1061
- this.dark = false;
1062
1034
  /**
1063
1035
  * Removes the ability to click or target the component
1064
1036
  */
@@ -1075,10 +1047,6 @@
1075
1047
  * Specifies an image background for the card
1076
1048
  */
1077
1049
  this.img = '';
1078
- /**
1079
- * Applies the light theme variant to the component
1080
- */
1081
- this.light = false;
1082
1050
  /**
1083
1051
  * Designates that the card is a link
1084
1052
  */
@@ -1102,7 +1070,6 @@
1102
1070
  this.activeClass = this.getInitValue('activeClass', props.activeClass, this.activeClass);
1103
1071
  this.append = this.getInitValue('append', props.append, this.append);
1104
1072
  this.color = this.getInitValue('color', props.color, this.color);
1105
- this.dark = this.getInitValue('dark', props.dark, this.dark);
1106
1073
  this.disabled = this.getInitValue('disabled', props.disabled, this.disabled);
1107
1074
  this.elevation = this.getInitValue('elevation', props.elevation, this.elevation);
1108
1075
  this.flat = this.getInitValue('flat', props.flat, this.flat);
@@ -1110,7 +1077,6 @@
1110
1077
  this.hover = this.getInitValue('hover', props.hover, this.hover);
1111
1078
  this.href = this.getInitValue('href', props.href, this.href);
1112
1079
  this.img = this.getInitValue('img', props.img, this.img);
1113
- this.light = this.getInitValue('light', props.light, this.light);
1114
1080
  this.link = this.getInitValue('link', props.link, this.link);
1115
1081
  this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
1116
1082
  this.maxWidth = this.getInitValue('maxWidth', props.maxWidth, this.maxWidth);
@@ -1323,10 +1289,6 @@
1323
1289
  * It can be the name of material or css color in hexa.
1324
1290
  */
1325
1291
  this.color = 'primary';
1326
- /**
1327
- * Applies the dark theme variant to the input.
1328
- */
1329
- this.dark = false;
1330
1292
  /**
1331
1293
  * Defines smaller input.
1332
1294
  */
@@ -1343,10 +1305,6 @@
1343
1305
  * Defines the input label.
1344
1306
  */
1345
1307
  this.label = '';
1346
- /**
1347
- * Applies the light theme variant to the input.
1348
- */
1349
- this.light = false;
1350
1308
  /**
1351
1309
  * Applies a custom character mask to the input.
1352
1310
  */
@@ -1415,13 +1373,11 @@
1415
1373
  this.autofocus = this.getInitValue('autofocus', props.autofocus, this.autofocus);
1416
1374
  this.clearable = this.getInitValue('clearable', props.clearable, this.clearable);
1417
1375
  this.color = this.getInitValue('color', props.color, this.color);
1418
- this.dark = this.getInitValue('dark', props.dark, this.dark);
1419
1376
  this.dense = this.getInitValue('dense', props.dense, this.dense);
1420
1377
  this.disabled = this.getInitValue('disabled', props.disabled, this.disabled);
1421
1378
  this.hint = this.getInitValue('hint', props.hint, this.hint);
1422
1379
  this.autoHintDetails = this.getInitValue('autoHintDetails', props.autoHintDetails, this.autoHintDetails);
1423
1380
  this.label = this.getInitValue('label', props.label, this.label);
1424
- this.light = this.getInitValue('light', props.light, this.light);
1425
1381
  this.mask = this.getInitValue('mask', props.mask, this.mask);
1426
1382
  this.maxLength = this.getInitValue('maxLength', props.maxLength, this.maxLength);
1427
1383
  this.persistentHint = this.getInitValue('persistentHint', props.persistentHint, this.persistentHint);
@@ -3679,18 +3635,10 @@
3679
3635
  */
3680
3636
  constructor(props) {
3681
3637
  super(props);
3682
- /**
3683
- * Applies the dark theme variant to the component.
3684
- */
3685
- this.dark = false;
3686
3638
  /**
3687
3639
  * Adds indentation (72px) for normal dividers, reduces max height for vertical.
3688
3640
  */
3689
3641
  this.inset = false;
3690
- /**
3691
- * Applies the light theme variant to the component.
3692
- */
3693
- this.light = false;
3694
3642
  /**
3695
3643
  * Displays dividers vertically.
3696
3644
  */
@@ -3960,10 +3908,6 @@
3960
3908
  * Applies specified color to the control. It can be the name of material or css color in hexa.
3961
3909
  */
3962
3910
  this.color = 'primary';
3963
- /**
3964
- * Applies the dark theme variant to footer.
3965
- */
3966
- this.dark = false;
3967
3911
  /**
3968
3912
  * Applies position fixed to footer.
3969
3913
  */
@@ -3980,10 +3924,6 @@
3980
3924
  * Render components on the left of footer.
3981
3925
  */
3982
3926
  this.leftSlot = [];
3983
- /**
3984
- * Applies the light theme variant to the footer.
3985
- */
3986
- this.light = false;
3987
3927
  /**
3988
3928
  * Remove all padding from the footer.
3989
3929
  */
@@ -4320,11 +4260,11 @@
4320
4260
  * Apply conditions
4321
4261
  * @param row Datasource row
4322
4262
  */
4323
- applyCondition(row) {
4263
+ applyCondition(row, factoredConditions = this.factoredConditions) {
4324
4264
  const appliedConditions = {};
4325
- Object.keys(this.factoredConditions).forEach((condition) => {
4326
- const conditionFunction = this.factoredConditions[condition];
4327
- set__default["default"](appliedConditions, condition, conditionFunction({ row }));
4265
+ Object.keys(factoredConditions).forEach((condition) => {
4266
+ const conditionFunction = factoredConditions[condition];
4267
+ set__default["default"](appliedConditions, condition, conditionFunction({ row, column: this }));
4328
4268
  });
4329
4269
  return appliedConditions;
4330
4270
  }
@@ -4338,11 +4278,7 @@
4338
4278
  const appliedConditions = {};
4339
4279
  Object.keys(this.actionFactoredConditions).forEach((action) => {
4340
4280
  const factoredConditions = this.actionFactoredConditions[action];
4341
- appliedConditions[action] = {};
4342
- Object.keys(factoredConditions).forEach((condition) => {
4343
- const conditionFunction = factoredConditions[condition];
4344
- set__default["default"](appliedConditions[action], condition, conditionFunction({ row }));
4345
- });
4281
+ appliedConditions[action] = Object.assign({}, this.applyCondition(row, factoredConditions));
4346
4282
  });
4347
4283
  return appliedConditions;
4348
4284
  }
@@ -4720,7 +4656,11 @@
4720
4656
  /**
4721
4657
  * Color of the header background
4722
4658
  */
4723
- this.headerBackground = 'white';
4659
+ this.headerBackground = '';
4660
+ /**
4661
+ * Color of the header cell text color
4662
+ */
4663
+ this.headerCellTextColor = '';
4724
4664
  /**
4725
4665
  * Available order types
4726
4666
  * @public
@@ -4764,6 +4704,8 @@
4764
4704
  },
4765
4705
  };
4766
4706
  this.dense = this.getInitValue('dense', props.dense, this.dense);
4707
+ this.dark = this.getInitValue('dark', props.dark, this.dark);
4708
+ this.light = this.getInitValue('light', props.light, this.light);
4767
4709
  this.selectable = this.getInitValue('selectable', props.selectable, this.selectable);
4768
4710
  this.height = this.getInitValue('height', props.height, this.height);
4769
4711
  this.fillHeight = this.getInitValue('fillHeight', props.fillHeight, this.fillHeight);
@@ -4773,6 +4715,7 @@
4773
4715
  this.showFooter = this.getInitValue('showFooter', props.showFooter, this.showFooter);
4774
4716
  this.showHeader = this.getInitValue('showHeader', props.showHeader, this.showHeader);
4775
4717
  this.headerBackground = this.getInitValue('headerBackground', props.headerBackground, this.headerBackground);
4718
+ this.headerCellTextColor = this.getInitValue('headerCellTextColor', props.headerCellTextColor, this.headerCellTextColor);
4776
4719
  this.dragColumns = this.getInitValue('dragColumns', props.dragColumns, this.dragColumns);
4777
4720
  this.resizeColumns = this.getInitValue('resizeColumns', props.resizeColumns, this.resizeColumns);
4778
4721
  this.toolbarSlot = props.toolbarSlot || this.toolbarSlot;
@@ -5075,7 +5018,6 @@
5075
5018
  if (this.editing)
5076
5019
  return;
5077
5020
  if (column.editable) {
5078
- this.selectedRows = [];
5079
5021
  this.editing = true;
5080
5022
  this.preventRowClick = true;
5081
5023
  this.datasource.currentRow = row;
@@ -5145,7 +5087,7 @@
5145
5087
  else {
5146
5088
  colValue = row[column.name];
5147
5089
  }
5148
- const componentProps = merge__default["default"]({}, column.componentProps, cellProps.componentProps);
5090
+ const componentProps = merge__default["default"]({}, column.componentProps, cellProps === null || cellProps === void 0 ? void 0 : cellProps.componentProps);
5149
5091
  let compEvents = {};
5150
5092
  if (componentProps && componentProps.events) {
5151
5093
  compEvents = core.Event.factory(componentProps.events);
@@ -5432,10 +5374,6 @@
5432
5374
  * Applies specified color to the control. It can be the name of material or css color in hexa.
5433
5375
  */
5434
5376
  this.color = 'primary';
5435
- /**
5436
- * Applies the dark theme variant to header.
5437
- */
5438
- this.dark = false;
5439
5377
  /**
5440
5378
  * Designates that the application menu positioned on the left is below the header.
5441
5379
  */
@@ -5460,10 +5398,6 @@
5460
5398
  * Render components on the left of header.
5461
5399
  */
5462
5400
  this.leftSlot = [];
5463
- /**
5464
- * Applies the light theme variant to the header.
5465
- */
5466
- this.light = false;
5467
5401
  /**
5468
5402
  * Removes internal padding from header.
5469
5403
  */
@@ -5478,13 +5412,11 @@
5478
5412
  this.clippedLeft = this.getInitValue('clippedLeft', props.clippedLeft, this.clippedLeft);
5479
5413
  this.clippedRight = this.getInitValue('clippedRight', props.clippedRight, this.clippedRight);
5480
5414
  this.color = this.getInitValue('color', props.color, this.color);
5481
- this.dark = this.getInitValue('dark', props.dark, this.dark);
5482
5415
  this.dense = this.getInitValue('dense', props.dense, this.dense);
5483
5416
  this.elevation = this.getInitValue('elevation', props.elevation, this.elevation);
5484
5417
  this.fixed = this.getInitValue('fixed', props.fixed, this.fixed);
5485
5418
  this.height = this.getInitValue('height', props.height, this.height);
5486
5419
  this.leftSlot = props.leftSlot || this.leftSlot;
5487
- this.light = this.getInitValue('light', props.light, this.light);
5488
5420
  this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
5489
5421
  this.maxWidth = this.getInitValue('maxWidth', props.maxWidth, this.maxWidth);
5490
5422
  this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
@@ -5518,10 +5450,6 @@
5518
5450
  * (for example success or purple) or css color (#033 or rgba(255, 0, 0, 0.5)).
5519
5451
  */
5520
5452
  this.color = '';
5521
- /**
5522
- * Applies the dark theme variant to the component.
5523
- */
5524
- this.dark = false;
5525
5453
  /**
5526
5454
  * Makes icon smaller (20px)
5527
5455
  */
@@ -5543,10 +5471,6 @@
5543
5471
  * of a button when placed to the left of another element or text
5544
5472
  */
5545
5473
  this.left = false;
5546
- /**
5547
- * Applies the light theme variant to the component.
5548
- */
5549
- this.light = false;
5550
5474
  /**
5551
5475
  * Applies appropriate margins to the icon inside of
5552
5476
  * a button when placed to the right of another element or text
@@ -5565,13 +5489,11 @@
5565
5489
  */
5566
5490
  this.tag = 'i';
5567
5491
  this.color = this.getInitValue('color', props.color, this.color);
5568
- this.dark = this.getInitValue('dark', props.dark, this.dark);
5569
5492
  this.dense = this.getInitValue('dense', props.dense, this.dense);
5570
5493
  this.disabled = this.getInitValue('disabled', props.disabled, this.disabled);
5571
5494
  this.iconName = this.getInitValue('iconName', props.iconName, this.iconName);
5572
5495
  this.large = this.getInitValue('large', props.large, this.large);
5573
5496
  this.left = this.getInitValue('left', props.left, this.left);
5574
- this.light = this.getInitValue('light', props.light, this.light);
5575
5497
  this.right = this.getInitValue('right', props.right, this.right);
5576
5498
  this.size = this.getInitValue('size', props.size, this.size);
5577
5499
  this.small = this.getInitValue('small', props.small, this.small);
@@ -5938,6 +5860,7 @@
5938
5860
  this.cachedData = [];
5939
5861
  this.cachedTotal = 0;
5940
5862
  this.formatterFn = core.FormatterParserProvider.getFormatter('ZdSelect');
5863
+ this.pushedValue = null;
5941
5864
  this.loadMoreQtty = 0;
5942
5865
  this.debounceSearch = debounce__default["default"](this.doSearch, 500);
5943
5866
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'expand');
@@ -5959,6 +5882,7 @@
5959
5882
  this.dataText = [this.dataText];
5960
5883
  const defaultDatasource = this.getDefaultDatasource(props);
5961
5884
  this.datasource = core.DatasourceFactory.factory(defaultDatasource);
5885
+ this.overrideGet();
5962
5886
  let defaultValue = props.value;
5963
5887
  if (core.Accessor.isAccessorDefinition(props.value)) {
5964
5888
  defaultValue = this.getAccessorValue(props.value);
@@ -5989,6 +5913,16 @@
5989
5913
  const searchIn = (((_a = field.datasource) === null || _a === void 0 ? void 0 : _a.searchIn) || []).concat(searchInDefault);
5990
5914
  return Object.assign(Object.assign({}, field.datasource), { searchIn, lazyLoad: (field.value !== '' && field.value !== undefined) || (field.datasource && field.datasource.lazyLoad) });
5991
5915
  }
5916
+ overrideGet() {
5917
+ const oldGet = this.datasource.get;
5918
+ this.datasource.get = () => __awaiter(this, void 0, void 0, function* () {
5919
+ yield oldGet.call(this.datasource);
5920
+ if (this.indexOf(this.value) !== -1 || this.datasource.search || this.isFocused)
5921
+ return;
5922
+ yield this.setValue(this.value, false);
5923
+ this.removePushedValue();
5924
+ });
5925
+ }
5992
5926
  get search() {
5993
5927
  return this.searchValue;
5994
5928
  }
@@ -6015,7 +5949,7 @@
6015
5949
  }
6016
5950
  if (this.manualMode)
6017
5951
  return;
6018
- this.cachedData = this.datasource.data;
5952
+ this.cachedData = [...this.datasource.data];
6019
5953
  this.cachedTotal = this.datasource.total;
6020
5954
  if (pushed) {
6021
5955
  this.pushedValue = this.selectedData;
@@ -6074,10 +6008,14 @@
6074
6008
  if (!this.pushedValue && this.isFilledObj(this.selectValue) && this.indexOf(this.selectValue) === -1) {
6075
6009
  this.pushedValue = this.selectValue;
6076
6010
  }
6077
- if (this.isFilledObj(this.pushedValue) && this.indexOf(this.pushedValue) === -1) {
6011
+ const index = this.indexOf(this.pushedValue);
6012
+ if (this.isFilledObj(this.pushedValue) && index === -1) {
6078
6013
  this.datasource.data.unshift(this.pushedValue);
6079
6014
  }
6080
- this.cachedData = this.datasource.data;
6015
+ else if (index !== 0) {
6016
+ this.pushedValue = null;
6017
+ }
6018
+ this.cachedData = [...this.datasource.data];
6081
6019
  this.cachedTotal = this.datasource.total;
6082
6020
  }
6083
6021
  /**
@@ -6136,6 +6074,7 @@
6136
6074
  }
6137
6075
  if (!searchValue) {
6138
6076
  this.setFieldRowValue(null);
6077
+ this.selectValue = this.selectedData;
6139
6078
  return false;
6140
6079
  }
6141
6080
  this.setFieldRowValue(searchValue);
@@ -6246,7 +6185,7 @@
6246
6185
  else {
6247
6186
  this.removePushedValue();
6248
6187
  this.datasource.search = this.searchValue;
6249
- this.datasource.data = this.cachedData;
6188
+ this.datasource.data = [...this.cachedData];
6250
6189
  this.datasource.total = this.cachedTotal;
6251
6190
  }
6252
6191
  });
@@ -6259,6 +6198,11 @@
6259
6198
  yield this.datasource.setLimit(this.datasource.limit + this.loadMoreQtty);
6260
6199
  if (!this.datasource.search) {
6261
6200
  this.afterLoad();
6201
+ const { dataValue } = this;
6202
+ const isSelected = this.selectValue && this.pushedValue && this.selectValue[dataValue] === this.pushedValue[dataValue];
6203
+ if (isSelected)
6204
+ return;
6205
+ this.removePushedValue();
6262
6206
  }
6263
6207
  });
6264
6208
  }
@@ -6272,7 +6216,7 @@
6272
6216
  this.datasource.search = '';
6273
6217
  this.dirtySearchValue = '';
6274
6218
  if (!this.manualMode) {
6275
- this.datasource.data = this.cachedData;
6219
+ this.datasource.data = [...this.cachedData];
6276
6220
  this.datasource.total = this.cachedTotal;
6277
6221
  }
6278
6222
  this.checkValueOnBlur();
@@ -6285,13 +6229,17 @@
6285
6229
  }
6286
6230
  if (this.manualMode)
6287
6231
  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;
6232
+ if (this.isFilledObj(this.selectValue) && this.indexOf(this.selectValue) === -1) {
6233
+ if (this.pushedValue) {
6234
+ this.removePushedValue();
6292
6235
  }
6236
+ this.datasource.data.unshift(this.selectValue);
6237
+ this.pushedValue = this.selectValue;
6293
6238
  return;
6294
6239
  }
6240
+ const { dataValue } = this;
6241
+ if (this.pushedValue && this.selectValue && this.selectValue[dataValue] === this.pushedValue[dataValue])
6242
+ return;
6295
6243
  this.removePushedValue();
6296
6244
  }
6297
6245
  showLoadMore() {
@@ -6529,10 +6477,6 @@
6529
6477
  class List extends ComponentRender {
6530
6478
  constructor(props) {
6531
6479
  super(props);
6532
- /**
6533
- * Applies the dark theme variant to the List.
6534
- */
6535
- this.dark = false;
6536
6480
  /**
6537
6481
  * Create the list with smaller items.
6538
6482
  */
@@ -6545,10 +6489,6 @@
6545
6489
  * Render list with dividers between the items.
6546
6490
  */
6547
6491
  this.divided = false;
6548
- /**
6549
- * Applies the light theme variant to the List.
6550
- */
6551
- this.light = false;
6552
6492
  /**
6553
6493
  * Increases the height of all the list items to better support three lines of text.
6554
6494
  */
@@ -6693,10 +6633,6 @@
6693
6633
  * It can be the name of material or css color in hexa.
6694
6634
  */
6695
6635
  this.color = '';
6696
- /**
6697
- * Applies the dark theme.
6698
- */
6699
- this.dark = false;
6700
6636
  /**
6701
6637
  * Card position orientation.
6702
6638
  */
@@ -6725,7 +6661,6 @@
6725
6661
  this.bottomLink = props.bottomLink || this.bottomLink;
6726
6662
  this.cardWidth = this.getInitValue('cardWidth', props.cardWidth, this.cardWidth);
6727
6663
  this.color = this.getInitValue('color', props.color, this.color);
6728
- this.dark = this.getInitValue('dark', props.dark, this.dark);
6729
6664
  this.layout = this.getInitValue('layout', props.layout, this.layout);
6730
6665
  this.logo = this.getInitValue('logo', props.logo, this.logo);
6731
6666
  this.logoMessage = this.getInitValue('logoMessage', props.logoMessage, this.logoMessage);
@@ -6952,10 +6887,6 @@
6952
6887
  * Defines if the menu should have a visible container
6953
6888
  */
6954
6889
  this.floating = false;
6955
- /**
6956
- * Applies the dark theme variant to the menu.
6957
- */
6958
- this.dark = false;
6959
6890
  /**
6960
6891
  * Create the menu with smaller items.
6961
6892
  */
@@ -7038,7 +6969,6 @@
7038
6969
  this.clipped = this.getInitValue('clipped', props.clipped, this.clipped);
7039
6970
  this.fixed = this.getInitValue('fixed', props.fixed, this.fixed);
7040
6971
  this.floating = this.getInitValue('floating', props.floating, this.floating);
7041
- this.dark = this.getInitValue('dark', props.dark, this.dark);
7042
6972
  this.dense = this.getInitValue('dense', props.dense, this.dense);
7043
6973
  this.mini = this.getInitValue('mini', props.mini, this.mini);
7044
6974
  this.miniState = this.getInitValue('miniState', props.miniState, this.miniState);
@@ -7679,10 +7609,6 @@
7679
7609
  * Defines the value color
7680
7610
  */
7681
7611
  this.color = 'primary';
7682
- /**
7683
- * Applies the dark theme variant to the component
7684
- */
7685
- this.dark = false;
7686
7612
  /**
7687
7613
  * Sets the height for the component
7688
7614
  */
@@ -7691,10 +7617,6 @@
7691
7617
  * Animates the component constantly
7692
7618
  */
7693
7619
  this.indeterminate = false;
7694
- /**
7695
- * Applies the light theme variant to the component
7696
- */
7697
- this.light = false;
7698
7620
  /**
7699
7621
  * Render components on the progress component
7700
7622
  */
@@ -7706,10 +7628,8 @@
7706
7628
  this.backgroundColor = this.getInitValue('backgroundColor', props.backgroundColor, this.backgroundColor);
7707
7629
  this.backgroundOpacity = this.getInitValue('backgroundOpacity', props.backgroundOpacity, this.backgroundOpacity);
7708
7630
  this.color = this.getInitValue('color', props.color, this.color);
7709
- this.dark = this.getInitValue('dark', props.dark, this.dark);
7710
7631
  this.height = this.getInitValue('height', props.height, this.height);
7711
7632
  this.indeterminate = this.getInitValue('indeterminate', props.indeterminate, this.indeterminate);
7712
- this.light = this.getInitValue('light', props.light, this.light);
7713
7633
  this.centerSlot = this.getInitValue('centerSlot', props.centerSlot, this.centerSlot);
7714
7634
  this.value = this.getInitValue('value', props.value, this.value);
7715
7635
  this.createAccessors();
@@ -7936,20 +7856,23 @@
7936
7856
  set selectValue(rows) {
7937
7857
  if (!Array.isArray(rows))
7938
7858
  return;
7939
- if (!this.manualMode && this.insertedValues.length > 0) {
7940
- this.insertsRemoved = [];
7859
+ if (!this.manualMode) {
7941
7860
  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
- });
7861
+ this.cutFromAToB(this.insertedValues, this.insertsRemoved, (value) => !values.includes(value[this.dataValue]));
7862
+ this.cutFromAToB(this.insertsRemoved, this.insertedValues, (value) => values.includes(value[this.dataValue]));
7949
7863
  }
7950
7864
  this.selectedValue = rows;
7951
7865
  this.setFieldValue(this.getValues(rows));
7952
7866
  }
7867
+ /**
7868
+ * Removes item from array a and add it to array b if condition is satisfied
7869
+ */
7870
+ cutFromAToB(a, b, condition) {
7871
+ const indices = a.reduce((result, value, index) => (condition(value) ? [...result, index] : result), []);
7872
+ indices.forEach((index) => {
7873
+ b.push(a.splice(index)[0]);
7874
+ });
7875
+ }
7953
7876
  setFieldValue(value) {
7954
7877
  return __awaiter(this, void 0, void 0, function* () {
7955
7878
  const promises = [];
@@ -8126,7 +8049,7 @@
8126
8049
  showLoadMore() {
8127
8050
  return !!this.datasource.data.length
8128
8051
  && !this.datasource.loadAll
8129
- && (this.datasource.data.length - this.insertedValues.length) < this.datasource.total;
8052
+ && (this.datasource.data.length - this.insertedValues.length - this.insertsRemoved.length) < this.datasource.total;
8130
8053
  }
8131
8054
  /**
8132
8055
  * Load more data
@@ -8134,10 +8057,16 @@
8134
8057
  loadMore() {
8135
8058
  return __awaiter(this, void 0, void 0, function* () {
8136
8059
  yield this.datasource.setLimit(this.datasource.limit + this.loadMoreQtty);
8060
+ this.insertsRemoved = this.insertsRemoved.filter((insert) => {
8061
+ const value = insert[this.dataValue];
8062
+ const foundInData = this.datasource.data.find(this.getCondition(value));
8063
+ return !foundInData;
8064
+ });
8065
+ this.insertSelected();
8137
8066
  if (!this.datasource.search) {
8138
8067
  this.setCache();
8139
8068
  }
8140
- this.insertSelected();
8069
+ this.removePushedValue();
8141
8070
  });
8142
8071
  }
8143
8072
  /**
@@ -8331,6 +8260,9 @@
8331
8260
  }
8332
8261
  return item;
8333
8262
  });
8263
+ if (parent) { // remove all existing children to add new ones
8264
+ this.treeData = this.treeData.filter((item) => item.tree__parent !== parent);
8265
+ }
8334
8266
  if (!parent) {
8335
8267
  this.treeData = childData;
8336
8268
  }
@@ -8514,7 +8446,7 @@
8514
8446
  this.treeStructure = {};
8515
8447
  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
8448
  this.treeData = childData;
8517
- this.treeStructure['no-parent'] = this.originalDatasource.data;
8449
+ this.treeStructure['no-parent'] = childData;
8518
8450
  }
8519
8451
  /**
8520
8452
  * Search value against a memory datasource
@@ -8635,6 +8567,10 @@
8635
8567
  * Defines if field value should be an object
8636
8568
  */
8637
8569
  this.returnObject = false;
8570
+ /**
8571
+ * Prevents load select data when the input is focused
8572
+ */
8573
+ this.preventLoadOnFocus = true;
8638
8574
  /**
8639
8575
  * Field used to make the item disabled
8640
8576
  */
@@ -8649,6 +8585,7 @@
8649
8585
  * Defines if should wait and not execute GET method when Datasource is created
8650
8586
  */
8651
8587
  this.lazyLoad = true;
8588
+ this.selectValue = null;
8652
8589
  this.nodes = this.getInitValue('nodes', props.nodes, this.nodes);
8653
8590
  this.alwaysOpen = this.getInitValue('alwaysOpen', props.alwaysOpen, this.alwaysOpen);
8654
8591
  this.flattenSearchResults = this.getInitValue('flattenSearchResults', props.flattenSearchResults, this.flattenSearchResults);
@@ -8666,6 +8603,7 @@
8666
8603
  this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
8667
8604
  this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
8668
8605
  this.disabledItems = this.getInitValue('disabledItems', props.disabledItems, this.disabledItems);
8606
+ this.preventLoadOnFocus = this.getInitValue('preventLoadOnFocus', props.preventLoadOnFocus, this.preventLoadOnFocus);
8669
8607
  if (props.datasource && Object.keys(props.datasource).length) {
8670
8608
  this.lazyLoad = props.datasource.lazyLoad !== false;
8671
8609
  const searchFields = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
@@ -8679,6 +8617,24 @@
8679
8617
  }
8680
8618
  this.createAccessors();
8681
8619
  }
8620
+ focus(event, element) {
8621
+ const _super = Object.create(null, {
8622
+ focus: { get: () => super.focus }
8623
+ });
8624
+ return __awaiter(this, void 0, void 0, function* () {
8625
+ _super.focus.call(this, event, element);
8626
+ this.afterFocus();
8627
+ });
8628
+ }
8629
+ afterFocus() {
8630
+ var _a;
8631
+ return __awaiter(this, void 0, void 0, function* () {
8632
+ if (!this.preventLoadOnFocus) {
8633
+ yield ((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.get());
8634
+ this.preventLoadOnFocus = true;
8635
+ }
8636
+ });
8637
+ }
8682
8638
  createDataStructure() {
8683
8639
  this.treeDataStructure = new TreeDataStructure({
8684
8640
  datasource: this.datasource,
@@ -8816,8 +8772,41 @@
8816
8772
  get searchValue() {
8817
8773
  return this.lastInputValue;
8818
8774
  }
8775
+ clearRow(row) {
8776
+ const result = Object.assign({}, row);
8777
+ Object.keys(result).forEach((key) => {
8778
+ if (key.indexOf('tree__') === 0) {
8779
+ delete result[key];
8780
+ }
8781
+ });
8782
+ return result;
8783
+ }
8784
+ get value() {
8785
+ if (!this.selectValue)
8786
+ return this.selectValue;
8787
+ if (this.returnObject) {
8788
+ return this.clearRow(this.selectValue.row);
8789
+ }
8790
+ return this.selectValue;
8791
+ }
8792
+ set value(value) {
8793
+ this.selectValue = value;
8794
+ }
8819
8795
  setValue(value) {
8820
- this.value = value;
8796
+ if (this.returnObject) {
8797
+ if (typeof value !== 'object') {
8798
+ this.value = { id: value };
8799
+ }
8800
+ else {
8801
+ this.value = { id: value[this.dataValue] };
8802
+ }
8803
+ }
8804
+ else if (typeof value === 'object') {
8805
+ this.value = value[this.dataValue];
8806
+ }
8807
+ else {
8808
+ this.value = value;
8809
+ }
8821
8810
  }
8822
8811
  }
8823
8812
 
@@ -8843,6 +8832,7 @@
8843
8832
  * Selected Nodes
8844
8833
  */
8845
8834
  this.selectedNodes = [];
8835
+ this.selectValue = [];
8846
8836
  this.flat = this.getInitValue('flat', props.flat, this.flat);
8847
8837
  this.limit = this.getInitValue('limit', props.limit, this.limit);
8848
8838
  this.createAccessors();
@@ -8859,6 +8849,34 @@
8859
8849
  deselect(node, element) {
8860
8850
  this.callEvent('onDeselect', { element, component: this, node });
8861
8851
  }
8852
+ get value() {
8853
+ if (this.returnObject) {
8854
+ return this.selectValue.map((value) => this.clearRow(value.row));
8855
+ }
8856
+ return this.selectValue;
8857
+ }
8858
+ set value(value) {
8859
+ this.selectValue = value;
8860
+ }
8861
+ setValue(value) {
8862
+ const arrValue = Array.isArray(value) ? value : [value];
8863
+ if (this.returnObject) {
8864
+ this.value = arrValue.map((item) => {
8865
+ if (typeof item !== 'object') {
8866
+ return { id: item };
8867
+ }
8868
+ return { id: item[this.dataValue] };
8869
+ });
8870
+ }
8871
+ else {
8872
+ this.value = arrValue.map((item) => {
8873
+ if (typeof item === 'object') {
8874
+ return item[this.dataValue];
8875
+ }
8876
+ return item;
8877
+ });
8878
+ }
8879
+ }
8862
8880
  }
8863
8881
 
8864
8882
  /**
@@ -8944,14 +8962,6 @@
8944
8962
  * Array of steppers items
8945
8963
  */
8946
8964
  this.items = [];
8947
- /**
8948
- * Applies the dark theme variant to the stepper
8949
- */
8950
- this.dark = false;
8951
- /**
8952
- * Applies the light theme variant to the stepper
8953
- */
8954
- this.light = false;
8955
8965
  /**
8956
8966
  * Allow user to jump to any step
8957
8967
  */
@@ -8963,9 +8973,7 @@
8963
8973
  this.activeStep = this.getInitValue('activeStep', props.activeStep, this.activeStep);
8964
8974
  this.altLabels = this.getInitValue('altLabels', props.altLabels, this.altLabels);
8965
8975
  this.content = this.getInitValue('content', props.content, this.content);
8966
- this.dark = this.getInitValue('dark', props.dark, this.dark);
8967
8976
  this.items = this.getInitValue('items', props.items, this.items);
8968
- this.light = this.getInitValue('light', props.light, this.light);
8969
8977
  this.nonLinear = this.getInitValue('nonLinear', props.nonLinear, this.nonLinear);
8970
8978
  this.vertical = this.getInitValue('vertical', props.vertical, this.vertical);
8971
8979
  this.steps = this.getInitValue('steps', props.steps, this.steps);
@@ -10128,7 +10136,6 @@
10128
10136
  if (this.editing)
10129
10137
  return;
10130
10138
  if (column.editable) {
10131
- this.selectedRows = [];
10132
10139
  this.editing = true;
10133
10140
  this.preventRowClick = true;
10134
10141
  this.datasource.currentRow = row;
@@ -10851,6 +10858,16 @@
10851
10858
  WatchURL.originalEvents = new Map();
10852
10859
 
10853
10860
  class BaseReport {
10861
+ constructor() {
10862
+ this.expressionZeedhiToXls = {
10863
+ AVG: 'AVERAGE',
10864
+ COUNT: 'COUNTA',
10865
+ MAX: 'MAX',
10866
+ MIN: 'MIN',
10867
+ SUM: 'SUM',
10868
+ };
10869
+ this.colunmXLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
10870
+ }
10854
10871
  buildColumns(columns) {
10855
10872
  const widths = {};
10856
10873
  let totalWidth;
@@ -11082,11 +11099,256 @@
11082
11099
  this.route = '/generateXLS';
11083
11100
  }
11084
11101
  buildDataset(data, columns) {
11102
+ const result = this.formatRawDataSet(data, columns);
11103
+ return JSON.stringify(result);
11104
+ }
11105
+ // formata o dataset para o formato "cru" xls
11106
+ formatRawDataSet(data, columns) {
11085
11107
  const columnNames = columns.map((col) => col.name);
11086
11108
  const result = data.reduce((reduced, row) => {
11087
11109
  const values = columnNames.map((col) => row[col] || '');
11088
11110
  return [...reduced, values];
11089
11111
  }, [columnNames]);
11112
+ return result;
11113
+ }
11114
+ buildMetadata(name, title, columns, filter) {
11115
+ const builtCols = this.buildColumns(columns);
11116
+ const builtFilters = this.buildFilter(filter || {});
11117
+ const lang = this.formatLangCode(core.I18n.instance.language);
11118
+ const clientLogo = '';
11119
+ const enterpriseLogo = '';
11120
+ const productLogo = '';
11121
+ const metadataObj = {
11122
+ name,
11123
+ title,
11124
+ lang,
11125
+ clientLogo,
11126
+ enterpriseLogo,
11127
+ productLogo,
11128
+ version: '1.0',
11129
+ words: {
11130
+ Page: core.I18n.translate('PAGE'),
11131
+ Report: core.I18n.translate('REPORT'),
11132
+ Version: core.I18n.translate('VERSION'),
11133
+ },
11134
+ staticData: {},
11135
+ groups: [],
11136
+ reportName: name,
11137
+ widgetLabel: title,
11138
+ orientation: 'PORTRAIT',
11139
+ columns: builtCols,
11140
+ filter: builtFilters,
11141
+ reportXLS: true,
11142
+ xlsMergedCell: [],
11143
+ };
11144
+ return Promise.resolve(JSON.stringify(metadataObj));
11145
+ }
11146
+ }
11147
+
11148
+ // XLS with groups
11149
+ class XLS2Report extends BaseReport {
11150
+ constructor() {
11151
+ super(...arguments);
11152
+ this.route = '/generateXLS';
11153
+ }
11154
+ buildDataset(data, metadata) {
11155
+ const result = this.formatDataSet(metadata, data);
11156
+ return JSON.stringify(result);
11157
+ }
11158
+ buildMetadata(name, title, columns, filter) {
11159
+ const builtCols = this.buildColumns(columns);
11160
+ const builtFilters = this.buildFilter(filter || {});
11161
+ const lang = this.formatLangCode(core.I18n.instance.language);
11162
+ const clientLogo = '';
11163
+ const enterpriseLogo = '';
11164
+ const productLogo = '';
11165
+ const metadataObj = {
11166
+ name,
11167
+ title,
11168
+ lang,
11169
+ clientLogo,
11170
+ enterpriseLogo,
11171
+ productLogo,
11172
+ version: '1.0',
11173
+ words: {
11174
+ Page: core.I18n.translate('PAGE'),
11175
+ Report: core.I18n.translate('REPORT'),
11176
+ Version: core.I18n.translate('VERSION'),
11177
+ },
11178
+ staticData: {},
11179
+ groups: [],
11180
+ reportName: name,
11181
+ widgetLabel: title,
11182
+ orientation: 'PORTRAIT',
11183
+ columns: builtCols,
11184
+ filter: builtFilters,
11185
+ reportXLS: true,
11186
+ xlsMergedCell: [],
11187
+ };
11188
+ return Promise.resolve(JSON.stringify(metadataObj));
11189
+ }
11190
+ // Ordenar o nome das colunas de acordo com seu index, e sempre deixando as colunas agrupadas nas primeiras posições
11191
+ getColumnsName(columns, metaData, lengthGroup) {
11192
+ const columnsNameGroup = metaData.groups.map((row) => row.field);
11193
+ let columnsName = [];
11194
+ const columnsGroupName = [];
11195
+ Object.entries(columns).forEach((row) => {
11196
+ const columnName = row[0];
11197
+ const index = row[1].sequence;
11198
+ if (columnsNameGroup.indexOf(columnName) === -1) {
11199
+ columnsName[index + lengthGroup] = columnName;
11200
+ }
11201
+ else {
11202
+ columnsGroupName.push(columnName);
11203
+ }
11204
+ });
11205
+ columnsName = columnsGroupName.concat(columnsName);
11206
+ columnsName = columnsName.filter((columnName) => typeof columnName === 'string');
11207
+ return columnsName;
11208
+ }
11209
+ // Inicializa alguns valores auxiliares
11210
+ initVars(metaData) {
11211
+ metaData.xlsMergedCell = [];
11212
+ const { columns } = metaData;
11213
+ const lengthGroup = metaData.groups.length;
11214
+ const indexLastGroup = lengthGroup - 1;
11215
+ let columnsName = [];
11216
+ columnsName = this.getColumnsName(columns, metaData, lengthGroup);
11217
+ const rowValues = [];
11218
+ const formatedDataSet = [];
11219
+ const groups = [];
11220
+ groups.groupEnd = {};
11221
+ groups.groupEnd.cellsfunc = {};
11222
+ return {
11223
+ columns, indexLastGroup, columnsName, rowValues, formatedDataSet, groups,
11224
+ };
11225
+ }
11226
+ // formata as expressões da linha
11227
+ formatRowFunc(column, columns, row, index, rowValues, funcXlsParam, groups, indexLastGroup) {
11228
+ let funcXls = funcXlsParam;
11229
+ if ((row[column] === 0 || row[column]) && index !== undefined) {
11230
+ const letter = this.colunmXLS[rowValues.length];
11231
+ funcXls = this.expressionZeedhiToXls[columns[column].expression];
11232
+ const cellsfunc = `${letter + groups[index].init}:${letter}${groups[index].end}`;
11233
+ let expression = '';
11234
+ if (indexLastGroup === index) {
11235
+ expression = `=${funcXls}(${cellsfunc})`;
11236
+ }
11237
+ else {
11238
+ expression = `=${funcXls}(${groups[index].cellsfunc[column]})`;
11239
+ if (index === 0) {
11240
+ if (groups.groupEnd.cellsfunc[column]) {
11241
+ groups.groupEnd.cellsfunc[column] += `,${groups[index].cellsfunc[column]}`;
11242
+ }
11243
+ else {
11244
+ groups.groupEnd.cellsfunc[column] = groups[index].cellsfunc[column];
11245
+ }
11246
+ }
11247
+ groups[index].cellsfunc[column] = null;
11248
+ }
11249
+ rowValues.push(expression);
11250
+ groups.forEach((group, indexGroup) => {
11251
+ if (indexGroup !== indexLastGroup) {
11252
+ if (!group.cellsfunc) {
11253
+ group.cellsfunc = {};
11254
+ }
11255
+ if (group.cellsfunc[column]) {
11256
+ group.cellsfunc[column] += `,${cellsfunc}`;
11257
+ }
11258
+ else {
11259
+ group.cellsfunc[column] = cellsfunc;
11260
+ }
11261
+ }
11262
+ });
11263
+ }
11264
+ else {
11265
+ let cell = row[column];
11266
+ if (row.groupSummary) {
11267
+ const groupEndFunc = groups.groupEnd.cellsfunc;
11268
+ if (groupEndFunc[column]) {
11269
+ funcXls = this.expressionZeedhiToXls[columns[column].expression];
11270
+ cell = `=${funcXls}(${groupEndFunc[column]})`;
11271
+ }
11272
+ }
11273
+ rowValues.push(cell);
11274
+ }
11275
+ }
11276
+ // formata a linha de grupo de acordo com o formato xls2
11277
+ setRowGroup(row, rowValues, groups, metaData, formatedDataSet, columnsName, columns, indexLastGroup) {
11278
+ const label = `${row.groupLabel}:${row.groupValue}`;
11279
+ const index = row.groupIndex;
11280
+ if (row.groupHeader) {
11281
+ rowValues[index] = label;
11282
+ groups[index] = { init: null, end: null };
11283
+ }
11284
+ else if (row.groupFooter) {
11285
+ if (!row.groupLabel) {
11286
+ rowValues.push('Total');
11287
+ }
11288
+ else {
11289
+ rowValues.push(`Total (${label})`);
11290
+ }
11291
+ const funcXls = null;
11292
+ if (groups[index]) {
11293
+ metaData.xlsMergedCell.push({
11294
+ start_row: groups[index].init,
11295
+ start_col: this.colunmXLS[index],
11296
+ end_row: formatedDataSet.length + 2,
11297
+ end_col: this.colunmXLS[index],
11298
+ });
11299
+ }
11300
+ columnsName.forEach((column, columnIndex) => {
11301
+ if (!(row.groupFooter && columnIndex === 0)) {
11302
+ this.formatRowFunc(column, columns, row, index, rowValues, funcXls, groups, indexLastGroup);
11303
+ }
11304
+ });
11305
+ }
11306
+ return rowValues;
11307
+ }
11308
+ // Defina o index dos grupos
11309
+ setIndexGroups(groups, formatedDataSet) {
11310
+ groups.forEach((group) => {
11311
+ if (!group.init) {
11312
+ group.init = formatedDataSet.length + 2;
11313
+ }
11314
+ group.end = formatedDataSet.length + 2;
11315
+ });
11316
+ }
11317
+ // Preenche uma linha "normal"
11318
+ setRowNormal(columnsName, rowValues, row) {
11319
+ columnsName.forEach((column) => {
11320
+ rowValues.push(row[column]);
11321
+ });
11322
+ }
11323
+ formatDataSet(metaData, dataSet) {
11324
+ const initVars = this.initVars(metaData);
11325
+ const { columns, indexLastGroup, columnsName, formatedDataSet, groups, } = initVars;
11326
+ let { rowValues } = initVars;
11327
+ dataSet.forEach((row) => {
11328
+ if (row.group || row.groupFooter) {
11329
+ rowValues = this.setRowGroup(row, rowValues, groups, metaData, formatedDataSet, columnsName, columns, indexLastGroup);
11330
+ }
11331
+ else {
11332
+ this.setIndexGroups(groups, formatedDataSet);
11333
+ this.setRowNormal(columnsName, rowValues, row);
11334
+ }
11335
+ if (!row.groupHeader) {
11336
+ formatedDataSet.push(rowValues);
11337
+ }
11338
+ rowValues = [];
11339
+ });
11340
+ return [columnsName].concat(formatedDataSet);
11341
+ }
11342
+ }
11343
+
11344
+ // Grid mirror (with groups)
11345
+ class XLS3Report extends BaseReport {
11346
+ constructor() {
11347
+ super(...arguments);
11348
+ this.route = '/generateXLS';
11349
+ }
11350
+ buildDataset(data, metadata) {
11351
+ const result = this.formatDataSet(metadata, data);
11090
11352
  return JSON.stringify(result);
11091
11353
  }
11092
11354
  buildMetadata(name, title, columns, filter) {
@@ -11116,9 +11378,153 @@
11116
11378
  orientation: 'PORTRAIT',
11117
11379
  columns: builtCols,
11118
11380
  filter: builtFilters,
11381
+ reportXLS: true,
11382
+ xlsMergedCell: [],
11119
11383
  };
11120
11384
  return Promise.resolve(JSON.stringify(metadataObj));
11121
11385
  }
11386
+ // Ordenar o nome das colunas de acordo com seu index, excluindo o nome das colunas agrupadas
11387
+ getColumnsNameFormat3(columns, metaData) {
11388
+ const columnsNameGroup = metaData.groups.map((row) => row.field);
11389
+ let columnsName = [];
11390
+ Object.entries(columns).forEach((row) => {
11391
+ const columnName = row[0];
11392
+ if (columnsNameGroup.indexOf(columnName) === -1) {
11393
+ const index = row[1].sequence;
11394
+ columnsName[index] = columnName;
11395
+ }
11396
+ });
11397
+ columnsName = columnsName.filter((columnName) => typeof columnName === 'string');
11398
+ return columnsName;
11399
+ }
11400
+ // Inicializa alguns valores auxiliares
11401
+ initVars(metaData) {
11402
+ metaData.xlsMergedCell = [];
11403
+ const { columns } = metaData;
11404
+ const lengthGroup = metaData.groups.length;
11405
+ const indexLastGroup = lengthGroup - 1;
11406
+ let columnsName = [];
11407
+ columnsName = this.getColumnsNameFormat3(columns, metaData);
11408
+ const rowValues = [];
11409
+ const formatedDataSet = [];
11410
+ const groups = [];
11411
+ groups.groupEnd = {};
11412
+ groups.groupEnd.cellsfunc = {};
11413
+ return {
11414
+ columns, indexLastGroup, columnsName, rowValues, formatedDataSet, groups,
11415
+ };
11416
+ }
11417
+ // formata a linha do grupo de acordo com o formato xls3
11418
+ setRowGroupFormat(row, rowValuesParam, groups, formatedDataSet, columnsName, columns, indexLastGroup) {
11419
+ let rowValues = rowValuesParam;
11420
+ const label = `${row.groupLabel}:${row.groupValue}`;
11421
+ const index = row.groupIndex;
11422
+ if (row.groupHeader) {
11423
+ rowValues[index] = label;
11424
+ groups[index] = { init: null, end: null };
11425
+ formatedDataSet.push(rowValues);
11426
+ rowValues = [];
11427
+ }
11428
+ else if (row.groupFooter) {
11429
+ if (!row.groupLabel) {
11430
+ rowValues.push('Total');
11431
+ }
11432
+ else {
11433
+ rowValues.push(`Total (${label})`);
11434
+ }
11435
+ formatedDataSet.push(rowValues);
11436
+ rowValues = [];
11437
+ const funcXls = null;
11438
+ columnsName.forEach((column) => {
11439
+ this.formatRowFunc(column, columns, row, index, rowValues, funcXls, groups, indexLastGroup);
11440
+ });
11441
+ }
11442
+ return rowValues;
11443
+ }
11444
+ // formata as expressões da linha
11445
+ formatRowFunc(column, columns, row, index, rowValues, funcXlsParam, groups, indexLastGroup) {
11446
+ let funcXls = funcXlsParam;
11447
+ if ((row[column] === 0 || row[column]) && index !== undefined) {
11448
+ const letter = this.colunmXLS[rowValues.length];
11449
+ funcXls = this.expressionZeedhiToXls[columns[column].expression];
11450
+ const cellsfunc = `${letter + groups[index].init}:${letter}${groups[index].end}`;
11451
+ let expression = '';
11452
+ if (indexLastGroup === index) {
11453
+ expression = `=${funcXls}(${cellsfunc})`;
11454
+ }
11455
+ else {
11456
+ expression = `=${funcXls}(${groups[index].cellsfunc[column]})`;
11457
+ if (index === 0) {
11458
+ if (groups.groupEnd.cellsfunc[column]) {
11459
+ groups.groupEnd.cellsfunc[column] += `,${groups[index].cellsfunc[column]}`;
11460
+ }
11461
+ else {
11462
+ groups.groupEnd.cellsfunc[column] = groups[index].cellsfunc[column];
11463
+ }
11464
+ }
11465
+ groups[index].cellsfunc[column] = null;
11466
+ }
11467
+ rowValues.push(expression);
11468
+ groups.forEach((group, indexGroup) => {
11469
+ if (indexGroup !== indexLastGroup) {
11470
+ if (!group.cellsfunc) {
11471
+ group.cellsfunc = {};
11472
+ }
11473
+ if (group.cellsfunc[column]) {
11474
+ group.cellsfunc[column] += `,${cellsfunc}`;
11475
+ }
11476
+ else {
11477
+ group.cellsfunc[column] = cellsfunc;
11478
+ }
11479
+ }
11480
+ });
11481
+ }
11482
+ else {
11483
+ let cell = row[column];
11484
+ if (row.groupSummary) {
11485
+ const groupEndFunc = groups.groupEnd.cellsfunc;
11486
+ if (groupEndFunc[column]) {
11487
+ funcXls = this.expressionZeedhiToXls[columns[column].expression];
11488
+ cell = `=${funcXls}(${groupEndFunc[column]})`;
11489
+ }
11490
+ }
11491
+ rowValues.push(cell);
11492
+ }
11493
+ }
11494
+ // Defina o index dos grupos
11495
+ setIndexGroups(groups, formatedDataSet) {
11496
+ groups.forEach((group) => {
11497
+ if (!group.init) {
11498
+ group.init = formatedDataSet.length + 2;
11499
+ }
11500
+ group.end = formatedDataSet.length + 2;
11501
+ });
11502
+ }
11503
+ // Preenche uma linha "normal"
11504
+ setRowNormal(columnsName, rowValues, row) {
11505
+ columnsName.forEach((column) => {
11506
+ rowValues.push(row[column]);
11507
+ });
11508
+ }
11509
+ formatDataSet(metaData, dataSet) {
11510
+ const initVars = this.initVars(metaData);
11511
+ const { columns, indexLastGroup, columnsName, formatedDataSet, groups, } = initVars;
11512
+ let { rowValues } = initVars;
11513
+ dataSet.forEach((row) => {
11514
+ if (row.group || row.groupFooter) {
11515
+ rowValues = this.setRowGroupFormat(row, rowValues, groups, formatedDataSet, columnsName, columns, indexLastGroup);
11516
+ }
11517
+ else {
11518
+ this.setIndexGroups(groups, formatedDataSet);
11519
+ this.setRowNormal(columnsName, rowValues, row);
11520
+ }
11521
+ if (!row.groupHeader) {
11522
+ formatedDataSet.push(rowValues);
11523
+ }
11524
+ rowValues = [];
11525
+ });
11526
+ return [columnsName].concat(formatedDataSet);
11527
+ }
11122
11528
  }
11123
11529
 
11124
11530
  class Report {
@@ -11157,6 +11563,12 @@
11157
11563
  if (type === 'xls') {
11158
11564
  return new XLSReport();
11159
11565
  }
11566
+ if (type === 'xls2') {
11567
+ return new XLS2Report();
11568
+ }
11569
+ if (type === 'xls3') {
11570
+ return new XLS3Report();
11571
+ }
11160
11572
  throw new Error(`Invalid report type: ${type}`);
11161
11573
  }
11162
11574
  getReport(type, portrait = true, rowObj) {
@@ -11170,9 +11582,18 @@
11170
11582
  const reportType = this.getReportType(type);
11171
11583
  const { route } = reportType;
11172
11584
  const { name, columns, datasource } = this.iterable;
11585
+ const { groupedData } = Object.assign({}, this.iterable);
11173
11586
  const formattedColumns = this.removeActionColumns(columns);
11174
- const dataset = reportType.buildDataset(data, formattedColumns);
11175
11587
  const metadataObj = yield reportType.buildMetadata(name, this.title, formattedColumns, datasource.filter, portrait);
11588
+ let dataset;
11589
+ if ((reportType instanceof XLS2Report || reportType instanceof XLS3Report) && groupedData) {
11590
+ const rowMetadata = rowObj.metaData;
11591
+ const metadataObjClone = merge__default["default"](rowMetadata, JSON.parse(metadataObj));
11592
+ dataset = reportType.buildDataset(groupedData, metadataObjClone);
11593
+ }
11594
+ else {
11595
+ dataset = reportType.buildDataset(data, formattedColumns);
11596
+ }
11176
11597
  const filter = '[]';
11177
11598
  let row = {};
11178
11599
  if (rowObj) {
@@ -11312,6 +11733,8 @@
11312
11733
  exports.TreeGrid = TreeGrid;
11313
11734
  exports.TreeGridEditable = TreeGridEditable;
11314
11735
  exports.WatchURL = WatchURL;
11736
+ exports.XLS2Report = XLS2Report;
11737
+ exports.XLS3Report = XLS3Report;
11315
11738
  exports.XLSReport = XLSReport;
11316
11739
  exports.initTheme = initTheme;
11317
11740