@zeedhi/teknisa-components-common 1.107.1 → 1.108.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 (77) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +7 -7
  3. package/coverage/clover.xml +772 -692
  4. package/coverage/coverage-final.json +47 -47
  5. package/coverage/lcov-report/index.html +15 -15
  6. package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +2 -2
  7. package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +2 -2
  8. package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +7 -7
  9. package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
  10. package/coverage/lcov-report/tests/__helpers__/index.ts.html +1 -1
  11. package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +1 -1
  12. package/coverage/lcov.info +1459 -1275
  13. package/dist/tek-components-common.esm.js +375 -252
  14. package/dist/tek-components-common.umd.js +375 -252
  15. package/jest.config.js +1 -1
  16. package/package.json +2 -2
  17. package/tests/__helpers__/component-event-helper.ts +5 -5
  18. package/tests/__helpers__/flush-promises-helper.ts +3 -3
  19. package/tests/__helpers__/get-child-helper.ts +27 -27
  20. package/tests/__helpers__/index.ts +3 -3
  21. package/tests/__helpers__/mock-created-helper.ts +12 -12
  22. package/tests/__mocks__/@zeedhi/core/i18n.js +74 -74
  23. package/tests/__mocks__/@zeedhi/core.js +4 -4
  24. package/tests/unit/components/crud/crud-add-button.spec.ts +56 -56
  25. package/tests/unit/components/crud/crud-button.spec.ts +94 -94
  26. package/tests/unit/components/crud/crud-cancel-button.spec.ts +91 -91
  27. package/tests/unit/components/crud/crud-delete-button.spec.ts +122 -122
  28. package/tests/unit/components/crud/crud-form.spec.ts +165 -165
  29. package/tests/unit/components/crud/crud-save-button.spec.ts +118 -118
  30. package/tests/unit/components/tek-breadcrumb-header/tek-breadcrumb-header.spec.ts +42 -42
  31. package/tests/unit/components/tek-card-title/CardTitle.spec.ts +34 -34
  32. package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +470 -470
  33. package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +364 -364
  34. package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +112 -112
  35. package/tests/unit/components/tek-grid/filter-helper.spec.ts +148 -148
  36. package/tests/unit/components/tek-grid/grid-column.spec.ts +270 -270
  37. package/tests/unit/components/tek-grid/grid-columns-button.spec.ts +195 -195
  38. package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +967 -967
  39. package/tests/unit/components/tek-grid/grid.spec.ts +3340 -3116
  40. package/tests/unit/components/tek-grid/layout_options.spec.ts +980 -980
  41. package/tests/unit/components/tek-image/Image.spec.ts +67 -67
  42. package/tests/unit/components/tek-iterable-carousel/iterable-carousel.spec.ts +37 -37
  43. package/tests/unit/components/tek-iterable-component-render/iterable-component-render.spec.ts +200 -200
  44. package/tests/unit/components/tek-loading/Loading.spec.ts +30 -30
  45. package/tests/unit/components/tek-notifications/notifications.spec.ts +201 -201
  46. package/tests/unit/components/tek-product-card/product-card.spec.ts +61 -61
  47. package/tests/unit/components/tek-user-info/TekUserInfoContoller.spec.ts +220 -220
  48. package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +86 -86
  49. package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +430 -430
  50. package/tests/unit/components/tree-grid/tree-grid.spec.ts +776 -776
  51. package/tests/unit/utils/grid-base/delete-rows-error.spec.ts +24 -0
  52. package/tests/unit/utils/grid-base/export-options/button-option.spec.ts +44 -44
  53. package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +135 -135
  54. package/tests/unit/utils/grid-base/grid-controller.spec.ts +267 -174
  55. package/tests/unit/utils/report-filter/report-filter.spec.ts +66 -66
  56. package/tsconfig.eslint.json +8 -8
  57. package/types/components/tek-datasource/memory-datasource.d.ts +2 -4
  58. package/types/components/tek-datasource/rest-datasource.d.ts +6 -3
  59. package/types/components/tek-grid/grid.d.ts +50 -6
  60. package/types/components/tek-grid/interfaces.d.ts +5 -3
  61. package/types/components/tek-tree-grid/tree-grid.d.ts +5 -1
  62. package/types/utils/grid-base/grid-base.d.ts +12 -229
  63. package/types/utils/grid-base/grid-controller.d.ts +1 -3
  64. package/types/components/tek-ag-grid/default-icons.d.ts +0 -53
  65. package/types/components/tek-ag-grid/interfaces.d.ts +0 -9
  66. package/types/components/tek-ag-grid/tek-ag-grid.d.ts +0 -35
  67. package/types/components/tek-datasource/datasource.d.ts +0 -94
  68. package/types/components/tek-grid/default-icons.d.ts +0 -53
  69. package/types/components/tek-grid/filter-dynamic-values.d.ts +0 -9
  70. package/types/components/tek-grid/grid-controller.d.ts +0 -19
  71. package/types/components/tek-grid/grid_column.d.ts +0 -14
  72. package/types/components/tek-grid/grid_controller.d.ts +0 -15
  73. package/types/components/tek-grid/tek-grid.d.ts +0 -35
  74. package/types/components/tek-login/interfaces.d.ts +0 -3
  75. package/types/components/tek-login/login-children.d.ts +0 -3
  76. package/types/components/tek-login/login.d.ts +0 -58
  77. package/types/components/tek-login/login_children.d.ts +0 -3
@@ -810,6 +810,7 @@
810
810
  class GridBase {
811
811
  constructor(grid) {
812
812
  this.exportConfigButtons = [];
813
+ this.defaultToolbar = {};
813
814
  this.atoms = {
814
815
  TITLE: '_gridTitle',
815
816
  HIDE_BUTTON: '_hideButton',
@@ -831,6 +832,7 @@
831
832
  };
832
833
  this.grid = grid;
833
834
  this.exportConfigButtons = this.getExportConfigButtons();
835
+ this.initializeDefaultToolbarItems();
834
836
  }
835
837
  getOption(config) {
836
838
  if (config.multiOption)
@@ -843,17 +845,17 @@
843
845
  return option.buildComponent(this.grid);
844
846
  });
845
847
  }
846
- createToolbarProps() {
847
- return [
848
- {
849
- name: `${this.grid.name}_gridTitle`,
848
+ initializeDefaultToolbarItems() {
849
+ this.defaultToolbar = {
850
+ title: () => ({
851
+ name: `${this.grid.name}_title`,
850
852
  component: 'ZdText',
851
853
  cssClass: 'toolbar-title',
852
854
  tag: 'h2',
853
855
  text: this.grid.title,
854
856
  title: this.grid.title,
855
- },
856
- {
857
+ }),
858
+ hideButton: () => ({
857
859
  name: `${this.grid.name}_hideTooltip`,
858
860
  component: 'ZdTooltip',
859
861
  label: `{{GridController_${this.grid.componentId}.tooltipName}}`,
@@ -863,213 +865,260 @@
863
865
  name: `${this.grid.name}_hideButton`,
864
866
  component: 'ZdIcon',
865
867
  iconName: 'mdi-chevron-right',
866
- isVisible: `{{GridController_${this.grid.componentId}.isNotEditing}}`,
868
+ isVisible: true,
867
869
  cssClass: `{{GridController_${this.grid.componentId}.toolbarStyle}}`,
868
870
  events: {
869
871
  click: this.hideButtonClick.bind(this),
870
872
  },
871
873
  },
872
874
  ],
873
- },
874
- {
875
- name: `${this.grid.name}_toolbarDiv`,
876
- component: 'ZdTag',
877
- tag: 'div',
878
- cssStyle: 'display: flex; align-items: center',
879
- isVisible: `{{GridController_${this.grid.componentId}.showToolbar}}`,
875
+ }),
876
+ addButton: () => ({
877
+ name: `${this.grid.name}_add_tooltip`,
878
+ component: 'ZdTooltip',
879
+ label: 'TEKGRID_ADD',
880
+ bottom: true,
880
881
  children: [
881
882
  {
882
- name: `${this.grid.name}_notEditingSpan`,
883
- component: 'ZdTag',
884
- tag: 'span',
885
- cssStyle: 'display: flex',
886
- isVisible: `{{GridController_${this.grid.componentId}.isNotEditing}}`,
887
- children: [
888
- {
889
- name: `${this.grid.name}_add_tooltip`,
890
- component: 'ZdTooltip',
891
- label: 'TEKGRID_ADD',
892
- bottom: true,
893
- children: [
894
- {
895
- name: `${this.grid.name}_addButton`,
896
- component: 'ZdButton',
897
- icon: true,
898
- iconName: 'add',
899
- isVisible: `{{GridController_${this.grid.componentId}.showAddButton}}`,
900
- events: {
901
- click: this.addButtonClick.bind(this),
902
- },
903
- },
904
- ],
905
- },
906
- {
907
- name: `${this.grid.name}_delete_tooltip`,
908
- component: 'ZdTooltip',
909
- label: 'TEKGRID_DELETE',
910
- bottom: true,
911
- children: [
912
- {
913
- name: `${this.grid.name}_deleteButton`,
914
- component: 'ZdButton',
915
- icon: true,
916
- iconName: 'delete',
917
- isVisible: `{{GridController_${this.grid.componentId}.showDeleteButton}}`,
918
- disabled: `{{GridController_${this.grid.componentId}.disableDeleteButton}}`,
919
- events: {
920
- click: this.deleteButtonClick.bind(this),
921
- },
922
- },
923
- ],
924
- },
925
- {
926
- name: `${this.grid.name}_divider1`,
927
- component: 'ZdDivider',
928
- cssClass: 'toolbar-divider',
929
- vertical: true,
930
- isVisible: `{{GridController_${this.grid.componentId}.showDivider1}}`,
931
- },
932
- {
933
- name: `${this.grid.name}_refresh_tooltip`,
934
- component: 'ZdTooltip',
935
- label: 'TEKGRID_REFRESH',
936
- bottom: true,
937
- children: [
938
- {
939
- name: `${this.grid.name}_refreshButton`,
940
- component: 'ZdButton',
941
- icon: true,
942
- iconName: 'refresh',
943
- isVisible: `{{GridController_${this.grid.componentId}.showReloadButton}}`,
944
- events: {
945
- click: this.reloadGrid.bind(this),
946
- },
947
- },
948
- ],
949
- },
950
- {
951
- name: `${this.grid.name}_divider2`,
952
- component: 'ZdDivider',
953
- cssClass: 'toolbar-divider',
954
- vertical: true,
955
- isVisible: `{{GridController_${this.grid.componentId}.showDivider2}}`,
956
- },
957
- {
958
- name: `${this.grid.name}_columns_button_tooltip`,
959
- component: 'ZdTooltip',
960
- label: 'TEKGRID_COLUMNS',
961
- bottom: true,
962
- children: [
963
- {
964
- name: `${this.grid.name}_columnsButton`,
965
- component: 'TekGridColumnsButton',
966
- isVisible: `{{GridController_${this.grid.componentId}.showColumnsButton}}`,
967
- iterableComponentName: this.grid.name,
968
- hideGroups: !(this.grid instanceof TekGrid),
969
- ignoreColumns: `{{GridController_${this.grid.componentId}.columnsButtonIgnore}}`,
970
- },
971
- ],
972
- },
973
- {
974
- name: `${this.grid.name}_layout_options`,
975
- component: 'TekGridLayoutOptions',
976
- isVisible: `{{GridController_${this.grid.componentId}.showLayoutOptionsButton}}`,
977
- },
978
- {
979
- name: `${this.grid.name}_dividerActions`,
980
- component: 'ZdDivider',
981
- cssClass: 'toolbar-divider',
982
- vertical: true,
983
- isVisible: `{{GridController_${this.grid.componentId}.showActionAndExportButton}}`,
984
- },
985
- {
986
- name: `${this.grid.name}_export_dropdown`,
987
- component: 'ZdDropdown',
988
- cssClass: 'tekgrid-actions-dropdown',
989
- offsetY: true,
990
- activator: {
991
- name: `${this.grid.name}_exportButton`,
992
- component: 'ZdButton',
993
- icon: true,
994
- iconName: 'fileDownload',
995
- isVisible: `{{GridController_${this.grid.componentId}.showExportButton}}`,
996
- },
997
- children: this.grid.exportActions || this.exportConfigButtons,
998
- },
999
- {
1000
- name: `${this.grid.name}_actions_dropdown`,
1001
- component: 'ZdDropdown',
1002
- cssClass: 'tekgrid-actions-dropdown',
1003
- offsetY: true,
1004
- activator: {
1005
- name: `${this.grid.name}_actionsButton`,
1006
- component: 'ZdButton',
1007
- icon: true,
1008
- iconName: 'more',
1009
- isVisible: `{{GridController_${this.grid.componentId}.showActionsButton}}`,
1010
- },
1011
- children: this.grid.actions,
1012
- },
1013
- {
1014
- name: `${this.grid.name}_divider3`,
1015
- component: 'ZdDivider',
1016
- cssClass: 'toolbar-divider',
1017
- vertical: true,
1018
- isVisible: `{{GridController_${this.grid.componentId}.showDivider3}}`,
1019
- },
1020
- ],
883
+ name: `${this.grid.name}_addButton`,
884
+ component: 'ZdButton',
885
+ icon: true,
886
+ iconName: 'add',
887
+ isVisible: `{{GridController_${this.grid.componentId}.showAddButton}}`,
888
+ events: {
889
+ click: this.addButtonClick.bind(this),
890
+ },
1021
891
  },
892
+ ],
893
+ }),
894
+ deleteButton: () => ({
895
+ name: `${this.grid.name}_delete_tooltip`,
896
+ component: 'ZdTooltip',
897
+ label: 'TEKGRID_DELETE',
898
+ bottom: true,
899
+ children: [
1022
900
  {
1023
- name: `${this.grid.name}_saveButton`,
901
+ name: `${this.grid.name}_deleteButton`,
1024
902
  component: 'ZdButton',
1025
- label: 'TEKGRID_SAVE',
1026
- isVisible: `{{GridController_${this.grid.componentId}.showEditButtons}}`,
1027
- small: true,
903
+ icon: true,
904
+ iconName: 'delete',
905
+ isVisible: `{{GridController_${this.grid.componentId}.showDeleteButton}}`,
906
+ disabled: `{{GridController_${this.grid.componentId}.disableDeleteButton}}`,
1028
907
  events: {
1029
- click: this.saveChanges.bind(this),
908
+ click: this.deleteButtonClick.bind(this),
1030
909
  },
1031
910
  },
911
+ ],
912
+ }),
913
+ divider: (index) => ({
914
+ name: `${this.grid.name}_divider${index}`,
915
+ component: 'ZdDivider',
916
+ cssClass: 'toolbar-divider',
917
+ vertical: true,
918
+ isVisible: `{{GridController_${this.grid.componentId}.showDivider}}`,
919
+ }),
920
+ refreshButton: () => ({
921
+ name: `${this.grid.name}_refresh_tooltip`,
922
+ component: 'ZdTooltip',
923
+ label: 'TEKGRID_REFRESH',
924
+ bottom: true,
925
+ children: [
1032
926
  {
1033
- name: `${this.grid.name}_cancelButton`,
927
+ name: `${this.grid.name}_refreshButton`,
1034
928
  component: 'ZdButton',
1035
- label: 'TEKGRID_CANCEL',
1036
- outline: true,
1037
- cssClass: 'zd-mx-2',
1038
- isVisible: `{{GridController_${this.grid.componentId}.showEditButtons}}`,
1039
- small: true,
929
+ icon: true,
930
+ iconName: 'refresh',
931
+ isVisible: `{{GridController_${this.grid.componentId}.showReloadButton}}`,
1040
932
  events: {
1041
- click: this.cancelChanges.bind(this),
933
+ click: this.reloadGrid.bind(this),
1042
934
  },
1043
935
  },
936
+ ],
937
+ }),
938
+ columnsButton: () => ({
939
+ name: `${this.grid.name}_columns_button_tooltip`,
940
+ component: 'ZdTooltip',
941
+ label: 'TEKGRID_COLUMNS',
942
+ bottom: true,
943
+ children: [
1044
944
  {
1045
- name: `${this.grid.name}_gridSearch`,
1046
- component: 'ZdSearch',
1047
- cssClass: 'zd-grid-search',
1048
- iterableComponentName: `${this.grid.name}`,
1049
- isVisible: `{{GridController_${this.grid.componentId}.showSearchInput}}`,
945
+ name: `${this.grid.name}_columnsButton`,
946
+ component: 'TekGridColumnsButton',
947
+ isVisible: `{{GridController_${this.grid.componentId}.showColumnsButton}}`,
948
+ iterableComponentName: this.grid.name,
949
+ hideGroups: !(this.grid instanceof TekGrid),
950
+ ignoreColumns: `{{GridController_${this.grid.componentId}.columnsButtonIgnore}}`,
1050
951
  },
952
+ ],
953
+ }),
954
+ layoutOptions: () => ({
955
+ name: `${this.grid.name}_layout_options`,
956
+ component: 'TekGridLayoutOptions',
957
+ isVisible: `{{GridController_${this.grid.componentId}.showLayoutOptionsButton}}`,
958
+ }),
959
+ exportDropdown: () => ({
960
+ name: `${this.grid.name}_export_dropdown`,
961
+ component: 'ZdDropdown',
962
+ cssClass: 'tekgrid-actions-dropdown',
963
+ offsetY: true,
964
+ activator: {
965
+ name: `${this.grid.name}_exportButton`,
966
+ component: 'ZdButton',
967
+ icon: true,
968
+ iconName: 'fileDownload',
969
+ isVisible: `{{GridController_${this.grid.componentId}.showExportButton}}`,
970
+ },
971
+ children: this.grid.exportActions || this.exportConfigButtons,
972
+ }),
973
+ actionsDropdown: () => ({
974
+ name: `${this.grid.name}_actions_dropdown`,
975
+ component: 'ZdDropdown',
976
+ cssClass: 'tekgrid-actions-dropdown',
977
+ offsetY: true,
978
+ activator: {
979
+ name: `${this.grid.name}_actionsButton`,
980
+ component: 'ZdButton',
981
+ icon: true,
982
+ iconName: 'more',
983
+ isVisible: `{{GridController_${this.grid.componentId}.showActionsButton}}`,
984
+ },
985
+ children: this.grid.actions,
986
+ }),
987
+ saveButton: () => ({
988
+ name: `${this.grid.name}_saveButton`,
989
+ component: 'ZdButton',
990
+ label: 'TEKGRID_SAVE',
991
+ isVisible: `{{GridController_${this.grid.componentId}.showEditButtons}}`,
992
+ small: true,
993
+ events: {
994
+ click: this.saveChanges.bind(this),
995
+ },
996
+ }),
997
+ cancelButton: () => ({
998
+ name: `${this.grid.name}_cancelButton`,
999
+ component: 'ZdButton',
1000
+ label: 'TEKGRID_CANCEL',
1001
+ outline: true,
1002
+ cssClass: 'zd-mx-2',
1003
+ isVisible: `{{GridController_${this.grid.componentId}.showEditButtons}}`,
1004
+ small: true,
1005
+ events: {
1006
+ click: this.cancelChanges.bind(this),
1007
+ },
1008
+ }),
1009
+ gridSearch: () => ({
1010
+ name: `${this.grid.name}_gridSearch`,
1011
+ component: 'ZdSearch',
1012
+ cssClass: 'zd-grid-search',
1013
+ iterableComponentName: `${this.grid.name}`,
1014
+ isVisible: `{{GridController_${this.grid.componentId}.showSearchInput}}`,
1015
+ }),
1016
+ filterButton: () => ({
1017
+ name: `${this.grid.name}_filter_tooltip`,
1018
+ component: 'ZdTooltip',
1019
+ label: 'TEKGRID_FILTER',
1020
+ bottom: true,
1021
+ children: [
1051
1022
  {
1052
- name: `${this.grid.name}_filter_tooltip`,
1053
- component: 'ZdTooltip',
1054
- label: 'TEKGRID_FILTER',
1055
- bottom: true,
1056
- children: [
1057
- {
1058
- name: `${this.grid.name}_filterButton`,
1059
- component: 'TekGridFilterButton',
1060
- grid: this.grid,
1061
- gridName: this.grid.name,
1062
- showCheckboxAll: this.grid.showCheckboxAllFilter,
1063
- isVisible: `{{GridController_${this.grid.componentId}.showFilterButton}}`,
1064
- events: {
1065
- onCreated: this.loadFilterButton.bind(this),
1066
- },
1067
- },
1068
- ],
1023
+ name: `${this.grid.name}_filterButton`,
1024
+ component: 'TekGridFilterButton',
1025
+ grid: this.grid,
1026
+ gridName: this.grid.name,
1027
+ showCheckboxAll: this.grid.showCheckboxAllFilter,
1028
+ isVisible: `{{GridController_${this.grid.componentId}.showFilterButton}}`,
1029
+ events: {
1030
+ onCreated: this.loadFilterButton.bind(this),
1031
+ },
1069
1032
  },
1070
1033
  ],
1071
- },
1034
+ }),
1035
+ };
1036
+ }
1037
+ processUserToolbarItems(toolbarDivChildren) {
1038
+ this.grid.toolbarConfig.forEach((item, index) => {
1039
+ if (typeof item === 'object' && item.component) {
1040
+ toolbarDivChildren.push(item);
1041
+ }
1042
+ else if (typeof item === 'string') {
1043
+ const toolbarToPropertyMap = {
1044
+ addButton: 'addButton',
1045
+ deleteButton: 'deleteButton',
1046
+ refreshButton: 'refreshButton',
1047
+ columnsButton: 'columnsButton',
1048
+ layoutOptions: 'layoutButton',
1049
+ exportDropdown: 'exportButton',
1050
+ actionsDropdown: 'actionsButton',
1051
+ gridSearch: 'searchInput',
1052
+ filterButton: 'filterButton',
1053
+ };
1054
+ const gridProperty = toolbarToPropertyMap[item];
1055
+ if (gridProperty && !this.grid[gridProperty]) {
1056
+ this.grid[gridProperty] = true;
1057
+ }
1058
+ const itemFactory = this.defaultToolbar[item];
1059
+ if (itemFactory) {
1060
+ const predefinedItem = itemFactory(index);
1061
+ if (predefinedItem) {
1062
+ toolbarDivChildren.push(predefinedItem);
1063
+ }
1064
+ }
1065
+ else {
1066
+ console.warn(`Predefined toolbar item "${item}" not found.`);
1067
+ }
1068
+ }
1069
+ else {
1070
+ console.warn('Invalid item in toolbarConfig:', item);
1071
+ }
1072
+ });
1073
+ }
1074
+ /**
1075
+ * Adiciona os itens padrão da toolbar quando nenhuma configuração é fornecida.
1076
+ * @param toolbarDivChildren Array para adicionar os componentes da toolbar.
1077
+ */
1078
+ addDefaultToolbarItems(toolbarDivChildren) {
1079
+ const defaultItems = [
1080
+ 'addButton', 'deleteButton', 'divider', 'refreshButton', 'divider',
1081
+ 'columnsButton', 'layoutOptions', 'exportDropdown', 'divider', 'actionsDropdown',
1082
+ 'saveButton', 'cancelButton', 'divider', 'gridSearch', 'filterButton',
1072
1083
  ];
1084
+ defaultItems.forEach((itemName, index) => {
1085
+ const itemFactory = this.defaultToolbar[itemName];
1086
+ if (itemFactory) {
1087
+ const predefinedItem = itemFactory(index);
1088
+ if (predefinedItem) {
1089
+ toolbarDivChildren.push(predefinedItem);
1090
+ }
1091
+ }
1092
+ });
1093
+ }
1094
+ /**
1095
+ * Cria os componentes que serão renderizados na toolbar do grid.
1096
+ */
1097
+ createToolbarProps() {
1098
+ var _a, _b, _c, _d;
1099
+ const toolbarItems = [];
1100
+ const toolbarDivChildren = [];
1101
+ const title = (_b = (_a = this.defaultToolbar).title) === null || _b === void 0 ? void 0 : _b.call(_a);
1102
+ const hideButton = (_d = (_c = this.defaultToolbar).hideButton) === null || _d === void 0 ? void 0 : _d.call(_c);
1103
+ if (title)
1104
+ toolbarItems.push(title);
1105
+ if (hideButton)
1106
+ toolbarItems.push(hideButton);
1107
+ if (this.grid.toolbarConfig && this.grid.toolbarConfig.length > 0) {
1108
+ this.processUserToolbarItems(toolbarDivChildren);
1109
+ }
1110
+ else {
1111
+ this.addDefaultToolbarItems(toolbarDivChildren);
1112
+ }
1113
+ toolbarItems.push({
1114
+ name: `${this.grid.name}_toolbarDiv`,
1115
+ component: 'ZdTag',
1116
+ tag: 'div',
1117
+ cssStyle: 'display: flex; align-items: center',
1118
+ isVisible: `{{GridController_${this.grid.componentId}.showToolbar}}`,
1119
+ children: toolbarDivChildren,
1120
+ });
1121
+ return toolbarItems;
1073
1122
  }
1074
1123
  loadFilterButton({ component }) {
1075
1124
  this.filterButton = component;
@@ -1258,7 +1307,6 @@
1258
1307
  TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Ano Atual',
1259
1308
  TEKGRID_WITH_GROUPS: '(Com grupos)',
1260
1309
  TEKGRID_GRID_MIRROR: '(Espelho do grid)',
1261
- TEKGRID_NO_DATA: 'Não há dados para gerar o relatório',
1262
1310
  },
1263
1311
  },
1264
1312
  'en-US': {
@@ -1331,7 +1379,6 @@
1331
1379
  TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Current Year',
1332
1380
  TEKGRID_WITH_GROUPS: '(With groups)',
1333
1381
  TEKGRID_GRID_MIRROR: '(Grid mirror)',
1334
- TEKGRID_NO_DATA: 'There is no data to generate the report',
1335
1382
  },
1336
1383
  },
1337
1384
  'es-CL': {
@@ -1404,7 +1451,6 @@
1404
1451
  TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Año actual',
1405
1452
  TEKGRID_WITH_GROUPS: '(Con grupos)',
1406
1453
  TEKGRID_GRID_MIRROR: '(Espejo de grid)',
1407
- TEKGRID_NO_DATA: 'No hay datos para generar el reporte',
1408
1454
  },
1409
1455
  },
1410
1456
  });
@@ -1419,19 +1465,19 @@
1419
1465
  return this.grid.title;
1420
1466
  }
1421
1467
  get showAddButton() {
1422
- return this.grid.addButton;
1468
+ return this.grid.addButton && !this.isEditing && this.openToolbar;
1423
1469
  }
1424
1470
  get showDeleteButton() {
1425
- return this.grid.deleteButton !== 'none';
1471
+ return this.grid.deleteButton !== 'none' && !this.isEditing && this.openToolbar;
1426
1472
  }
1427
1473
  get showFilterButton() {
1428
- return this.grid.filterButton;
1474
+ return this.grid.filterButton && this.openToolbar;
1429
1475
  }
1430
1476
  get showModalFilterProps() {
1431
1477
  return this.grid.modalFilterProps;
1432
1478
  }
1433
1479
  get showSearchInput() {
1434
- return this.grid.showSearch;
1480
+ return this.grid.showSearch && this.openToolbar;
1435
1481
  }
1436
1482
  get showToolbar() {
1437
1483
  return this.openToolbar;
@@ -1446,46 +1492,29 @@
1446
1492
  return !this.openToolbar ? 'TEKGRID_SHOW' : 'TEKGRID_HIDE';
1447
1493
  }
1448
1494
  get showReloadButton() {
1449
- return this.grid.showReload;
1450
- }
1451
- get showDivider2() {
1452
- return (this.showReloadButton
1453
- && (this.showLayoutOptionsButton
1454
- || this.showColumnsButton
1455
- || this.showActionsButton
1456
- || this.showExportButton
1457
- || this.showSearchInput));
1495
+ return this.grid.showReload && !this.isEditing && this.openToolbar;
1458
1496
  }
1459
1497
  get showColumnsButton() {
1460
- return this.grid.columnsButton;
1498
+ return this.grid.columnsButton && !this.isEditing && this.openToolbar;
1461
1499
  }
1462
1500
  get columnsButtonIgnore() {
1463
1501
  return this.grid.columnsButtonIgnore;
1464
1502
  }
1465
1503
  get showLayoutOptionsButton() {
1466
- return this.grid.showLayoutOptions;
1504
+ return this.grid.showLayoutOptions && !this.isEditing && this.openToolbar;
1467
1505
  }
1468
- get showDivider1() {
1469
- return ((this.showAddButton || this.showDeleteButton)
1470
- && (this.showReloadButton
1471
- || this.showLayoutOptionsButton
1472
- || this.showColumnsButton
1473
- || this.showActionsButton
1474
- || this.showExportButton
1475
- || this.showSearchInput));
1506
+ get showDivider() {
1507
+ return !this.isEditing && this.openToolbar;
1476
1508
  }
1477
1509
  get showActionsButton() {
1478
- return this.grid.actions.length > 0;
1510
+ return this.grid.actions.length > 0 && !this.isEditing && this.openToolbar;
1479
1511
  }
1480
1512
  get showExportButton() {
1481
- return this.grid.showExport;
1513
+ return this.grid.showExport && !this.isEditing && this.openToolbar;
1482
1514
  }
1483
1515
  get showActionAndExportButton() {
1484
1516
  return ((this.showLayoutOptionsButton || this.showColumnsButton)
1485
- && (this.showActionsButton || this.showExportButton || this.showSearchInput));
1486
- }
1487
- get showDivider3() {
1488
- return ((this.showActionsButton || this.showExportButton) && this.showSearchInput);
1517
+ && (this.showActionsButton || this.showExportButton || this.showSearchInput)) && !this.isEditing && this.openToolbar;
1489
1518
  }
1490
1519
  get isEditing() {
1491
1520
  return this.grid.editing;
@@ -2247,6 +2276,10 @@
2247
2276
  * @public
2248
2277
  */
2249
2278
  this.dragColumns = true;
2279
+ /**
2280
+ * Components that will be rendered on toolbar slot
2281
+ */
2282
+ this.toolbarConfig = [];
2250
2283
  /**
2251
2284
  * Enables column resizing
2252
2285
  * @public
@@ -2328,8 +2361,8 @@
2328
2361
  this.groupColumnNames = [];
2329
2362
  this.summaryColumns = [];
2330
2363
  this.groupColumns = [];
2331
- this.groupedData = [];
2332
2364
  this.toolbarSlotProps = false;
2365
+ this.groupedData = [];
2333
2366
  this.editNewRowsOnly = false;
2334
2367
  this.showCheckboxAllFilter = core.Config.gridShowCheckboxAllFilter || false;
2335
2368
  this.defaultFilter = {};
@@ -2368,6 +2401,7 @@
2368
2401
  this.showSummaryTotal = this.getInitValue('showSummaryTotal', props.showSummaryTotal, this.showSummaryTotal);
2369
2402
  this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
2370
2403
  this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
2404
+ this.toolbarConfig = this.getInitValue('toolbarConfig', props.toolbarConfig, this.toolbarConfig);
2371
2405
  this.toolbarOpened = this.getInitValue('toolbarOpened', props.toolbarOpened, this.toolbarOpened);
2372
2406
  this.editNewRowsOnly = this.getInitValue('editNewRowsOnly', props.editNewRowsOnly, this.editNewRowsOnly);
2373
2407
  this.mainGrid = this.getInitValue('mainGrid', props.mainGrid, this.mainGrid);
@@ -2665,8 +2699,9 @@
2665
2699
  });
2666
2700
  if (this.groupedData.length > 0) {
2667
2701
  this.addGroupFooters(0);
2668
- if (this.showSummaryTotal) {
2669
- this.addSummary();
2702
+ if (this.showSummaryTotal && this.summaryColumns.length > 0) {
2703
+ const summaryRow = this.getSummary();
2704
+ this.groupedData.push(summaryRow);
2670
2705
  }
2671
2706
  }
2672
2707
  }
@@ -2718,14 +2753,79 @@
2718
2753
  for (let i = this.groups.length - 1; i >= groupIndex; i -= 1) {
2719
2754
  if (!this.groups[i].initialized)
2720
2755
  return;
2721
- const groupFooterRow = Object.assign({ groupFooter: true, groupIndex: i, groupHeaders: [], groupLabel: this.groups[i].lastGroupHeaderRow.groupLabel, groupValue: this.groups[i].lastGroupHeaderRow.groupValue }, this.summaryData(this.groups[i].footer));
2722
- // add header for outer groups
2723
- for (let g = 0; g < i; g += 1) {
2724
- groupFooterRow.groupHeaders.push(this.groups[g].lastGroupHeaderRow);
2725
- }
2756
+ const groupFooterRow = this.getGroupFooter(this.groups[i], i);
2757
+ groupFooterRow.groupHeaders = this.getGroupHeaders(groupIndex);
2726
2758
  this.groupedData.push(groupFooterRow);
2727
2759
  }
2728
2760
  }
2761
+ /**
2762
+ * Creates a group footer, calculating its summary data
2763
+ * @param group Group to which this footer is related
2764
+ * @param groupIndex Index of the group
2765
+ * @returns new group footer
2766
+ */
2767
+ getGroupFooter(group, groupIndex) {
2768
+ const groupFooterRow = Object.assign({ groupIndex, groupFooter: true, groupHeaders: [], groupLabel: group.lastGroupHeaderRow.groupLabel, groupValue: group.lastGroupHeaderRow.groupValue }, this.getSummaryData(group.footer));
2769
+ return groupFooterRow;
2770
+ }
2771
+ /**
2772
+ * Gets all of the group headers that belong to the group at the specified index
2773
+ * This method should be called only during the groups creation process because it depends on the
2774
+ * group creation order (because it accesses lastGroupHeaderRow that changes during the creation process)
2775
+ * @param groupIndex
2776
+ * @returns
2777
+ */
2778
+ getGroupHeaders(groupIndex) {
2779
+ const groupHeaders = [];
2780
+ for (let i = 0; i <= groupIndex; i += 1) {
2781
+ groupHeaders.push(this.groups[i].lastGroupHeaderRow);
2782
+ }
2783
+ return groupHeaders;
2784
+ }
2785
+ /**
2786
+ * Updates all footers summary data and the summary total
2787
+ */
2788
+ updateSummary() {
2789
+ this.summary = {};
2790
+ this.groups.forEach((group) => {
2791
+ this.resetFooterVariables(group);
2792
+ });
2793
+ this.groupedData.forEach((row) => {
2794
+ if (this.isGroupHeader(row))
2795
+ return;
2796
+ if (this.isGroupFooter(row)) {
2797
+ this.updateGroupFooterSummary(row);
2798
+ this.resetFooterVariables(this.groups[row.groupIndex]);
2799
+ return;
2800
+ }
2801
+ if (this.isGroupSummary(row)) {
2802
+ this.updateSummaryTotal(row);
2803
+ return;
2804
+ }
2805
+ this.calcSummary(row);
2806
+ });
2807
+ }
2808
+ /**
2809
+ * Takes a group footer and updates its summary data
2810
+ */
2811
+ updateGroupFooterSummary(groupFooter) {
2812
+ const group = this.groups[groupFooter.groupIndex];
2813
+ const summary = this.getSummaryData(group.footer);
2814
+ Object.keys(summary).forEach((key) => {
2815
+ // change properties one by one to avoid changing the object reference
2816
+ groupFooter[key] = summary[key];
2817
+ });
2818
+ }
2819
+ /**
2820
+ * Updates the total summary data
2821
+ */
2822
+ updateSummaryTotal(summaryTotal) {
2823
+ const summary = this.getSummaryData(this.summary);
2824
+ Object.keys(summary).forEach((key) => {
2825
+ // change properties one by one to avoid changing the object reference
2826
+ summaryTotal[key] = summary[key];
2827
+ });
2828
+ }
2729
2829
  resetFooterVariables(group) {
2730
2830
  this.summaryColumns.forEach((column) => {
2731
2831
  group.footer[column.name] = {
@@ -2762,33 +2862,31 @@
2762
2862
  }
2763
2863
  }
2764
2864
  calcSummary(row) {
2765
- if (this.summaryColumns.length > 0) {
2766
- this.summaryColumns.forEach((column) => {
2767
- const columnName = column.name;
2768
- const rowValue = row[columnName];
2769
- if (this.isUndefined(this.summary[columnName])) {
2770
- this.summary[columnName] = {
2771
- count: 0,
2772
- sum: undefined,
2773
- avg: undefined,
2774
- min: undefined,
2775
- max: undefined,
2776
- };
2777
- }
2778
- this.calcSummaryValues(columnName, this.summary[columnName], rowValue);
2779
- this.groups.forEach((group) => {
2780
- this.calcSummaryValues(columnName, group.footer[columnName], rowValue);
2781
- });
2782
- });
2783
- }
2784
- }
2785
- addSummary() {
2786
2865
  if (this.summaryColumns.length === 0)
2787
2866
  return;
2788
- const summaryRow = Object.assign({ groupFooter: true, groupSummary: true }, this.summaryData(this.summary));
2789
- this.groupedData.push(summaryRow);
2867
+ this.summaryColumns.forEach((column) => {
2868
+ const columnName = column.name;
2869
+ const rowValue = this.getVisibleValue(row, column);
2870
+ if (this.isUndefined(this.summary[columnName])) {
2871
+ this.summary[columnName] = {
2872
+ count: 0,
2873
+ sum: undefined,
2874
+ avg: undefined,
2875
+ min: undefined,
2876
+ max: undefined,
2877
+ };
2878
+ }
2879
+ this.calcSummaryValues(columnName, this.summary[columnName], rowValue);
2880
+ this.groups.forEach((group) => {
2881
+ this.calcSummaryValues(columnName, group.footer[columnName], rowValue);
2882
+ });
2883
+ });
2790
2884
  }
2791
- summaryData(group) {
2885
+ getSummary() {
2886
+ const summaryRow = Object.assign({ groupFooter: true, groupSummary: true }, this.getSummaryData(this.summary));
2887
+ return summaryRow;
2888
+ }
2889
+ getSummaryData(group) {
2792
2890
  const summaryData = {};
2793
2891
  this.summaryColumns.forEach((column) => {
2794
2892
  const { aggregation } = column;
@@ -3181,12 +3279,32 @@
3181
3279
  isGroupHeader(row) {
3182
3280
  return row.groupHeader;
3183
3281
  }
3282
+ /**
3283
+ * Checks if a row is a group footer, adding typescript type-checking
3284
+ */
3285
+ isGroupFooter(row) {
3286
+ return row.groupFooter && !row.groupSummary;
3287
+ }
3288
+ /**
3289
+ * Checks if a row is a summary, adding typescript type-checking
3290
+ */
3291
+ isGroupSummary(row) {
3292
+ return row.groupSummary;
3293
+ }
3184
3294
  /**
3185
3295
  * Checks if a row is the last grouping of the grid (the most internal grouping)
3186
3296
  */
3187
3297
  isLastGrouping(group) {
3188
3298
  return group.groupColumnName === this.groupColumns[this.groupColumns.length - 1].name;
3189
3299
  }
3300
+ /**
3301
+ * change event of editable components
3302
+ * - override to call updateSummary on change
3303
+ */
3304
+ changeEditableComponent(column, row, value, component) {
3305
+ super.changeEditableComponent(column, row, value, component);
3306
+ this.updateSummary();
3307
+ }
3190
3308
  }
3191
3309
 
3192
3310
  class TekGridColumnsButtonController extends common.IterableColumnsButtonController {
@@ -3829,6 +3947,10 @@
3829
3947
  this.title = '';
3830
3948
  /* Show Add button */
3831
3949
  this.addButton = false;
3950
+ /**
3951
+ * Components that will be rendered on toolbar slot
3952
+ */
3953
+ this.toolbarConfig = [];
3832
3954
  /* Show edit buttons */
3833
3955
  this.showEditButtons = true;
3834
3956
  /* Show Delete button */
@@ -3947,6 +4069,7 @@
3947
4069
  this.exportConfig = this.getInitValue('exportConfig', props.exportConfig, this.exportConfig);
3948
4070
  this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
3949
4071
  this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
4072
+ this.toolbarConfig = this.getInitValue('toolbarConfig', props.toolbarConfig, this.toolbarConfig);
3950
4073
  this.toolbarOpened = this.getInitValue('toolbarOpened', props.toolbarOpened, this.toolbarOpened);
3951
4074
  this.exportActions = props.exportActions || this.exportActions;
3952
4075
  this.reportTitle = this.getInitValue('reportTitle', props.reportTitle, this.reportTitle);