@onerjs/gui 8.23.1

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 (354) hide show
  1. package/2D/FrameGraph/guiTask.d.ts +34 -0
  2. package/2D/FrameGraph/guiTask.js +62 -0
  3. package/2D/FrameGraph/guiTask.js.map +1 -0
  4. package/2D/FrameGraph/renderGraphGUIBlock.d.ts +43 -0
  5. package/2D/FrameGraph/renderGraphGUIBlock.js +66 -0
  6. package/2D/FrameGraph/renderGraphGUIBlock.js.map +1 -0
  7. package/2D/adtInstrumentation.d.ts +52 -0
  8. package/2D/adtInstrumentation.js +107 -0
  9. package/2D/adtInstrumentation.js.map +1 -0
  10. package/2D/advancedDynamicTexture.d.ts +548 -0
  11. package/2D/advancedDynamicTexture.js +1522 -0
  12. package/2D/advancedDynamicTexture.js.map +1 -0
  13. package/2D/controls/button.d.ts +109 -0
  14. package/2D/controls/button.js +246 -0
  15. package/2D/controls/button.js.map +1 -0
  16. package/2D/controls/checkbox.d.ts +53 -0
  17. package/2D/controls/checkbox.js +164 -0
  18. package/2D/controls/checkbox.js.map +1 -0
  19. package/2D/controls/colorpicker.d.ts +101 -0
  20. package/2D/controls/colorpicker.js +1396 -0
  21. package/2D/controls/colorpicker.js.map +1 -0
  22. package/2D/controls/container.d.ts +179 -0
  23. package/2D/controls/container.js +616 -0
  24. package/2D/controls/container.js.map +1 -0
  25. package/2D/controls/control.d.ts +943 -0
  26. package/2D/controls/control.js +2460 -0
  27. package/2D/controls/control.js.map +1 -0
  28. package/2D/controls/displayGrid.d.ts +53 -0
  29. package/2D/controls/displayGrid.js +202 -0
  30. package/2D/controls/displayGrid.js.map +1 -0
  31. package/2D/controls/ellipse.d.ts +25 -0
  32. package/2D/controls/ellipse.js +93 -0
  33. package/2D/controls/ellipse.js.map +1 -0
  34. package/2D/controls/focusableButton.d.ts +17 -0
  35. package/2D/controls/focusableButton.js +25 -0
  36. package/2D/controls/focusableButton.js.map +1 -0
  37. package/2D/controls/focusableControl.d.ts +43 -0
  38. package/2D/controls/focusableControl.js +2 -0
  39. package/2D/controls/focusableControl.js.map +1 -0
  40. package/2D/controls/gradient/BaseGradient.d.ts +69 -0
  41. package/2D/controls/gradient/BaseGradient.js +84 -0
  42. package/2D/controls/gradient/BaseGradient.js.map +1 -0
  43. package/2D/controls/gradient/LinearGradient.d.ts +45 -0
  44. package/2D/controls/gradient/LinearGradient.js +73 -0
  45. package/2D/controls/gradient/LinearGradient.js.map +1 -0
  46. package/2D/controls/gradient/RadialGradient.d.ts +53 -0
  47. package/2D/controls/gradient/RadialGradient.js +89 -0
  48. package/2D/controls/gradient/RadialGradient.js.map +1 -0
  49. package/2D/controls/grid.d.ts +151 -0
  50. package/2D/controls/grid.js +528 -0
  51. package/2D/controls/grid.js.map +1 -0
  52. package/2D/controls/image.d.ts +228 -0
  53. package/2D/controls/image.js +915 -0
  54. package/2D/controls/image.js.map +1 -0
  55. package/2D/controls/index.d.ts +34 -0
  56. package/2D/controls/index.js +35 -0
  57. package/2D/controls/index.js.map +1 -0
  58. package/2D/controls/inputPassword.d.ts +9 -0
  59. package/2D/controls/inputPassword.js +22 -0
  60. package/2D/controls/inputPassword.js.map +1 -0
  61. package/2D/controls/inputText.d.ts +197 -0
  62. package/2D/controls/inputText.js +1035 -0
  63. package/2D/controls/inputText.js.map +1 -0
  64. package/2D/controls/inputTextArea.d.ts +142 -0
  65. package/2D/controls/inputTextArea.js +1025 -0
  66. package/2D/controls/inputTextArea.js.map +1 -0
  67. package/2D/controls/line.d.ts +73 -0
  68. package/2D/controls/line.js +227 -0
  69. package/2D/controls/line.js.map +1 -0
  70. package/2D/controls/multiLine.d.ts +75 -0
  71. package/2D/controls/multiLine.js +237 -0
  72. package/2D/controls/multiLine.js.map +1 -0
  73. package/2D/controls/radioButton.d.ts +49 -0
  74. package/2D/controls/radioButton.js +185 -0
  75. package/2D/controls/radioButton.js.map +1 -0
  76. package/2D/controls/rectangle.d.ts +43 -0
  77. package/2D/controls/rectangle.js +204 -0
  78. package/2D/controls/rectangle.js.map +1 -0
  79. package/2D/controls/scrollViewers/scrollViewer.d.ts +178 -0
  80. package/2D/controls/scrollViewers/scrollViewer.js +587 -0
  81. package/2D/controls/scrollViewers/scrollViewer.js.map +1 -0
  82. package/2D/controls/scrollViewers/scrollViewerWindow.d.ts +51 -0
  83. package/2D/controls/scrollViewers/scrollViewerWindow.js +254 -0
  84. package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -0
  85. package/2D/controls/selector.d.ts +237 -0
  86. package/2D/controls/selector.js +579 -0
  87. package/2D/controls/selector.js.map +1 -0
  88. package/2D/controls/sliders/baseSlider.d.ts +80 -0
  89. package/2D/controls/sliders/baseSlider.js +299 -0
  90. package/2D/controls/sliders/baseSlider.js.map +1 -0
  91. package/2D/controls/sliders/imageBasedSlider.d.ts +47 -0
  92. package/2D/controls/sliders/imageBasedSlider.js +168 -0
  93. package/2D/controls/sliders/imageBasedSlider.js.map +1 -0
  94. package/2D/controls/sliders/imageScrollBar.d.ts +67 -0
  95. package/2D/controls/sliders/imageScrollBar.js +248 -0
  96. package/2D/controls/sliders/imageScrollBar.js.map +1 -0
  97. package/2D/controls/sliders/scrollBar.d.ts +50 -0
  98. package/2D/controls/sliders/scrollBar.js +175 -0
  99. package/2D/controls/sliders/scrollBar.js.map +1 -0
  100. package/2D/controls/sliders/slider.d.ts +46 -0
  101. package/2D/controls/sliders/slider.js +281 -0
  102. package/2D/controls/sliders/slider.js.map +1 -0
  103. package/2D/controls/stackPanel.d.ts +64 -0
  104. package/2D/controls/stackPanel.js +244 -0
  105. package/2D/controls/stackPanel.js.map +1 -0
  106. package/2D/controls/statics.d.ts +6 -0
  107. package/2D/controls/statics.js +50 -0
  108. package/2D/controls/statics.js.map +1 -0
  109. package/2D/controls/textBlock.d.ts +219 -0
  110. package/2D/controls/textBlock.js +670 -0
  111. package/2D/controls/textBlock.js.map +1 -0
  112. package/2D/controls/textWrapper.d.ts +13 -0
  113. package/2D/controls/textWrapper.js +88 -0
  114. package/2D/controls/textWrapper.js.map +1 -0
  115. package/2D/controls/toggleButton.d.ts +93 -0
  116. package/2D/controls/toggleButton.js +229 -0
  117. package/2D/controls/toggleButton.js.map +1 -0
  118. package/2D/controls/virtualKeyboard.d.ts +102 -0
  119. package/2D/controls/virtualKeyboard.js +275 -0
  120. package/2D/controls/virtualKeyboard.js.map +1 -0
  121. package/2D/index.d.ts +11 -0
  122. package/2D/index.js +13 -0
  123. package/2D/index.js.map +1 -0
  124. package/2D/math2D.d.ts +136 -0
  125. package/2D/math2D.js +235 -0
  126. package/2D/math2D.js.map +1 -0
  127. package/2D/measure.d.ts +77 -0
  128. package/2D/measure.js +138 -0
  129. package/2D/measure.js.map +1 -0
  130. package/2D/multiLinePoint.d.ts +47 -0
  131. package/2D/multiLinePoint.js +110 -0
  132. package/2D/multiLinePoint.js.map +1 -0
  133. package/2D/style.d.ts +46 -0
  134. package/2D/style.js +80 -0
  135. package/2D/style.js.map +1 -0
  136. package/2D/valueAndUnit.d.ts +89 -0
  137. package/2D/valueAndUnit.js +194 -0
  138. package/2D/valueAndUnit.js.map +1 -0
  139. package/2D/xmlLoader.d.ts +60 -0
  140. package/2D/xmlLoader.js +348 -0
  141. package/2D/xmlLoader.js.map +1 -0
  142. package/3D/behaviors/defaultBehavior.d.ts +73 -0
  143. package/3D/behaviors/defaultBehavior.js +103 -0
  144. package/3D/behaviors/defaultBehavior.js.map +1 -0
  145. package/3D/controls/MRTK3/touchHolographicButton.d.ts +220 -0
  146. package/3D/controls/MRTK3/touchHolographicButton.js +868 -0
  147. package/3D/controls/MRTK3/touchHolographicButton.js.map +1 -0
  148. package/3D/controls/abstractButton3D.d.ts +15 -0
  149. package/3D/controls/abstractButton3D.js +22 -0
  150. package/3D/controls/abstractButton3D.js.map +1 -0
  151. package/3D/controls/button3D.d.ts +51 -0
  152. package/3D/controls/button3D.js +98 -0
  153. package/3D/controls/button3D.js.map +1 -0
  154. package/3D/controls/container3D.d.ts +72 -0
  155. package/3D/controls/container3D.js +126 -0
  156. package/3D/controls/container3D.js.map +1 -0
  157. package/3D/controls/contentDisplay3D.d.ts +42 -0
  158. package/3D/controls/contentDisplay3D.js +81 -0
  159. package/3D/controls/contentDisplay3D.js.map +1 -0
  160. package/3D/controls/control3D.d.ts +183 -0
  161. package/3D/controls/control3D.js +401 -0
  162. package/3D/controls/control3D.js.map +1 -0
  163. package/3D/controls/cylinderPanel.d.ts +17 -0
  164. package/3D/controls/cylinderPanel.js +57 -0
  165. package/3D/controls/cylinderPanel.js.map +1 -0
  166. package/3D/controls/handMenu.d.ts +28 -0
  167. package/3D/controls/handMenu.js +39 -0
  168. package/3D/controls/handMenu.js.map +1 -0
  169. package/3D/controls/holographicBackplate.d.ts +49 -0
  170. package/3D/controls/holographicBackplate.js +104 -0
  171. package/3D/controls/holographicBackplate.js.map +1 -0
  172. package/3D/controls/holographicButton.d.ts +84 -0
  173. package/3D/controls/holographicButton.js +300 -0
  174. package/3D/controls/holographicButton.js.map +1 -0
  175. package/3D/controls/holographicSlate.d.ts +134 -0
  176. package/3D/controls/holographicSlate.js +413 -0
  177. package/3D/controls/holographicSlate.js.map +1 -0
  178. package/3D/controls/index.d.ts +22 -0
  179. package/3D/controls/index.js +24 -0
  180. package/3D/controls/index.js.map +1 -0
  181. package/3D/controls/meshButton3D.d.ts +21 -0
  182. package/3D/controls/meshButton3D.js +58 -0
  183. package/3D/controls/meshButton3D.js.map +1 -0
  184. package/3D/controls/nearMenu.d.ts +44 -0
  185. package/3D/controls/nearMenu.js +103 -0
  186. package/3D/controls/nearMenu.js.map +1 -0
  187. package/3D/controls/planePanel.d.ts +9 -0
  188. package/3D/controls/planePanel.js +30 -0
  189. package/3D/controls/planePanel.js.map +1 -0
  190. package/3D/controls/scatterPanel.d.ts +18 -0
  191. package/3D/controls/scatterPanel.js +98 -0
  192. package/3D/controls/scatterPanel.js.map +1 -0
  193. package/3D/controls/slider3D.d.ts +95 -0
  194. package/3D/controls/slider3D.js +256 -0
  195. package/3D/controls/slider3D.js.map +1 -0
  196. package/3D/controls/spherePanel.d.ts +17 -0
  197. package/3D/controls/spherePanel.js +58 -0
  198. package/3D/controls/spherePanel.js.map +1 -0
  199. package/3D/controls/stackPanel3D.d.ts +22 -0
  200. package/3D/controls/stackPanel3D.js +95 -0
  201. package/3D/controls/stackPanel3D.js.map +1 -0
  202. package/3D/controls/touchButton3D.d.ts +77 -0
  203. package/3D/controls/touchButton3D.js +205 -0
  204. package/3D/controls/touchButton3D.js.map +1 -0
  205. package/3D/controls/touchHolographicButton.d.ts +110 -0
  206. package/3D/controls/touchHolographicButton.js +400 -0
  207. package/3D/controls/touchHolographicButton.js.map +1 -0
  208. package/3D/controls/touchHolographicMenu.d.ts +61 -0
  209. package/3D/controls/touchHolographicMenu.js +139 -0
  210. package/3D/controls/touchHolographicMenu.js.map +1 -0
  211. package/3D/controls/touchMeshButton3D.d.ts +21 -0
  212. package/3D/controls/touchMeshButton3D.js +58 -0
  213. package/3D/controls/touchMeshButton3D.js.map +1 -0
  214. package/3D/controls/volumeBasedPanel.d.ts +53 -0
  215. package/3D/controls/volumeBasedPanel.js +158 -0
  216. package/3D/controls/volumeBasedPanel.js.map +1 -0
  217. package/3D/gizmos/gizmoHandle.d.ts +108 -0
  218. package/3D/gizmos/gizmoHandle.js +175 -0
  219. package/3D/gizmos/gizmoHandle.js.map +1 -0
  220. package/3D/gizmos/index.d.ts +2 -0
  221. package/3D/gizmos/index.js +3 -0
  222. package/3D/gizmos/index.js.map +1 -0
  223. package/3D/gizmos/slateGizmo.d.ts +57 -0
  224. package/3D/gizmos/slateGizmo.js +353 -0
  225. package/3D/gizmos/slateGizmo.js.map +1 -0
  226. package/3D/gui3DManager.d.ts +94 -0
  227. package/3D/gui3DManager.js +233 -0
  228. package/3D/gui3DManager.js.map +1 -0
  229. package/3D/index.d.ts +5 -0
  230. package/3D/index.js +7 -0
  231. package/3D/index.js.map +1 -0
  232. package/3D/materials/fluent/fluentMaterial.d.ts +91 -0
  233. package/3D/materials/fluent/fluentMaterial.js +286 -0
  234. package/3D/materials/fluent/fluentMaterial.js.map +1 -0
  235. package/3D/materials/fluent/index.d.ts +1 -0
  236. package/3D/materials/fluent/index.js +2 -0
  237. package/3D/materials/fluent/index.js.map +1 -0
  238. package/3D/materials/fluent/shaders/fluent.fragment.d.ts +5 -0
  239. package/3D/materials/fluent/shaders/fluent.fragment.js +41 -0
  240. package/3D/materials/fluent/shaders/fluent.fragment.js.map +1 -0
  241. package/3D/materials/fluent/shaders/fluent.vertex.d.ts +5 -0
  242. package/3D/materials/fluent/shaders/fluent.vertex.js +40 -0
  243. package/3D/materials/fluent/shaders/fluent.vertex.js.map +1 -0
  244. package/3D/materials/fluentBackplate/fluentBackplateMaterial.d.ts +155 -0
  245. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +466 -0
  246. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -0
  247. package/3D/materials/fluentBackplate/index.d.ts +1 -0
  248. package/3D/materials/fluentBackplate/index.js +2 -0
  249. package/3D/materials/fluentBackplate/index.js.map +1 -0
  250. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.d.ts +5 -0
  251. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js +60 -0
  252. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js.map +1 -0
  253. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.d.ts +5 -0
  254. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js +127 -0
  255. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js.map +1 -0
  256. package/3D/materials/fluentButton/fluentButtonMaterial.d.ts +190 -0
  257. package/3D/materials/fluentButton/fluentButtonMaterial.js +536 -0
  258. package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -0
  259. package/3D/materials/fluentButton/index.d.ts +1 -0
  260. package/3D/materials/fluentButton/index.js +2 -0
  261. package/3D/materials/fluentButton/index.js.map +1 -0
  262. package/3D/materials/fluentButton/shaders/fluentButton.fragment.d.ts +5 -0
  263. package/3D/materials/fluentButton/shaders/fluentButton.fragment.js +57 -0
  264. package/3D/materials/fluentButton/shaders/fluentButton.fragment.js.map +1 -0
  265. package/3D/materials/fluentButton/shaders/fluentButton.vertex.d.ts +5 -0
  266. package/3D/materials/fluentButton/shaders/fluentButton.vertex.js +162 -0
  267. package/3D/materials/fluentButton/shaders/fluentButton.vertex.js.map +1 -0
  268. package/3D/materials/fluentMaterial.d.ts +4 -0
  269. package/3D/materials/fluentMaterial.js +5 -0
  270. package/3D/materials/fluentMaterial.js.map +1 -0
  271. package/3D/materials/handle/handleMaterial.d.ts +68 -0
  272. package/3D/materials/handle/handleMaterial.js +114 -0
  273. package/3D/materials/handle/handleMaterial.js.map +1 -0
  274. package/3D/materials/handle/index.d.ts +1 -0
  275. package/3D/materials/handle/index.js +2 -0
  276. package/3D/materials/handle/index.js.map +1 -0
  277. package/3D/materials/handle/shaders/handle.fragment.d.ts +5 -0
  278. package/3D/materials/handle/shaders/handle.fragment.js +11 -0
  279. package/3D/materials/handle/shaders/handle.fragment.js.map +1 -0
  280. package/3D/materials/handle/shaders/handle.vertex.d.ts +5 -0
  281. package/3D/materials/handle/shaders/handle.vertex.js +11 -0
  282. package/3D/materials/handle/shaders/handle.vertex.js.map +1 -0
  283. package/3D/materials/index.d.ts +5 -0
  284. package/3D/materials/index.js +7 -0
  285. package/3D/materials/index.js.map +1 -0
  286. package/3D/materials/mrdl/index.d.ts +3 -0
  287. package/3D/materials/mrdl/index.js +4 -0
  288. package/3D/materials/mrdl/index.js.map +1 -0
  289. package/3D/materials/mrdl/mrdlBackglowMaterial.d.ts +87 -0
  290. package/3D/materials/mrdl/mrdlBackglowMaterial.js +302 -0
  291. package/3D/materials/mrdl/mrdlBackglowMaterial.js.map +1 -0
  292. package/3D/materials/mrdl/mrdlBackplateMaterial.d.ts +148 -0
  293. package/3D/materials/mrdl/mrdlBackplateMaterial.js +433 -0
  294. package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -0
  295. package/3D/materials/mrdl/mrdlFrontplateMaterial.d.ts +186 -0
  296. package/3D/materials/mrdl/mrdlFrontplateMaterial.js +532 -0
  297. package/3D/materials/mrdl/mrdlFrontplateMaterial.js.map +1 -0
  298. package/3D/materials/mrdl/mrdlInnerquadMaterial.d.ts +56 -0
  299. package/3D/materials/mrdl/mrdlInnerquadMaterial.js +230 -0
  300. package/3D/materials/mrdl/mrdlInnerquadMaterial.js.map +1 -0
  301. package/3D/materials/mrdl/mrdlSliderBarMaterial.d.ts +337 -0
  302. package/3D/materials/mrdl/mrdlSliderBarMaterial.js +855 -0
  303. package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -0
  304. package/3D/materials/mrdl/mrdlSliderThumbMaterial.d.ts +337 -0
  305. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +855 -0
  306. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -0
  307. package/3D/materials/mrdl/shaders/mrdlBackglow.fragment.d.ts +5 -0
  308. package/3D/materials/mrdl/shaders/mrdlBackglow.fragment.js +25 -0
  309. package/3D/materials/mrdl/shaders/mrdlBackglow.fragment.js.map +1 -0
  310. package/3D/materials/mrdl/shaders/mrdlBackglow.vertex.d.ts +5 -0
  311. package/3D/materials/mrdl/shaders/mrdlBackglow.vertex.js +12 -0
  312. package/3D/materials/mrdl/shaders/mrdlBackglow.vertex.js.map +1 -0
  313. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.d.ts +5 -0
  314. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js +88 -0
  315. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js.map +1 -0
  316. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.d.ts +5 -0
  317. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js +96 -0
  318. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js.map +1 -0
  319. package/3D/materials/mrdl/shaders/mrdlFrontplate.fragment.d.ts +5 -0
  320. package/3D/materials/mrdl/shaders/mrdlFrontplate.fragment.js +48 -0
  321. package/3D/materials/mrdl/shaders/mrdlFrontplate.fragment.js.map +1 -0
  322. package/3D/materials/mrdl/shaders/mrdlFrontplate.vertex.d.ts +5 -0
  323. package/3D/materials/mrdl/shaders/mrdlFrontplate.vertex.js +158 -0
  324. package/3D/materials/mrdl/shaders/mrdlFrontplate.vertex.js.map +1 -0
  325. package/3D/materials/mrdl/shaders/mrdlInnerquad.fragment.d.ts +5 -0
  326. package/3D/materials/mrdl/shaders/mrdlInnerquad.fragment.js +27 -0
  327. package/3D/materials/mrdl/shaders/mrdlInnerquad.fragment.js.map +1 -0
  328. package/3D/materials/mrdl/shaders/mrdlInnerquad.vertex.d.ts +5 -0
  329. package/3D/materials/mrdl/shaders/mrdlInnerquad.vertex.js +13 -0
  330. package/3D/materials/mrdl/shaders/mrdlInnerquad.vertex.js.map +1 -0
  331. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.d.ts +5 -0
  332. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js +236 -0
  333. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js.map +1 -0
  334. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.d.ts +5 -0
  335. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js +137 -0
  336. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js.map +1 -0
  337. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.d.ts +5 -0
  338. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js +236 -0
  339. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js.map +1 -0
  340. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.d.ts +5 -0
  341. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js +137 -0
  342. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js.map +1 -0
  343. package/3D/vector3WithInfo.d.ts +16 -0
  344. package/3D/vector3WithInfo.js +18 -0
  345. package/3D/vector3WithInfo.js.map +1 -0
  346. package/index.d.ts +2 -0
  347. package/index.js +4 -0
  348. package/index.js.map +1 -0
  349. package/legacy/legacy.d.ts +1 -0
  350. package/legacy/legacy.js +17 -0
  351. package/legacy/legacy.js.map +1 -0
  352. package/license.md +71 -0
  353. package/package.json +47 -0
  354. package/readme.md +31 -0
@@ -0,0 +1,1035 @@
1
+ import { __decorate } from "@babylonjs/core/tslib.es6.js";
2
+ import { Observable } from "@babylonjs/core/Misc/observable.js";
3
+ import { ClipboardEventTypes } from "@babylonjs/core/Events/clipboardEvents.js";
4
+ import { PointerEventTypes } from "@babylonjs/core/Events/pointerEvents.js";
5
+ import { Control } from "./control.js";
6
+ import { ValueAndUnit } from "../valueAndUnit.js";
7
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
8
+ import { TextWrapper } from "./textWrapper.js";
9
+ import { serialize } from "@babylonjs/core/Misc/decorators.js";
10
+ /**
11
+ * Class used to create input text control
12
+ */
13
+ export class InputText extends Control {
14
+ /**
15
+ * Gets or sets outlineWidth of the text to display
16
+ */
17
+ get outlineWidth() {
18
+ return this._outlineWidth;
19
+ }
20
+ set outlineWidth(value) {
21
+ if (this._outlineWidth === value) {
22
+ return;
23
+ }
24
+ this._outlineWidth = value;
25
+ this._markAsDirty();
26
+ }
27
+ /**
28
+ * Gets or sets outlineColor of the text to display
29
+ */
30
+ get outlineColor() {
31
+ return this._outlineColor;
32
+ }
33
+ set outlineColor(value) {
34
+ if (this._outlineColor === value) {
35
+ return;
36
+ }
37
+ this._outlineColor = value;
38
+ this._markAsDirty();
39
+ }
40
+ /** Gets or sets the maximum width allowed by the control */
41
+ get maxWidth() {
42
+ return this._maxWidth.toString(this._host);
43
+ }
44
+ /** Gets the maximum width allowed by the control in pixels */
45
+ get maxWidthInPixels() {
46
+ return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
47
+ }
48
+ set maxWidth(value) {
49
+ if (this._maxWidth.toString(this._host) === value) {
50
+ return;
51
+ }
52
+ if (this._maxWidth.fromString(value)) {
53
+ this._markAsDirty();
54
+ }
55
+ }
56
+ /** Gets or sets the text highlighter transparency; default: 0.4 */
57
+ get highligherOpacity() {
58
+ return this._highligherOpacity;
59
+ }
60
+ set highligherOpacity(value) {
61
+ if (this._highligherOpacity === value) {
62
+ return;
63
+ }
64
+ this._highligherOpacity = value;
65
+ this._markAsDirty();
66
+ }
67
+ /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
68
+ get onFocusSelectAll() {
69
+ return this._onFocusSelectAll;
70
+ }
71
+ set onFocusSelectAll(value) {
72
+ if (this._onFocusSelectAll === value) {
73
+ return;
74
+ }
75
+ this._onFocusSelectAll = value;
76
+ this._markAsDirty();
77
+ }
78
+ /** Gets or sets the text hightlight color */
79
+ get textHighlightColor() {
80
+ return this._textHighlightColor;
81
+ }
82
+ set textHighlightColor(value) {
83
+ if (this._textHighlightColor === value) {
84
+ return;
85
+ }
86
+ this._textHighlightColor = value;
87
+ this._markAsDirty();
88
+ }
89
+ /** Gets or sets control margin */
90
+ get margin() {
91
+ return this._margin.toString(this._host);
92
+ }
93
+ /** Gets control margin in pixels */
94
+ get marginInPixels() {
95
+ return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
96
+ }
97
+ set margin(value) {
98
+ if (this._margin.toString(this._host) === value) {
99
+ return;
100
+ }
101
+ if (this._margin.fromString(value)) {
102
+ this._markAsDirty();
103
+ }
104
+ }
105
+ /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
106
+ get autoStretchWidth() {
107
+ return this._autoStretchWidth;
108
+ }
109
+ set autoStretchWidth(value) {
110
+ if (this._autoStretchWidth === value) {
111
+ return;
112
+ }
113
+ this._autoStretchWidth = value;
114
+ this._markAsDirty();
115
+ }
116
+ /** Gets or sets border thickness */
117
+ get thickness() {
118
+ return this._thickness;
119
+ }
120
+ set thickness(value) {
121
+ if (this._thickness === value) {
122
+ return;
123
+ }
124
+ this._thickness = value;
125
+ this._markAsDirty();
126
+ }
127
+ /** Gets or sets the background color when focused */
128
+ get focusedBackground() {
129
+ return this._focusedBackground;
130
+ }
131
+ set focusedBackground(value) {
132
+ if (this._focusedBackground === value) {
133
+ return;
134
+ }
135
+ this._focusedBackground = value;
136
+ this._markAsDirty();
137
+ }
138
+ /** Gets or sets the background color when focused */
139
+ set focusedColor(value) {
140
+ if (this._focusedColor === value) {
141
+ return;
142
+ }
143
+ this._focusedColor = value;
144
+ this._markAsDirty();
145
+ }
146
+ /** Gets or sets the background color */
147
+ get background() {
148
+ return this._background;
149
+ }
150
+ set background(value) {
151
+ if (this._background === value) {
152
+ return;
153
+ }
154
+ this._background = value;
155
+ this._markAsDirty();
156
+ }
157
+ /** Gets or sets the placeholder color */
158
+ get placeholderColor() {
159
+ return this._placeholderColor;
160
+ }
161
+ set placeholderColor(value) {
162
+ if (this._placeholderColor === value) {
163
+ return;
164
+ }
165
+ this._placeholderColor = value;
166
+ this._markAsDirty();
167
+ }
168
+ /** Gets or sets the text displayed when the control is empty */
169
+ get placeholderText() {
170
+ return this._placeholderText;
171
+ }
172
+ set placeholderText(value) {
173
+ if (this._placeholderText === value) {
174
+ return;
175
+ }
176
+ this._placeholderText = value;
177
+ this._markAsDirty();
178
+ }
179
+ /** Gets or sets the dead key. 0 to disable. */
180
+ get deadKey() {
181
+ return this._deadKey;
182
+ }
183
+ set deadKey(flag) {
184
+ this._deadKey = flag;
185
+ }
186
+ /** Gets or sets the highlight text */
187
+ get highlightedText() {
188
+ return this._highlightedText;
189
+ }
190
+ set highlightedText(text) {
191
+ if (this._highlightedText === text) {
192
+ return;
193
+ }
194
+ this._highlightedText = text;
195
+ this._markAsDirty();
196
+ }
197
+ /** Gets or sets if the current key should be added */
198
+ get addKey() {
199
+ return this._addKey;
200
+ }
201
+ set addKey(flag) {
202
+ this._addKey = flag;
203
+ }
204
+ /** Gets or sets the value of the current key being entered */
205
+ get currentKey() {
206
+ return this._currentKey;
207
+ }
208
+ set currentKey(key) {
209
+ this._currentKey = key;
210
+ }
211
+ /** Gets or sets the text displayed in the control */
212
+ get text() {
213
+ return this._textWrapper.text;
214
+ }
215
+ set text(value) {
216
+ const valueAsString = value.toString(); // Forcing convertion
217
+ if (!this._textWrapper) {
218
+ this._textWrapper = new TextWrapper();
219
+ }
220
+ if (this._textWrapper.text === valueAsString) {
221
+ return;
222
+ }
223
+ this._textWrapper.text = valueAsString;
224
+ this._textHasChanged();
225
+ }
226
+ _textHasChanged() {
227
+ this._markAsDirty();
228
+ this.onTextChangedObservable.notifyObservers(this);
229
+ }
230
+ _applyStates(context) {
231
+ super._applyStates(context);
232
+ if (this.outlineWidth) {
233
+ context.lineWidth = this.outlineWidth;
234
+ context.strokeStyle = this.outlineColor;
235
+ }
236
+ }
237
+ /** Gets or sets control width */
238
+ get width() {
239
+ return this._width.toString(this._host);
240
+ }
241
+ set width(value) {
242
+ if (this._width.toString(this._host) === value && !this._autoStretchWidth) {
243
+ return;
244
+ }
245
+ if (this._width.fromString(value)) {
246
+ this._markAsDirty();
247
+ }
248
+ this.autoStretchWidth = false;
249
+ }
250
+ /**
251
+ * Creates a new InputText
252
+ * @param name defines the control name
253
+ * @param text defines the text of the control
254
+ */
255
+ constructor(name, text = "") {
256
+ super(name);
257
+ this.name = name;
258
+ this._placeholderText = "";
259
+ this._background = "#222222";
260
+ this._focusedBackground = "#000000";
261
+ this._placeholderColor = "gray";
262
+ this._thickness = 1;
263
+ this._margin = new ValueAndUnit(10, ValueAndUnit.UNITMODE_PIXEL);
264
+ this._autoStretchWidth = true;
265
+ this._maxWidth = new ValueAndUnit(1, ValueAndUnit.UNITMODE_PERCENTAGE, false);
266
+ this._blinkIsEven = false;
267
+ this._cursorOffset = 0;
268
+ this._deadKey = false;
269
+ this._addKey = true;
270
+ this._currentKey = "";
271
+ this._isTextHighlightOn = false;
272
+ this._textHighlightColor = "#d5e0ff";
273
+ this._highligherOpacity = 0.4;
274
+ this._highlightedText = "";
275
+ this._startHighlightIndex = 0;
276
+ this._endHighlightIndex = 0;
277
+ this._cursorIndex = -1;
278
+ this._outlineWidth = 0;
279
+ this._outlineColor = "white";
280
+ this._onFocusSelectAll = false;
281
+ this._isPointerDown = false;
282
+ /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
283
+ this.promptMessage = "Please enter text:";
284
+ /** Force disable prompt on mobile device */
285
+ this.disableMobilePrompt = false;
286
+ /** Observable raised when the text changes */
287
+ this.onTextChangedObservable = new Observable();
288
+ /** Observable raised just before an entered character is to be added */
289
+ this.onBeforeKeyAddObservable = new Observable();
290
+ /** Observable raised when the text is highlighted */
291
+ this.onTextHighlightObservable = new Observable();
292
+ /** Observable raised when copy event is triggered */
293
+ this.onTextCopyObservable = new Observable();
294
+ /** Observable raised when cut event is triggered */
295
+ this.onTextCutObservable = new Observable();
296
+ /** Observable raised when paste event is triggered */
297
+ this.onTextPasteObservable = new Observable();
298
+ this.text = text;
299
+ this.isPointerBlocker = true;
300
+ this._focusedColor = "white";
301
+ }
302
+ /** @internal */
303
+ onBlur() {
304
+ this._isFocused = false;
305
+ this._scrollLeft = null;
306
+ this._cursorOffset = 0;
307
+ clearTimeout(this._blinkTimeout);
308
+ this._markAsDirty();
309
+ this.onBlurObservable.notifyObservers(this);
310
+ this._host.unRegisterClipboardEvents();
311
+ if (this._onClipboardObserver) {
312
+ this._host.onClipboardObservable.remove(this._onClipboardObserver);
313
+ }
314
+ const scene = this._host.getScene();
315
+ if (this._onPointerDblTapObserver && scene) {
316
+ scene.onPointerObservable.remove(this._onPointerDblTapObserver);
317
+ }
318
+ }
319
+ /** @internal */
320
+ onFocus() {
321
+ if (!this._isEnabled) {
322
+ return;
323
+ }
324
+ this._scrollLeft = null;
325
+ this._isFocused = true;
326
+ this._blinkIsEven = false;
327
+ this._cursorOffset = 0;
328
+ this._markAsDirty();
329
+ this.onFocusObservable.notifyObservers(this);
330
+ if (this._focusedBy === "touch" && !this.disableMobilePrompt) {
331
+ const value = prompt(this.promptMessage);
332
+ if (value !== null) {
333
+ this.text = value;
334
+ }
335
+ this._host.focusedControl = null;
336
+ return;
337
+ }
338
+ this._host.registerClipboardEvents();
339
+ this._onClipboardObserver = this._host.onClipboardObservable.add((clipboardInfo) => {
340
+ // process clipboard event, can be configured.
341
+ switch (clipboardInfo.type) {
342
+ case ClipboardEventTypes.COPY:
343
+ this._onCopyText(clipboardInfo.event);
344
+ this.onTextCopyObservable.notifyObservers(this);
345
+ break;
346
+ case ClipboardEventTypes.CUT:
347
+ this._onCutText(clipboardInfo.event);
348
+ this.onTextCutObservable.notifyObservers(this);
349
+ break;
350
+ case ClipboardEventTypes.PASTE:
351
+ this._onPasteText(clipboardInfo.event);
352
+ this.onTextPasteObservable.notifyObservers(this);
353
+ break;
354
+ default:
355
+ return;
356
+ }
357
+ });
358
+ const scene = this._host.getScene();
359
+ if (scene) {
360
+ //register the pointer double tap event
361
+ this._onPointerDblTapObserver = scene.onPointerObservable.add((pointerInfo) => {
362
+ if (!this._isFocused) {
363
+ return;
364
+ }
365
+ if (pointerInfo.type === PointerEventTypes.POINTERDOUBLETAP) {
366
+ this._processDblClick(pointerInfo);
367
+ }
368
+ });
369
+ }
370
+ if (this._onFocusSelectAll) {
371
+ this.selectAllText();
372
+ }
373
+ }
374
+ _getTypeName() {
375
+ return "InputText";
376
+ }
377
+ /**
378
+ * Function called to get the list of controls that should not steal the focus from this control
379
+ * @returns an array of controls
380
+ */
381
+ keepsFocusWith() {
382
+ if (!this._connectedVirtualKeyboard) {
383
+ return null;
384
+ }
385
+ return [this._connectedVirtualKeyboard];
386
+ }
387
+ /**
388
+ * @internal
389
+ */
390
+ processKey(keyCode, key, evt) {
391
+ if (this.isReadOnly) {
392
+ return;
393
+ }
394
+ //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
395
+ if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
396
+ return;
397
+ }
398
+ //select all
399
+ if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
400
+ this.selectAllText();
401
+ evt.preventDefault();
402
+ return;
403
+ }
404
+ // Specific cases
405
+ switch (keyCode) {
406
+ case 32: //SPACE
407
+ key = " "; //ie11 key for space is "Spacebar"
408
+ break;
409
+ case 191: //SLASH
410
+ if (evt) {
411
+ evt.preventDefault();
412
+ }
413
+ break;
414
+ case 8: // BACKSPACE
415
+ if (this._textWrapper.text && this._textWrapper.length > 0) {
416
+ //delete the highlighted text
417
+ if (this.isTextHighlightOn) {
418
+ this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
419
+ this._textHasChanged();
420
+ this.isTextHighlightOn = false;
421
+ this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
422
+ this._blinkIsEven = false;
423
+ if (evt) {
424
+ evt.preventDefault();
425
+ }
426
+ return;
427
+ }
428
+ //delete single character
429
+ if (this._cursorOffset === 0) {
430
+ this.text = this._textWrapper.substring(0, this._textWrapper.length - 1);
431
+ }
432
+ else {
433
+ const deletePosition = this._textWrapper.length - this._cursorOffset;
434
+ if (deletePosition > 0) {
435
+ this._textWrapper.removePart(deletePosition - 1, deletePosition);
436
+ this._textHasChanged();
437
+ }
438
+ }
439
+ }
440
+ if (evt) {
441
+ evt.preventDefault();
442
+ }
443
+ return;
444
+ case 46: // DELETE
445
+ if (this.isTextHighlightOn) {
446
+ this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
447
+ this._textHasChanged();
448
+ this.isTextHighlightOn = false;
449
+ this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
450
+ if (evt) {
451
+ evt.preventDefault();
452
+ }
453
+ return;
454
+ }
455
+ if (this._textWrapper.text && this._textWrapper.length > 0 && this._cursorOffset > 0) {
456
+ const deletePosition = this._textWrapper.length - this._cursorOffset;
457
+ this._textWrapper.removePart(deletePosition, deletePosition + 1);
458
+ this._textHasChanged();
459
+ this._cursorOffset--;
460
+ }
461
+ if (evt) {
462
+ evt.preventDefault();
463
+ }
464
+ return;
465
+ case 13: // RETURN
466
+ this._host.focusedControl = null;
467
+ this.isTextHighlightOn = false;
468
+ return;
469
+ case 35: // END
470
+ this._cursorOffset = 0;
471
+ this._blinkIsEven = false;
472
+ this.isTextHighlightOn = false;
473
+ this._markAsDirty();
474
+ return;
475
+ case 36: // HOME
476
+ this._cursorOffset = this._textWrapper.length;
477
+ this._blinkIsEven = false;
478
+ this.isTextHighlightOn = false;
479
+ this._markAsDirty();
480
+ return;
481
+ case 37: // LEFT
482
+ this._cursorOffset++;
483
+ if (this._cursorOffset > this._textWrapper.length) {
484
+ this._cursorOffset = this._textWrapper.length;
485
+ }
486
+ if (evt && evt.shiftKey) {
487
+ // update the cursor
488
+ this._blinkIsEven = false;
489
+ // shift + ctrl/cmd + <-
490
+ if (evt.ctrlKey || evt.metaKey) {
491
+ if (!this.isTextHighlightOn) {
492
+ if (this._textWrapper.length === this._cursorOffset) {
493
+ return;
494
+ }
495
+ else {
496
+ this._endHighlightIndex = this._textWrapper.length - this._cursorOffset + 1;
497
+ }
498
+ }
499
+ this._startHighlightIndex = 0;
500
+ this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
501
+ this._cursorOffset = this._textWrapper.length;
502
+ this.isTextHighlightOn = true;
503
+ this._markAsDirty();
504
+ return;
505
+ }
506
+ //store the starting point
507
+ if (!this.isTextHighlightOn) {
508
+ this.isTextHighlightOn = true;
509
+ this._cursorIndex = this._cursorOffset >= this._textWrapper.length ? this._textWrapper.length : this._cursorOffset - 1;
510
+ }
511
+ //if text is already highlighted
512
+ else if (this._cursorIndex === -1) {
513
+ this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
514
+ this._cursorOffset = this._startHighlightIndex === 0 ? this._textWrapper.length : this._textWrapper.length - this._startHighlightIndex + 1;
515
+ }
516
+ //set the highlight indexes
517
+ if (this._cursorIndex < this._cursorOffset) {
518
+ this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
519
+ this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
520
+ }
521
+ else if (this._cursorIndex > this._cursorOffset) {
522
+ this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
523
+ this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
524
+ }
525
+ else {
526
+ this.isTextHighlightOn = false;
527
+ }
528
+ this._markAsDirty();
529
+ return;
530
+ }
531
+ if (this.isTextHighlightOn) {
532
+ this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
533
+ this.isTextHighlightOn = false;
534
+ }
535
+ if (evt && (evt.ctrlKey || evt.metaKey)) {
536
+ this._cursorOffset = this._textWrapper.length;
537
+ evt.preventDefault();
538
+ }
539
+ this._blinkIsEven = false;
540
+ this.isTextHighlightOn = false;
541
+ this._cursorIndex = -1;
542
+ this._markAsDirty();
543
+ return;
544
+ case 39: // RIGHT
545
+ this._cursorOffset--;
546
+ if (this._cursorOffset < 0) {
547
+ this._cursorOffset = 0;
548
+ }
549
+ if (evt && evt.shiftKey) {
550
+ //update the cursor
551
+ this._blinkIsEven = false;
552
+ //shift + ctrl/cmd + ->
553
+ if (evt.ctrlKey || evt.metaKey) {
554
+ if (!this.isTextHighlightOn) {
555
+ if (this._cursorOffset === 0) {
556
+ return;
557
+ }
558
+ else {
559
+ this._startHighlightIndex = this._textWrapper.length - this._cursorOffset - 1;
560
+ }
561
+ }
562
+ this._endHighlightIndex = this._textWrapper.length;
563
+ this.isTextHighlightOn = true;
564
+ this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
565
+ this._cursorOffset = 0;
566
+ this._markAsDirty();
567
+ return;
568
+ }
569
+ if (!this.isTextHighlightOn) {
570
+ this.isTextHighlightOn = true;
571
+ this._cursorIndex = this._cursorOffset <= 0 ? 0 : this._cursorOffset + 1;
572
+ }
573
+ //if text is already highlighted
574
+ else if (this._cursorIndex === -1) {
575
+ this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
576
+ this._cursorOffset = this._textWrapper.length === this._endHighlightIndex ? 0 : this._textWrapper.length - this._endHighlightIndex - 1;
577
+ }
578
+ //set the highlight indexes
579
+ if (this._cursorIndex < this._cursorOffset) {
580
+ this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
581
+ this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
582
+ }
583
+ else if (this._cursorIndex > this._cursorOffset) {
584
+ this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
585
+ this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
586
+ }
587
+ else {
588
+ this.isTextHighlightOn = false;
589
+ }
590
+ this._markAsDirty();
591
+ return;
592
+ }
593
+ if (this.isTextHighlightOn) {
594
+ this._cursorOffset = this._textWrapper.length - this._endHighlightIndex;
595
+ this.isTextHighlightOn = false;
596
+ }
597
+ //ctr + ->
598
+ if (evt && (evt.ctrlKey || evt.metaKey)) {
599
+ this._cursorOffset = 0;
600
+ evt.preventDefault();
601
+ }
602
+ this._blinkIsEven = false;
603
+ this.isTextHighlightOn = false;
604
+ this._cursorIndex = -1;
605
+ this._markAsDirty();
606
+ return;
607
+ }
608
+ if (keyCode === 32) {
609
+ key = evt?.key ?? " ";
610
+ }
611
+ this._deadKey = key === "Dead";
612
+ // Printable characters
613
+ if (key &&
614
+ (keyCode === -1 || // Direct access
615
+ keyCode === 32 || // Space
616
+ keyCode === 34 || // " add support for single and double quotes
617
+ keyCode === 39 || // '
618
+ (keyCode > 47 && keyCode < 64) || // Numbers
619
+ (keyCode > 64 && keyCode < 91) || // Letters
620
+ (keyCode > 159 && keyCode < 193) || // Special characters
621
+ (keyCode > 218 && keyCode < 223) || // Special characters
622
+ (keyCode > 95 && keyCode < 112))) {
623
+ // Numpad
624
+ this._currentKey = key;
625
+ this.onBeforeKeyAddObservable.notifyObservers(this);
626
+ key = this._currentKey;
627
+ if (this._addKey && !this._deadKey) {
628
+ if (this.isTextHighlightOn) {
629
+ this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex, key);
630
+ this._textHasChanged();
631
+ this._cursorOffset = this._textWrapper.length - (this._startHighlightIndex + 1);
632
+ this.isTextHighlightOn = false;
633
+ this._blinkIsEven = false;
634
+ this._markAsDirty();
635
+ }
636
+ else if (this._cursorOffset === 0) {
637
+ this.text += this._deadKey && evt?.key ? evt.key : key;
638
+ }
639
+ else {
640
+ const insertPosition = this._textWrapper.length - this._cursorOffset;
641
+ this._textWrapper.removePart(insertPosition, insertPosition, key);
642
+ this._textHasChanged();
643
+ }
644
+ }
645
+ }
646
+ }
647
+ /**
648
+ * @internal
649
+ */
650
+ _updateValueFromCursorIndex(offset) {
651
+ //update the cursor
652
+ this._blinkIsEven = false;
653
+ if (this._cursorIndex === -1) {
654
+ this._cursorIndex = offset;
655
+ }
656
+ else {
657
+ if (this._cursorIndex < this._cursorOffset) {
658
+ this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
659
+ this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
660
+ }
661
+ else if (this._cursorIndex > this._cursorOffset) {
662
+ this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
663
+ this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
664
+ }
665
+ else {
666
+ this.isTextHighlightOn = false;
667
+ this._markAsDirty();
668
+ return;
669
+ }
670
+ }
671
+ this.isTextHighlightOn = true;
672
+ this._markAsDirty();
673
+ }
674
+ /**
675
+ * @internal
676
+ */
677
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
678
+ _processDblClick(evt) {
679
+ //pre-find the start and end index of the word under cursor, speeds up the rendering
680
+ this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
681
+ this._endHighlightIndex = this._startHighlightIndex;
682
+ let moveLeft, moveRight;
683
+ do {
684
+ moveRight = this._endHighlightIndex < this._textWrapper.length && this._textWrapper.isWord(this._endHighlightIndex) ? ++this._endHighlightIndex : 0;
685
+ moveLeft = this._startHighlightIndex > 0 && this._textWrapper.isWord(this._startHighlightIndex - 1) ? --this._startHighlightIndex : 0;
686
+ } while (moveLeft || moveRight);
687
+ this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
688
+ this.isTextHighlightOn = true;
689
+ this._clickedCoordinate = null;
690
+ this._blinkIsEven = true;
691
+ this._cursorIndex = -1;
692
+ this._markAsDirty();
693
+ }
694
+ /**
695
+ * Allow the user to select all text
696
+ */
697
+ selectAllText() {
698
+ this._blinkIsEven = true;
699
+ this.isTextHighlightOn = true;
700
+ this._startHighlightIndex = 0;
701
+ this._endHighlightIndex = this._textWrapper.length;
702
+ this._cursorOffset = this._textWrapper.length;
703
+ this._cursorIndex = -1;
704
+ this._markAsDirty();
705
+ }
706
+ /**
707
+ * Handles the keyboard event
708
+ * @param evt Defines the KeyboardEvent
709
+ */
710
+ processKeyboard(evt) {
711
+ // process pressed key
712
+ this.processKey(evt.keyCode, evt.key, evt);
713
+ super.processKeyboard(evt);
714
+ }
715
+ /**
716
+ * @internal
717
+ */
718
+ _onCopyText(ev) {
719
+ this.isTextHighlightOn = false;
720
+ //when write permission to clipbaord data is denied
721
+ try {
722
+ ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
723
+ }
724
+ catch { } //pass
725
+ this._host.clipboardData = this._highlightedText;
726
+ }
727
+ /**
728
+ * @internal
729
+ */
730
+ _onCutText(ev) {
731
+ if (!this._highlightedText) {
732
+ return;
733
+ }
734
+ this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
735
+ this._textHasChanged();
736
+ this.isTextHighlightOn = false;
737
+ this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
738
+ //when write permission to clipbaord data is denied
739
+ try {
740
+ ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
741
+ }
742
+ catch { } //pass
743
+ this._host.clipboardData = this._highlightedText;
744
+ this._highlightedText = "";
745
+ }
746
+ /**
747
+ * @internal
748
+ */
749
+ _onPasteText(ev) {
750
+ let data = "";
751
+ if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
752
+ data = ev.clipboardData.getData("text/plain");
753
+ }
754
+ else {
755
+ //get the cached data; returns blank string by default
756
+ data = this._host.clipboardData;
757
+ }
758
+ const insertPosition = this._textWrapper.length - this._cursorOffset;
759
+ this._textWrapper.removePart(insertPosition, insertPosition, data);
760
+ this._textHasChanged();
761
+ }
762
+ _draw(context) {
763
+ context.save();
764
+ this._applyStates(context);
765
+ if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
766
+ context.shadowColor = this.shadowColor;
767
+ context.shadowBlur = this.shadowBlur;
768
+ context.shadowOffsetX = this.shadowOffsetX;
769
+ context.shadowOffsetY = this.shadowOffsetY;
770
+ }
771
+ // Background
772
+ if (this._isFocused) {
773
+ if (this._focusedBackground) {
774
+ context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
775
+ context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
776
+ }
777
+ }
778
+ else if (this._background) {
779
+ context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
780
+ context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
781
+ }
782
+ if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
783
+ context.shadowBlur = 0;
784
+ context.shadowOffsetX = 0;
785
+ context.shadowOffsetY = 0;
786
+ }
787
+ if (!this._fontOffset || this._wasDirty) {
788
+ this._fontOffset = Control._GetFontOffset(context.font, this._host.getScene()?.getEngine());
789
+ }
790
+ // Text
791
+ const clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
792
+ if (this.color) {
793
+ context.fillStyle = this.color;
794
+ }
795
+ let text = this._beforeRenderText(this._textWrapper);
796
+ if (!this._isFocused && !this._textWrapper.text && this._placeholderText) {
797
+ text = new TextWrapper();
798
+ text.text = this._placeholderText;
799
+ if (this._placeholderColor) {
800
+ context.fillStyle = this._placeholderColor;
801
+ }
802
+ }
803
+ this._textWidth = context.measureText(text.text).width;
804
+ const marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
805
+ if (this._autoStretchWidth) {
806
+ this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
807
+ this._autoStretchWidth = true; // setting the width will have reset _autoStretchWidth to false!
808
+ }
809
+ const rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
810
+ const availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
811
+ context.save();
812
+ context.beginPath();
813
+ context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
814
+ context.clip();
815
+ if (this._isFocused && this._textWidth > availableWidth) {
816
+ const textLeft = clipTextLeft - this._textWidth + availableWidth;
817
+ if (!this._scrollLeft) {
818
+ this._scrollLeft = textLeft;
819
+ }
820
+ }
821
+ else {
822
+ this._scrollLeft = clipTextLeft;
823
+ }
824
+ if (this.outlineWidth) {
825
+ context.strokeText(text.text, this._scrollLeft, this._currentMeasure.top + rootY);
826
+ }
827
+ context.fillText(text.text, this._scrollLeft, this._currentMeasure.top + rootY);
828
+ // Cursor
829
+ if (this._isFocused) {
830
+ // Need to move cursor
831
+ if (this._clickedCoordinate) {
832
+ const rightPosition = this._scrollLeft + this._textWidth;
833
+ const absoluteCursorPosition = rightPosition - this._clickedCoordinate;
834
+ let currentSize = 0;
835
+ this._cursorOffset = 0;
836
+ let previousDist = 0;
837
+ do {
838
+ if (this._cursorOffset) {
839
+ previousDist = Math.abs(absoluteCursorPosition - currentSize);
840
+ }
841
+ this._cursorOffset++;
842
+ currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
843
+ } while (currentSize < absoluteCursorPosition && text.length >= this._cursorOffset);
844
+ // Find closest move
845
+ if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
846
+ this._cursorOffset--;
847
+ }
848
+ this._blinkIsEven = false;
849
+ this._clickedCoordinate = null;
850
+ }
851
+ // Render cursor
852
+ if (!this._blinkIsEven) {
853
+ const cursorOffsetText = text.substr(text.length - this._cursorOffset);
854
+ const cursorOffsetWidth = context.measureText(cursorOffsetText).width;
855
+ let cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
856
+ if (cursorLeft < clipTextLeft) {
857
+ this._scrollLeft += clipTextLeft - cursorLeft;
858
+ cursorLeft = clipTextLeft;
859
+ this._markAsDirty();
860
+ }
861
+ else if (cursorLeft > clipTextLeft + availableWidth) {
862
+ this._scrollLeft += clipTextLeft + availableWidth - cursorLeft;
863
+ cursorLeft = clipTextLeft + availableWidth;
864
+ this._markAsDirty();
865
+ }
866
+ if (!this.isTextHighlightOn) {
867
+ context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
868
+ }
869
+ }
870
+ clearTimeout(this._blinkTimeout);
871
+ this._blinkTimeout = setTimeout(() => {
872
+ this._blinkIsEven = !this._blinkIsEven;
873
+ this._markAsDirty();
874
+ }, 500);
875
+ //show the highlighted text
876
+ if (this.isTextHighlightOn) {
877
+ clearTimeout(this._blinkTimeout);
878
+ const highlightCursorOffsetWidth = context.measureText(text.substring(this._startHighlightIndex)).width;
879
+ let highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
880
+ this._highlightedText = text.substring(this._startHighlightIndex, this._endHighlightIndex);
881
+ let width = context.measureText(text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
882
+ if (highlightCursorLeft < clipTextLeft) {
883
+ width = width - (clipTextLeft - highlightCursorLeft);
884
+ if (!width) {
885
+ // when using left arrow on text.length > availableWidth;
886
+ // assigns the width of the first letter after clipTextLeft
887
+ width = context.measureText(text.charAt(text.length - this._cursorOffset)).width;
888
+ }
889
+ highlightCursorLeft = clipTextLeft;
890
+ }
891
+ //for transparancy
892
+ context.globalAlpha = this._highligherOpacity;
893
+ context.fillStyle = this._textHighlightColor;
894
+ context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
895
+ context.globalAlpha = 1.0;
896
+ }
897
+ }
898
+ context.restore();
899
+ // Border
900
+ if (this._thickness) {
901
+ if (this._isFocused) {
902
+ if (this.focusedColor) {
903
+ context.strokeStyle = this.focusedColor;
904
+ }
905
+ }
906
+ else {
907
+ if (this.color) {
908
+ context.strokeStyle = this.color;
909
+ }
910
+ }
911
+ context.lineWidth = this._thickness;
912
+ context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
913
+ }
914
+ context.restore();
915
+ }
916
+ _onPointerDown(target, coordinates, pointerId, buttonIndex, pi) {
917
+ if (!super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi)) {
918
+ return false;
919
+ }
920
+ if (this.isReadOnly) {
921
+ return true;
922
+ }
923
+ this._clickedCoordinate = coordinates.x;
924
+ this.isTextHighlightOn = false;
925
+ this._highlightedText = "";
926
+ this._cursorIndex = -1;
927
+ this._isPointerDown = true;
928
+ this._host._capturingControl[pointerId] = this;
929
+ this._focusedBy = pi.event.pointerType;
930
+ if (this._host.focusedControl === this) {
931
+ // Move cursor
932
+ clearTimeout(this._blinkTimeout);
933
+ this._markAsDirty();
934
+ return true;
935
+ }
936
+ if (!this._isEnabled) {
937
+ return false;
938
+ }
939
+ this._host.focusedControl = this;
940
+ return true;
941
+ }
942
+ _onPointerMove(target, coordinates, pointerId, pi) {
943
+ if (this._host.focusedControl === this && this._isPointerDown && !this.isReadOnly) {
944
+ this._clickedCoordinate = coordinates.x;
945
+ this._markAsDirty();
946
+ this._updateValueFromCursorIndex(this._cursorOffset);
947
+ }
948
+ super._onPointerMove(target, coordinates, pointerId, pi);
949
+ }
950
+ _onPointerUp(target, coordinates, pointerId, buttonIndex, notifyClick) {
951
+ this._isPointerDown = false;
952
+ delete this._host._capturingControl[pointerId];
953
+ super._onPointerUp(target, coordinates, pointerId, buttonIndex, notifyClick);
954
+ }
955
+ _beforeRenderText(textWrapper) {
956
+ return textWrapper;
957
+ }
958
+ /** @internal */
959
+ // eslint-disable-next-line @typescript-eslint/naming-convention
960
+ set isTextHighlightOn(value) {
961
+ if (this._isTextHighlightOn === value) {
962
+ return;
963
+ }
964
+ if (value) {
965
+ this.onTextHighlightObservable.notifyObservers(this);
966
+ }
967
+ this._isTextHighlightOn = value;
968
+ }
969
+ /** @internal */
970
+ // eslint-disable-next-line @typescript-eslint/naming-convention
971
+ get isTextHighlightOn() {
972
+ return this._isTextHighlightOn;
973
+ }
974
+ dispose() {
975
+ super.dispose();
976
+ this.onBlurObservable.clear();
977
+ this.onFocusObservable.clear();
978
+ this.onTextChangedObservable.clear();
979
+ this.onTextCopyObservable.clear();
980
+ this.onTextCutObservable.clear();
981
+ this.onTextPasteObservable.clear();
982
+ this.onTextHighlightObservable.clear();
983
+ this.onKeyboardEventProcessedObservable.clear();
984
+ }
985
+ }
986
+ __decorate([
987
+ serialize()
988
+ ], InputText.prototype, "promptMessage", void 0);
989
+ __decorate([
990
+ serialize()
991
+ ], InputText.prototype, "disableMobilePrompt", void 0);
992
+ __decorate([
993
+ serialize()
994
+ ], InputText.prototype, "maxWidth", null);
995
+ __decorate([
996
+ serialize()
997
+ ], InputText.prototype, "highligherOpacity", null);
998
+ __decorate([
999
+ serialize()
1000
+ ], InputText.prototype, "onFocusSelectAll", null);
1001
+ __decorate([
1002
+ serialize()
1003
+ ], InputText.prototype, "textHighlightColor", null);
1004
+ __decorate([
1005
+ serialize()
1006
+ ], InputText.prototype, "margin", null);
1007
+ __decorate([
1008
+ serialize()
1009
+ ], InputText.prototype, "autoStretchWidth", null);
1010
+ __decorate([
1011
+ serialize()
1012
+ ], InputText.prototype, "thickness", null);
1013
+ __decorate([
1014
+ serialize()
1015
+ ], InputText.prototype, "focusedBackground", null);
1016
+ __decorate([
1017
+ serialize()
1018
+ ], InputText.prototype, "background", null);
1019
+ __decorate([
1020
+ serialize()
1021
+ ], InputText.prototype, "placeholderColor", null);
1022
+ __decorate([
1023
+ serialize()
1024
+ ], InputText.prototype, "placeholderText", null);
1025
+ __decorate([
1026
+ serialize()
1027
+ ], InputText.prototype, "deadKey", null);
1028
+ __decorate([
1029
+ serialize()
1030
+ ], InputText.prototype, "text", null);
1031
+ __decorate([
1032
+ serialize()
1033
+ ], InputText.prototype, "width", null);
1034
+ RegisterClass("BABYLON.GUI.InputText", InputText);
1035
+ //# sourceMappingURL=inputText.js.map