@babylonjs/shared-ui-components 5.28.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 (312) hide show
  1. package/colorPicker/colorComponentEntry.d.ts +18 -0
  2. package/colorPicker/colorComponentEntry.js +37 -0
  3. package/colorPicker/colorComponentEntry.js.map +1 -0
  4. package/colorPicker/colorPicker.d.ts +43 -0
  5. package/colorPicker/colorPicker.js +137 -0
  6. package/colorPicker/colorPicker.js.map +1 -0
  7. package/colorPicker/hexColor.d.ts +20 -0
  8. package/colorPicker/hexColor.js +43 -0
  9. package/colorPicker/hexColor.js.map +1 -0
  10. package/components/Button.d.ts +10 -0
  11. package/components/Button.js +7 -0
  12. package/components/Button.js.map +1 -0
  13. package/components/Icon.d.ts +6 -0
  14. package/components/Icon.js +7 -0
  15. package/components/Icon.js.map +1 -0
  16. package/components/Label.d.ts +7 -0
  17. package/components/Label.js +7 -0
  18. package/components/Label.js.map +1 -0
  19. package/components/MessageDialog.d.ts +7 -0
  20. package/components/MessageDialog.js +23 -0
  21. package/components/MessageDialog.js.map +1 -0
  22. package/components/Toggle.d.ts +8 -0
  23. package/components/Toggle.js +16 -0
  24. package/components/Toggle.js.map +1 -0
  25. package/components/bars/CommandBarComponent.d.ts +16 -0
  26. package/components/bars/CommandBarComponent.js +69 -0
  27. package/components/bars/CommandBarComponent.js.map +1 -0
  28. package/components/bars/CommandButtonComponent.d.ts +11 -0
  29. package/components/bars/CommandButtonComponent.js +7 -0
  30. package/components/bars/CommandButtonComponent.js.map +1 -0
  31. package/components/bars/CommandDropdownComponent.d.ts +26 -0
  32. package/components/bars/CommandDropdownComponent.js +49 -0
  33. package/components/bars/CommandDropdownComponent.js.map +1 -0
  34. package/components/classNames.d.ts +2 -0
  35. package/components/classNames.js +19 -0
  36. package/components/classNames.js.map +1 -0
  37. package/components/colorPicker/ColorComponentEntry.d.ts +18 -0
  38. package/components/colorPicker/ColorComponentEntry.js +38 -0
  39. package/components/colorPicker/ColorComponentEntry.js.map +1 -0
  40. package/components/colorPicker/ColorPicker.d.ts +43 -0
  41. package/components/colorPicker/ColorPicker.js +138 -0
  42. package/components/colorPicker/ColorPicker.js.map +1 -0
  43. package/components/colorPicker/HexColor.d.ts +20 -0
  44. package/components/colorPicker/HexColor.js +46 -0
  45. package/components/colorPicker/HexColor.js.map +1 -0
  46. package/components/lines/ColorLineComponent.d.ts +40 -0
  47. package/components/lines/ColorLineComponent.js +146 -0
  48. package/components/lines/ColorLineComponent.js.map +1 -0
  49. package/components/lines/ColorPickerLineComponent.d.ts +33 -0
  50. package/components/lines/ColorPickerLineComponent.js +62 -0
  51. package/components/lines/ColorPickerLineComponent.js.map +1 -0
  52. package/components/lines/FileButtonLineComponent.d.ts +16 -0
  53. package/components/lines/FileButtonLineComponent.js +22 -0
  54. package/components/lines/FileButtonLineComponent.js.map +1 -0
  55. package/components/lines/NumericInputComponent.d.ts +31 -0
  56. package/components/lines/NumericInputComponent.js +87 -0
  57. package/components/lines/NumericInputComponent.js.map +1 -0
  58. package/license.md +71 -0
  59. package/lines/booleanLineComponent.d.ts +11 -0
  60. package/lines/booleanLineComponent.js +15 -0
  61. package/lines/booleanLineComponent.js.map +1 -0
  62. package/lines/buttonLineComponent.d.ts +12 -0
  63. package/lines/buttonLineComponent.js +11 -0
  64. package/lines/buttonLineComponent.js.map +1 -0
  65. package/lines/checkBoxLineComponent.d.ts +36 -0
  66. package/lines/checkBoxLineComponent.js +89 -0
  67. package/lines/checkBoxLineComponent.js.map +1 -0
  68. package/lines/color3LineComponent.d.ts +18 -0
  69. package/lines/color3LineComponent.js +10 -0
  70. package/lines/color3LineComponent.js.map +1 -0
  71. package/lines/color4LineComponent.d.ts +18 -0
  72. package/lines/color4LineComponent.js +10 -0
  73. package/lines/color4LineComponent.js.map +1 -0
  74. package/lines/colorLineComponent.d.ts +40 -0
  75. package/lines/colorLineComponent.js +145 -0
  76. package/lines/colorLineComponent.js.map +1 -0
  77. package/lines/colorPickerComponent.d.ts +31 -0
  78. package/lines/colorPickerComponent.js +61 -0
  79. package/lines/colorPickerComponent.js.map +1 -0
  80. package/lines/draggableLineComponent.d.ts +9 -0
  81. package/lines/draggableLineComponent.js +13 -0
  82. package/lines/draggableLineComponent.js.map +1 -0
  83. package/lines/fileButtonLineComponent.d.ts +17 -0
  84. package/lines/fileButtonLineComponent.js +21 -0
  85. package/lines/fileButtonLineComponent.js.map +1 -0
  86. package/lines/fileMultipleButtonLineComponent.d.ts +17 -0
  87. package/lines/fileMultipleButtonLineComponent.js +21 -0
  88. package/lines/fileMultipleButtonLineComponent.js.map +1 -0
  89. package/lines/floatLineComponent.d.ts +50 -0
  90. package/lines/floatLineComponent.js +176 -0
  91. package/lines/floatLineComponent.js.map +1 -0
  92. package/lines/hexLineComponent.d.ts +40 -0
  93. package/lines/hexLineComponent.js +122 -0
  94. package/lines/hexLineComponent.js.map +1 -0
  95. package/lines/iSelectedLineContainer.d.ts +4 -0
  96. package/lines/iSelectedLineContainer.js +2 -0
  97. package/lines/iSelectedLineContainer.js.map +1 -0
  98. package/lines/iconButtonLineComponent.d.ts +11 -0
  99. package/lines/iconButtonLineComponent.js +11 -0
  100. package/lines/iconButtonLineComponent.js.map +1 -0
  101. package/lines/iconComponent.d.ts +9 -0
  102. package/lines/iconComponent.js +8 -0
  103. package/lines/iconComponent.js.map +1 -0
  104. package/lines/indentedTextLineComponent.d.ts +16 -0
  105. package/lines/indentedTextLineComponent.js +27 -0
  106. package/lines/indentedTextLineComponent.js.map +1 -0
  107. package/lines/inputArrowsComponent.d.ts +13 -0
  108. package/lines/inputArrowsComponent.js +38 -0
  109. package/lines/inputArrowsComponent.js.map +1 -0
  110. package/lines/lineContainerComponent.d.ts +19 -0
  111. package/lines/lineContainerComponent.js +50 -0
  112. package/lines/lineContainerComponent.js.map +1 -0
  113. package/lines/linkButtonComponent.d.ts +16 -0
  114. package/lines/linkButtonComponent.js +21 -0
  115. package/lines/linkButtonComponent.js.map +1 -0
  116. package/lines/matrixLineComponent.d.ts +36 -0
  117. package/lines/matrixLineComponent.js +103 -0
  118. package/lines/matrixLineComponent.js.map +1 -0
  119. package/lines/messageLineComponent.d.ts +12 -0
  120. package/lines/messageLineComponent.js +15 -0
  121. package/lines/messageLineComponent.js.map +1 -0
  122. package/lines/numericInputComponent.d.ts +31 -0
  123. package/lines/numericInputComponent.js +86 -0
  124. package/lines/numericInputComponent.js.map +1 -0
  125. package/lines/optionsLineComponent.d.ts +48 -0
  126. package/lines/optionsLineComponent.js +119 -0
  127. package/lines/optionsLineComponent.js.map +1 -0
  128. package/lines/popup.d.ts +4 -0
  129. package/lines/popup.js +68 -0
  130. package/lines/popup.js.map +1 -0
  131. package/lines/radioLineComponent.d.ts +21 -0
  132. package/lines/radioLineComponent.js +27 -0
  133. package/lines/radioLineComponent.js.map +1 -0
  134. package/lines/sliderLineComponent.d.ts +37 -0
  135. package/lines/sliderLineComponent.js +90 -0
  136. package/lines/sliderLineComponent.js.map +1 -0
  137. package/lines/targetsProxy.d.ts +11 -0
  138. package/lines/targetsProxy.js +43 -0
  139. package/lines/targetsProxy.js.map +1 -0
  140. package/lines/textInputLineComponent.d.ts +47 -0
  141. package/lines/textInputLineComponent.js +155 -0
  142. package/lines/textInputLineComponent.js.map +1 -0
  143. package/lines/textLineComponent.d.ts +21 -0
  144. package/lines/textLineComponent.js +31 -0
  145. package/lines/textLineComponent.js.map +1 -0
  146. package/lines/unitButton.d.ts +8 -0
  147. package/lines/unitButton.js +8 -0
  148. package/lines/unitButton.js.map +1 -0
  149. package/lines/valueLineComponent.d.ts +15 -0
  150. package/lines/valueLineComponent.js +13 -0
  151. package/lines/valueLineComponent.js.map +1 -0
  152. package/lines/vector2LineComponent.d.ts +36 -0
  153. package/lines/vector2LineComponent.js +64 -0
  154. package/lines/vector2LineComponent.js.map +1 -0
  155. package/lines/vector3LineComponent.d.ts +41 -0
  156. package/lines/vector3LineComponent.js +75 -0
  157. package/lines/vector3LineComponent.js.map +1 -0
  158. package/lines/vector4LineComponent.d.ts +42 -0
  159. package/lines/vector4LineComponent.js +82 -0
  160. package/lines/vector4LineComponent.js.map +1 -0
  161. package/nodeGraphSystem/displayLedger.d.ts +5 -0
  162. package/nodeGraphSystem/displayLedger.js +4 -0
  163. package/nodeGraphSystem/displayLedger.js.map +1 -0
  164. package/nodeGraphSystem/frameNodePort.d.ts +25 -0
  165. package/nodeGraphSystem/frameNodePort.js +60 -0
  166. package/nodeGraphSystem/frameNodePort.js.map +1 -0
  167. package/nodeGraphSystem/graphCanvas.d.ts +111 -0
  168. package/nodeGraphSystem/graphCanvas.js +1132 -0
  169. package/nodeGraphSystem/graphCanvas.js.map +1 -0
  170. package/nodeGraphSystem/graphFrame.d.ts +153 -0
  171. package/nodeGraphSystem/graphFrame.js +1329 -0
  172. package/nodeGraphSystem/graphFrame.js.map +1 -0
  173. package/nodeGraphSystem/graphNode.d.ts +79 -0
  174. package/nodeGraphSystem/graphNode.js +460 -0
  175. package/nodeGraphSystem/graphNode.js.map +1 -0
  176. package/nodeGraphSystem/interfaces/displayManager.d.ts +13 -0
  177. package/nodeGraphSystem/interfaces/displayManager.js +2 -0
  178. package/nodeGraphSystem/interfaces/displayManager.js.map +1 -0
  179. package/nodeGraphSystem/interfaces/nodeContainer.d.ts +6 -0
  180. package/nodeGraphSystem/interfaces/nodeContainer.js +2 -0
  181. package/nodeGraphSystem/interfaces/nodeContainer.js.map +1 -0
  182. package/nodeGraphSystem/interfaces/nodeData.d.ts +15 -0
  183. package/nodeGraphSystem/interfaces/nodeData.js +2 -0
  184. package/nodeGraphSystem/interfaces/nodeData.js.map +1 -0
  185. package/nodeGraphSystem/interfaces/nodeLocationInfo.d.ts +26 -0
  186. package/nodeGraphSystem/interfaces/nodeLocationInfo.js +2 -0
  187. package/nodeGraphSystem/interfaces/nodeLocationInfo.js.map +1 -0
  188. package/nodeGraphSystem/interfaces/portData.d.ts +28 -0
  189. package/nodeGraphSystem/interfaces/portData.js +8 -0
  190. package/nodeGraphSystem/interfaces/portData.js.map +1 -0
  191. package/nodeGraphSystem/interfaces/propertyComponentProps.d.ts +6 -0
  192. package/nodeGraphSystem/interfaces/propertyComponentProps.js +2 -0
  193. package/nodeGraphSystem/interfaces/propertyComponentProps.js.map +1 -0
  194. package/nodeGraphSystem/interfaces/selectionChangedOptions.d.ts +11 -0
  195. package/nodeGraphSystem/interfaces/selectionChangedOptions.js +2 -0
  196. package/nodeGraphSystem/interfaces/selectionChangedOptions.js.map +1 -0
  197. package/nodeGraphSystem/nodeLink.d.ts +31 -0
  198. package/nodeGraphSystem/nodeLink.js +183 -0
  199. package/nodeGraphSystem/nodeLink.js.map +1 -0
  200. package/nodeGraphSystem/nodePort.d.ts +35 -0
  201. package/nodeGraphSystem/nodePort.js +129 -0
  202. package/nodeGraphSystem/nodePort.js.map +1 -0
  203. package/nodeGraphSystem/propertyLedger.d.ts +8 -0
  204. package/nodeGraphSystem/propertyLedger.js +4 -0
  205. package/nodeGraphSystem/propertyLedger.js.map +1 -0
  206. package/nodeGraphSystem/stateManager.d.ts +45 -0
  207. package/nodeGraphSystem/stateManager.js +19 -0
  208. package/nodeGraphSystem/stateManager.js.map +1 -0
  209. package/nodeGraphSystem/tools.d.ts +5 -0
  210. package/nodeGraphSystem/tools.js +37 -0
  211. package/nodeGraphSystem/tools.js.map +1 -0
  212. package/nodeGraphSystem/typeLedger.d.ts +8 -0
  213. package/nodeGraphSystem/typeLedger.js +3 -0
  214. package/nodeGraphSystem/typeLedger.js.map +1 -0
  215. package/nodeGraphSystem/types/framePortData.d.ts +7 -0
  216. package/nodeGraphSystem/types/framePortData.js +2 -0
  217. package/nodeGraphSystem/types/framePortData.js.map +1 -0
  218. package/package.json +55 -0
  219. package/propertyChangedEvent.d.ts +7 -0
  220. package/propertyChangedEvent.js +3 -0
  221. package/propertyChangedEvent.js.map +1 -0
  222. package/readme.md +6 -0
  223. package/stories/Button.stories.d.ts +10 -0
  224. package/stories/Button.stories.js +20 -0
  225. package/stories/Button.stories.js.map +1 -0
  226. package/stories/Icon.stories.d.ts +9 -0
  227. package/stories/Icon.stories.js +17 -0
  228. package/stories/Icon.stories.js.map +1 -0
  229. package/stories/Label.stories.d.ts +8 -0
  230. package/stories/Label.stories.js +11 -0
  231. package/stories/Label.stories.js.map +1 -0
  232. package/stories/MessageDialog.stories.d.ts +9 -0
  233. package/stories/MessageDialog.stories.js +20 -0
  234. package/stories/MessageDialog.stories.js.map +1 -0
  235. package/stories/Toggle.stories.d.ts +9 -0
  236. package/stories/Toggle.stories.js +18 -0
  237. package/stories/Toggle.stories.js.map +1 -0
  238. package/stories/bars/CommandBarComponent.stories.d.ts +11 -0
  239. package/stories/bars/CommandBarComponent.stories.js +13 -0
  240. package/stories/bars/CommandBarComponent.stories.js.map +1 -0
  241. package/stories/bars/CommandButtonComponent.stories.d.ts +6 -0
  242. package/stories/bars/CommandButtonComponent.stories.js +7 -0
  243. package/stories/bars/CommandButtonComponent.stories.js.map +1 -0
  244. package/stories/colorPicker/ColorPicker.stories.d.ts +11 -0
  245. package/stories/colorPicker/ColorPicker.stories.js +5 -0
  246. package/stories/colorPicker/ColorPicker.stories.js.map +1 -0
  247. package/stories/lines/ColorLineComponent.stories.d.ts +21 -0
  248. package/stories/lines/ColorLineComponent.stories.js +10 -0
  249. package/stories/lines/ColorLineComponent.stories.js.map +1 -0
  250. package/stories/lines/ColorPickerLineComponent.stories.d.ts +14 -0
  251. package/stories/lines/ColorPickerLineComponent.stories.js +11 -0
  252. package/stories/lines/ColorPickerLineComponent.stories.js.map +1 -0
  253. package/stories/lines/FileButtonLineComponent.stories.d.ts +6 -0
  254. package/stories/lines/FileButtonLineComponent.stories.js +6 -0
  255. package/stories/lines/FileButtonLineComponent.stories.js.map +1 -0
  256. package/stories/lines/NumericInputComponent.stories.d.ts +11 -0
  257. package/stories/lines/NumericInputComponent.stories.js +6 -0
  258. package/stories/lines/NumericInputComponent.stories.js.map +1 -0
  259. package/stringTools.d.ts +11 -0
  260. package/stringTools.js +89 -0
  261. package/stringTools.js.map +1 -0
  262. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.d.ts +15 -0
  263. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js +16 -0
  264. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js.map +1 -0
  265. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.d.ts +15 -0
  266. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js +15 -0
  267. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js.map +1 -0
  268. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.d.ts +17 -0
  269. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js +56 -0
  270. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js.map +1 -0
  271. package/tabs/propertyGrids/gui/controlPropertyGridComponent.d.ts +15 -0
  272. package/tabs/propertyGrids/gui/controlPropertyGridComponent.js +13 -0
  273. package/tabs/propertyGrids/gui/controlPropertyGridComponent.js.map +1 -0
  274. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.d.ts +15 -0
  275. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js +16 -0
  276. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js.map +1 -0
  277. package/tabs/propertyGrids/gui/gridPropertyGridComponent.d.ts +17 -0
  278. package/tabs/propertyGrids/gui/gridPropertyGridComponent.js +39 -0
  279. package/tabs/propertyGrids/gui/gridPropertyGridComponent.js.map +1 -0
  280. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.d.ts +15 -0
  281. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js +17 -0
  282. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js.map +1 -0
  283. package/tabs/propertyGrids/gui/imagePropertyGridComponent.d.ts +15 -0
  284. package/tabs/propertyGrids/gui/imagePropertyGridComponent.js +26 -0
  285. package/tabs/propertyGrids/gui/imagePropertyGridComponent.js.map +1 -0
  286. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.d.ts +15 -0
  287. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js +18 -0
  288. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js.map +1 -0
  289. package/tabs/propertyGrids/gui/linePropertyGridComponent.d.ts +16 -0
  290. package/tabs/propertyGrids/gui/linePropertyGridComponent.js +28 -0
  291. package/tabs/propertyGrids/gui/linePropertyGridComponent.js.map +1 -0
  292. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.d.ts +15 -0
  293. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js +18 -0
  294. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js.map +1 -0
  295. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.d.ts +15 -0
  296. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js +16 -0
  297. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js.map +1 -0
  298. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.d.ts +15 -0
  299. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js +16 -0
  300. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js.map +1 -0
  301. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.d.ts +15 -0
  302. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js +17 -0
  303. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js.map +1 -0
  304. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.d.ts +15 -0
  305. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js +15 -0
  306. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js.map +1 -0
  307. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.d.ts +15 -0
  308. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js +35 -0
  309. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js.map +1 -0
  310. package/tabs/propertyGrids/lockObject.d.ts +9 -0
  311. package/tabs/propertyGrids/lockObject.js +12 -0
  312. package/tabs/propertyGrids/lockObject.js.map +1 -0
@@ -0,0 +1,155 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { conflictingValuesPlaceholder } from "./targetsProxy.js";
4
+ import { InputArrowsComponent } from "./inputArrowsComponent.js";
5
+ export class TextInputLineComponent extends React.Component {
6
+ constructor(props) {
7
+ super(props);
8
+ this._localChange = false;
9
+ const emptyValue = this.props.numeric ? "0" : "";
10
+ this.state = {
11
+ value: (this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName]) || emptyValue,
12
+ dragging: false,
13
+ };
14
+ }
15
+ componentWillUnmount() {
16
+ if (this.props.lockObject) {
17
+ this.props.lockObject.lock = false;
18
+ }
19
+ }
20
+ shouldComponentUpdate(nextProps, nextState) {
21
+ if (this._localChange) {
22
+ this._localChange = false;
23
+ return true;
24
+ }
25
+ const newValue = nextProps.value !== undefined ? nextProps.value : nextProps.target[nextProps.propertyName];
26
+ if (newValue !== nextState.value) {
27
+ nextState.value = newValue || "";
28
+ return true;
29
+ }
30
+ if (nextState.dragging != this.state.dragging || nextProps.unit !== this.props.unit) {
31
+ return true;
32
+ }
33
+ return false;
34
+ }
35
+ raiseOnPropertyChanged(newValue, previousValue) {
36
+ if (this.props.onChange) {
37
+ this.props.onChange(newValue);
38
+ return;
39
+ }
40
+ if (!this.props.onPropertyChangedObservable) {
41
+ return;
42
+ }
43
+ this.props.onPropertyChangedObservable.notifyObservers({
44
+ object: this.props.target,
45
+ property: this.props.propertyName,
46
+ value: newValue,
47
+ initialValue: previousValue,
48
+ });
49
+ }
50
+ getCurrentNumericValue(value) {
51
+ const numeric = parseFloat(value);
52
+ if (!isNaN(numeric)) {
53
+ return numeric;
54
+ }
55
+ if (this.props.placeholder !== undefined) {
56
+ const placeholderNumeric = parseFloat(this.props.placeholder);
57
+ if (!isNaN(placeholderNumeric)) {
58
+ return placeholderNumeric;
59
+ }
60
+ }
61
+ return 0;
62
+ }
63
+ updateValue(value, valueToValidate) {
64
+ if (this.props.numbersOnly) {
65
+ if (/[^0-9.\p\x%-]/g.test(value)) {
66
+ return;
67
+ }
68
+ if (!value) {
69
+ value = "0";
70
+ }
71
+ //Removing starting zero if there is a number of a minus after it.
72
+ if (value.search(/0+[0-9-]/g) === 0) {
73
+ value = value.substr(1);
74
+ }
75
+ }
76
+ if (this.props.numeric) {
77
+ let numericValue = this.getCurrentNumericValue(value);
78
+ if (this.props.roundValues) {
79
+ numericValue = Math.round(numericValue);
80
+ }
81
+ if (this.props.min !== undefined) {
82
+ numericValue = Math.max(this.props.min, numericValue);
83
+ }
84
+ if (this.props.max !== undefined) {
85
+ numericValue = Math.min(this.props.max, numericValue);
86
+ }
87
+ value = numericValue.toString();
88
+ }
89
+ this._localChange = true;
90
+ const store = this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName];
91
+ if (this.props.validator && valueToValidate) {
92
+ if (this.props.validator(valueToValidate) == false) {
93
+ value = store;
94
+ }
95
+ }
96
+ this.setState({ value: value });
97
+ if (this.props.propertyName && !this.props.delayInput) {
98
+ this.props.target[this.props.propertyName] = value;
99
+ }
100
+ this.raiseOnPropertyChanged(value, store);
101
+ }
102
+ incrementValue(amount) {
103
+ if (this.props.step) {
104
+ amount *= this.props.step;
105
+ }
106
+ if (this.props.arrowsIncrement) {
107
+ this.props.arrowsIncrement(amount);
108
+ return;
109
+ }
110
+ const currentValue = this.getCurrentNumericValue(this.state.value);
111
+ this.updateValue((currentValue + amount).toFixed(2));
112
+ }
113
+ onKeyDown(event) {
114
+ if (this.props.arrows) {
115
+ if (event.key === "ArrowUp") {
116
+ this.incrementValue(1);
117
+ event.preventDefault();
118
+ }
119
+ if (event.key === "ArrowDown") {
120
+ this.incrementValue(-1);
121
+ event.preventDefault();
122
+ }
123
+ }
124
+ }
125
+ render() {
126
+ const value = this.state.value === conflictingValuesPlaceholder ? "" : this.state.value;
127
+ const placeholder = this.state.value === conflictingValuesPlaceholder ? conflictingValuesPlaceholder : this.props.placeholder || "";
128
+ const step = this.props.step || (this.props.roundValues ? 1 : 0.01);
129
+ return (_jsxs("div", { className: this.props.multilines ? "textInputArea" : this.props.unit !== undefined ? "textInputLine withUnits" : "textInputLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, color: "black", className: "icon" }), this.props.label !== undefined && (_jsx("div", { className: "label", title: this.props.label, children: this.props.label })), this.props.multilines && (_jsx(_Fragment, { children: _jsx("textarea", { value: this.state.value, onFocus: () => {
130
+ if (this.props.lockObject) {
131
+ this.props.lockObject.lock = true;
132
+ }
133
+ }, onChange: (evt) => this.updateValue(evt.target.value), onKeyDown: (evt) => {
134
+ if (evt.keyCode !== 13) {
135
+ return;
136
+ }
137
+ this.updateValue(this.state.value);
138
+ }, onBlur: (evt) => {
139
+ this.updateValue(evt.target.value, evt.target.value);
140
+ if (this.props.lockObject) {
141
+ this.props.lockObject.lock = false;
142
+ }
143
+ } }) })), !this.props.multilines && (_jsxs("div", { className: `value${this.props.noUnderline === true ? " noUnderline" : ""}${this.props.arrows ? " hasArrows" : ""}${this.state.dragging ? " dragging" : ""}`, children: [_jsx("input", { value: value, onBlur: (evt) => {
144
+ if (this.props.lockObject) {
145
+ this.props.lockObject.lock = false;
146
+ }
147
+ this.updateValue((this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName]) || "", evt.target.value);
148
+ }, onFocus: () => {
149
+ if (this.props.lockObject) {
150
+ this.props.lockObject.lock = true;
151
+ }
152
+ }, onChange: (evt) => this.updateValue(evt.target.value), onKeyDown: (evt) => this.onKeyDown(evt), placeholder: placeholder, type: this.props.numeric ? "number" : "text", step: step }), this.props.arrows && (_jsx(InputArrowsComponent, { incrementValue: (amount) => this.incrementValue(amount), setDragging: (dragging) => this.setState({ dragging }) }))] })), this.props.unit] }));
153
+ }
154
+ }
155
+ //# sourceMappingURL=textInputLineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textInputLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/textInputLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AA4B9D,MAAM,OAAO,sBAAuB,SAAQ,KAAK,CAAC,SAA6E;IAG3H,YAAY,KAAmC;QAC3C,KAAK,CAAC,KAAK,CAAC,CAAC;QAHT,iBAAY,GAAG,KAAK,CAAC;QAKzB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAEjD,IAAI,CAAC,KAAK,GAAG;YACT,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAa,CAAC,CAAC,IAAI,UAAU;YACtH,QAAQ,EAAE,KAAK;SAClB,CAAC;IACN,CAAC;IAED,oBAAoB;QAChB,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;YACvB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,KAAK,CAAC;SACtC;IACL,CAAC;IAED,qBAAqB,CAAC,SAAuC,EAAE,SAA+C;QAC1G,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;YAC1B,OAAO,IAAI,CAAC;SACf;QAED,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAA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AAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAI,CAC5I,IACC,CACT,EACA,IAAI,CAAC,KAAK,CAAC,IAAI,IACd,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport { InputArrowsComponent } from \"./inputArrowsComponent\";\r\n\r\nexport interface ITextInputLineComponentProps {\r\n label?: string;\r\n lockObject?: LockObject;\r\n target?: any;\r\n propertyName?: string;\r\n value?: string;\r\n onChange?: (value: string) => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n icon?: string;\r\n iconLabel?: string;\r\n noUnderline?: boolean;\r\n numbersOnly?: boolean;\r\n delayInput?: boolean;\r\n arrows?: boolean;\r\n arrowsIncrement?: (amount: number) => void;\r\n step?: number;\r\n numeric?: boolean;\r\n roundValues?: boolean;\r\n min?: number;\r\n max?: number;\r\n placeholder?: string;\r\n unit?: React.ReactNode;\r\n validator?: (value: string) => boolean;\r\n multilines?: boolean;\r\n}\r\n\r\nexport class TextInputLineComponent extends React.Component<ITextInputLineComponentProps, { value: string; dragging: boolean }> {\r\n private _localChange = false;\r\n\r\n constructor(props: ITextInputLineComponentProps) {\r\n super(props);\r\n\r\n const emptyValue = this.props.numeric ? \"0\" : \"\";\r\n\r\n this.state = {\r\n value: (this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName!]) || emptyValue,\r\n dragging: false,\r\n };\r\n }\r\n\r\n componentWillUnmount() {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n }\r\n\r\n shouldComponentUpdate(nextProps: ITextInputLineComponentProps, nextState: { value: string; dragging: boolean }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n const newValue = nextProps.value !== undefined ? nextProps.value : nextProps.target[nextProps.propertyName!];\r\n if (newValue !== nextState.value) {\r\n nextState.value = newValue || \"\";\r\n return true;\r\n }\r\n\r\n if (nextState.dragging != this.state.dragging || nextProps.unit !== this.props.unit) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n raiseOnPropertyChanged(newValue: string, previousValue: string) {\r\n if (this.props.onChange) {\r\n this.props.onChange(newValue);\r\n return;\r\n }\r\n\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName!,\r\n value: newValue,\r\n initialValue: previousValue,\r\n });\r\n }\r\n\r\n getCurrentNumericValue(value: string) {\r\n const numeric = parseFloat(value);\r\n if (!isNaN(numeric)) {\r\n return numeric;\r\n }\r\n if (this.props.placeholder !== undefined) {\r\n const placeholderNumeric = parseFloat(this.props.placeholder);\r\n if (!isNaN(placeholderNumeric)) {\r\n return placeholderNumeric;\r\n }\r\n }\r\n return 0;\r\n }\r\n\r\n updateValue(value: string, valueToValidate?: string) {\r\n if (this.props.numbersOnly) {\r\n if (/[^0-9.\\p\\x%-]/g.test(value)) {\r\n return;\r\n }\r\n if (!value) {\r\n value = \"0\";\r\n }\r\n\r\n //Removing starting zero if there is a number of a minus after it.\r\n if (value.search(/0+[0-9-]/g) === 0) {\r\n value = value.substr(1);\r\n }\r\n }\r\n\r\n if (this.props.numeric) {\r\n let numericValue = this.getCurrentNumericValue(value);\r\n if (this.props.roundValues) {\r\n numericValue = Math.round(numericValue);\r\n }\r\n if (this.props.min !== undefined) {\r\n numericValue = Math.max(this.props.min, numericValue);\r\n }\r\n if (this.props.max !== undefined) {\r\n numericValue = Math.min(this.props.max, numericValue);\r\n }\r\n value = numericValue.toString();\r\n }\r\n\r\n this._localChange = true;\r\n const store = this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName!];\r\n\r\n if (this.props.validator && valueToValidate) {\r\n if (this.props.validator(valueToValidate) == false) {\r\n value = store;\r\n }\r\n }\r\n\r\n this.setState({ value: value });\r\n\r\n if (this.props.propertyName && !this.props.delayInput) {\r\n this.props.target[this.props.propertyName] = value;\r\n }\r\n\r\n this.raiseOnPropertyChanged(value, store);\r\n }\r\n\r\n incrementValue(amount: number) {\r\n if (this.props.step) {\r\n amount *= this.props.step;\r\n }\r\n if (this.props.arrowsIncrement) {\r\n this.props.arrowsIncrement(amount);\r\n return;\r\n }\r\n const currentValue = this.getCurrentNumericValue(this.state.value);\r\n this.updateValue((currentValue + amount).toFixed(2));\r\n }\r\n\r\n onKeyDown(event: React.KeyboardEvent) {\r\n if (this.props.arrows) {\r\n if (event.key === \"ArrowUp\") {\r\n this.incrementValue(1);\r\n event.preventDefault();\r\n }\r\n if (event.key === \"ArrowDown\") {\r\n this.incrementValue(-1);\r\n event.preventDefault();\r\n }\r\n }\r\n }\r\n\r\n render() {\r\n const value = this.state.value === conflictingValuesPlaceholder ? \"\" : this.state.value;\r\n const placeholder = this.state.value === conflictingValuesPlaceholder ? conflictingValuesPlaceholder : this.props.placeholder || \"\";\r\n const step = this.props.step || (this.props.roundValues ? 1 : 0.01);\r\n return (\r\n <div className={this.props.multilines ? \"textInputArea\" : this.props.unit !== undefined ? \"textInputLine withUnits\" : \"textInputLine\"}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} color=\"black\" className=\"icon\" />}\r\n {this.props.label !== undefined && (\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n {this.props.multilines && (\r\n <>\r\n <textarea\r\n value={this.state.value}\r\n onFocus={() => {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = true;\r\n }\r\n }}\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n onKeyDown={(evt) => {\r\n if (evt.keyCode !== 13) {\r\n return;\r\n }\r\n this.updateValue(this.state.value);\r\n }}\r\n onBlur={(evt) => {\r\n this.updateValue(evt.target.value, evt.target.value);\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n }}\r\n />\r\n </>\r\n )}\r\n {!this.props.multilines && (\r\n <div\r\n className={`value${this.props.noUnderline === true ? \" noUnderline\" : \"\"}${this.props.arrows ? \" hasArrows\" : \"\"}${this.state.dragging ? \" dragging\" : \"\"}`}\r\n >\r\n <input\r\n value={value}\r\n onBlur={(evt) => {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n this.updateValue((this.props.value !== undefined ? this.props.value : this.props.target[this.props.propertyName!]) || \"\", evt.target.value);\r\n }}\r\n onFocus={() => {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = true;\r\n }\r\n }}\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n onKeyDown={(evt) => this.onKeyDown(evt)}\r\n placeholder={placeholder}\r\n type={this.props.numeric ? \"number\" : \"text\"}\r\n step={step}\r\n />\r\n {this.props.arrows && (\r\n <InputArrowsComponent incrementValue={(amount) => this.incrementValue(amount)} setDragging={(dragging) => this.setState({ dragging })} />\r\n )}\r\n </div>\r\n )}\r\n {this.props.unit}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+ interface ITextLineComponentProps {
3
+ label?: string;
4
+ value?: string;
5
+ color?: string;
6
+ underline?: boolean;
7
+ onLink?: () => void;
8
+ url?: string;
9
+ ignoreValue?: boolean;
10
+ additionalClass?: string;
11
+ icon?: string;
12
+ iconLabel?: string;
13
+ tooltip?: string;
14
+ }
15
+ export declare class TextLineComponent extends React.Component<ITextLineComponentProps> {
16
+ constructor(props: ITextLineComponentProps);
17
+ onLink(): void;
18
+ renderContent(): JSX.Element | null;
19
+ render(): JSX.Element;
20
+ }
21
+ export {};
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ export class TextLineComponent extends React.Component {
4
+ constructor(props) {
5
+ super(props);
6
+ }
7
+ onLink() {
8
+ if (this.props.url) {
9
+ window.open(this.props.url, "_blank");
10
+ return;
11
+ }
12
+ if (!this.props.onLink) {
13
+ return;
14
+ }
15
+ this.props.onLink();
16
+ }
17
+ renderContent() {
18
+ if (this.props.ignoreValue) {
19
+ return null;
20
+ }
21
+ if (this.props.onLink || this.props.url) {
22
+ return (_jsx("div", { className: "link-value", title: this.props.value, onClick: () => this.onLink(), children: this.props.url ? "doc" : this.props.value || "no name" }));
23
+ }
24
+ return (_jsx("div", { className: "value", title: this.props.value, style: { color: this.props.color ? this.props.color : "" }, children: this.props.value || "no name" }));
25
+ }
26
+ render() {
27
+ var _a, _b, _c;
28
+ return (_jsxs("div", { className: this.props.underline ? "textLine underline" : "textLine" + (this.props.additionalClass ? " " + this.props.additionalClass : ""), children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "label", title: (_b = (_a = this.props.tooltip) !== null && _a !== void 0 ? _a : this.props.label) !== null && _b !== void 0 ? _b : "", children: (_c = this.props.label) !== null && _c !== void 0 ? _c : "" }), this.renderContent()] }));
29
+ }
30
+ }
31
+ //# sourceMappingURL=textLineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/textLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgB/B,MAAM,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAkC;IAC3E,YAAY,KAA8B;QACtC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,MAAM;QACF,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YAChB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACtC,OAAO;SACV;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KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,EAAC,MAAM,GAAG,EAC1H,cAAK,SAAS,EAAC,OAAO,EAAC,KAAK,EAAE,MAAA,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,mCAAI,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,EAAE,YACrE,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,EAAE,GACrB,EACL,IAAI,CAAC,aAAa,EAAE,IACnB,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\n\r\ninterface ITextLineComponentProps {\r\n label?: string;\r\n value?: string;\r\n color?: string;\r\n underline?: boolean;\r\n onLink?: () => void;\r\n url?: string;\r\n ignoreValue?: boolean;\r\n additionalClass?: string;\r\n icon?: string;\r\n iconLabel?: string;\r\n tooltip?: string;\r\n}\r\n\r\nexport class TextLineComponent extends React.Component<ITextLineComponentProps> {\r\n constructor(props: ITextLineComponentProps) {\r\n super(props);\r\n }\r\n\r\n onLink() {\r\n if (this.props.url) {\r\n window.open(this.props.url, \"_blank\");\r\n return;\r\n }\r\n if (!this.props.onLink) {\r\n return;\r\n }\r\n\r\n this.props.onLink();\r\n }\r\n\r\n renderContent() {\r\n if (this.props.ignoreValue) {\r\n return null;\r\n }\r\n\r\n if (this.props.onLink || this.props.url) {\r\n return (\r\n <div className=\"link-value\" title={this.props.value} onClick={() => this.onLink()}>\r\n {this.props.url ? \"doc\" : this.props.value || \"no name\"}\r\n </div>\r\n );\r\n }\r\n return (\r\n <div className=\"value\" title={this.props.value} style={{ color: this.props.color ? this.props.color : \"\" }}>\r\n {this.props.value || \"no name\"}\r\n </div>\r\n );\r\n }\r\n\r\n render() {\r\n return (\r\n <div className={this.props.underline ? \"textLine underline\" : \"textLine\" + (this.props.additionalClass ? \" \" + this.props.additionalClass : \"\")}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"label\" title={this.props.tooltip ?? this.props.label ?? \"\"}>\r\n {this.props.label ?? \"\"}\r\n </div>\r\n {this.renderContent()}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ interface IUnitButtonProps {
3
+ unit: string;
4
+ locked?: boolean;
5
+ onClick?: (unit: string) => void;
6
+ }
7
+ export declare function UnitButton(props: IUnitButtonProps): JSX.Element;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function UnitButton(props) {
3
+ return (_jsx("button", { className: "unit", onClick: () => {
4
+ if (props.onClick && !props.locked)
5
+ props.onClick(props.unit || "");
6
+ }, disabled: props.locked, children: props.unit }));
7
+ }
8
+ //# sourceMappingURL=unitButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unitButton.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/unitButton.tsx"],"names":[],"mappings":";AAMA,MAAM,UAAU,UAAU,CAAC,KAAuB;IAC9C,OAAO,CACH,iBACI,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,GAAG,EAAE;YACV,IAAI,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM;gBAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QACxE,CAAC,EACD,QAAQ,EAAE,KAAK,CAAC,MAAM,YAErB,KAAK,CAAC,IAAI,GACN,CACZ,CAAC;AACN,CAAC","sourcesContent":["interface IUnitButtonProps {\r\n unit: string;\r\n locked?: boolean;\r\n onClick?: (unit: string) => void;\r\n}\r\n\r\nexport function UnitButton(props: IUnitButtonProps) {\r\n return (\r\n <button\r\n className={\"unit\"}\r\n onClick={() => {\r\n if (props.onClick && !props.locked) props.onClick(props.unit || \"\");\r\n }}\r\n disabled={props.locked}\r\n >\r\n {props.unit}\r\n </button>\r\n );\r\n}\r\n"]}
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ interface IValueLineComponentProps {
3
+ label: string;
4
+ value: number;
5
+ color?: string;
6
+ fractionDigits?: number;
7
+ units?: string;
8
+ icon?: string;
9
+ iconLabel?: string;
10
+ }
11
+ export declare class ValueLineComponent extends React.Component<IValueLineComponentProps> {
12
+ constructor(props: IValueLineComponentProps);
13
+ render(): JSX.Element;
14
+ }
15
+ export {};
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ export class ValueLineComponent extends React.Component {
4
+ constructor(props) {
5
+ super(props);
6
+ }
7
+ render() {
8
+ const digits = this.props.fractionDigits !== undefined ? this.props.fractionDigits : 2;
9
+ const value = this.props.value.toFixed(digits) + (this.props.units ? " " + this.props.units : "");
10
+ return (_jsxs("div", { className: "textLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsx("div", { className: "value", style: { color: this.props.color ? this.props.color : "" }, children: value })] }));
11
+ }
12
+ }
13
+ //# sourceMappingURL=valueLineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valueLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/valueLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,MAAM,OAAO,kBAAmB,SAAQ,KAAK,CAAC,SAAmC;IAC7E,YAAY,KAA+B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,MAAM;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;QACvF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAElG,OAAO,CACH,eAAK,SAAS,EAAC,UAAU,aACpB,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,cAAK,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,EAAC,MAAM,GAAG,EAC1H,cAAK,SAAS,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,YACzC,IAAI,CAAC,KAAK,CAAC,KAAK,GACf,EACN,cAAK,SAAS,EAAC,OAAO,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,YAC5E,KAAK,GACJ,IACJ,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\n\r\ninterface IValueLineComponentProps {\r\n label: string;\r\n value: number;\r\n color?: string;\r\n fractionDigits?: number;\r\n units?: string;\r\n icon?: string;\r\n iconLabel?: string;\r\n}\r\n\r\nexport class ValueLineComponent extends React.Component<IValueLineComponentProps> {\r\n constructor(props: IValueLineComponentProps) {\r\n super(props);\r\n }\r\n\r\n render() {\r\n const digits = this.props.fractionDigits !== undefined ? this.props.fractionDigits : 2;\r\n const value = this.props.value.toFixed(digits) + (this.props.units ? \" \" + this.props.units : \"\");\r\n\r\n return (\r\n <div className=\"textLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"value\" style={{ color: this.props.color ? this.props.color : \"\" }}>\r\n {value}\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ import type { Vector2 } from "@babylonjs/core/Maths/math.vector.js";
3
+ import type { Observable } from "@babylonjs/core/Misc/observable.js";
4
+ import type { PropertyChangedEvent } from "../propertyChangedEvent";
5
+ import type { LockObject } from "../tabs/propertyGrids/lockObject";
6
+ interface IVector2LineComponentProps {
7
+ label: string;
8
+ target: any;
9
+ propertyName: string;
10
+ step?: number;
11
+ onChange?: (newvalue: Vector2) => void;
12
+ onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
13
+ icon?: string;
14
+ iconLabel?: string;
15
+ lockObject: LockObject;
16
+ }
17
+ export declare class Vector2LineComponent extends React.Component<IVector2LineComponentProps, {
18
+ isExpanded: boolean;
19
+ value: Vector2;
20
+ }> {
21
+ static defaultProps: {
22
+ step: number;
23
+ };
24
+ private _localChange;
25
+ constructor(props: IVector2LineComponentProps);
26
+ shouldComponentUpdate(nextProps: IVector2LineComponentProps, nextState: {
27
+ isExpanded: boolean;
28
+ value: Vector2;
29
+ }): boolean;
30
+ switchExpandState(): void;
31
+ raiseOnPropertyChanged(previousValue: Vector2): void;
32
+ updateStateX(value: number): void;
33
+ updateStateY(value: number): void;
34
+ render(): JSX.Element;
35
+ }
36
+ export {};
@@ -0,0 +1,64 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { NumericInputComponent } from "./numericInputComponent.js";
4
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
+ import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
6
+ export class Vector2LineComponent extends React.Component {
7
+ constructor(props) {
8
+ super(props);
9
+ this._localChange = false;
10
+ this.state = { isExpanded: false, value: this.props.target[this.props.propertyName].clone() };
11
+ }
12
+ shouldComponentUpdate(nextProps, nextState) {
13
+ const nextPropsValue = nextProps.target[nextProps.propertyName];
14
+ if (!nextPropsValue.equals(nextState.value) || this._localChange) {
15
+ nextState.value = nextPropsValue.clone();
16
+ this._localChange = false;
17
+ return true;
18
+ }
19
+ return false;
20
+ }
21
+ switchExpandState() {
22
+ this._localChange = true;
23
+ this.setState({ isExpanded: !this.state.isExpanded });
24
+ }
25
+ raiseOnPropertyChanged(previousValue) {
26
+ if (this.props.onChange) {
27
+ this.props.onChange(this.state.value);
28
+ }
29
+ if (!this.props.onPropertyChangedObservable) {
30
+ return;
31
+ }
32
+ this.props.onPropertyChangedObservable.notifyObservers({
33
+ object: this.props.target,
34
+ property: this.props.propertyName,
35
+ value: this.state.value,
36
+ initialValue: previousValue,
37
+ });
38
+ }
39
+ updateStateX(value) {
40
+ this._localChange = true;
41
+ const store = this.state.value.clone();
42
+ this.props.target[this.props.propertyName].x = value;
43
+ this.state.value.x = value;
44
+ this.setState({ value: this.state.value });
45
+ this.raiseOnPropertyChanged(store);
46
+ }
47
+ updateStateY(value) {
48
+ this._localChange = true;
49
+ const store = this.state.value.clone();
50
+ this.props.target[this.props.propertyName].y = value;
51
+ this.state.value.y = value;
52
+ this.setState({ value: this.state.value });
53
+ this.raiseOnPropertyChanged(store);
54
+ }
55
+ render() {
56
+ const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
57
+ return (_jsxs("div", { className: "vector3Line", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsxs("div", { className: "firstLine", title: this.props.label, children: [_jsx("div", { className: "label", children: this.props.label }), _jsx("div", { className: "vector", children: `X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}` }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron })] }), this.state.isExpanded && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "x", step: this.props.step, value: this.state.value.x, onChange: (value) => this.updateStateX(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "y", step: this.props.step, value: this.state.value.y, onChange: (value) => this.updateStateY(value) })] }))] }));
58
+ }
59
+ }
60
+ // eslint-disable-next-line @typescript-eslint/naming-convention
61
+ Vector2LineComponent.defaultProps = {
62
+ step: 0.001, // cm
63
+ };
64
+ //# sourceMappingURL=vector2LineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector2LineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/vector2LineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAgBpE,MAAM,OAAO,oBAAqB,SAAQ,KAAK,CAAC,SAA8E;IAQ1H,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;QAHT,iBAAY,GAAG,KAAK,CAAC;QAKzB,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;IAClG,CAAC;IAED,qBAAqB,CAAC,SAAqC,EAAE,SAAkD;QAC3G,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAEhE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK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Q,YAAE,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAO,EAC1G,cAAK,SAAS,EAAC,kBAAkB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAC,QAAQ,YACpF,OAAO,GACN,IACJ,EACL,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CACtB,eAAK,SAAS,EAAC,YAAY,aACvB,KAAC,qBAAqB,IAClB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,EACF,KAAC,qBAAqB,IAClB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,IACA,CACT,IACC,CACT,CAAC;IACN,CAAC;;AApGD,gEAAgE;AACzD,iCAAY,GAAG;IAClB,IAAI,EAAE,KAAK,EAAE,KAAK;CACrB,CAAC","sourcesContent":["import * as React from \"react\";\r\nimport type { Vector2 } from \"core/Maths/math.vector\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\n\r\nimport { NumericInputComponent } from \"./numericInputComponent\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faMinus, faPlus } from \"@fortawesome/free-solid-svg-icons\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\ninterface IVector2LineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n step?: number;\r\n onChange?: (newvalue: Vector2) => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n icon?: string;\r\n iconLabel?: string;\r\n lockObject: LockObject;\r\n}\r\n\r\nexport class Vector2LineComponent extends React.Component<IVector2LineComponentProps, { isExpanded: boolean; value: Vector2 }> {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n static defaultProps = {\r\n step: 0.001, // cm\r\n };\r\n\r\n private _localChange = false;\r\n\r\n constructor(props: IVector2LineComponentProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, value: this.props.target[this.props.propertyName].clone() };\r\n }\r\n\r\n shouldComponentUpdate(nextProps: IVector2LineComponentProps, nextState: { isExpanded: boolean; value: Vector2 }) {\r\n const nextPropsValue = nextProps.target[nextProps.propertyName];\r\n\r\n if (!nextPropsValue.equals(nextState.value) || this._localChange) {\r\n nextState.value = nextPropsValue.clone();\r\n this._localChange = false;\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n switchExpandState() {\r\n this._localChange = true;\r\n this.setState({ isExpanded: !this.state.isExpanded });\r\n }\r\n\r\n raiseOnPropertyChanged(previousValue: Vector2) {\r\n if (this.props.onChange) {\r\n this.props.onChange(this.state.value);\r\n }\r\n\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName,\r\n value: this.state.value,\r\n initialValue: previousValue,\r\n });\r\n }\r\n\r\n updateStateX(value: number) {\r\n this._localChange = true;\r\n\r\n const store = this.state.value.clone();\r\n this.props.target[this.props.propertyName].x = value;\r\n this.state.value.x = value;\r\n this.setState({ value: this.state.value });\r\n\r\n this.raiseOnPropertyChanged(store);\r\n }\r\n\r\n updateStateY(value: number) {\r\n this._localChange = true;\r\n\r\n const store = this.state.value.clone();\r\n this.props.target[this.props.propertyName].y = value;\r\n this.state.value.y = value;\r\n this.setState({ value: this.state.value });\r\n\r\n this.raiseOnPropertyChanged(store);\r\n }\r\n\r\n render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className=\"vector3Line\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"firstLine\" title={this.props.label}>\r\n <div className=\"label\">{this.props.label}</div>\r\n <div className=\"vector\">{`X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}`}</div>\r\n <div className=\"expand hoverIcon\" onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className=\"secondLine\">\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"x\"\r\n step={this.props.step}\r\n value={this.state.value.x}\r\n onChange={(value) => this.updateStateX(value)}\r\n />\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"y\"\r\n step={this.props.step}\r\n value={this.state.value.y}\r\n onChange={(value) => this.updateStateY(value)}\r\n />\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -0,0 +1,41 @@
1
+ import * as React from "react";
2
+ import type { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
3
+ import type { Observable } from "@babylonjs/core/Misc/observable.js";
4
+ import type { PropertyChangedEvent } from "../propertyChangedEvent";
5
+ import type { LockObject } from "../tabs/propertyGrids/lockObject";
6
+ interface IVector3LineComponentProps {
7
+ label: string;
8
+ target: any;
9
+ propertyName: string;
10
+ step?: number;
11
+ onChange?: (newvalue: Vector3) => void;
12
+ useEuler?: boolean;
13
+ onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
14
+ noSlider?: boolean;
15
+ icon?: string;
16
+ iconLabel?: string;
17
+ lockObject: LockObject;
18
+ }
19
+ export declare class Vector3LineComponent extends React.Component<IVector3LineComponentProps, {
20
+ isExpanded: boolean;
21
+ value: Vector3;
22
+ }> {
23
+ static defaultProps: {
24
+ step: number;
25
+ };
26
+ private _localChange;
27
+ constructor(props: IVector3LineComponentProps);
28
+ getCurrentValue(): any;
29
+ shouldComponentUpdate(nextProps: IVector3LineComponentProps, nextState: {
30
+ isExpanded: boolean;
31
+ value: Vector3;
32
+ }): boolean;
33
+ switchExpandState(): void;
34
+ raiseOnPropertyChanged(previousValue: Vector3): void;
35
+ updateVector3(): void;
36
+ updateStateX(value: number): void;
37
+ updateStateY(value: number): void;
38
+ updateStateZ(value: number): void;
39
+ render(): JSX.Element;
40
+ }
41
+ export {};
@@ -0,0 +1,75 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { NumericInputComponent } from "../lines/numericInputComponent.js";
4
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
+ import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
6
+ import { SliderLineComponent } from "../lines/sliderLineComponent.js";
7
+ import { Tools } from "@babylonjs/core/Misc/tools.js";
8
+ export class Vector3LineComponent extends React.Component {
9
+ constructor(props) {
10
+ super(props);
11
+ this._localChange = false;
12
+ this.state = { isExpanded: false, value: this.getCurrentValue().clone() };
13
+ }
14
+ getCurrentValue() {
15
+ return this.props.target[this.props.propertyName];
16
+ }
17
+ shouldComponentUpdate(nextProps, nextState) {
18
+ const nextPropsValue = this.getCurrentValue();
19
+ if (!nextPropsValue.equals(nextState.value) || this._localChange) {
20
+ nextState.value = nextPropsValue.clone();
21
+ this._localChange = false;
22
+ return true;
23
+ }
24
+ return false;
25
+ }
26
+ switchExpandState() {
27
+ this._localChange = true;
28
+ this.setState({ isExpanded: !this.state.isExpanded });
29
+ }
30
+ raiseOnPropertyChanged(previousValue) {
31
+ if (this.props.onChange) {
32
+ this.props.onChange(this.state.value);
33
+ }
34
+ if (!this.props.onPropertyChangedObservable) {
35
+ return;
36
+ }
37
+ this.props.onPropertyChangedObservable.notifyObservers({
38
+ object: this.props.target,
39
+ property: this.props.propertyName,
40
+ value: this.state.value,
41
+ initialValue: previousValue,
42
+ });
43
+ }
44
+ updateVector3() {
45
+ const store = this.props.target[this.props.propertyName].clone();
46
+ this.props.target[this.props.propertyName] = this.state.value;
47
+ this.setState({ value: store });
48
+ this.raiseOnPropertyChanged(store);
49
+ }
50
+ updateStateX(value) {
51
+ this._localChange = true;
52
+ this.state.value.x = value;
53
+ this.updateVector3();
54
+ }
55
+ updateStateY(value) {
56
+ this._localChange = true;
57
+ this.state.value.y = value;
58
+ this.updateVector3();
59
+ }
60
+ updateStateZ(value) {
61
+ this._localChange = true;
62
+ this.state.value.z = value;
63
+ this.updateVector3();
64
+ }
65
+ render() {
66
+ const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
67
+ return (_jsxs("div", { className: "vector3Line", children: [_jsxs("div", { className: "firstLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsxs("div", { className: "vector", children: [!this.props.useEuler && `X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}, Z: ${this.state.value.z.toFixed(2)}`, this.props.useEuler &&
68
+ `X: ${Tools.ToDegrees(this.state.value.x).toFixed(2)}, Y: ${Tools.ToDegrees(this.state.value.y).toFixed(2)}, Z: ${Tools.ToDegrees(this.state.value.z).toFixed(2)}`] }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron })] }), this.state.isExpanded && !this.props.useEuler && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInputComponent, { label: "x", lockObject: this.props.lockObject, step: this.props.step, value: this.state.value.x, onChange: (value) => this.updateStateX(value) }), _jsx(NumericInputComponent, { label: "y", lockObject: this.props.lockObject, step: this.props.step, value: this.state.value.y, onChange: (value) => this.updateStateY(value) }), _jsx(NumericInputComponent, { label: "z", lockObject: this.props.lockObject, step: this.props.step, value: this.state.value.z, onChange: (value) => this.updateStateZ(value) })] })), this.state.isExpanded && this.props.useEuler && !this.props.noSlider && (_jsxs("div", { className: "secondLine", children: [_jsx(SliderLineComponent, { lockObject: this.props.lockObject, margin: true, label: "x", minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(this.state.value.x), onChange: (value) => this.updateStateX(Tools.ToRadians(value)) }), _jsx(SliderLineComponent, { lockObject: this.props.lockObject, margin: true, label: "y", minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(this.state.value.y), onChange: (value) => this.updateStateY(Tools.ToRadians(value)) }), _jsx(SliderLineComponent, { lockObject: this.props.lockObject, margin: true, label: "z", minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(this.state.value.z), onChange: (value) => this.updateStateZ(Tools.ToRadians(value)) })] })), this.state.isExpanded && this.props.useEuler && this.props.noSlider && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "x", step: this.props.step, value: Tools.ToDegrees(this.state.value.x), onChange: (value) => this.updateStateX(Tools.ToRadians(value)) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "y", step: this.props.step, value: Tools.ToDegrees(this.state.value.y), onChange: (value) => this.updateStateY(Tools.ToRadians(value)) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "z", step: this.props.step, value: Tools.ToDegrees(this.state.value.z), onChange: (value) => this.updateStateZ(Tools.ToRadians(value)) })] }))] }));
69
+ }
70
+ }
71
+ // eslint-disable-next-line @typescript-eslint/naming-convention
72
+ Vector3LineComponent.defaultProps = {
73
+ step: 0.001, // cm
74
+ };
75
+ //# sourceMappingURL=vector3LineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector3LineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/vector3LineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAiBxC,MAAM,OAAO,oBAAqB,SAAQ,KAAK,CAAC,SAA8E;IAQ1H,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;QAHT,iBAAY,GAAG,KAAK,CAAC;QAKzB,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;IAC9E,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;IAED,qBAAqB,CAAC,SAAqC,EAAE,SAAkD;QAC3G,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAE9C,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE;YAC9D,SAAS,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;YACzC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;YAC1B,OA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,CAAC,CAAC,CAAC,EAC1C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAChE,EACF,KAAC,qBAAqB,IAClB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAC1C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAChE,IACA,CACT,IACC,CACT,CAAC;IACN,CAAC;;AA1LD,gEAAgE;AACzD,iCAAY,GAAG;IAClB,IAAI,EAAE,KAAK,EAAE,KAAK;CACrB,CAAC","sourcesContent":["import * as React from \"react\";\r\nimport type { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\n\r\nimport { NumericInputComponent } from \"../lines/numericInputComponent\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faMinus, faPlus } from \"@fortawesome/free-solid-svg-icons\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { SliderLineComponent } from \"../lines/sliderLineComponent\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\ninterface IVector3LineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n step?: number;\r\n onChange?: (newvalue: Vector3) => void;\r\n useEuler?: boolean;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n noSlider?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n lockObject: LockObject;\r\n}\r\n\r\nexport class Vector3LineComponent extends React.Component<IVector3LineComponentProps, { isExpanded: boolean; value: Vector3 }> {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n static defaultProps = {\r\n step: 0.001, // cm\r\n };\r\n\r\n private _localChange = false;\r\n\r\n constructor(props: IVector3LineComponentProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, value: this.getCurrentValue().clone() };\r\n }\r\n\r\n getCurrentValue() {\r\n return this.props.target[this.props.propertyName];\r\n }\r\n\r\n shouldComponentUpdate(nextProps: IVector3LineComponentProps, nextState: { isExpanded: boolean; value: Vector3 }) {\r\n const nextPropsValue = this.getCurrentValue();\r\n\r\n if (!nextPropsValue.equals(nextState.value) || this._localChange) {\r\n nextState.value = nextPropsValue.clone();\r\n this._localChange = false;\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n switchExpandState() {\r\n this._localChange = true;\r\n this.setState({ isExpanded: !this.state.isExpanded });\r\n }\r\n\r\n raiseOnPropertyChanged(previousValue: Vector3) {\r\n if (this.props.onChange) {\r\n this.props.onChange(this.state.value);\r\n }\r\n\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName,\r\n value: this.state.value,\r\n initialValue: previousValue,\r\n });\r\n }\r\n\r\n updateVector3() {\r\n const store = this.props.target[this.props.propertyName].clone();\r\n this.props.target[this.props.propertyName] = this.state.value;\r\n\r\n this.setState({ value: store });\r\n\r\n this.raiseOnPropertyChanged(store);\r\n }\r\n\r\n updateStateX(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.x = value;\r\n this.updateVector3();\r\n }\r\n\r\n updateStateY(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.y = value;\r\n this.updateVector3();\r\n }\r\n\r\n updateStateZ(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.z = value;\r\n this.updateVector3();\r\n }\r\n\r\n render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className=\"vector3Line\">\r\n <div className=\"firstLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"vector\">\r\n {!this.props.useEuler && `X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}, Z: ${this.state.value.z.toFixed(2)}`}\r\n {this.props.useEuler &&\r\n `X: ${Tools.ToDegrees(this.state.value.x).toFixed(2)}, Y: ${Tools.ToDegrees(this.state.value.y).toFixed(2)}, Z: ${Tools.ToDegrees(\r\n this.state.value.z\r\n ).toFixed(2)}`}\r\n </div>\r\n <div className=\"expand hoverIcon\" onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n </div>\r\n {this.state.isExpanded && !this.props.useEuler && (\r\n <div className=\"secondLine\">\r\n <NumericInputComponent\r\n label=\"x\"\r\n lockObject={this.props.lockObject}\r\n step={this.props.step}\r\n value={this.state.value.x}\r\n onChange={(value) => this.updateStateX(value)}\r\n />\r\n <NumericInputComponent\r\n label=\"y\"\r\n lockObject={this.props.lockObject}\r\n step={this.props.step}\r\n value={this.state.value.y}\r\n onChange={(value) => this.updateStateY(value)}\r\n />\r\n <NumericInputComponent\r\n label=\"z\"\r\n lockObject={this.props.lockObject}\r\n step={this.props.step}\r\n value={this.state.value.z}\r\n onChange={(value) => this.updateStateZ(value)}\r\n />\r\n </div>\r\n )}\r\n {this.state.isExpanded && this.props.useEuler && !this.props.noSlider && (\r\n <div className=\"secondLine\">\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n margin={true}\r\n label=\"x\"\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(this.state.value.x)}\r\n onChange={(value) => this.updateStateX(Tools.ToRadians(value))}\r\n />\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n margin={true}\r\n label=\"y\"\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(this.state.value.y)}\r\n onChange={(value) => this.updateStateY(Tools.ToRadians(value))}\r\n />\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n margin={true}\r\n label=\"z\"\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(this.state.value.z)}\r\n onChange={(value) => this.updateStateZ(Tools.ToRadians(value))}\r\n />\r\n </div>\r\n )}\r\n {this.state.isExpanded && this.props.useEuler && this.props.noSlider && (\r\n <div className=\"secondLine\">\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"x\"\r\n step={this.props.step}\r\n value={Tools.ToDegrees(this.state.value.x)}\r\n onChange={(value) => this.updateStateX(Tools.ToRadians(value))}\r\n />\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"y\"\r\n step={this.props.step}\r\n value={Tools.ToDegrees(this.state.value.y)}\r\n onChange={(value) => this.updateStateY(Tools.ToRadians(value))}\r\n />\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"z\"\r\n step={this.props.step}\r\n value={Tools.ToDegrees(this.state.value.z)}\r\n onChange={(value) => this.updateStateZ(Tools.ToRadians(value))}\r\n />\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}