x4js 1.4.52 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/lib/{action.d.ts → cjs/action.d.ts} +0 -0
  2. package/lib/{action.js → cjs/action.js} +0 -0
  3. package/lib/{application.d.ts → cjs/application.d.ts} +0 -0
  4. package/lib/{application.js → cjs/application.js} +13 -19
  5. package/lib/{autocomplete.d.ts → cjs/autocomplete.d.ts} +0 -0
  6. package/lib/{autocomplete.js → cjs/autocomplete.js} +0 -4
  7. package/lib/{base_component.d.ts → cjs/base_component.d.ts} +0 -0
  8. package/lib/cjs/base_component.js +124 -0
  9. package/lib/{button.d.ts → cjs/button.d.ts} +0 -0
  10. package/lib/{button.js → cjs/button.js} +4 -4
  11. package/lib/{calendar.d.ts → cjs/calendar.d.ts} +0 -0
  12. package/lib/{calendar.js → cjs/calendar.js} +22 -22
  13. package/lib/{canvas.d.ts → cjs/canvas.d.ts} +0 -0
  14. package/lib/{canvas.js → cjs/canvas.js} +7 -8
  15. package/lib/{cardview.d.ts → cjs/cardview.d.ts} +0 -0
  16. package/lib/{cardview.js → cjs/cardview.js} +3 -5
  17. package/lib/{checkbox.d.ts → cjs/checkbox.d.ts} +0 -0
  18. package/lib/{checkbox.js → cjs/checkbox.js} +6 -5
  19. package/lib/{color.d.ts → cjs/color.d.ts} +0 -0
  20. package/lib/cjs/color.js +591 -0
  21. package/lib/{colorpicker.d.ts → cjs/colorpicker.d.ts} +0 -0
  22. package/lib/{colorpicker.js → cjs/colorpicker.js} +1 -14
  23. package/lib/{combobox.d.ts → cjs/combobox.d.ts} +0 -0
  24. package/lib/{combobox.js → cjs/combobox.js} +2 -6
  25. package/lib/{component.d.ts → cjs/component.d.ts} +0 -0
  26. package/lib/{component.js → cjs/component.js} +16 -25
  27. package/lib/{datastore.d.ts → cjs/datastore.d.ts} +0 -0
  28. package/lib/{datastore.js → cjs/datastore.js} +18 -32
  29. package/lib/{dialog.d.ts → cjs/dialog.d.ts} +0 -0
  30. package/lib/{dialog.js → cjs/dialog.js} +4 -21
  31. package/lib/{dom_events.d.ts → cjs/dom_events.d.ts} +0 -0
  32. package/lib/{dom_events.js → cjs/dom_events.js} +0 -0
  33. package/lib/{drag_manager.d.ts → cjs/drag_manager.d.ts} +0 -0
  34. package/lib/{drag_manager.js → cjs/drag_manager.js} +0 -5
  35. package/lib/{drawtext.d.ts → cjs/drawtext.d.ts} +0 -0
  36. package/lib/{drawtext.js → cjs/drawtext.js} +5 -4
  37. package/lib/{fileupload.d.ts → cjs/fileupload.d.ts} +0 -0
  38. package/lib/{fileupload.js → cjs/fileupload.js} +0 -3
  39. package/lib/{form.d.ts → cjs/form.d.ts} +0 -0
  40. package/lib/{form.js → cjs/form.js} +2 -6
  41. package/lib/{formatters.d.ts → cjs/formatters.d.ts} +0 -0
  42. package/lib/{formatters.js → cjs/formatters.js} +0 -0
  43. package/lib/{gridview.d.ts → cjs/gridview.d.ts} +0 -0
  44. package/lib/{gridview.js → cjs/gridview.js} +20 -33
  45. package/lib/{i18n.d.ts → cjs/i18n.d.ts} +0 -0
  46. package/lib/{i18n.js → cjs/i18n.js} +0 -0
  47. package/lib/{icon.d.ts → cjs/icon.d.ts} +0 -0
  48. package/lib/{icon.js → cjs/icon.js} +17 -11
  49. package/lib/{image.d.ts → cjs/image.d.ts} +0 -0
  50. package/lib/{image.js → cjs/image.js} +4 -5
  51. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  52. package/lib/{index.js → cjs/index.js} +0 -0
  53. package/lib/{input.d.ts → cjs/input.d.ts} +0 -0
  54. package/lib/cjs/input.js +174 -0
  55. package/lib/{label.d.ts → cjs/label.d.ts} +0 -0
  56. package/lib/{label.js → cjs/label.js} +2 -1
  57. package/lib/{layout.d.ts → cjs/layout.d.ts} +0 -0
  58. package/lib/{layout.js → cjs/layout.js} +9 -8
  59. package/lib/{link.d.ts → cjs/link.d.ts} +0 -0
  60. package/lib/{link.js → cjs/link.js} +3 -2
  61. package/lib/{listview.d.ts → cjs/listview.d.ts} +0 -0
  62. package/lib/cjs/listview.js +544 -0
  63. package/lib/{md5.d.ts → cjs/md5.d.ts} +0 -0
  64. package/lib/cjs/md5.js +403 -0
  65. package/lib/{menu.d.ts → cjs/menu.d.ts} +0 -0
  66. package/lib/{menu.js → cjs/menu.js} +4 -11
  67. package/lib/{messagebox.d.ts → cjs/messagebox.d.ts} +0 -0
  68. package/lib/{messagebox.js → cjs/messagebox.js} +4 -4
  69. package/lib/{panel.d.ts → cjs/panel.d.ts} +0 -0
  70. package/lib/{panel.js → cjs/panel.js} +3 -4
  71. package/lib/{popup.d.ts → cjs/popup.d.ts} +0 -0
  72. package/lib/{popup.js → cjs/popup.js} +4 -5
  73. package/lib/{property_editor.d.ts → cjs/property_editor.d.ts} +0 -0
  74. package/lib/{property_editor.js → cjs/property_editor.js} +2 -5
  75. package/lib/{radiobtn.d.ts → cjs/radiobtn.d.ts} +0 -0
  76. package/lib/{radiobtn.js → cjs/radiobtn.js} +6 -6
  77. package/lib/{rating.d.ts → cjs/rating.d.ts} +0 -0
  78. package/lib/{rating.js → cjs/rating.js} +7 -6
  79. package/lib/{request.d.ts → cjs/request.d.ts} +0 -0
  80. package/lib/cjs/request.js +246 -0
  81. package/lib/{router.d.ts → cjs/router.d.ts} +0 -0
  82. package/lib/{router.js → cjs/router.js} +0 -1
  83. package/lib/{settings.d.ts → cjs/settings.d.ts} +0 -0
  84. package/lib/cjs/settings.js +69 -0
  85. package/lib/{sidebarview.d.ts → cjs/sidebarview.d.ts} +0 -0
  86. package/lib/{sidebarview.js → cjs/sidebarview.js} +2 -3
  87. package/lib/{spreadsheet.d.ts → cjs/spreadsheet.d.ts} +0 -0
  88. package/lib/{spreadsheet.js → cjs/spreadsheet.js} +10 -27
  89. package/lib/{styles.d.ts → cjs/styles.d.ts} +0 -0
  90. package/lib/{styles.js → cjs/styles.js} +5 -6
  91. package/lib/{svgcomponent.d.ts → cjs/svgcomponent.d.ts} +0 -0
  92. package/lib/{svgcomponent.js → cjs/svgcomponent.js} +3 -11
  93. package/lib/{tabbar.d.ts → cjs/tabbar.d.ts} +0 -0
  94. package/lib/{tabbar.js → cjs/tabbar.js} +5 -5
  95. package/lib/{tabview.d.ts → cjs/tabview.d.ts} +0 -0
  96. package/lib/{tabview.js → cjs/tabview.js} +0 -2
  97. package/lib/{textarea.d.ts → cjs/textarea.d.ts} +0 -0
  98. package/lib/{textarea.js → cjs/textarea.js} +4 -3
  99. package/lib/{textedit.d.ts → cjs/textedit.d.ts} +0 -0
  100. package/lib/{textedit.js → cjs/textedit.js} +7 -8
  101. package/lib/{toaster.d.ts → cjs/toaster.d.ts} +0 -0
  102. package/lib/{toaster.js → cjs/toaster.js} +0 -2
  103. package/lib/{tools.d.ts → cjs/tools.d.ts} +0 -0
  104. package/lib/{tools.js → cjs/tools.js} +7 -16
  105. package/lib/{tooltips.d.ts → cjs/tooltips.d.ts} +0 -0
  106. package/lib/{tooltips.js → cjs/tooltips.js} +0 -1
  107. package/lib/{treeview.d.ts → cjs/treeview.d.ts} +0 -0
  108. package/lib/{treeview.js → cjs/treeview.js} +23 -19
  109. package/lib/cjs/types/action.d.ts +57 -0
  110. package/lib/cjs/types/application.d.ts +104 -0
  111. package/lib/cjs/types/autocomplete.d.ts +58 -0
  112. package/lib/cjs/types/base_component.d.ts +88 -0
  113. package/lib/cjs/types/button.d.ts +151 -0
  114. package/lib/cjs/types/calendar.d.ts +81 -0
  115. package/lib/cjs/types/canvas.d.ts +92 -0
  116. package/lib/cjs/types/cardview.d.ts +87 -0
  117. package/lib/cjs/types/checkbox.d.ts +77 -0
  118. package/lib/cjs/types/color.d.ts +148 -0
  119. package/lib/cjs/types/colorpicker.d.ts +107 -0
  120. package/lib/cjs/types/combobox.d.ts +101 -0
  121. package/lib/cjs/types/component.d.ts +601 -0
  122. package/lib/cjs/types/datastore.d.ts +396 -0
  123. package/lib/cjs/types/dialog.d.ts +175 -0
  124. package/lib/cjs/types/dom_events.d.ts +302 -0
  125. package/lib/cjs/types/drag_manager.d.ts +54 -0
  126. package/lib/cjs/types/drawtext.d.ts +48 -0
  127. package/lib/cjs/types/fileupload.d.ts +64 -0
  128. package/lib/cjs/types/form.d.ts +126 -0
  129. package/lib/cjs/types/formatters.d.ts +35 -0
  130. package/lib/cjs/types/gridview.d.ts +175 -0
  131. package/lib/cjs/types/i18n.d.ts +73 -0
  132. package/lib/cjs/types/icon.d.ts +64 -0
  133. package/lib/cjs/types/image.d.ts +55 -0
  134. package/lib/cjs/types/index.d.ts +83 -0
  135. package/lib/cjs/types/input.d.ts +91 -0
  136. package/lib/cjs/types/label.d.ts +58 -0
  137. package/lib/cjs/types/layout.d.ts +87 -0
  138. package/lib/cjs/types/link.d.ts +50 -0
  139. package/lib/cjs/types/listview.d.ts +178 -0
  140. package/lib/cjs/types/md5.d.ts +61 -0
  141. package/lib/cjs/types/menu.d.ts +130 -0
  142. package/lib/cjs/types/messagebox.d.ts +68 -0
  143. package/lib/cjs/types/panel.d.ts +47 -0
  144. package/lib/cjs/types/popup.d.ts +75 -0
  145. package/lib/cjs/types/property_editor.d.ts +71 -0
  146. package/lib/cjs/types/radiobtn.d.ts +72 -0
  147. package/lib/cjs/types/rating.d.ts +53 -0
  148. package/lib/cjs/types/request.d.ts +52 -0
  149. package/lib/cjs/types/router.d.ts +42 -0
  150. package/lib/cjs/types/settings.d.ts +37 -0
  151. package/lib/cjs/types/sidebarview.d.ts +49 -0
  152. package/lib/cjs/types/spreadsheet.d.ts +218 -0
  153. package/lib/cjs/types/styles.d.ts +85 -0
  154. package/lib/cjs/types/svgcomponent.d.ts +191 -0
  155. package/lib/cjs/types/tabbar.d.ts +58 -0
  156. package/lib/cjs/types/tabview.d.ts +49 -0
  157. package/lib/{texthiliter.d.ts → cjs/types/textarea.d.ts} +26 -23
  158. package/lib/cjs/types/textedit.d.ts +123 -0
  159. package/lib/cjs/types/toaster.d.ts +42 -0
  160. package/lib/cjs/types/tools.d.ts +394 -0
  161. package/lib/cjs/types/tooltips.d.ts +46 -0
  162. package/lib/cjs/types/treeview.d.ts +132 -0
  163. package/lib/{version.d.ts → cjs/types/version.d.ts} +0 -0
  164. package/lib/{x4dom.d.ts → cjs/types/x4dom.d.ts} +0 -0
  165. package/lib/{x4events.d.ts → cjs/types/x4events.d.ts} +0 -0
  166. package/lib/{x4react.d.ts → cjs/types/x4react.d.ts} +0 -0
  167. package/lib/cjs/version.d.ts +29 -0
  168. package/lib/{version.js → cjs/version.js} +0 -0
  169. package/lib/cjs/x4dom.d.ts +49 -0
  170. package/lib/{x4dom.js → cjs/x4dom.js} +0 -0
  171. package/lib/{x4_events.d.ts → cjs/x4events.d.ts} +6 -3
  172. package/lib/{x4events.js → cjs/x4events.js} +6 -11
  173. package/lib/cjs/x4react.d.ts +41 -0
  174. package/lib/{x4react.js → cjs/x4react.js} +1 -4
  175. package/lib/esm/action.d.ts +57 -0
  176. package/lib/esm/action.js +53 -0
  177. package/lib/esm/application.d.ts +104 -0
  178. package/lib/esm/application.js +184 -0
  179. package/lib/esm/autocomplete.d.ts +58 -0
  180. package/lib/esm/autocomplete.js +155 -0
  181. package/lib/esm/base_component.d.ts +88 -0
  182. package/lib/{base_component.js → esm/base_component.js} +3 -7
  183. package/lib/esm/button.d.ts +151 -0
  184. package/lib/esm/button.js +257 -0
  185. package/lib/esm/calendar.d.ts +81 -0
  186. package/lib/esm/calendar.js +244 -0
  187. package/lib/esm/canvas.d.ts +92 -0
  188. package/lib/esm/canvas.js +358 -0
  189. package/lib/esm/cardview.d.ts +87 -0
  190. package/lib/esm/cardview.js +159 -0
  191. package/lib/esm/checkbox.d.ts +77 -0
  192. package/lib/esm/checkbox.js +133 -0
  193. package/lib/esm/color.d.ts +148 -0
  194. package/lib/{color.js → esm/color.js} +3 -7
  195. package/lib/esm/colorpicker.d.ts +107 -0
  196. package/lib/esm/colorpicker.js +1475 -0
  197. package/lib/esm/combobox.d.ts +101 -0
  198. package/lib/esm/combobox.js +259 -0
  199. package/lib/esm/component.d.ts +601 -0
  200. package/lib/esm/component.js +1711 -0
  201. package/lib/esm/datastore.d.ts +396 -0
  202. package/lib/esm/datastore.js +990 -0
  203. package/lib/esm/dialog.d.ts +175 -0
  204. package/lib/esm/dialog.js +490 -0
  205. package/lib/esm/dom_events.d.ts +302 -0
  206. package/lib/{base64.d.ts → esm/dom_events.js} +2 -8
  207. package/lib/esm/drag_manager.d.ts +54 -0
  208. package/lib/esm/drag_manager.js +147 -0
  209. package/lib/esm/drawtext.d.ts +48 -0
  210. package/lib/esm/drawtext.js +271 -0
  211. package/lib/esm/fileupload.d.ts +64 -0
  212. package/lib/esm/fileupload.js +163 -0
  213. package/lib/esm/form.d.ts +126 -0
  214. package/lib/esm/form.js +297 -0
  215. package/lib/esm/formatters.d.ts +35 -0
  216. package/lib/esm/formatters.js +81 -0
  217. package/lib/esm/gridview.d.ts +175 -0
  218. package/lib/esm/gridview.js +889 -0
  219. package/lib/esm/i18n.d.ts +73 -0
  220. package/lib/esm/i18n.js +257 -0
  221. package/lib/esm/icon.d.ts +64 -0
  222. package/lib/esm/icon.js +256 -0
  223. package/lib/esm/image.d.ts +55 -0
  224. package/lib/esm/image.js +154 -0
  225. package/lib/esm/index.d.ts +83 -0
  226. package/lib/esm/index.mjs +86 -0
  227. package/lib/esm/input.d.ts +91 -0
  228. package/lib/{input.js → esm/input.js} +2 -6
  229. package/lib/esm/label.d.ts +58 -0
  230. package/lib/esm/label.js +90 -0
  231. package/lib/esm/layout.d.ts +87 -0
  232. package/lib/esm/layout.js +310 -0
  233. package/lib/esm/link.d.ts +50 -0
  234. package/lib/esm/link.js +59 -0
  235. package/lib/esm/listview.d.ts +178 -0
  236. package/lib/{listview.js → esm/listview.js} +30 -36
  237. package/lib/esm/md5.d.ts +61 -0
  238. package/lib/{md5.js → esm/md5.js} +1 -5
  239. package/lib/esm/menu.d.ts +130 -0
  240. package/lib/esm/menu.js +300 -0
  241. package/lib/esm/messagebox.d.ts +68 -0
  242. package/lib/esm/messagebox.js +145 -0
  243. package/lib/esm/panel.d.ts +47 -0
  244. package/lib/esm/panel.js +65 -0
  245. package/lib/esm/popup.d.ts +75 -0
  246. package/lib/esm/popup.js +379 -0
  247. package/lib/esm/property_editor.d.ts +71 -0
  248. package/lib/esm/property_editor.js +251 -0
  249. package/lib/esm/radiobtn.d.ts +72 -0
  250. package/lib/esm/radiobtn.js +136 -0
  251. package/lib/esm/rating.d.ts +53 -0
  252. package/lib/esm/rating.js +97 -0
  253. package/lib/esm/request.d.ts +52 -0
  254. package/lib/{request.js → esm/request.js} +9 -16
  255. package/lib/esm/router.d.ts +42 -0
  256. package/lib/esm/router.js +136 -0
  257. package/lib/esm/settings.d.ts +37 -0
  258. package/lib/{settings.js → esm/settings.js} +1 -5
  259. package/lib/esm/sidebarview.d.ts +49 -0
  260. package/lib/esm/sidebarview.js +79 -0
  261. package/lib/esm/spreadsheet.d.ts +218 -0
  262. package/lib/esm/spreadsheet.js +1091 -0
  263. package/lib/esm/styles.d.ts +85 -0
  264. package/lib/esm/styles.js +270 -0
  265. package/lib/esm/svgcomponent.d.ts +191 -0
  266. package/lib/esm/svgcomponent.js +422 -0
  267. package/lib/esm/tabbar.d.ts +58 -0
  268. package/lib/esm/tabbar.js +107 -0
  269. package/lib/esm/tabview.d.ts +49 -0
  270. package/lib/esm/tabview.js +83 -0
  271. package/lib/esm/textarea.d.ts +63 -0
  272. package/lib/esm/textarea.js +123 -0
  273. package/lib/esm/textedit.d.ts +123 -0
  274. package/lib/esm/textedit.js +412 -0
  275. package/lib/esm/toaster.d.ts +42 -0
  276. package/lib/esm/toaster.js +62 -0
  277. package/lib/esm/tools.d.ts +394 -0
  278. package/lib/esm/tools.js +1155 -0
  279. package/lib/esm/tooltips.d.ts +46 -0
  280. package/lib/esm/tooltips.js +153 -0
  281. package/lib/esm/treeview.d.ts +132 -0
  282. package/lib/esm/treeview.js +495 -0
  283. package/lib/esm/types/action.d.ts +57 -0
  284. package/lib/esm/types/application.d.ts +104 -0
  285. package/lib/esm/types/autocomplete.d.ts +58 -0
  286. package/lib/esm/types/base_component.d.ts +88 -0
  287. package/lib/esm/types/button.d.ts +151 -0
  288. package/lib/esm/types/calendar.d.ts +81 -0
  289. package/lib/esm/types/canvas.d.ts +92 -0
  290. package/lib/esm/types/cardview.d.ts +87 -0
  291. package/lib/esm/types/checkbox.d.ts +77 -0
  292. package/lib/esm/types/color.d.ts +148 -0
  293. package/lib/esm/types/colorpicker.d.ts +107 -0
  294. package/lib/esm/types/combobox.d.ts +101 -0
  295. package/lib/esm/types/component.d.ts +601 -0
  296. package/lib/esm/types/datastore.d.ts +396 -0
  297. package/lib/esm/types/dialog.d.ts +175 -0
  298. package/lib/esm/types/dom_events.d.ts +302 -0
  299. package/lib/esm/types/drag_manager.d.ts +54 -0
  300. package/lib/esm/types/drawtext.d.ts +48 -0
  301. package/lib/esm/types/fileupload.d.ts +64 -0
  302. package/lib/esm/types/form.d.ts +126 -0
  303. package/lib/esm/types/formatters.d.ts +35 -0
  304. package/lib/esm/types/gridview.d.ts +175 -0
  305. package/lib/esm/types/i18n.d.ts +73 -0
  306. package/lib/esm/types/icon.d.ts +64 -0
  307. package/lib/esm/types/image.d.ts +55 -0
  308. package/lib/esm/types/index.d.ts +83 -0
  309. package/lib/esm/types/input.d.ts +91 -0
  310. package/lib/esm/types/label.d.ts +58 -0
  311. package/lib/esm/types/layout.d.ts +87 -0
  312. package/lib/esm/types/link.d.ts +50 -0
  313. package/lib/esm/types/listview.d.ts +178 -0
  314. package/lib/esm/types/md5.d.ts +61 -0
  315. package/lib/esm/types/menu.d.ts +130 -0
  316. package/lib/esm/types/messagebox.d.ts +68 -0
  317. package/lib/esm/types/panel.d.ts +47 -0
  318. package/lib/esm/types/popup.d.ts +75 -0
  319. package/lib/esm/types/property_editor.d.ts +71 -0
  320. package/lib/esm/types/radiobtn.d.ts +72 -0
  321. package/lib/esm/types/rating.d.ts +53 -0
  322. package/lib/esm/types/request.d.ts +52 -0
  323. package/lib/esm/types/router.d.ts +42 -0
  324. package/lib/esm/types/settings.d.ts +37 -0
  325. package/lib/esm/types/sidebarview.d.ts +49 -0
  326. package/lib/esm/types/spreadsheet.d.ts +218 -0
  327. package/lib/esm/types/styles.d.ts +85 -0
  328. package/lib/esm/types/svgcomponent.d.ts +191 -0
  329. package/lib/esm/types/tabbar.d.ts +58 -0
  330. package/lib/esm/types/tabview.d.ts +49 -0
  331. package/lib/esm/types/textarea.d.ts +63 -0
  332. package/lib/esm/types/textedit.d.ts +123 -0
  333. package/lib/esm/types/toaster.d.ts +42 -0
  334. package/lib/esm/types/tools.d.ts +394 -0
  335. package/lib/esm/types/tooltips.d.ts +46 -0
  336. package/lib/esm/types/treeview.d.ts +132 -0
  337. package/lib/esm/types/version.d.ts +29 -0
  338. package/lib/esm/types/x4dom.d.ts +49 -0
  339. package/lib/esm/types/x4events.d.ts +269 -0
  340. package/lib/esm/types/x4react.d.ts +41 -0
  341. package/lib/esm/version.d.ts +29 -0
  342. package/lib/esm/version.js +29 -0
  343. package/lib/esm/x4dom.d.ts +49 -0
  344. package/lib/esm/x4dom.js +29 -0
  345. package/lib/esm/x4events.d.ts +269 -0
  346. package/lib/{x4_events.js → esm/x4events.js} +11 -24
  347. package/lib/esm/x4react.d.ts +41 -0
  348. package/lib/esm/x4react.js +71 -0
  349. package/lib/{x4.css → styles/x4.css} +0 -0
  350. package/{src → lib/styles}/x4.less +0 -0
  351. package/{src → lib/ts_src}/MIT-license.md +0 -0
  352. package/{src → lib/ts_src}/action.ts +0 -0
  353. package/{src → lib/ts_src}/alpha.jpg +0 -0
  354. package/{src → lib/ts_src}/application.ts +0 -0
  355. package/{src → lib/ts_src}/autocomplete.ts +0 -0
  356. package/{src → lib/ts_src}/base64.ts +0 -0
  357. package/{src → lib/ts_src}/base_component.ts +0 -0
  358. package/{src → lib/ts_src}/button.ts +0 -0
  359. package/{src → lib/ts_src}/calendar.ts +0 -0
  360. package/{src → lib/ts_src}/canvas.ts +0 -0
  361. package/{src → lib/ts_src}/cardview.ts +0 -0
  362. package/{src → lib/ts_src}/checkbox.ts +0 -0
  363. package/{src → lib/ts_src}/color.ts +0 -0
  364. package/{src → lib/ts_src}/colorpicker.ts +0 -0
  365. package/{src → lib/ts_src}/combobox.ts +0 -0
  366. package/{src → lib/ts_src}/component.ts +0 -0
  367. package/{src → lib/ts_src}/datastore.ts +0 -0
  368. package/{src → lib/ts_src}/dialog.ts +0 -0
  369. package/{src → lib/ts_src}/dom_events.ts +0 -0
  370. package/{src → lib/ts_src}/drag_manager.ts +0 -0
  371. package/{src → lib/ts_src}/drawtext.ts +0 -0
  372. package/{src → lib/ts_src}/fileupload.ts +0 -0
  373. package/{src → lib/ts_src}/form.ts +0 -0
  374. package/{src → lib/ts_src}/formatters.ts +0 -0
  375. package/{src → lib/ts_src}/gridview.ts +0 -0
  376. package/{src → lib/ts_src}/i18n.ts +0 -0
  377. package/{src → lib/ts_src}/icon.ts +0 -0
  378. package/{src → lib/ts_src}/image.ts +0 -0
  379. package/{src → lib/ts_src}/index.ts +0 -0
  380. package/{src → lib/ts_src}/input.ts +0 -0
  381. package/{src → lib/ts_src}/label.ts +0 -0
  382. package/{src → lib/ts_src}/layout.ts +0 -0
  383. package/{src → lib/ts_src}/link.ts +0 -0
  384. package/{src → lib/ts_src}/listview.ts +0 -0
  385. package/{src → lib/ts_src}/md5.ts +0 -0
  386. package/{src → lib/ts_src}/menu.ts +0 -0
  387. package/{src → lib/ts_src}/messagebox.ts +0 -0
  388. package/{src → lib/ts_src}/panel.ts +0 -0
  389. package/{src → lib/ts_src}/popup.ts +0 -0
  390. package/{src → lib/ts_src}/property_editor.ts +0 -0
  391. package/{src → lib/ts_src}/radiobtn.ts +0 -0
  392. package/{src → lib/ts_src}/rating.ts +0 -0
  393. package/{src → lib/ts_src}/request.ts +0 -0
  394. package/{src → lib/ts_src}/router.ts +0 -0
  395. package/{src → lib/ts_src}/settings.ts +0 -0
  396. package/{src → lib/ts_src}/sidebarview.ts +0 -0
  397. package/{src → lib/ts_src}/spreadsheet.ts +0 -0
  398. package/{src → lib/ts_src}/styles.ts +0 -0
  399. package/{src → lib/ts_src}/svgcomponent.ts +0 -0
  400. package/{src → lib/ts_src}/tabbar.ts +0 -0
  401. package/{src → lib/ts_src}/tabview.ts +0 -0
  402. package/{src → lib/ts_src}/textarea.ts +0 -0
  403. package/{src → lib/ts_src}/textedit.ts +0 -0
  404. package/{src → lib/ts_src}/toaster.ts +0 -0
  405. package/{src → lib/ts_src}/tools.ts +0 -0
  406. package/{src → lib/ts_src}/tooltips.ts +0 -0
  407. package/{src → lib/ts_src}/treeview.ts +0 -0
  408. package/{src → lib/ts_src}/version.ts +0 -0
  409. package/lib/ts_src/x4.less +2236 -0
  410. package/{src → lib/ts_src}/x4dom.ts +0 -0
  411. package/{src → lib/ts_src}/x4events.ts +0 -0
  412. package/{src → lib/ts_src}/x4react.ts +0 -0
  413. package/package.json +36 -14
  414. package/build.sh +0 -5
  415. package/lib/base64.js +0 -143
  416. package/lib/hosts/host.d.ts +0 -44
  417. package/lib/hosts/host.js +0 -73
  418. package/lib/smartedit.d.ts +0 -107
  419. package/lib/smartedit.js +0 -390
  420. package/lib/texthiliter.js +0 -227
  421. package/tsconfig.json +0 -21
@@ -0,0 +1,1091 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file spreadsheet.ts
9
+ * @author Etienne Cochard
10
+ *
11
+ * Copyright (c) 2019-2022 R-libre ingenierie
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
+ * of the Software, and to permit persons to whom the Software is furnished to do so,
18
+ * subject to the following conditions:
19
+ * The above copyright notice and this permission notice shall be included in all copies
20
+ * or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ **/
29
+ import { x4document } from './x4dom';
30
+ import { Component, SizerOverlay, EvDblClick } from './component';
31
+ import { HLayout, VLayout } from './layout';
32
+ import { TextEdit } from './textedit';
33
+ import { asap, parseIntlFloat } from './tools';
34
+ import { deferCall } from './tools';
35
+ import { EvContextMenu, EvChange, EvSelectionChange } from './x4events';
36
+ import { ComboBox } from './combobox';
37
+ class CellData {
38
+ text;
39
+ cls;
40
+ static empty_cell = {
41
+ text: ''
42
+ };
43
+ }
44
+ /**
45
+ *
46
+ */
47
+ export class Spreadsheet extends VLayout {
48
+ m_columns;
49
+ m_row_limit;
50
+ m_cells_data;
51
+ m_rows_data;
52
+ m_view;
53
+ m_container;
54
+ m_header;
55
+ m_itemHeight;
56
+ m_topIndex;
57
+ m_visible_cells;
58
+ m_row_count; // visible row count
59
+ m_selection;
60
+ m_editor;
61
+ m_autoedit;
62
+ m_lockupdate;
63
+ m_auto_row_count;
64
+ m_recycler;
65
+ m_used_cells;
66
+ constructor(props) {
67
+ super(props);
68
+ this.m_columns = props.columns;
69
+ this.m_autoedit = props.autoedit;
70
+ this.m_lockupdate = 0;
71
+ this.m_cells_data = new Map();
72
+ this.m_rows_data = new Map();
73
+ this.m_itemHeight = 0;
74
+ this.m_selection = { row: 0, col: 0 };
75
+ this.m_row_count = 0;
76
+ this.m_auto_row_count = false;
77
+ this.m_recycler = [];
78
+ this.m_used_cells = [];
79
+ if (props.maxrows === undefined) {
80
+ this.m_row_limit = 0;
81
+ this.m_auto_row_count = true;
82
+ }
83
+ else if (props.maxrows < 0) {
84
+ this.m_row_limit = 0;
85
+ this.m_auto_row_count = true;
86
+ }
87
+ else {
88
+ this.m_row_limit = props.maxrows;
89
+ }
90
+ this.setAttribute('tabindex', 0);
91
+ this.setDomEvent('click', (e) => this._itemClick(e));
92
+ this.setDomEvent('dblclick', (e) => this._itemDblClick(e));
93
+ this.setDomEvent('keydown', (e) => this._handleKey(e));
94
+ this.setDomEvent('keypress', (e) => this._keyPress(e));
95
+ this.setDomEvent('focus', () => this._focus(true));
96
+ this.setDomEvent('focusout', () => this._focus(false));
97
+ this.setDomEvent('contextmenu', (e) => this._ctxMenu(e));
98
+ this.mapPropEvents(props, 'dblClick', 'selectionChange', 'contextMenu', 'change');
99
+ }
100
+ componentCreated() {
101
+ super.componentCreated();
102
+ this._updateScroll(true);
103
+ }
104
+ setColWidth(col, width) {
105
+ this._on_col_resize(col, width);
106
+ this.update(10);
107
+ }
108
+ getColWidth(col) {
109
+ if (!this.m_columns[col]) {
110
+ return;
111
+ }
112
+ return this.m_columns[col].width;
113
+ }
114
+ setColTitle(col, title) {
115
+ console.assert(this.m_columns[col] !== undefined); // what ?
116
+ this.m_columns[col].title = title;
117
+ this.update(10);
118
+ }
119
+ reset(columns) {
120
+ this.m_columns = columns;
121
+ this.m_cells_data = new Map();
122
+ this.m_rows_data = new Map();
123
+ this.update(10);
124
+ }
125
+ /**
126
+ * insert a row
127
+ * @param before row number before wich insert the new row
128
+ */
129
+ insertRow(before) {
130
+ let new_cells_data = new Map();
131
+ this.m_cells_data.forEach((celldata, key) => {
132
+ let { row, col } = _getid(key);
133
+ if (row >= before) {
134
+ new_cells_data.set(_mkid(row + 1, col), celldata);
135
+ }
136
+ else {
137
+ new_cells_data.set(key, celldata);
138
+ }
139
+ });
140
+ let new_rows_data = new Map();
141
+ this.m_rows_data.forEach((rowdata, row) => {
142
+ if (row >= before) {
143
+ new_rows_data.set(row + 1, rowdata);
144
+ }
145
+ else {
146
+ new_rows_data.set(row, rowdata);
147
+ }
148
+ });
149
+ this.m_cells_data = new_cells_data;
150
+ this.m_rows_data = new_rows_data;
151
+ this._buildItems();
152
+ }
153
+ /**
154
+ * remove a row
155
+ * @param rowtodel row number to remove
156
+ */
157
+ deleteRow(rowtodel) {
158
+ let new_cells_data = new Map();
159
+ let new_rows_data = new Map();
160
+ this.m_cells_data.forEach((celldata, key) => {
161
+ let { row, col } = _getid(key);
162
+ if (row > rowtodel) {
163
+ new_cells_data.set(_mkid(row - 1, col), celldata);
164
+ }
165
+ else if (row < rowtodel) {
166
+ new_cells_data.set(key, celldata);
167
+ }
168
+ });
169
+ this.m_rows_data.forEach((rowdata, row) => {
170
+ if (row > rowtodel) {
171
+ new_rows_data.set(row - 1, rowdata);
172
+ }
173
+ else if (row < rowtodel) {
174
+ new_rows_data.set(row, rowdata);
175
+ }
176
+ });
177
+ this.m_cells_data = new_cells_data;
178
+ this.m_rows_data = new_rows_data;
179
+ this._buildItems();
180
+ }
181
+ /**
182
+ * insert a new column
183
+ * @param before column index before to insert the new column or <0 to append
184
+ */
185
+ insertCol(before, column) {
186
+ let inspos = before;
187
+ if (inspos < 0) {
188
+ inspos = this.m_columns.length + 1;
189
+ }
190
+ // insert the col at the right place
191
+ this.m_columns.splice(inspos, 0, column);
192
+ if (before >= 0) {
193
+ let new_cells_data = new Map();
194
+ this.m_cells_data.forEach((celldata, key) => {
195
+ let { row, col } = _getid(key);
196
+ if (col >= before) {
197
+ new_cells_data.set(_mkid(row, col + 1), celldata);
198
+ }
199
+ else {
200
+ new_cells_data.set(key, celldata);
201
+ }
202
+ });
203
+ this.m_cells_data = new_cells_data;
204
+ }
205
+ this.update();
206
+ }
207
+ /**
208
+ * remove a column
209
+ * @param coltodel
210
+ */
211
+ deleteCol(coltodel) {
212
+ // insert the col at the right place
213
+ this.m_columns.splice(coltodel, 1);
214
+ let new_cells_data = new Map();
215
+ this.m_cells_data.forEach((celldata, key) => {
216
+ let { row, col } = _getid(key);
217
+ if (col > coltodel) {
218
+ new_cells_data.set(_mkid(row, col - 1), celldata);
219
+ }
220
+ else if (col < coltodel) {
221
+ new_cells_data.set(key, celldata);
222
+ }
223
+ });
224
+ this.m_cells_data = new_cells_data;
225
+ this.update();
226
+ }
227
+ /**
228
+ *
229
+ * @param row
230
+ * @param col
231
+ */
232
+ _getCellData(row, col, raw = false) {
233
+ let value = this.m_cells_data.get(_mkid(row, col));
234
+ if (value === undefined) {
235
+ return raw ? null : CellData.empty_cell;
236
+ }
237
+ return value;
238
+ }
239
+ _focus(focus) {
240
+ this.setClass('@focus', focus);
241
+ }
242
+ _ctxMenu(e) {
243
+ let dom = e.target, self = this.dom;
244
+ while (dom && dom != self) {
245
+ let itm = Component.getElement(dom), row = itm.getData('row-id'), col = itm.getData('col-id');
246
+ if (row !== undefined) {
247
+ this._selectItem(row, col);
248
+ this.emit('contextMenu', EvContextMenu(e, { row, col, item: itm }));
249
+ e.preventDefault();
250
+ return;
251
+ }
252
+ dom = dom.parentElement;
253
+ }
254
+ }
255
+ /** @ignore */
256
+ render() {
257
+ this.m_recycler = [];
258
+ this.m_container = new Component({
259
+ cls: 'content',
260
+ });
261
+ this.m_view = new Component({
262
+ cls: '@scroll-view',
263
+ flex: 1,
264
+ dom_events: {
265
+ sizechange: () => this._updateScroll(true),
266
+ scroll: () => this._updateScroll(false)
267
+ },
268
+ content: this.m_container
269
+ });
270
+ let cols = this.m_columns.map((col, index) => {
271
+ let comp = new Component({
272
+ cls: '@cell c' + index,
273
+ content: col.title ? col.title : '&nbsp',
274
+ flex: col.width < 0 ? -col.width : undefined,
275
+ attrs: {
276
+ title: col.title
277
+ },
278
+ style: {
279
+ width: col.width >= 0 ? col.width : undefined,
280
+ minWidth: col.min_width
281
+ },
282
+ });
283
+ new SizerOverlay({
284
+ target: comp,
285
+ sens: 'right',
286
+ resize: (ev) => {
287
+ this._on_col_resize(index, ev.size.width);
288
+ }
289
+ });
290
+ col.$col = comp;
291
+ return comp;
292
+ });
293
+ this.m_header = new HLayout({
294
+ cls: '@header',
295
+ content: cols,
296
+ });
297
+ this.setContent([
298
+ this.m_header,
299
+ this.m_view
300
+ ]);
301
+ }
302
+ /**
303
+ *
304
+ */
305
+ _on_col_resize(col, width) {
306
+ if (!this.m_columns[col]) {
307
+ return;
308
+ }
309
+ // -> flex
310
+ if (width <= 0) {
311
+ this.m_columns[col].width = -1; // flex default
312
+ }
313
+ else {
314
+ this.m_columns[col].width = width;
315
+ }
316
+ this._updateScroll(true);
317
+ }
318
+ /**
319
+ * compute misc dimensions
320
+ * - item height
321
+ * - scroll width
322
+ */
323
+ _computeItemHeight() {
324
+ let g1 = x4document.createElement('div');
325
+ g1.classList.add('x-spreadsheet');
326
+ let g2 = x4document.createElement('div');
327
+ g2.classList.add('content');
328
+ let g3 = x4document.createElement('div');
329
+ g3.classList.add('x-cell');
330
+ g3.append('&nbsp;');
331
+ g2.appendChild(g3);
332
+ g1.appendChild(g2);
333
+ this.dom.appendChild(g1);
334
+ let rc = g3.getBoundingClientRect();
335
+ this.dom.removeChild(g1);
336
+ this.m_itemHeight = rc.height;
337
+ }
338
+ /**
339
+ * compute columns widths
340
+ * use col.width for fixed size columns
341
+ * if col.width < 0 that mean that this is a proportion of the remaining space
342
+ */
343
+ _calcColWidths(width) {
344
+ let fullw = 0;
345
+ let nwide = 0;
346
+ let calcw = new Int32Array(this.m_columns.length);
347
+ let calcz = new Int32Array(this.m_columns.length);
348
+ let calcm = new Int32Array(this.m_columns.length);
349
+ this.m_columns.forEach((col, colIdx) => {
350
+ let minw = Math.max(10, col.min_width ?? 0);
351
+ if (col.width > 0) {
352
+ let cw = Math.max(col.width, minw);
353
+ fullw += cw;
354
+ calcw[colIdx] = cw;
355
+ }
356
+ else {
357
+ let z = -col.width;
358
+ calcz[colIdx] = z;
359
+ nwide += z;
360
+ }
361
+ calcm[colIdx] = minw;
362
+ });
363
+ if (nwide) {
364
+ let restw = width - fullw;
365
+ for (let i = 0; i < this.m_columns.length && nwide; i++) {
366
+ if (!calcw[i]) {
367
+ let rest = Math.round(restw / nwide) * calcz[i];
368
+ if (rest < calcm[i]) {
369
+ rest = calcm[i];
370
+ }
371
+ calcw[i] = rest;
372
+ restw -= rest;
373
+ nwide -= calcz[i];
374
+ }
375
+ }
376
+ }
377
+ return calcw;
378
+ }
379
+ /**
380
+ * create a cell (component)
381
+ * and append it to the parent view
382
+ * if a cell was reviously recyled, use it
383
+ */
384
+ _createCell() {
385
+ let cell;
386
+ if (this.m_recycler.length) {
387
+ cell = this.m_recycler.pop();
388
+ cell.clearClasses();
389
+ cell.addClass('@comp'); // todo: find better to reset to default
390
+ }
391
+ else {
392
+ cell = new Component({
393
+ cls: '@cell'
394
+ });
395
+ }
396
+ if (!cell.dom) {
397
+ this.m_container.appendChild(cell);
398
+ }
399
+ return cell;
400
+ }
401
+ /**
402
+ * build cells of the spreadsheet
403
+ * cells are recycled when scrolling,
404
+ * only visibles cells exists
405
+ */
406
+ _buildItems() {
407
+ let rc = this.getBoundingRect();
408
+ let rh = this.m_header.getBoundingRect();
409
+ let height = rc.height - rh.height;
410
+ if (this.m_itemHeight == 0) {
411
+ this._computeItemHeight();
412
+ }
413
+ let top = this.m_topIndex * this.m_itemHeight;
414
+ let y = 0;
415
+ let cidx = 0;
416
+ let rowIdx = this.m_topIndex;
417
+ let count = this.m_row_limit;
418
+ if (this.m_auto_row_count) {
419
+ //@review should be evaluated only when row count change
420
+ this.m_row_limit = count = this.getMaxRowCount();
421
+ }
422
+ let right_pos = 0;
423
+ if ((count * this.m_itemHeight) > height) {
424
+ let w = Component.getScrollbarSize();
425
+ rc.width -= w;
426
+ right_pos = w;
427
+ }
428
+ let even = this.m_topIndex & 1 ? true : false;
429
+ this.m_visible_cells = new Map();
430
+ // passe 0 - all created cells are moved to the recycler
431
+ this.m_used_cells.forEach((c) => {
432
+ this.m_recycler.push(c);
433
+ });
434
+ this.m_used_cells = [];
435
+ // pass 1 - compute column widths
436
+ let calcw = this._calcColWidths(rc.width);
437
+ //
438
+ let full_width = 0;
439
+ for (let i = 0; i < calcw.length; i++) {
440
+ full_width += calcw[i];
441
+ }
442
+ if (full_width <= rc.width) {
443
+ this.m_view.setStyleValue('overflow-x', 'hidden');
444
+ this.m_header.setStyleValue('width', rc.width);
445
+ this.m_container.setStyleValue('width', rc.width);
446
+ this.m_container.setStyle({
447
+ height: count * this.m_itemHeight,
448
+ });
449
+ }
450
+ else {
451
+ this.m_header.setStyleValue('width', full_width);
452
+ this.m_container.setStyleValue('width', full_width);
453
+ this.m_view.setStyleValue('overflow-x', 'visible');
454
+ this.m_container.setStyle({
455
+ height: count * this.m_itemHeight,
456
+ width: full_width
457
+ });
458
+ }
459
+ this.m_view.addClass('@hidden');
460
+ // pass 2 - build cells
461
+ let limit = 100;
462
+ while (y < height && rowIdx < count && --limit > 0) {
463
+ let rowdata = this.m_rows_data.get(rowIdx);
464
+ let x = 0;
465
+ let cols = this.m_columns.map((col, colIdx) => {
466
+ let cls = '@cell c' + colIdx;
467
+ if (col.align) {
468
+ cls += ' ' + col.align;
469
+ }
470
+ if (col.cls) {
471
+ cls += ' ' + col.cls;
472
+ }
473
+ let cell;
474
+ let celldata = this._getCellData(rowIdx, colIdx);
475
+ let text = celldata.text;
476
+ if (col.renderer && text.length) {
477
+ text = col.renderer(text, { row: rowIdx, col: colIdx });
478
+ }
479
+ //if( text.length==0 ) {
480
+ // text = '&nbsp;'
481
+ //}
482
+ cls += (even ? ' even' : ' odd');
483
+ if (rowdata) {
484
+ cls += ' ' + rowdata;
485
+ }
486
+ cell = this._createCell();
487
+ this.m_used_cells.push(cell);
488
+ cell.setContent(text); // always because cell reuse
489
+ cell.addClass(cls);
490
+ cell.setStyle({
491
+ left: x,
492
+ top: top + y,
493
+ width: calcw[colIdx],
494
+ height: this.m_itemHeight
495
+ });
496
+ if (this.m_selection.row == rowIdx && this.m_selection.col == colIdx) {
497
+ cell.addClass('@selected');
498
+ }
499
+ cell.setData('row-id', rowIdx);
500
+ cell.setData('col-id', colIdx);
501
+ if (celldata.cls) {
502
+ cell.addClass(celldata.cls);
503
+ }
504
+ this.m_visible_cells.set(_mkid(rowIdx, colIdx), cell);
505
+ x += calcw[colIdx];
506
+ return cell;
507
+ });
508
+ even = !even;
509
+ y += this.m_itemHeight;
510
+ rowIdx++;
511
+ cidx++;
512
+ //rows.splice( rows.length, 0, ...cols );
513
+ }
514
+ // if some cells are still in cache, hide them
515
+ this.m_recycler.forEach((c) => {
516
+ c.addClass('@hidden');
517
+ });
518
+ this.m_row_count = cidx;
519
+ //this.m_container.setContent( <ComponentContent>rows);
520
+ this.m_view.removeClass('@hidden');
521
+ this.setClass('empty', count == 0);
522
+ }
523
+ /** @ignore */
524
+ _itemClick(e) {
525
+ let dom = e.target;
526
+ if (this.m_editor && this.m_editor.dom.contains(dom)) {
527
+ return;
528
+ }
529
+ let itm = Component.getElement(dom, Component);
530
+ if (!itm) {
531
+ return;
532
+ }
533
+ let rowIdx = itm.getData('row-id'), colIdx = itm.getData('col-id');
534
+ if (rowIdx === undefined || colIdx === undefined) {
535
+ return;
536
+ }
537
+ this._selectItem(rowIdx, colIdx);
538
+ }
539
+ _itemDblClick(e) {
540
+ let dom = e.target;
541
+ if (this.m_editor && this.m_editor.dom.contains(dom)) {
542
+ return;
543
+ }
544
+ let itm = Component.getElement(dom), rowIdx = itm.getData('row-id'), colIdx = itm.getData('col-id');
545
+ if (rowIdx === undefined || colIdx === undefined) {
546
+ return;
547
+ }
548
+ this.emit('dblClick', EvDblClick({ row: rowIdx, col: colIdx }));
549
+ this.editCell(rowIdx, colIdx);
550
+ }
551
+ /**
552
+ *
553
+ * @param rowIdx
554
+ * @param colIdx
555
+ * @param scrollIntoView
556
+ */
557
+ _selectItem(rowIdx, colIdx, scrollIntoView) {
558
+ if (rowIdx < 0) {
559
+ rowIdx = 0;
560
+ }
561
+ if (rowIdx > this.m_row_limit - 1) {
562
+ rowIdx = this.m_row_limit - 1;
563
+ }
564
+ if (colIdx < 0) {
565
+ colIdx = 0;
566
+ }
567
+ let lastcol = this.m_columns.length - 1;
568
+ if (colIdx > lastcol) {
569
+ colIdx = lastcol;
570
+ }
571
+ if (this.m_selection.row == rowIdx && this.m_selection.col == colIdx) {
572
+ return;
573
+ }
574
+ this.select(rowIdx, colIdx, scrollIntoView);
575
+ }
576
+ _scrollIntoView(row, col) {
577
+ let doscroll = (itm, mode = 'nearest') => {
578
+ itm.scrollIntoView({
579
+ block: mode //<ScrollLogicalPosition>sens ?? 'nearest'
580
+ });
581
+ };
582
+ let last = this.m_topIndex + this.m_row_count - 1;
583
+ if (row < this.m_topIndex) {
584
+ this.m_topIndex = row;
585
+ this.m_view.dom.scrollTop = this.m_topIndex * this.m_itemHeight;
586
+ this._buildItems();
587
+ doscroll(this._findItem(row, col), 'start');
588
+ }
589
+ else if (row > last) {
590
+ this.m_topIndex = row - this.m_row_count + 1;
591
+ this.m_view.dom.scrollTop = this.m_topIndex * this.m_itemHeight;
592
+ this._buildItems();
593
+ doscroll(this._findItem(row, col), 'end');
594
+ }
595
+ else {
596
+ doscroll(this._findItem(row, col));
597
+ }
598
+ }
599
+ /**
600
+ *
601
+ * @param row
602
+ * @param col
603
+ */
604
+ _findItem(row, col) {
605
+ if (!this.m_visible_cells) {
606
+ return null;
607
+ }
608
+ return this.m_visible_cells.get(_mkid(row, col));
609
+ }
610
+ /**
611
+ *
612
+ */
613
+ _updateScroll(forceUpdate) {
614
+ if (!this?.m_view?.dom) {
615
+ return;
616
+ }
617
+ let newTop = Math.floor(this.m_view.dom.scrollTop / (this.m_itemHeight || 1));
618
+ if (newTop != this.m_topIndex || forceUpdate) {
619
+ this.m_topIndex = newTop;
620
+ this._buildItems();
621
+ }
622
+ let newLeft = this.m_view.dom.scrollLeft;
623
+ this.m_header.setStyleValue('left', -newLeft);
624
+ }
625
+ /**
626
+ *
627
+ * @param event
628
+ * @param t
629
+ */
630
+ _moveSel(sensy, sensx) {
631
+ let sel = this.m_selection;
632
+ let newRow = sel.row ?? 0;
633
+ let newCol = sel.col ?? 0;
634
+ if (sensy == 1) {
635
+ newRow++;
636
+ }
637
+ else if (sensy == -1) {
638
+ newRow--;
639
+ }
640
+ else if (sensy == 2) {
641
+ newRow += this.m_row_count - 1;
642
+ }
643
+ else if (sensy == -2) {
644
+ newRow -= this.m_row_count - 1;
645
+ }
646
+ else if (sensy == 3) {
647
+ newRow = this.m_row_limit - 1;
648
+ }
649
+ else if (sensy == -3) {
650
+ newRow = 0;
651
+ }
652
+ if (sensx == 1) {
653
+ newCol++;
654
+ }
655
+ else if (sensx == -1) {
656
+ newCol--;
657
+ }
658
+ else if (sensx == 2) {
659
+ newCol = this.m_columns.length - 1;
660
+ }
661
+ else if (sensx == -2) {
662
+ newCol = 0;
663
+ }
664
+ else if (sensx == 3) { // new editable cell skip line if needed
665
+ newCol++;
666
+ let lastcol = this.m_columns.length - 1;
667
+ l1: for (let trys = 0; trys < 2; trys++) {
668
+ while (newCol < lastcol) {
669
+ if (this.m_columns[newCol].createEditor !== null) {
670
+ break l1;
671
+ }
672
+ newCol++;
673
+ }
674
+ if (newCol > lastcol) {
675
+ newRow++;
676
+ newCol = 0;
677
+ }
678
+ }
679
+ }
680
+ else if (sensx == -3) {
681
+ newCol--;
682
+ let lastcol = this.m_columns.length - 1;
683
+ l2: for (let trys = 0; trys < 2; trys++) {
684
+ while (newCol >= 0) {
685
+ if (this.m_columns[newCol].createEditor !== null) {
686
+ break l2;
687
+ }
688
+ newCol--;
689
+ }
690
+ if (newCol < 0) {
691
+ newRow--;
692
+ newCol = lastcol;
693
+ }
694
+ }
695
+ }
696
+ this._selectItem(newRow, newCol, true);
697
+ }
698
+ _handleKey(event) {
699
+ let dom = event.target;
700
+ if (this.m_editor && this.m_editor.dom.contains(dom)) {
701
+ return;
702
+ }
703
+ switch (event.key) {
704
+ case 'ArrowDown':
705
+ case 'Down': {
706
+ this._moveSel(1, 0);
707
+ break;
708
+ }
709
+ case 'ArrowUp':
710
+ case 'Up': {
711
+ this._moveSel(-1, 0);
712
+ break;
713
+ }
714
+ case 'PageUp': {
715
+ this._moveSel(-2, 0);
716
+ break;
717
+ }
718
+ case 'PageDown': {
719
+ this._moveSel(2, 0);
720
+ break;
721
+ }
722
+ case 'ArrowLeft':
723
+ case 'Left': {
724
+ this._moveSel(0, -1);
725
+ break;
726
+ }
727
+ case 'ArrowRight':
728
+ case 'Right': {
729
+ this._moveSel(0, 1);
730
+ break;
731
+ }
732
+ case 'Home': {
733
+ if (event.ctrlKey) {
734
+ this._moveSel(-3, 0);
735
+ }
736
+ else {
737
+ this._moveSel(0, -2);
738
+ }
739
+ break;
740
+ }
741
+ case 'End': {
742
+ if (event.ctrlKey) {
743
+ this._moveSel(3, 0);
744
+ }
745
+ else {
746
+ this._moveSel(0, 2);
747
+ }
748
+ break;
749
+ }
750
+ case 'Enter': {
751
+ this.editCurCell();
752
+ event.stopPropagation();
753
+ event.preventDefault();
754
+ break;
755
+ }
756
+ case 'Delete': {
757
+ this.clearCell(this.m_selection.row, this.m_selection.col);
758
+ break;
759
+ }
760
+ default: {
761
+ //console.log( "unknown key: ", event.key);
762
+ break;
763
+ }
764
+ }
765
+ }
766
+ _keyPress(event) {
767
+ let dom = event.target;
768
+ if (this.m_editor && this.m_editor.dom.contains(dom)) {
769
+ return;
770
+ }
771
+ if (event.ctrlKey || event.altKey) {
772
+ return;
773
+ }
774
+ this.editCurCell(event.key);
775
+ }
776
+ /**
777
+ * return the selection
778
+ * { row, col }
779
+ */
780
+ getSelection() {
781
+ return this.m_selection;
782
+ }
783
+ select(row, col, scrollIntoView = true) {
784
+ if (this.m_selection.row == row && this.m_selection.col == col) {
785
+ return;
786
+ }
787
+ let oldSel = this._findItem(this.m_selection.row, this.m_selection.col);
788
+ if (oldSel) {
789
+ oldSel.removeClass('@selected');
790
+ }
791
+ this.m_selection = { row, col };
792
+ if (scrollIntoView) {
793
+ this._scrollIntoView(row, col);
794
+ }
795
+ let newSel = this._findItem(row, col);
796
+ if (newSel) {
797
+ newSel.addClass('@selected');
798
+ }
799
+ this.emit('selectionChange', EvSelectionChange({ row, col }));
800
+ }
801
+ /**
802
+ * return the row count
803
+ */
804
+ rowCount() {
805
+ return this.m_row_limit;
806
+ }
807
+ /**
808
+ * return the maximum row index filled with something
809
+ */
810
+ getMaxRowCount() {
811
+ let max_row = 0;
812
+ this.m_cells_data.forEach((c, uid) => {
813
+ let row = Math.round(uid / 1000) + 1;
814
+ if (max_row < row) {
815
+ max_row = row;
816
+ }
817
+ });
818
+ return max_row;
819
+ }
820
+ getColCount() {
821
+ return this.m_columns.length;
822
+ }
823
+ setRowStyle(row, cls) {
824
+ this.m_rows_data.set(row, cls);
825
+ if (this.m_lockupdate == 0) {
826
+ this._buildItems();
827
+ }
828
+ }
829
+ getRowStyle(row) {
830
+ return this.m_rows_data.get(row);
831
+ }
832
+ setCellStyle(row, col, cls) {
833
+ let cell = this._getCellData(row, col, true);
834
+ if (!cell) {
835
+ cell = { text: '' };
836
+ this.m_cells_data.set(_mkid(row, col), cell);
837
+ }
838
+ cell.cls = cls;
839
+ if (this.m_lockupdate == 0 && this.m_visible_cells) {
840
+ let itm = this._findItem(row, col);
841
+ if (itm) {
842
+ itm.setClass(cls, true); //todo: pb when changing classes
843
+ }
844
+ else {
845
+ this._buildItems();
846
+ }
847
+ }
848
+ }
849
+ getCellText(row, col) {
850
+ return this._getCellData(row, col).text;
851
+ }
852
+ getCellNumber(row, col) {
853
+ let text = this._getCellData(row, col).text;
854
+ return parseIntlFloat(text);
855
+ }
856
+ clearRow(row) {
857
+ for (let c = 0; c < this.m_columns.length; c++) {
858
+ this.clearCell(row, c);
859
+ }
860
+ this.update(10);
861
+ }
862
+ clearCell(row, col) {
863
+ this.setCellText(row, col, null);
864
+ }
865
+ editCurCell(forceText) {
866
+ this.editCell(this.m_selection.row, this.m_selection.col, forceText);
867
+ }
868
+ editCell(row, col, forcedText) {
869
+ if (!this.m_autoedit) {
870
+ return;
871
+ }
872
+ // disable edition
873
+ if (this.m_columns[col].createEditor === null) {
874
+ return;
875
+ }
876
+ this._scrollIntoView(row, col);
877
+ let item = this._findItem(row, col);
878
+ let place = item.dom;
879
+ let parent = place.parentElement;
880
+ let rc = place.getBoundingClientRect();
881
+ let prc = parent.getBoundingClientRect();
882
+ let cell = this._getCellData(row, col, true);
883
+ let edtBuilder = (props, col, row) => {
884
+ return new TextEdit(props);
885
+ };
886
+ if (this.m_columns[col].createEditor) {
887
+ edtBuilder = this.m_columns[col].createEditor;
888
+ }
889
+ let cellvalue = forcedText ? forcedText : (cell ? cell.text : '');
890
+ this.m_editor = edtBuilder({
891
+ cls: '@editor',
892
+ style: {
893
+ left: rc.left - prc.left,
894
+ top: rc.top - prc.top,
895
+ width: rc.width - 1,
896
+ height: rc.height - 1
897
+ },
898
+ tabIndex: false,
899
+ value: cellvalue,
900
+ data: {
901
+ row,
902
+ col
903
+ },
904
+ }, row, col);
905
+ if (!this.m_editor) {
906
+ return;
907
+ }
908
+ parent.appendChild(this.m_editor._build());
909
+ this._setupEditor();
910
+ this.m_editor.setData('old-value', cellvalue);
911
+ this.m_editor.focus();
912
+ if (this.m_editor instanceof TextEdit) {
913
+ this.m_editor.selectAll();
914
+ }
915
+ }
916
+ _setupEditor() {
917
+ let movesel = (sensy, sensx) => {
918
+ deferCall(() => {
919
+ this.killEditor(true);
920
+ this._moveSel(sensy, sensx);
921
+ this.editCurCell();
922
+ });
923
+ };
924
+ // todo: better
925
+ if (this.m_editor instanceof TextEdit) {
926
+ let editor = this.m_editor;
927
+ let input = editor.input;
928
+ input.setDomEvent('blur', () => {
929
+ this.killEditor(true);
930
+ });
931
+ input.setDomEvent('keydown', (e) => {
932
+ // prevented by edit...
933
+ if (e.defaultPrevented) {
934
+ return;
935
+ }
936
+ switch (e.key) {
937
+ case 'Escape': {
938
+ this.killEditor(false);
939
+ e.stopPropagation();
940
+ e.preventDefault();
941
+ break;
942
+ }
943
+ case 'Enter':
944
+ case 'Tab': {
945
+ let sens = 3;
946
+ if (e.shiftKey) {
947
+ sens = -3;
948
+ }
949
+ movesel(0, sens);
950
+ e.stopPropagation();
951
+ e.preventDefault();
952
+ break;
953
+ }
954
+ case 'ArrowUp':
955
+ case 'Up': {
956
+ movesel(-1, 0);
957
+ e.stopPropagation();
958
+ e.preventDefault();
959
+ break;
960
+ }
961
+ case 'ArrowDown':
962
+ case 'Down': {
963
+ movesel(1, 0);
964
+ e.stopPropagation();
965
+ e.preventDefault();
966
+ break;
967
+ }
968
+ }
969
+ });
970
+ }
971
+ else if (this.m_editor instanceof ComboBox) {
972
+ let input = this.m_editor.input;
973
+ input.setDomEvent('blur', () => {
974
+ this.killEditor(true);
975
+ });
976
+ input.setDomEvent('keydown', (e) => {
977
+ switch (e.key) {
978
+ case 'Escape': {
979
+ this.killEditor(false);
980
+ e.stopPropagation();
981
+ e.preventDefault();
982
+ break;
983
+ }
984
+ case 'Enter':
985
+ case 'Tab': {
986
+ let sens = 3;
987
+ if (e.shiftKey) {
988
+ sens = -3;
989
+ }
990
+ movesel(0, sens);
991
+ e.stopPropagation();
992
+ e.preventDefault();
993
+ break;
994
+ }
995
+ }
996
+ });
997
+ this.m_editor.showPopup();
998
+ this.m_editor.on('change', (ev) => {
999
+ this.killEditor(true);
1000
+ });
1001
+ this.m_editor.on('cancel', (ev) => {
1002
+ this.killEditor(false);
1003
+ });
1004
+ }
1005
+ }
1006
+ killEditor(save) {
1007
+ if (this.m_editor) {
1008
+ if (save) {
1009
+ let text, id;
1010
+ if (this.m_editor instanceof TextEdit) {
1011
+ text = this.m_editor.value;
1012
+ }
1013
+ else if (this.m_editor instanceof ComboBox) {
1014
+ id = this.m_editor.value;
1015
+ text = this.m_editor.valueText;
1016
+ }
1017
+ let row = this.m_editor.getData('row');
1018
+ let col = this.m_editor.getData('col');
1019
+ let old = this.m_editor.getData('old-value');
1020
+ this.setCellText(row, col, text);
1021
+ const ev = EvChange(text, { row, col, oldValue: old, id });
1022
+ this.emit('change', ev);
1023
+ if (ev.defaultPrevented) {
1024
+ this.setCellText(row, col, old);
1025
+ }
1026
+ }
1027
+ // cannot dipose while handling blur event, so we defer...
1028
+ let t = this.m_editor;
1029
+ asap(() => {
1030
+ t.dispose();
1031
+ });
1032
+ this.m_editor = null;
1033
+ this.focus();
1034
+ }
1035
+ }
1036
+ clearData() {
1037
+ this.m_cells_data = new Map();
1038
+ this.m_rows_data = new Map();
1039
+ }
1040
+ setCellText(row, col, value) {
1041
+ if (value == null || value.length == 0) {
1042
+ this.m_cells_data.delete(_mkid(row, col));
1043
+ value = ''; //'&nbsp';
1044
+ }
1045
+ else {
1046
+ let cell = this._getCellData(row, col, true);
1047
+ if (!cell) {
1048
+ cell = {};
1049
+ }
1050
+ cell.text = value;
1051
+ this.m_cells_data.set(_mkid(row, col), cell);
1052
+ }
1053
+ if (this.m_lockupdate == 0 && this.m_visible_cells) {
1054
+ let itm = this._findItem(row, col);
1055
+ if (itm) {
1056
+ if (this.m_columns[col].renderer) {
1057
+ value = this.m_columns[col].renderer(value, { row, col });
1058
+ }
1059
+ itm.setContent(value);
1060
+ }
1061
+ else {
1062
+ this._buildItems();
1063
+ }
1064
+ }
1065
+ }
1066
+ lockUpdate(start) {
1067
+ if (start) {
1068
+ this.m_lockupdate++;
1069
+ }
1070
+ else {
1071
+ if (--this.m_lockupdate == 0) {
1072
+ this._updateScroll(true);
1073
+ }
1074
+ }
1075
+ }
1076
+ }
1077
+ /**
1078
+ * @ignore
1079
+ */
1080
+ function _mkid(row, col) {
1081
+ return row * 1000 + col;
1082
+ }
1083
+ /**
1084
+ * @ignore
1085
+ */
1086
+ function _getid(key) {
1087
+ return {
1088
+ row: Math.floor(key / 1000) | 0,
1089
+ col: (key % 1000) | 0
1090
+ };
1091
+ }