@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
@@ -0,0 +1,24 @@
1
+ import { TekGridDeleteRowsError } from '../../../../src/error/delete-rows-error';
2
+
3
+ describe('TekGridDeleteRowsError', () => {
4
+ describe('constructor()', () => {
5
+ it('should create an instance of the error with the correct name and message', () => {
6
+ // Cria uma nova instância do erro
7
+ const error = new TekGridDeleteRowsError();
8
+
9
+ // Verifica se a instância foi criada corretamente
10
+ expect(error).toBeInstanceOf(TekGridDeleteRowsError);
11
+ expect(error).toBeInstanceOf(Error);
12
+
13
+ // Verifica se o nome do erro está correto
14
+ expect(error.name).toBe('TekGridDeleteRowsError');
15
+
16
+ // Verifica se a mensagem de erro está correta
17
+ expect(error.message).toBe(
18
+ 'TekGrid can\'t automatically delete rows when selectAllPages property is true.'
19
+ + ' You should delete them manually using the beforeDelete event and preventing'
20
+ + ' the default execution',
21
+ );
22
+ });
23
+ });
24
+ });
@@ -1,44 +1,44 @@
1
- import { Button } from '@zeedhi/common';
2
- import { TekGrid } from '../../../../../src/components';
3
- import { ButtonOption } from '../../../../../src/utils';
4
-
5
- describe('ButtonOption', () => {
6
- describe('buildComponent()', () => {
7
- it('when called, should build a simple button component', () => {
8
- const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
9
- const config = {
10
- type: 'pdf',
11
- label: 'Exportar PDF',
12
- };
13
- const option = new ButtonOption(config);
14
-
15
- const component = option.buildComponent(grid);
16
-
17
- expect(component).toEqual(expect.objectContaining({
18
- label: config.label,
19
- name: 'Grid_export_pdf_portrait',
20
- component: 'ZdButton',
21
- iconName: undefined,
22
- flat: true,
23
- }));
24
- });
25
-
26
- it('the generated button component should call grid.getReport on click', () => {
27
- const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
28
- const spy = jest.fn();
29
- grid.getReport = spy;
30
- const config = {
31
- type: 'pdf',
32
- label: 'Exportar PDF',
33
- };
34
- const option = new ButtonOption(config);
35
-
36
- const component = option.buildComponent(grid);
37
-
38
- const instance = new Button(component);
39
- instance.click();
40
-
41
- expect(spy).toHaveBeenCalledTimes(1);
42
- });
43
- });
44
- });
1
+ import { Button } from '@zeedhi/common';
2
+ import { TekGrid } from '../../../../../src/components';
3
+ import { ButtonOption } from '../../../../../src/utils';
4
+
5
+ describe('ButtonOption', () => {
6
+ describe('buildComponent()', () => {
7
+ it('when called, should build a simple button component', () => {
8
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
9
+ const config = {
10
+ type: 'pdf',
11
+ label: 'Exportar PDF',
12
+ };
13
+ const option = new ButtonOption(config);
14
+
15
+ const component = option.buildComponent(grid);
16
+
17
+ expect(component).toEqual(expect.objectContaining({
18
+ label: config.label,
19
+ name: 'Grid_export_pdf_portrait',
20
+ component: 'ZdButton',
21
+ iconName: undefined,
22
+ flat: true,
23
+ }));
24
+ });
25
+
26
+ it('the generated button component should call grid.getReport on click', () => {
27
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
28
+ const spy = jest.fn();
29
+ grid.getReport = spy;
30
+ const config = {
31
+ type: 'pdf',
32
+ label: 'Exportar PDF',
33
+ };
34
+ const option = new ButtonOption(config);
35
+
36
+ const component = option.buildComponent(grid);
37
+
38
+ const instance = new Button(component);
39
+ instance.click();
40
+
41
+ expect(spy).toHaveBeenCalledTimes(1);
42
+ });
43
+ });
44
+ });
@@ -1,135 +1,135 @@
1
- import { Button, IText, Text } from '@zeedhi/common';
2
- import { ITekGridExportConfig, TekGrid } from '../../../../../src/components';
3
- import { MultiOption } from '../../../../../src/utils';
4
-
5
- describe('MultiOption', () => {
6
- describe('buildComponent()', () => {
7
- it('when called, should build a row with multiple buttons', () => {
8
- const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
9
- const config: ITekGridExportConfig = {
10
- type: 'pdf',
11
- label: 'Exportar PDF',
12
- multiOption: [
13
- { label: 'portrait', iconName: 'icon-portrait' },
14
- { label: 'landscape', iconName: 'icon-landscape' },
15
- ],
16
- };
17
- const option = new MultiOption(config);
18
-
19
- const component = option.buildComponent(grid);
20
-
21
- expect(component).toEqual({
22
- name: 'Grid_export_pdf_row',
23
- component: 'ZdRow',
24
- cssClass: 'zd-display-flex zd-ma-0 zd-py-0 zd-gap-x-1 tek-grid-export-multioption-row',
25
- children: [
26
- expect.objectContaining({
27
- name: 'Grid_export_pdf_text',
28
- component: 'ZdText',
29
- text: 'Exportar PDF',
30
- cssClass: 'zd-display-flex zd-align-center zd-flex-grow-1 tek-grid-export-multioption-text',
31
- }),
32
- {
33
- name: 'Grid_export_pdf_tooltip_portrait',
34
- component: 'ZdTooltip',
35
- bottom: true,
36
- label: 'portrait',
37
- children: [
38
- expect.objectContaining({
39
- name: 'Grid_export_pdf_button_portrait',
40
- component: 'ZdButton',
41
- icon: true,
42
- iconName: 'icon-portrait',
43
- }),
44
- ],
45
- },
46
- expect.objectContaining({
47
- name: 'Grid_export_pdf_divider_portrait',
48
- component: 'ZdDivider',
49
- cssClass: 'zd-my-1',
50
- vertical: true,
51
- }),
52
- {
53
- name: 'Grid_export_pdf_tooltip_landscape',
54
- component: 'ZdTooltip',
55
- bottom: true,
56
- label: 'landscape',
57
- children: [
58
- expect.objectContaining({
59
- name: 'Grid_export_pdf_button_landscape',
60
- component: 'ZdButton',
61
- icon: true,
62
- iconName: 'icon-landscape',
63
- }),
64
- ],
65
- },
66
- ],
67
- });
68
- });
69
-
70
- it('the generated text component should call stopPropagation on click', () => {
71
- const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
72
- const config: ITekGridExportConfig = {
73
- type: 'pdf',
74
- label: 'Exportar PDF',
75
- multiOption: [
76
- { label: 'portrait', iconName: 'icon-portrait' },
77
- { label: 'landscape', iconName: 'icon-landscape' },
78
- ],
79
- };
80
- const option = new MultiOption(config);
81
-
82
- const component = option.buildComponent(grid);
83
-
84
- const instance = new Text(component.children![0] as IText);
85
- const spy = jest.fn();
86
- const event = { stopPropagation: spy } as unknown as Event;
87
- instance.click(event);
88
-
89
- expect(spy).toHaveBeenCalled();
90
- });
91
-
92
- it('the generated text component should not throw if event is undefined', () => {
93
- const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
94
- const config: ITekGridExportConfig = {
95
- type: 'pdf',
96
- label: 'Exportar PDF',
97
- multiOption: [
98
- { label: 'portrait', iconName: 'icon-portrait' },
99
- { label: 'landscape', iconName: 'icon-landscape' },
100
- ],
101
- };
102
- const option = new MultiOption(config);
103
-
104
- const component = option.buildComponent(grid);
105
-
106
- const instance = new Text(component.children![0] as IText);
107
-
108
- expect(() => instance.callEvent('click', { event: undefined })).not.toThrow();
109
- });
110
-
111
- it('the generated button components should call grid.getReport on click', () => {
112
- const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
113
- const spy = jest.fn();
114
- grid.getReport = spy;
115
- const config: ITekGridExportConfig = {
116
- type: 'pdf',
117
- multiOption: [
118
- { label: 'portrait', iconName: 'icon-portrait' },
119
- { label: 'landscape', iconName: 'icon-landscape' },
120
- ],
121
- };
122
- const option = new MultiOption(config);
123
-
124
- const component = option.buildComponent(grid);
125
-
126
- const instance = new Button(component.children![1].children![0]);
127
- instance.click();
128
-
129
- const instance2 = new Button(component.children![3].children![0]);
130
- instance2.click();
131
-
132
- expect(spy).toHaveBeenCalledTimes(2);
133
- });
134
- });
135
- });
1
+ import { Button, IText, Text } from '@zeedhi/common';
2
+ import { ITekGridExportConfig, TekGrid } from '../../../../../src/components';
3
+ import { MultiOption } from '../../../../../src/utils';
4
+
5
+ describe('MultiOption', () => {
6
+ describe('buildComponent()', () => {
7
+ it('when called, should build a row with multiple buttons', () => {
8
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
9
+ const config: ITekGridExportConfig = {
10
+ type: 'pdf',
11
+ label: 'Exportar PDF',
12
+ multiOption: [
13
+ { label: 'portrait', iconName: 'icon-portrait' },
14
+ { label: 'landscape', iconName: 'icon-landscape' },
15
+ ],
16
+ };
17
+ const option = new MultiOption(config);
18
+
19
+ const component = option.buildComponent(grid);
20
+
21
+ expect(component).toEqual({
22
+ name: 'Grid_export_pdf_row',
23
+ component: 'ZdRow',
24
+ cssClass: 'zd-display-flex zd-ma-0 zd-py-0 zd-gap-x-1 tek-grid-export-multioption-row',
25
+ children: [
26
+ expect.objectContaining({
27
+ name: 'Grid_export_pdf_text',
28
+ component: 'ZdText',
29
+ text: 'Exportar PDF',
30
+ cssClass: 'zd-display-flex zd-align-center zd-flex-grow-1 tek-grid-export-multioption-text',
31
+ }),
32
+ {
33
+ name: 'Grid_export_pdf_tooltip_portrait',
34
+ component: 'ZdTooltip',
35
+ bottom: true,
36
+ label: 'portrait',
37
+ children: [
38
+ expect.objectContaining({
39
+ name: 'Grid_export_pdf_button_portrait',
40
+ component: 'ZdButton',
41
+ icon: true,
42
+ iconName: 'icon-portrait',
43
+ }),
44
+ ],
45
+ },
46
+ expect.objectContaining({
47
+ name: 'Grid_export_pdf_divider_portrait',
48
+ component: 'ZdDivider',
49
+ cssClass: 'zd-my-1',
50
+ vertical: true,
51
+ }),
52
+ {
53
+ name: 'Grid_export_pdf_tooltip_landscape',
54
+ component: 'ZdTooltip',
55
+ bottom: true,
56
+ label: 'landscape',
57
+ children: [
58
+ expect.objectContaining({
59
+ name: 'Grid_export_pdf_button_landscape',
60
+ component: 'ZdButton',
61
+ icon: true,
62
+ iconName: 'icon-landscape',
63
+ }),
64
+ ],
65
+ },
66
+ ],
67
+ });
68
+ });
69
+
70
+ it('the generated text component should call stopPropagation on click', () => {
71
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
72
+ const config: ITekGridExportConfig = {
73
+ type: 'pdf',
74
+ label: 'Exportar PDF',
75
+ multiOption: [
76
+ { label: 'portrait', iconName: 'icon-portrait' },
77
+ { label: 'landscape', iconName: 'icon-landscape' },
78
+ ],
79
+ };
80
+ const option = new MultiOption(config);
81
+
82
+ const component = option.buildComponent(grid);
83
+
84
+ const instance = new Text(component.children![0] as IText);
85
+ const spy = jest.fn();
86
+ const event = { stopPropagation: spy } as unknown as Event;
87
+ instance.click(event);
88
+
89
+ expect(spy).toHaveBeenCalled();
90
+ });
91
+
92
+ it('the generated text component should not throw if event is undefined', () => {
93
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
94
+ const config: ITekGridExportConfig = {
95
+ type: 'pdf',
96
+ label: 'Exportar PDF',
97
+ multiOption: [
98
+ { label: 'portrait', iconName: 'icon-portrait' },
99
+ { label: 'landscape', iconName: 'icon-landscape' },
100
+ ],
101
+ };
102
+ const option = new MultiOption(config);
103
+
104
+ const component = option.buildComponent(grid);
105
+
106
+ const instance = new Text(component.children![0] as IText);
107
+
108
+ expect(() => instance.callEvent('click', { event: undefined })).not.toThrow();
109
+ });
110
+
111
+ it('the generated button components should call grid.getReport on click', () => {
112
+ const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
113
+ const spy = jest.fn();
114
+ grid.getReport = spy;
115
+ const config: ITekGridExportConfig = {
116
+ type: 'pdf',
117
+ multiOption: [
118
+ { label: 'portrait', iconName: 'icon-portrait' },
119
+ { label: 'landscape', iconName: 'icon-landscape' },
120
+ ],
121
+ };
122
+ const option = new MultiOption(config);
123
+
124
+ const component = option.buildComponent(grid);
125
+
126
+ const instance = new Button(component.children![1].children![0]);
127
+ instance.click();
128
+
129
+ const instance2 = new Button(component.children![3].children![0]);
130
+ instance2.click();
131
+
132
+ expect(spy).toHaveBeenCalledTimes(2);
133
+ });
134
+ });
135
+ });