@genesislcap/grid-pro 14.275.3 → 14.276.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 (150) hide show
  1. package/README.md +428 -15
  2. package/dist/custom-elements.json +1306 -141
  3. package/dist/dts/datasource/base.datasource.d.ts +38 -1
  4. package/dist/dts/datasource/base.datasource.d.ts.map +1 -1
  5. package/dist/dts/datasource/index.d.ts +1 -0
  6. package/dist/dts/datasource/index.d.ts.map +1 -1
  7. package/dist/dts/datasource/server-side.datasource.d.ts +6 -5
  8. package/dist/dts/datasource/server-side.datasource.d.ts.map +1 -1
  9. package/dist/dts/grid-pro-genesis-datasource/grid-pro-genesis-datasource.d.ts +34 -12
  10. package/dist/dts/grid-pro-genesis-datasource/grid-pro-genesis-datasource.d.ts.map +1 -1
  11. package/dist/dts/grid-pro.d.ts +65 -16
  12. package/dist/dts/grid-pro.d.ts.map +1 -1
  13. package/dist/dts/grid-pro.styles.d.ts.map +1 -1
  14. package/dist/dts/grid-pro.types.d.ts +91 -0
  15. package/dist/dts/grid-pro.types.d.ts.map +1 -1
  16. package/dist/dts/index.d.ts +1 -0
  17. package/dist/dts/index.d.ts.map +1 -1
  18. package/dist/dts/status-bar-components/index.d.ts +5 -0
  19. package/dist/dts/status-bar-components/index.d.ts.map +1 -0
  20. package/dist/dts/status-bar-components/label-value.status-bar.d.ts +21 -0
  21. package/dist/dts/status-bar-components/label-value.status-bar.d.ts.map +1 -0
  22. package/dist/dts/status-bar-components/load-more.status-bar.d.ts +43 -0
  23. package/dist/dts/status-bar-components/load-more.status-bar.d.ts.map +1 -0
  24. package/dist/dts/status-bar-components/pagination.status-bar.d.ts +32 -0
  25. package/dist/dts/status-bar-components/pagination.status-bar.d.ts.map +1 -0
  26. package/dist/dts/status-bar-components/reload.status-bar.d.ts +36 -0
  27. package/dist/dts/status-bar-components/reload.status-bar.d.ts.map +1 -0
  28. package/dist/esm/datasource/base.datasource.js +124 -7
  29. package/dist/esm/datasource/index.js +1 -0
  30. package/dist/esm/datasource/server-side.datasource.js +9 -9
  31. package/dist/esm/grid-pro-genesis-datasource/grid-pro-genesis-datasource.js +111 -34
  32. package/dist/esm/grid-pro.js +116 -2
  33. package/dist/esm/grid-pro.styles.js +10 -0
  34. package/dist/esm/grid-pro.types.js +28 -0
  35. package/dist/esm/index.js +1 -0
  36. package/dist/esm/status-bar-components/index.js +4 -0
  37. package/dist/esm/status-bar-components/label-value.status-bar.js +33 -0
  38. package/dist/esm/status-bar-components/load-more.status-bar.js +209 -0
  39. package/dist/esm/status-bar-components/pagination.status-bar.js +206 -0
  40. package/dist/esm/status-bar-components/reload.status-bar.js +162 -0
  41. package/dist/grid-pro.api.json +6872 -3339
  42. package/dist/grid-pro.d.ts +384 -32
  43. package/docs/api/grid-pro.criteriadelimiter.md +13 -0
  44. package/docs/api/grid-pro.criteriajoin.md +13 -0
  45. package/docs/api/grid-pro.default_status_bar_config.md +13 -0
  46. package/docs/api/grid-pro.genesisgriddatasourceelement.aggrid.md +11 -0
  47. package/docs/api/grid-pro.genesisgriddatasourceelement.connect.md +11 -0
  48. package/docs/api/grid-pro.genesisgriddatasourceelement.criteria.md +11 -0
  49. package/docs/api/grid-pro.genesisgriddatasourceelement.criteriafromfilters.md +11 -0
  50. package/docs/api/grid-pro.genesisgriddatasourceelement.datasource.md +11 -0
  51. package/docs/api/grid-pro.genesisgriddatasourceelement.datasourceoptions.md +15 -0
  52. package/docs/api/grid-pro.genesisgriddatasourceelement.datasourcestatuschanged.md +23 -0
  53. package/docs/api/grid-pro.genesisgriddatasourceelement.defaultrowidbyresourcetype.md +11 -0
  54. package/docs/api/grid-pro.genesisgriddatasourceelement.deferredcolumnstates.md +11 -0
  55. package/docs/api/grid-pro.genesisgriddatasourceelement.deferredgridoptions.md +11 -0
  56. package/docs/api/grid-pro.genesisgriddatasourceelement.disablepolling.md +11 -0
  57. package/docs/api/grid-pro.genesisgriddatasourceelement.fields.md +11 -0
  58. package/docs/api/grid-pro.genesisgriddatasourceelement.isrequestserver.md +11 -0
  59. package/docs/api/grid-pro.genesisgriddatasourceelement.issnapshot.md +11 -0
  60. package/docs/api/grid-pro.genesisgriddatasourceelement.maxrows.md +11 -0
  61. package/docs/api/grid-pro.genesisgriddatasourceelement.maxview.md +11 -0
  62. package/docs/api/grid-pro.genesisgriddatasourceelement.md +55 -0
  63. package/docs/api/grid-pro.genesisgriddatasourceelement.movingview.md +11 -0
  64. package/docs/api/grid-pro.genesisgriddatasourceelement.orderby.md +11 -0
  65. package/docs/api/grid-pro.genesisgriddatasourceelement.pollinginterval.md +11 -0
  66. package/docs/api/grid-pro.genesisgriddatasourceelement.removefilter.md +22 -0
  67. package/docs/api/grid-pro.genesisgriddatasourceelement.request.md +11 -0
  68. package/docs/api/grid-pro.genesisgriddatasourceelement.requestautosetup.md +18 -0
  69. package/docs/api/grid-pro.genesisgriddatasourceelement.resourcename.md +11 -0
  70. package/docs/api/grid-pro.genesisgriddatasourceelement.reverse.md +11 -0
  71. package/docs/api/grid-pro.genesisgriddatasourceelement.rowdatamapper.md +13 -0
  72. package/docs/api/grid-pro.genesisgriddatasourceelement.rowid.md +11 -0
  73. package/docs/api/grid-pro.genesisgriddatasourceelement.rowidattr.md +15 -0
  74. package/docs/api/grid-pro.genesisgriddatasourceelement.setfilter.md +23 -0
  75. package/docs/api/grid-pro.genesisgriddatasourceelement.update.md +11 -0
  76. package/docs/api/grid-pro.genesisgriddatasourceelement.viewnumber.md +11 -0
  77. package/docs/api/grid-pro.gridpro.clearlocalgridoptions.md +17 -0
  78. package/docs/api/grid-pro.gridpro.gridprodatasource.md +2 -2
  79. package/docs/api/grid-pro.gridpro.md +8 -2
  80. package/docs/api/grid-pro.gridpro.pagination.md +18 -0
  81. package/docs/api/grid-pro.gridpro.paginationpagesize.md +18 -0
  82. package/docs/api/grid-pro.gridpro.persistcolumnstatekey.md +1 -1
  83. package/docs/api/grid-pro.gridpro.setuppaginationandstatusbar.md +22 -0
  84. package/docs/api/grid-pro.gridpro.statusbarconfig.md +18 -0
  85. package/docs/api/grid-pro.gridpro.withstatusbar.md +18 -0
  86. package/docs/api/grid-pro.gridprobasedatasource.agtransaction.md +11 -0
  87. package/docs/api/grid-pro.gridprobasedatasource.applyallagtransactions.md +15 -0
  88. package/docs/api/grid-pro.gridprobasedatasource.applyasyncfuncname.md +11 -0
  89. package/docs/api/grid-pro.gridprobasedatasource.applyfuncname.md +11 -0
  90. package/docs/api/grid-pro.gridprobasedatasource.applytransaction.md +22 -0
  91. package/docs/api/grid-pro.gridprobasedatasource.applytransactionasync.md +23 -0
  92. package/docs/api/grid-pro.gridprobasedatasource.datasubwasloggedoff.md +11 -0
  93. package/docs/api/grid-pro.gridprobasedatasource.destroy.md +15 -0
  94. package/docs/api/grid-pro.gridprobasedatasource.generatecolumndefsfrommetadata.md +23 -0
  95. package/docs/api/grid-pro.gridprobasedatasource.getdatasourcestatusbarpanels.md +24 -0
  96. package/docs/api/grid-pro.gridprobasedatasource.handlestreamdeletes.md +22 -0
  97. package/docs/api/grid-pro.gridprobasedatasource.handlestreaminserts.md +23 -0
  98. package/docs/api/grid-pro.gridprobasedatasource.handlestreamupdates.md +22 -0
  99. package/docs/api/grid-pro.gridprobasedatasource.loadmore.md +15 -0
  100. package/docs/api/grid-pro.gridprobasedatasource.md +42 -0
  101. package/docs/api/grid-pro.gridprobasedatasource.pagination.md +11 -0
  102. package/docs/api/grid-pro.gridprobasedatasource.reloadresourcedata.md +15 -0
  103. package/docs/api/grid-pro.gridprobasedatasource.restart.md +15 -0
  104. package/docs/api/grid-pro.gridprobasedatasource.rowdata.md +11 -0
  105. package/docs/api/grid-pro.gridprogenesisdatasource.handlestreamdeletes.md +24 -0
  106. package/docs/api/grid-pro.gridprogenesisdatasource.handlestreaminserts.md +22 -0
  107. package/docs/api/grid-pro.gridprogenesisdatasource.handlestreamupdates.md +22 -0
  108. package/docs/api/grid-pro.gridprogenesisdatasource.loadmore.md +15 -0
  109. package/docs/api/grid-pro.gridprogenesisdatasource.md +6 -1
  110. package/docs/api/grid-pro.gridprogenesisdatasource.reloadresourcedata.md +21 -0
  111. package/docs/api/grid-pro.gridprogenesisdatasource.restart.md +3 -3
  112. package/docs/api/grid-pro.gridprostatusbarconfig.loadmore.md +18 -0
  113. package/docs/api/grid-pro.gridprostatusbarconfig.maxrows.md +18 -0
  114. package/docs/api/grid-pro.gridprostatusbarconfig.md +27 -0
  115. package/docs/api/grid-pro.gridprostatusbarconfig.reload.md +18 -0
  116. package/docs/api/grid-pro.gridprostatusbarconfig.rows.md +18 -0
  117. package/docs/api/grid-pro.gridprostatusbarloadmoreconfig.appearance.md +18 -0
  118. package/docs/api/grid-pro.gridprostatusbarloadmoreconfig.md +22 -0
  119. package/docs/api/grid-pro.gridprostatusbarloadmoreconfig.onloadmore.md +13 -0
  120. package/docs/api/grid-pro.gridprostatusbarloadmoreconfig.tooltip.md +18 -0
  121. package/docs/api/grid-pro.gridprostatusbarreloadconfig.icon.md +18 -0
  122. package/docs/api/grid-pro.gridprostatusbarreloadconfig.md +22 -0
  123. package/docs/api/grid-pro.gridprostatusbarreloadconfig.onreload.md +13 -0
  124. package/docs/api/grid-pro.gridprostatusbarreloadconfig.tooltip.md +18 -0
  125. package/docs/api/grid-pro.gridprostatusbartypes.md +27 -0
  126. package/docs/api/grid-pro.labelvaluestatusbarcomponent.destroy.md +15 -0
  127. package/docs/api/grid-pro.labelvaluestatusbarcomponent.getgui.md +15 -0
  128. package/docs/api/grid-pro.labelvaluestatusbarcomponent.init.md +22 -0
  129. package/docs/api/grid-pro.labelvaluestatusbarcomponent.md +23 -0
  130. package/docs/api/grid-pro.labelvaluestatusbarparams.md +17 -0
  131. package/docs/api/grid-pro.loadmorestatusbarcomponent.destroy.md +15 -0
  132. package/docs/api/grid-pro.loadmorestatusbarcomponent.getgui.md +15 -0
  133. package/docs/api/grid-pro.loadmorestatusbarcomponent.init.md +22 -0
  134. package/docs/api/grid-pro.loadmorestatusbarcomponent.md +25 -0
  135. package/docs/api/grid-pro.loadmorestatusbarcomponent.updatebuttonvisibility.md +15 -0
  136. package/docs/api/grid-pro.loadmorestatusbarcomponent.updateparams.md +22 -0
  137. package/docs/api/grid-pro.loadmorestatusbarparams.md +18 -0
  138. package/docs/api/grid-pro.md +16 -0
  139. package/docs/api/grid-pro.paginationstatusbarcomponent.destroy.md +15 -0
  140. package/docs/api/grid-pro.paginationstatusbarcomponent.getgui.md +15 -0
  141. package/docs/api/grid-pro.paginationstatusbarcomponent.init.md +22 -0
  142. package/docs/api/grid-pro.paginationstatusbarcomponent.md +23 -0
  143. package/docs/api/grid-pro.reloadstatusbarcomponent.destroy.md +15 -0
  144. package/docs/api/grid-pro.reloadstatusbarcomponent.getgui.md +15 -0
  145. package/docs/api/grid-pro.reloadstatusbarcomponent.init.md +22 -0
  146. package/docs/api/grid-pro.reloadstatusbarcomponent.md +24 -0
  147. package/docs/api/grid-pro.reloadstatusbarcomponent.updateparams.md +22 -0
  148. package/docs/api/grid-pro.reloadstatusbarparams.md +17 -0
  149. package/docs/api-report.md +256 -6
  150. package/package.json +13 -13
@@ -0,0 +1,209 @@
1
+ import { __awaiter } from "tslib";
2
+ import { delay, getCurrentDesignSystemPrefix } from '@genesislcap/foundation-utils';
3
+ const LOADING_DELAY = 500;
4
+ /**
5
+ * A status bar component that shows a "Load More" button when more rows are available
6
+ * @public
7
+ */
8
+ export class LoadMoreStatusBarComponent {
9
+ constructor() {
10
+ this.buttonLabel = 'Load More';
11
+ this.isLoading = false;
12
+ this.isLeftAligned = false;
13
+ }
14
+ init(params) {
15
+ var _a, _b, _c;
16
+ this.params = params;
17
+ this.gridApi = params.api;
18
+ this.element = document.createElement('div');
19
+ this.element.classList.add('ag-status-panel', 'ag-load-more-panel');
20
+ this.element.setAttribute('data-test-id', 'grid-load-more-panel');
21
+ this.element.setAttribute('role', 'region');
22
+ this.element.setAttribute('aria-label', 'Load more data controls');
23
+ this.element.style.display = 'flex';
24
+ this.element.style.alignItems = 'center';
25
+ // Determine alignment based on pagination status
26
+ // When pagination is enabled, load more is aligned left, otherwise right
27
+ this.isLeftAligned = ((_c = (_b = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.gridOptionsService) === null || _b === void 0 ? void 0 : _b.gridOptions) === null || _c === void 0 ? void 0 : _c.pagination) || false;
28
+ this.element.style.justifyContent = this.isLeftAligned ? 'flex-start' : 'flex-end';
29
+ // Only add padding on the side where the button is
30
+ this.element.style.paddingLeft = 'var(--ag-grid-size)';
31
+ this.element.style.paddingRight = 'var(--ag-grid-size)';
32
+ this.element.style.height = 'var(--ag-status-bar-height)';
33
+ // Detect the current design system prefix (rapid or zero)
34
+ this.designSystemPrefix = getCurrentDesignSystemPrefix(this.element, 'zero');
35
+ this.createProgressRing();
36
+ this.createLoadMoreButton();
37
+ this.updateButtonVisibility();
38
+ // Remove all children first to ensure correct ordering
39
+ while (this.element.firstChild) {
40
+ this.element.removeChild(this.element.firstChild);
41
+ }
42
+ // Add elements in the correct order based on alignment
43
+ if (this.isLeftAligned) {
44
+ // Left-aligned: Button first, then progress ring
45
+ this.element.appendChild(this.loadMoreButton);
46
+ this.element.appendChild(this.progressRing);
47
+ }
48
+ else {
49
+ // Right-aligned: Progress ring first, then button
50
+ this.element.appendChild(this.progressRing);
51
+ this.element.appendChild(this.loadMoreButton);
52
+ }
53
+ }
54
+ createProgressRing() {
55
+ // Create the progress ring with the appropriate design system prefix
56
+ this.progressRing = document.createElement(`${this.designSystemPrefix}-progress-ring`);
57
+ this.progressRing.setAttribute('data-test-id', 'grid-load-more-progress');
58
+ this.progressRing.setAttribute('aria-label', 'Loading more data');
59
+ // Set styles for the progress ring
60
+ this.progressRing.style.width = '20px';
61
+ this.progressRing.style.height = '20px';
62
+ // Different margin based on alignment - when left-aligned, progress ring goes after button
63
+ this.progressRing.style.margin = this.isLeftAligned ? '0 0 0 8px' : '0 8px 0 0';
64
+ this.progressRing.style.display = 'none'; // Hidden by default
65
+ }
66
+ createLoadMoreButton() {
67
+ var _a, _b;
68
+ // Create the button with the appropriate design system prefix
69
+ this.loadMoreButton = document.createElement(`${this.designSystemPrefix}-button`);
70
+ this.loadMoreButton.setAttribute('data-test-id', 'grid-load-more-button');
71
+ // Set button appearance - use custom appearance if provided, otherwise default to 'outline'
72
+ const appearance = ((_a = this.params) === null || _a === void 0 ? void 0 : _a.appearance) || 'outline';
73
+ this.loadMoreButton.setAttribute('appearance', appearance);
74
+ // Set button label - use default
75
+ this.loadMoreButton.textContent = this.buttonLabel;
76
+ // Set button styles - improve sizing to match UI better
77
+ this.loadMoreButton.style.margin = '2px 8px';
78
+ this.loadMoreButton.style.minWidth = '120px';
79
+ this.loadMoreButton.style.textAlign = 'center';
80
+ this.loadMoreButton.style.height = '24px';
81
+ this.loadMoreButton.style.lineHeight = '20px';
82
+ // Add native tooltip if provided
83
+ if ((_b = this.params) === null || _b === void 0 ? void 0 : _b.tooltip) {
84
+ this.loadMoreButton.setAttribute('title', this.params.tooltip);
85
+ this.loadMoreButton.setAttribute('aria-describedby', 'grid-load-more-tooltip');
86
+ }
87
+ // Set initial ARIA attributes - use tooltip as aria-label if available, otherwise use default
88
+ this.updateAriaLabel();
89
+ this.loadMoreButton.setAttribute('role', 'button');
90
+ // Add event listener for the load more action
91
+ this.clickHandler = () => __awaiter(this, void 0, void 0, function* () {
92
+ if (this.isLoading)
93
+ return; // Prevent multiple clicks
94
+ try {
95
+ this.showLoading(true);
96
+ yield delay(LOADING_DELAY);
97
+ // Execute the load more action
98
+ if (this.params.onLoadMore) {
99
+ this.params.onLoadMore();
100
+ }
101
+ // After the action completes, hide the loading state
102
+ // this.showLoading(false);
103
+ }
104
+ catch (error) {
105
+ // In case of error, ensure loading state is hidden
106
+ this.showLoading(false);
107
+ }
108
+ });
109
+ this.loadMoreButton.addEventListener('click', this.clickHandler);
110
+ }
111
+ /**
112
+ * Update the aria-label based on current state and tooltip
113
+ */
114
+ updateAriaLabel() {
115
+ var _a, _b;
116
+ let ariaLabel;
117
+ if ((_a = this.params) === null || _a === void 0 ? void 0 : _a.tooltip) {
118
+ // Use tooltip as primary aria-label
119
+ ariaLabel = this.params.tooltip;
120
+ }
121
+ else {
122
+ // Fall back to descriptive labels based on state
123
+ if (this.isLoading) {
124
+ ariaLabel = 'Loading more data';
125
+ }
126
+ else if ((_b = this.params) === null || _b === void 0 ? void 0 : _b.moreRows) {
127
+ ariaLabel = 'Load more rows from server';
128
+ }
129
+ else {
130
+ ariaLabel = 'No more rows available';
131
+ }
132
+ }
133
+ this.loadMoreButton.setAttribute('aria-label', ariaLabel);
134
+ }
135
+ /**
136
+ * Show or hide the loading state
137
+ */
138
+ showLoading(loading) {
139
+ var _a;
140
+ this.isLoading = loading;
141
+ if (loading) {
142
+ // Show loading state
143
+ this.progressRing.style.display = 'inline-block';
144
+ this.loadMoreButton.setAttribute('disabled', 'true');
145
+ this.loadMoreButton.textContent = 'Loading...';
146
+ }
147
+ else {
148
+ // Hide loading state
149
+ this.progressRing.style.display = 'none';
150
+ // Reset button state based on moreRows parameter
151
+ if ((_a = this.params) === null || _a === void 0 ? void 0 : _a.moreRows) {
152
+ this.loadMoreButton.textContent = 'Load More';
153
+ this.loadMoreButton.removeAttribute('disabled');
154
+ }
155
+ else {
156
+ this.loadMoreButton.textContent = 'No More Rows';
157
+ this.loadMoreButton.setAttribute('disabled', 'true');
158
+ }
159
+ }
160
+ // Update aria-label to reflect current state
161
+ this.updateAriaLabel();
162
+ }
163
+ updateButtonVisibility() {
164
+ // If we don't have params or during loading, don't update
165
+ if (!this.params || this.isLoading) {
166
+ return;
167
+ }
168
+ // Reset loading state (safeguard)
169
+ this.progressRing.style.display = 'none';
170
+ // If we have more rows, enable the button
171
+ if (this.params.moreRows) {
172
+ this.loadMoreButton.style.display = 'inline-flex';
173
+ this.loadMoreButton.textContent = 'Load More';
174
+ this.loadMoreButton.removeAttribute('disabled');
175
+ }
176
+ else {
177
+ // No more rows available
178
+ this.loadMoreButton.style.display = 'inline-flex';
179
+ this.loadMoreButton.textContent = 'No More Rows';
180
+ this.loadMoreButton.setAttribute('disabled', 'true');
181
+ }
182
+ // Update aria-label to reflect current state
183
+ this.updateAriaLabel();
184
+ }
185
+ updateParams(params) {
186
+ var _a, _b;
187
+ const prevParams = this.params;
188
+ this.params = Object.assign(Object.assign({}, this.params), params);
189
+ // If tooltip changed, update the title attribute
190
+ if ((prevParams === null || prevParams === void 0 ? void 0 : prevParams.tooltip) !== ((_a = this.params) === null || _a === void 0 ? void 0 : _a.tooltip) && ((_b = this.params) === null || _b === void 0 ? void 0 : _b.tooltip)) {
191
+ this.loadMoreButton.setAttribute('title', this.params.tooltip);
192
+ }
193
+ // If we were loading, but got an update that says no more rows,
194
+ // we need to stop the loading state immediately
195
+ if (this.isLoading) {
196
+ this.showLoading(false);
197
+ }
198
+ this.updateButtonVisibility();
199
+ }
200
+ getGui() {
201
+ return this.element;
202
+ }
203
+ destroy() {
204
+ // Clean up event listeners
205
+ if (this.loadMoreButton && this.clickHandler) {
206
+ this.loadMoreButton.removeEventListener('click', this.clickHandler);
207
+ }
208
+ }
209
+ }
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Pagination Status Bar Component for AG Grid
3
+ * Displays pagination controls and information about current page and total rows
4
+ * @public
5
+ */
6
+ export class PaginationStatusBarComponent {
7
+ init(params) {
8
+ this.api = params.api;
9
+ this.eGui = document.createElement('div');
10
+ this.eGui.className = 'ag-status-panel';
11
+ this.eGui.setAttribute('data-test-id', 'grid-pagination-panel');
12
+ this.eGui.setAttribute('role', 'navigation');
13
+ this.eGui.setAttribute('aria-label', 'Pagination controls');
14
+ this.eGui.style.display = 'flex';
15
+ this.eGui.style.alignItems = 'center';
16
+ this.eGui.style.justifyContent = 'flex-end';
17
+ this.eGui.style.height = 'var(--ag-status-bar-height)';
18
+ this.createPaginationPanel();
19
+ // Initial update
20
+ this.updateDisplay();
21
+ // Listen to pagination changes
22
+ this.paginationChangedHandler = this.updateDisplay.bind(this);
23
+ this.api.addEventListener('paginationChanged', this.paginationChangedHandler);
24
+ }
25
+ getGui() {
26
+ return this.eGui;
27
+ }
28
+ createPaginationPanel() {
29
+ // Create the main pagination panel
30
+ this.paginationPanel = document.createElement('div');
31
+ this.paginationPanel.className = 'ag-paging-panel ag-unselectable';
32
+ this.paginationPanel.setAttribute('id', 'ag-pagination-clone');
33
+ this.paginationPanel.setAttribute('data-test-id', 'grid-pagination-controls');
34
+ // Row summary panel
35
+ this.paginationSummaryPanel = document.createElement('span');
36
+ this.paginationSummaryPanel.className = 'ag-paging-row-summary-panel';
37
+ this.paginationSummaryPanel.setAttribute('role', 'status');
38
+ this.paginationSummaryPanel.setAttribute('data-test-id', 'grid-pagination-summary');
39
+ this.paginationSummaryPanel.setAttribute('aria-label', 'Row count summary');
40
+ // First page button
41
+ this.firstPageButton = this.createPaginationButton('btFirst', 'ag-paging-button ag-disabled', 'First Page', true);
42
+ this.firstPageButton.setAttribute('data-test-id', 'grid-pagination-first');
43
+ // Previous page button
44
+ this.prevPageButton = this.createPaginationButton('btPrevious', 'ag-paging-button ag-disabled', 'Previous Page', true);
45
+ this.prevPageButton.setAttribute('data-test-id', 'grid-pagination-previous');
46
+ // Create the description panel
47
+ this.descriptionPanel = document.createElement('span');
48
+ this.descriptionPanel.className = 'ag-paging-description';
49
+ this.descriptionPanel.setAttribute('role', 'status');
50
+ this.descriptionPanel.setAttribute('data-test-id', 'grid-pagination-description');
51
+ this.descriptionPanel.setAttribute('aria-label', 'Current page information');
52
+ // Page information elements
53
+ this.pageStartDisplay = document.createElement('span');
54
+ this.pageStartDisplay.className = 'ag-paging-number';
55
+ this.pageStartDisplay.setAttribute('id', 'ag-pagination-clone-start-page');
56
+ this.pageStartDisplay.setAttribute('data-test-id', 'grid-pagination-page-label');
57
+ this.pageStartDisplay.textContent = 'Page';
58
+ this.pageNumberDisplay = document.createElement('span');
59
+ this.pageNumberDisplay.className = 'ag-paging-number';
60
+ this.pageNumberDisplay.setAttribute('id', 'ag-pagination-clone-start-page-number');
61
+ this.pageNumberDisplay.setAttribute('ref', 'lbCurrent');
62
+ this.pageNumberDisplay.setAttribute('data-test-id', 'grid-pagination-current-page');
63
+ this.pageNumberDisplay.setAttribute('aria-label', 'Current page number');
64
+ this.pageNumberDisplay.textContent = '1';
65
+ this.pageOfDisplay = document.createElement('span');
66
+ this.pageOfDisplay.className = 'ag-paging-number';
67
+ this.pageOfDisplay.setAttribute('id', 'ag-pagination-clone-of-page');
68
+ this.pageOfDisplay.setAttribute('data-test-id', 'grid-pagination-of-label');
69
+ this.pageOfDisplay.textContent = 'of';
70
+ this.pageNumberTotalDisplay = document.createElement('span');
71
+ this.pageNumberTotalDisplay.className = 'ag-paging-number';
72
+ this.pageNumberTotalDisplay.setAttribute('id', 'ag-pagination-clone-of-page-number');
73
+ this.pageNumberTotalDisplay.setAttribute('ref', 'lbTotal');
74
+ this.pageNumberTotalDisplay.setAttribute('data-test-id', 'grid-pagination-total-pages');
75
+ this.pageNumberTotalDisplay.setAttribute('aria-label', 'Total number of pages');
76
+ this.pageNumberTotalDisplay.textContent = '1';
77
+ // Next page button
78
+ this.nextPageButton = this.createPaginationButton('btNext', 'ag-paging-button', 'Next Page', false);
79
+ this.nextPageButton.setAttribute('data-test-id', 'grid-pagination-next');
80
+ // Last page button
81
+ this.lastPageButton = this.createPaginationButton('btLast', 'ag-paging-button', 'Last Page', false);
82
+ this.lastPageButton.setAttribute('data-test-id', 'grid-pagination-last');
83
+ // Assemble the description panel
84
+ this.descriptionPanel.appendChild(this.pageStartDisplay);
85
+ this.descriptionPanel.appendChild(document.createTextNode(' '));
86
+ this.descriptionPanel.appendChild(this.pageNumberDisplay);
87
+ this.descriptionPanel.appendChild(document.createTextNode(' '));
88
+ this.descriptionPanel.appendChild(this.pageOfDisplay);
89
+ this.descriptionPanel.appendChild(document.createTextNode(' '));
90
+ this.descriptionPanel.appendChild(this.pageNumberTotalDisplay);
91
+ // Assemble the pagination panel
92
+ this.paginationPanel.appendChild(this.paginationSummaryPanel);
93
+ this.paginationPanel.appendChild(this.firstPageButton);
94
+ this.paginationPanel.appendChild(this.prevPageButton);
95
+ this.paginationPanel.appendChild(this.descriptionPanel);
96
+ this.paginationPanel.appendChild(this.nextPageButton);
97
+ this.paginationPanel.appendChild(this.lastPageButton);
98
+ // Add to main container
99
+ this.eGui.appendChild(this.paginationPanel);
100
+ // Add event listeners with keyboard support
101
+ this.addPaginationEventListeners();
102
+ }
103
+ addPaginationEventListeners() {
104
+ // Click event listeners
105
+ this.firstPageButton.addEventListener('click', () => this.goToPage('first'));
106
+ this.prevPageButton.addEventListener('click', () => this.goToPage('previous'));
107
+ this.nextPageButton.addEventListener('click', () => this.goToPage('next'));
108
+ this.lastPageButton.addEventListener('click', () => this.goToPage('last'));
109
+ // Keyboard event listeners for accessibility
110
+ this.firstPageButton.addEventListener('keydown', (event) => {
111
+ if (event.key === 'Enter' || event.key === ' ') {
112
+ event.preventDefault();
113
+ this.goToPage('first');
114
+ }
115
+ });
116
+ this.prevPageButton.addEventListener('keydown', (event) => {
117
+ if (event.key === 'Enter' || event.key === ' ') {
118
+ event.preventDefault();
119
+ this.goToPage('previous');
120
+ }
121
+ });
122
+ this.nextPageButton.addEventListener('keydown', (event) => {
123
+ if (event.key === 'Enter' || event.key === ' ') {
124
+ event.preventDefault();
125
+ this.goToPage('next');
126
+ }
127
+ });
128
+ this.lastPageButton.addEventListener('keydown', (event) => {
129
+ if (event.key === 'Enter' || event.key === ' ') {
130
+ event.preventDefault();
131
+ this.goToPage('last');
132
+ }
133
+ });
134
+ }
135
+ createPaginationButton(ref, className, ariaLabel, disabled) {
136
+ const button = document.createElement('div');
137
+ button.setAttribute('ref', ref);
138
+ button.className = className;
139
+ button.setAttribute('role', 'button');
140
+ button.setAttribute('aria-label', ariaLabel);
141
+ button.setAttribute('tabindex', disabled ? '-1' : '0');
142
+ if (disabled) {
143
+ button.setAttribute('aria-disabled', 'true');
144
+ }
145
+ const iconSpan = document.createElement('span');
146
+ iconSpan.className = `ag-icon ag-icon-${ref.substring(2).toLowerCase()}`;
147
+ iconSpan.setAttribute('unselectable', 'on');
148
+ iconSpan.setAttribute('role', 'presentation');
149
+ button.appendChild(iconSpan);
150
+ return button;
151
+ }
152
+ goToPage(page) {
153
+ switch (page) {
154
+ case 'first':
155
+ this.api.paginationGoToFirstPage();
156
+ break;
157
+ case 'previous':
158
+ this.api.paginationGoToPreviousPage();
159
+ break;
160
+ case 'next':
161
+ this.api.paginationGoToNextPage();
162
+ break;
163
+ case 'last':
164
+ this.api.paginationGoToLastPage();
165
+ break;
166
+ }
167
+ }
168
+ updateDisplay() {
169
+ const currentPage = this.api.paginationGetCurrentPage() + 1; // 1-based for display
170
+ const totalPages = this.api.paginationGetTotalPages() || 1;
171
+ const pageSize = this.api.paginationGetPageSize();
172
+ const rowCount = this.api.paginationGetRowCount();
173
+ // Update the page numbers
174
+ this.pageNumberDisplay.textContent = currentPage.toString();
175
+ this.pageNumberTotalDisplay.textContent = totalPages.toString();
176
+ // Update the row summary panel
177
+ const startRow = (currentPage - 1) * pageSize + 1;
178
+ const endRow = Math.min(currentPage * pageSize, rowCount);
179
+ this.paginationSummaryPanel.textContent = `${rowCount > 0 ? startRow : 0} to ${endRow} of ${rowCount}`;
180
+ // Update button states
181
+ const isFirstPage = currentPage === 1;
182
+ const isLastPage = currentPage >= totalPages;
183
+ this.updateButtonState(this.firstPageButton, isFirstPage);
184
+ this.updateButtonState(this.prevPageButton, isFirstPage);
185
+ this.updateButtonState(this.nextPageButton, isLastPage);
186
+ this.updateButtonState(this.lastPageButton, isLastPage);
187
+ }
188
+ updateButtonState(button, disabled) {
189
+ if (disabled) {
190
+ button.classList.add('ag-disabled');
191
+ button.setAttribute('aria-disabled', 'true');
192
+ button.setAttribute('tabindex', '-1');
193
+ }
194
+ else {
195
+ button.classList.remove('ag-disabled');
196
+ button.setAttribute('aria-disabled', 'false');
197
+ button.setAttribute('tabindex', '0');
198
+ }
199
+ }
200
+ destroy() {
201
+ // Remove event listeners
202
+ if (this.api && this.paginationChangedHandler) {
203
+ this.api.removeEventListener('paginationChanged', this.paginationChangedHandler);
204
+ }
205
+ }
206
+ }
@@ -0,0 +1,162 @@
1
+ import { __awaiter } from "tslib";
2
+ import { delay, getCurrentDesignSystemPrefix } from '@genesislcap/foundation-utils';
3
+ // Delay in milliseconds to keep the icon in disabled state for visual feedback
4
+ const RELOAD_DELAY = 500;
5
+ /**
6
+ * A status bar component that shows a refresh icon to reload the grid data
7
+ * @public
8
+ */
9
+ export class ReloadStatusBarComponent {
10
+ constructor() {
11
+ this.isReloading = false;
12
+ }
13
+ init(params) {
14
+ this.params = params;
15
+ this.element = document.createElement('div');
16
+ this.element.classList.add('ag-status-panel', 'ag-reload-panel');
17
+ this.element.setAttribute('data-test-id', 'grid-reload-panel');
18
+ this.element.setAttribute('role', 'region');
19
+ this.element.setAttribute('aria-label', 'Reload data controls');
20
+ this.element.style.display = 'flex';
21
+ this.element.style.alignItems = 'center';
22
+ this.element.style.justifyContent = 'center';
23
+ this.element.style.paddingLeft = 'var(--ag-grid-size)';
24
+ this.element.style.height = 'var(--ag-status-bar-height)';
25
+ // Detect the current design system prefix (rapid or zero)
26
+ this.designSystemPrefix = getCurrentDesignSystemPrefix(this.element, 'zero');
27
+ this.createRefreshIcon();
28
+ this.createProgressRing();
29
+ // Initially show the icon, hide the progress ring
30
+ this.element.appendChild(this.refreshIcon);
31
+ this.element.appendChild(this.progressRing);
32
+ this.progressRing.style.display = 'none';
33
+ }
34
+ createProgressRing() {
35
+ // Create the progress ring with the appropriate design system prefix
36
+ this.progressRing = document.createElement(`${this.designSystemPrefix}-progress-ring`);
37
+ this.progressRing.setAttribute('data-test-id', 'grid-reload-progress');
38
+ this.progressRing.setAttribute('aria-label', 'Reloading data');
39
+ // Set styles for the progress ring
40
+ this.progressRing.style.width = '20px';
41
+ this.progressRing.style.height = '20px';
42
+ this.progressRing.style.margin = '4px';
43
+ this.progressRing.style.display = 'none'; // Hidden by default
44
+ }
45
+ createRefreshIcon() {
46
+ var _a, _b, _c, _d;
47
+ // For design systems that support icons
48
+ if (this.designSystemPrefix === 'zero' || this.designSystemPrefix === 'rapid') {
49
+ this.refreshIcon = document.createElement(`${this.designSystemPrefix}-icon`);
50
+ // Use custom icon if provided, otherwise default to 'refresh'
51
+ const iconName = ((_a = this.params) === null || _a === void 0 ? void 0 : _a.icon) || 'refresh';
52
+ this.refreshIcon.setAttribute('name', iconName);
53
+ this.refreshIcon.setAttribute('aria-label', ((_b = this.params) === null || _b === void 0 ? void 0 : _b.tooltip) || 'Reload grid data');
54
+ }
55
+ else {
56
+ // Fallback for systems without icon components
57
+ this.refreshIcon = document.createElement('div');
58
+ this.refreshIcon.textContent = '↻'; // Unicode refresh symbol
59
+ this.refreshIcon.setAttribute('aria-label', ((_c = this.params) === null || _c === void 0 ? void 0 : _c.tooltip) || 'Reload grid data');
60
+ }
61
+ // Add accessibility attributes
62
+ this.refreshIcon.setAttribute('data-test-id', 'grid-reload-button');
63
+ this.refreshIcon.setAttribute('role', 'button');
64
+ this.refreshIcon.setAttribute('tabindex', '0');
65
+ // Set common styles for the icon - make it larger
66
+ this.refreshIcon.style.cursor = 'pointer';
67
+ this.refreshIcon.style.width = '28px';
68
+ this.refreshIcon.style.height = '28px';
69
+ this.refreshIcon.style.display = 'flex';
70
+ this.refreshIcon.style.alignItems = 'center';
71
+ this.refreshIcon.style.justifyContent = 'center';
72
+ this.refreshIcon.style.fontSize = '20px'; // Increase text size for fallback icon
73
+ // Add native tooltip if provided
74
+ if ((_d = this.params) === null || _d === void 0 ? void 0 : _d.tooltip) {
75
+ this.refreshIcon.setAttribute('title', this.params.tooltip);
76
+ }
77
+ // Add hover effect
78
+ this.mouseoverHandler = () => {
79
+ if (!this.isReloading) {
80
+ this.refreshIcon.style.opacity = '0.7';
81
+ }
82
+ };
83
+ this.refreshIcon.addEventListener('mouseover', this.mouseoverHandler);
84
+ this.mouseoutHandler = () => {
85
+ if (!this.isReloading) {
86
+ this.refreshIcon.style.opacity = '1';
87
+ }
88
+ };
89
+ this.refreshIcon.addEventListener('mouseout', this.mouseoutHandler);
90
+ // Add click event listener
91
+ this.clickHandler = () => __awaiter(this, void 0, void 0, function* () {
92
+ if (this.isReloading)
93
+ return; // Prevent multiple clicks
94
+ try {
95
+ this.showReloading(true);
96
+ yield delay(RELOAD_DELAY);
97
+ // Execute the reload action if provided
98
+ if (this.params.onReload) {
99
+ this.params.onReload();
100
+ }
101
+ // Reset the icon state
102
+ this.showReloading(false);
103
+ }
104
+ catch (error) {
105
+ // In case of error, ensure icon state is reset
106
+ this.showReloading(false);
107
+ }
108
+ });
109
+ this.refreshIcon.addEventListener('click', this.clickHandler);
110
+ // Add keyboard support for accessibility
111
+ this.refreshIcon.addEventListener('keydown', (event) => {
112
+ if (event.key === 'Enter' || event.key === ' ') {
113
+ event.preventDefault();
114
+ // Trigger the same click handler
115
+ this.clickHandler(new MouseEvent('click'));
116
+ }
117
+ });
118
+ }
119
+ /**
120
+ * Show or hide the reloading state
121
+ */
122
+ showReloading(reloading) {
123
+ this.isReloading = reloading;
124
+ if (reloading) {
125
+ // Hide the icon and show the progress ring
126
+ this.refreshIcon.style.display = 'none';
127
+ this.progressRing.style.display = 'inline-block';
128
+ }
129
+ else {
130
+ // Show the icon and hide the progress ring
131
+ this.refreshIcon.style.display = 'inline-flex';
132
+ this.progressRing.style.display = 'none';
133
+ }
134
+ }
135
+ updateParams(params) {
136
+ var _a, _b;
137
+ const prevParams = this.params;
138
+ this.params = Object.assign(Object.assign({}, this.params), params);
139
+ // If tooltip changed, update the title attribute and aria-label
140
+ if ((prevParams === null || prevParams === void 0 ? void 0 : prevParams.tooltip) !== ((_a = this.params) === null || _a === void 0 ? void 0 : _a.tooltip)) {
141
+ if ((_b = this.params) === null || _b === void 0 ? void 0 : _b.tooltip) {
142
+ this.refreshIcon.setAttribute('title', this.params.tooltip);
143
+ this.refreshIcon.setAttribute('aria-label', this.params.tooltip);
144
+ }
145
+ else {
146
+ this.refreshIcon.removeAttribute('title');
147
+ this.refreshIcon.setAttribute('aria-label', 'Reload grid data');
148
+ }
149
+ }
150
+ }
151
+ getGui() {
152
+ return this.element;
153
+ }
154
+ destroy() {
155
+ // Clean up event listeners
156
+ if (this.refreshIcon) {
157
+ this.refreshIcon.removeEventListener('mouseover', this.mouseoverHandler);
158
+ this.refreshIcon.removeEventListener('mouseout', this.mouseoutHandler);
159
+ this.refreshIcon.removeEventListener('click', this.clickHandler);
160
+ }
161
+ }
162
+ }