@highcharts/grid-pro 2.2.0 → 2.3.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 (266) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +15 -9
  3. package/css/grid-pro.css +1262 -1122
  4. package/css/modules/grid-base-variables.css +131 -0
  5. package/css/modules/grid-button-variables.css +140 -0
  6. package/css/modules/grid-caption-variables.css +11 -0
  7. package/css/modules/grid-description-variables.css +11 -0
  8. package/css/modules/grid-input-variables.css +114 -0
  9. package/css/modules/grid-link-variables.css +18 -0
  10. package/css/modules/grid-menu-variables.css +50 -0
  11. package/css/modules/grid-pagination-variables.css +12 -0
  12. package/css/modules/grid-popup-variables.css +24 -0
  13. package/css/modules/grid-pro.css +234 -0
  14. package/css/modules/grid-table-variables.css +385 -0
  15. package/css/modules/grid-theme-default.css +55 -0
  16. package/es-modules/Accessibility/A11yI18n.js +1 -2
  17. package/es-modules/Accessibility/Accessibility.js +1 -2
  18. package/es-modules/Accessibility/AccessibilityComponent.d.ts +2 -2
  19. package/es-modules/Accessibility/Components/InfoRegionsComponent.js +5 -6
  20. package/es-modules/Accessibility/Components/LegendComponent.js +1 -2
  21. package/es-modules/Accessibility/Components/MenuComponent.js +1 -2
  22. package/es-modules/Accessibility/Components/NavigatorComponent.js +3 -4
  23. package/es-modules/Accessibility/Components/RangeSelectorComponent.js +1 -2
  24. package/es-modules/Accessibility/Components/SeriesComponent/ForcedMarkers.js +1 -2
  25. package/es-modules/Accessibility/Components/SeriesComponent/NewDataAnnouncer.js +3 -4
  26. package/es-modules/Accessibility/Components/SeriesComponent/SeriesDescriber.js +3 -4
  27. package/es-modules/Accessibility/Components/SeriesComponent/SeriesKeyboardNavigation.js +1 -2
  28. package/es-modules/Accessibility/Components/ZoomComponent.js +1 -2
  29. package/es-modules/Accessibility/FocusBorder.js +1 -2
  30. package/es-modules/Accessibility/KeyboardNavigation.js +1 -2
  31. package/es-modules/Accessibility/KeyboardNavigationHandler.js +1 -2
  32. package/es-modules/Accessibility/Options/A11yDefaults.d.ts +11 -0
  33. package/es-modules/Accessibility/Options/A11yDefaults.js +11 -0
  34. package/es-modules/Accessibility/Options/DeprecatedOptions.d.ts +58 -0
  35. package/es-modules/Accessibility/Options/DeprecatedOptions.js +7 -2
  36. package/es-modules/Accessibility/Options/LangDefaults.js +9 -0
  37. package/es-modules/Accessibility/ProxyElement.js +2 -5
  38. package/es-modules/Accessibility/ProxyProvider.js +1 -2
  39. package/es-modules/Accessibility/Utils/Announcer.js +2 -3
  40. package/es-modules/Accessibility/Utils/ChartUtilities.js +1 -2
  41. package/es-modules/Accessibility/Utils/EventProvider.d.ts +2 -2
  42. package/es-modules/Accessibility/Utils/EventProvider.js +6 -2
  43. package/es-modules/Accessibility/Utils/HTMLUtilities.js +1 -2
  44. package/es-modules/Core/Animation/AnimationUtilities.js +1 -2
  45. package/es-modules/Core/Animation/Fx.js +1 -2
  46. package/es-modules/Core/Callback.d.ts +9 -2
  47. package/es-modules/Core/Chart/Chart.js +48 -41
  48. package/es-modules/Core/Chart/Chart3D.js +1 -2
  49. package/es-modules/Core/Chart/ChartDefaults.js +11 -0
  50. package/es-modules/Core/Chart/ChartOptions.d.ts +8 -0
  51. package/es-modules/Core/Chart/GanttChart.js +1 -2
  52. package/es-modules/Core/Chart/MapChart.js +1 -2
  53. package/es-modules/Core/Chart/StockChart.js +2 -3
  54. package/es-modules/Core/Color/Color.js +1 -2
  55. package/es-modules/Core/Defaults.js +36 -9
  56. package/es-modules/Core/Delaunay.d.ts +52 -0
  57. package/es-modules/Core/Delaunay.js +310 -0
  58. package/es-modules/Core/Foundation.js +1 -2
  59. package/es-modules/Core/Geometry/CircleUtilities.js +1 -2
  60. package/es-modules/Core/Globals.js +1 -1
  61. package/es-modules/Core/HttpUtilities.js +1 -2
  62. package/es-modules/Core/MSPointer.js +1 -2
  63. package/es-modules/Core/Math3D.js +1 -2
  64. package/es-modules/Core/Options.d.ts +6 -2
  65. package/es-modules/Core/Pointer.js +23 -4
  66. package/es-modules/Core/PointerEvent.d.ts +2 -0
  67. package/es-modules/Core/Renderer/HTML/AST.js +2 -2
  68. package/es-modules/Core/Renderer/HTML/HTMLElement.js +1 -2
  69. package/es-modules/Core/Renderer/RendererUtilities.js +34 -19
  70. package/es-modules/Core/Responsive.d.ts +4 -2
  71. package/es-modules/Core/Responsive.js +10 -4
  72. package/es-modules/Core/Templating.d.ts +1 -1
  73. package/es-modules/Core/Templating.js +3 -4
  74. package/es-modules/Core/Time.d.ts +8 -0
  75. package/es-modules/Core/Time.js +2 -2
  76. package/es-modules/Core/Tooltip.d.ts +4 -8
  77. package/es-modules/Core/Tooltip.js +100 -81
  78. package/es-modules/Core/TooltipOptions.d.ts +44 -1
  79. package/es-modules/Core/Utilities.d.ts +25 -665
  80. package/es-modules/Core/Utilities.js +17 -1398
  81. package/es-modules/Data/ColumnUtils.d.ts +83 -80
  82. package/es-modules/Data/ColumnUtils.js +103 -113
  83. package/es-modules/Data/Connectors/CSVConnector.d.ts +9 -14
  84. package/es-modules/Data/Connectors/CSVConnector.js +3 -4
  85. package/es-modules/Data/Connectors/DataConnector.d.ts +52 -54
  86. package/es-modules/Data/Connectors/DataConnector.js +33 -52
  87. package/es-modules/Data/Connectors/GoogleSheetsConnector.d.ts +40 -42
  88. package/es-modules/Data/Connectors/GoogleSheetsConnector.js +73 -88
  89. package/es-modules/Data/Connectors/GoogleSheetsConnectorOptions.d.ts +4 -2
  90. package/es-modules/Data/Connectors/HTMLTableConnector.d.ts +23 -28
  91. package/es-modules/Data/Connectors/HTMLTableConnector.js +3 -4
  92. package/es-modules/Data/Connectors/JSONConnector.d.ts +9 -14
  93. package/es-modules/Data/Connectors/JSONConnector.js +3 -4
  94. package/es-modules/Data/Converters/CSVConverter.d.ts +5 -5
  95. package/es-modules/Data/Converters/CSVConverter.js +3 -4
  96. package/es-modules/Data/Converters/CSVConverterOptions.d.ts +2 -2
  97. package/es-modules/Data/Converters/DataConverter.d.ts +76 -78
  98. package/es-modules/Data/Converters/DataConverter.js +26 -53
  99. package/es-modules/Data/Converters/DataConverterUtils.d.ts +88 -81
  100. package/es-modules/Data/Converters/DataConverterUtils.js +169 -181
  101. package/es-modules/Data/Converters/GoogleSheetsConverter.d.ts +4 -4
  102. package/es-modules/Data/Converters/GoogleSheetsConverter.js +3 -3
  103. package/es-modules/Data/Converters/GoogleSheetsConverterOptions.d.ts +2 -2
  104. package/es-modules/Data/Converters/HTMLTableConverter.d.ts +4 -4
  105. package/es-modules/Data/Converters/HTMLTableConverter.js +2 -3
  106. package/es-modules/Data/Converters/HTMLTableConverterOptions.d.ts +2 -2
  107. package/es-modules/Data/Converters/JSONConverter.d.ts +7 -7
  108. package/es-modules/Data/Converters/JSONConverter.js +6 -6
  109. package/es-modules/Data/Converters/JSONConverterOptions.d.ts +2 -2
  110. package/es-modules/Data/DataCursor.d.ts +65 -70
  111. package/es-modules/Data/DataCursor.js +119 -139
  112. package/es-modules/Data/DataEvent.d.ts +55 -57
  113. package/es-modules/Data/DataPool.d.ts +10 -17
  114. package/es-modules/Data/DataPool.js +20 -9
  115. package/es-modules/Data/DataTable.d.ts +111 -113
  116. package/es-modules/Data/DataTable.js +3 -3
  117. package/es-modules/Data/DataTableCore.d.ts +9 -9
  118. package/es-modules/Data/DataTableCore.js +2 -2
  119. package/es-modules/Data/Formula/FormulaParser.js +1 -2
  120. package/es-modules/Data/Formula/FormulaProcessor.js +1 -2
  121. package/es-modules/Data/Modifiers/ChainModifier.d.ts +29 -34
  122. package/es-modules/Data/Modifiers/ChainModifier.js +7 -8
  123. package/es-modules/Data/Modifiers/DataModifier.d.ts +36 -41
  124. package/es-modules/Data/Modifiers/DataModifier.js +31 -53
  125. package/es-modules/Data/Modifiers/FilterModifier.d.ts +4 -4
  126. package/es-modules/Data/Modifiers/FilterModifier.js +3 -4
  127. package/es-modules/Data/Modifiers/FilterModifierOptions.d.ts +3 -2
  128. package/es-modules/Data/Modifiers/InvertModifier.d.ts +4 -4
  129. package/es-modules/Data/Modifiers/InvertModifier.js +3 -4
  130. package/es-modules/Data/Modifiers/MathModifier.d.ts +5 -4
  131. package/es-modules/Data/Modifiers/RangeModifier.d.ts +4 -4
  132. package/es-modules/Data/Modifiers/RangeModifier.js +3 -4
  133. package/es-modules/Data/Modifiers/SortModifier.d.ts +6 -11
  134. package/es-modules/Data/Modifiers/SortModifier.js +3 -4
  135. package/es-modules/Data/Modifiers/SortModifierOptions.d.ts +3 -3
  136. package/es-modules/Grid/Core/Accessibility/Accessibility.d.ts +1 -1
  137. package/es-modules/Grid/Core/Accessibility/Accessibility.js +5 -6
  138. package/es-modules/Grid/Core/Data/DataProvider.d.ts +97 -0
  139. package/es-modules/Grid/Core/Data/DataProvider.js +89 -0
  140. package/es-modules/Grid/Core/Data/DataProviderRegistry.d.ts +20 -0
  141. package/es-modules/Grid/Core/Data/DataProviderRegistry.js +52 -0
  142. package/es-modules/Grid/Core/Data/DataProviderType.d.ts +19 -0
  143. package/es-modules/Grid/Core/Data/DataProviderType.js +15 -0
  144. package/es-modules/Grid/Core/Data/LocalDataProvider.d.ts +165 -0
  145. package/es-modules/Grid/Core/Data/LocalDataProvider.js +341 -0
  146. package/es-modules/Grid/Core/Defaults.js +4 -2
  147. package/es-modules/Grid/Core/Globals.d.ts +20 -16
  148. package/es-modules/Grid/Core/Globals.js +10 -8
  149. package/es-modules/Grid/Core/Grid.d.ts +31 -22
  150. package/es-modules/Grid/Core/Grid.js +214 -136
  151. package/es-modules/Grid/Core/GridUtils.d.ts +33 -0
  152. package/es-modules/Grid/Core/GridUtils.js +50 -3
  153. package/es-modules/Grid/Core/Options.d.ts +145 -4
  154. package/es-modules/Grid/Core/Pagination/Pagination.d.ts +3 -0
  155. package/es-modules/Grid/Core/Pagination/Pagination.js +63 -23
  156. package/es-modules/Grid/Core/Pagination/PaginationOptions.d.ts +4 -0
  157. package/es-modules/Grid/Core/Querying/FilteringController.js +1 -2
  158. package/es-modules/Grid/Core/Querying/PaginationController.d.ts +2 -2
  159. package/es-modules/Grid/Core/Querying/PaginationController.js +3 -3
  160. package/es-modules/Grid/Core/Querying/QueryingController.d.ts +1 -1
  161. package/es-modules/Grid/Core/Querying/QueryingController.js +2 -26
  162. package/es-modules/Grid/Core/Responsive/ResponsiveComposition.d.ts +53 -0
  163. package/es-modules/Grid/Core/Responsive/ResponsiveComposition.js +229 -0
  164. package/es-modules/Grid/Core/Responsive/ResponsiveOptions.d.ts +58 -0
  165. package/es-modules/Grid/Core/Responsive/ResponsiveOptions.js +15 -0
  166. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/ColumnFiltering.js +2 -3
  167. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterCell.d.ts +1 -1
  168. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterCell.js +3 -4
  169. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterRow.d.ts +1 -1
  170. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterRow.js +2 -2
  171. package/es-modules/Grid/Core/Table/Actions/ColumnSorting.d.ts +17 -1
  172. package/es-modules/Grid/Core/Table/Actions/ColumnSorting.js +58 -15
  173. package/es-modules/Grid/Core/Table/Actions/ColumnsResizer.js +1 -3
  174. package/es-modules/Grid/Core/Table/Actions/RowsVirtualizer.d.ts +57 -3
  175. package/es-modules/Grid/Core/Table/Actions/RowsVirtualizer.js +397 -118
  176. package/es-modules/Grid/Core/Table/Body/CellContextMenu.d.ts +11 -0
  177. package/es-modules/Grid/Core/Table/Body/CellContextMenu.js +84 -0
  178. package/es-modules/Grid/Core/Table/Body/TableCell.d.ts +27 -13
  179. package/es-modules/Grid/Core/Table/Body/TableCell.js +74 -25
  180. package/es-modules/Grid/Core/Table/Body/TableRow.d.ts +7 -15
  181. package/es-modules/Grid/Core/Table/Body/TableRow.js +24 -19
  182. package/es-modules/Grid/Core/Table/Cell.d.ts +16 -3
  183. package/es-modules/Grid/Core/Table/Cell.js +36 -3
  184. package/es-modules/Grid/Core/Table/CellContent/TextContent.js +3 -8
  185. package/es-modules/Grid/Core/Table/Column.d.ts +10 -4
  186. package/es-modules/Grid/Core/Table/Column.js +23 -34
  187. package/es-modules/Grid/Core/Table/ColumnResizing/IndependentResizingMode.js +9 -8
  188. package/es-modules/Grid/Core/Table/ColumnResizing/ResizingMode.js +4 -3
  189. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ColumnToolbar.d.ts +5 -0
  190. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ColumnToolbar.js +7 -2
  191. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/FilterPopup.js +1 -2
  192. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/MenuButtons/FilterMenuButton.js +1 -2
  193. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/MenuButtons/SortMenuButton.js +2 -3
  194. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/FilterToolbarButton.js +1 -2
  195. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/MenuToolbarButton.js +1 -2
  196. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/SortToolbarButton.d.ts +0 -1
  197. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/SortToolbarButton.js +4 -14
  198. package/es-modules/Grid/Core/Table/Header/HeaderCell.d.ts +6 -1
  199. package/es-modules/Grid/Core/Table/Header/HeaderCell.js +33 -13
  200. package/es-modules/Grid/Core/Table/Header/HeaderRow.js +4 -5
  201. package/es-modules/Grid/Core/Table/Header/TableHeader.d.ts +1 -1
  202. package/es-modules/Grid/Core/Table/Header/TableHeader.js +3 -3
  203. package/es-modules/Grid/Core/Table/Row.d.ts +1 -1
  204. package/es-modules/Grid/Core/Table/Row.js +2 -2
  205. package/es-modules/Grid/Core/Table/Table.d.ts +38 -12
  206. package/es-modules/Grid/Core/Table/Table.js +184 -91
  207. package/es-modules/Grid/Core/UI/ContextMenuButton.d.ts +6 -7
  208. package/es-modules/Grid/Core/UI/ContextMenuButton.js +5 -3
  209. package/es-modules/Grid/Core/UI/Popup.js +7 -9
  210. package/es-modules/Grid/Core/UI/SvgIcons.d.ts +42 -7
  211. package/es-modules/Grid/Core/UI/SvgIcons.js +206 -33
  212. package/es-modules/Grid/Core/UI/Toolbar.d.ts +5 -0
  213. package/es-modules/Grid/Core/UI/ToolbarButton.d.ts +4 -12
  214. package/es-modules/Grid/Core/UI/ToolbarButton.js +8 -26
  215. package/es-modules/Grid/Pro/CellEditing/CellEditMode.d.ts +2 -2
  216. package/es-modules/Grid/Pro/CellEditing/CellEditing.js +10 -10
  217. package/es-modules/Grid/Pro/CellEditing/CellEditingComposition.js +1 -2
  218. package/es-modules/Grid/Pro/CellRendering/CellRenderersComposition.d.ts +1 -1
  219. package/es-modules/Grid/Pro/CellRendering/CellRenderersComposition.js +4 -2
  220. package/es-modules/Grid/Pro/CellRendering/ContentTypes/CheckboxContent.d.ts +2 -2
  221. package/es-modules/Grid/Pro/CellRendering/ContentTypes/NumberInputContent.js +1 -2
  222. package/es-modules/Grid/Pro/CellRendering/ContentTypes/SelectContent.d.ts +2 -2
  223. package/es-modules/Grid/Pro/CellRendering/ContentTypes/SparklineContent.js +1 -2
  224. package/es-modules/Grid/Pro/CellRendering/ContentTypes/TextInputContent.d.ts +2 -2
  225. package/es-modules/Grid/Pro/CellRendering/ContentTypes/TextInputContent.js +1 -2
  226. package/es-modules/Grid/Pro/CellRendering/Renderers/CheckboxRenderer.js +1 -2
  227. package/es-modules/Grid/Pro/CellRendering/Renderers/DateInputRenderer.js +1 -2
  228. package/es-modules/Grid/Pro/CellRendering/Renderers/DateTimeInputRenderer.js +1 -2
  229. package/es-modules/Grid/Pro/CellRendering/Renderers/NumberInputRenderer.js +1 -2
  230. package/es-modules/Grid/Pro/CellRendering/Renderers/SelectRenderer.js +1 -2
  231. package/es-modules/Grid/Pro/CellRendering/Renderers/SparklineRenderer.d.ts +2 -2
  232. package/es-modules/Grid/Pro/CellRendering/Renderers/SparklineRenderer.js +1 -2
  233. package/es-modules/Grid/Pro/CellRendering/Renderers/TextInputRenderer.js +1 -2
  234. package/es-modules/Grid/Pro/CellRendering/Renderers/TextRenderer.js +1 -2
  235. package/es-modules/Grid/Pro/CellRendering/Renderers/TimeInputRenderer.js +1 -2
  236. package/es-modules/Grid/Pro/ColumnTypes/Validator.js +34 -32
  237. package/es-modules/Grid/Pro/ColumnTypes/ValidatorComposition.d.ts +1 -1
  238. package/es-modules/Grid/Pro/ColumnTypes/ValidatorComposition.js +3 -4
  239. package/es-modules/Grid/Pro/Credits/CreditsProComposition.js +1 -3
  240. package/es-modules/Grid/Pro/Data/DataSourceHelper.d.ts +74 -0
  241. package/es-modules/Grid/Pro/Data/DataSourceHelper.js +246 -0
  242. package/es-modules/Grid/Pro/Data/QuerySerializer.d.ts +46 -0
  243. package/es-modules/Grid/Pro/Data/QuerySerializer.js +169 -0
  244. package/es-modules/Grid/Pro/Data/RemoteDataProvider.d.ts +187 -0
  245. package/es-modules/Grid/Pro/Data/RemoteDataProvider.js +500 -0
  246. package/es-modules/Grid/Pro/Export/Exporting.js +1 -2
  247. package/es-modules/Grid/Pro/Export/ExportingComposition.js +1 -2
  248. package/es-modules/Grid/Pro/GridEvents.js +1 -2
  249. package/es-modules/Grid/Pro/Pagination/PaginationComposition.d.ts +0 -1
  250. package/es-modules/Grid/Pro/Pagination/PaginationComposition.js +1 -2
  251. package/es-modules/Shared/BaseForm.js +1 -2
  252. package/es-modules/Shared/DownloadURL.js +1 -2
  253. package/es-modules/Shared/TimeBase.js +3 -3
  254. package/es-modules/Shared/Types.d.ts +7 -0
  255. package/es-modules/Shared/Utilities.d.ts +576 -0
  256. package/es-modules/Shared/Utilities.js +1368 -0
  257. package/es-modules/masters/grid-pro.src.d.ts +15 -11
  258. package/es-modules/masters/grid-pro.src.js +12 -5
  259. package/grid-pro.d.ts +15 -11
  260. package/grid-pro.js +3 -3
  261. package/grid-pro.js.map +1 -1
  262. package/grid-pro.src.d.ts +15 -11
  263. package/grid-pro.src.js +10408 -8009
  264. package/package.json +1 -1
  265. package/es-modules/Grid/Core/Pagination/Icons.d.ts +0 -7
  266. package/es-modules/Grid/Core/Pagination/Icons.js +0 -7
@@ -16,17 +16,17 @@
16
16
  'use strict';
17
17
  import Accessibility from './Accessibility/Accessibility.js';
18
18
  import AST from '../../Core/Renderer/HTML/AST.js';
19
- import { defaultOptions } from './Defaults.js';
20
- import GridUtils from './GridUtils.js';
19
+ import DataProviderRegistry from './Data/DataProviderRegistry.js';
21
20
  import DataTable from '../../Data/DataTable.js';
21
+ import { defaultOptions } from './Defaults.js';
22
+ import { makeHTMLElement, setHTMLContent, createOptionsProxy } from './GridUtils.js';
22
23
  import Table from './Table/Table.js';
23
- import U from '../../Core/Utilities.js';
24
24
  import QueryingController from './Querying/QueryingController.js';
25
25
  import Globals from './Globals.js';
26
26
  import TimeBase from '../../Shared/TimeBase.js';
27
27
  import Pagination from './Pagination/Pagination.js';
28
- const { makeHTMLElement, setHTMLContent, createOptionsProxy } = GridUtils;
29
- const { defined, diffObjects, extend, fireEvent, merge, pick } = U;
28
+ import { defined, diffObjects, extend, fireEvent, merge, pick } from '../../Shared/Utilities.js';
29
+ import { uniqueKey } from '../../Core/Utilities.js';
30
30
  /* *
31
31
  *
32
32
  * Class
@@ -85,11 +85,6 @@ export class Grid {
85
85
  * The list of currently shown popups.
86
86
  */
87
87
  this.popups = new Set();
88
- /**
89
- * Functions that unregister events attached to the grid's data table,
90
- * that need to be removed when the grid is destroyed.
91
- */
92
- this.dataTableEventDestructors = [];
93
88
  /**
94
89
  * Whether the Grid is rendered.
95
90
  */
@@ -100,9 +95,16 @@ export class Grid {
100
95
  * @internal
101
96
  */
102
97
  this.dirtyFlags = new Set();
98
+ /**
99
+ * Internal redraw queue used to prevent concurrent `redraw()` calls from
100
+ * interleaving async DOM work and corrupting the state (for example
101
+ * rendering duplicate pagination controls when `update()` is called
102
+ * multiple times without awaiting).
103
+ */
104
+ this.redrawQueue = Promise.resolve();
103
105
  this.renderTo = renderTo;
104
106
  this.loadUserOptions(options);
105
- this.id = this.options?.id || U.uniqueKey();
107
+ this.id = this.options?.id || uniqueKey();
106
108
  this.querying = new QueryingController(this);
107
109
  this.locale = this.options?.lang?.locale || (this.container?.closest('[lang]')?.lang);
108
110
  this.time = new TimeBase(extend(this.options?.time, { locale: this.locale }), this.options?.lang);
@@ -118,6 +120,31 @@ export class Grid {
118
120
  * Methods
119
121
  *
120
122
  * */
123
+ /**
124
+ * The data source of the Grid. It contains the original data table
125
+ * that was passed to the Grid.
126
+ *
127
+ * @deprecated Use `dataProvider` instead.
128
+ */
129
+ get dataTable() {
130
+ const dp = this.dataProvider;
131
+ if (dp && 'getDataTable' in dp) {
132
+ return dp.getDataTable();
133
+ }
134
+ }
135
+ /**
136
+ * The presentation table of the Grid. It contains a modified version
137
+ * of the data table that is used for rendering the Grid content. If
138
+ * not modified, just a reference to the original data table.
139
+ *
140
+ * @deprecated Use `dataProvider` instead.
141
+ */
142
+ get presentationTable() {
143
+ const dp = this.dataProvider;
144
+ if (dp && 'getDataTable' in dp) {
145
+ return dp.getDataTable(true);
146
+ }
147
+ }
121
148
  /*
122
149
  * Initializes the accessibility controller.
123
150
  */
@@ -333,7 +360,7 @@ export class Grid {
333
360
  * the ones that are currently defined in the user options. When `true`,
334
361
  * the columns not defined in the new options will be removed.
335
362
  */
336
- async update(options = {}, redraw = true, oneToOne = false) {
363
+ update(options = {}, redraw = true, oneToOne = false) {
337
364
  fireEvent(this, 'beforeUpdate', {
338
365
  scope: 'grid',
339
366
  options,
@@ -344,20 +371,28 @@ export class Grid {
344
371
  const diff = this.loadUserOptions(options, oneToOne);
345
372
  const flags = this.dirtyFlags;
346
373
  if (viewport) {
347
- if (!this.dataTable || 'dataTable' in diff) {
348
- this.userOptions.dataTable = options.dataTable;
349
- (this.options ?? {}).dataTable = options.dataTable;
350
- this.loadDataTable();
351
- // TODO: Sometimes it can be too much, so we need to check if
352
- // the columns have changed or just their data. If just their
353
- // data, we can just mark the grid.table as dirty instead of the
354
- // whole grid.
374
+ if (!this.dataProvider ||
375
+ ('data' in diff) ||
376
+ ('dataTable' in diff)) {
377
+ if ( // Handle backward compatibility
378
+ diff.dataTable &&
379
+ this.options?.dataTable &&
380
+ this.options?.data?.providerType === 'local') {
381
+ const userDT = this.options.dataTable;
382
+ this.options.data.dataTable = 'clone' in userDT ?
383
+ userDT : new DataTable(userDT);
384
+ }
385
+ this.loadDataProvider(); // Rebuild the data provider
386
+ // TODO(update): Sometimes it can be too much, so we need to
387
+ // check if the columns have changed or just their data. If
388
+ // just their data, we can just mark the grid.table as dirty
389
+ // instead of the whole grid.
355
390
  flags.add('grid');
356
391
  }
357
392
  if ('columns' in diff) {
358
393
  const ids = Object.keys(diff.columns ?? {});
359
394
  for (const id of ids) {
360
- // TODO: Move this to the column update method.
395
+ // TODO(update): Move this to the column update method.
361
396
  this.loadColumnOptionDiffs(viewport, id, diff.columns?.[id]);
362
397
  delete diff.columns?.[id];
363
398
  }
@@ -374,7 +409,7 @@ export class Grid {
374
409
  this.time.update({ locale: this.locale });
375
410
  }
376
411
  delete langDiff.locale;
377
- // TODO: Add more lang diff checks here.
412
+ // TODO(update): Add more lang diff checks here.
378
413
  if (Object.keys(langDiff).length > 0) {
379
414
  flags.add('grid');
380
415
  }
@@ -394,7 +429,7 @@ export class Grid {
394
429
  this.pagination?.update(paginationDiff);
395
430
  }
396
431
  delete diff.pagination;
397
- // TODO: Add more options that can be optimized here.
432
+ // TODO(update): Add more options that can be optimized here.
398
433
  if (Object.keys(diff).length > 0) {
399
434
  flags.add('grid');
400
435
  }
@@ -402,15 +437,18 @@ export class Grid {
402
437
  else {
403
438
  flags.add('grid');
404
439
  }
440
+ const finish = () => {
441
+ fireEvent(this, 'afterUpdate', {
442
+ scope: 'grid',
443
+ options,
444
+ redraw,
445
+ oneToOne
446
+ });
447
+ };
405
448
  if (redraw) {
406
- await this.redraw();
449
+ return this.redraw().then(finish);
407
450
  }
408
- fireEvent(this, 'afterUpdate', {
409
- scope: 'grid',
410
- options,
411
- redraw,
412
- oneToOne
413
- });
451
+ finish();
414
452
  }
415
453
  /**
416
454
  * Loads the column option diffs by updating the dirty flags.
@@ -442,8 +480,7 @@ export class Grid {
442
480
  const cellsDiff = columnDiff.cells ?? {};
443
481
  if ('format' in cellsDiff ||
444
482
  'formatter' in cellsDiff ||
445
- 'className' in cellsDiff // TODO: check if this too
446
- ) {
483
+ 'className' in cellsDiff) {
447
484
  // Optimization idea: list of columns to update
448
485
  flags.add('rows');
449
486
  }
@@ -467,6 +504,7 @@ export class Grid {
467
504
  }
468
505
  delete sortingDiff.compare;
469
506
  delete sortingDiff.order;
507
+ delete sortingDiff.orderSequence;
470
508
  // Idea: sortable - redraw only header cell
471
509
  if (Object.keys(sortingDiff).length > 0) {
472
510
  flags.add('grid');
@@ -496,52 +534,64 @@ export class Grid {
496
534
  * them minimizing the number of DOM operations.
497
535
  */
498
536
  async redraw() {
499
- fireEvent(this, 'beforeRedraw');
500
- const flags = this.dirtyFlags;
501
- if (flags.has('grid')) {
502
- await this.render();
503
- fireEvent(this, 'afterRedraw');
504
- return;
505
- }
506
- const { viewport: vp, pagination } = this;
507
- const colResizing = vp?.columnResizing;
508
- if (flags.has('sorting') ||
509
- flags.has('filtering') ||
510
- pagination?.isDirtyQuerying) {
511
- this.querying.loadOptions();
512
- }
513
- if (colResizing?.isDirty) {
514
- colResizing.loadColumns();
515
- }
516
- if (flags.has('rows') ||
517
- flags.has('sorting') ||
518
- flags.has('filtering') ||
519
- pagination?.isDirtyQuerying) {
520
- await vp?.updateRows();
521
- }
522
- else if (flags.has('reflow') ||
523
- colResizing?.isDirty) {
524
- vp?.reflow();
525
- }
526
- const columns = vp?.columns ?? [];
527
- if (flags.has('sorting') ||
528
- flags.has('filtering')) {
529
- for (const column of columns) {
530
- column.header?.toolbar?.refreshState();
537
+ const run = async () => {
538
+ fireEvent(this, 'beforeRedraw');
539
+ const flags = this.dirtyFlags;
540
+ const flagsToProcess = new Set(flags);
541
+ const { viewport: vp, pagination } = this;
542
+ const colResizing = vp?.columnResizing;
543
+ const paginationWasDirty = !!pagination?.isDirtyQuerying;
544
+ const colResizingWasDirty = !!colResizing?.isDirty;
545
+ if (flagsToProcess.has('grid')) {
546
+ await this.render(false);
547
+ for (const flag of flagsToProcess) {
548
+ flags.delete(flag);
549
+ }
550
+ fireEvent(this, 'afterRedraw');
551
+ return;
531
552
  }
532
- }
533
- if (flags.has('filtering')) {
534
- for (const column of columns) {
535
- column.filtering?.refreshState();
553
+ await this.dataProvider?.init();
554
+ if (flagsToProcess.has('sorting') ||
555
+ flagsToProcess.has('filtering') ||
556
+ paginationWasDirty) {
557
+ this.querying.loadOptions();
536
558
  }
537
- }
538
- if (pagination?.isDirtyQuerying) {
539
- pagination.updateControls(true);
540
- }
541
- delete pagination?.isDirtyQuerying;
542
- delete colResizing?.isDirty;
543
- flags.clear();
544
- fireEvent(this, 'afterRedraw');
559
+ if (colResizingWasDirty) {
560
+ colResizing?.loadColumns();
561
+ }
562
+ if (flagsToProcess.has('rows') ||
563
+ flagsToProcess.has('sorting') ||
564
+ flagsToProcess.has('filtering') ||
565
+ paginationWasDirty) {
566
+ await vp?.updateRows();
567
+ }
568
+ else if (flagsToProcess.has('reflow') ||
569
+ colResizingWasDirty) {
570
+ vp?.reflow();
571
+ }
572
+ const columns = vp?.columns ?? [];
573
+ if (flagsToProcess.has('sorting') ||
574
+ flagsToProcess.has('filtering')) {
575
+ for (const column of columns) {
576
+ column.header?.toolbar?.refreshState();
577
+ }
578
+ }
579
+ if (flagsToProcess.has('filtering')) {
580
+ for (const column of columns) {
581
+ column.filtering?.refreshState();
582
+ }
583
+ }
584
+ pagination?.redraw();
585
+ delete colResizing?.isDirty;
586
+ for (const flag of ['sorting', 'filtering']) {
587
+ flags.delete(flag);
588
+ }
589
+ fireEvent(this, 'afterRedraw');
590
+ };
591
+ const queued = this.redrawQueue.then(run, run);
592
+ // Keep the queue progressing even if one redraw fails.
593
+ this.redrawQueue = queued['catch'](() => void 0);
594
+ return queued;
545
595
  }
546
596
  /**
547
597
  * Updates the column of the Grid with new options.
@@ -672,19 +722,21 @@ export class Grid {
672
722
  });
673
723
  }
674
724
  }
675
- async render() {
725
+ async render(clearDirtyFlags = true) {
676
726
  if (this.isRendered) {
677
727
  this.destroy(true);
678
728
  }
679
- this.loadDataTable();
729
+ await this.loadDataProvider().init();
680
730
  this.initContainer(this.renderTo);
681
731
  this.initAccessibility();
682
732
  this.initPagination();
683
733
  this.querying.loadOptions();
684
734
  await this.querying.proceed();
685
- this.renderViewport();
735
+ await this.renderViewport();
686
736
  this.isRendered = true;
687
- this.dirtyFlags.clear();
737
+ if (clearDirtyFlags) {
738
+ this.dirtyFlags.clear();
739
+ }
688
740
  }
689
741
  /**
690
742
  * Hovers the row with the provided index. It removes the hover effect from
@@ -774,20 +826,19 @@ export class Grid {
774
826
  */
775
827
  renderCaption() {
776
828
  const captionOptions = this.options?.caption;
777
- const captionText = captionOptions?.text;
778
- if (!captionText) {
829
+ if (!captionOptions?.text || !this.contentWrapper) {
779
830
  return;
780
831
  }
781
- // Create a caption element.
782
- this.captionElement = makeHTMLElement('div', {
783
- className: Globals.getClassName('captionElement'),
784
- id: this.id + '-caption'
785
- }, this.contentWrapper);
786
- // Render the caption element content.
787
- setHTMLContent(this.captionElement, captionText);
788
- if (captionOptions.className) {
789
- this.captionElement.classList.add(...captionOptions.className.split(/\s+/g));
790
- }
832
+ const tag = captionOptions.htmlTag?.toLowerCase();
833
+ const tagName = tag && AST.allowedTags.includes(tag) ? tag : 'div';
834
+ const defaultClass = Globals.getClassName('captionElement');
835
+ const className = captionOptions.className ?
836
+ `${defaultClass} ${captionOptions.className}` : defaultClass;
837
+ this.captionElement = new AST([{
838
+ tagName,
839
+ attributes: { 'class': className, id: this.id + '-caption' },
840
+ textContent: captionOptions.text
841
+ }]).addToDOM(this.contentWrapper);
791
842
  }
792
843
  /**
793
844
  * Render description under the grid.
@@ -830,11 +881,11 @@ export class Grid {
830
881
  * rendered, it will be destroyed and re-rendered with the new data.
831
882
  * @internal
832
883
  */
833
- renderViewport() {
884
+ async renderViewport() {
834
885
  const viewportMeta = this.viewport?.getStateMeta();
835
886
  const pagination = this.pagination;
836
887
  const paginationPosition = pagination?.options?.position;
837
- this.enabledColumns = this.getEnabledColumnIDs();
888
+ this.enabledColumns = await this.getEnabledColumnIDs();
838
889
  this.credits?.destroy();
839
890
  this.viewport?.destroy();
840
891
  delete this.viewport;
@@ -846,7 +897,8 @@ export class Grid {
846
897
  pagination?.render();
847
898
  }
848
899
  if (this.enabledColumns.length > 0) {
849
- this.viewport = this.renderTable();
900
+ this.viewport = await this.renderTable();
901
+ this.viewport.tableElement.setAttribute('id', this.id);
850
902
  if (viewportMeta && this.viewport) {
851
903
  this.viewport.applyStateMeta(viewportMeta);
852
904
  }
@@ -854,7 +906,7 @@ export class Grid {
854
906
  else {
855
907
  this.renderNoData();
856
908
  }
857
- this.renderAccessibility();
909
+ await this.renderAccessibility();
858
910
  // Render bottom pagination, footer pagination,
859
911
  // or custom container pagination (after table).
860
912
  if (paginationPosition !== 'top') {
@@ -868,12 +920,12 @@ export class Grid {
868
920
  * Renders the Grid accessibility.
869
921
  * @internal
870
922
  */
871
- renderAccessibility() {
923
+ async renderAccessibility() {
872
924
  const accessibility = this.accessibility;
873
925
  if (!accessibility) {
874
926
  return;
875
927
  }
876
- accessibility.setA11yOptions();
928
+ await accessibility.setA11yOptions();
877
929
  accessibility.addScreenReaderSection('before');
878
930
  accessibility.addScreenReaderSection('after');
879
931
  }
@@ -883,12 +935,14 @@ export class Grid {
883
935
  * @returns
884
936
  * The newly rendered table (viewport) of the Grid.
885
937
  */
886
- renderTable() {
938
+ async renderTable() {
887
939
  this.tableElement = makeHTMLElement('table', {
888
940
  className: Globals.getClassName('tableElement')
889
941
  }, this.contentWrapper);
890
942
  this.tableElement.setAttribute('role', 'grid');
891
- return new Table(this, this.tableElement);
943
+ const table = new Table(this, this.tableElement);
944
+ await table.init();
945
+ return table;
892
946
  }
893
947
  /**
894
948
  * Renders a message that there is no data to display.
@@ -903,12 +957,12 @@ export class Grid {
903
957
  * Returns the array of IDs of columns that should be displayed in the data
904
958
  * grid, in the correct order.
905
959
  */
906
- getEnabledColumnIDs() {
960
+ async getEnabledColumnIDs() {
907
961
  const { columnOptionsMap } = this;
908
962
  const header = this.options?.header;
909
963
  const headerColumns = this.getColumnIds(header || [], false);
910
964
  const columnsIncluded = this.options?.rendering?.columns?.included || (headerColumns && headerColumns.length > 0 ?
911
- headerColumns : this.dataTable?.getColumnIds());
965
+ headerColumns : await this.dataProvider?.getColumnIds());
912
966
  if (!columnsIncluded?.length) {
913
967
  return [];
914
968
  }
@@ -925,37 +979,25 @@ export class Grid {
925
979
  }
926
980
  return result;
927
981
  }
928
- /**
929
- * Loads the data table of the Grid. If the data table is passed as a
930
- * reference, it should be used instead of creating a new one.
931
- */
932
- loadDataTable() {
982
+ loadDataProvider() {
983
+ this.dataProvider?.destroy();
933
984
  this.querying.shouldBeUpdated = true;
934
- // Unregister all events attached to the previous data table.
935
- this.dataTableEventDestructors.forEach((fn) => fn());
936
- const tableOptions = this.options?.dataTable;
937
- // If the table is passed as a reference, it should be used instead of
938
- // creating a new one.
939
- if (tableOptions?.clone) {
940
- this.dataTable = tableOptions;
941
- this.presentationTable = this.dataTable.getModified();
942
- return;
943
- }
944
- const dt = this.dataTable = this.presentationTable =
945
- new DataTable(tableOptions);
946
- // If the data table is modified, mark the querying controller to be
947
- // updated on the next proceed.
948
- [
949
- 'afterDeleteColumns',
950
- 'afterDeleteRows',
951
- 'afterSetCell',
952
- 'afterSetColumns',
953
- 'afterSetRows'
954
- ].forEach((eventName) => {
955
- this.dataTableEventDestructors.push(dt.on(eventName, () => {
956
- this.querying.shouldBeUpdated = true;
957
- }));
958
- });
985
+ const userDT = this.options?.dataTable;
986
+ const dataOptions = this.options?.data ?? {
987
+ providerType: 'local',
988
+ dataTable: userDT ?? {}
989
+ };
990
+ // Just for the backward compatibility, remove in the future
991
+ if (dataOptions.providerType === 'local' &&
992
+ !dataOptions.dataTable && userDT) {
993
+ dataOptions.dataTable = 'clone' in userDT ?
994
+ userDT : new DataTable(userDT);
995
+ }
996
+ // End of backward compatibility snippet
997
+ const DataProviderConstructor = DataProviderRegistry.types[dataOptions.providerType ?? 'local'] ??
998
+ DataProviderRegistry.types.local;
999
+ this.dataProvider = new DataProviderConstructor(this.querying, dataOptions);
1000
+ return this.dataProvider;
959
1001
  }
960
1002
  /**
961
1003
  * Extracts all references to columnIds on all levels below defined level
@@ -992,9 +1034,10 @@ export class Grid {
992
1034
  * after destruction by calling the `render` method.
993
1035
  */
994
1036
  destroy(onlyDOM = false) {
1037
+ fireEvent(this, 'beforeDestroy');
995
1038
  this.isRendered = false;
996
1039
  const dgIndex = Grid.grids.findIndex((dg) => dg === this);
997
- this.dataTableEventDestructors.forEach((fn) => fn());
1040
+ this.dataProvider?.destroy();
998
1041
  this.accessibility?.destroy();
999
1042
  this.pagination?.destroy();
1000
1043
  this.viewport?.destroy();
@@ -1045,6 +1088,11 @@ export class Grid {
1045
1088
  /**
1046
1089
  * Returns the grid data as a JSON string.
1047
1090
  *
1091
+ * **Note:** This method only works with `LocalDataProvider`.
1092
+ * For other data providers, use your data source directly.
1093
+ *
1094
+ * @deprecated
1095
+ *
1048
1096
  * @param modified
1049
1097
  * Whether to return the modified data table (after filtering/sorting/etc.)
1050
1098
  * or the unmodified, original one. Default value is set to `true`.
@@ -1053,7 +1101,14 @@ export class Grid {
1053
1101
  * JSON representation of the data
1054
1102
  */
1055
1103
  getData(modified = true) {
1056
- const dataTable = modified ? this.presentationTable : this.dataTable;
1104
+ if (!this.dataProvider || !('getDataTable' in this.dataProvider)) {
1105
+ // eslint-disable-next-line no-console
1106
+ console.warn('getData() works only with LocalDataProvider.');
1107
+ return JSON.stringify({
1108
+ error: 'getData() works only with LocalDataProvider.'
1109
+ }, null, 2);
1110
+ }
1111
+ const dataTable = this.dataProvider.getDataTable(modified);
1057
1112
  const tableColumns = dataTable?.columns;
1058
1113
  const outputColumns = {};
1059
1114
  if (!this.enabledColumns || !tableColumns) {
@@ -1095,12 +1150,35 @@ export class Grid {
1095
1150
  * Grid options.
1096
1151
  */
1097
1152
  getOptions(onlyUserOptions = true) {
1098
- const options = onlyUserOptions ? merge(this.userOptions) : merge(this.options);
1099
- if (options.dataTable?.id) {
1153
+ const options = onlyUserOptions ?
1154
+ merge(this.userOptions) :
1155
+ merge(this.options);
1156
+ // Keep `getOptions()` serializable:
1157
+ if (options.dataTable && 'clone' in options.dataTable) {
1100
1158
  options.dataTable = {
1101
1159
  columns: options.dataTable.columns
1102
1160
  };
1103
1161
  }
1162
+ if (options.data?.providerType === 'local') {
1163
+ if (options.data?.dataTable && 'clone' in options.data.dataTable) {
1164
+ options.data.columns = options.data.dataTable.columns;
1165
+ }
1166
+ if (options.data?.connector &&
1167
+ 'initConverters' in options.data.connector) {
1168
+ options.data.connector = options.data.connector.options;
1169
+ }
1170
+ }
1171
+ // Clean up the column options by removing the ones that have no other
1172
+ // options than `id`:
1173
+ const oldColumnOptions = options.columns;
1174
+ if (oldColumnOptions) {
1175
+ options.columns = [];
1176
+ for (const columnOption of oldColumnOptions) {
1177
+ if (Object.keys(columnOption).length > 1) {
1178
+ options.columns.push(columnOption);
1179
+ }
1180
+ }
1181
+ }
1104
1182
  return options;
1105
1183
  }
1106
1184
  }
@@ -1,3 +1,4 @@
1
+ import type CSSObject from '../../Core/Renderer/CSSObject';
1
2
  /**
2
3
  * The event object for the grid.
3
4
  */
@@ -28,6 +29,10 @@ export interface MakeHTMLElementParameters {
28
29
  innerHTML?: string;
29
30
  style?: Partial<CSSStyleDeclaration>;
30
31
  }
32
+ /**
33
+ * A style object or callback returning one.
34
+ */
35
+ export type StyleValue<T> = CSSObject | ((this: T, target: T) => CSSObject);
31
36
  /**
32
37
  * Creates a HTML element with the provided options.
33
38
  *
@@ -105,6 +110,32 @@ export declare function createOptionsProxy<T extends object>(options: T, default
105
110
  * @returns Formatted text
106
111
  */
107
112
  export declare function formatText(template: string, values: Record<string, string | number>): string;
113
+ /**
114
+ * Resolves a style value that can be static or callback based.
115
+ *
116
+ * @param style
117
+ * Style object or callback returning one.
118
+ *
119
+ * @param target
120
+ * Runtime target used as callback context and first argument.
121
+ *
122
+ * @returns
123
+ * A resolved style object or `undefined`.
124
+ */
125
+ export declare function resolveStyleValue<T>(style?: StyleValue<T>, target?: T): (CSSObject | undefined);
126
+ /**
127
+ * Resolves and merges style values in order.
128
+ *
129
+ * @param target
130
+ * Runtime target used as callback context and first argument.
131
+ *
132
+ * @param styleValues
133
+ * Style values to merge in order, where latter entries override former.
134
+ *
135
+ * @returns
136
+ * Merged style object.
137
+ */
138
+ export declare function mergeStyleValues<T>(target: T, ...styleValues: Array<(StyleValue<T> | undefined)>): CSSObject;
108
139
  declare const _default: {
109
140
  readonly makeHTMLElement: typeof makeHTMLElement;
110
141
  readonly makeDiv: typeof makeDiv;
@@ -113,5 +144,7 @@ declare const _default: {
113
144
  readonly setHTMLContent: typeof setHTMLContent;
114
145
  readonly createOptionsProxy: typeof createOptionsProxy;
115
146
  readonly formatText: typeof formatText;
147
+ readonly resolveStyleValue: typeof resolveStyleValue;
148
+ readonly mergeStyleValues: typeof mergeStyleValues;
116
149
  };
117
150
  export default _default;