@babylonjs/gui 9.13.0 → 9.15.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 (325) hide show
  1. package/2D/FrameGraph/pure.d.ts +2 -0
  2. package/2D/FrameGraph/pure.js +3 -0
  3. package/2D/FrameGraph/pure.js.map +1 -0
  4. package/2D/FrameGraph/renderGraphGUIBlock.d.ts +3 -41
  5. package/2D/FrameGraph/renderGraphGUIBlock.js +5 -64
  6. package/2D/FrameGraph/renderGraphGUIBlock.js.map +1 -1
  7. package/2D/FrameGraph/renderGraphGUIBlock.pure.d.ts +48 -0
  8. package/2D/FrameGraph/renderGraphGUIBlock.pure.js +78 -0
  9. package/2D/FrameGraph/renderGraphGUIBlock.pure.js.map +1 -0
  10. package/2D/advancedDynamicTexture.d.ts +2 -2
  11. package/2D/advancedDynamicTexture.js +2 -2
  12. package/2D/advancedDynamicTexture.js.map +1 -1
  13. package/2D/controls/button.d.ts +3 -107
  14. package/2D/controls/button.js +5 -243
  15. package/2D/controls/button.js.map +1 -1
  16. package/2D/controls/button.pure.d.ts +114 -0
  17. package/2D/controls/button.pure.js +257 -0
  18. package/2D/controls/button.pure.js.map +1 -0
  19. package/2D/controls/checkbox.d.ts +3 -51
  20. package/2D/controls/checkbox.js +5 -161
  21. package/2D/controls/checkbox.js.map +1 -1
  22. package/2D/controls/checkbox.pure.d.ts +58 -0
  23. package/2D/controls/checkbox.pure.js +175 -0
  24. package/2D/controls/checkbox.pure.js.map +1 -0
  25. package/2D/controls/colorpicker.d.ts +5 -101
  26. package/2D/controls/colorpicker.js +7 -1394
  27. package/2D/controls/colorpicker.js.map +1 -1
  28. package/2D/controls/colorpicker.pure.d.ts +106 -0
  29. package/2D/controls/colorpicker.pure.js +1406 -0
  30. package/2D/controls/colorpicker.pure.js.map +1 -0
  31. package/2D/controls/container.d.ts +3 -177
  32. package/2D/controls/container.js +5 -615
  33. package/2D/controls/container.js.map +1 -1
  34. package/2D/controls/container.pure.d.ts +184 -0
  35. package/2D/controls/container.pure.js +629 -0
  36. package/2D/controls/container.pure.js.map +1 -0
  37. package/2D/controls/control.d.ts +3 -944
  38. package/2D/controls/control.js +5 -2457
  39. package/2D/controls/control.js.map +1 -1
  40. package/2D/controls/control.pure.d.ts +951 -0
  41. package/2D/controls/control.pure.js +2471 -0
  42. package/2D/controls/control.pure.js.map +1 -0
  43. package/2D/controls/displayGrid.d.ts +5 -53
  44. package/2D/controls/displayGrid.js +7 -201
  45. package/2D/controls/displayGrid.js.map +1 -1
  46. package/2D/controls/displayGrid.pure.d.ts +58 -0
  47. package/2D/controls/displayGrid.pure.js +213 -0
  48. package/2D/controls/displayGrid.pure.js.map +1 -0
  49. package/2D/controls/ellipse.d.ts +5 -25
  50. package/2D/controls/ellipse.js +7 -92
  51. package/2D/controls/ellipse.js.map +1 -1
  52. package/2D/controls/ellipse.pure.d.ts +30 -0
  53. package/2D/controls/ellipse.pure.js +104 -0
  54. package/2D/controls/ellipse.pure.js.map +1 -0
  55. package/2D/controls/focusableButton.d.ts +3 -15
  56. package/2D/controls/focusableButton.js +5 -22
  57. package/2D/controls/focusableButton.js.map +1 -1
  58. package/2D/controls/focusableButton.pure.d.ts +22 -0
  59. package/2D/controls/focusableButton.pure.js +36 -0
  60. package/2D/controls/focusableButton.pure.js.map +1 -0
  61. package/2D/controls/gradient/LinearGradient.d.ts +3 -43
  62. package/2D/controls/gradient/LinearGradient.js +5 -70
  63. package/2D/controls/gradient/LinearGradient.js.map +1 -1
  64. package/2D/controls/gradient/LinearGradient.pure.d.ts +50 -0
  65. package/2D/controls/gradient/LinearGradient.pure.js +84 -0
  66. package/2D/controls/gradient/LinearGradient.pure.js.map +1 -0
  67. package/2D/controls/gradient/RadialGradient.d.ts +3 -51
  68. package/2D/controls/gradient/RadialGradient.js +5 -86
  69. package/2D/controls/gradient/RadialGradient.js.map +1 -1
  70. package/2D/controls/gradient/RadialGradient.pure.d.ts +58 -0
  71. package/2D/controls/gradient/RadialGradient.pure.js +100 -0
  72. package/2D/controls/gradient/RadialGradient.pure.js.map +1 -0
  73. package/2D/controls/gradient/pure.d.ts +3 -0
  74. package/2D/controls/gradient/pure.js +4 -0
  75. package/2D/controls/gradient/pure.js.map +1 -0
  76. package/2D/controls/grid.d.ts +3 -149
  77. package/2D/controls/grid.js +5 -525
  78. package/2D/controls/grid.js.map +1 -1
  79. package/2D/controls/grid.pure.d.ts +156 -0
  80. package/2D/controls/grid.pure.js +539 -0
  81. package/2D/controls/grid.pure.js.map +1 -0
  82. package/2D/controls/image.d.ts +3 -226
  83. package/2D/controls/image.js +5 -913
  84. package/2D/controls/image.js.map +1 -1
  85. package/2D/controls/image.pure.d.ts +233 -0
  86. package/2D/controls/image.pure.js +927 -0
  87. package/2D/controls/image.pure.js.map +1 -0
  88. package/2D/controls/inputPassword.d.ts +3 -7
  89. package/2D/controls/inputPassword.js +5 -19
  90. package/2D/controls/inputPassword.js.map +1 -1
  91. package/2D/controls/inputPassword.pure.d.ts +14 -0
  92. package/2D/controls/inputPassword.pure.js +33 -0
  93. package/2D/controls/inputPassword.pure.js.map +1 -0
  94. package/2D/controls/inputText.d.ts +3 -202
  95. package/2D/controls/inputText.js +5 -1050
  96. package/2D/controls/inputText.js.map +1 -1
  97. package/2D/controls/inputText.pure.d.ts +209 -0
  98. package/2D/controls/inputText.pure.js +1064 -0
  99. package/2D/controls/inputText.pure.js.map +1 -0
  100. package/2D/controls/inputTextArea.d.ts +3 -140
  101. package/2D/controls/inputTextArea.js +5 -1023
  102. package/2D/controls/inputTextArea.js.map +1 -1
  103. package/2D/controls/inputTextArea.pure.d.ts +147 -0
  104. package/2D/controls/inputTextArea.pure.js +1037 -0
  105. package/2D/controls/inputTextArea.pure.js.map +1 -0
  106. package/2D/controls/line.d.ts +5 -74
  107. package/2D/controls/line.js +7 -234
  108. package/2D/controls/line.js.map +1 -1
  109. package/2D/controls/line.pure.d.ts +79 -0
  110. package/2D/controls/line.pure.js +246 -0
  111. package/2D/controls/line.pure.js.map +1 -0
  112. package/2D/controls/multiLine.d.ts +3 -73
  113. package/2D/controls/multiLine.js +5 -234
  114. package/2D/controls/multiLine.js.map +1 -1
  115. package/2D/controls/multiLine.pure.d.ts +80 -0
  116. package/2D/controls/multiLine.pure.js +248 -0
  117. package/2D/controls/multiLine.pure.js.map +1 -0
  118. package/2D/controls/pure.d.ts +38 -0
  119. package/2D/controls/pure.js +39 -0
  120. package/2D/controls/pure.js.map +1 -0
  121. package/2D/controls/radioButton.d.ts +3 -47
  122. package/2D/controls/radioButton.js +5 -182
  123. package/2D/controls/radioButton.js.map +1 -1
  124. package/2D/controls/radioButton.pure.d.ts +54 -0
  125. package/2D/controls/radioButton.pure.js +196 -0
  126. package/2D/controls/radioButton.pure.js.map +1 -0
  127. package/2D/controls/rectangle.d.ts +5 -43
  128. package/2D/controls/rectangle.js +7 -205
  129. package/2D/controls/rectangle.js.map +1 -1
  130. package/2D/controls/rectangle.pure.d.ts +48 -0
  131. package/2D/controls/rectangle.pure.js +217 -0
  132. package/2D/controls/rectangle.pure.js.map +1 -0
  133. package/2D/controls/scrollViewers/pure.d.ts +2 -0
  134. package/2D/controls/scrollViewers/pure.js +3 -0
  135. package/2D/controls/scrollViewers/pure.js.map +1 -0
  136. package/2D/controls/scrollViewers/scrollViewer.d.ts +3 -176
  137. package/2D/controls/scrollViewers/scrollViewer.js +5 -584
  138. package/2D/controls/scrollViewers/scrollViewer.js.map +1 -1
  139. package/2D/controls/scrollViewers/scrollViewer.pure.d.ts +183 -0
  140. package/2D/controls/scrollViewers/scrollViewer.pure.js +598 -0
  141. package/2D/controls/scrollViewers/scrollViewer.pure.js.map +1 -0
  142. package/2D/controls/scrollViewers/scrollViewerWindow.d.ts +1 -1
  143. package/2D/controls/scrollViewers/scrollViewerWindow.js +2 -2
  144. package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -1
  145. package/2D/controls/selector.d.ts +2 -2
  146. package/2D/controls/selector.js +8 -8
  147. package/2D/controls/selector.js.map +1 -1
  148. package/2D/controls/sliders/baseSlider.d.ts +1 -1
  149. package/2D/controls/sliders/baseSlider.js +1 -1
  150. package/2D/controls/sliders/baseSlider.js.map +1 -1
  151. package/2D/controls/sliders/imageBasedSlider.d.ts +3 -45
  152. package/2D/controls/sliders/imageBasedSlider.js +5 -165
  153. package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
  154. package/2D/controls/sliders/imageBasedSlider.pure.d.ts +52 -0
  155. package/2D/controls/sliders/imageBasedSlider.pure.js +179 -0
  156. package/2D/controls/sliders/imageBasedSlider.pure.js.map +1 -0
  157. package/2D/controls/sliders/pure.d.ts +4 -0
  158. package/2D/controls/sliders/pure.js +5 -0
  159. package/2D/controls/sliders/pure.js.map +1 -0
  160. package/2D/controls/sliders/scrollBar.d.ts +3 -48
  161. package/2D/controls/sliders/scrollBar.js +5 -170
  162. package/2D/controls/sliders/scrollBar.js.map +1 -1
  163. package/2D/controls/sliders/scrollBar.pure.d.ts +55 -0
  164. package/2D/controls/sliders/scrollBar.pure.js +184 -0
  165. package/2D/controls/sliders/scrollBar.pure.js.map +1 -0
  166. package/2D/controls/sliders/slider.d.ts +3 -44
  167. package/2D/controls/sliders/slider.js +5 -278
  168. package/2D/controls/sliders/slider.js.map +1 -1
  169. package/2D/controls/sliders/slider.pure.d.ts +51 -0
  170. package/2D/controls/sliders/slider.pure.js +292 -0
  171. package/2D/controls/sliders/slider.pure.js.map +1 -0
  172. package/2D/controls/stackPanel.d.ts +3 -62
  173. package/2D/controls/stackPanel.js +5 -243
  174. package/2D/controls/stackPanel.js.map +1 -1
  175. package/2D/controls/stackPanel.pure.d.ts +69 -0
  176. package/2D/controls/stackPanel.pure.js +257 -0
  177. package/2D/controls/stackPanel.pure.js.map +1 -0
  178. package/2D/controls/statics.d.ts +3 -4
  179. package/2D/controls/statics.js +5 -47
  180. package/2D/controls/statics.js.map +1 -1
  181. package/2D/controls/statics.pure.d.ts +11 -0
  182. package/2D/controls/statics.pure.js +61 -0
  183. package/2D/controls/statics.pure.js.map +1 -0
  184. package/2D/controls/textBlock.d.ts +3 -217
  185. package/2D/controls/textBlock.js +5 -676
  186. package/2D/controls/textBlock.js.map +1 -1
  187. package/2D/controls/textBlock.pure.d.ts +224 -0
  188. package/2D/controls/textBlock.pure.js +690 -0
  189. package/2D/controls/textBlock.pure.js.map +1 -0
  190. package/2D/controls/toggleButton.d.ts +3 -91
  191. package/2D/controls/toggleButton.js +5 -226
  192. package/2D/controls/toggleButton.js.map +1 -1
  193. package/2D/controls/toggleButton.pure.d.ts +98 -0
  194. package/2D/controls/toggleButton.pure.js +240 -0
  195. package/2D/controls/toggleButton.pure.js.map +1 -0
  196. package/2D/controls/virtualKeyboard.d.ts +3 -100
  197. package/2D/controls/virtualKeyboard.js +5 -272
  198. package/2D/controls/virtualKeyboard.js.map +1 -1
  199. package/2D/controls/virtualKeyboard.pure.d.ts +107 -0
  200. package/2D/controls/virtualKeyboard.pure.js +286 -0
  201. package/2D/controls/virtualKeyboard.pure.js.map +1 -0
  202. package/2D/math2D.d.ts +1 -1
  203. package/2D/math2D.js +1 -1
  204. package/2D/math2D.js.map +1 -1
  205. package/2D/measure.js +1 -1
  206. package/2D/measure.js.map +1 -1
  207. package/2D/pure.d.ts +13 -0
  208. package/2D/pure.js +15 -0
  209. package/2D/pure.js.map +1 -0
  210. package/3D/controls/MRTK3/touchHolographicButton.d.ts +4 -4
  211. package/3D/controls/MRTK3/touchHolographicButton.js +10 -10
  212. package/3D/controls/MRTK3/touchHolographicButton.js.map +1 -1
  213. package/3D/controls/holographicBackplate.d.ts +1 -1
  214. package/3D/controls/holographicBackplate.js +1 -1
  215. package/3D/controls/holographicBackplate.js.map +1 -1
  216. package/3D/controls/holographicButton.d.ts +1 -1
  217. package/3D/controls/holographicButton.js +4 -4
  218. package/3D/controls/holographicButton.js.map +1 -1
  219. package/3D/controls/holographicSlate.js +4 -4
  220. package/3D/controls/holographicSlate.js.map +1 -1
  221. package/3D/controls/pure.d.ts +23 -0
  222. package/3D/controls/pure.js +24 -0
  223. package/3D/controls/pure.js.map +1 -0
  224. package/3D/controls/slider3D.d.ts +3 -3
  225. package/3D/controls/slider3D.js +3 -3
  226. package/3D/controls/slider3D.js.map +1 -1
  227. package/3D/controls/touchHolographicButton.d.ts +2 -2
  228. package/3D/controls/touchHolographicButton.js +5 -5
  229. package/3D/controls/touchHolographicButton.js.map +1 -1
  230. package/3D/controls/touchHolographicMenu.js +1 -1
  231. package/3D/controls/touchHolographicMenu.js.map +1 -1
  232. package/3D/gizmos/gizmoHandle.d.ts +1 -1
  233. package/3D/gizmos/gizmoHandle.js +1 -1
  234. package/3D/gizmos/gizmoHandle.js.map +1 -1
  235. package/3D/gizmos/pure.d.ts +3 -0
  236. package/3D/gizmos/pure.js +4 -0
  237. package/3D/gizmos/pure.js.map +1 -0
  238. package/3D/materials/fluent/fluentMaterial.d.ts +5 -100
  239. package/3D/materials/fluent/fluentMaterial.js +7 -305
  240. package/3D/materials/fluent/fluentMaterial.js.map +1 -1
  241. package/3D/materials/fluent/fluentMaterial.pure.d.ts +105 -0
  242. package/3D/materials/fluent/fluentMaterial.pure.js +320 -0
  243. package/3D/materials/fluent/fluentMaterial.pure.js.map +1 -0
  244. package/3D/materials/fluent/pure.d.ts +2 -0
  245. package/3D/materials/fluent/pure.js +3 -0
  246. package/3D/materials/fluent/pure.js.map +1 -0
  247. package/3D/materials/fluentBackplate/fluentBackplateMaterial.d.ts +5 -164
  248. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +7 -488
  249. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -1
  250. package/3D/materials/fluentBackplate/fluentBackplateMaterial.pure.d.ts +169 -0
  251. package/3D/materials/fluentBackplate/fluentBackplateMaterial.pure.js +503 -0
  252. package/3D/materials/fluentBackplate/fluentBackplateMaterial.pure.js.map +1 -0
  253. package/3D/materials/fluentBackplate/pure.d.ts +2 -0
  254. package/3D/materials/fluentBackplate/pure.js +3 -0
  255. package/3D/materials/fluentBackplate/pure.js.map +1 -0
  256. package/3D/materials/fluentButton/fluentButtonMaterial.d.ts +5 -200
  257. package/3D/materials/fluentButton/fluentButtonMaterial.js +7 -563
  258. package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -1
  259. package/3D/materials/fluentButton/fluentButtonMaterial.pure.d.ts +205 -0
  260. package/3D/materials/fluentButton/fluentButtonMaterial.pure.js +578 -0
  261. package/3D/materials/fluentButton/fluentButtonMaterial.pure.js.map +1 -0
  262. package/3D/materials/fluentButton/pure.d.ts +2 -0
  263. package/3D/materials/fluentButton/pure.js +3 -0
  264. package/3D/materials/fluentButton/pure.js.map +1 -0
  265. package/3D/materials/fluentMaterial.d.ts +1 -1
  266. package/3D/materials/fluentMaterial.js +1 -1
  267. package/3D/materials/fluentMaterial.js.map +1 -1
  268. package/3D/materials/handle/handleMaterial.d.ts +5 -66
  269. package/3D/materials/handle/handleMaterial.js +5 -118
  270. package/3D/materials/handle/handleMaterial.js.map +1 -1
  271. package/3D/materials/handle/handleMaterial.pure.d.ts +66 -0
  272. package/3D/materials/handle/handleMaterial.pure.js +121 -0
  273. package/3D/materials/handle/handleMaterial.pure.js.map +1 -0
  274. package/3D/materials/handle/pure.d.ts +2 -0
  275. package/3D/materials/handle/pure.js +3 -0
  276. package/3D/materials/handle/pure.js.map +1 -0
  277. package/3D/materials/mrdl/mrdlBackglowMaterial.d.ts +5 -85
  278. package/3D/materials/mrdl/mrdlBackglowMaterial.js +7 -299
  279. package/3D/materials/mrdl/mrdlBackglowMaterial.js.map +1 -1
  280. package/3D/materials/mrdl/mrdlBackglowMaterial.pure.d.ts +90 -0
  281. package/3D/materials/mrdl/mrdlBackglowMaterial.pure.js +314 -0
  282. package/3D/materials/mrdl/mrdlBackglowMaterial.pure.js.map +1 -0
  283. package/3D/materials/mrdl/mrdlBackplateMaterial.d.ts +5 -145
  284. package/3D/materials/mrdl/mrdlBackplateMaterial.js +7 -433
  285. package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -1
  286. package/3D/materials/mrdl/mrdlBackplateMaterial.pure.d.ts +157 -0
  287. package/3D/materials/mrdl/mrdlBackplateMaterial.pure.js +455 -0
  288. package/3D/materials/mrdl/mrdlBackplateMaterial.pure.js.map +1 -0
  289. package/3D/materials/mrdl/mrdlFrontplateMaterial.d.ts +5 -183
  290. package/3D/materials/mrdl/mrdlFrontplateMaterial.js +7 -532
  291. package/3D/materials/mrdl/mrdlFrontplateMaterial.js.map +1 -1
  292. package/3D/materials/mrdl/mrdlFrontplateMaterial.pure.d.ts +188 -0
  293. package/3D/materials/mrdl/mrdlFrontplateMaterial.pure.js +547 -0
  294. package/3D/materials/mrdl/mrdlFrontplateMaterial.pure.js.map +1 -0
  295. package/3D/materials/mrdl/mrdlInnerquadMaterial.d.ts +5 -54
  296. package/3D/materials/mrdl/mrdlInnerquadMaterial.js +7 -227
  297. package/3D/materials/mrdl/mrdlInnerquadMaterial.js.map +1 -1
  298. package/3D/materials/mrdl/mrdlInnerquadMaterial.pure.d.ts +59 -0
  299. package/3D/materials/mrdl/mrdlInnerquadMaterial.pure.js +242 -0
  300. package/3D/materials/mrdl/mrdlInnerquadMaterial.pure.js.map +1 -0
  301. package/3D/materials/mrdl/mrdlSliderBarMaterial.d.ts +5 -334
  302. package/3D/materials/mrdl/mrdlSliderBarMaterial.js +7 -855
  303. package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -1
  304. package/3D/materials/mrdl/mrdlSliderBarMaterial.pure.d.ts +346 -0
  305. package/3D/materials/mrdl/mrdlSliderBarMaterial.pure.js +877 -0
  306. package/3D/materials/mrdl/mrdlSliderBarMaterial.pure.js.map +1 -0
  307. package/3D/materials/mrdl/mrdlSliderThumbMaterial.d.ts +5 -334
  308. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +7 -855
  309. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -1
  310. package/3D/materials/mrdl/mrdlSliderThumbMaterial.pure.d.ts +346 -0
  311. package/3D/materials/mrdl/mrdlSliderThumbMaterial.pure.js +877 -0
  312. package/3D/materials/mrdl/mrdlSliderThumbMaterial.pure.js.map +1 -0
  313. package/3D/materials/mrdl/pure.d.ts +7 -0
  314. package/3D/materials/mrdl/pure.js +8 -0
  315. package/3D/materials/mrdl/pure.js.map +1 -0
  316. package/3D/materials/pure.d.ts +6 -0
  317. package/3D/materials/pure.js +8 -0
  318. package/3D/materials/pure.js.map +1 -0
  319. package/3D/pure.d.ts +6 -0
  320. package/3D/pure.js +8 -0
  321. package/3D/pure.js.map +1 -0
  322. package/package.json +50 -3
  323. package/pure.d.ts +3 -0
  324. package/pure.js +5 -0
  325. package/pure.js.map +1 -0
@@ -1,1026 +1,8 @@
1
- import { __decorate } from "@babylonjs/core/tslib.es6.js";
2
- import { Observable } from "@babylonjs/core/Misc/observable.js";
3
- import { Control } from "./control.js";
4
- import { ValueAndUnit } from "../valueAndUnit.js";
5
- import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
6
- import { InputText } from "./inputText.js";
7
- import { serialize } from "@babylonjs/core/Misc/decorators.js";
8
1
  /**
9
- * Class used to create input text control
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./inputTextArea.pure" for tree-shakeable, side-effect-free usage.
10
4
  */
11
- export class InputTextArea extends InputText {
12
- /** Gets or sets a boolean indicating if the control can auto stretch its height to adapt to the text */
13
- get autoStretchHeight() {
14
- return this._autoStretchHeight;
15
- }
16
- set autoStretchHeight(value) {
17
- if (this._autoStretchHeight === value) {
18
- return;
19
- }
20
- this._autoStretchHeight = value;
21
- this._markAsDirty();
22
- }
23
- set height(value) {
24
- this.fixedRatioMasterIsWidth = false;
25
- if (this._height.toString(this._host) === value) {
26
- return;
27
- }
28
- if (this._height.fromString(value)) {
29
- this._markAsDirty();
30
- }
31
- this._autoStretchHeight = false;
32
- }
33
- get maxHeight() {
34
- return this._maxHeight.toString(this._host);
35
- }
36
- /** Gets the maximum width allowed by the control in pixels */
37
- get maxHeightInPixels() {
38
- return this._maxHeight.getValueInPixel(this._host, this._cachedParentMeasure.height);
39
- }
40
- set maxHeight(value) {
41
- if (this._maxHeight.toString(this._host) === value) {
42
- return;
43
- }
44
- if (this._maxHeight.fromString(value)) {
45
- this._markAsDirty();
46
- }
47
- }
48
- /**
49
- * Creates a new InputTextArea
50
- * @param name defines the control name
51
- * @param text defines the text of the control
52
- */
53
- constructor(name, text = "") {
54
- super(name);
55
- this.name = name;
56
- this._textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
57
- this._textVerticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
58
- this._prevText = this.text;
59
- this._lineSpacing = new ValueAndUnit(0);
60
- this._maxHeight = new ValueAndUnit(1, ValueAndUnit.UNITMODE_PERCENTAGE, false);
61
- /**
62
- * An event triggered after the text was broken up into lines
63
- */
64
- this.onLinesReadyObservable = new Observable();
65
- this.text = text;
66
- this.isPointerBlocker = true;
67
- this.onLinesReadyObservable.add(() => this._updateCursorPosition());
68
- this._highlightCursorInfo = {
69
- initialStartIndex: -1,
70
- initialRelativeStartIndex: -1,
71
- initialLineIndex: -1,
72
- };
73
- this._cursorInfo = {
74
- globalStartIndex: 0,
75
- globalEndIndex: 0,
76
- relativeEndIndex: 0,
77
- relativeStartIndex: 0,
78
- currentLineIndex: 0,
79
- };
80
- }
81
- _getTypeName() {
82
- return "InputTextArea";
83
- }
84
- /**
85
- * Handles the keyboard event
86
- * @param evt Defines the KeyboardEvent
87
- */
88
- processKeyboard(evt) {
89
- if (this.isReadOnly) {
90
- return;
91
- }
92
- // process pressed key
93
- this.alternativeProcessKey(evt.code, evt.key, evt);
94
- this.onKeyboardEventProcessedObservable.notifyObservers(evt);
95
- }
96
- /**
97
- * Process the last keyboard input
98
- *
99
- * @param code The ascii input number
100
- * @param key The key string representation
101
- * @param evt The keyboard event emits with input
102
- * @internal
103
- */
104
- alternativeProcessKey(code, key, evt) {
105
- //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
106
- if (evt && (evt.ctrlKey || evt.metaKey) && (key === "c" || key === "v" || key === "x")) {
107
- return;
108
- }
109
- // Specific cases
110
- switch (code) {
111
- case "Period": //SLASH
112
- if (evt && evt.shiftKey) {
113
- evt.preventDefault();
114
- }
115
- break;
116
- case "Backspace": // BACKSPACE
117
- if (!this._isTextHighlightOn && this._cursorInfo.globalStartIndex > 0) {
118
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
119
- this._cursorInfo.globalStartIndex--;
120
- }
121
- this._prevText = this._textWrapper.text;
122
- this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex);
123
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
124
- if (evt) {
125
- evt.preventDefault();
126
- }
127
- this._blinkIsEven = false;
128
- this._isTextHighlightOn = false;
129
- this._textHasChanged();
130
- break;
131
- case "Delete": // DELETE
132
- if (!this._isTextHighlightOn && this._cursorInfo.globalEndIndex < this.text.length) {
133
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex + 1;
134
- }
135
- this._prevText = this._textWrapper.text;
136
- this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex);
137
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
138
- if (evt) {
139
- evt.preventDefault();
140
- }
141
- this._blinkIsEven = false;
142
- this._isTextHighlightOn = false;
143
- this._textHasChanged();
144
- break;
145
- case "NumpadEnter": // NUMPAD ENTER
146
- case "Enter": // RETURN
147
- this._prevText = this._textWrapper.text;
148
- this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex, "\n");
149
- this._cursorInfo.globalStartIndex++;
150
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
151
- this._blinkIsEven = false;
152
- this._isTextHighlightOn = false;
153
- this._textHasChanged();
154
- return;
155
- case "End": // END
156
- this._cursorInfo.globalStartIndex = this.text.length;
157
- this._blinkIsEven = false;
158
- this._isTextHighlightOn = false;
159
- this._markAsDirty();
160
- return;
161
- case "Home": // HOME
162
- this._cursorInfo.globalStartIndex = 0;
163
- this._blinkIsEven = false;
164
- this._isTextHighlightOn = false;
165
- this._markAsDirty();
166
- return;
167
- case "ArrowLeft": // LEFT
168
- this._markAsDirty();
169
- if (evt && evt.shiftKey) {
170
- // shift + ctrl/cmd + <-
171
- if (evt.ctrlKey || evt.metaKey) {
172
- // Go to line's start by substract the relativeStartIndex to the globalStartIndex
173
- this._cursorInfo.globalStartIndex -= this._cursorInfo.relativeStartIndex;
174
- this._cursorInfo.globalEndIndex = this._highlightCursorInfo.initialStartIndex;
175
- }
176
- // store the starting point
177
- if (!this._isTextHighlightOn) {
178
- this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
179
- this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
180
- this._highlightCursorInfo.initialRelativeStartIndex = this._cursorInfo.relativeStartIndex;
181
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
182
- this._cursorInfo.globalStartIndex--;
183
- this._isTextHighlightOn = true;
184
- }
185
- else {
186
- if (this._cursorInfo.globalEndIndex > this._highlightCursorInfo.initialStartIndex) {
187
- this._cursorInfo.globalEndIndex--;
188
- }
189
- else {
190
- this._cursorInfo.globalStartIndex--;
191
- }
192
- }
193
- this._blinkIsEven = true;
194
- evt.preventDefault();
195
- return;
196
- }
197
- if (this._isTextHighlightOn) {
198
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
199
- }
200
- else if (evt && (evt.ctrlKey || evt.metaKey)) {
201
- // ctr + <-
202
- this._cursorInfo.globalStartIndex -= this._cursorInfo.relativeStartIndex;
203
- evt.preventDefault();
204
- }
205
- else if (this._cursorInfo.globalStartIndex > 0) {
206
- this._cursorInfo.globalStartIndex--;
207
- }
208
- // update the cursor
209
- this._blinkIsEven = false;
210
- this._isTextHighlightOn = false;
211
- return;
212
- case "ArrowRight": // RIGHT
213
- this._markAsDirty();
214
- if (evt && evt.shiftKey) {
215
- // shift + ctrl/cmd + ->
216
- if (evt.ctrlKey || evt.metaKey) {
217
- const rightDelta = this._lines[this._cursorInfo.currentLineIndex].text.length - this._cursorInfo.relativeEndIndex - 1;
218
- this._cursorInfo.globalEndIndex += rightDelta;
219
- this._cursorInfo.globalStartIndex = this._highlightCursorInfo.initialStartIndex;
220
- }
221
- // store the starting point
222
- if (!this._isTextHighlightOn) {
223
- this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
224
- this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
225
- this._highlightCursorInfo.initialRelativeStartIndex = this._cursorInfo.relativeStartIndex;
226
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
227
- this._cursorInfo.globalEndIndex++;
228
- this._isTextHighlightOn = true;
229
- }
230
- else {
231
- if (this._cursorInfo.globalStartIndex < this._highlightCursorInfo.initialStartIndex) {
232
- this._cursorInfo.globalStartIndex++;
233
- }
234
- else {
235
- this._cursorInfo.globalEndIndex++;
236
- }
237
- }
238
- this._blinkIsEven = true;
239
- evt.preventDefault();
240
- return;
241
- }
242
- if (this._isTextHighlightOn) {
243
- this._cursorInfo.globalStartIndex = this._cursorInfo.globalEndIndex;
244
- }
245
- else if (evt && (evt.ctrlKey || evt.metaKey)) {
246
- //ctr + ->
247
- const rightDelta = this._lines[this._cursorInfo.currentLineIndex].text.length - this._cursorInfo.relativeEndIndex;
248
- this._cursorInfo.globalStartIndex += rightDelta;
249
- }
250
- else if (this._cursorInfo.globalStartIndex < this.text.length) {
251
- this._cursorInfo.globalStartIndex++;
252
- }
253
- // update the cursor
254
- this._blinkIsEven = false;
255
- this._isTextHighlightOn = false;
256
- return;
257
- case "ArrowUp": // UP
258
- // update the cursor
259
- this._blinkIsEven = false;
260
- if (evt) {
261
- if (evt.shiftKey) {
262
- if (!this._isTextHighlightOn) {
263
- this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
264
- this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
265
- this._highlightCursorInfo.initialRelativeStartIndex = this._cursorInfo.relativeStartIndex;
266
- }
267
- this._isTextHighlightOn = true;
268
- this._blinkIsEven = true;
269
- }
270
- else {
271
- this._isTextHighlightOn = false;
272
- }
273
- evt.preventDefault();
274
- }
275
- if (this._cursorInfo.currentLineIndex === 0) {
276
- // First line
277
- this._cursorInfo.globalStartIndex = 0;
278
- }
279
- else {
280
- const currentLine = this._lines[this._cursorInfo.currentLineIndex];
281
- const upperLine = this._lines[this._cursorInfo.currentLineIndex - 1];
282
- let tmpIndex;
283
- let relativeIndex;
284
- if (!this._isTextHighlightOn || this._cursorInfo.currentLineIndex < this._highlightCursorInfo.initialLineIndex) {
285
- tmpIndex = this._cursorInfo.globalStartIndex;
286
- relativeIndex = this._cursorInfo.relativeStartIndex;
287
- }
288
- else {
289
- tmpIndex = this._cursorInfo.globalEndIndex;
290
- relativeIndex = this._cursorInfo.relativeEndIndex;
291
- }
292
- const currentText = currentLine.text.substring(0, relativeIndex);
293
- const currentWidth = this._contextForBreakLines.measureText(currentText).width;
294
- let upperWidth = 0;
295
- let previousWidth = 0;
296
- tmpIndex -= relativeIndex; // Start of current line
297
- tmpIndex -= upperLine.text.length + upperLine.lineEnding.length; // Start of upper line
298
- let upperLineRelativeIndex = 0;
299
- while (upperWidth < currentWidth && upperLineRelativeIndex < upperLine.text.length) {
300
- tmpIndex++;
301
- upperLineRelativeIndex++;
302
- previousWidth = Math.abs(currentWidth - upperWidth);
303
- upperWidth = this._contextForBreakLines.measureText(upperLine.text.substring(0, upperLineRelativeIndex)).width;
304
- }
305
- // Find closest move
306
- if (Math.abs(currentWidth - upperWidth) > previousWidth && upperLineRelativeIndex > 0) {
307
- tmpIndex--;
308
- }
309
- if (!this._isTextHighlightOn) {
310
- this._cursorInfo.globalStartIndex = tmpIndex;
311
- }
312
- else if (this._cursorInfo.currentLineIndex <= this._highlightCursorInfo.initialLineIndex) {
313
- this._cursorInfo.globalStartIndex = tmpIndex;
314
- this._cursorInfo.globalEndIndex = this._highlightCursorInfo.initialStartIndex;
315
- this._cursorInfo.relativeEndIndex = this._highlightCursorInfo.initialRelativeStartIndex;
316
- }
317
- else {
318
- this._cursorInfo.globalEndIndex = tmpIndex;
319
- }
320
- }
321
- this._markAsDirty();
322
- return;
323
- case "ArrowDown": // DOWN
324
- // update the cursor
325
- this._blinkIsEven = false;
326
- if (evt) {
327
- if (evt.shiftKey) {
328
- if (!this._isTextHighlightOn) {
329
- this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
330
- this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
331
- this._highlightCursorInfo.initialRelativeStartIndex = this._cursorInfo.relativeStartIndex;
332
- }
333
- this._isTextHighlightOn = true;
334
- this._blinkIsEven = true;
335
- }
336
- else {
337
- this._isTextHighlightOn = false;
338
- }
339
- evt.preventDefault();
340
- }
341
- if (this._cursorInfo.currentLineIndex === this._lines.length - 1) {
342
- // Last line
343
- this._cursorInfo.globalStartIndex = this.text.length;
344
- }
345
- else {
346
- const currentLine = this._lines[this._cursorInfo.currentLineIndex];
347
- const underLine = this._lines[this._cursorInfo.currentLineIndex + 1];
348
- let tmpIndex;
349
- let relativeIndex;
350
- if (!this._isTextHighlightOn || this._cursorInfo.currentLineIndex < this._highlightCursorInfo.initialLineIndex) {
351
- tmpIndex = this._cursorInfo.globalStartIndex;
352
- relativeIndex = this._cursorInfo.relativeStartIndex;
353
- }
354
- else {
355
- tmpIndex = this._cursorInfo.globalEndIndex;
356
- relativeIndex = this._cursorInfo.relativeEndIndex;
357
- }
358
- const currentText = currentLine.text.substring(0, relativeIndex);
359
- const currentWidth = this._contextForBreakLines.measureText(currentText).width;
360
- let underWidth = 0;
361
- let previousWidth = 0;
362
- tmpIndex += currentLine.text.length - relativeIndex + currentLine.lineEnding.length; // Start of current line
363
- let underLineRelativeIndex = 0;
364
- while (underWidth < currentWidth && underLineRelativeIndex < underLine.text.length) {
365
- tmpIndex++;
366
- underLineRelativeIndex++;
367
- previousWidth = Math.abs(currentWidth - underWidth);
368
- underWidth = this._contextForBreakLines.measureText(underLine.text.substring(0, underLineRelativeIndex)).width;
369
- }
370
- // Find closest move
371
- if (Math.abs(currentWidth - underWidth) > previousWidth && underLineRelativeIndex > 0) {
372
- tmpIndex--;
373
- }
374
- if (!this._isTextHighlightOn) {
375
- this._cursorInfo.globalStartIndex = tmpIndex;
376
- }
377
- else if (this._cursorInfo.currentLineIndex < this._highlightCursorInfo.initialLineIndex) {
378
- this._cursorInfo.globalStartIndex = tmpIndex;
379
- if (this._cursorInfo.globalStartIndex > this._cursorInfo.globalEndIndex) {
380
- this._cursorInfo.globalEndIndex += this._cursorInfo.globalStartIndex;
381
- this._cursorInfo.globalStartIndex = this._cursorInfo.globalEndIndex - this._cursorInfo.globalStartIndex;
382
- this._cursorInfo.globalEndIndex -= this._cursorInfo.globalStartIndex;
383
- }
384
- }
385
- else {
386
- this._cursorInfo.globalEndIndex = tmpIndex;
387
- this._cursorInfo.globalStartIndex = this._highlightCursorInfo.initialStartIndex;
388
- }
389
- }
390
- this._markAsDirty();
391
- return;
392
- }
393
- // special case - select all. Use key instead of code to support all keyboard layouts
394
- if (key === "a" && evt && (evt.ctrlKey || evt.metaKey)) {
395
- this.selectAllText();
396
- evt.preventDefault();
397
- return;
398
- }
399
- // Printable characters
400
- if (key?.length === 1) {
401
- evt?.preventDefault();
402
- this._currentKey = key;
403
- this.onBeforeKeyAddObservable.notifyObservers(this);
404
- key = this._currentKey;
405
- if (this._addKey) {
406
- this._isTextHighlightOn = false;
407
- this._blinkIsEven = false;
408
- this._prevText = this._textWrapper.text;
409
- this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex, key);
410
- this._cursorInfo.globalStartIndex += key.length;
411
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
412
- this._textHasChanged();
413
- }
414
- }
415
- }
416
- _parseLineWordWrap(line = "", width, context) {
417
- const lines = [];
418
- const words = line.split(" ");
419
- let lineWidth = 0;
420
- for (let n = 0; n < words.length; n++) {
421
- const testLine = n > 0 ? line + " " + words[n] : words[0];
422
- const metrics = context.measureText(testLine);
423
- const testWidth = metrics.width;
424
- if (testWidth > width) {
425
- if (n > 0) {
426
- // Avoid first word duplication if of too long
427
- lineWidth = context.measureText(line).width;
428
- lines.push({ text: line, width: lineWidth, lineEnding: " " });
429
- }
430
- line = words[n];
431
- let flushedLine = "";
432
- line.split("").map((char) => {
433
- if (context.measureText(flushedLine + char).width > width) {
434
- lines.push({ text: flushedLine, width: context.measureText(flushedLine).width, lineEnding: "" });
435
- flushedLine = "";
436
- }
437
- flushedLine += char;
438
- });
439
- line = flushedLine;
440
- // Measure remaining characters
441
- lineWidth = context.measureText(line).width;
442
- }
443
- else {
444
- lineWidth = testWidth;
445
- line = testLine;
446
- }
447
- }
448
- lines.push({ text: line, width: lineWidth, lineEnding: " " });
449
- return lines;
450
- }
451
- _breakLines(refWidth, context) {
452
- const lines = [];
453
- const _lines = (this.text || this.placeholderText).split("\n");
454
- if (this.clipContent) {
455
- for (const _line of _lines) {
456
- lines.push(...this._parseLineWordWrap(_line, refWidth, context));
457
- }
458
- }
459
- else {
460
- for (const _line of _lines) {
461
- lines.push(this._parseLine(_line, context));
462
- }
463
- }
464
- lines[lines.length - 1].lineEnding = "\n";
465
- return lines;
466
- }
467
- _parseLine(line = "", context) {
468
- return { text: line, width: context.measureText(line).width, lineEnding: " " };
469
- }
470
- /**
471
- * Processing of child right before the parent measurement update
472
- *
473
- * @param parentMeasure The parent measure
474
- * @param context The rendering canvas
475
- * @internal
476
- */
477
- _preMeasure(parentMeasure, context) {
478
- if (!this._fontOffset || this._wasDirty) {
479
- this._fontOffset = Control._GetFontOffset(context.font, this._host.getScene()?.getEngine());
480
- }
481
- let text = this._beforeRenderText(this._textWrapper).text;
482
- // placeholder conditions and color setting
483
- if (!this.text && this._placeholderText) {
484
- text = this._placeholderText;
485
- }
486
- // measures the textlength -> this.measure.width
487
- this._textWidth = context.measureText(text).width;
488
- // we double up the margin width
489
- const marginWidth = this._margin.getValueInPixel(this._host, parentMeasure.width) * 2;
490
- if (this._autoStretchWidth) {
491
- const tmpLines = text.split("\n");
492
- const longerString = tmpLines.reduce((acc, val) => {
493
- const valueLength = context.measureText(val).width;
494
- const accLength = context.measureText(acc).width;
495
- return valueLength > accLength ? val : acc;
496
- }, "");
497
- const longerStringWidth = context.measureText(longerString).width;
498
- this.width = Math.min(this._maxWidth.getValueInPixel(this._host, parentMeasure.width), longerStringWidth + marginWidth) + "px";
499
- this.autoStretchWidth = true;
500
- }
501
- this._availableWidth = this._width.getValueInPixel(this._host, parentMeasure.width) - marginWidth;
502
- // Prepare lines
503
- this._lines = this._breakLines(this._availableWidth, context);
504
- // can we find a cleaner implementation here?
505
- this._contextForBreakLines = context;
506
- if (this._autoStretchHeight) {
507
- const textHeight = this._lines.length * this._fontOffset.height;
508
- const totalHeight = textHeight + this._margin.getValueInPixel(this._host, parentMeasure.height) * 2;
509
- this.height = Math.min(this._maxHeight.getValueInPixel(this._host, parentMeasure.height), totalHeight) + "px";
510
- this._autoStretchHeight = true;
511
- }
512
- const marginHeight = this._margin.getValueInPixel(this._host, parentMeasure.height) * 2;
513
- this._availableHeight = this._height.getValueInPixel(this._host, parentMeasure.height) - marginHeight;
514
- if (this._isFocused) {
515
- this._cursorInfo.currentLineIndex = 0;
516
- let lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
517
- let tmpLength = 0;
518
- while (tmpLength + lineLength <= this._cursorInfo.globalStartIndex) {
519
- tmpLength += lineLength;
520
- if (this._cursorInfo.currentLineIndex < this._lines.length - 1) {
521
- this._cursorInfo.currentLineIndex++;
522
- lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
523
- }
524
- }
525
- }
526
- }
527
- _textHasChanged() {
528
- if (!this._prevText && this._textWrapper.text && this.placeholderText) {
529
- this._cursorInfo.currentLineIndex = 0;
530
- this._cursorInfo.globalStartIndex = 1;
531
- this._cursorInfo.globalEndIndex = 1;
532
- this._cursorInfo.relativeStartIndex = 1;
533
- this._cursorInfo.relativeEndIndex = 1;
534
- }
535
- super._textHasChanged();
536
- }
537
- _computeScroll() {
538
- this._clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
539
- this._clipTextTop = this._currentMeasure.top + this._margin.getValueInPixel(this._host, this._cachedParentMeasure.height);
540
- if (this._isFocused && this._lines[this._cursorInfo.currentLineIndex].width > this._availableWidth) {
541
- const textLeft = this._clipTextLeft - this._lines[this._cursorInfo.currentLineIndex].width + this._availableWidth;
542
- if (!this._scrollLeft) {
543
- this._scrollLeft = textLeft;
544
- }
545
- }
546
- else {
547
- this._scrollLeft = this._clipTextLeft;
548
- }
549
- if (this._isFocused) {
550
- const selectedHeight = (this._cursorInfo.currentLineIndex + 1) * this._fontOffset.height;
551
- const textTop = this._clipTextTop - selectedHeight;
552
- if (!this._scrollTop) {
553
- this._scrollTop = textTop;
554
- }
555
- }
556
- else {
557
- this._scrollTop = this._clipTextTop;
558
- }
559
- }
560
- /**
561
- * Processing of child after the parent measurement update
562
- *
563
- * @internal
564
- */
565
- _additionalProcessing() {
566
- // Flush the highlighted text each frame
567
- this.highlightedText = "";
568
- this.onLinesReadyObservable.notifyObservers(this);
569
- }
570
- _drawText(text, textWidth, y, context) {
571
- const width = this._currentMeasure.width;
572
- let x = this._scrollLeft;
573
- switch (this._textHorizontalAlignment) {
574
- case Control.HORIZONTAL_ALIGNMENT_LEFT:
575
- x += 0;
576
- break;
577
- case Control.HORIZONTAL_ALIGNMENT_RIGHT:
578
- x += width - textWidth;
579
- break;
580
- case Control.HORIZONTAL_ALIGNMENT_CENTER:
581
- x += (width - textWidth) / 2;
582
- break;
583
- }
584
- if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
585
- context.shadowColor = this.shadowColor;
586
- context.shadowBlur = this.shadowBlur;
587
- context.shadowOffsetX = this.shadowOffsetX * this._host.idealRatio;
588
- context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;
589
- }
590
- if (this.outlineWidth) {
591
- context.strokeText(text, this._currentMeasure.left + x, y);
592
- }
593
- context.fillText(text, x, y);
594
- }
595
- /**
596
- * Copy the text in the clipboard
597
- *
598
- * @param ev The clipboard event
599
- * @internal
600
- */
601
- _onCopyText(ev) {
602
- this._isTextHighlightOn = false;
603
- //when write permission to clipbaord data is denied
604
- try {
605
- ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
606
- }
607
- catch { } //pass
608
- this._host.clipboardData = this._highlightedText;
609
- }
610
- /**
611
- * Cut the text and copy it in the clipboard
612
- *
613
- * @param ev The clipboard event
614
- * @internal
615
- */
616
- _onCutText(ev) {
617
- if (!this._highlightedText) {
618
- return;
619
- }
620
- //when write permission to clipbaord data is denied
621
- try {
622
- ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
623
- }
624
- catch { } //pass
625
- this._host.clipboardData = this._highlightedText;
626
- this._prevText = this._textWrapper.text;
627
- this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex);
628
- this._textHasChanged();
629
- }
630
- /**
631
- * Paste the copied text from the clipboard
632
- *
633
- * @param ev The clipboard event
634
- * @internal
635
- */
636
- _onPasteText(ev) {
637
- let data;
638
- if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
639
- data = ev.clipboardData.getData("text/plain");
640
- }
641
- else {
642
- //get the cached data; returns blank string by default
643
- data = this._host.clipboardData;
644
- }
645
- this._isTextHighlightOn = false;
646
- this._prevText = this._textWrapper.text;
647
- this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex, data);
648
- const deltaIndex = data.length - (this._cursorInfo.globalEndIndex - this._cursorInfo.globalStartIndex);
649
- this._cursorInfo.globalStartIndex += deltaIndex;
650
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
651
- this._clickedCoordinateX = null;
652
- this._clickedCoordinateY = null;
653
- super._textHasChanged();
654
- }
655
- _draw(context) {
656
- this._computeScroll();
657
- this._scrollLeft = this._scrollLeft ?? 0;
658
- this._scrollTop = this._scrollTop ?? 0;
659
- context.save();
660
- this._applyStates(context);
661
- if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
662
- context.shadowColor = this.shadowColor;
663
- context.shadowBlur = this.shadowBlur;
664
- context.shadowOffsetX = this.shadowOffsetX * this._host.idealRatio;
665
- context.shadowOffsetY = this.shadowOffsetY * this._host.idealRatio;
666
- }
667
- // Background
668
- if (this._isFocused) {
669
- if (this._focusedBackground) {
670
- context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
671
- context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
672
- }
673
- }
674
- else if (this._background) {
675
- context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
676
- context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
677
- }
678
- if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
679
- context.shadowBlur = 0;
680
- context.shadowOffsetX = 0;
681
- context.shadowOffsetY = 0;
682
- }
683
- // sets the color of the rectangle (border if background available)
684
- if (this.color) {
685
- context.fillStyle = this.color;
686
- }
687
- const height = this._currentMeasure.height;
688
- const width = this._currentMeasure.width;
689
- let rootY = 0;
690
- switch (this._textVerticalAlignment) {
691
- case Control.VERTICAL_ALIGNMENT_TOP:
692
- rootY = this._fontOffset.ascent;
693
- break;
694
- case Control.VERTICAL_ALIGNMENT_BOTTOM:
695
- rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
696
- break;
697
- case Control.VERTICAL_ALIGNMENT_CENTER:
698
- rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
699
- break;
700
- }
701
- context.save();
702
- context.beginPath();
703
- context.fillStyle = this.fontStyle;
704
- if (!this._textWrapper.text && this.placeholderText) {
705
- context.fillStyle = this._placeholderColor;
706
- }
707
- // here we define the visible reactangle to clip it in next line
708
- context.rect(this._clipTextLeft, this._clipTextTop, this._availableWidth + 2, this._availableHeight + 2);
709
- context.clip();
710
- // Text
711
- rootY += this._scrollTop;
712
- for (let i = 0; i < this._lines.length; i++) {
713
- const line = this._lines[i];
714
- if (i !== 0 && this._lineSpacing.internalValue !== 0) {
715
- if (this._lineSpacing.isPixel) {
716
- rootY += this._lineSpacing.getValue(this._host);
717
- }
718
- else {
719
- rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
720
- }
721
- }
722
- this._drawText(line.text, line.width, rootY, context);
723
- rootY += this._fontOffset.height;
724
- }
725
- context.restore();
726
- // Cursor
727
- if (this._isFocused) {
728
- // Render cursor
729
- if (!this._blinkIsEven || this._isTextHighlightOn) {
730
- let cursorLeft = this._scrollLeft + context.measureText(this._lines[this._cursorInfo.currentLineIndex].text.substring(0, this._cursorInfo.relativeStartIndex)).width;
731
- if (cursorLeft < this._clipTextLeft) {
732
- this._scrollLeft += this._clipTextLeft - cursorLeft;
733
- cursorLeft = this._clipTextLeft;
734
- this._markAsDirty();
735
- }
736
- else if (cursorLeft > this._clipTextLeft + this._availableWidth) {
737
- this._scrollLeft += this._clipTextLeft + this._availableWidth - cursorLeft;
738
- cursorLeft = this._clipTextLeft + this._availableWidth;
739
- this._markAsDirty();
740
- }
741
- let cursorTop = this._scrollTop + this._cursorInfo.currentLineIndex * this._fontOffset.height; //cursorTop distance from top to cursor start
742
- if (cursorTop < this._clipTextTop) {
743
- this._scrollTop += this._clipTextTop - cursorTop;
744
- cursorTop = this._clipTextTop;
745
- this._markAsDirty();
746
- }
747
- else if (cursorTop + this._fontOffset.height > this._clipTextTop + this._availableHeight && this._availableHeight > this._fontOffset.height) {
748
- this._scrollTop += this._clipTextTop + this._availableHeight - cursorTop - this._fontOffset.height;
749
- cursorTop = this._clipTextTop + this._availableHeight - this._fontOffset.height;
750
- this._markAsDirty();
751
- }
752
- if (!this._isTextHighlightOn) {
753
- context.fillRect(cursorLeft, cursorTop, 2, this._fontOffset.height);
754
- }
755
- }
756
- this._resetBlinking();
757
- //show the highlighted text
758
- if (this._isTextHighlightOn) {
759
- clearTimeout(this._blinkTimeout);
760
- this._highlightedText = this.text.substring(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex);
761
- context.globalAlpha = this._highlighterOpacity;
762
- context.fillStyle = this._textHighlightColor;
763
- const startLineIndex = Math.min(this._cursorInfo.currentLineIndex, this._highlightCursorInfo.initialLineIndex);
764
- const endLineIndex = Math.max(this._cursorInfo.currentLineIndex, this._highlightCursorInfo.initialLineIndex);
765
- let highlightRootY = this._scrollTop + startLineIndex * this._fontOffset.height;
766
- for (let i = startLineIndex; i <= endLineIndex; i++) {
767
- const line = this._lines[i];
768
- let highlightRootX = this._scrollLeft;
769
- switch (this._textHorizontalAlignment) {
770
- case Control.HORIZONTAL_ALIGNMENT_LEFT:
771
- highlightRootX += 0;
772
- break;
773
- case Control.HORIZONTAL_ALIGNMENT_RIGHT:
774
- highlightRootX += width - line.width;
775
- break;
776
- case Control.HORIZONTAL_ALIGNMENT_CENTER:
777
- highlightRootX += (width - line.width) / 2;
778
- break;
779
- }
780
- const begin = i === startLineIndex ? this._cursorInfo.relativeStartIndex : 0;
781
- const end = i === endLineIndex ? this._cursorInfo.relativeEndIndex : line.text.length;
782
- const leftOffsetWidth = context.measureText(line.text.substring(0, begin)).width;
783
- const selectedText = line.text.substring(begin, end);
784
- const hightlightWidth = context.measureText(selectedText).width;
785
- context.fillRect(highlightRootX + leftOffsetWidth, highlightRootY, hightlightWidth, this._fontOffset.height);
786
- highlightRootY += this._fontOffset.height;
787
- }
788
- if (this._cursorInfo.globalEndIndex === this._cursorInfo.globalStartIndex) {
789
- this._resetBlinking();
790
- }
791
- }
792
- }
793
- context.restore();
794
- // Border
795
- if (this._thickness) {
796
- if (this._isFocused) {
797
- if (this.focusedColor) {
798
- context.strokeStyle = this.focusedColor;
799
- }
800
- }
801
- else {
802
- if (this.color) {
803
- context.strokeStyle = this.color;
804
- }
805
- }
806
- context.lineWidth = this._thickness;
807
- context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
808
- }
809
- }
810
- _resetBlinking() {
811
- clearTimeout(this._blinkTimeout);
812
- this._blinkTimeout = setTimeout(() => {
813
- this._blinkIsEven = !this._blinkIsEven;
814
- this._markAsDirty();
815
- }, 500);
816
- }
817
- _onPointerDown(target, coordinates, pointerId, buttonIndex, pi) {
818
- if (!super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi)) {
819
- return false;
820
- }
821
- if (this.isReadOnly) {
822
- return true;
823
- }
824
- this._clickedCoordinateX = coordinates.x;
825
- this._clickedCoordinateY = coordinates.y;
826
- this._isTextHighlightOn = false;
827
- this._highlightedText = "";
828
- this._isPointerDown = true;
829
- this._host._capturingControl[pointerId] = this;
830
- if (this._host.focusedControl === this) {
831
- // Move cursor
832
- clearTimeout(this._blinkTimeout);
833
- this._markAsDirty();
834
- return true;
835
- }
836
- if (!this._isEnabled) {
837
- return false;
838
- }
839
- this._host.focusedControl = this;
840
- return true;
841
- }
842
- // for textselection
843
- _onPointerMove(target, coordinates, pointerId, pi) {
844
- // Avoid Chromium-like beahavior when this event is fired right after onPointerDown
845
- if (pi.event.movementX === 0 && pi.event.movementY === 0) {
846
- return;
847
- }
848
- if (this._host.focusedControl === this && this._isPointerDown && !this.isReadOnly) {
849
- this._clickedCoordinateX = coordinates.x;
850
- this._clickedCoordinateY = coordinates.y;
851
- if (!this._isTextHighlightOn) {
852
- this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
853
- this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
854
- this._highlightCursorInfo.initialRelativeStartIndex = this._cursorInfo.relativeStartIndex;
855
- this._isTextHighlightOn = true;
856
- }
857
- this._markAsDirty();
858
- }
859
- super._onPointerMove(target, coordinates, pointerId, pi);
860
- }
861
- /**
862
- * Apply the correct position of cursor according to current modification
863
- */
864
- _updateCursorPosition() {
865
- if (!this._isFocused) {
866
- return;
867
- }
868
- if (!this._textWrapper.text && this.placeholderText) {
869
- this._cursorInfo.currentLineIndex = 0;
870
- this._cursorInfo.globalStartIndex = 0;
871
- this._cursorInfo.globalEndIndex = 0;
872
- this._cursorInfo.relativeStartIndex = 0;
873
- this._cursorInfo.relativeEndIndex = 0;
874
- }
875
- else {
876
- if (this._clickedCoordinateX && this._clickedCoordinateY) {
877
- if (!this._isTextHighlightOn) {
878
- this._cursorInfo = {
879
- globalStartIndex: 0,
880
- globalEndIndex: 0,
881
- relativeStartIndex: 0,
882
- relativeEndIndex: 0,
883
- currentLineIndex: 0,
884
- };
885
- }
886
- let globalIndex = 0;
887
- let relativeIndex = 0;
888
- const lastClickedCoordinateY = this._clickedCoordinateY - this._scrollTop;
889
- const relativeCoordinateY = Math.floor(lastClickedCoordinateY / this._fontOffset.height);
890
- this._cursorInfo.currentLineIndex = Math.min(Math.max(relativeCoordinateY, 0), this._lines.length - 1);
891
- let currentSize = 0;
892
- const relativeXPosition = this._clickedCoordinateX - (this._scrollLeft ?? 0);
893
- let previousDist = 0;
894
- for (let index = 0; index < this._cursorInfo.currentLineIndex; index++) {
895
- const line = this._lines[index];
896
- globalIndex += line.text.length + line.lineEnding.length;
897
- }
898
- while (currentSize < relativeXPosition && this._lines[this._cursorInfo.currentLineIndex].text.length > relativeIndex) {
899
- relativeIndex++;
900
- previousDist = Math.abs(relativeXPosition - currentSize);
901
- currentSize = this._contextForBreakLines.measureText(this._lines[this._cursorInfo.currentLineIndex].text.substring(0, relativeIndex)).width;
902
- }
903
- // Find closest move
904
- if (Math.abs(relativeXPosition - currentSize) > previousDist && relativeIndex > 0) {
905
- relativeIndex--;
906
- }
907
- globalIndex += relativeIndex;
908
- if (!this._isTextHighlightOn) {
909
- this._cursorInfo.globalStartIndex = globalIndex;
910
- this._cursorInfo.relativeStartIndex = relativeIndex;
911
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
912
- this._cursorInfo.relativeEndIndex = this._cursorInfo.relativeStartIndex;
913
- }
914
- else {
915
- if (globalIndex < this._highlightCursorInfo.initialStartIndex) {
916
- this._cursorInfo.globalStartIndex = globalIndex;
917
- this._cursorInfo.relativeStartIndex = relativeIndex;
918
- this._cursorInfo.globalEndIndex = this._highlightCursorInfo.initialStartIndex;
919
- this._cursorInfo.relativeEndIndex = this._highlightCursorInfo.initialRelativeStartIndex;
920
- }
921
- else {
922
- this._cursorInfo.globalStartIndex = this._highlightCursorInfo.initialStartIndex;
923
- this._cursorInfo.relativeStartIndex = this._highlightCursorInfo.initialRelativeStartIndex;
924
- this._cursorInfo.globalEndIndex = globalIndex;
925
- this._cursorInfo.relativeEndIndex = relativeIndex;
926
- }
927
- }
928
- // Avoid the caret during highlighting
929
- this._blinkIsEven = this._isTextHighlightOn;
930
- this._clickedCoordinateX = null;
931
- this._clickedCoordinateY = null;
932
- }
933
- else {
934
- // Standard behavior same as Current line is at least above the initial highlight index
935
- this._cursorInfo.relativeStartIndex = 0;
936
- this._cursorInfo.currentLineIndex = 0;
937
- let lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
938
- let tmpLength = 0;
939
- while (tmpLength + lineLength <= this._cursorInfo.globalStartIndex) {
940
- tmpLength += lineLength;
941
- if (this._cursorInfo.currentLineIndex < this._lines.length - 1) {
942
- this._cursorInfo.currentLineIndex++;
943
- lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
944
- }
945
- }
946
- this._cursorInfo.relativeStartIndex = this._cursorInfo.globalStartIndex - tmpLength;
947
- if (!this._isTextHighlightOn) {
948
- this._cursorInfo.relativeEndIndex = this._cursorInfo.relativeStartIndex;
949
- this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
950
- }
951
- else if (this._highlightCursorInfo.initialStartIndex !== -1 && this._cursorInfo.globalStartIndex >= this._highlightCursorInfo.initialStartIndex) {
952
- // Current line is at least below the initial highlight index
953
- while (tmpLength + lineLength <= this._cursorInfo.globalEndIndex) {
954
- tmpLength += lineLength;
955
- if (this._cursorInfo.currentLineIndex < this._lines.length - 1) {
956
- this._cursorInfo.currentLineIndex++;
957
- lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
958
- }
959
- }
960
- this._cursorInfo.relativeEndIndex = this._cursorInfo.globalEndIndex - tmpLength;
961
- }
962
- }
963
- }
964
- }
965
- /**
966
- * Update all values of cursor information based on cursorIndex value
967
- *
968
- * @param offset The index to take care of
969
- * @internal
970
- */
971
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
972
- _updateValueFromCursorIndex(offset) {
973
- // Override to avoid parent behavior during _onPointerMove
974
- }
975
- /**
976
- * Select the word immediatly under the cursor on double click
977
- *
978
- * @param _evt Pointer informations of double click
979
- * @internal
980
- */
981
- _processDblClick(_evt) {
982
- //pre-find the start and end index of the word under cursor, speeds up the rendering
983
- let moveLeft, moveRight;
984
- do {
985
- moveLeft = this._cursorInfo.globalStartIndex > 0 && this._textWrapper.isWord(this._cursorInfo.globalStartIndex - 1) ? --this._cursorInfo.globalStartIndex : 0;
986
- moveRight =
987
- this._cursorInfo.globalEndIndex < this._textWrapper.length && this._textWrapper.isWord(this._cursorInfo.globalEndIndex) ? ++this._cursorInfo.globalEndIndex : 0;
988
- } while (moveLeft || moveRight);
989
- this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
990
- this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
991
- this.onTextHighlightObservable.notifyObservers(this);
992
- this._isTextHighlightOn = true;
993
- this._blinkIsEven = true;
994
- this._markAsDirty();
995
- }
996
- /** @internal */
997
- selectAllText() {
998
- this._isTextHighlightOn = true;
999
- this._blinkIsEven = true;
1000
- this._highlightCursorInfo = {
1001
- initialStartIndex: 0,
1002
- initialRelativeStartIndex: 0,
1003
- initialLineIndex: 0,
1004
- };
1005
- this._cursorInfo = {
1006
- globalStartIndex: 0,
1007
- globalEndIndex: this._textWrapper.length,
1008
- relativeEndIndex: this._lines[this._lines.length - 1].text.length,
1009
- relativeStartIndex: 0,
1010
- currentLineIndex: this._lines.length - 1,
1011
- };
1012
- this._markAsDirty();
1013
- }
1014
- dispose() {
1015
- super.dispose();
1016
- this.onLinesReadyObservable.clear();
1017
- }
1018
- }
1019
- __decorate([
1020
- serialize()
1021
- ], InputTextArea.prototype, "autoStretchHeight", null);
1022
- __decorate([
1023
- serialize()
1024
- ], InputTextArea.prototype, "maxHeight", null);
1025
- RegisterClass("BABYLON.GUI.InputTextArea", InputTextArea);
5
+ export * from "./inputTextArea.pure.js";
6
+ import { RegisterInputTextArea } from "./inputTextArea.pure.js";
7
+ RegisterInputTextArea();
1026
8
  //# sourceMappingURL=inputTextArea.js.map