cx 26.0.1 → 26.0.3

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 (808) hide show
  1. package/build/charts/Bar.d.ts +29 -0
  2. package/build/charts/Bar.js +74 -0
  3. package/build/charts/BarGraph.d.ts +29 -0
  4. package/build/charts/BarGraph.js +86 -0
  5. package/build/charts/BubbleGraph.d.ts +54 -0
  6. package/build/charts/BubbleGraph.js +80 -0
  7. package/build/charts/Chart.d.ts +31 -0
  8. package/build/charts/Chart.js +62 -0
  9. package/build/charts/ColorMap.d.ts +59 -0
  10. package/build/charts/ColorMap.js +97 -0
  11. package/build/charts/Column.d.ts +32 -0
  12. package/build/charts/Column.js +81 -0
  13. package/build/charts/ColumnBarBase.d.ts +92 -0
  14. package/build/charts/ColumnBarBase.js +144 -0
  15. package/build/charts/ColumnBarGraphBase.d.ts +91 -0
  16. package/build/charts/ColumnBarGraphBase.js +106 -0
  17. package/build/charts/ColumnGraph.d.ts +30 -0
  18. package/build/charts/ColumnGraph.js +94 -0
  19. package/build/charts/Grid.d.ts +2 -0
  20. package/build/charts/Grid.js +3 -0
  21. package/build/charts/Gridlines.d.ts +34 -0
  22. package/build/charts/Gridlines.js +42 -0
  23. package/build/charts/Legend.d.ts +73 -0
  24. package/build/charts/Legend.js +138 -0
  25. package/build/charts/LegendEntry.d.ts +60 -0
  26. package/build/charts/LegendEntry.js +101 -0
  27. package/build/charts/LineGraph.d.ts +111 -0
  28. package/build/charts/LineGraph.js +253 -0
  29. package/build/charts/Marker.d.ts +133 -0
  30. package/build/charts/Marker.js +275 -0
  31. package/build/charts/MarkerLine.d.ts +65 -0
  32. package/build/charts/MarkerLine.js +108 -0
  33. package/build/charts/MouseTracker.d.ts +34 -0
  34. package/build/charts/MouseTracker.js +55 -0
  35. package/build/charts/Pie.d.ts +4 -0
  36. package/build/charts/Pie.js +5 -0
  37. package/build/charts/PieChart.d.ts +158 -0
  38. package/build/charts/PieChart.js +445 -0
  39. package/build/charts/PieLabel.d.ts +34 -0
  40. package/build/charts/PieLabel.js +47 -0
  41. package/build/charts/PieLabelsContainer.d.ts +15 -0
  42. package/build/charts/PieLabelsContainer.js +54 -0
  43. package/build/charts/Range.d.ts +94 -0
  44. package/build/charts/Range.js +160 -0
  45. package/build/charts/RangeMarker.d.ts +65 -0
  46. package/build/charts/RangeMarker.js +143 -0
  47. package/build/charts/ScatterGraph.d.ts +72 -0
  48. package/build/charts/ScatterGraph.js +133 -0
  49. package/build/charts/Swimlane.d.ts +47 -0
  50. package/build/charts/Swimlane.js +113 -0
  51. package/build/charts/Swimlanes.d.ts +57 -0
  52. package/build/charts/Swimlanes.js +83 -0
  53. package/build/charts/axis/Axis.d.ts +141 -0
  54. package/build/charts/axis/Axis.js +215 -0
  55. package/build/charts/axis/CategoryAxis.d.ts +35 -0
  56. package/build/charts/axis/CategoryAxis.js +240 -0
  57. package/build/charts/axis/NumericAxis.d.ts +57 -0
  58. package/build/charts/axis/NumericAxis.js +316 -0
  59. package/build/charts/axis/Stack.d.ts +16 -0
  60. package/build/charts/axis/Stack.js +57 -0
  61. package/build/charts/axis/TimeAxis.d.ts +50 -0
  62. package/build/charts/axis/TimeAxis.js +554 -0
  63. package/build/charts/axis/index.d.ts +4 -0
  64. package/build/charts/axis/index.js +4 -0
  65. package/build/charts/helpers/MinMaxFinder.d.ts +36 -0
  66. package/build/charts/helpers/MinMaxFinder.js +37 -0
  67. package/build/charts/helpers/PointReducer.d.ts +41 -0
  68. package/build/charts/helpers/PointReducer.js +55 -0
  69. package/build/charts/helpers/SnapPointFinder.d.ts +58 -0
  70. package/build/charts/helpers/SnapPointFinder.js +65 -0
  71. package/build/charts/helpers/ValueAtFinder.d.ts +33 -0
  72. package/build/charts/helpers/ValueAtFinder.js +46 -0
  73. package/build/charts/helpers/index.d.ts +4 -0
  74. package/build/charts/helpers/index.js +4 -0
  75. package/build/charts/index.d.ts +26 -0
  76. package/build/charts/index.js +26 -0
  77. package/build/charts/shapes.d.ts +13 -0
  78. package/build/charts/shapes.js +62 -0
  79. package/build/data/AggregateFunction.d.ts +60 -0
  80. package/build/data/AggregateFunction.js +155 -0
  81. package/build/data/ArrayElementView.d.ts +33 -0
  82. package/build/data/ArrayElementView.js +65 -0
  83. package/build/data/ArrayElementView.spec.d.ts +1 -0
  84. package/build/data/ArrayElementView.spec.js +81 -0
  85. package/build/data/ArrayRef.d.ts +9 -0
  86. package/build/data/ArrayRef.js +29 -0
  87. package/build/data/AugmentedViewBase.d.ts +18 -0
  88. package/build/data/AugmentedViewBase.js +72 -0
  89. package/build/data/Binding.d.ts +23 -0
  90. package/build/data/Binding.js +78 -0
  91. package/build/data/Binding.spec.d.ts +1 -0
  92. package/build/data/Binding.spec.js +61 -0
  93. package/build/data/ExposedRecordView.d.ts +24 -0
  94. package/build/data/ExposedRecordView.js +76 -0
  95. package/build/data/ExposedValueView.d.ts +20 -0
  96. package/build/data/ExposedValueView.js +68 -0
  97. package/build/data/Expression.d.ts +12 -0
  98. package/build/data/Expression.js +201 -0
  99. package/build/data/Expression.spec.d.ts +1 -0
  100. package/build/data/Expression.spec.js +196 -0
  101. package/build/data/Grouper.d.ts +29 -0
  102. package/build/data/Grouper.js +138 -0
  103. package/build/data/Grouper.spec.d.ts +1 -0
  104. package/build/data/Grouper.spec.js +48 -0
  105. package/build/data/NestedDataView.d.ts +21 -0
  106. package/build/data/NestedDataView.js +24 -0
  107. package/build/data/ReadOnlyDataView.d.ts +13 -0
  108. package/build/data/ReadOnlyDataView.js +25 -0
  109. package/build/data/Ref.d.ts +23 -0
  110. package/build/data/Ref.js +79 -0
  111. package/build/data/Ref.spec.d.ts +1 -0
  112. package/build/data/Ref.spec.js +72 -0
  113. package/build/data/Selector.d.ts +8 -0
  114. package/build/data/Selector.js +1 -0
  115. package/build/data/Store.d.ts +12 -0
  116. package/build/data/Store.js +41 -0
  117. package/build/data/Store.spec.d.ts +1 -0
  118. package/build/data/Store.spec.js +19 -0
  119. package/build/data/StoreProxy.d.ts +6 -0
  120. package/build/data/StoreProxy.js +14 -0
  121. package/build/data/StoreRef.d.ts +22 -0
  122. package/build/data/StoreRef.js +47 -0
  123. package/build/data/StoreRef.spec.d.ts +1 -0
  124. package/build/data/StoreRef.spec.js +22 -0
  125. package/build/data/StringTemplate.d.ts +9 -0
  126. package/build/data/StringTemplate.js +81 -0
  127. package/build/data/StringTemplate.spec.d.ts +1 -0
  128. package/build/data/StringTemplate.spec.js +112 -0
  129. package/build/data/StructuredSelector.d.ts +12 -0
  130. package/build/data/StructuredSelector.js +131 -0
  131. package/build/data/StructuredSelector.spec.d.ts +1 -0
  132. package/build/data/StructuredSelector.spec.js +102 -0
  133. package/build/data/SubscribableView.d.ts +15 -0
  134. package/build/data/SubscribableView.js +52 -0
  135. package/build/data/View.d.ts +125 -0
  136. package/build/data/View.js +163 -0
  137. package/build/data/View.spec.d.ts +1 -0
  138. package/build/data/View.spec.js +44 -0
  139. package/build/data/ZoomIntoPropertyView.d.ts +15 -0
  140. package/build/data/ZoomIntoPropertyView.js +34 -0
  141. package/build/data/ZoomIntoPropertyView.spec.d.ts +1 -0
  142. package/build/data/ZoomIntoPropertyView.spec.js +54 -0
  143. package/build/data/comparer.d.ts +11 -0
  144. package/build/data/comparer.js +55 -0
  145. package/build/data/comparer.spec.d.ts +1 -0
  146. package/build/data/comparer.spec.js +50 -0
  147. package/build/data/computable.d.ts +10 -0
  148. package/build/data/computable.js +46 -0
  149. package/build/data/computable.spec.d.ts +1 -0
  150. package/build/data/computable.spec.js +56 -0
  151. package/build/data/createAccessorModelProxy.d.ts +17 -0
  152. package/build/data/createAccessorModelProxy.js +37 -0
  153. package/build/data/createAccessorModelProxy.spec.d.ts +1 -0
  154. package/build/data/createAccessorModelProxy.spec.js +30 -0
  155. package/build/data/createStructuredSelector.d.ts +9 -0
  156. package/build/data/createStructuredSelector.js +40 -0
  157. package/build/data/createStructuredSelector.spec.d.ts +1 -0
  158. package/build/data/createStructuredSelector.spec.js +42 -0
  159. package/build/data/defaultCompare.d.ts +1 -0
  160. package/build/data/defaultCompare.js +12 -0
  161. package/build/data/diff/diffArrays.d.ts +12 -0
  162. package/build/data/diff/diffArrays.js +34 -0
  163. package/build/data/diff/diffs.spec.d.ts +1 -0
  164. package/build/data/diff/diffs.spec.js +45 -0
  165. package/build/data/diff/index.d.ts +1 -0
  166. package/build/data/diff/index.js +1 -0
  167. package/build/data/enableFatArrowExpansion.d.ts +1 -0
  168. package/build/data/enableFatArrowExpansion.js +5 -0
  169. package/build/data/getAccessor.d.ts +11 -0
  170. package/build/data/getAccessor.js +51 -0
  171. package/build/data/getAccessor.spec.d.ts +1 -0
  172. package/build/data/getAccessor.spec.js +10 -0
  173. package/build/data/getSelector.d.ts +3 -0
  174. package/build/data/getSelector.js +60 -0
  175. package/build/data/getSelector.spec.d.ts +1 -0
  176. package/build/data/getSelector.spec.js +36 -0
  177. package/build/data/index.d.ts +29 -0
  178. package/build/data/index.js +29 -0
  179. package/build/data/isSelector.d.ts +1 -0
  180. package/build/data/isSelector.js +19 -0
  181. package/build/data/ops/append.d.ts +1 -0
  182. package/build/data/ops/append.js +7 -0
  183. package/build/data/ops/append.spec.d.ts +1 -0
  184. package/build/data/ops/append.spec.js +24 -0
  185. package/build/data/ops/filter.d.ts +1 -0
  186. package/build/data/ops/filter.js +8 -0
  187. package/build/data/ops/filter.spec.d.ts +1 -0
  188. package/build/data/ops/filter.spec.js +25 -0
  189. package/build/data/ops/findTreeNode.d.ts +1 -0
  190. package/build/data/ops/findTreeNode.js +13 -0
  191. package/build/data/ops/findTreeNode.spec.d.ts +1 -0
  192. package/build/data/ops/findTreeNode.spec.js +20 -0
  193. package/build/data/ops/findTreePath.d.ts +1 -0
  194. package/build/data/ops/findTreePath.js +15 -0
  195. package/build/data/ops/index.d.ts +10 -0
  196. package/build/data/ops/index.js +10 -0
  197. package/build/data/ops/insertElement.d.ts +1 -0
  198. package/build/data/ops/insertElement.js +3 -0
  199. package/build/data/ops/merge.d.ts +1 -0
  200. package/build/data/ops/merge.js +10 -0
  201. package/build/data/ops/merge.spec.d.ts +1 -0
  202. package/build/data/ops/merge.spec.js +23 -0
  203. package/build/data/ops/moveElement.d.ts +1 -0
  204. package/build/data/ops/moveElement.js +20 -0
  205. package/build/data/ops/removeTreeNodes.d.ts +1 -0
  206. package/build/data/ops/removeTreeNodes.js +4 -0
  207. package/build/data/ops/removeTreeNodes.spec.d.ts +1 -0
  208. package/build/data/ops/removeTreeNodes.spec.js +35 -0
  209. package/build/data/ops/updateArray.d.ts +1 -0
  210. package/build/data/ops/updateArray.js +23 -0
  211. package/build/data/ops/updateArray.spec.d.ts +1 -0
  212. package/build/data/ops/updateArray.spec.js +33 -0
  213. package/build/data/ops/updateTree.d.ts +1 -0
  214. package/build/data/ops/updateTree.js +14 -0
  215. package/build/data/ops/updateTree.spec.d.ts +1 -0
  216. package/build/data/ops/updateTree.spec.js +44 -0
  217. package/build/data/test-types.d.ts +1 -0
  218. package/build/data/test-types.js +2 -0
  219. package/build/hooks/createLocalStorageRef.d.ts +2 -0
  220. package/build/hooks/createLocalStorageRef.js +22 -0
  221. package/build/hooks/index.d.ts +8 -0
  222. package/build/hooks/index.js +8 -0
  223. package/build/hooks/invokeCallback.d.ts +2 -0
  224. package/build/hooks/invokeCallback.js +8 -0
  225. package/build/hooks/invokeCallback.spec.d.ts +1 -0
  226. package/build/hooks/invokeCallback.spec.js +44 -0
  227. package/build/hooks/resolveCallback.d.ts +2 -0
  228. package/build/hooks/resolveCallback.js +13 -0
  229. package/build/hooks/resolveCallback.spec.d.ts +1 -0
  230. package/build/hooks/resolveCallback.spec.js +35 -0
  231. package/build/hooks/store.d.ts +11 -0
  232. package/build/hooks/store.js +38 -0
  233. package/build/hooks/store.spec.d.ts +1 -0
  234. package/build/hooks/store.spec.js +48 -0
  235. package/build/hooks/useEffect.d.ts +2 -0
  236. package/build/hooks/useEffect.js +13 -0
  237. package/build/hooks/useInterval.d.ts +1 -0
  238. package/build/hooks/useInterval.js +7 -0
  239. package/build/hooks/useState.d.ts +2 -0
  240. package/build/hooks/useState.js +17 -0
  241. package/build/hooks/useTrigger.d.ts +3 -0
  242. package/build/hooks/useTrigger.js +22 -0
  243. package/build/hooks/useTrigger.spec.d.ts +1 -0
  244. package/build/hooks/useTrigger.spec.js +59 -0
  245. package/build/index.d.ts +7 -0
  246. package/build/index.js +7 -0
  247. package/build/jsx-runtime.d.ts +31 -0
  248. package/build/jsx-runtime.js +27 -0
  249. package/build/locale/de-de.d.ts +1 -0
  250. package/build/locale/de-de.js +62 -0
  251. package/build/locale/en-us.d.ts +1 -0
  252. package/build/locale/en-us.js +62 -0
  253. package/build/locale/es-es.d.ts +1 -0
  254. package/build/locale/es-es.js +62 -0
  255. package/build/locale/fr-fr.d.ts +1 -0
  256. package/build/locale/fr-fr.js +62 -0
  257. package/build/locale/nl-nl.d.ts +1 -0
  258. package/build/locale/nl-nl.js +62 -0
  259. package/build/locale/pt-pt.d.ts +1 -0
  260. package/build/locale/pt-pt.js +62 -0
  261. package/build/locale/sr-latn-ba.d.ts +1 -0
  262. package/build/locale/sr-latn-ba.js +62 -0
  263. package/build/svg/BoundedObject.d.ts +39 -0
  264. package/build/svg/BoundedObject.js +51 -0
  265. package/build/svg/ClipRect.d.ts +11 -0
  266. package/build/svg/ClipRect.js +18 -0
  267. package/build/svg/Ellipse.d.ts +27 -0
  268. package/build/svg/Ellipse.js +22 -0
  269. package/build/svg/Line.d.ts +26 -0
  270. package/build/svg/Line.js +19 -0
  271. package/build/svg/NonOverlappingRect.d.ts +12 -0
  272. package/build/svg/NonOverlappingRect.js +17 -0
  273. package/build/svg/NonOverlappingRectGroup.d.ts +15 -0
  274. package/build/svg/NonOverlappingRectGroup.js +38 -0
  275. package/build/svg/Rectangle.d.ts +40 -0
  276. package/build/svg/Rectangle.js +27 -0
  277. package/build/svg/Svg.d.ts +49 -0
  278. package/build/svg/Svg.js +132 -0
  279. package/build/svg/Text.d.ts +48 -0
  280. package/build/svg/Text.js +60 -0
  281. package/build/svg/TextualBoundedObject.d.ts +7 -0
  282. package/build/svg/TextualBoundedObject.js +22 -0
  283. package/build/svg/index.d.ts +11 -0
  284. package/build/svg/index.js +11 -0
  285. package/build/svg/util/Rect.d.ts +31 -0
  286. package/build/svg/util/Rect.js +83 -0
  287. package/build/svg/util/index.d.ts +1 -0
  288. package/build/svg/util/index.js +1 -0
  289. package/build/ui/CSS.d.ts +10 -0
  290. package/build/ui/CSS.js +77 -0
  291. package/build/ui/CSSHelper.d.ts +5 -0
  292. package/build/ui/CSSHelper.js +15 -0
  293. package/build/ui/Container.d.ts +55 -0
  294. package/build/ui/Container.js +160 -0
  295. package/build/ui/ContentResolver.d.ts +51 -0
  296. package/build/ui/ContentResolver.js +71 -0
  297. package/build/ui/Controller.d.ts +64 -0
  298. package/build/ui/Controller.js +110 -0
  299. package/build/ui/Controller.spec.d.ts +1 -0
  300. package/build/ui/Controller.spec.js +251 -0
  301. package/build/ui/Culture.d.ts +39 -0
  302. package/build/ui/Culture.js +124 -0
  303. package/build/ui/Cx.d.ts +57 -0
  304. package/build/ui/Cx.js +277 -0
  305. package/build/ui/Cx.spec.d.ts +1 -0
  306. package/build/ui/Cx.spec.js +153 -0
  307. package/build/ui/DataProxy.d.ts +24 -0
  308. package/build/ui/DataProxy.js +26 -0
  309. package/build/ui/DataProxy.spec.d.ts +1 -0
  310. package/build/ui/DataProxy.spec.js +208 -0
  311. package/build/ui/DetachedScope.d.ts +61 -0
  312. package/build/ui/DetachedScope.js +84 -0
  313. package/build/ui/FocusManager.d.ts +16 -0
  314. package/build/ui/FocusManager.js +149 -0
  315. package/build/ui/Format.d.ts +4 -0
  316. package/build/ui/Format.js +96 -0
  317. package/build/ui/HoverSync.d.ts +30 -0
  318. package/build/ui/HoverSync.js +129 -0
  319. package/build/ui/Instance.d.ts +219 -0
  320. package/build/ui/Instance.js +613 -0
  321. package/build/ui/IsolatedScope.d.ts +19 -0
  322. package/build/ui/IsolatedScope.js +31 -0
  323. package/build/ui/IsolatedScope.spec.d.ts +1 -0
  324. package/build/ui/IsolatedScope.spec.js +42 -0
  325. package/build/ui/Localization.d.ts +9 -0
  326. package/build/ui/Localization.js +63 -0
  327. package/build/ui/Prop.d.ts +83 -0
  328. package/build/ui/Prop.js +1 -0
  329. package/build/ui/PureContainer.d.ts +9 -0
  330. package/build/ui/PureContainer.js +9 -0
  331. package/build/ui/RenderingContext.d.ts +19 -0
  332. package/build/ui/RenderingContext.js +84 -0
  333. package/build/ui/Repeater.d.ts +73 -0
  334. package/build/ui/Repeater.js +99 -0
  335. package/build/ui/Repeater.spec.d.ts +1 -0
  336. package/build/ui/Repeater.spec.js +109 -0
  337. package/build/ui/Rescope.d.ts +18 -0
  338. package/build/ui/Rescope.js +31 -0
  339. package/build/ui/Rescope.spec.d.ts +1 -0
  340. package/build/ui/Rescope.spec.js +134 -0
  341. package/build/ui/ResizeManager.d.ts +5 -0
  342. package/build/ui/ResizeManager.js +24 -0
  343. package/build/ui/Restate.d.ts +44 -0
  344. package/build/ui/Restate.js +142 -0
  345. package/build/ui/Restate.spec.d.ts +1 -0
  346. package/build/ui/Restate.spec.js +257 -0
  347. package/build/ui/StaticText.d.ts +5 -0
  348. package/build/ui/StaticText.js +7 -0
  349. package/build/ui/StructuredInstanceDataAccessor.d.ts +13 -0
  350. package/build/ui/StructuredInstanceDataAccessor.js +30 -0
  351. package/build/ui/Text.d.ts +10 -0
  352. package/build/ui/Text.js +21 -0
  353. package/build/ui/VDOM.d.ts +20 -0
  354. package/build/ui/VDOM.js +3 -0
  355. package/build/ui/Widget.d.ts +111 -0
  356. package/build/ui/Widget.js +170 -0
  357. package/build/ui/ZIndexManager.d.ts +4 -0
  358. package/build/ui/ZIndexManager.js +9 -0
  359. package/build/ui/adapter/ArrayAdapter.d.ts +48 -0
  360. package/build/ui/adapter/ArrayAdapter.js +148 -0
  361. package/build/ui/adapter/ArrayAdapter.spec.d.ts +1 -0
  362. package/build/ui/adapter/ArrayAdapter.spec.js +44 -0
  363. package/build/ui/adapter/DataAdapter.d.ts +30 -0
  364. package/build/ui/adapter/DataAdapter.js +13 -0
  365. package/build/ui/adapter/GroupAdapter.d.ts +57 -0
  366. package/build/ui/adapter/GroupAdapter.js +137 -0
  367. package/build/ui/adapter/TreeAdapter.d.ts +51 -0
  368. package/build/ui/adapter/TreeAdapter.js +98 -0
  369. package/build/ui/adapter/TreeAdapter.spec.d.ts +1 -0
  370. package/build/ui/adapter/TreeAdapter.spec.js +71 -0
  371. package/build/ui/adapter/index.d.ts +4 -0
  372. package/build/ui/adapter/index.js +4 -0
  373. package/build/ui/app/History.d.ts +18 -0
  374. package/build/ui/app/History.js +109 -0
  375. package/build/ui/app/Url.d.ts +13 -0
  376. package/build/ui/app/Url.js +86 -0
  377. package/build/ui/app/Url.spec.d.ts +1 -0
  378. package/build/ui/app/Url.spec.js +43 -0
  379. package/build/ui/app/index.d.ts +4 -0
  380. package/build/ui/app/index.js +4 -0
  381. package/build/ui/app/startAppLoop.d.ts +10 -0
  382. package/build/ui/app/startAppLoop.js +53 -0
  383. package/build/ui/app/startHotAppLoop.d.ts +11 -0
  384. package/build/ui/app/startHotAppLoop.js +22 -0
  385. package/build/ui/batchUpdates.d.ts +5 -0
  386. package/build/ui/batchUpdates.js +60 -0
  387. package/build/ui/bind.d.ts +3 -0
  388. package/build/ui/bind.js +7 -0
  389. package/build/ui/createFunctionalComponent.d.ts +2 -0
  390. package/build/ui/createFunctionalComponent.js +58 -0
  391. package/build/ui/createFunctionalComponent.spec.d.ts +1 -0
  392. package/build/ui/createFunctionalComponent.spec.js +272 -0
  393. package/build/ui/expr.d.ts +11 -0
  394. package/build/ui/expr.js +17 -0
  395. package/build/ui/flattenProps.d.ts +1 -0
  396. package/build/ui/flattenProps.js +18 -0
  397. package/build/ui/index.d.ts +40 -0
  398. package/build/ui/index.js +41 -0
  399. package/build/ui/keyboardShortcuts.d.ts +10 -0
  400. package/build/ui/keyboardShortcuts.js +27 -0
  401. package/build/ui/layout/Content.d.ts +14 -0
  402. package/build/ui/layout/Content.js +15 -0
  403. package/build/ui/layout/ContentPlaceholder.d.ts +35 -0
  404. package/build/ui/layout/ContentPlaceholder.js +105 -0
  405. package/build/ui/layout/ContentPlaceholder.spec.d.ts +1 -0
  406. package/build/ui/layout/ContentPlaceholder.spec.js +333 -0
  407. package/build/ui/layout/FirstVisibleChildLayout.d.ts +7 -0
  408. package/build/ui/layout/FirstVisibleChildLayout.js +58 -0
  409. package/build/ui/layout/FirstVisibleChildLayout.spec.d.ts +1 -0
  410. package/build/ui/layout/FirstVisibleChildLayout.spec.js +101 -0
  411. package/build/ui/layout/LabelsLeftLayout.d.ts +17 -0
  412. package/build/ui/layout/LabelsLeftLayout.js +50 -0
  413. package/build/ui/layout/LabelsTopLayout.d.ts +36 -0
  414. package/build/ui/layout/LabelsTopLayout.js +97 -0
  415. package/build/ui/layout/UseParentLayout.d.ts +4 -0
  416. package/build/ui/layout/UseParentLayout.js +5 -0
  417. package/build/ui/layout/exploreChildren.d.ts +4 -0
  418. package/build/ui/layout/exploreChildren.js +27 -0
  419. package/build/ui/layout/index.d.ts +7 -0
  420. package/build/ui/layout/index.js +7 -0
  421. package/build/ui/selection/KeySelection.d.ts +37 -0
  422. package/build/ui/selection/KeySelection.js +125 -0
  423. package/build/ui/selection/PropertySelection.d.ts +26 -0
  424. package/build/ui/selection/PropertySelection.js +51 -0
  425. package/build/ui/selection/Selection.d.ts +35 -0
  426. package/build/ui/selection/Selection.js +75 -0
  427. package/build/ui/selection/index.d.ts +3 -0
  428. package/build/ui/selection/index.js +3 -0
  429. package/build/ui/tpl.d.ts +3 -0
  430. package/build/ui/tpl.js +5 -0
  431. package/build/util/Component.d.ts +149 -0
  432. package/build/util/Component.js +109 -0
  433. package/build/util/Console.d.ts +4 -0
  434. package/build/util/Console.js +10 -0
  435. package/build/util/DOM.d.ts +24 -0
  436. package/build/util/DOM.js +64 -0
  437. package/build/util/Debug.d.ts +25 -0
  438. package/build/util/Debug.js +42 -0
  439. package/build/util/Format.d.ts +14 -0
  440. package/build/util/Format.js +229 -0
  441. package/build/util/Format.spec.d.ts +1 -0
  442. package/build/util/Format.spec.js +58 -0
  443. package/build/util/GlobalCacheIdentifier.d.ts +4 -0
  444. package/build/util/GlobalCacheIdentifier.js +9 -0
  445. package/build/util/KeyCode.d.ts +21 -0
  446. package/build/util/KeyCode.js +21 -0
  447. package/build/util/SubscriberList.d.ts +39 -0
  448. package/build/util/SubscriberList.js +70 -0
  449. package/build/util/Timing.d.ts +15 -0
  450. package/build/util/Timing.js +49 -0
  451. package/build/util/TraversalStack.d.ts +8 -0
  452. package/build/util/TraversalStack.js +37 -0
  453. package/build/util/TraversalStack.spec.d.ts +1 -0
  454. package/build/util/TraversalStack.spec.js +43 -0
  455. package/build/util/addEventListenerWithOptions.d.ts +17 -0
  456. package/build/util/addEventListenerWithOptions.js +8 -0
  457. package/build/util/browserSupportsPassiveEventHandlers.d.ts +5 -0
  458. package/build/util/browserSupportsPassiveEventHandlers.js +20 -0
  459. package/build/util/calculateNaturalElementHeight.d.ts +1 -0
  460. package/build/util/calculateNaturalElementHeight.js +24 -0
  461. package/build/util/capitalize.d.ts +1 -0
  462. package/build/util/capitalize.js +5 -0
  463. package/build/util/coalesce.d.ts +1 -0
  464. package/build/util/coalesce.js +7 -0
  465. package/build/util/color/hslToRgb.d.ts +8 -0
  466. package/build/util/color/hslToRgb.js +38 -0
  467. package/build/util/color/index.d.ts +4 -0
  468. package/build/util/color/index.js +4 -0
  469. package/build/util/color/parseColor.d.ts +57 -0
  470. package/build/util/color/parseColor.js +114 -0
  471. package/build/util/color/rgbToHex.d.ts +8 -0
  472. package/build/util/color/rgbToHex.js +14 -0
  473. package/build/util/color/rgbToHsl.d.ts +8 -0
  474. package/build/util/color/rgbToHsl.js +35 -0
  475. package/build/util/date/dateDiff.d.ts +7 -0
  476. package/build/util/date/dateDiff.js +10 -0
  477. package/build/util/date/diff.d.ts +7 -0
  478. package/build/util/date/diff.js +11 -0
  479. package/build/util/date/encodeDate.d.ts +1 -0
  480. package/build/util/date/encodeDate.js +7 -0
  481. package/build/util/date/encodeDateWithTimezoneOffset.d.ts +1 -0
  482. package/build/util/date/encodeDateWithTimezoneOffset.js +16 -0
  483. package/build/util/date/index.d.ts +11 -0
  484. package/build/util/date/index.js +11 -0
  485. package/build/util/date/lowerBoundCheck.d.ts +8 -0
  486. package/build/util/date/lowerBoundCheck.js +12 -0
  487. package/build/util/date/maxDate.d.ts +6 -0
  488. package/build/util/date/maxDate.js +13 -0
  489. package/build/util/date/minDate.d.ts +6 -0
  490. package/build/util/date/minDate.js +13 -0
  491. package/build/util/date/monthStart.d.ts +6 -0
  492. package/build/util/date/monthStart.js +8 -0
  493. package/build/util/date/parseDateInvariant.d.ts +2 -0
  494. package/build/util/date/parseDateInvariant.js +18 -0
  495. package/build/util/date/sameDate.d.ts +7 -0
  496. package/build/util/date/sameDate.js +11 -0
  497. package/build/util/date/upperBoundCheck.d.ts +8 -0
  498. package/build/util/date/upperBoundCheck.js +12 -0
  499. package/build/util/date/upperBoundCheck.spec.d.ts +1 -0
  500. package/build/util/date/upperBoundCheck.spec.js +22 -0
  501. package/build/util/date/zeroTime.d.ts +7 -0
  502. package/build/util/date/zeroTime.js +9 -0
  503. package/build/util/debounce.d.ts +5 -0
  504. package/build/util/debounce.js +15 -0
  505. package/build/util/dummyCallback.d.ts +1 -0
  506. package/build/util/dummyCallback.js +1 -0
  507. package/build/util/escapeSpecialRegexCharacters.d.ts +6 -0
  508. package/build/util/escapeSpecialRegexCharacters.js +8 -0
  509. package/build/util/eventCallbacks.d.ts +7 -0
  510. package/build/util/eventCallbacks.js +6 -0
  511. package/build/util/expandFatArrows.d.ts +1 -0
  512. package/build/util/expandFatArrows.js +104 -0
  513. package/build/util/findScrollableParent.d.ts +1 -0
  514. package/build/util/findScrollableParent.js +16 -0
  515. package/build/util/getActiveElement.d.ts +1 -0
  516. package/build/util/getActiveElement.js +4 -0
  517. package/build/util/getParentFrameBoundingClientRect.d.ts +1 -0
  518. package/build/util/getParentFrameBoundingClientRect.js +13 -0
  519. package/build/util/getScrollerBoundingClientRect.d.ts +1 -0
  520. package/build/util/getScrollerBoundingClientRect.js +10 -0
  521. package/build/util/getSearchQueryPredicate.d.ts +2 -0
  522. package/build/util/getSearchQueryPredicate.js +54 -0
  523. package/build/util/getSearchQueryPredicate.spec.d.ts +1 -0
  524. package/build/util/getSearchQueryPredicate.spec.js +33 -0
  525. package/build/util/getTopLevelBoundingClientRect.d.ts +1 -0
  526. package/build/util/getTopLevelBoundingClientRect.js +6 -0
  527. package/build/util/getVendorPrefix.d.ts +1 -0
  528. package/build/util/getVendorPrefix.js +22 -0
  529. package/build/util/hasKey.d.ts +4 -0
  530. package/build/util/hasKey.js +14 -0
  531. package/build/util/index.d.ts +55 -0
  532. package/build/util/index.js +55 -0
  533. package/build/util/innerTextTrim.d.ts +6 -0
  534. package/build/util/innerTextTrim.js +10 -0
  535. package/build/util/isArray.d.ts +1 -0
  536. package/build/util/isArray.js +3 -0
  537. package/build/util/isDataRecord.d.ts +1 -0
  538. package/build/util/isDataRecord.js +4 -0
  539. package/build/util/isDefined.d.ts +1 -0
  540. package/build/util/isDefined.js +3 -0
  541. package/build/util/isDigit.d.ts +6 -0
  542. package/build/util/isDigit.js +8 -0
  543. package/build/util/isFunction.d.ts +1 -0
  544. package/build/util/isFunction.js +3 -0
  545. package/build/util/isNonEmptyArray.d.ts +1 -0
  546. package/build/util/isNonEmptyArray.js +3 -0
  547. package/build/util/isNumber.d.ts +1 -0
  548. package/build/util/isNumber.js +3 -0
  549. package/build/util/isObject.d.ts +1 -0
  550. package/build/util/isObject.js +3 -0
  551. package/build/util/isPromise.d.ts +1 -0
  552. package/build/util/isPromise.js +5 -0
  553. package/build/util/isString.d.ts +1 -0
  554. package/build/util/isString.js +3 -0
  555. package/build/util/isTextInputElement.d.ts +1 -0
  556. package/build/util/isTextInputElement.js +3 -0
  557. package/build/util/isTouchDevice.d.ts +1 -0
  558. package/build/util/isTouchDevice.js +6 -0
  559. package/build/util/isTouchEvent.d.ts +2 -0
  560. package/build/util/isTouchEvent.js +43 -0
  561. package/build/util/isUndefined.d.ts +1 -0
  562. package/build/util/isUndefined.js +3 -0
  563. package/build/util/isValidIdentifierName.d.ts +1 -0
  564. package/build/util/isValidIdentifierName.js +4 -0
  565. package/build/util/isValidIdentifierName.spec.d.ts +1 -0
  566. package/build/util/isValidIdentifierName.spec.js +28 -0
  567. package/build/util/onIdleCallback.d.ts +1 -0
  568. package/build/util/onIdleCallback.js +13 -0
  569. package/build/util/parseStyle.d.ts +2 -0
  570. package/build/util/parseStyle.js +22 -0
  571. package/build/util/quote.d.ts +2 -0
  572. package/build/util/quote.js +5 -0
  573. package/build/util/reverseSlice.d.ts +1 -0
  574. package/build/util/reverseSlice.js +10 -0
  575. package/build/util/routeAppend.d.ts +1 -0
  576. package/build/util/routeAppend.js +16 -0
  577. package/build/util/routeAppend.spec.d.ts +1 -0
  578. package/build/util/routeAppend.spec.js +14 -0
  579. package/build/util/scrollElementIntoView.d.ts +1 -0
  580. package/build/util/scrollElementIntoView.js +28 -0
  581. package/build/util/shallowEquals.d.ts +1 -0
  582. package/build/util/shallowEquals.js +30 -0
  583. package/build/util/test/createTestRenderer.d.ts +5 -0
  584. package/build/util/test/createTestRenderer.js +10 -0
  585. package/build/util/throttle.d.ts +9 -0
  586. package/build/util/throttle.js +19 -0
  587. package/build/util/validatedDebounce.d.ts +3 -0
  588. package/build/util/validatedDebounce.js +18 -0
  589. package/build/widgets/AccessorBindings.spec.d.ts +1 -0
  590. package/build/widgets/AccessorBindings.spec.js +40 -0
  591. package/build/widgets/Button.d.ts +57 -0
  592. package/build/widgets/Button.js +105 -0
  593. package/build/widgets/CxCredit.d.ts +11 -0
  594. package/build/widgets/CxCredit.js +25 -0
  595. package/build/widgets/DocumentTitle.d.ts +27 -0
  596. package/build/widgets/DocumentTitle.js +57 -0
  597. package/build/widgets/FlexBox.d.ts +79 -0
  598. package/build/widgets/FlexBox.js +77 -0
  599. package/build/widgets/Heading.d.ts +16 -0
  600. package/build/widgets/Heading.js +24 -0
  601. package/build/widgets/HighlightedSearchText.d.ts +18 -0
  602. package/build/widgets/HighlightedSearchText.js +32 -0
  603. package/build/widgets/HtmlElement.d.ts +46 -0
  604. package/build/widgets/HtmlElement.js +253 -0
  605. package/build/widgets/HtmlElement.spec.d.ts +1 -0
  606. package/build/widgets/HtmlElement.spec.js +38 -0
  607. package/build/widgets/Icon.d.ts +29 -0
  608. package/build/widgets/Icon.js +39 -0
  609. package/build/widgets/List.d.ts +122 -0
  610. package/build/widgets/List.js +510 -0
  611. package/build/widgets/ProgressBar.d.ts +20 -0
  612. package/build/widgets/ProgressBar.js +29 -0
  613. package/build/widgets/Resizer.d.ts +30 -0
  614. package/build/widgets/Resizer.js +111 -0
  615. package/build/widgets/Sandbox.d.ts +40 -0
  616. package/build/widgets/Sandbox.js +54 -0
  617. package/build/widgets/Section.d.ts +52 -0
  618. package/build/widgets/Section.js +93 -0
  619. package/build/widgets/autoFocus.d.ts +1 -0
  620. package/build/widgets/autoFocus.js +9 -0
  621. package/build/widgets/cx.d.ts +2 -0
  622. package/build/widgets/cx.js +53 -0
  623. package/build/widgets/drag-drop/DragHandle.d.ts +12 -0
  624. package/build/widgets/drag-drop/DragHandle.js +23 -0
  625. package/build/widgets/drag-drop/DragSource.d.ts +55 -0
  626. package/build/widgets/drag-drop/DragSource.js +135 -0
  627. package/build/widgets/drag-drop/DropZone.d.ts +103 -0
  628. package/build/widgets/drag-drop/DropZone.js +173 -0
  629. package/build/widgets/drag-drop/index.d.ts +4 -0
  630. package/build/widgets/drag-drop/index.js +4 -0
  631. package/build/widgets/drag-drop/ops.d.ts +55 -0
  632. package/build/widgets/drag-drop/ops.js +292 -0
  633. package/build/widgets/enableAllInternalDependencies.d.ts +1 -0
  634. package/build/widgets/enableAllInternalDependencies.js +10 -0
  635. package/build/widgets/form/Calendar.d.ts +130 -0
  636. package/build/widgets/form/Calendar.js +445 -0
  637. package/build/widgets/form/Checkbox.d.ts +46 -0
  638. package/build/widgets/form/Checkbox.js +157 -0
  639. package/build/widgets/form/ColorField.d.ts +49 -0
  640. package/build/widgets/form/ColorField.js +310 -0
  641. package/build/widgets/form/ColorPicker.d.ts +46 -0
  642. package/build/widgets/form/ColorPicker.js +304 -0
  643. package/build/widgets/form/DateField.d.ts +8 -0
  644. package/build/widgets/form/DateField.js +12 -0
  645. package/build/widgets/form/DateTimeField.d.ts +98 -0
  646. package/build/widgets/form/DateTimeField.js +474 -0
  647. package/build/widgets/form/DateTimePicker.d.ts +17 -0
  648. package/build/widgets/form/DateTimePicker.js +248 -0
  649. package/build/widgets/form/Field.d.ts +140 -0
  650. package/build/widgets/form/Field.js +369 -0
  651. package/build/widgets/form/FieldGroup.d.ts +5 -0
  652. package/build/widgets/form/FieldGroup.js +5 -0
  653. package/build/widgets/form/FieldIcon.d.ts +22 -0
  654. package/build/widgets/form/FieldIcon.js +41 -0
  655. package/build/widgets/form/HelpText.d.ts +6 -0
  656. package/build/widgets/form/HelpText.js +10 -0
  657. package/build/widgets/form/Label.d.ts +27 -0
  658. package/build/widgets/form/Label.js +74 -0
  659. package/build/widgets/form/LabeledContainer.d.ts +30 -0
  660. package/build/widgets/form/LabeledContainer.js +48 -0
  661. package/build/widgets/form/LookupField.d.ts +124 -0
  662. package/build/widgets/form/LookupField.js +907 -0
  663. package/build/widgets/form/MonthField.d.ts +104 -0
  664. package/build/widgets/form/MonthField.js +423 -0
  665. package/build/widgets/form/MonthPicker.d.ts +125 -0
  666. package/build/widgets/form/MonthPicker.js +557 -0
  667. package/build/widgets/form/NumberField.d.ts +63 -0
  668. package/build/widgets/form/NumberField.js +361 -0
  669. package/build/widgets/form/Radio.d.ts +43 -0
  670. package/build/widgets/form/Radio.js +131 -0
  671. package/build/widgets/form/Select.d.ts +40 -0
  672. package/build/widgets/form/Select.js +183 -0
  673. package/build/widgets/form/Slider.d.ts +68 -0
  674. package/build/widgets/form/Slider.js +264 -0
  675. package/build/widgets/form/Switch.d.ts +41 -0
  676. package/build/widgets/form/Switch.js +94 -0
  677. package/build/widgets/form/TextArea.d.ts +20 -0
  678. package/build/widgets/form/TextArea.js +128 -0
  679. package/build/widgets/form/TextField.d.ts +49 -0
  680. package/build/widgets/form/TextField.js +202 -0
  681. package/build/widgets/form/TimeField.d.ts +3 -0
  682. package/build/widgets/form/TimeField.js +8 -0
  683. package/build/widgets/form/TimeList.d.ts +1 -0
  684. package/build/widgets/form/TimeList.js +89 -0
  685. package/build/widgets/form/UploadButton.d.ts +17 -0
  686. package/build/widgets/form/UploadButton.js +163 -0
  687. package/build/widgets/form/ValidationError.d.ts +27 -0
  688. package/build/widgets/form/ValidationError.js +33 -0
  689. package/build/widgets/form/ValidationGroup.d.ts +63 -0
  690. package/build/widgets/form/ValidationGroup.js +58 -0
  691. package/build/widgets/form/ValidationGroup.spec.d.ts +1 -0
  692. package/build/widgets/form/ValidationGroup.spec.js +62 -0
  693. package/build/widgets/form/Validator.d.ts +8 -0
  694. package/build/widgets/form/Validator.js +19 -0
  695. package/build/widgets/form/Wheel.d.ts +61 -0
  696. package/build/widgets/form/Wheel.js +178 -0
  697. package/build/widgets/form/index.d.ts +28 -0
  698. package/build/widgets/form/index.js +28 -0
  699. package/build/widgets/grid/Grid.d.ts +517 -0
  700. package/build/widgets/grid/Grid.js +2756 -0
  701. package/build/widgets/grid/GridCell.d.ts +68 -0
  702. package/build/widgets/grid/GridCell.js +61 -0
  703. package/build/widgets/grid/GridCellEditor.d.ts +10 -0
  704. package/build/widgets/grid/GridCellEditor.js +29 -0
  705. package/build/widgets/grid/GridRow.d.ts +87 -0
  706. package/build/widgets/grid/GridRow.js +192 -0
  707. package/build/widgets/grid/GridRowLine.d.ts +27 -0
  708. package/build/widgets/grid/GridRowLine.js +24 -0
  709. package/build/widgets/grid/Pagination.d.ts +23 -0
  710. package/build/widgets/grid/Pagination.js +73 -0
  711. package/build/widgets/grid/TreeNode.d.ts +42 -0
  712. package/build/widgets/grid/TreeNode.js +82 -0
  713. package/build/widgets/grid/createGridCellEditor.d.ts +2 -0
  714. package/build/widgets/grid/createGridCellEditor.js +6 -0
  715. package/build/widgets/grid/index.d.ts +10 -0
  716. package/build/widgets/grid/index.js +10 -0
  717. package/build/widgets/icons/calendar.d.ts +2 -0
  718. package/build/widgets/icons/calendar.js +5 -0
  719. package/build/widgets/icons/check.d.ts +2 -0
  720. package/build/widgets/icons/check.js +5 -0
  721. package/build/widgets/icons/clear.d.ts +2 -0
  722. package/build/widgets/icons/clear.js +5 -0
  723. package/build/widgets/icons/close.d.ts +2 -0
  724. package/build/widgets/icons/close.js +5 -0
  725. package/build/widgets/icons/cx.d.ts +2 -0
  726. package/build/widgets/icons/cx.js +5 -0
  727. package/build/widgets/icons/drop-down.d.ts +2 -0
  728. package/build/widgets/icons/drop-down.js +5 -0
  729. package/build/widgets/icons/file.d.ts +2 -0
  730. package/build/widgets/icons/file.js +5 -0
  731. package/build/widgets/icons/folder-open.d.ts +2 -0
  732. package/build/widgets/icons/folder-open.js +5 -0
  733. package/build/widgets/icons/folder.d.ts +2 -0
  734. package/build/widgets/icons/folder.js +5 -0
  735. package/build/widgets/icons/forward.d.ts +2 -0
  736. package/build/widgets/icons/forward.js +5 -0
  737. package/build/widgets/icons/index.d.ts +12 -0
  738. package/build/widgets/icons/index.js +12 -0
  739. package/build/widgets/icons/loading.d.ts +2 -0
  740. package/build/widgets/icons/loading.js +14 -0
  741. package/build/widgets/icons/menu.d.ts +2 -0
  742. package/build/widgets/icons/menu.js +5 -0
  743. package/build/widgets/icons/pixel-picker.d.ts +2 -0
  744. package/build/widgets/icons/pixel-picker.js +5 -0
  745. package/build/widgets/icons/registry.d.ts +9 -0
  746. package/build/widgets/icons/registry.js +40 -0
  747. package/build/widgets/icons/search.d.ts +2 -0
  748. package/build/widgets/icons/search.js +5 -0
  749. package/build/widgets/icons/sort-asc.d.ts +2 -0
  750. package/build/widgets/icons/sort-asc.js +5 -0
  751. package/build/widgets/icons/square.d.ts +2 -0
  752. package/build/widgets/icons/square.js +5 -0
  753. package/build/widgets/index.d.ts +36 -0
  754. package/build/widgets/index.js +37 -0
  755. package/build/widgets/nav/Link.d.ts +6 -0
  756. package/build/widgets/nav/Link.js +6 -0
  757. package/build/widgets/nav/LinkButton.d.ts +45 -0
  758. package/build/widgets/nav/LinkButton.js +110 -0
  759. package/build/widgets/nav/Menu.d.ts +48 -0
  760. package/build/widgets/nav/Menu.js +336 -0
  761. package/build/widgets/nav/MenuItem.d.ts +68 -0
  762. package/build/widgets/nav/MenuItem.js +364 -0
  763. package/build/widgets/nav/MenuSpacer.d.ts +13 -0
  764. package/build/widgets/nav/MenuSpacer.js +11 -0
  765. package/build/widgets/nav/RedirectRoute.d.ts +14 -0
  766. package/build/widgets/nav/RedirectRoute.js +30 -0
  767. package/build/widgets/nav/Route.d.ts +40 -0
  768. package/build/widgets/nav/Route.js +94 -0
  769. package/build/widgets/nav/Route.spec.d.ts +1 -0
  770. package/build/widgets/nav/Route.spec.js +15 -0
  771. package/build/widgets/nav/Scroller.d.ts +55 -0
  772. package/build/widgets/nav/Scroller.js +125 -0
  773. package/build/widgets/nav/Submenu.d.ts +3 -0
  774. package/build/widgets/nav/Submenu.js +3 -0
  775. package/build/widgets/nav/Tab.d.ts +40 -0
  776. package/build/widgets/nav/Tab.js +66 -0
  777. package/build/widgets/nav/index.d.ts +10 -0
  778. package/build/widgets/nav/index.js +10 -0
  779. package/build/widgets/overlay/ContextMenu.d.ts +9 -0
  780. package/build/widgets/overlay/ContextMenu.js +31 -0
  781. package/build/widgets/overlay/Dropdown.d.ts +120 -0
  782. package/build/widgets/overlay/Dropdown.js +522 -0
  783. package/build/widgets/overlay/FlyweightTooltipTracker.d.ts +22 -0
  784. package/build/widgets/overlay/FlyweightTooltipTracker.js +39 -0
  785. package/build/widgets/overlay/MsgBox.d.ts +25 -0
  786. package/build/widgets/overlay/MsgBox.js +67 -0
  787. package/build/widgets/overlay/Overlay.d.ts +183 -0
  788. package/build/widgets/overlay/Overlay.js +597 -0
  789. package/build/widgets/overlay/Toast.d.ts +27 -0
  790. package/build/widgets/overlay/Toast.js +76 -0
  791. package/build/widgets/overlay/Tooltip.d.ts +55 -0
  792. package/build/widgets/overlay/Tooltip.js +307 -0
  793. package/build/widgets/overlay/Window.d.ts +65 -0
  794. package/build/widgets/overlay/Window.js +154 -0
  795. package/build/widgets/overlay/alerts.d.ts +12 -0
  796. package/build/widgets/overlay/alerts.js +31 -0
  797. package/build/widgets/overlay/captureMouse.d.ts +57 -0
  798. package/build/widgets/overlay/captureMouse.js +147 -0
  799. package/build/widgets/overlay/createHotPromiseWindowFactory.d.ts +10 -0
  800. package/build/widgets/overlay/createHotPromiseWindowFactory.js +54 -0
  801. package/build/widgets/overlay/index.d.ts +11 -0
  802. package/build/widgets/overlay/index.js +11 -0
  803. package/build/widgets/overlay/tooltip-ops.d.ts +73 -0
  804. package/build/widgets/overlay/tooltip-ops.js +34 -0
  805. package/dist/manifest.js +844 -844
  806. package/dist/util.js +0 -1
  807. package/dist/widgets.js +1 -2
  808. package/package.json +3 -2
@@ -0,0 +1,2756 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Binding } from "../../data/Binding";
3
+ import { getAccessor } from "../../data/getAccessor";
4
+ import { getSelector } from "../../data/getSelector";
5
+ import { isSelector } from "../../data/isSelector";
6
+ import { ArrayAdapter } from "../../ui/adapter/ArrayAdapter";
7
+ import { GroupAdapter } from "../../ui/adapter/GroupAdapter";
8
+ import { batchUpdates } from "../../ui/batchUpdates";
9
+ import { ContainerBase } from "../../ui/Container";
10
+ import { Cx } from "../../ui/Cx";
11
+ import { FocusManager, offFocusOut, oneFocusOut, unfocusElement } from "../../ui/FocusManager";
12
+ import { Format } from "../../ui/Format";
13
+ import { InstanceCache } from "../../ui/Instance";
14
+ import { Localization } from "../../ui/Localization";
15
+ import { PureContainer, PureContainerBase } from "../../ui/PureContainer";
16
+ import { RenderingContext } from "../../ui/RenderingContext";
17
+ import { ResizeManager } from "../../ui/ResizeManager";
18
+ import { Selection } from "../../ui/selection/Selection";
19
+ import { StaticText } from "../../ui/StaticText";
20
+ import { getContent, VDOM, Widget } from "../../ui/Widget";
21
+ import { Console } from "../../util/Console";
22
+ import { debounce } from "../../util/debounce";
23
+ import { closest, findFirstChild } from "../../util/DOM";
24
+ import { findScrollableParent } from "../../util/findScrollableParent";
25
+ import { getActiveElement } from "../../util/getActiveElement";
26
+ import { getParentFrameBoundingClientRect } from "../../util/getParentFrameBoundingClientRect";
27
+ import { getTopLevelBoundingClientRect } from "../../util/getTopLevelBoundingClientRect";
28
+ import { isArray } from "../../util/isArray";
29
+ import { isDefined } from "../../util/isDefined";
30
+ import { isNonEmptyArray } from "../../util/isNonEmptyArray";
31
+ import { isNumber } from "../../util/isNumber";
32
+ import { isObject } from "../../util/isObject";
33
+ import { isString } from "../../util/isString";
34
+ import { isTextInputElement } from "../../util/isTextInputElement";
35
+ import { KeyCode } from "../../util/KeyCode";
36
+ import { parseStyle } from "../../util/parseStyle";
37
+ import { scrollElementIntoView } from "../../util/scrollElementIntoView";
38
+ import { shallowEquals } from "../../util/shallowEquals";
39
+ import { SubscriberList } from "../../util/SubscriberList";
40
+ import { ddDetect, ddMouseDown, initiateDragDrop, registerDropZone, } from "../drag-drop/ops";
41
+ import { HtmlElement } from "../HtmlElement";
42
+ import DropDownIcon from "../icons/sort-asc";
43
+ import { captureMouse2, getCursorPos } from "../overlay/captureMouse";
44
+ import { tooltipMouseLeave, tooltipMouseMove } from "../overlay/tooltip-ops";
45
+ import { createGridCellEditor } from "./createGridCellEditor";
46
+ import { GridRow, GridRowComponent } from "./GridRow";
47
+ export class Grid extends ContainerBase {
48
+ constructor(config) {
49
+ super(config);
50
+ }
51
+ declareData(...args) {
52
+ let selection = this.selection.configureWidget(this);
53
+ super.declareData(...args, {
54
+ records: undefined,
55
+ sorters: undefined,
56
+ preSorters: undefined,
57
+ scrollable: undefined,
58
+ sortField: undefined,
59
+ sortDirection: undefined,
60
+ emptyText: undefined,
61
+ dragSource: { structured: true },
62
+ dropZone: { structured: true },
63
+ filterParams: { structured: true },
64
+ groupingParams: { structured: true },
65
+ scrollResetParams: { structured: true },
66
+ page: undefined,
67
+ totalRecordCount: undefined,
68
+ tabIndex: undefined,
69
+ columnParams: { structured: true },
70
+ }, selection);
71
+ }
72
+ init() {
73
+ if (this.recordAlias)
74
+ this.recordName = this.recordAlias;
75
+ if (this.indexAlias)
76
+ this.indexName = this.indexAlias;
77
+ if (this.infinite) {
78
+ this.buffered = true;
79
+ this.remoteSort = true;
80
+ }
81
+ if (this.buffered)
82
+ this.scrollable = true;
83
+ this.recordsAccessor = getAccessor(this.records);
84
+ this.selection = Selection.create(this.selection, {
85
+ records: this.records,
86
+ });
87
+ if (!this.selection.isDummy || this.onRowClick || this.onRowDoubleClick)
88
+ this.selectable = true;
89
+ if (this.focusable == null)
90
+ this.focusable = !this.selection.isDummy || this.cellEditable;
91
+ super.init();
92
+ }
93
+ initState(context, instance) {
94
+ instance.state = {
95
+ colWidth: {},
96
+ lockedColWidth: {},
97
+ dimensionsVersion: 0,
98
+ disableDefaultSort: false,
99
+ };
100
+ instance.v = 0;
101
+ if (this.infinite)
102
+ instance.buffer = {
103
+ records: [],
104
+ totalRecordCount: 0,
105
+ page: 1,
106
+ };
107
+ }
108
+ applyParentStore(instance) {
109
+ super.applyParentStore(instance);
110
+ // force prepareData to execute again and propagate the store change to the records
111
+ if (instance.cached)
112
+ delete instance.cached.rawData;
113
+ }
114
+ createRowTemplate(context, columnParams, instance, groupingData) {
115
+ var row = this.row || {};
116
+ let columns = this.columns;
117
+ if (this.onGetColumns) {
118
+ let result = instance.invoke("onGetColumns", columnParams, instance);
119
+ if (isArray(result))
120
+ columns = result;
121
+ else
122
+ row = result;
123
+ }
124
+ if (columns)
125
+ row.line1 = {
126
+ columns,
127
+ };
128
+ row.hasSortableColumns = false;
129
+ row.hasResizableColumns = false;
130
+ row.hasMergedCells = false;
131
+ row.mergedColumns = [];
132
+ let aggregates = {};
133
+ let showFooter = false;
134
+ let lines = [];
135
+ for (let i = 0; i < 10; i++) {
136
+ let l = row["line" + i];
137
+ if (l) {
138
+ if (isArray(l.columns))
139
+ for (let c = 0; c < l.columns.length; c++)
140
+ l.columns[c].uniqueColumnId = `l${i}-${l.columns[c].key || c}`;
141
+ lines.push(l);
142
+ }
143
+ }
144
+ row.header = PureContainer.create({
145
+ items: GridColumnHeaderLine.create(lines),
146
+ });
147
+ row.header.items.forEach((line) => {
148
+ line.items.forEach((c, index) => {
149
+ if (c.sortable)
150
+ row.hasSortableColumns = true;
151
+ if (c.mergeCells) {
152
+ if (row.header.items.length > 1)
153
+ Console.warn("Merged columns are only supported in grids in which rows have only one line of cells.");
154
+ else {
155
+ row.hasMergedCells = true;
156
+ row.mergedColumns.push({ uniqueColumnId: c.uniqueColumnId, index, mode: c.mergeCells });
157
+ }
158
+ }
159
+ if (c.resizable ||
160
+ (c.header && c.header.resizable) ||
161
+ (c.header1 && c.header1.resizable) ||
162
+ (c.header2 && c.header2.resizable) ||
163
+ (c.header3 && c.header3.resizable))
164
+ row.hasResizableColumns = true;
165
+ if (c.aggregate && c.aggregateAlias && (c.aggregateField || isDefined(c.aggregateValue))) {
166
+ aggregates[c.aggregateAlias] = {
167
+ value: isDefined(c.aggregateValue)
168
+ ? c.aggregateValue
169
+ : isDefined(c.value)
170
+ ? c.value
171
+ : c.aggregateField
172
+ ? { bind: this.recordName + "." + c.aggregateField }
173
+ : null,
174
+ weight: c.weight != null
175
+ ? c.weight
176
+ : c.weightField && {
177
+ bind: this.recordName + "." + c.weightField,
178
+ },
179
+ type: c.aggregate,
180
+ };
181
+ }
182
+ else if (c.footer && !showFooter) {
183
+ showFooter = true;
184
+ }
185
+ });
186
+ });
187
+ //add default footer if some columns have aggregates and grouping is not defined
188
+ if (!groupingData && (Object.keys(aggregates).length > 0 || this.fixedFooter || showFooter))
189
+ groupingData = [
190
+ {
191
+ key: {},
192
+ showFooter: true,
193
+ },
194
+ ];
195
+ let { grouping, showHeader } = this.resolveGrouping(groupingData);
196
+ this.showHeader = showHeader;
197
+ if (this.fixedFooter && isNonEmptyArray(grouping)) {
198
+ grouping[0].showFooter = true;
199
+ if (grouping[0].key && Object.keys(grouping[0].key).length > 0)
200
+ Console.warn("First grouping level in grids with a fixed footer must group all data. The key field should be omitted.");
201
+ }
202
+ instance.dataAdapter =
203
+ this.dataAdapter instanceof ArrayAdapter
204
+ ? this.dataAdapter
205
+ : GroupAdapter.create({
206
+ recordsAccessor: this.recordsAccessor,
207
+ keyField: this.keyField,
208
+ aggregates: aggregates,
209
+ recordName: this.recordName,
210
+ indexName: this.indexName,
211
+ sortOptions: this.sortOptions,
212
+ groupings: grouping,
213
+ preserveOrder: this.preserveGroupOrder,
214
+ }, this.dataAdapter);
215
+ instance.dataAdapter.initInstance(context, instance);
216
+ return Widget.create(GridRow, {
217
+ class: this.CSS.element(this.baseClass, "data"),
218
+ className: this.rowClass,
219
+ style: this.rowStyle,
220
+ recordName: this.recordName,
221
+ hoverId: this.rowHoverId,
222
+ ...row,
223
+ });
224
+ }
225
+ prepareData(context, instance) {
226
+ let { data, state, cached, row } = instance;
227
+ let grouping = this.grouping;
228
+ if (this.onGetGrouping) {
229
+ if (!cached.data || cached.data.groupingParams !== data.groupingParams)
230
+ grouping = instance.invoke("onGetGrouping", data.groupingParams, instance);
231
+ else
232
+ grouping = cached.grouping;
233
+ }
234
+ let groupingChanged = instance.cache("grouping", grouping);
235
+ if (instance.cache("columnParams", data.columnParams) || groupingChanged || !row) {
236
+ row = instance.row = this.createRowTemplate(context, data.columnParams, instance, grouping);
237
+ }
238
+ data.version = instance.v++;
239
+ if (!this.infinite)
240
+ data.totalRecordCount = isArray(data.records) ? data.records.length : 0;
241
+ else {
242
+ if (isNumber(data.totalRecordCount))
243
+ instance.buffer.totalRecordCount = data.totalRecordCount;
244
+ else
245
+ data.totalRecordCount = instance.buffer.totalRecordCount;
246
+ if (isDefined(data.records))
247
+ instance.buffer.records = data.records;
248
+ else
249
+ data.records = instance.buffer.records;
250
+ if (isNumber(data.page))
251
+ instance.buffer.page = data.page;
252
+ else
253
+ data.page = instance.buffer.page;
254
+ data.offset = (data.page - 1) * this.pageSize;
255
+ }
256
+ if (!isArray(data.records))
257
+ data.records = [];
258
+ if (state.sorters && !isDefined(this.sorters))
259
+ data.sorters = state.sorters;
260
+ let sortField = null;
261
+ if (isDefined(this.sortField) && isDefined(this.sortDirection)) {
262
+ let sorter = {
263
+ field: data.sortField,
264
+ direction: data.sortDirection,
265
+ };
266
+ sortField = data.sortField;
267
+ data.sorters = [sorter];
268
+ }
269
+ let skipDefaultSorting = this.clearableSort && instance.state.disableDefaultSort;
270
+ if (!skipDefaultSorting && !isNonEmptyArray(data.sorters) && this.defaultSortField) {
271
+ let sorter = {
272
+ field: this.defaultSortField,
273
+ direction: this.defaultSortDirection || "ASC",
274
+ };
275
+ sortField = this.defaultSortField;
276
+ data.sorters = [sorter];
277
+ }
278
+ if (sortField) {
279
+ for (let l = 1; l < 10; l++) {
280
+ let line = instance.row[`line${l}`];
281
+ let sortColumn = line && line.columns && line.columns.find((c) => c.field == sortField);
282
+ if (sortColumn) {
283
+ data.sorters[0].value = sortColumn.sortValue || sortColumn.value;
284
+ data.sorters[0].comparer = sortColumn.comparer;
285
+ data.sorters[0].sortOptions = sortColumn.sortOptions;
286
+ break;
287
+ }
288
+ }
289
+ }
290
+ let headerMode = this.headerMode;
291
+ if (this.headerMode == null) {
292
+ if (this.scrollable || row.hasSortableColumns || row.hasResizableColumns)
293
+ headerMode = "default";
294
+ else
295
+ headerMode = "plain";
296
+ }
297
+ let border = this.border;
298
+ if (this.showBorder || (border == null && this.scrollable))
299
+ border = true;
300
+ let dragMode = false;
301
+ if (data.dragSource)
302
+ dragMode = data.dragSource.mode || "move";
303
+ let dropMode = data.dropZone && data.dropZone.mode;
304
+ if (this.onDrop && !dropMode)
305
+ dropMode = "preview";
306
+ data.dropMode = dropMode;
307
+ data.stateMods = {
308
+ selectable: this.selectable,
309
+ "cell-editable": this.cellEditable,
310
+ scrollable: data.scrollable,
311
+ buffered: this.buffered,
312
+ ["header-" + headerMode]: true,
313
+ border: border,
314
+ vlines: this.vlines,
315
+ ["drag-" + dragMode]: dragMode,
316
+ ["drop-" + dropMode]: dropMode,
317
+ resizable: row.hasResizableColumns,
318
+ };
319
+ super.prepareData(context, instance);
320
+ instance.records = this.mapRecords(context, instance);
321
+ //tree adapters can have additional (child) records, filtering also affects actual record count
322
+ if (instance.records && !this.infinite) {
323
+ //apply record count after filtering
324
+ data.totalRecordCount = instance.records.length;
325
+ //recheck if there are any actual records
326
+ //when grouping is enabled group header/footer are always in
327
+ if (instance.records.length < 5) {
328
+ data.empty = true;
329
+ for (let i = 0; i < instance.records.length; i++)
330
+ if (instance.records[i].type == "data") {
331
+ data.empty = false;
332
+ break;
333
+ }
334
+ }
335
+ else
336
+ data.empty = data.totalRecordCount == 0;
337
+ }
338
+ else
339
+ data.empty = data.totalRecordCount == 0;
340
+ if (this.onCreateIsRecordSelectable) {
341
+ instance.isRecordSelectable = instance.invoke("onCreateIsRecordSelectable", null, instance);
342
+ }
343
+ if (this.onCreateIsRecordDraggable) {
344
+ instance.isRecordDraggable = instance.invoke("onCreateIsRecordDraggable", null, instance);
345
+ }
346
+ if (this.onTrackMappedRecords) {
347
+ instance.invoke("onTrackMappedRecords", instance.records, instance);
348
+ }
349
+ }
350
+ initInstance(context, instance) {
351
+ instance.fixedHeaderResizeEvent = new SubscriberList();
352
+ super.initInstance(context, instance);
353
+ }
354
+ explore(context, instance) {
355
+ context.push("parentPositionChangeEvent", instance.fixedHeaderResizeEvent);
356
+ instance.hoverSync = context.hoverSync;
357
+ super.explore(context, instance);
358
+ instance.header = instance.getChild(context, instance.row.header, "header");
359
+ instance.header.scheduleExploreIfVisible(context);
360
+ let { store } = instance;
361
+ instance.isSelected = this.selection.getIsSelectedDelegate(store);
362
+ //do not process rows in buffered mode or cached mode if nothing has changed;
363
+ if (!this.buffered && (!this.cached || instance.shouldUpdate)) {
364
+ for (let i = 0; i < instance.records.length; i++) {
365
+ let record = instance.records[i];
366
+ if (record.type == "data") {
367
+ let row = (record.row = instance.getChild(context, instance.row, record.key, record.store));
368
+ row.selected = instance.isSelected(record.data, record.index);
369
+ let changed = false;
370
+ if (row.cache("selected", row.selected))
371
+ changed = true;
372
+ if (row.cache("recordData", record.data))
373
+ changed = true;
374
+ if (this.cached && !changed && !row.childStateDirty)
375
+ row.shouldUpdate = false;
376
+ else
377
+ row.scheduleExploreIfVisible(context);
378
+ }
379
+ }
380
+ }
381
+ }
382
+ exploreCleanup(context, instance) {
383
+ context.pop("parentPositionChangeEvent");
384
+ let fixedColumnCount = 0, visibleColumns = [];
385
+ instance.header.children.forEach((line) => {
386
+ line.children.forEach((col) => {
387
+ if (col.data.fixed)
388
+ fixedColumnCount++;
389
+ visibleColumns.push(col.widget);
390
+ });
391
+ });
392
+ instance.visibleColumns = visibleColumns;
393
+ instance.hasFixedColumns = fixedColumnCount > 0;
394
+ instance.fixedColumnCount = fixedColumnCount;
395
+ if (fixedColumnCount > 0) {
396
+ instance.data.classNames += ` ${instance.widget.CSS.state("fixed-columns")}`;
397
+ }
398
+ }
399
+ resolveGrouping(grouping) {
400
+ if (grouping) {
401
+ if (!isArray(grouping)) {
402
+ if (isString(grouping) || isObject(grouping))
403
+ grouping = [grouping];
404
+ else
405
+ throw new Error("Dynamic grouping should be an array of grouping objects.");
406
+ }
407
+ grouping = grouping.map((g, i) => {
408
+ let group;
409
+ if (isString(g))
410
+ group = {
411
+ key: {
412
+ [g]: {
413
+ bind: this.recordName + "." + g,
414
+ },
415
+ },
416
+ showHeader: !this.scrollable && i == grouping.length - 1,
417
+ showFooter: true,
418
+ caption: { bind: `$group.${g}` },
419
+ text: { bind: `${this.recordName}.${g}` },
420
+ };
421
+ else
422
+ group = {
423
+ ...g,
424
+ };
425
+ if (group.caption)
426
+ group.caption = getSelector(group.caption);
427
+ return group;
428
+ });
429
+ }
430
+ let showHeader = !isArray(grouping) || !grouping.some((g) => g.showHeader);
431
+ return { showHeader, grouping };
432
+ }
433
+ groupBy(groupingData, options) {
434
+ let { grouping, showHeader } = this.resolveGrouping(groupingData);
435
+ this.grouping = grouping;
436
+ if (options?.autoConfigure)
437
+ this.showHeader = showHeader;
438
+ this.update();
439
+ }
440
+ render(context, instance, key) {
441
+ let { data, hasFixedColumns } = instance;
442
+ let fixedHeader = data.scrollable && this.showHeader && this.renderHeader(context, instance, "header", true, false);
443
+ let fixedColumnsFixedHeader = data.scrollable &&
444
+ this.showHeader &&
445
+ hasFixedColumns &&
446
+ this.renderHeader(context, instance, "header", true, true);
447
+ if (!this.buffered)
448
+ this.renderRows(context, instance);
449
+ if (this.fixedFooter)
450
+ this.renderFixedFooter(context, instance);
451
+ let header = this.showHeader && this.renderHeader(context, instance, "header", false, false);
452
+ let fixedColumnsHeader = this.showHeader && hasFixedColumns && this.renderHeader(context, instance, "header", false, true);
453
+ return (_jsx(GridComponent, { instance: instance, data: instance.data, shouldUpdate: instance.shouldUpdate, header: header, fixedColumnsHeader: fixedColumnsHeader, fixedColumnsFixedHeader: fixedColumnsFixedHeader, fixedHeader: fixedHeader, fixedFooter: instance.fixedFooterVDOM, fixedColumnsFixedFooter: instance.fixedColumnsFixedFooterVDOM, children: this.renderChildren(context, instance) }, key));
454
+ }
455
+ renderResizer(instance, hdinst, header, colIndex, forPreviousColumn) {
456
+ let { widget } = instance;
457
+ let { CSS, baseClass } = widget;
458
+ let hdwidget = hdinst.widget;
459
+ let resizerClassName = "col-resizer";
460
+ if (forPreviousColumn)
461
+ resizerClassName += "-prev-col";
462
+ return (_jsx("div", { className: CSS.element(baseClass, resizerClassName), onClick: (e) => {
463
+ e.stopPropagation();
464
+ }, "data-unique-col-id": hdwidget.uniqueColumnId, onMouseDown: (e) => {
465
+ if (e.buttons != 1)
466
+ return;
467
+ let resizeOverlayEl = document.createElement("div");
468
+ let gridEl = e.target.parentElement.parentElement.parentElement.parentElement
469
+ .parentElement.parentElement;
470
+ let uniqueColId = e.currentTarget.dataset.uniqueColId;
471
+ // if we use fixed columns, rhs resizer of the last fixed column is within regular columns header tbody
472
+ let headerCell = findFirstChild(gridEl, (el) => el.tagName == "TH" &&
473
+ el.dataset &&
474
+ el.dataset.uniqueColId == uniqueColId);
475
+ let initialWidth = headerCell.offsetWidth;
476
+ let initialPosition = getCursorPos(e);
477
+ resizeOverlayEl.className = CSS.element(baseClass, "resize-overlay");
478
+ resizeOverlayEl.style.width = `${initialWidth}px`;
479
+ resizeOverlayEl.style.left = `${headerCell.getBoundingClientRect().left - gridEl.getBoundingClientRect().left}px`;
480
+ gridEl.appendChild(resizeOverlayEl);
481
+ captureMouse2(e, {
482
+ onMouseMove: (e) => {
483
+ let cursor = getCursorPos(e);
484
+ let width = Math.max(30, Math.round(initialWidth + cursor.clientX - initialPosition.clientX));
485
+ resizeOverlayEl.style.width = `${width}px`;
486
+ },
487
+ onMouseUp: (e) => {
488
+ if (!resizeOverlayEl)
489
+ return; //dblclick
490
+ let width = resizeOverlayEl.offsetWidth;
491
+ hdinst.assignedWidth = width;
492
+ gridEl.removeChild(resizeOverlayEl);
493
+ resizeOverlayEl = null;
494
+ if (widget.onColumnResize)
495
+ instance.invoke("onColumnResize", { width, column: hdwidget }, hdinst);
496
+ header.set("width", width);
497
+ instance.setState({
498
+ dimensionsVersion: instance.state.dimensionsVersion + 1,
499
+ colWidth: {
500
+ ...instance.state.colWidth,
501
+ [hdwidget.uniqueColumnId]: width,
502
+ },
503
+ });
504
+ },
505
+ onDblClick: () => {
506
+ let table = gridEl.querySelector("table");
507
+ let parentEl = table.parentElement;
508
+ let tableClone = table.cloneNode(true);
509
+ tableClone.childNodes.forEach((tbody) => {
510
+ tbody.childNodes.forEach((tr) => {
511
+ tr.childNodes.forEach((td, index) => {
512
+ if (index == colIndex) {
513
+ td.style.maxWidth = null;
514
+ td.style.minWidth = null;
515
+ td.style.width = "auto";
516
+ }
517
+ else {
518
+ td.style.display = "none";
519
+ }
520
+ });
521
+ });
522
+ });
523
+ tableClone.style.position = "absolute";
524
+ tableClone.style.visibility = "hidden";
525
+ tableClone.style.top = "0";
526
+ tableClone.style.left = "0";
527
+ tableClone.style.width = "auto";
528
+ parentEl.appendChild(tableClone);
529
+ let width = tableClone.offsetWidth;
530
+ parentEl.removeChild(tableClone);
531
+ header.set("width", width);
532
+ instance.setState({
533
+ dimensionsVersion: instance.state.dimensionsVersion + 1,
534
+ colWidth: {
535
+ ...instance.state.colWidth,
536
+ [hdwidget.uniqueColumnId]: width,
537
+ },
538
+ });
539
+ },
540
+ });
541
+ } }));
542
+ }
543
+ renderHeader(context, instance, key, fixed, fixedColumns) {
544
+ let { data, widget, header } = instance;
545
+ let { CSS, baseClass } = widget;
546
+ let headerRows = [];
547
+ if (!header)
548
+ return null;
549
+ let skip = {};
550
+ let lineIndex = 0;
551
+ header.children.forEach((line) => {
552
+ let empty = [true, true, true];
553
+ let result = [[], [], []];
554
+ line.children.forEach((hdinst, colIndex) => {
555
+ let hdwidget = hdinst.widget;
556
+ for (let l = 0; l < 3; l++) {
557
+ let colKey = `${lineIndex + l}-${colIndex}`;
558
+ if (skip[colKey])
559
+ continue;
560
+ if (Boolean(hdinst.data.fixed) != fixedColumns)
561
+ continue;
562
+ let header = hdinst.components[`header${l + 1}`];
563
+ let colSpan, rowSpan, style, cls, mods = [], content, sortIcon, tool;
564
+ let resizer = null, prevColumnResizer = null;
565
+ if (header) {
566
+ empty[l] = false;
567
+ if (header.widget.align)
568
+ mods.push("aligned-" + header.widget.align);
569
+ else if (hdwidget.align)
570
+ mods.push("aligned-" + hdwidget.align);
571
+ if (hdwidget.sortable && header.widget.allowSorting) {
572
+ mods.push("sortable");
573
+ if (data.sorters && data.sorters[0].field == (hdwidget.sortField || hdwidget.field)) {
574
+ mods.push("sorted-" + data.sorters[0].direction.toLowerCase());
575
+ sortIcon = _jsx(DropDownIcon, { className: CSS.element(baseClass, "column-sort-icon") });
576
+ }
577
+ }
578
+ let uniqueColumnId = header.data.colSpan > 1 ? null : hdwidget.uniqueColumnId;
579
+ style = header.data.style;
580
+ let customWidth = header.data.width ||
581
+ instance.state.colWidth[uniqueColumnId] ||
582
+ header.data.defaultWidth ||
583
+ instance.state.lockedColWidth[uniqueColumnId];
584
+ if (customWidth) {
585
+ if (instance.state.colWidth[uniqueColumnId] != customWidth)
586
+ instance.state.colWidth[uniqueColumnId] = customWidth;
587
+ let s = `${customWidth}px`;
588
+ style = {
589
+ ...style,
590
+ width: s,
591
+ minWidth: s,
592
+ maxWidth: s,
593
+ };
594
+ }
595
+ if (header.data.classNames)
596
+ cls = header.data.classNames;
597
+ content = header.render(context);
598
+ if (header.components && header.components.tool) {
599
+ tool = (_jsx("div", { className: CSS.element(baseClass, "col-header-tool"), children: getContent(header.components.tool.render(context)) }));
600
+ mods.push("tool");
601
+ }
602
+ if (header.data.colSpan > 1 || header.data.rowSpan > 1) {
603
+ colSpan = header.data.colSpan;
604
+ rowSpan = header.data.rowSpan;
605
+ for (let r = 0; r < header.data.rowSpan; r++)
606
+ for (let c = 0; c < header.data.colSpan; c++)
607
+ skip[`${lineIndex + l + r}-${colIndex + c}`] = true;
608
+ }
609
+ if ((hdwidget.resizable || header.data.resizable) && header.data.colSpan < 2) {
610
+ resizer = this.renderResizer(instance, hdinst, header, colIndex);
611
+ }
612
+ if (colIndex > 0) {
613
+ let hdinstPrev = line.children[colIndex - 1];
614
+ let prevLine = 3;
615
+ let headerPrev;
616
+ while (!headerPrev && prevLine >= 0) {
617
+ headerPrev = hdinstPrev.components[`header${prevLine + 1}`];
618
+ prevLine--;
619
+ }
620
+ if ((hdinstPrev.widget.resizable || headerPrev?.data?.resizable) &&
621
+ headerPrev?.data?.colSpan < 2) {
622
+ prevColumnResizer = this.renderResizer(instance, hdinstPrev, headerPrev, colIndex - 1, true);
623
+ }
624
+ }
625
+ }
626
+ cls = CSS.element(baseClass, "col-header", mods) + (cls ? " " + cls : "");
627
+ let onContextMenu;
628
+ if (this.onColumnContextMenu)
629
+ onContextMenu = (e) => instance.invoke("onColumnContextMenu", e, hdinst);
630
+ result[l].push(_jsxs("th", { colSpan: colSpan, rowSpan: rowSpan, className: cls, style: style, onMouseDown: ddMouseDown, onMouseMove: (e) => this.onHeaderMouseMove(e, hdwidget, hdinst, instance, l), onMouseLeave: (e) => this.onHeaderMouseLeave(e, hdinst, l), onClick: (e) => this.onHeaderClick(e, hdwidget, instance, l), onContextMenu: onContextMenu, "data-unique-col-id": colSpan > 1 ? null : hdwidget.uniqueColumnId, children: [getContent(content), sortIcon, tool, prevColumnResizer, resizer] }, colIndex));
631
+ }
632
+ });
633
+ result = result.filter((_, i) => !empty[i]);
634
+ lineIndex += result.length;
635
+ if (result[0]) {
636
+ if (fixed && !fixedColumns) {
637
+ result[0].push(_jsx("th", { rowSpan: result.length, className: CSS.element(baseClass, "col-header") }, "dummy"));
638
+ }
639
+ headerRows.push(...result.map((h, i) => _jsx("tr", { children: h }, `${lineIndex}-${i}`)));
640
+ }
641
+ });
642
+ if (headerRows.length == 0)
643
+ return null;
644
+ return (_jsx("tbody", { className: CSS.element(baseClass, "header"), children: headerRows }, "h" + key));
645
+ }
646
+ onHeaderMouseMove(e, column, columnInstance, gridInstance, headerLine) {
647
+ let { baseClass, CSS } = gridInstance.widget;
648
+ if (columnInstance.data.fixed)
649
+ return;
650
+ let headerInstance = columnInstance.components[`header${headerLine + 1}`];
651
+ if (!headerInstance)
652
+ return;
653
+ let { store, data } = headerInstance;
654
+ if (headerInstance.widget?.tooltip) {
655
+ tooltipMouseMove(e, headerInstance, headerInstance.widget.tooltip);
656
+ }
657
+ if (data.draggable && !data.fixed && ddDetect(e) && e.buttons == 1) {
658
+ initiateDragDrop(e, {
659
+ sourceEl: e.currentTarget,
660
+ source: {
661
+ type: "grid-column",
662
+ store,
663
+ column,
664
+ columnInstance,
665
+ headerInstance,
666
+ gridInstance,
667
+ headerLine,
668
+ },
669
+ clone: {
670
+ store: store,
671
+ matchCursorOffset: true,
672
+ matchWidth: true,
673
+ widget: () => _jsx("div", { className: CSS.element(baseClass, "col-header-drag-clone"), children: data.text }),
674
+ },
675
+ }, () => { });
676
+ }
677
+ }
678
+ onHeaderMouseLeave(e, columnInstance, headerLine) {
679
+ let headerInstance = columnInstance.components[`header${headerLine + 1}`];
680
+ if (!headerInstance)
681
+ return;
682
+ if (headerInstance.widget?.tooltip) {
683
+ tooltipMouseLeave(e, headerInstance, headerInstance.widget.tooltip);
684
+ }
685
+ }
686
+ onHeaderClick(e, column, instance, headerLine) {
687
+ e.preventDefault();
688
+ e.stopPropagation();
689
+ let { data } = instance;
690
+ let header = column.components[`header${headerLine + 1}`];
691
+ let field = column.sortField || column.field;
692
+ let value = column.sortValue || column.value;
693
+ let comparer = column.comparer;
694
+ let sortOptions = column.sortOptions;
695
+ if (header && header.allowSorting && column.sortable && (field || value || data.sortField)) {
696
+ let direction = column.primarySortDirection ?? "ASC";
697
+ if (isNonEmptyArray(data.sorters) &&
698
+ ((!!data.sorters[0].field && data.sorters[0].field == (field || data.sortField)) ||
699
+ (!!value && data.sorters[0].value == value))) {
700
+ if (data.sorters[0].direction == "ASC" && (!this.clearableSort || direction == "ASC"))
701
+ direction = "DESC";
702
+ else if (data.sorters[0].direction == "DESC" && (!this.clearableSort || direction == "DESC"))
703
+ direction = "ASC";
704
+ else {
705
+ direction = null;
706
+ instance.state.disableDefaultSort = true;
707
+ }
708
+ }
709
+ let sorters = direction
710
+ ? [
711
+ {
712
+ field,
713
+ direction,
714
+ value,
715
+ comparer,
716
+ sortOptions,
717
+ },
718
+ ]
719
+ : null;
720
+ if (sorters == null)
721
+ field = null;
722
+ instance.set("sorters", sorters);
723
+ instance.set("sortField", field);
724
+ instance.set("sortDirection", direction);
725
+ if (!this.remoteSort || this.infinite)
726
+ instance.setState({ sorters });
727
+ }
728
+ }
729
+ renderGroupHeader(context, instance, g, level, group, i, store, fixedColumns) {
730
+ let { CSS, baseClass } = this;
731
+ let data = store.getData();
732
+ if (g.caption) {
733
+ let caption = g.caption(data);
734
+ return (_jsx("tbody", { className: CSS.element(baseClass, "group-caption", ["level-" + level]), "data-group-key": group.$key, "data-group-element": `group-caption-${level}`, children: _jsx("tr", { children: _jsx("td", { colSpan: 1000, children: caption }) }) }, `g-${level}-${group.$key}`));
735
+ }
736
+ else if (g.showCaption) {
737
+ let skip = 0;
738
+ let { header } = instance;
739
+ let lines = [];
740
+ header.children.forEach((line, lineIndex) => {
741
+ let empty = true;
742
+ let cells = line.children.map((ci, i) => {
743
+ if (--skip >= 0)
744
+ return null;
745
+ if (Boolean(ci.data.fixed) != fixedColumns)
746
+ return null;
747
+ let v, c = ci.widget, colSpan, pad, cls = "", style = null;
748
+ if (c.caption) {
749
+ if (c.caption.children)
750
+ v = _jsx(Cx, { widget: c.caption.children, store: store, parentInstance: instance, subscribe: true });
751
+ else {
752
+ v = c.caption.value(data);
753
+ let fmt = c.caption.format(data);
754
+ if (fmt)
755
+ v = Format.value(v, fmt);
756
+ }
757
+ pad = c.caption.pad;
758
+ colSpan = c.caption.colSpan;
759
+ empty = false;
760
+ cls = CSS.expand(c.caption.class(data)) || "";
761
+ style = parseStyle(c.caption.style(data));
762
+ if (c.caption.expand) {
763
+ colSpan = 1;
764
+ for (let ind = i + 1; ind < line.children.length &&
765
+ !line.children[ind].widget.caption &&
766
+ !line.children[ind].widget.aggregate; ind++)
767
+ colSpan++;
768
+ }
769
+ if (colSpan > 1)
770
+ skip = colSpan - 1;
771
+ }
772
+ else if (c.aggregate && c.aggregateAliasGetter && c.caption !== false) {
773
+ empty = false;
774
+ v = c.aggregateAliasGetter(group);
775
+ if (isString(ci.data.format))
776
+ v = Format.value(v, ci.data.format);
777
+ }
778
+ if (cls)
779
+ cls += " ";
780
+ if (c.align)
781
+ cls += CSS.state("aligned-" + c.align);
782
+ if (pad !== false)
783
+ cls += (cls ? " " : "") + CSS.state("pad");
784
+ return (_jsx("td", { className: cls, colSpan: colSpan, style: style, children: v }, i));
785
+ });
786
+ if (empty)
787
+ return;
788
+ lines.push(_jsx("tr", { children: cells }, lineIndex));
789
+ });
790
+ if (lines.length == 0)
791
+ return null;
792
+ return (_jsx("tbody", { className: CSS.element(baseClass, "group-caption", ["level-" + level]), "data-group-key": group.$key, "data-group-element": `group-caption-${level}`, children: lines }, "c" + group.$key));
793
+ }
794
+ }
795
+ renderGroupFooter(context, instance, g, level, group, i, store, fixed, fixedColumns) {
796
+ let { CSS, baseClass } = this;
797
+ let data = store.getData();
798
+ let skip = 0;
799
+ let { header, state } = instance;
800
+ let rowStyle = {};
801
+ let lines = [];
802
+ header.children.forEach((line, lineIndex) => {
803
+ let empty = true;
804
+ let cells = line.children.map((ci, i) => {
805
+ if (--skip >= 0)
806
+ return null;
807
+ if (Boolean(ci.data.fixed) != fixedColumns)
808
+ return null;
809
+ let v, c = ci.widget, colSpan = 1, pad, cls = "", style = null;
810
+ if (c.footer) {
811
+ v = c.footer.value(data);
812
+ let fmt = c.footer.format(data);
813
+ if (fmt)
814
+ v = Format.value(v, fmt);
815
+ pad = c.footer.pad;
816
+ colSpan = c.footer.colSpan;
817
+ empty = false;
818
+ cls = CSS.expand(c.footer.class(data)) || "";
819
+ style = parseStyle(c.footer.style(data));
820
+ if (c.footer.expand) {
821
+ colSpan = 1;
822
+ for (let ind = i + 1; ind < line.children.length &&
823
+ !line.children[ind].widget.footer &&
824
+ !line.children[ind].widget.aggregate; ind++)
825
+ colSpan++;
826
+ }
827
+ if (colSpan > 1)
828
+ skip = colSpan - 1;
829
+ }
830
+ else if (c.aggregate && c.aggregateAliasGetter && c.footer !== false) {
831
+ empty = false;
832
+ v = c.aggregateAliasGetter(group);
833
+ if (isString(ci.data.format))
834
+ v = Format.value(v, ci.data.format);
835
+ }
836
+ if (cls)
837
+ cls += " ";
838
+ if (c.align)
839
+ cls += CSS.state("aligned-" + c.align);
840
+ if (pad !== false)
841
+ cls += (cls ? " " : "") + CSS.state("pad");
842
+ // apply column width to footers too, but only if colSpan == 1,
843
+ // otherwise set 1px so that the footer is not participating in the layout
844
+ let maxWidth = 1;
845
+ if (colSpan == 1)
846
+ maxWidth = state.colWidth[c.uniqueColumnId];
847
+ style = {
848
+ ...style,
849
+ maxWidth,
850
+ };
851
+ return (_jsx("td", { className: cls, colSpan: colSpan, style: style, children: v }, i));
852
+ });
853
+ if (empty)
854
+ return;
855
+ if (fixed && !fixedColumns)
856
+ cells.push(_jsx("td", { className: CSS.element(baseClass, "fixed-footer-corner") }, "dummy"));
857
+ lines.push(_jsx("tr", { children: cells }, lineIndex));
858
+ });
859
+ if (lines.length == 0)
860
+ return null;
861
+ return (_jsx("tbody", { style: rowStyle, className: CSS.element(baseClass, "group-footer", ["level-" + level]), "data-group-key": group.$key, "data-group-element": `group-footer-${level}`, children: lines }, "f" + i));
862
+ }
863
+ renderRows(context, instance) {
864
+ let { records, hasFixedColumns } = instance;
865
+ if (!isArray(records))
866
+ return null;
867
+ let record, g;
868
+ for (let i = 0; i < records.length; i++) {
869
+ record = records[i];
870
+ if (record.type == "data")
871
+ record.vdom = record.row.render(context);
872
+ if (record.type == "group-header") {
873
+ record.vdom = [];
874
+ record.fixedVdom = [];
875
+ g = record.grouping;
876
+ if (g.caption || g.showCaption)
877
+ record.vdom.push(this.renderGroupHeader(context, instance, g, record.level, record.group, record.key + "-caption", record.store, false));
878
+ if (hasFixedColumns)
879
+ record.fixedVdom.push(this.renderGroupHeader(context, instance, g, record.level, record.group, record.key + "-caption", record.store, true));
880
+ if (g.showHeader) {
881
+ record.vdom.push(this.renderHeader(context, instance, record.key + "-header", false, false));
882
+ if (hasFixedColumns)
883
+ record.fixedVdom.push(this.renderHeader(context, instance, record.key + "-header", false, true));
884
+ }
885
+ }
886
+ if (record.type == "group-footer") {
887
+ g = record.grouping;
888
+ if (g.showFooter) {
889
+ record.vdom = this.renderGroupFooter(context, instance, g, record.level, record.group, record.key + "-footer", record.store, false, false);
890
+ if (hasFixedColumns)
891
+ record.fixedVdom = this.renderGroupFooter(context, instance, g, record.level, record.group, record.key + "-footer", record.store, false, true);
892
+ }
893
+ }
894
+ }
895
+ }
896
+ renderFixedFooter(context, instance) {
897
+ let { records, hasFixedColumns, data } = instance;
898
+ instance.fixedFooterVDOM = null;
899
+ instance.fixedColumnsFixedFooterVDOM = null;
900
+ if (data.empty || !isNonEmptyArray(records))
901
+ return;
902
+ //all type of records are allowed here because the footer can be based on pre-computed data
903
+ //it doesn't make sense to show the footer if the grid is empty though
904
+ let record = records[records.length - 1];
905
+ instance.fixedFooterOverlap = true;
906
+ instance.fixedFooterIsGroupFooter = record.type == "group-footer";
907
+ instance.fixedFooterVDOM = this.renderGroupFooter(context, instance, record.grouping, record.level || 1, record.group || { $key: "fixed-footer" }, record.key + "-footer", record.store, true, false);
908
+ if (hasFixedColumns)
909
+ instance.fixedColumnsFixedFooterVDOM = this.renderGroupFooter(context, instance, record.grouping, record.level, record.group || { $key: "fixed-footer" }, record.key + "-footer", record.store, true, true);
910
+ }
911
+ mapRecords(context, instance) {
912
+ let { data, store, dataAdapter } = instance;
913
+ let filter = null;
914
+ if (this.onCreateFilter)
915
+ filter = instance.invoke("onCreateFilter", data.filterParams, instance);
916
+ let sorters = !this.remoteSort && data.sorters;
917
+ //apply pre-sorters only if some sorting is applied
918
+ if (isNonEmptyArray(data.sorters) && isNonEmptyArray(data.preSorters)) {
919
+ sorters = [...data.preSorters, ...data.sorters];
920
+ }
921
+ dataAdapter.setFilter(filter);
922
+ dataAdapter.sort(sorters);
923
+ //if no filtering or sorting applied, let the component maps records on demand
924
+ if (this.buffered &&
925
+ !this.fixedFooter &&
926
+ !filter &&
927
+ !isNonEmptyArray(sorters) &&
928
+ !dataAdapter.isTreeAdapter &&
929
+ !instance.dataAdapter.groupings)
930
+ return undefined;
931
+ return dataAdapter.getRecords(context, instance, data.records, store);
932
+ }
933
+ mapRecord(context, instance, data, index) {
934
+ return instance.dataAdapter.mapRecord(context, instance, data, instance.store, this.recordsAccessor, index);
935
+ }
936
+ }
937
+ Grid.prototype.baseClass = "grid";
938
+ Grid.prototype.showHeader = true;
939
+ Grid.prototype.showFooter = false;
940
+ Grid.prototype.recordName = "$record";
941
+ Grid.prototype.indexName = "$index";
942
+ Grid.prototype.remoteSort = false;
943
+ Grid.prototype.lockColumnWidths = false;
944
+ Grid.prototype.lockColumnWidthsRequiredRowCount = 3;
945
+ Grid.prototype.focused = false;
946
+ Grid.prototype.emptyText = false;
947
+ Grid.prototype.showBorder = false; // show border override for material theme
948
+ Grid.prototype.cached = false;
949
+ Grid.prototype.buffered = false;
950
+ Grid.prototype.bufferStep = 15;
951
+ Grid.prototype.bufferSize = 60;
952
+ Grid.prototype.pageSize = 100;
953
+ Grid.prototype.infinite = false;
954
+ Grid.prototype.styled = true;
955
+ Grid.prototype.scrollSelectionIntoView = false;
956
+ Grid.prototype.clearableSort = false;
957
+ Grid.prototype.cellEditable = false;
958
+ Grid.prototype.preciseMeasurements = false;
959
+ Grid.prototype.hoverChannel = "default";
960
+ Grid.prototype.focusable = null; // automatically resolved
961
+ Grid.prototype.allowsFileDrops = false;
962
+ Grid.prototype.preserveGroupOrder = false;
963
+ Widget.alias("grid", Grid);
964
+ Localization.registerPrototype("cx/widgets/Grid", Grid);
965
+ class GridComponent extends VDOM.Component {
966
+ dom;
967
+ syncBuffering = false;
968
+ scrollerRef;
969
+ fixedScrollerRef;
970
+ gridRef;
971
+ offResize;
972
+ unregisterDropZone;
973
+ constructor(props) {
974
+ super(props);
975
+ this.dom = {};
976
+ let { widget } = props.instance;
977
+ let end = Math.min(widget.bufferSize, props.data.totalRecordCount);
978
+ this.state = {
979
+ cursor: widget.focused && widget.selectable ? 0 : -1,
980
+ cursorCellIndex: 0,
981
+ focused: widget.focused,
982
+ dropInsertionIndex: null,
983
+ dropNextToTheRowAbove: null,
984
+ start: 0,
985
+ end: end,
986
+ };
987
+ this.syncBuffering = false;
988
+ if (widget.infinite) {
989
+ this.start = 0;
990
+ this.end = end;
991
+ this.loadingStartPage = 0;
992
+ this.loadingEndPage = 0;
993
+ }
994
+ this.scrollerRef = (el) => {
995
+ this.dom.scroller = el;
996
+ };
997
+ this.fixedScrollerRef = (el) => {
998
+ this.dom.fixedScroller = el;
999
+ };
1000
+ this.gridRef = (el) => {
1001
+ this.dom.el = el;
1002
+ };
1003
+ }
1004
+ getBufferStartEnd() {
1005
+ return this.syncBuffering ? { start: this.start, end: this.end } : this.state;
1006
+ }
1007
+ renderCellEditor(key, CSS, baseClass, instance, column) {
1008
+ //add an inner div with fixed height in order to help IE absolutely position the contents inside
1009
+ let editor = createGridCellEditor(CSS.element(baseClass, "cell-editor-wrap"), this.rowHeight != null && this.rowHeight > 0
1010
+ ? {
1011
+ height: this.rowHeight + 1,
1012
+ }
1013
+ : null, {
1014
+ get: () => this.cellEditorValid ?? false,
1015
+ set: (value) => {
1016
+ this.cellEditorValid = value;
1017
+ return true;
1018
+ },
1019
+ }, column.editor);
1020
+ return (_jsx("td", { className: CSS.element(baseClass, "cell-editor"), children: _jsx(Cx, { parentInstance: instance, subscribe: true, widget: editor }) }, key));
1021
+ }
1022
+ createRowRenderer(cellWrap) {
1023
+ let { instance, data } = this.props;
1024
+ let { widget, isRecordSelectable, visibleColumns, isRecordDraggable, row } = instance;
1025
+ let { CSS, baseClass } = widget;
1026
+ let { dragSource } = data;
1027
+ let { dragged, cursor, cursorCellIndex, cellEdit, dropInsertionIndex, dropTarget } = this.state;
1028
+ let { colWidth, dimensionsVersion } = instance.state;
1029
+ let { hasMergedCells } = row;
1030
+ return (record, index, standalone, fixed) => {
1031
+ let { store, key, row } = record;
1032
+ let isDragged = dragged && (row?.selected || record == dragged);
1033
+ let mod = {
1034
+ selected: row?.selected,
1035
+ dragged: isDragged,
1036
+ cursor: widget.selectable && index == cursor,
1037
+ over: dropTarget == "row" && dropInsertionIndex === index,
1038
+ alternate: index % 2 == 1,
1039
+ };
1040
+ if (isRecordSelectable) {
1041
+ let selectable = isRecordSelectable(record.data, {});
1042
+ mod["selectable"] = selectable;
1043
+ mod["non-selectable"] = !selectable;
1044
+ }
1045
+ let draggable = dragSource &&
1046
+ !isNonEmptyArray(row.dragHandles) &&
1047
+ (!isRecordDraggable || isRecordDraggable(record.data));
1048
+ mod["draggable"] = draggable;
1049
+ mod["non-draggable"] = !draggable;
1050
+ let wrap = (children) => {
1051
+ let skipCells = {};
1052
+ return (_jsx(GridRowComponent, { className: CSS.state(mod), store: store, dragSource: dragSource, instance: row, grid: instance, record: record, parent: this, cursorIndex: index, selected: row?.selected, isBeingDragged: dragged, isDraggedOver: mod.over, cursor: mod.cursor, cursorCellIndex: index == cursor && cursorCellIndex, cellEdit: index == cursor && cursorCellIndex != null && cellEdit, shouldUpdate: row?.shouldUpdate, dimensionsVersion: dimensionsVersion, fixed: fixed, useTrTag: hasMergedCells, children: children.content.map(({ key, data, content }, line) => {
1053
+ let cells = content.map(({ key, data, content, uniqueColumnId, merged, mergeRowSpan }, cellIndex) => {
1054
+ if (Boolean(data.fixed) !== fixed)
1055
+ return null;
1056
+ if (merged)
1057
+ return null;
1058
+ let cellected = index == cursor && cellIndex == cursorCellIndex && widget.cellEditable && line == 0;
1059
+ let className = cellected
1060
+ ? CSS.expand(data.classNames, CSS.state("cellected"))
1061
+ : data.classNames;
1062
+ if (cellected && cellEdit) {
1063
+ let column = visibleColumns[cursorCellIndex];
1064
+ if (column && column.editor && data.editable)
1065
+ return this.renderCellEditor(key, CSS, baseClass, row, column);
1066
+ }
1067
+ let width = colWidth[uniqueColumnId];
1068
+ let style = data.style;
1069
+ if (width) {
1070
+ style = {
1071
+ ...style,
1072
+ maxWidth: `${width}px`,
1073
+ };
1074
+ }
1075
+ if (skipCells[`${line}-${cellIndex}`])
1076
+ return null;
1077
+ if (data.colSpan > 1 || data.rowSpan > 1) {
1078
+ for (let r = line; r < line + (data.rowSpan ?? 1); r++)
1079
+ for (let c = cellIndex; c < cellIndex + (data.colSpan ?? 1); c++)
1080
+ skipCells[`${r}-${c}`] = true;
1081
+ }
1082
+ if (cellWrap)
1083
+ content = cellWrap(content);
1084
+ return (_jsx("td", { className: className, style: style, colSpan: data.colSpan, rowSpan: mergeRowSpan ?? data.rowSpan, children: content }, key));
1085
+ });
1086
+ if (hasMergedCells)
1087
+ return cells;
1088
+ return (_jsx("tr", { className: data.classNames, style: data.style, children: cells }, key));
1089
+ }) }, key));
1090
+ };
1091
+ if (!standalone)
1092
+ return wrap(record.vdom);
1093
+ return (_jsx(Cx, { instance: record.row, parentInstance: instance, options: { name: "grid-row" }, contentFactory: (x) => wrap({
1094
+ content: Array.isArray(x.children) ? x.children : x.children != null ? [x.children] : [],
1095
+ data: {},
1096
+ }), params: {
1097
+ ...mod,
1098
+ dimensionsVersion: dimensionsVersion,
1099
+ cursorIndex: index,
1100
+ data: record.data,
1101
+ cursorCellIndex: index == cursor && cursorCellIndex,
1102
+ cellEdit: index == cursor && cursorCellIndex != null && cellEdit,
1103
+ } }, key));
1104
+ };
1105
+ }
1106
+ render() {
1107
+ let { instance, data, fixedFooter, fixedColumnsFixedFooter } = this.props;
1108
+ let { widget, hasFixedColumns } = instance;
1109
+ let { CSS, baseClass } = widget;
1110
+ let { start, end } = this.getBufferStartEnd();
1111
+ let cellWrap = false;
1112
+ if (widget.cellEditable && (widget.hasResizableColumns || hasFixedColumns)) {
1113
+ cellWrap = (children) => _jsx("div", { className: "cxe-grid-cell-clip", children: children });
1114
+ }
1115
+ let children = [], fixedChildren = [];
1116
+ let renderRow = this.createRowRenderer(cellWrap);
1117
+ let addRow = (record, index, standalone) => {
1118
+ children.push(renderRow(record, index, standalone, false));
1119
+ if (hasFixedColumns)
1120
+ fixedChildren.push(renderRow(record, index, standalone, true));
1121
+ //avoid re-rendering on cursor change
1122
+ record.row.shouldUpdate = false;
1123
+ };
1124
+ if (widget.buffered) {
1125
+ let context = new RenderingContext();
1126
+ let dummyDataClass = CSS.element(baseClass, "data", { dummy: true });
1127
+ if (!instance.recordInstanceCache)
1128
+ instance.recordInstanceCache = new InstanceCache(instance);
1129
+ instance.recordInstanceCache.mark();
1130
+ this.getRecordsSlice(start, end).forEach((r, i) => {
1131
+ if (r == null) {
1132
+ addRow({
1133
+ key: "dummy-" + start + i,
1134
+ row: {
1135
+ data: { classNames: dummyDataClass },
1136
+ widget: instance.row,
1137
+ },
1138
+ vdom: {
1139
+ content: [
1140
+ {
1141
+ key: 0,
1142
+ data: {},
1143
+ content: [
1144
+ {
1145
+ key: 0,
1146
+ data: {
1147
+ colSpan: 1000,
1148
+ style: {
1149
+ height: `${this.rowHeight}px`,
1150
+ },
1151
+ },
1152
+ },
1153
+ ],
1154
+ },
1155
+ ],
1156
+ },
1157
+ }, start + i);
1158
+ }
1159
+ else {
1160
+ let record = instance.records
1161
+ ? r
1162
+ : widget.mapRecord(context, instance, r, widget.infinite ? start + i - data.offset : start + i);
1163
+ let row = (record.row = instance.recordInstanceCache.getChild(instance.row, record.store, record.key));
1164
+ instance.recordInstanceCache.addChild(row);
1165
+ row.detached = true;
1166
+ row.selected = instance.isSelected(record.data, record.index);
1167
+ if (record.type == "data") {
1168
+ addRow(record, start + i, true);
1169
+ }
1170
+ else if (record.type == "group-header") {
1171
+ let g = record.grouping;
1172
+ if (g.caption || g.showCaption) {
1173
+ children.push(widget.renderGroupHeader(null, instance, g, record.level, record.group, record.key + "-caption", record.store, false));
1174
+ if (hasFixedColumns)
1175
+ fixedChildren.push(widget.renderGroupHeader(null, instance, g, record.level, record.group, record.key + "-caption", record.store, true));
1176
+ }
1177
+ }
1178
+ else if (record.type == "group-footer") {
1179
+ let g = record.grouping;
1180
+ if (g.showFooter && (!widget.fixedFooter || start + i != instance.records.length - 1)) {
1181
+ children.push(widget.renderGroupFooter(null, instance, g, record.level, record.group, record.key + "-footer", record.store, false, false));
1182
+ if (hasFixedColumns)
1183
+ fixedChildren.push(widget.renderGroupFooter(null, instance, g, record.level, record.group, record.key + "-footer", record.store, false, true));
1184
+ }
1185
+ }
1186
+ }
1187
+ });
1188
+ instance.recordInstanceCache.sweep();
1189
+ }
1190
+ else {
1191
+ let { row } = instance;
1192
+ let { hasMergedCells, mergedColumns } = row;
1193
+ if (hasMergedCells) {
1194
+ // merge adjacent cells with the same value in columns that are marked as merged
1195
+ let rowSpan = {};
1196
+ let getCellRenderInfo = (vdom, cellIndex) => vdom.content[0]?.content[cellIndex];
1197
+ for (let index = instance.records.length - 1; index >= 0; index--) {
1198
+ let row = instance.records[index];
1199
+ let prevRow = instance.records[index - 1];
1200
+ if (row.type == "data") {
1201
+ let stopMerge = false;
1202
+ for (let mi = 0; mi < mergedColumns.length; mi++) {
1203
+ let mergedCol = mergedColumns[mi];
1204
+ let cellInfo = getCellRenderInfo(row.vdom, mergedCol.index);
1205
+ cellInfo.merged = false;
1206
+ delete cellInfo.mergeRowSpan;
1207
+ if (prevRow?.type == "data") {
1208
+ let shouldMerge = false;
1209
+ switch (mergedCol.mode) {
1210
+ case "always":
1211
+ shouldMerge = true;
1212
+ break;
1213
+ case "same-value":
1214
+ let prevCellInfo = getCellRenderInfo(prevRow.vdom, mergedCol.index);
1215
+ shouldMerge = !stopMerge && cellInfo.data.value === prevCellInfo.data.value;
1216
+ break;
1217
+ }
1218
+ if (shouldMerge) {
1219
+ cellInfo.merged = true;
1220
+ rowSpan[mergedCol.uniqueColumnId] = (rowSpan[mergedCol.uniqueColumnId] ?? 1) + 1;
1221
+ }
1222
+ else {
1223
+ if (mergedCol.mode == "same-value")
1224
+ stopMerge = true;
1225
+ }
1226
+ }
1227
+ if (!cellInfo.merged && rowSpan[mergedCol.uniqueColumnId] > 1) {
1228
+ cellInfo.mergeRowSpan = rowSpan[mergedCol.uniqueColumnId];
1229
+ rowSpan[mergedCol.uniqueColumnId] = 1;
1230
+ }
1231
+ }
1232
+ }
1233
+ else
1234
+ rowSpan = {};
1235
+ }
1236
+ }
1237
+ instance.records.forEach((record, i) => {
1238
+ if (record.type == "data")
1239
+ addRow(record, i, false);
1240
+ else {
1241
+ children.push(record.vdom);
1242
+ if (hasFixedColumns)
1243
+ fixedChildren.push(record.fixedVdom);
1244
+ }
1245
+ });
1246
+ }
1247
+ if (this.state.dropTarget == "grid" && this.state.dropInsertionIndex != null) {
1248
+ let dragInsertionRow = (_jsx("tbody", { children: _jsx("tr", { children: _jsx("td", { className: CSS.element(baseClass, "dropzone"), colSpan: 1000, style: {
1249
+ height: data.dropMode == "insertion" ? 0 : this.state.dropItemHeight,
1250
+ } }) }) }, "dropzone"));
1251
+ let dataRecordClass = CSS.element(baseClass, "data");
1252
+ let isDataRecord = widget.buffered
1253
+ ? (item) => item?.props?.instance?.data?.class == dataRecordClass
1254
+ : (item) => item?.props?.record?.type;
1255
+ let index = 0;
1256
+ while (index < children.length && !isDataRecord(children[index]))
1257
+ index++;
1258
+ let count = 0;
1259
+ while (index < children.length && count < this.state.dropInsertionIndex) {
1260
+ if (isDataRecord(children[index]))
1261
+ count++;
1262
+ index++;
1263
+ }
1264
+ let savedIndexPos = index;
1265
+ if (!this.state.dropNextToTheRowAbove)
1266
+ while (index < children.length && !isDataRecord(children[index]))
1267
+ index++;
1268
+ // do not allow insertion after the last group footer
1269
+ if (savedIndexPos < index && index == children.length)
1270
+ index = savedIndexPos;
1271
+ children.splice(index, 0, dragInsertionRow);
1272
+ }
1273
+ let content = [], fixedColumnsContent = [];
1274
+ //instance.records holds the record count after filtering
1275
+ if (data.emptyText && data.empty) {
1276
+ children = [
1277
+ _jsx("tbody", { className: CSS.element(baseClass, "empty-text"), children: _jsx("tr", { children: _jsx("td", { colSpan: 1000, children: data.emptyText }) }) }, "empty"),
1278
+ ];
1279
+ }
1280
+ else if (widget.fixedFooter && (widget.buffered || !instance.fixedFooterIsGroupFooter)) {
1281
+ //add fixed footer content for buffered grids
1282
+ if (fixedFooter || fixedColumnsFixedFooter) {
1283
+ children.push(fixedFooter);
1284
+ if (hasFixedColumns)
1285
+ fixedChildren.push(fixedColumnsFixedFooter);
1286
+ }
1287
+ }
1288
+ let shouldRenderFixedFooter = widget.scrollable && (fixedFooter || fixedColumnsFixedFooter);
1289
+ if (hasFixedColumns) {
1290
+ fixedColumnsContent.push(_jsx("div", { ref: this.fixedScrollerRef, className: CSS.element(baseClass, "fixed-scroll-area", {
1291
+ "fixed-header": !!this.props.header,
1292
+ "fixed-footer": shouldRenderFixedFooter,
1293
+ }), children: _jsx("div", { className: CSS.element(baseClass, "fixed-table-wrapper"), children: _jsxs("table", { ref: (el) => {
1294
+ this.dom.fixedTable = el;
1295
+ }, children: [this.props.fixedColumnsHeader, fixedChildren] }) }) }, "fixedscroller"));
1296
+ }
1297
+ content.push(_jsx("div", { ref: this.scrollerRef, onScroll: this.onScroll.bind(this), className: CSS.element(baseClass, "scroll-area", {
1298
+ "fixed-header": !!this.props.header,
1299
+ "fixed-footer": shouldRenderFixedFooter,
1300
+ }), children: _jsx("div", { className: CSS.element(baseClass, "table-wrapper"), children: _jsxs("table", { ref: (el) => {
1301
+ this.dom.table = el;
1302
+ if (this.props.instance.widget.onRef)
1303
+ this.props.instance.invoke("onRef", el, this.props.instance);
1304
+ }, children: [this.props.header, children] }) }) }, "scroller"));
1305
+ if (this.props.fixedHeader)
1306
+ content.push(_jsx("div", { ref: (el) => {
1307
+ this.dom.fixedHeader = el;
1308
+ }, className: CSS.element(baseClass, "fixed-header"), style: {
1309
+ display: this.scrollWidth > 0 ? "block" : "none",
1310
+ }, children: _jsx("table", { children: this.props.fixedHeader }) }, "fh"));
1311
+ if (this.props.fixedColumnsFixedHeader)
1312
+ fixedColumnsContent.push(_jsx("div", { ref: (el) => {
1313
+ this.dom.fixedColumnsFixedHeader = el;
1314
+ }, className: CSS.element(baseClass, "fixed-fixed-header"), style: {
1315
+ display: this.scrollWidth > 0 ? "block" : "none",
1316
+ }, children: _jsx("table", { children: this.props.fixedColumnsFixedHeader }) }, "fcfh"));
1317
+ if (shouldRenderFixedFooter) {
1318
+ content.push(_jsx("div", { ref: (el) => {
1319
+ this.dom.fixedFooter = el;
1320
+ }, className: CSS.element(baseClass, "fixed-footer"), children: _jsx("table", { children: fixedFooter }) }, "ff"));
1321
+ if (hasFixedColumns)
1322
+ fixedColumnsContent.push(_jsx("div", { ref: (el) => {
1323
+ this.dom.fixedColumnsFixedFooter = el;
1324
+ }, className: CSS.element(baseClass, "fixed-fixed-footer"), children: _jsx("table", { children: fixedColumnsFixedFooter }) }, "fcff"));
1325
+ }
1326
+ let columnInsertionMarker = null;
1327
+ if (this.state.dropTarget == "column") {
1328
+ columnInsertionMarker = (_jsx("div", { className: CSS.element(baseClass, "col-insertion-marker"), style: {
1329
+ left: this.state.colDropInsertionLeft,
1330
+ } }));
1331
+ }
1332
+ return (_jsxs("div", { className: data.classNames, style: { ...data.style, counterReset: `cx-row-number ${start}` }, tabIndex: widget.focusable ? data.tabIndex || 0 : null, ref: this.gridRef, onKeyDown: this.handleKeyDown.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this), onDragEnter: this.onFileDragEnter.bind(this), onDragOver: this.onFileDragOver.bind(this), onDragLeave: this.onFileDragLeave.bind(this), onDrop: this.onFileDrop.bind(this), children: [fixedColumnsContent, content, columnInsertionMarker, this.props.children] }));
1333
+ }
1334
+ getRecordsSlice(start, end) {
1335
+ let { data, instance } = this.props;
1336
+ let { widget } = instance;
1337
+ if (!widget.infinite) {
1338
+ let source = instance.records || data.records;
1339
+ return source.slice(start, end);
1340
+ }
1341
+ let { offset, records } = data;
1342
+ let result = [];
1343
+ for (let i = start; i < Math.min(end, data.totalRecordCount); i++) {
1344
+ if (i >= offset && i < offset + records.length)
1345
+ result.push(records[i - offset]);
1346
+ else
1347
+ result.push(null);
1348
+ }
1349
+ return result;
1350
+ }
1351
+ ensureData(visibleStart, visibleEnd) {
1352
+ if (this.loading)
1353
+ return;
1354
+ let { instance } = this.props;
1355
+ let { widget } = instance;
1356
+ let { pageSize } = widget;
1357
+ let startPage = Math.trunc(visibleStart / pageSize) + 1, endPage = Math.trunc((visibleEnd - 1) / pageSize) + 1;
1358
+ //debouncing restricts excessive page loading on fast scrolling as rendering data is
1359
+ //useless because visible region is scrolled away before data appears
1360
+ //the user should spent some time on the page before loading it
1361
+ if (!this.loadPageRange)
1362
+ this.loadPageRange = debounce((startPage, endPage) => {
1363
+ let { data } = this.props;
1364
+ let { records, offset } = data;
1365
+ let promises = [];
1366
+ for (let page = startPage; page <= endPage; page++) {
1367
+ let s = (page - 1) * pageSize, e = s + pageSize;
1368
+ if (s >= offset && e <= offset + records.length) {
1369
+ promises.push(Promise.resolve(records.slice(s - offset, e - offset)));
1370
+ }
1371
+ else {
1372
+ let result = instance.invoke("onFetchRecords", {
1373
+ page,
1374
+ pageSize,
1375
+ sorters: data.sorters,
1376
+ sortField: data.sortField,
1377
+ sortDirection: data.sortDirection,
1378
+ filterParams: data.filterParams,
1379
+ state: this.prevFetchRecordsState,
1380
+ }, instance);
1381
+ promises.push(Promise.resolve(result));
1382
+ }
1383
+ }
1384
+ this.loading = true;
1385
+ Promise.all(promises)
1386
+ .then((pageRecords) => {
1387
+ this.loading = false;
1388
+ let records = [];
1389
+ let totalRecordCount;
1390
+ let lastPage;
1391
+ pageRecords.forEach((page) => {
1392
+ if (Array.isArray(page)) {
1393
+ records.push(...page);
1394
+ }
1395
+ else {
1396
+ if (!Array.isArray(page.records))
1397
+ throw new Error("onFetchRecords should return an array of records or an object with results inside records property.");
1398
+ totalRecordCount = page.totalRecordCount;
1399
+ lastPage = page.lastPage;
1400
+ this.prevFetchRecordsState = page.state;
1401
+ records.push(...page.records);
1402
+ }
1403
+ });
1404
+ let { data } = this.props;
1405
+ if (!isNumber(totalRecordCount)) {
1406
+ totalRecordCount = (startPage - 1) * pageSize + records.length;
1407
+ if (!lastPage && records.length == (endPage - startPage + 1) * pageSize)
1408
+ totalRecordCount++;
1409
+ if (data.totalRecordCount > totalRecordCount)
1410
+ totalRecordCount = data.totalRecordCount;
1411
+ }
1412
+ instance.buffer.totalRecordCount = data.totalRecordCount = totalRecordCount;
1413
+ instance.buffer.records = data.records = records;
1414
+ instance.buffer.page = data.page = startPage;
1415
+ data.offset = (startPage - 1) * pageSize;
1416
+ instance.store.silently(() => {
1417
+ instance.set("records", records);
1418
+ instance.set("page", startPage);
1419
+ instance.set("totalRecordCount", totalRecordCount);
1420
+ });
1421
+ let stateChanges = {
1422
+ startPage,
1423
+ endPage,
1424
+ };
1425
+ if (this.state.end == 0)
1426
+ stateChanges.end = Math.min(widget.bufferSize, totalRecordCount);
1427
+ this.setState(stateChanges, () => {
1428
+ this.loadingStartPage = startPage;
1429
+ this.loadingEndPage = endPage;
1430
+ this.onScroll();
1431
+ });
1432
+ })
1433
+ .catch((error) => {
1434
+ this.loading = false;
1435
+ if (widget.onLoadingError)
1436
+ instance.invoke(error, "onLoadingError", instance);
1437
+ });
1438
+ }, 30);
1439
+ if (startPage < this.loadingStartPage || endPage > this.loadingEndPage) {
1440
+ this.loadingStartPage = startPage;
1441
+ this.loadingEndPage = endPage;
1442
+ this.loadPageRange(startPage, endPage);
1443
+ }
1444
+ }
1445
+ onScroll() {
1446
+ //check if unmounted
1447
+ if (!this.dom.scroller)
1448
+ return;
1449
+ if (this.dom.fixedHeader) {
1450
+ this.dom.fixedHeader.scrollLeft = this.dom.scroller.scrollLeft;
1451
+ }
1452
+ if (this.dom.fixedFooter) {
1453
+ this.dom.fixedFooter.scrollLeft = this.dom.scroller.scrollLeft;
1454
+ }
1455
+ if (this.dom.fixedScroller) {
1456
+ this.dom.fixedScroller.scrollTop = this.dom.scroller.scrollTop;
1457
+ }
1458
+ let { instance, data } = this.props;
1459
+ let { widget } = instance;
1460
+ if (widget.buffered && !this.pending) {
1461
+ let start = 0;
1462
+ if (widget.measureRowHeights && instance.records)
1463
+ start = Math.max(0, this.estimateStart(instance.records, this.dom.scroller.scrollTop) - widget.bufferStep);
1464
+ else if (this.rowHeight > 0)
1465
+ start = Math.round(this.dom.scroller.scrollTop / this.rowHeight - widget.bufferStep);
1466
+ start = Math.round(start / widget.bufferStep) * widget.bufferStep;
1467
+ start = Math.max(0, Math.min(start, data.totalRecordCount - widget.bufferSize));
1468
+ let end = Math.min(data.totalRecordCount, start + widget.bufferSize);
1469
+ if (widget.infinite) {
1470
+ this.ensureData(start, end);
1471
+ }
1472
+ if (this.syncBuffering) {
1473
+ this.start = start;
1474
+ this.end = end;
1475
+ }
1476
+ else if (this.state.end != end) {
1477
+ this.pending = true;
1478
+ this.setState({ start, end }, () => {
1479
+ this.pending = false;
1480
+ });
1481
+ }
1482
+ }
1483
+ }
1484
+ onFixedColumnsWheel(e) {
1485
+ this.dom.scroller.scrollTop += e.deltaY;
1486
+ e.preventDefault();
1487
+ }
1488
+ shouldComponentUpdate(props, state) {
1489
+ return props.shouldUpdate !== false || state !== this.state;
1490
+ }
1491
+ componentDidMount() {
1492
+ this.componentDidUpdate();
1493
+ let { instance } = this.props;
1494
+ let { widget } = instance;
1495
+ if (widget.scrollable) {
1496
+ //update fixed header/footer on resize
1497
+ this.offResize = ResizeManager.trackElement(this.dom.scroller, () => {
1498
+ requestAnimationFrame(() => {
1499
+ //ignore changes if the element is not visible on the page
1500
+ if (!this.dom.scroller?.offsetWidth)
1501
+ return;
1502
+ this.componentDidUpdate();
1503
+ instance.setState({
1504
+ dimensionsVersion: instance.state.dimensionsVersion + 1,
1505
+ lockedColWidth: {},
1506
+ });
1507
+ });
1508
+ });
1509
+ }
1510
+ if (widget.pipeKeyDown)
1511
+ instance.invoke("pipeKeyDown", this.handleKeyDown.bind(this), instance);
1512
+ this.unregisterDropZone = registerDropZone(this);
1513
+ if (widget.infinite)
1514
+ this.ensureData(0, 0);
1515
+ if (this.dom.fixedScroller) {
1516
+ this.onFixedColumnsWheel = this.onFixedColumnsWheel.bind(this);
1517
+ this.dom.fixedScroller.addEventListener("wheel", this.onFixedColumnsWheel, { passive: false });
1518
+ }
1519
+ }
1520
+ onDragStart(e) {
1521
+ let { instance } = this.props;
1522
+ let { widget } = instance;
1523
+ if (widget.onDragStart)
1524
+ instance.invoke("onDragStart", e, instance);
1525
+ }
1526
+ onDrop(e) {
1527
+ try {
1528
+ let { instance } = this.props;
1529
+ let { widget } = instance;
1530
+ let { start } = this.getBufferStartEnd();
1531
+ let { dropInsertionIndex, dropTarget, dropNextToTheRowAbove } = this.state;
1532
+ if (dropTarget == "grid" && widget.onDrop && dropInsertionIndex != null) {
1533
+ let gridEvent = e;
1534
+ gridEvent.target = {
1535
+ insertionIndex: start + dropInsertionIndex,
1536
+ recordBefore: this.getDataRecordAt(start + dropInsertionIndex - 1),
1537
+ recordAfter: this.getDataRecordAt(start + dropInsertionIndex),
1538
+ totalRecordCount: instance.records.length,
1539
+ dropNextToTheRowAbove,
1540
+ };
1541
+ instance.invoke("onDrop", gridEvent, instance);
1542
+ }
1543
+ else if (dropTarget == "row") {
1544
+ let rowEvent = e;
1545
+ rowEvent.target = {
1546
+ index: start + dropInsertionIndex,
1547
+ record: this.getDataRecordAt(start + dropInsertionIndex),
1548
+ };
1549
+ instance.invoke("onRowDrop", rowEvent, instance);
1550
+ }
1551
+ else if (dropTarget == "column" && widget.onColumnDrop) {
1552
+ let colEvent = e;
1553
+ colEvent.target = {
1554
+ index: this.state.colDropInsertionIndex,
1555
+ grid: widget,
1556
+ instance,
1557
+ };
1558
+ instance.invoke("onColumnDrop", colEvent, instance);
1559
+ }
1560
+ }
1561
+ catch (err) {
1562
+ console.error("Grid drop operation failed. Please fix this error:", err);
1563
+ }
1564
+ //in some cases drop operation is not followed by leave
1565
+ this.onDragLeave(e);
1566
+ }
1567
+ onDropTest(e) {
1568
+ let { instance } = this.props;
1569
+ let { widget } = instance;
1570
+ let grid = widget.onDropTest && instance.invoke("onDropTest", e, instance);
1571
+ let row = widget.onRowDropTest && instance.invoke("onRowDropTest", e, instance);
1572
+ let column = widget.onColumnDropTest && instance.invoke("onColumnDropTest", e, instance);
1573
+ return (grid || row || column) && { grid, row, column };
1574
+ }
1575
+ onDragEnd(e) {
1576
+ this.setState({
1577
+ dropTarget: null,
1578
+ dropInsertionIndex: null,
1579
+ colDropInsertionIndex: undefined,
1580
+ colDropInsertionLeft: undefined,
1581
+ });
1582
+ let { instance } = this.props;
1583
+ let { widget } = instance;
1584
+ if (widget.onDragEnd)
1585
+ instance.invoke("onDragEnd", e, instance);
1586
+ }
1587
+ onDragMeasure(e, { test: { grid, row, column } }) {
1588
+ //columns can be dropped anywhere, while rows only in the scrollable area
1589
+ let r = getTopLevelBoundingClientRect(column ? this.dom.el : this.dom.scroller);
1590
+ let { clientX, clientY } = e.cursor;
1591
+ if (clientX < r.left || clientX >= r.right || clientY < r.top || clientY >= r.bottom)
1592
+ return false;
1593
+ return {
1594
+ over: 1000,
1595
+ near: false,
1596
+ };
1597
+ }
1598
+ onColumnDragOver(ev) {
1599
+ let headerTBody = this.dom.table.firstChild;
1600
+ let positions = [];
1601
+ let bounds;
1602
+ let exists = {};
1603
+ for (let r = 0; r < headerTBody.children.length; r++) {
1604
+ let cells = headerTBody.children[r].children;
1605
+ for (let c = 0; c < cells.length; c++) {
1606
+ bounds = cells[c].getBoundingClientRect();
1607
+ let key = bounds.left.toFixed(0);
1608
+ if (exists[key])
1609
+ continue;
1610
+ positions.push(bounds.left);
1611
+ exists[key] = true;
1612
+ }
1613
+ if (r == 0)
1614
+ positions.push(bounds.right);
1615
+ }
1616
+ //due to the order of enumeration it's possible that positions are out of order
1617
+ positions.sort((a, b) => a - b);
1618
+ let index = 0;
1619
+ while (index + 1 < positions.length && ev.cursor.clientX > positions[index + 1])
1620
+ index++;
1621
+ let { fixedColumnCount } = this.props.instance;
1622
+ this.setState({
1623
+ colDropInsertionIndex: fixedColumnCount + index,
1624
+ colDropInsertionLeft: positions[index] - positions[0] - this.dom.scroller.scrollLeft + this.dom.scroller.offsetLeft,
1625
+ dropTarget: "column",
1626
+ });
1627
+ }
1628
+ onDragOver(ev, { test: { grid, row, column } }) {
1629
+ if (column)
1630
+ this.onColumnDragOver(ev);
1631
+ if (!grid && !row)
1632
+ return;
1633
+ let { instance } = this.props;
1634
+ let { widget, data } = instance;
1635
+ let { CSS, baseClass } = widget;
1636
+ let rowClass = CSS.element(baseClass, "data");
1637
+ let nodes = Array.from(this.dom.table.children).filter((node) => node.className && node.className.indexOf(rowClass) != -1);
1638
+ let { start } = this.getBufferStartEnd();
1639
+ let s = 0, e = nodes.length, m, b;
1640
+ let parentOffset = getParentFrameBoundingClientRect(this.dom.scroller);
1641
+ let cy = ev.cursor.clientY - parentOffset.top;
1642
+ let rowOverIndex = null;
1643
+ let nextToTheRowAbove = false;
1644
+ while (s < e) {
1645
+ m = Math.floor((s + e) / 2);
1646
+ b = nodes[m].getBoundingClientRect();
1647
+ //dragged items might be invisible and have no client bounds
1648
+ if (b.top == 0 && b.bottom == 0) {
1649
+ //it's important to go all the way in one direction otherwise infinite loop might occur
1650
+ while (m > s && b.top == 0 && b.bottom == 0) {
1651
+ m--;
1652
+ b = nodes[m].getBoundingClientRect();
1653
+ }
1654
+ while (m + 1 < e && b.top == 0 && b.bottom == 0) {
1655
+ m = m + 1;
1656
+ b = nodes[m].getBoundingClientRect();
1657
+ }
1658
+ if (b.top == 0 && b.bottom == 0) {
1659
+ s = e = m;
1660
+ break;
1661
+ }
1662
+ }
1663
+ if (cy < b.top)
1664
+ e = m;
1665
+ else if (cy > b.bottom)
1666
+ s = m + 1;
1667
+ else {
1668
+ //hovering over a row here
1669
+ if (row) {
1670
+ let confirmed = !grid;
1671
+ if (!confirmed) {
1672
+ let insertionZone = (b.bottom - b.top) / 4;
1673
+ confirmed = cy > b.top + insertionZone && cy < b.bottom - insertionZone;
1674
+ }
1675
+ if (confirmed) {
1676
+ rowOverIndex = m;
1677
+ break;
1678
+ }
1679
+ }
1680
+ if (cy > (b.bottom + b.top) / 2) {
1681
+ s = e = m + 1;
1682
+ nextToTheRowAbove = true;
1683
+ }
1684
+ else
1685
+ s = e = m;
1686
+ }
1687
+ }
1688
+ let cancel = false;
1689
+ if (rowOverIndex != null) {
1690
+ let evt = {
1691
+ ...ev,
1692
+ target: {
1693
+ record: this.getRecordAt(rowOverIndex),
1694
+ index: start + rowOverIndex,
1695
+ },
1696
+ };
1697
+ if (widget.onRowDragOver && instance.invoke("onRowDragOver", evt, instance) === false)
1698
+ cancel = true;
1699
+ else if (rowOverIndex != this.state.dropInsertionIndex || this.state.dropTarget != "row") {
1700
+ this.setState({
1701
+ dropInsertionIndex: rowOverIndex,
1702
+ dropNextToTheRowAbove: false,
1703
+ dropItemHeight: ev.source.height - 1,
1704
+ dropTarget: "row",
1705
+ });
1706
+ }
1707
+ }
1708
+ else if (grid) {
1709
+ let evt = {
1710
+ ...ev,
1711
+ target: {
1712
+ recordBefore: this.getRecordAt(s - 1),
1713
+ recordAfter: this.getRecordAt(s),
1714
+ insertionIndex: start + s,
1715
+ totalRecordCount: data.totalRecordCount,
1716
+ },
1717
+ };
1718
+ if (widget.onDragOver && instance.invoke("onDragOver", evt, instance) === false)
1719
+ cancel = true;
1720
+ else if (s != this.state.dropInsertionIndex || this.state.dropTarget != "grid") {
1721
+ this.setState({
1722
+ dropInsertionIndex: s,
1723
+ dropNextToTheRowAbove: nextToTheRowAbove,
1724
+ dropItemHeight: ev.source.height - 1,
1725
+ dropTarget: "grid",
1726
+ });
1727
+ }
1728
+ }
1729
+ if (cancel) {
1730
+ this.setState({
1731
+ dropInsertionIndex: null,
1732
+ dropNextToTheRowAbove: null,
1733
+ dropTarget: null,
1734
+ });
1735
+ }
1736
+ }
1737
+ onDragLeave(e) {
1738
+ this.setState({
1739
+ dropInsertionIndex: null,
1740
+ dropNextToTheRowAbove: null,
1741
+ dropTarget: null,
1742
+ });
1743
+ }
1744
+ onGetHScrollParent() {
1745
+ let { widget } = this.props.instance;
1746
+ if (widget.scrollable)
1747
+ return this.dom.scroller;
1748
+ return findScrollableParent(this.dom.table, true);
1749
+ }
1750
+ onGetVScrollParent({ test: { grid, row, column } }) {
1751
+ if (column && !grid && !row)
1752
+ return null;
1753
+ let { widget } = this.props.instance;
1754
+ if (widget.scrollable)
1755
+ return this.dom.scroller;
1756
+ return findScrollableParent(this.dom.table);
1757
+ }
1758
+ UNSAFE_componentWillReceiveProps(props) {
1759
+ let { data, widget } = props.instance;
1760
+ if (this.state.cursor >= data.totalRecordCount)
1761
+ this.setState({
1762
+ cursor: data.totalRecordCount - 1,
1763
+ });
1764
+ else if (widget.selectable && this.state.focused && this.state.cursor < 0)
1765
+ this.setState({
1766
+ cursor: 0,
1767
+ });
1768
+ }
1769
+ componentWillUnmount() {
1770
+ let { instance } = this.props;
1771
+ let { widget } = instance;
1772
+ if (this.offResize)
1773
+ this.offResize();
1774
+ offFocusOut(this);
1775
+ if (this.unregisterDropZone)
1776
+ this.unregisterDropZone();
1777
+ if (widget.pipeKeyDown)
1778
+ instance.invoke("pipeKeyDown", null, instance);
1779
+ if (this.dom.fixedScroller) {
1780
+ this.dom.fixedScroller.removeEventListener("wheel", this.onFixedColumnsWheel);
1781
+ }
1782
+ }
1783
+ estimateHeight(records, start, end, breakCondition) {
1784
+ let avgDataRowHeight = this.heightStats.estimate("data") ?? 0;
1785
+ let totalHeight = 0;
1786
+ for (let i = start; i < end; i++) {
1787
+ let record = records[i];
1788
+ switch (record.type) {
1789
+ case "data":
1790
+ if (record.key in this.rowHeights)
1791
+ totalHeight += this.rowHeights[record.key];
1792
+ else
1793
+ totalHeight += avgDataRowHeight;
1794
+ break;
1795
+ case "group-header":
1796
+ if (record.grouping.showCaption) {
1797
+ let captionKey = "group-caption-" + record.level;
1798
+ if (`${captionKey}-${record.group.$key}` in this.rowHeights)
1799
+ totalHeight += this.rowHeights[`${captionKey}-${record.group.$key}`];
1800
+ else
1801
+ totalHeight += this.heightStats.estimate(captionKey) ?? avgDataRowHeight;
1802
+ }
1803
+ break;
1804
+ case "group-footer":
1805
+ if (record.grouping.showFooter) {
1806
+ let captionKey = "group-footer-" + record.level;
1807
+ if (`${captionKey}-${record.group.$key}` in this.rowHeights)
1808
+ totalHeight += this.rowHeights[`${captionKey}-${record.group.$key}`];
1809
+ else
1810
+ totalHeight += this.heightStats.estimate(captionKey) ?? avgDataRowHeight;
1811
+ }
1812
+ break;
1813
+ default:
1814
+ Console.warn("UNPROCESSED RECORD TYPE", record);
1815
+ break;
1816
+ }
1817
+ if (breakCondition && breakCondition(i, totalHeight) === false)
1818
+ break;
1819
+ }
1820
+ return totalHeight;
1821
+ }
1822
+ estimateStart(records, height) {
1823
+ let start = 0;
1824
+ if (height == 0)
1825
+ return 0;
1826
+ this.estimateHeight(records, 0, records.length, (index, h) => {
1827
+ start = index;
1828
+ return h < height;
1829
+ });
1830
+ return start;
1831
+ }
1832
+ componentDidUpdate() {
1833
+ let { instance, data } = this.props;
1834
+ let { widget, fixedFooterOverlap } = instance;
1835
+ if (widget.lockColumnWidths &&
1836
+ isArray(data.records) &&
1837
+ data.records.length >= widget.lockColumnWidthsRequiredRowCount) {
1838
+ let headerTBody = this.dom.table.firstChild;
1839
+ for (let r = 0; r < headerTBody.children.length; r++) {
1840
+ let sr = headerTBody.children[r];
1841
+ for (let c = 0; c < sr.children.length; c++) {
1842
+ let cell = sr.children[c];
1843
+ cell.style.width =
1844
+ cell.style.minWidth =
1845
+ cell.style.maxWidth =
1846
+ `${sr.children[c].offsetWidth}px`;
1847
+ cell.style.boxSizing = "border-box";
1848
+ if (cell.dataset.uniqueColId)
1849
+ instance.state.lockedColWidth[cell.dataset.uniqueColId] = sr.children[c].offsetWidth;
1850
+ }
1851
+ }
1852
+ }
1853
+ if (widget.scrollable) {
1854
+ this.scrollWidth = this.dom.scroller.offsetWidth - this.dom.scroller.clientWidth;
1855
+ let resized = false, headerHeight = 0, footerHeight = 0, rowHeight = 0;
1856
+ if (this.dom.fixedTable)
1857
+ syncHeaderHeights(this.dom.table.firstChild, this.dom.fixedTable.firstChild);
1858
+ if (this.dom.fixedHeader) {
1859
+ let fixedHeaderTBody = this.dom.fixedHeader.firstChild.firstChild;
1860
+ resized = widget.preciseMeasurements
1861
+ ? copyCellSizePrecise(this.dom.table.firstChild, fixedHeaderTBody)
1862
+ : copyCellSize(this.dom.table.firstChild, fixedHeaderTBody);
1863
+ let scrollColumnEl = fixedHeaderTBody?.firstChild?.lastChild;
1864
+ if (scrollColumnEl)
1865
+ scrollColumnEl.style.minWidth = scrollColumnEl.style.maxWidth = this.scrollWidth + "px";
1866
+ this.dom.fixedHeader.style.display = "block";
1867
+ headerHeight = this.dom.fixedHeader.offsetHeight;
1868
+ this.dom.scroller.style.marginTop = `${headerHeight}px`;
1869
+ if (this.dom.fixedScroller)
1870
+ this.dom.fixedScroller.style.marginTop = `${headerHeight}px`;
1871
+ else if (this.dom.fixedHeader.style.left != null)
1872
+ this.dom.fixedHeader.style.removeProperty("left");
1873
+ }
1874
+ else {
1875
+ this.dom.scroller.style.removeProperty("marginTop");
1876
+ if (this.dom.fixedScroller)
1877
+ this.dom.fixedScroller.style.removeProperty("marginTop");
1878
+ }
1879
+ if (this.dom.fixedColumnsFixedHeader) {
1880
+ let fixedColumnsWidth = `${this.dom.fixedScroller.offsetWidth}px`;
1881
+ this.dom.fixedColumnsFixedHeader.style.right = "auto";
1882
+ this.dom.fixedColumnsFixedHeader.style.width = fixedColumnsWidth;
1883
+ if (this.dom.fixedHeader)
1884
+ this.dom.fixedHeader.style.left = fixedColumnsWidth;
1885
+ this.dom.fixedColumnsFixedHeader.style.display = "block";
1886
+ let fixedHeaderTBody = this.dom.fixedColumnsFixedHeader.firstElementChild
1887
+ ?.firstElementChild;
1888
+ if (this.dom.fixedTable.firstChild) {
1889
+ resized = copyCellSize(this.dom.fixedTable.firstElementChild, fixedHeaderTBody);
1890
+ }
1891
+ }
1892
+ if (this.dom.fixedFooter || this.dom.fixedColumnsFixedFooter) {
1893
+ if (this.dom.fixedColumnsFixedFooter) {
1894
+ let fixedColumnsWidth = `${this.dom.fixedScroller.offsetWidth}px`;
1895
+ this.dom.fixedColumnsFixedFooter.style.right = "auto";
1896
+ this.dom.fixedColumnsFixedFooter.style.width = fixedColumnsWidth;
1897
+ let dstTableBody = this.dom.fixedColumnsFixedFooter.firstElementChild
1898
+ ?.firstElementChild;
1899
+ if (dstTableBody) {
1900
+ let srcTableBody = this.dom.fixedTable.lastElementChild;
1901
+ copyCellSize(srcTableBody, dstTableBody, fixedFooterOverlap);
1902
+ this.dom.fixedColumnsFixedFooter.style.display = "block";
1903
+ footerHeight = this.dom.fixedFooter.offsetHeight;
1904
+ }
1905
+ }
1906
+ if (this.dom.fixedFooter) {
1907
+ let dstTableBody = this.dom.fixedFooter.firstElementChild?.firstElementChild;
1908
+ if (dstTableBody) {
1909
+ let srcTableBody = this.dom.table.lastElementChild;
1910
+ copyCellSize(srcTableBody, dstTableBody, fixedFooterOverlap);
1911
+ let scrollColumnEl = dstTableBody.firstElementChild?.firstElementChild;
1912
+ if (scrollColumnEl)
1913
+ scrollColumnEl.style.minWidth = scrollColumnEl.style.maxWidth = this.scrollWidth + "px";
1914
+ this.dom.fixedFooter.style.display = "block";
1915
+ footerHeight = this.dom.fixedFooter.offsetHeight;
1916
+ }
1917
+ if (this.dom.fixedScroller)
1918
+ this.dom.fixedFooter.style.left = `${this.dom.fixedScroller.offsetWidth}px`;
1919
+ else if (this.dom.fixedFooter.style.left != null)
1920
+ this.dom.fixedFooter.style.removeProperty("left");
1921
+ }
1922
+ this.dom.scroller.style.marginBottom = `${footerHeight}px`;
1923
+ if (this.dom.fixedScroller)
1924
+ this.dom.fixedScroller.style.marginBottom = `${footerHeight}px`;
1925
+ }
1926
+ else {
1927
+ this.dom.scroller.style.marginBottom = "0";
1928
+ if (this.dom.fixedScroller)
1929
+ this.dom.fixedScroller.style.marginBottom = "0";
1930
+ }
1931
+ let scrollOverlap = fixedFooterOverlap ? footerHeight : 0;
1932
+ if (widget.buffered) {
1933
+ let { start, end } = this.getBufferStartEnd();
1934
+ let remaining = 0, count = Math.min(data.totalRecordCount, end - start);
1935
+ if (widget.measureRowHeights) {
1936
+ if (!this.rowHeights)
1937
+ this.rowHeights = {};
1938
+ if (!this.heightStats)
1939
+ this.heightStats = new AvgHeight();
1940
+ for (let i = 0; i < this.dom.table.children.length; i++) {
1941
+ let body = this.dom.table.children[i];
1942
+ if (body.dataset.recordKey != null) {
1943
+ if (!(body.dataset.recordKey in this.rowHeights))
1944
+ this.heightStats.add("data", body.offsetHeight);
1945
+ this.rowHeights[body.dataset.recordKey] = body.offsetHeight;
1946
+ }
1947
+ else if (body.dataset.groupKey) {
1948
+ let key = body.dataset.groupElement + "-" + body.dataset.groupKey;
1949
+ this.rowHeights[key] = body.offsetHeight;
1950
+ if (!(body.dataset.recordKey in this.rowHeights))
1951
+ this.heightStats.add(body.dataset.groupElement, body.offsetHeight);
1952
+ }
1953
+ }
1954
+ }
1955
+ if (count > 0) {
1956
+ //do not change row height while a drag-drop operation is in place
1957
+ rowHeight = this.state.dragged
1958
+ ? this.rowHeight
1959
+ : Math.round((this.dom.table.offsetHeight - headerHeight) / count);
1960
+ // if (this.rowHeight && this.rowHeight != rowHeight) {
1961
+ // console.warn("ROW-HEIGHT-CHANGE", this.rowHeight, rowHeight);
1962
+ // }
1963
+ remaining = Math.max(0, data.totalRecordCount - end);
1964
+ }
1965
+ let upperMargin = 0, lowerMargin = 0;
1966
+ if (widget.measureRowHeights && instance.records) {
1967
+ upperMargin = this.estimateHeight(instance.records, 0, start);
1968
+ lowerMargin = this.estimateHeight(instance.records, end, instance.records.length);
1969
+ }
1970
+ else {
1971
+ upperMargin = start * rowHeight;
1972
+ lowerMargin = remaining * rowHeight;
1973
+ }
1974
+ //console.log(upperMargin, start * rowHeight, this.rowHeights, this.heightStats);
1975
+ this.dom.table.style.marginTop = `${(-headerHeight + upperMargin).toFixed(0)}px`;
1976
+ this.dom.table.style.marginBottom = `${(lowerMargin - scrollOverlap).toFixed(0)}px`;
1977
+ }
1978
+ else {
1979
+ this.dom.table.style.marginTop = `${-headerHeight}px`;
1980
+ this.dom.table.style.marginBottom = `${-scrollOverlap}px`;
1981
+ }
1982
+ if (this.dom.fixedTable) {
1983
+ this.dom.fixedTable.style.marginTop = this.dom.table.style.marginTop;
1984
+ this.dom.fixedTable.style.marginBottom = this.dom.table.style.marginBottom;
1985
+ }
1986
+ this.rowHeight = rowHeight;
1987
+ let sortersChanged = widget.infinite && !shallowEquals(data.sorters, this.lastSorters);
1988
+ if (data.empty && !widget.infinite) {
1989
+ this.dom.scroller.scrollTop = 0;
1990
+ }
1991
+ if (sortersChanged ||
1992
+ data.filterParams !== this.lastScrollFilterParams ||
1993
+ data.scrollResetParams !== this.lastScrollResetParams) {
1994
+ this.dom.scroller.scrollTop = 0;
1995
+ this.lastScrollFilterParams = data.filterParams;
1996
+ this.lastScrollResetParams = data.scrollResetParams;
1997
+ this.lastSorters = data.sorters;
1998
+ if (widget.infinite) {
1999
+ this.loadingStartPage = 0;
2000
+ this.loadingEndPage = 0;
2001
+ instance.buffer.records = data.records = [];
2002
+ instance.buffer.totalRecordCount = 0;
2003
+ instance.buffer.page = 1;
2004
+ this.prevFetchRecordsState = null;
2005
+ this.loading = false;
2006
+ }
2007
+ }
2008
+ if (widget.scrollSelectionIntoView && !widget.buffered) {
2009
+ let { CSS, baseClass } = widget;
2010
+ let selectedRowSelector = `.${CSS.element(baseClass, "data")}.${CSS.state("selected")}`;
2011
+ let firstSelectedRow = this.dom.table.querySelector(selectedRowSelector);
2012
+ if (firstSelectedRow != this.selectedEl) {
2013
+ firstSelectedRow && scrollElementIntoView(firstSelectedRow);
2014
+ this.selectedEl = firstSelectedRow;
2015
+ }
2016
+ }
2017
+ setTimeout(this.onScroll.bind(this), 0);
2018
+ if (resized)
2019
+ instance.fixedHeaderResizeEvent.notify();
2020
+ }
2021
+ }
2022
+ moveCursor(index, { focused, hover, scrollIntoView, select, selectRange, selectOptions, cellIndex, cellEdit, cancelEdit, } = {}) {
2023
+ let { widget, visibleColumns } = this.props.instance;
2024
+ if (!widget.selectable && !widget.cellEditable)
2025
+ return;
2026
+ let newState = {};
2027
+ if (cellEdit != null && cellEdit != this.state.cellEdit) {
2028
+ newState.cellEdit = cellEdit;
2029
+ if (cellEdit &&
2030
+ (!visibleColumns[this.state.cursorCellIndex] || !visibleColumns[this.state.cursorCellIndex].editor))
2031
+ newState.cellEdit = false;
2032
+ }
2033
+ if (cellIndex != null && cellIndex != this.state.cursorCellIndex) {
2034
+ newState.cursorCellIndex = cellIndex;
2035
+ newState.cellEdit = false;
2036
+ }
2037
+ if (widget.focused)
2038
+ focused = true;
2039
+ if (focused != null && this.state.focused != focused) {
2040
+ newState.focused = focused;
2041
+ newState.cellEdit = false;
2042
+ }
2043
+ if (index != this.state.cursor) {
2044
+ newState.cursor = index;
2045
+ newState.cellEdit = false;
2046
+ }
2047
+ batchUpdates(() => {
2048
+ if (select) {
2049
+ let start = selectRange && this.state.selectionStart != null && this.state.selectionStart >= 0
2050
+ ? this.state.selectionStart
2051
+ : index;
2052
+ if (start < 0)
2053
+ start = index;
2054
+ this.selectRange(start, index, selectOptions);
2055
+ if (!selectRange)
2056
+ newState.selectionStart = index;
2057
+ }
2058
+ if (Object.keys(newState).length > 0) {
2059
+ let prevState = this.state;
2060
+ let wasCellEditing = prevState.focused && prevState.cellEdit;
2061
+ let futureState = { ...this.state, ...newState };
2062
+ if (!futureState.cellEdit && wasCellEditing) {
2063
+ // If cell editing is in progress, moving the cursor may cause that the cell editor to unmount before
2064
+ // the blur event which may cause data loss for components which do not have reactOn=change set, e.g. NumberField.
2065
+ unfocusElement(null, false);
2066
+ let record = this.getRecordAt(prevState.cursor);
2067
+ if ((!this.cellEditorValid || cancelEdit) && this.cellEditUndoData)
2068
+ record.store.set(widget.recordName, this.cellEditUndoData);
2069
+ else {
2070
+ let newData = record.store.get(widget.recordName); //record.data might be stale at this point
2071
+ if (widget.onCellEdited && newData != this.cellEditUndoData) {
2072
+ this.props.instance.invoke("onCellEdited", {
2073
+ column: visibleColumns[prevState.cursorCellIndex],
2074
+ newData,
2075
+ oldData: this.cellEditUndoData,
2076
+ field: visibleColumns[prevState.cursorCellIndex].field,
2077
+ }, record);
2078
+ this.cellEditUndoData = newData;
2079
+ }
2080
+ }
2081
+ }
2082
+ if (futureState.cellEdit && !wasCellEditing) {
2083
+ let record = this.getRecordAt(futureState.cursor);
2084
+ let cellEditUndoData = record.data;
2085
+ if (widget.onBeforeCellEdit &&
2086
+ this.props.instance.invoke("onBeforeCellEdit", {
2087
+ column: visibleColumns[futureState.cursorCellIndex],
2088
+ data: cellEditUndoData,
2089
+ field: visibleColumns[futureState.cursorCellIndex].field,
2090
+ }, record) === false)
2091
+ return;
2092
+ this.cellEditUndoData = cellEditUndoData;
2093
+ }
2094
+ this.setState(newState, () => {
2095
+ if (this.state.focused && !this.state.cellEdit && wasCellEditing)
2096
+ FocusManager.focus(this.dom.el);
2097
+ if (scrollIntoView) {
2098
+ let record = this.getRecordAt(index);
2099
+ let item = record && this.dom.table.querySelector(`tbody[data-record-key="${record.key}"]`);
2100
+ let hscroll = false;
2101
+ if (item) {
2102
+ if (widget.cellEditable)
2103
+ if (this.state.cursorCellIndex >= this.props.instance.fixedColumnCount) {
2104
+ hscroll = true;
2105
+ item = item.firstChild.children[this.state.cursorCellIndex - this.props.instance.fixedColumnCount];
2106
+ }
2107
+ else {
2108
+ let fixedItem = this.dom.fixedTable.querySelector(`tbody[data-record-key="${record.key}"]`);
2109
+ let cell = fixedItem && fixedItem.firstChild.children[this.state.cursorCellIndex];
2110
+ if (cell)
2111
+ scrollElementIntoView(cell, false, true, 10);
2112
+ }
2113
+ scrollElementIntoView(item, true, hscroll, widget.cellEditable ? 10 : 0);
2114
+ }
2115
+ }
2116
+ });
2117
+ }
2118
+ });
2119
+ }
2120
+ showCursor(focused) {
2121
+ let { records, isSelected } = this.props.instance;
2122
+ let cursor = this.state.cursor;
2123
+ if (cursor == -1) {
2124
+ if (records) {
2125
+ cursor = records.findIndex((x) => isSelected(x.data, x.index));
2126
+ //if there are no selected records, find the first data record (skip group header)
2127
+ if (cursor == -1)
2128
+ cursor = records.findIndex((x) => x.type == "data");
2129
+ }
2130
+ else
2131
+ cursor = 0;
2132
+ }
2133
+ this.moveCursor(cursor, { focused: true, scrollIntoView: false });
2134
+ }
2135
+ onFocus() {
2136
+ FocusManager.nudge();
2137
+ //focus moved within the grid
2138
+ if (this.state.focused) {
2139
+ if (this.state.cellEdit && this.dom.el == getActiveElement())
2140
+ this.moveCursor(this.state.cursor, {
2141
+ cellEdit: false,
2142
+ });
2143
+ return;
2144
+ }
2145
+ let { widget } = this.props.instance;
2146
+ //the cursor will be set if focus in originating from a mouse event
2147
+ setTimeout(() => {
2148
+ this.showCursor(true);
2149
+ }, 0);
2150
+ if (!widget.focused) {
2151
+ if (this.dom.el) {
2152
+ //if an inner element is focused first (autoFocus), this.dom.el! might be undefined
2153
+ oneFocusOut(this, this.dom.el, () => {
2154
+ this.moveCursor(-1, { focused: false });
2155
+ });
2156
+ }
2157
+ }
2158
+ this.setState({
2159
+ focused: true,
2160
+ });
2161
+ }
2162
+ onBlur() {
2163
+ FocusManager.nudge();
2164
+ }
2165
+ selectRange(from, to, options) {
2166
+ let { instance, data } = this.props;
2167
+ let { records, widget } = instance;
2168
+ if (from > to) {
2169
+ let tmp = from;
2170
+ from = to;
2171
+ to = tmp;
2172
+ }
2173
+ options = {
2174
+ ...options,
2175
+ range: from < to,
2176
+ };
2177
+ let selection = [], indexes = [];
2178
+ for (let cursor = from; cursor <= to; cursor++) {
2179
+ let record;
2180
+ if (records)
2181
+ record = records[cursor];
2182
+ else {
2183
+ let offset = widget.infinite ? data.offset : 0;
2184
+ let r = data.records[cursor - offset];
2185
+ if (r)
2186
+ record = widget.mapRecord(null, instance, r, cursor - offset);
2187
+ }
2188
+ if (record && record.type == "data") {
2189
+ if (instance.isRecordSelectable && !instance.isRecordSelectable(record.data, options))
2190
+ continue;
2191
+ selection.push(record.data);
2192
+ indexes.push(record.index);
2193
+ }
2194
+ }
2195
+ widget.selection.selectMultiple(instance.store, selection, indexes, options);
2196
+ }
2197
+ getDataRecordAt(index) {
2198
+ let { records } = this.props.instance;
2199
+ if (!records)
2200
+ return this.getRecordAt(index);
2201
+ let dataRecords = records.filter((r) => r.type == "data");
2202
+ return dataRecords[index];
2203
+ }
2204
+ getRecordAt(cursor) {
2205
+ let { instance, data } = this.props;
2206
+ let { records, widget } = instance;
2207
+ if (records)
2208
+ return records[cursor];
2209
+ let offset = widget.infinite ? data.offset : 0;
2210
+ let r = data.records[cursor - offset];
2211
+ if (r)
2212
+ return widget.mapRecord(null, instance, r, cursor - offset);
2213
+ return undefined;
2214
+ }
2215
+ getRecordInstanceAt(cursor) {
2216
+ let record = this.getRecordAt(cursor);
2217
+ if (!record)
2218
+ return null;
2219
+ let { instance } = this.props;
2220
+ if (instance.recordInstanceCache)
2221
+ return instance.recordInstanceCache.getChild(instance.row, record.store, record.key);
2222
+ //different signature
2223
+ return instance.getChild(null, instance.row, record.key, record.store);
2224
+ }
2225
+ handleKeyDown(e) {
2226
+ let { instance, data } = this.props;
2227
+ let { widget } = instance;
2228
+ if (widget.onKeyDown && instance.invoke("onKeyDown", e, instance) === false)
2229
+ return;
2230
+ let recordInstance = this.getRecordInstanceAt(this.state.cursor);
2231
+ if (recordInstance && widget.onRowKeyDown && instance.invoke("onRowKeyDown", e, recordInstance) === false)
2232
+ return;
2233
+ if (widget.onCellKeyDown && widget.cellEditable && this.state.cursorCellIndex != -1) {
2234
+ if (instance.invoke("onCellKeyDown", e, instance, {
2235
+ cellIndex: this.state.cursorCellIndex,
2236
+ record: recordInstance,
2237
+ }) === false)
2238
+ return;
2239
+ }
2240
+ switch (e.keyCode) {
2241
+ case KeyCode.enter:
2242
+ this.moveCursor(this.state.cursor, {
2243
+ select: true,
2244
+ selectOptions: {
2245
+ toggle: e.ctrlKey && !e.shiftKey,
2246
+ add: e.ctrlKey && e.shiftKey,
2247
+ },
2248
+ selectRange: e.shiftKey,
2249
+ cellEdit: widget.cellEditable && !this.state.cellEdit,
2250
+ focused: true,
2251
+ });
2252
+ e.stopPropagation();
2253
+ e.preventDefault();
2254
+ break;
2255
+ case KeyCode.esc:
2256
+ if (this.state.cellEdit) {
2257
+ this.moveCursor(this.state.cursor, {
2258
+ cellEdit: false,
2259
+ focused: true,
2260
+ cancelEdit: true,
2261
+ });
2262
+ e.stopPropagation();
2263
+ e.preventDefault();
2264
+ }
2265
+ break;
2266
+ case KeyCode.tab:
2267
+ if (widget.cellEditable) {
2268
+ e.stopPropagation();
2269
+ e.preventDefault();
2270
+ let direction = e.shiftKey ? -1 : +1;
2271
+ let cursor = this.state.cursor;
2272
+ let cellIndex = (this.state.cursorCellIndex + direction) % instance.row.line1.columns.length;
2273
+ if (cellIndex == -1) {
2274
+ cellIndex += instance.row.line1.columns.length;
2275
+ cursor--;
2276
+ }
2277
+ else if (cellIndex == 0 && direction > 0)
2278
+ cursor++;
2279
+ for (;; cursor += direction) {
2280
+ let record = this.getRecordAt(cursor);
2281
+ if (!record)
2282
+ break;
2283
+ if (record.type != "data")
2284
+ continue;
2285
+ this.moveCursor(cursor, {
2286
+ focused: true,
2287
+ cellIndex,
2288
+ scrollIntoView: true,
2289
+ cellEdit: false,
2290
+ });
2291
+ break;
2292
+ }
2293
+ }
2294
+ break;
2295
+ case KeyCode.down:
2296
+ for (let cursor = this.state.cursor + 1;; cursor++) {
2297
+ let record = this.getRecordAt(cursor);
2298
+ if (!record)
2299
+ break;
2300
+ if (record.type != "data")
2301
+ continue;
2302
+ this.moveCursor(cursor, {
2303
+ focused: true,
2304
+ scrollIntoView: true,
2305
+ select: e.shiftKey,
2306
+ selectRange: e.shiftKey,
2307
+ });
2308
+ break;
2309
+ }
2310
+ e.stopPropagation();
2311
+ e.preventDefault();
2312
+ break;
2313
+ case KeyCode.up:
2314
+ for (let cursor = this.state.cursor - 1; cursor >= 0; cursor--) {
2315
+ let record = this.getRecordAt(cursor);
2316
+ if (!record)
2317
+ break;
2318
+ if (record.type != "data")
2319
+ continue;
2320
+ this.moveCursor(cursor, {
2321
+ focused: true,
2322
+ scrollIntoView: true,
2323
+ select: e.shiftKey,
2324
+ selectRange: e.shiftKey,
2325
+ });
2326
+ break;
2327
+ }
2328
+ e.stopPropagation();
2329
+ e.preventDefault();
2330
+ break;
2331
+ case KeyCode.right:
2332
+ if (widget.cellEditable) {
2333
+ if (this.state.cursorCellIndex + 1 < instance.row.line1.columns.length) {
2334
+ this.moveCursor(this.state.cursor, {
2335
+ focused: true,
2336
+ cellIndex: this.state.cursorCellIndex + 1,
2337
+ scrollIntoView: true,
2338
+ });
2339
+ }
2340
+ e.stopPropagation();
2341
+ e.preventDefault();
2342
+ }
2343
+ break;
2344
+ case KeyCode.left:
2345
+ if (widget.cellEditable) {
2346
+ if (this.state.cursorCellIndex > 0) {
2347
+ this.moveCursor(this.state.cursor, {
2348
+ focused: true,
2349
+ cellIndex: this.state.cursorCellIndex - 1,
2350
+ scrollIntoView: true,
2351
+ });
2352
+ }
2353
+ e.stopPropagation();
2354
+ e.preventDefault();
2355
+ }
2356
+ break;
2357
+ case KeyCode.a:
2358
+ if (!e.ctrlKey || !widget.selection.multiple)
2359
+ return;
2360
+ if (isTextInputElement(e.target))
2361
+ return;
2362
+ this.selectRange(0, data.totalRecordCount);
2363
+ e.stopPropagation();
2364
+ e.preventDefault();
2365
+ break;
2366
+ }
2367
+ }
2368
+ beginDragDrop(e, record) {
2369
+ let { instance, data } = this.props;
2370
+ let { widget, store } = instance;
2371
+ let { isRecordDraggable } = instance;
2372
+ if (isRecordDraggable && !isRecordDraggable(record.data))
2373
+ return;
2374
+ //get a fresh isSelected delegate
2375
+ let isSelected = widget.selection.getIsSelectedDelegate(store);
2376
+ let selected = [];
2377
+ let add = (rec, data, index, force) => {
2378
+ if (!data || !(force || isSelected(data, index)) || (isRecordDraggable && !isRecordDraggable(data)))
2379
+ return;
2380
+ let mappedRecord = rec ? { ...rec } : widget.mapRecord(null, instance, data, index);
2381
+ let row = (mappedRecord.row = instance.getDetachedChild(instance.row, "DD:" + mappedRecord.key, mappedRecord.store));
2382
+ row.selected = true;
2383
+ selected.push(mappedRecord);
2384
+ };
2385
+ if (!record.row?.selected) {
2386
+ if (instance.records)
2387
+ instance.records.forEach((r) => add(r, r.data, r.index));
2388
+ else
2389
+ this.getRecordsSlice(0, data.totalRecordCount).forEach((r, index) => add(null, r, index));
2390
+ }
2391
+ if (selected.length == 0)
2392
+ add(record, record.data, record.index, true);
2393
+ let renderRow = this.createRowRenderer(false);
2394
+ let contents = selected.map((record, i) => ({
2395
+ type: StaticText,
2396
+ text: renderRow(record, i, true, false),
2397
+ }));
2398
+ initiateDragDrop(e, {
2399
+ sourceEl: closest(e.currentTarget, (a) => a.tagName == "TBODY"),
2400
+ source: {
2401
+ data: data.dragSource.data,
2402
+ store: store,
2403
+ record: record,
2404
+ records: selected,
2405
+ },
2406
+ clone: {
2407
+ store: record.store,
2408
+ matchCursorOffset: true,
2409
+ matchWidth: true,
2410
+ widget: {
2411
+ type: HtmlElement,
2412
+ tag: "div",
2413
+ className: data.classNames,
2414
+ children: [
2415
+ {
2416
+ type: HtmlElement,
2417
+ tag: "table",
2418
+ children: contents,
2419
+ },
2420
+ ],
2421
+ },
2422
+ },
2423
+ }, () => {
2424
+ this.setState({
2425
+ dragged: false,
2426
+ });
2427
+ });
2428
+ this.setState({
2429
+ dragged: record,
2430
+ });
2431
+ }
2432
+ onFileDragEnter(ev) {
2433
+ if (!this.props.instance.widget.allowsFileDrops)
2434
+ return;
2435
+ let event = getDragDropEvent(ev, this.props.instance.store, "dragmove");
2436
+ var test = this.onDropTest(event);
2437
+ if (test) {
2438
+ ev.preventDefault();
2439
+ ev.stopPropagation();
2440
+ this.onDragStart(event);
2441
+ }
2442
+ }
2443
+ onFileDragOver(ev) {
2444
+ if (!this.props.instance.widget.allowsFileDrops)
2445
+ return;
2446
+ let event = getDragDropEvent(ev, this.props.instance.store, "dragmove");
2447
+ var test = this.onDropTest(event);
2448
+ if (test) {
2449
+ ev.preventDefault();
2450
+ ev.stopPropagation();
2451
+ this.onDragOver(event, { test });
2452
+ }
2453
+ }
2454
+ onFileDragLeave(ev) {
2455
+ if (!this.props.instance.widget.allowsFileDrops)
2456
+ return;
2457
+ if (ev.target != this.dom.el) {
2458
+ //The dragleave event fires when the cursor leave any of the child elements.
2459
+ //We need to be sure that the cursor left the top element too.
2460
+ let el = document.elementFromPoint(ev.clientX, ev.clientY);
2461
+ if (el == this.dom.el || this.dom.el.contains(el))
2462
+ return;
2463
+ }
2464
+ let event = getDragDropEvent(ev, this.props.instance.store, "dragmove");
2465
+ var test = this.onDropTest(event);
2466
+ if (test) {
2467
+ this.onDragLeave(event);
2468
+ }
2469
+ }
2470
+ onFileDrop(ev) {
2471
+ if (!this.props.instance.widget.allowsFileDrops)
2472
+ return;
2473
+ let event = getDragDropEvent(ev, this.props.instance.store, "dragdrop");
2474
+ var test = this.onDropTest(event);
2475
+ if (test) {
2476
+ ev.preventDefault();
2477
+ ev.stopPropagation();
2478
+ this.onDrop(event);
2479
+ }
2480
+ }
2481
+ }
2482
+ class GridColumnHeaderLine extends PureContainerBase {
2483
+ declareData() {
2484
+ return super.declareData(...arguments, {
2485
+ showHeader: undefined,
2486
+ });
2487
+ }
2488
+ init() {
2489
+ this.items = Widget.create(GridColumnHeader, this.columns || []);
2490
+ this.visible = this.showHeader;
2491
+ this.style = this.headerStyle;
2492
+ this.className = this.headerClass;
2493
+ this.class = null;
2494
+ super.init();
2495
+ }
2496
+ render(context, instance, key) {
2497
+ let { data } = instance;
2498
+ return (_jsx("tr", { className: data.classNames, style: data.style, children: this.renderChildren(context, instance) }, key));
2499
+ }
2500
+ }
2501
+ GridColumnHeaderLine.prototype.isPureContainer = false;
2502
+ GridColumnHeaderLine.prototype.styled = true;
2503
+ GridColumnHeaderLine.prototype.showHeader = true;
2504
+ GridColumnHeaderLine.autoInit = true;
2505
+ class GridColumnHeader extends Widget {
2506
+ declareData() {
2507
+ return super.declareData(...arguments, {
2508
+ format: undefined,
2509
+ width: undefined,
2510
+ defaultWidth: undefined,
2511
+ fixed: undefined,
2512
+ });
2513
+ }
2514
+ init() {
2515
+ delete this.style;
2516
+ delete this.className;
2517
+ delete this.class;
2518
+ if (this.header)
2519
+ this.header1 = this.header;
2520
+ if (this.header1 || this.resizable || this.width || this.defaultWidth || this.sortable || this.draggable) {
2521
+ if (!isObject(this.header1))
2522
+ this.header1 = {
2523
+ text: this.header1 || "",
2524
+ };
2525
+ if (this.resizable)
2526
+ this.header1.resizable = this.resizable;
2527
+ if (this.width)
2528
+ this.header1.width = this.width;
2529
+ if (this.defaultWidth)
2530
+ this.header1.defaultWidth = this.defaultWidth;
2531
+ if (this.draggable)
2532
+ this.header1.draggable = this.draggable;
2533
+ }
2534
+ if (this.header2 && isSelector(this.header2))
2535
+ this.header2 = {
2536
+ text: this.header2,
2537
+ };
2538
+ if (this.header3 && isSelector(this.header3))
2539
+ this.header3 = {
2540
+ text: this.header3,
2541
+ };
2542
+ if (!this.aggregateField && this.field)
2543
+ this.aggregateField = this.field;
2544
+ if (!this.aggregateAlias)
2545
+ this.aggregateAlias = this.aggregateField;
2546
+ if (this.aggregateAlias)
2547
+ this.aggregateAliasGetter = Binding.get(this.aggregateAlias).value;
2548
+ if (this.footer && isSelector(this.footer))
2549
+ this.footer = {
2550
+ value: this.footer,
2551
+ pad: this.pad,
2552
+ colSpan: this.colSpan,
2553
+ };
2554
+ if (this.footer) {
2555
+ this.footer.value = getSelector(this.footer.value);
2556
+ this.footer.class = getSelector(this.footer.class);
2557
+ this.footer.style = getSelector(this.footer.style);
2558
+ this.footer.format = getSelector(this.footer.format);
2559
+ }
2560
+ if (this.caption && isSelector(this.caption))
2561
+ this.caption = {
2562
+ value: this.caption,
2563
+ pad: this.pad,
2564
+ format: this.format,
2565
+ };
2566
+ if (this.caption) {
2567
+ let children = this.caption.children || this.caption.items;
2568
+ if (children) {
2569
+ delete this.caption.items;
2570
+ this.caption.children = Widget.create(children);
2571
+ }
2572
+ else {
2573
+ this.caption.value = getSelector(this.caption.value);
2574
+ this.caption.format = getSelector(this.caption.format);
2575
+ }
2576
+ this.caption.class = getSelector(this.caption.class);
2577
+ this.caption.style = getSelector(this.caption.style);
2578
+ }
2579
+ super.init();
2580
+ }
2581
+ initComponents() {
2582
+ return super.initComponents({
2583
+ header1: this.header1 && GridColumnHeaderCell.create(this.header1),
2584
+ header2: this.header2 && GridColumnHeaderCell.create(this.header2),
2585
+ header3: this.header3 && GridColumnHeaderCell.create(this.header3),
2586
+ });
2587
+ }
2588
+ render() {
2589
+ return null;
2590
+ }
2591
+ }
2592
+ GridColumnHeader.autoInit = true;
2593
+ class GridColumnHeaderCell extends PureContainerBase {
2594
+ declareData() {
2595
+ return super.declareData(...arguments, {
2596
+ text: undefined,
2597
+ colSpan: undefined,
2598
+ rowSpan: undefined,
2599
+ width: undefined,
2600
+ defaultWidth: undefined,
2601
+ resizable: undefined,
2602
+ fixed: undefined,
2603
+ draggable: undefined,
2604
+ });
2605
+ }
2606
+ initComponents() {
2607
+ return super.initComponents(...arguments, {
2608
+ tool: this.tool && Widget.create(this.tool),
2609
+ });
2610
+ }
2611
+ render(context, instance, key) {
2612
+ let { data } = instance;
2613
+ return data.text || super.render(context, instance, key);
2614
+ }
2615
+ }
2616
+ GridColumnHeaderCell.prototype.colSpan = 1;
2617
+ GridColumnHeaderCell.prototype.rowSpan = 1;
2618
+ GridColumnHeaderCell.prototype.allowSorting = true;
2619
+ GridColumnHeaderCell.prototype.styled = true;
2620
+ GridColumnHeaderCell.prototype.fixed = false;
2621
+ // function initGrouping(grouping) {
2622
+ // grouping.forEach((g) => {
2623
+ // if (g.caption) g.caption = getSelector(g.caption);
2624
+ // });
2625
+ // }
2626
+ function copyCellSize(srcTableBody, dstTableBody, applyHeight = true) {
2627
+ if (!srcTableBody || !dstTableBody)
2628
+ return false;
2629
+ let changed = false;
2630
+ for (let r = 0; r < dstTableBody.children.length && r < srcTableBody.children.length; r++) {
2631
+ let sr = srcTableBody.children[r];
2632
+ let dr = dstTableBody.children[r];
2633
+ for (let c = 0; c < dr.children.length && c < sr.children.length; c++) {
2634
+ let dc = dr.children[c];
2635
+ let sc = sr.children[c];
2636
+ let ws = `${sc.offsetWidth}px`;
2637
+ if (!changed && dc.style.width != ws)
2638
+ changed = true;
2639
+ dc.style.width = dc.style.minWidth = dc.style.maxWidth = ws;
2640
+ if (applyHeight)
2641
+ dc.style.height = `${sc.offsetHeight}px`;
2642
+ }
2643
+ }
2644
+ return changed;
2645
+ }
2646
+ function copyCellSizePrecise(srcTableBody, dstTableBody, applyHeight = true) {
2647
+ if (!srcTableBody || !dstTableBody)
2648
+ return false;
2649
+ let changed = false;
2650
+ for (let r = 0; r < dstTableBody.children.length && r < srcTableBody.children.length; r++) {
2651
+ let sr = srcTableBody.children[r];
2652
+ let dr = dstTableBody.children[r];
2653
+ for (let c = 0; c < dr.children.length && c < sr.children.length; c++) {
2654
+ let dc = dr.children[c];
2655
+ let sc = sr.children[c];
2656
+ let bounds = sc.getBoundingClientRect();
2657
+ let ws = `${bounds.width}px`;
2658
+ if (!changed && dc.style.width != ws)
2659
+ changed = true;
2660
+ dc.style.width = dc.style.minWidth = dc.style.maxWidth = ws;
2661
+ if (applyHeight)
2662
+ dc.style.height = `${bounds.height}px`;
2663
+ }
2664
+ }
2665
+ return changed;
2666
+ }
2667
+ function syncHeaderHeights(header1, header2) {
2668
+ /**
2669
+ * In the first pass measure all row heights.
2670
+ * In the second pass apply those heights.
2671
+ * Use getBoundingClientRect() for sub-pixel accuracy.
2672
+ */
2673
+ if (!header1 || !header2)
2674
+ return;
2675
+ const rowCount = Math.max(header1.children.length, header2.children.length);
2676
+ let rowHeight = [];
2677
+ for (let r = 0; r < rowCount; r++) {
2678
+ rowHeight.push(0);
2679
+ let tr1 = header1.children[r];
2680
+ let tr2 = header2.children[r];
2681
+ if (tr1) {
2682
+ for (let i = 0; i < tr1.children.length; i++) {
2683
+ let td = tr1.children[i];
2684
+ let h = td.getBoundingClientRect().height;
2685
+ if (td.rowSpan == 1 && h > rowHeight[r]) {
2686
+ rowHeight[r] = h;
2687
+ break;
2688
+ }
2689
+ }
2690
+ }
2691
+ if (tr2) {
2692
+ for (let i = 0; i < tr2.children.length; i++) {
2693
+ let td = tr2.children[i];
2694
+ let h = td.getBoundingClientRect().height;
2695
+ if (td.rowSpan == 1 && h > rowHeight[r]) {
2696
+ rowHeight[r] = h;
2697
+ break;
2698
+ }
2699
+ }
2700
+ }
2701
+ }
2702
+ for (let r = 0; r < rowCount; r++) {
2703
+ let tr1 = header1.children[r];
2704
+ let tr2 = header2.children[r];
2705
+ if (tr1) {
2706
+ for (let i = 0; i < tr1.children.length; i++) {
2707
+ let td = tr1.children[i];
2708
+ let h = 0;
2709
+ for (let x = 0; x < td.rowSpan; x++)
2710
+ h += rowHeight[r + x];
2711
+ td.style.height = `${h}px`;
2712
+ }
2713
+ }
2714
+ if (tr2) {
2715
+ for (let i = 0; i < tr2.children.length; i++) {
2716
+ let td = tr2.children[i];
2717
+ let h = 0;
2718
+ for (let x = 0; x < td.rowSpan; x++)
2719
+ h += rowHeight[r + x];
2720
+ td.style.height = `${h}px`;
2721
+ }
2722
+ }
2723
+ }
2724
+ }
2725
+ class AvgHeight {
2726
+ constructor() {
2727
+ this.groups = {};
2728
+ }
2729
+ add(group, height) {
2730
+ let g = this.groups[group];
2731
+ if (!g)
2732
+ g = this.groups[group] = { sum: 0, count: 0 };
2733
+ g.sum += height;
2734
+ g.count++;
2735
+ }
2736
+ estimate(group) {
2737
+ let g = this.groups[group];
2738
+ if (!g || g.count == 0)
2739
+ return null;
2740
+ return Math.round(g.sum / g.count);
2741
+ }
2742
+ }
2743
+ function getDragDropEvent(ev, store, type) {
2744
+ return {
2745
+ type,
2746
+ event: ev,
2747
+ cursor: getCursorPos(ev),
2748
+ dataTransfer: ev.dataTransfer,
2749
+ source: {
2750
+ width: 32,
2751
+ height: 32,
2752
+ margin: [],
2753
+ store,
2754
+ },
2755
+ };
2756
+ }