@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,48 @@
1
+ import * as React from "react";
2
+ import type { Observable } from "@babylonjs/core/Misc/observable.js";
3
+ import type { PropertyChangedEvent } from "../propertyChangedEvent";
4
+ import type { IInspectableOptions } from "@babylonjs/core/Misc/iInspectable.js";
5
+ export declare const Null_Value: number;
6
+ export interface IOptionsLineComponentProps {
7
+ label: string;
8
+ target: any;
9
+ propertyName: string;
10
+ options: IInspectableOptions[];
11
+ addInput?: boolean;
12
+ noDirectUpdate?: boolean;
13
+ onSelect?: (value: number | string) => void;
14
+ extractValue?: (target: any) => number | string;
15
+ addVal?: (newVal: {
16
+ label: string;
17
+ value: number;
18
+ }, prevVal: number) => void;
19
+ onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
20
+ allowNullValue?: boolean;
21
+ icon?: string;
22
+ iconLabel?: string;
23
+ className?: string;
24
+ valuesAreStrings?: boolean;
25
+ defaultIfNull?: number;
26
+ fromFontDropdown?: boolean;
27
+ valueProp?: number;
28
+ fallbackValue?: number;
29
+ }
30
+ export declare class OptionsLineComponent extends React.Component<IOptionsLineComponentProps, {
31
+ value: number | string;
32
+ addCustom: boolean;
33
+ }> {
34
+ private _localChange;
35
+ private _remapValueIn;
36
+ private _remapValueOut;
37
+ private _getValue;
38
+ constructor(props: IOptionsLineComponentProps);
39
+ shouldComponentUpdate(nextProps: IOptionsLineComponentProps, nextState: {
40
+ value: number;
41
+ addCustom: boolean;
42
+ }): boolean;
43
+ raiseOnPropertyChanged(newValue: number, previousValue: number): void;
44
+ setValue(value: string | number): void;
45
+ updateValue(valueString: string): void;
46
+ updateCustomValue(): void;
47
+ render(): JSX.Element;
48
+ }
@@ -0,0 +1,119 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4
+ export const Null_Value = Number.MAX_SAFE_INTEGER;
5
+ const DEFAULT_FALLBACK_VALUE = -1;
6
+ export class OptionsLineComponent extends React.Component {
7
+ constructor(props) {
8
+ // Initialize default props
9
+ super(props);
10
+ this._localChange = false;
11
+ this.state = { value: this._remapValueIn(this._getValue(props)), addCustom: false };
12
+ }
13
+ _remapValueIn(value) {
14
+ return this.props.allowNullValue && value === null ? Null_Value : value;
15
+ }
16
+ _remapValueOut(value) {
17
+ return this.props.allowNullValue && value === Null_Value ? null : value;
18
+ }
19
+ _getValue(props) {
20
+ if (props.extractValue) {
21
+ return props.extractValue(props.target);
22
+ }
23
+ return props.target && props.propertyName ? props.target[props.propertyName] : props.options[props.defaultIfNull || 0];
24
+ }
25
+ shouldComponentUpdate(nextProps, nextState) {
26
+ if (this._localChange) {
27
+ this._localChange = false;
28
+ return true;
29
+ }
30
+ const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(nextProps.target) : nextProps.target[nextProps.propertyName]);
31
+ if (newValue != null && newValue !== nextState.value) {
32
+ nextState.value = newValue;
33
+ return true;
34
+ }
35
+ if (this.props.options !== nextProps.options) {
36
+ return true;
37
+ }
38
+ return false;
39
+ }
40
+ raiseOnPropertyChanged(newValue, previousValue) {
41
+ if (!this.props.onPropertyChangedObservable) {
42
+ return;
43
+ }
44
+ this.props.onPropertyChangedObservable.notifyObservers({
45
+ object: this.props.target,
46
+ property: this.props.propertyName,
47
+ value: newValue,
48
+ initialValue: previousValue,
49
+ allowNullValue: this.props.allowNullValue,
50
+ });
51
+ }
52
+ setValue(value) {
53
+ this.setState({ value: value });
54
+ }
55
+ updateValue(valueString) {
56
+ var _a, _b;
57
+ let value = this.props.valuesAreStrings ? valueString : parseInt(valueString);
58
+ if (isNaN(Number(value))) {
59
+ for (let i = 0; i < this.props.options.length; i++) {
60
+ if (((_a = this.props.options.at(i)) === null || _a === void 0 ? void 0 : _a.label) === valueString) {
61
+ value = Number((_b = this.props.options.at(i)) === null || _b === void 0 ? void 0 : _b.value);
62
+ }
63
+ }
64
+ }
65
+ if (value === 0 && this.props.fromFontDropdown) {
66
+ this.setState({ addCustom: true });
67
+ }
68
+ this._localChange = true;
69
+ const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
70
+ if (!this.props.noDirectUpdate) {
71
+ this.props.target[this.props.propertyName] = this._remapValueOut(value);
72
+ }
73
+ //selecting a regular option from font dropdown
74
+ if (value != 0 && this.props.fromFontDropdown) {
75
+ this.setState({ value: value });
76
+ if (this.props.onSelect) {
77
+ this.props.onSelect(value);
78
+ }
79
+ //selecting 'custom font' from font dropdown
80
+ }
81
+ else if (this.props.fromFontDropdown) {
82
+ if (this.props.onSelect) {
83
+ this.props.onSelect(this.state.value);
84
+ }
85
+ }
86
+ //selecting from a dropdown that's not font dropdown
87
+ else {
88
+ this.setState({ value: value });
89
+ if (this.props.onSelect) {
90
+ this.props.onSelect(value);
91
+ }
92
+ }
93
+ const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
94
+ this.raiseOnPropertyChanged(newValue, store);
95
+ }
96
+ updateCustomValue() {
97
+ this.setState({ addCustom: false });
98
+ }
99
+ render() {
100
+ var _a;
101
+ const fallback = this.props.fallbackValue !== undefined ? this.props.fallbackValue : DEFAULT_FALLBACK_VALUE;
102
+ return (_jsxs("div", { className: `listLine ${(_a = this.props.className) !== null && _a !== void 0 ? _a : ""}`, children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, color: "black", className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsx("div", { className: "options", children: this.state.addCustom ? (_jsx("input", { type: "text", placeholder: "Enter a custom font here", onKeyDown: (event) => {
103
+ event.key === "Enter" && this.props.addVal != undefined
104
+ ? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
105
+ this.updateCustomValue(),
106
+ this.forceUpdate())
107
+ : null;
108
+ }, onBlur: (event) => {
109
+ this.props.addVal != undefined
110
+ ? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
111
+ this.updateCustomValue(),
112
+ this.forceUpdate())
113
+ : null;
114
+ } })) : (_jsx("select", { onChange: (evt) => this.updateValue(evt.target.value), value: this.state.value === null || this.state.value === undefined ? fallback : this.state.value, children: this.props.options.map((option, i) => {
115
+ return (_jsx("option", { selected: option.selected, value: option.value, title: option.label, children: option.label }, option.label + i));
116
+ }) })) })] }));
117
+ }
118
+ }
119
+ //# sourceMappingURL=optionsLineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optionsLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/optionsLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAElD,MAAM,sBAAsB,GAAG,CAAC,CAAC,CAAC;AAyBlC,MAAM,OAAO,oBAAqB,SAAQ,KAAK,CAAC,SAAqF;IAiBjI,YAAY,KAAiC;QACzC,2BAA2B;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAC;QAlBT,iBAAY,GAAG,KAAK,CAAC;QAoBzB,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACxF,CAAC;IApBO,aAAa,CAAC,KAAoB;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAM,CAAC;IAC7E,CAAC;IAEO,cAAc,CAAC,KAAa;QAChC,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,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B,MAAM,CAAC,KAAK,GAAG,CAAC,CAE/C,CACZ,CAAC;wBACN,CAAC,CAAC,GACG,CACZ,GACC,IACJ,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 { IInspectableOptions } from \"core/Misc/iInspectable\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const Null_Value = Number.MAX_SAFE_INTEGER;\r\n\r\nconst DEFAULT_FALLBACK_VALUE = -1;\r\n\r\nexport interface IOptionsLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n options: IInspectableOptions[];\r\n addInput?: boolean;\r\n noDirectUpdate?: boolean;\r\n onSelect?: (value: number | string) => void;\r\n extractValue?: (target: any) => number | string;\r\n addVal?: (newVal: { label: string; value: number }, prevVal: number) => void;\r\n\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n allowNullValue?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n className?: string;\r\n valuesAreStrings?: boolean;\r\n defaultIfNull?: number;\r\n fromFontDropdown?: boolean;\r\n valueProp?: number;\r\n fallbackValue?: number;\r\n}\r\n\r\nexport class OptionsLineComponent extends React.Component<IOptionsLineComponentProps, { value: number | string; addCustom: boolean }> {\r\n private _localChange = false;\r\n private _remapValueIn(value: number | null): number {\r\n return this.props.allowNullValue && value === null ? Null_Value : value!;\r\n }\r\n\r\n private _remapValueOut(value: number): number | null {\r\n return this.props.allowNullValue && value === Null_Value ? null : value;\r\n }\r\n\r\n private _getValue(props: IOptionsLineComponentProps) {\r\n if (props.extractValue) {\r\n return props.extractValue(props.target);\r\n }\r\n return props.target && props.propertyName ? props.target[props.propertyName] : props.options[props.defaultIfNull || 0];\r\n }\r\n\r\n constructor(props: IOptionsLineComponentProps) {\r\n // Initialize default props\r\n super(props);\r\n\r\n this.state = { value: this._remapValueIn(this._getValue(props)), addCustom: false };\r\n }\r\n\r\n shouldComponentUpdate(nextProps: IOptionsLineComponentProps, nextState: { value: number; addCustom: boolean }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n\r\n return true;\r\n }\r\n\r\n const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(nextProps.target) : nextProps.target[nextProps.propertyName]);\r\n\r\n if (newValue != null && newValue !== nextState.value) {\r\n nextState.value = newValue;\r\n\r\n return true;\r\n }\r\n\r\n if (this.props.options !== nextProps.options) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n raiseOnPropertyChanged(newValue: number, previousValue: number) {\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 allowNullValue: this.props.allowNullValue,\r\n });\r\n }\r\n\r\n setValue(value: string | number) {\r\n this.setState({ value: value });\r\n }\r\n\r\n updateValue(valueString: string) {\r\n let value = this.props.valuesAreStrings ? valueString : parseInt(valueString);\r\n\r\n if (isNaN(Number(value))) {\r\n for (let i = 0; i < this.props.options.length; i++) {\r\n if (this.props.options.at(i)?.label === valueString) {\r\n value = Number(this.props.options.at(i)?.value);\r\n }\r\n }\r\n }\r\n\r\n if (value === 0 && this.props.fromFontDropdown) {\r\n this.setState({ addCustom: true });\r\n }\r\n\r\n this._localChange = true;\r\n\r\n const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n\r\n if (!this.props.noDirectUpdate) {\r\n this.props.target[this.props.propertyName] = this._remapValueOut(value as number);\r\n }\r\n\r\n //selecting a regular option from font dropdown\r\n if (value != 0 && this.props.fromFontDropdown) {\r\n this.setState({ value: value });\r\n if (this.props.onSelect) {\r\n this.props.onSelect(value);\r\n }\r\n //selecting 'custom font' from font dropdown\r\n } else if (this.props.fromFontDropdown) {\r\n if (this.props.onSelect) {\r\n this.props.onSelect(this.state.value);\r\n }\r\n }\r\n //selecting from a dropdown that's not font dropdown\r\n else {\r\n this.setState({ value: value });\r\n if (this.props.onSelect) {\r\n this.props.onSelect(value);\r\n }\r\n }\r\n\r\n const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n\r\n this.raiseOnPropertyChanged(newValue, store);\r\n }\r\n\r\n updateCustomValue() {\r\n this.setState({ addCustom: false });\r\n }\r\n\r\n render() {\r\n const fallback = this.props.fallbackValue !== undefined ? this.props.fallbackValue : DEFAULT_FALLBACK_VALUE;\r\n return (\r\n <div className={`listLine ${this.props.className ?? \"\"}`}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} color=\"black\" className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"options\">\r\n {this.state.addCustom ? (\r\n <input\r\n type=\"text\"\r\n placeholder=\"Enter a custom font here\"\r\n onKeyDown={(event) => {\r\n event.key === \"Enter\" && this.props.addVal != undefined\r\n ? (this.props.addVal({ label: (event.target as HTMLInputElement).value, value: this.props.options.length + 1 }, Number(this.state.value)),\r\n this.updateCustomValue(),\r\n this.forceUpdate())\r\n : null;\r\n }}\r\n onBlur={(event) => {\r\n this.props.addVal != undefined\r\n ? (this.props.addVal({ label: (event.target as HTMLInputElement).value, value: this.props.options.length + 1 }, Number(this.state.value)),\r\n this.updateCustomValue(),\r\n this.forceUpdate())\r\n : null;\r\n }}\r\n />\r\n ) : (\r\n <select\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n value={this.state.value === null || this.state.value === undefined ? fallback : this.state.value}\r\n >\r\n {this.props.options.map((option, i) => {\r\n return (\r\n <option selected={option.selected} key={option.label + i} value={option.value} title={option.label}>\r\n {option.label}\r\n </option>\r\n );\r\n })}\r\n </select>\r\n )}\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -0,0 +1,4 @@
1
+ export declare class Popup {
2
+ static CreatePopup(title: string, windowVariableName: string, width?: number, height?: number): HTMLDivElement | null;
3
+ private static _CopyStyles;
4
+ }
package/lines/popup.js ADDED
@@ -0,0 +1,68 @@
1
+ export class Popup {
2
+ static CreatePopup(title, windowVariableName, width = 300, height = 800) {
3
+ const windowCreationOptionsList = {
4
+ width: width,
5
+ height: height,
6
+ top: (window.innerHeight - width) / 2 + window.screenY,
7
+ left: (window.innerWidth - height) / 2 + window.screenX,
8
+ };
9
+ const windowCreationOptions = Object.keys(windowCreationOptionsList)
10
+ .map((key) => key + "=" + windowCreationOptionsList[key])
11
+ .join(",");
12
+ const popupWindow = window.open("", title, windowCreationOptions);
13
+ if (!popupWindow) {
14
+ return null;
15
+ }
16
+ const parentDocument = popupWindow.document;
17
+ // Font
18
+ const newLinkEl = parentDocument.createElement("link");
19
+ newLinkEl.rel = "stylesheet";
20
+ newLinkEl.href = "https://use.typekit.net/cta4xsb.css";
21
+ parentDocument.head.appendChild(newLinkEl);
22
+ parentDocument.title = title;
23
+ parentDocument.body.style.width = "100%";
24
+ parentDocument.body.style.height = "100%";
25
+ parentDocument.body.style.margin = "0";
26
+ parentDocument.body.style.padding = "0";
27
+ const parentControl = parentDocument.createElement("div");
28
+ parentControl.style.width = "100%";
29
+ parentControl.style.height = "100%";
30
+ parentControl.style.margin = "0";
31
+ parentControl.style.padding = "0";
32
+ popupWindow.document.body.appendChild(parentControl);
33
+ this._CopyStyles(window.document, parentDocument);
34
+ setTimeout(() => {
35
+ // need this for late bindings
36
+ this._CopyStyles(window.document, parentDocument);
37
+ }, 0);
38
+ this[windowVariableName] = popupWindow;
39
+ return parentControl;
40
+ }
41
+ static _CopyStyles(sourceDoc, targetDoc) {
42
+ for (let index = 0; index < sourceDoc.styleSheets.length; index++) {
43
+ const styleSheet = sourceDoc.styleSheets[index];
44
+ try {
45
+ if (styleSheet.cssRules) {
46
+ // for <style> elements
47
+ const newStyleEl = sourceDoc.createElement("style");
48
+ for (const cssRule of styleSheet.cssRules) {
49
+ // write the text of each rule into the body of the style element
50
+ newStyleEl.appendChild(sourceDoc.createTextNode(cssRule.cssText));
51
+ }
52
+ targetDoc.head.appendChild(newStyleEl);
53
+ }
54
+ else if (styleSheet.href) {
55
+ // for <link> elements loading CSS from a URL
56
+ const newLinkEl = sourceDoc.createElement("link");
57
+ newLinkEl.rel = "stylesheet";
58
+ newLinkEl.href = styleSheet.href;
59
+ targetDoc.head.appendChild(newLinkEl);
60
+ }
61
+ }
62
+ catch (e) {
63
+ console.log(e);
64
+ }
65
+ }
66
+ }
67
+ }
68
+ //# sourceMappingURL=popup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popup.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/popup.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,KAAK;IACP,MAAM,CAAC,WAAW,CAAC,KAAa,EAAE,kBAA0B,EAAE,KAAK,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG;QAC1F,MAAM,yBAAyB,GAAG;YAC9B,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO;YACtD,IAAI,EAAE,CAAC,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO;SAC1D,CAAC;QAEF,MAAM,qBAAqB,GAAG,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC;aAC/D,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,GAAI,yBAAiC,CAAC,GAAG,CAAC,CAAC;aACjE,IAAI,CAAC,GAAG,CAAC,CAAC;QAEf,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC;QAClE,IAAI,CAAC,WAAW,EAAE;YACd,OAAO,I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CAAC;QAEhD,OAAO,aAAa,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,WAAW,CAAC,SAAuB,EAAE,SAAuB;QACvE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YAC/D,MAAM,UAAU,GAAQ,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACrD,IAAI;gBACA,IAAI,UAAU,CAAC,QAAQ,EAAE;oBACrB,uBAAuB;oBACvB,MAAM,UAAU,GAAG,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;oBAEpD,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE;wBACvC,iEAAiE;wBACjE,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;qBACrE;oBAED,SAAS,CAAC,IAAK,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;iBAC3C;qBAAM,IAAI,UAAU,CAAC,IAAI,EAAE;oBACxB,6CAA6C;oBAC7C,MAAM,SAAS,GAAG,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;oBAElD,SAAS,CAAC,GAAG,GAAG,YAAY,CAAC;oBAC7B,SAAS,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;oBACjC,SAAS,CAAC,IAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;iBAC1C;aACJ;YAAC,OAAO,CAAC,EAAE;gBACR,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aAClB;SACJ;IACL,CAAC;CACJ","sourcesContent":["export class Popup {\r\n public static CreatePopup(title: string, windowVariableName: string, width = 300, height = 800) {\r\n const windowCreationOptionsList = {\r\n width: width,\r\n height: height,\r\n top: (window.innerHeight - width) / 2 + window.screenY,\r\n left: (window.innerWidth - height) / 2 + window.screenX,\r\n };\r\n\r\n const windowCreationOptions = Object.keys(windowCreationOptionsList)\r\n .map((key) => key + \"=\" + (windowCreationOptionsList as any)[key])\r\n .join(\",\");\r\n\r\n const popupWindow = window.open(\"\", title, windowCreationOptions);\r\n if (!popupWindow) {\r\n return null;\r\n }\r\n\r\n const parentDocument = popupWindow.document;\r\n\r\n // Font\r\n const newLinkEl = parentDocument.createElement(\"link\");\r\n\r\n newLinkEl.rel = \"stylesheet\";\r\n newLinkEl.href = \"https://use.typekit.net/cta4xsb.css\";\r\n parentDocument.head!.appendChild(newLinkEl);\r\n\r\n parentDocument.title = title;\r\n parentDocument.body.style.width = \"100%\";\r\n parentDocument.body.style.height = \"100%\";\r\n parentDocument.body.style.margin = \"0\";\r\n parentDocument.body.style.padding = \"0\";\r\n\r\n const parentControl = parentDocument.createElement(\"div\");\r\n parentControl.style.width = \"100%\";\r\n parentControl.style.height = \"100%\";\r\n parentControl.style.margin = \"0\";\r\n parentControl.style.padding = \"0\";\r\n\r\n popupWindow.document.body.appendChild(parentControl);\r\n this._CopyStyles(window.document, parentDocument);\r\n setTimeout(() => {\r\n // need this for late bindings\r\n this._CopyStyles(window.document, parentDocument);\r\n }, 0);\r\n\r\n (this as any)[windowVariableName] = popupWindow;\r\n\r\n return parentControl;\r\n }\r\n\r\n private static _CopyStyles(sourceDoc: HTMLDocument, targetDoc: HTMLDocument) {\r\n for (let index = 0; index < sourceDoc.styleSheets.length; index++) {\r\n const styleSheet: any = sourceDoc.styleSheets[index];\r\n try {\r\n if (styleSheet.cssRules) {\r\n // for <style> elements\r\n const newStyleEl = sourceDoc.createElement(\"style\");\r\n\r\n for (const cssRule of styleSheet.cssRules) {\r\n // write the text of each rule into the body of the style element\r\n newStyleEl.appendChild(sourceDoc.createTextNode(cssRule.cssText));\r\n }\r\n\r\n targetDoc.head!.appendChild(newStyleEl);\r\n } else if (styleSheet.href) {\r\n // for <link> elements loading CSS from a URL\r\n const newLinkEl = sourceDoc.createElement(\"link\");\r\n\r\n newLinkEl.rel = \"stylesheet\";\r\n newLinkEl.href = styleSheet.href;\r\n targetDoc.head!.appendChild(newLinkEl);\r\n }\r\n } catch (e) {\r\n console.log(e);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+ import type { Observable } from "@babylonjs/core/Misc/observable.js";
3
+ interface IRadioButtonLineComponentProps {
4
+ onSelectionChangedObservable: Observable<RadioButtonLineComponent>;
5
+ label: string;
6
+ isSelected: () => boolean;
7
+ onSelect: () => void;
8
+ icon?: string;
9
+ iconLabel?: string;
10
+ }
11
+ export declare class RadioButtonLineComponent extends React.Component<IRadioButtonLineComponentProps, {
12
+ isSelected: boolean;
13
+ }> {
14
+ private _onSelectionChangedObserver;
15
+ constructor(props: IRadioButtonLineComponentProps);
16
+ componentDidMount(): void;
17
+ componentWillUnmount(): void;
18
+ onChange(): void;
19
+ render(): JSX.Element;
20
+ }
21
+ export {};
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ export class RadioButtonLineComponent extends React.Component {
4
+ constructor(props) {
5
+ super(props);
6
+ this.state = { isSelected: this.props.isSelected() };
7
+ }
8
+ componentDidMount() {
9
+ this._onSelectionChangedObserver = this.props.onSelectionChangedObservable.add((value) => {
10
+ this.setState({ isSelected: value === this });
11
+ });
12
+ }
13
+ componentWillUnmount() {
14
+ if (this._onSelectionChangedObserver) {
15
+ this.props.onSelectionChangedObservable.remove(this._onSelectionChangedObserver);
16
+ this._onSelectionChangedObserver = null;
17
+ }
18
+ }
19
+ onChange() {
20
+ this.props.onSelect();
21
+ this.props.onSelectionChangedObservable.notifyObservers(this);
22
+ }
23
+ render() {
24
+ return (_jsxs("div", { className: "radioLine", 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: "radioContainer", children: [_jsx("input", { id: this.props.label, className: "radio", type: "radio", checked: this.state.isSelected, onChange: () => this.onChange() }), _jsx("label", { htmlFor: this.props.label, className: "labelForRadio" })] })] }));
25
+ }
26
+ }
27
+ //# sourceMappingURL=radioLineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radioLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/radioLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,MAAM,OAAO,wBAAyB,SAAQ,KAAK,CAAC,SAAkE;IAGlH,YAAY,KAAqC;QAC7C,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC;IACzD,CAAC;IAED,iBAAiB;QACb,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACrF,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,KAAK,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACP,CAAC;IAED,oBAAoB;QAChB,IAAI,IAAI,CAAC,2BAA2B,EAAE;YAClC,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YACjF,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC;SAC3C;IACL,CAAC;IAED,QAAQ;QACJ,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAED,MAAM;QACF,OAAO,CACH,eAAK,SAAS,EAAC,WAAW,aACrB,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,eAAK,SAAS,EAAC,gBAAgB,aAC3B,gBAAO,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAC,OAAO,EAAC,IAAI,EAAC,OAAO,EAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAI,EAC/H,gBAAO,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAC,eAAe,GAAG,IAC5D,IACJ,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observer, Observable } from \"core/Misc/observable\";\r\n\r\ninterface IRadioButtonLineComponentProps {\r\n onSelectionChangedObservable: Observable<RadioButtonLineComponent>;\r\n label: string;\r\n isSelected: () => boolean;\r\n onSelect: () => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n}\r\n\r\nexport class RadioButtonLineComponent extends React.Component<IRadioButtonLineComponentProps, { isSelected: boolean }> {\r\n private _onSelectionChangedObserver: Nullable<Observer<RadioButtonLineComponent>>;\r\n\r\n constructor(props: IRadioButtonLineComponentProps) {\r\n super(props);\r\n\r\n this.state = { isSelected: this.props.isSelected() };\r\n }\r\n\r\n componentDidMount() {\r\n this._onSelectionChangedObserver = this.props.onSelectionChangedObservable.add((value) => {\r\n this.setState({ isSelected: value === this });\r\n });\r\n }\r\n\r\n componentWillUnmount() {\r\n if (this._onSelectionChangedObserver) {\r\n this.props.onSelectionChangedObservable.remove(this._onSelectionChangedObserver);\r\n this._onSelectionChangedObserver = null;\r\n }\r\n }\r\n\r\n onChange() {\r\n this.props.onSelect();\r\n this.props.onSelectionChangedObservable.notifyObservers(this);\r\n }\r\n\r\n render() {\r\n return (\r\n <div className=\"radioLine\">\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=\"radioContainer\">\r\n <input id={this.props.label} className=\"radio\" type=\"radio\" checked={this.state.isSelected} onChange={() => this.onChange()} />\r\n <label htmlFor={this.props.label} className=\"labelForRadio\" />\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -0,0 +1,37 @@
1
+ import * as React from "react";
2
+ import type { Observable } from "@babylonjs/core/Misc/observable.js";
3
+ import type { PropertyChangedEvent } from "../propertyChangedEvent";
4
+ import type { LockObject } from "../tabs/propertyGrids/lockObject";
5
+ interface ISliderLineComponentProps {
6
+ label: string;
7
+ target?: any;
8
+ propertyName?: string;
9
+ minimum: number;
10
+ maximum: number;
11
+ step: number;
12
+ directValue?: number;
13
+ useEuler?: boolean;
14
+ onChange?: (value: number) => void;
15
+ onInput?: (value: number) => void;
16
+ onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
17
+ decimalCount?: number;
18
+ margin?: boolean;
19
+ icon?: string;
20
+ iconLabel?: string;
21
+ lockObject: LockObject;
22
+ unit?: React.ReactNode;
23
+ }
24
+ export declare class SliderLineComponent extends React.Component<ISliderLineComponentProps, {
25
+ value: number;
26
+ }> {
27
+ private _localChange;
28
+ constructor(props: ISliderLineComponentProps);
29
+ shouldComponentUpdate(nextProps: ISliderLineComponentProps, nextState: {
30
+ value: number;
31
+ }): boolean;
32
+ onChange(newValueString: any): void;
33
+ onInput(newValueString: any): void;
34
+ prepareDataToRead(value: number): number;
35
+ render(): JSX.Element;
36
+ }
37
+ export {};
@@ -0,0 +1,90 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Tools } from "@babylonjs/core/Misc/tools.js";
4
+ import { FloatLineComponent } from "./floatLineComponent.js";
5
+ export class SliderLineComponent extends React.Component {
6
+ constructor(props) {
7
+ super(props);
8
+ this._localChange = false;
9
+ if (this.props.directValue !== undefined) {
10
+ this.state = {
11
+ value: this.props.directValue,
12
+ };
13
+ }
14
+ else {
15
+ let value = this.props.target[this.props.propertyName];
16
+ if (value === undefined) {
17
+ value = this.props.maximum;
18
+ }
19
+ this.state = { value: value };
20
+ }
21
+ }
22
+ shouldComponentUpdate(nextProps, nextState) {
23
+ if (nextProps.directValue !== undefined) {
24
+ nextState.value = nextProps.directValue;
25
+ return true;
26
+ }
27
+ let currentState = nextProps.target[nextProps.propertyName];
28
+ if (currentState === undefined) {
29
+ currentState = nextProps.maximum;
30
+ }
31
+ if (currentState !== nextState.value || this._localChange || nextProps.maximum !== this.props.maximum || nextProps.minimum !== this.props.minimum) {
32
+ nextState.value = currentState;
33
+ this._localChange = false;
34
+ return true;
35
+ }
36
+ if (nextProps.unit !== this.props.unit) {
37
+ return true;
38
+ }
39
+ return false;
40
+ }
41
+ onChange(newValueString) {
42
+ if (newValueString === "—")
43
+ return;
44
+ this._localChange = true;
45
+ let newValue = parseFloat(newValueString);
46
+ if (this.props.useEuler) {
47
+ newValue = Tools.ToRadians(newValue);
48
+ }
49
+ if (this.props.target) {
50
+ if (this.props.onPropertyChangedObservable) {
51
+ this.props.onPropertyChangedObservable.notifyObservers({
52
+ object: this.props.target,
53
+ property: this.props.propertyName,
54
+ value: newValue,
55
+ initialValue: this.state.value,
56
+ });
57
+ }
58
+ this.props.target[this.props.propertyName] = newValue;
59
+ }
60
+ if (this.props.onChange) {
61
+ this.props.onChange(newValue);
62
+ }
63
+ this.setState({ value: newValue });
64
+ }
65
+ onInput(newValueString) {
66
+ const newValue = parseFloat(newValueString);
67
+ if (this.props.onInput) {
68
+ this.props.onInput(newValue);
69
+ }
70
+ }
71
+ prepareDataToRead(value) {
72
+ if (value === null) {
73
+ value = 0;
74
+ }
75
+ if (this.props.useEuler) {
76
+ return Tools.ToDegrees(value);
77
+ }
78
+ return value;
79
+ }
80
+ render() {
81
+ return (_jsxs("div", { className: "sliderLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), (!this.props.icon || this.props.label != "") && (_jsx("div", { className: this.props.margin ? "label withMargins" : "label", title: this.props.label, children: this.props.label })), _jsx(FloatLineComponent, { lockObject: this.props.lockObject, isInteger: this.props.decimalCount === 0, smallUI: true, label: "", target: this.state, digits: this.props.decimalCount === undefined ? 4 : this.props.decimalCount, propertyName: "value", min: this.props.minimum, max: this.props.maximum, onEnter: () => {
82
+ const changed = this.prepareDataToRead(this.state.value);
83
+ this.onChange(changed);
84
+ }, onChange: () => {
85
+ const changed = this.prepareDataToRead(this.state.value);
86
+ this.onChange(changed);
87
+ }, onPropertyChangedObservable: this.props.onPropertyChangedObservable, unit: this.props.unit }), _jsx("div", { className: "slider", children: _jsx("input", { className: "range", type: "range", step: this.props.step, min: this.prepareDataToRead(this.props.minimum), max: this.prepareDataToRead(this.props.maximum), value: this.prepareDataToRead(this.state.value), onInput: (evt) => this.onInput(evt.target.value), onChange: (evt) => this.onChange(evt.target.value) }) })] }));
88
+ }
89
+ }
90
+ //# sourceMappingURL=sliderLineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sliderLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/sliderLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,KAAK,EAAE,sCAAwB;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAuB1D,MAAM,OAAO,mBAAoB,SAAQ,KAAK,CAAC,SAAuD;IAElG,YAA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,IAAI,CAAC,KAAK,CAAC,OAAO,EACvB,OAAO,EAAE,GAAG,EAAE;wBACV,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;wBACzD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;oBAC3B,CAAC,EACD,QAAQ,EAAE,GAAG,EAAE;wBACX,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;wBACzD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;oBAC3B,CAAC,EACD,2BAA2B,EAAE,IAAI,CAAC,KAAK,CAAC,2BAA2B,EACnE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GACvB,EACF,cAAK,SAAS,EAAC,QAAQ,YACnB,gBACI,SAAS,EAAC,OAAO,EACjB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAC/C,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAC/C,KAAK,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAC/C,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAE,GAAG,CAAC,MAA2B,CAAC,KAAK,CAAC,EACtE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GACpD,GACA,IACJ,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 { Tools } from \"core/Misc/tools\";\r\nimport { FloatLineComponent } from \"./floatLineComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\ninterface ISliderLineComponentProps {\r\n label: string;\r\n target?: any;\r\n propertyName?: string;\r\n minimum: number;\r\n maximum: number;\r\n step: number;\r\n directValue?: number;\r\n useEuler?: boolean;\r\n onChange?: (value: number) => void;\r\n onInput?: (value: number) => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n decimalCount?: number;\r\n margin?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n lockObject: LockObject;\r\n unit?: React.ReactNode;\r\n}\r\n\r\nexport class SliderLineComponent extends React.Component<ISliderLineComponentProps, { value: number }> {\r\n private _localChange = false;\r\n constructor(props: ISliderLineComponentProps) {\r\n super(props);\r\n\r\n if (this.props.directValue !== undefined) {\r\n this.state = {\r\n value: this.props.directValue,\r\n };\r\n } else {\r\n let value = this.props.target![this.props.propertyName!];\r\n\r\n if (value === undefined) {\r\n value = this.props.maximum;\r\n }\r\n this.state = { value: value };\r\n }\r\n }\r\n\r\n shouldComponentUpdate(nextProps: ISliderLineComponentProps, nextState: { value: number }) {\r\n if (nextProps.directValue !== undefined) {\r\n nextState.value = nextProps.directValue;\r\n return true;\r\n }\r\n\r\n let currentState = nextProps.target![nextProps.propertyName!];\r\n if (currentState === undefined) {\r\n currentState = nextProps.maximum;\r\n }\r\n\r\n if (currentState !== nextState.value || this._localChange || nextProps.maximum !== this.props.maximum || nextProps.minimum !== this.props.minimum) {\r\n nextState.value = currentState;\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.unit !== this.props.unit) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n onChange(newValueString: any) {\r\n if (newValueString === \"—\") return;\r\n this._localChange = true;\r\n let newValue = parseFloat(newValueString);\r\n\r\n if (this.props.useEuler) {\r\n newValue = Tools.ToRadians(newValue);\r\n }\r\n\r\n if (this.props.target) {\r\n if (this.props.onPropertyChangedObservable) {\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: this.state.value,\r\n });\r\n }\r\n\r\n this.props.target[this.props.propertyName!] = newValue;\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange(newValue);\r\n }\r\n\r\n this.setState({ value: newValue });\r\n }\r\n\r\n onInput(newValueString: any) {\r\n const newValue = parseFloat(newValueString);\r\n if (this.props.onInput) {\r\n this.props.onInput(newValue);\r\n }\r\n }\r\n\r\n prepareDataToRead(value: number) {\r\n if (value === null) {\r\n value = 0;\r\n }\r\n\r\n if (this.props.useEuler) {\r\n return Tools.ToDegrees(value);\r\n }\r\n\r\n return value;\r\n }\r\n\r\n render() {\r\n return (\r\n <div className=\"sliderLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {(!this.props.icon || this.props.label != \"\") && (\r\n <div className={this.props.margin ? \"label withMargins\" : \"label\"} title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n <FloatLineComponent\r\n lockObject={this.props.lockObject}\r\n isInteger={this.props.decimalCount === 0}\r\n smallUI={true}\r\n label=\"\"\r\n target={this.state}\r\n digits={this.props.decimalCount === undefined ? 4 : this.props.decimalCount}\r\n propertyName=\"value\"\r\n min={this.props.minimum}\r\n max={this.props.maximum}\r\n onEnter={() => {\r\n const changed = this.prepareDataToRead(this.state.value);\r\n this.onChange(changed);\r\n }}\r\n onChange={() => {\r\n const changed = this.prepareDataToRead(this.state.value);\r\n this.onChange(changed);\r\n }}\r\n onPropertyChangedObservable={this.props.onPropertyChangedObservable}\r\n unit={this.props.unit}\r\n />\r\n <div className=\"slider\">\r\n <input\r\n className=\"range\"\r\n type=\"range\"\r\n step={this.props.step}\r\n min={this.prepareDataToRead(this.props.minimum)}\r\n max={this.prepareDataToRead(this.props.maximum)}\r\n value={this.prepareDataToRead(this.state.value)}\r\n onInput={(evt) => this.onInput((evt.target as HTMLInputElement).value)}\r\n onChange={(evt) => this.onChange(evt.target.value)}\r\n />\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -0,0 +1,11 @@
1
+ import type { PropertyChangedEvent } from "../propertyChangedEvent";
2
+ import type { Observable } from "@babylonjs/core/Misc/observable.js";
3
+ export declare const conflictingValuesPlaceholder = "\u2014";
4
+ /**
5
+ *
6
+ * @param targets a list of selected targets
7
+ * @param onPropertyChangedObservable
8
+ * @param getProperty
9
+ * @returns a proxy object that can be passed as a target into the input
10
+ */
11
+ export declare function makeTargetsProxy<Type>(targets: Type[], onPropertyChangedObservable?: Observable<PropertyChangedEvent>, getProperty?: (target: Type, property: keyof Type) => any): any;
@@ -0,0 +1,43 @@
1
+ export const conflictingValuesPlaceholder = "—";
2
+ /**
3
+ *
4
+ * @param targets a list of selected targets
5
+ * @param onPropertyChangedObservable
6
+ * @param getProperty
7
+ * @returns a proxy object that can be passed as a target into the input
8
+ */
9
+ export function makeTargetsProxy(targets, onPropertyChangedObservable, getProperty = (target, property) => target[property]) {
10
+ return new Proxy({}, {
11
+ get(_, name) {
12
+ const property = name;
13
+ if (targets.length === 0)
14
+ return conflictingValuesPlaceholder;
15
+ const firstValue = getProperty(targets[0], property);
16
+ for (const target of targets) {
17
+ if (getProperty(target, property) !== firstValue) {
18
+ return conflictingValuesPlaceholder;
19
+ }
20
+ }
21
+ return firstValue;
22
+ },
23
+ set(_, name, value) {
24
+ if (value === "—")
25
+ return true;
26
+ const property = name;
27
+ for (const target of targets) {
28
+ const initialValue = target[property];
29
+ target[property] = value;
30
+ if (onPropertyChangedObservable) {
31
+ onPropertyChangedObservable.notifyObservers({
32
+ object: target,
33
+ property: name,
34
+ value: target[property],
35
+ initialValue,
36
+ });
37
+ }
38
+ }
39
+ return true;
40
+ },
41
+ });
42
+ }
43
+ //# sourceMappingURL=targetsProxy.js.map
@@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AAY;qBACf,CAAC,CAAC;iBACN;aACJ;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;KACJ,CACG,CAAC;AACb,CAAC","sourcesContent":["import type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\n\r\nexport const conflictingValuesPlaceholder = \"—\";\r\n\r\n/**\r\n *\r\n * @param targets a list of selected targets\r\n * @param onPropertyChangedObservable\r\n * @param getProperty\r\n * @returns a proxy object that can be passed as a target into the input\r\n */\r\nexport function makeTargetsProxy<Type>(\r\n targets: Type[],\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>,\r\n getProperty: (target: Type, property: keyof Type) => any = (target, property) => target[property]\r\n) {\r\n return new Proxy(\r\n {},\r\n {\r\n get(_, name) {\r\n const property = name as keyof Type;\r\n if (targets.length === 0) return conflictingValuesPlaceholder;\r\n const firstValue = getProperty(targets[0], property);\r\n for (const target of targets) {\r\n if (getProperty(target, property) !== firstValue) {\r\n return conflictingValuesPlaceholder;\r\n }\r\n }\r\n return firstValue;\r\n },\r\n set(_, name, value) {\r\n if (value === \"—\") return true;\r\n const property = name as keyof Type;\r\n for (const target of targets) {\r\n const initialValue = target[property];\r\n target[property] = value;\r\n if (onPropertyChangedObservable) {\r\n onPropertyChangedObservable.notifyObservers({\r\n object: target,\r\n property: name as string,\r\n value: target[property],\r\n initialValue,\r\n });\r\n }\r\n }\r\n return true;\r\n },\r\n }\r\n ) as any;\r\n}\r\n"]}
@@ -0,0 +1,47 @@
1
+ import * as React from "react";
2
+ import type { Observable } from "@babylonjs/core/Misc/observable.js";
3
+ import type { PropertyChangedEvent } from "../propertyChangedEvent";
4
+ import type { LockObject } from "../tabs/propertyGrids/lockObject";
5
+ export interface ITextInputLineComponentProps {
6
+ label?: string;
7
+ lockObject?: LockObject;
8
+ target?: any;
9
+ propertyName?: string;
10
+ value?: string;
11
+ onChange?: (value: string) => void;
12
+ onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
13
+ icon?: string;
14
+ iconLabel?: string;
15
+ noUnderline?: boolean;
16
+ numbersOnly?: boolean;
17
+ delayInput?: boolean;
18
+ arrows?: boolean;
19
+ arrowsIncrement?: (amount: number) => void;
20
+ step?: number;
21
+ numeric?: boolean;
22
+ roundValues?: boolean;
23
+ min?: number;
24
+ max?: number;
25
+ placeholder?: string;
26
+ unit?: React.ReactNode;
27
+ validator?: (value: string) => boolean;
28
+ multilines?: boolean;
29
+ }
30
+ export declare class TextInputLineComponent extends React.Component<ITextInputLineComponentProps, {
31
+ value: string;
32
+ dragging: boolean;
33
+ }> {
34
+ private _localChange;
35
+ constructor(props: ITextInputLineComponentProps);
36
+ componentWillUnmount(): void;
37
+ shouldComponentUpdate(nextProps: ITextInputLineComponentProps, nextState: {
38
+ value: string;
39
+ dragging: boolean;
40
+ }): boolean;
41
+ raiseOnPropertyChanged(newValue: string, previousValue: string): void;
42
+ getCurrentNumericValue(value: string): number;
43
+ updateValue(value: string, valueToValidate?: string): void;
44
+ incrementValue(amount: number): void;
45
+ onKeyDown(event: React.KeyboardEvent): void;
46
+ render(): JSX.Element;
47
+ }