@babylonjs/shared-ui-components 5.28.0 → 5.29.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 (246) hide show
  1. package/colorPicker/colorComponentEntry.d.ts +18 -18
  2. package/colorPicker/colorComponentEntry.js +36 -36
  3. package/colorPicker/colorPicker.d.ts +43 -43
  4. package/colorPicker/colorPicker.js +136 -136
  5. package/colorPicker/hexColor.d.ts +20 -20
  6. package/colorPicker/hexColor.js +42 -42
  7. package/components/Button.d.ts +10 -10
  8. package/components/Button.js +6 -6
  9. package/components/Icon.d.ts +6 -6
  10. package/components/Icon.js +6 -6
  11. package/components/Label.d.ts +7 -7
  12. package/components/Label.js +6 -6
  13. package/components/MessageDialog.d.ts +7 -7
  14. package/components/MessageDialog.js +22 -22
  15. package/components/Toggle.d.ts +8 -8
  16. package/components/Toggle.js +15 -15
  17. package/components/bars/CommandBarComponent.d.ts +16 -16
  18. package/components/bars/CommandBarComponent.js +68 -68
  19. package/components/bars/CommandButtonComponent.d.ts +11 -11
  20. package/components/bars/CommandButtonComponent.js +6 -6
  21. package/components/bars/CommandDropdownComponent.d.ts +26 -26
  22. package/components/bars/CommandDropdownComponent.js +48 -48
  23. package/components/classNames.d.ts +2 -2
  24. package/components/classNames.js +18 -18
  25. package/components/colorPicker/ColorComponentEntry.d.ts +18 -18
  26. package/components/colorPicker/ColorComponentEntry.js +37 -37
  27. package/components/colorPicker/ColorPicker.d.ts +43 -43
  28. package/components/colorPicker/ColorPicker.js +137 -137
  29. package/components/colorPicker/HexColor.d.ts +20 -20
  30. package/components/colorPicker/HexColor.js +45 -45
  31. package/components/layout/DraggableIcon.d.ts +23 -0
  32. package/components/layout/DraggableIcon.js +18 -0
  33. package/components/layout/DraggableIcon.js.map +1 -0
  34. package/components/layout/FlexibleColumn.d.ts +17 -0
  35. package/components/layout/FlexibleColumn.js +12 -0
  36. package/components/layout/FlexibleColumn.js.map +1 -0
  37. package/components/layout/FlexibleDragHandler.d.ts +18 -0
  38. package/components/layout/FlexibleDragHandler.js +88 -0
  39. package/components/layout/FlexibleDragHandler.js.map +1 -0
  40. package/components/layout/FlexibleDropZone.d.ts +19 -0
  41. package/components/layout/FlexibleDropZone.js +12 -0
  42. package/components/layout/FlexibleDropZone.js.map +1 -0
  43. package/components/layout/FlexibleGridContainer.d.ts +10 -0
  44. package/components/layout/FlexibleGridContainer.js +23 -0
  45. package/components/layout/FlexibleGridContainer.js.map +1 -0
  46. package/components/layout/FlexibleGridLayout.d.ts +16 -0
  47. package/components/layout/FlexibleGridLayout.js +24 -0
  48. package/components/layout/FlexibleGridLayout.js.map +1 -0
  49. package/components/layout/FlexibleResizeBar.d.ts +40 -0
  50. package/components/layout/FlexibleResizeBar.js +21 -0
  51. package/components/layout/FlexibleResizeBar.js.map +1 -0
  52. package/components/layout/FlexibleTab.d.ts +34 -0
  53. package/components/layout/FlexibleTab.js +36 -0
  54. package/components/layout/FlexibleTab.js.map +1 -0
  55. package/components/layout/FlexibleTabsContainer.d.ts +28 -0
  56. package/components/layout/FlexibleTabsContainer.js +54 -0
  57. package/components/layout/FlexibleTabsContainer.js.map +1 -0
  58. package/components/layout/LayoutContext.d.ts +12 -0
  59. package/components/layout/LayoutContext.js +3 -0
  60. package/components/layout/LayoutContext.js.map +1 -0
  61. package/components/layout/types.d.ts +78 -0
  62. package/components/layout/types.js +13 -0
  63. package/components/layout/types.js.map +1 -0
  64. package/components/layout/utils.d.ts +25 -0
  65. package/components/layout/utils.js +68 -0
  66. package/components/layout/utils.js.map +1 -0
  67. package/components/lines/ColorLineComponent.d.ts +40 -40
  68. package/components/lines/ColorLineComponent.js +145 -145
  69. package/components/lines/ColorPickerLineComponent.d.ts +33 -33
  70. package/components/lines/ColorPickerLineComponent.js +61 -61
  71. package/components/lines/FileButtonLineComponent.d.ts +16 -16
  72. package/components/lines/FileButtonLineComponent.js +21 -21
  73. package/components/lines/NumericInputComponent.d.ts +31 -31
  74. package/components/lines/NumericInputComponent.js +86 -86
  75. package/lines/booleanLineComponent.d.ts +11 -11
  76. package/lines/booleanLineComponent.js +14 -14
  77. package/lines/buttonLineComponent.d.ts +12 -12
  78. package/lines/buttonLineComponent.js +10 -10
  79. package/lines/checkBoxLineComponent.d.ts +36 -36
  80. package/lines/checkBoxLineComponent.js +88 -88
  81. package/lines/color3LineComponent.d.ts +18 -18
  82. package/lines/color3LineComponent.js +9 -9
  83. package/lines/color4LineComponent.d.ts +18 -18
  84. package/lines/color4LineComponent.js +9 -9
  85. package/lines/colorLineComponent.d.ts +40 -40
  86. package/lines/colorLineComponent.js +144 -144
  87. package/lines/colorPickerComponent.d.ts +31 -31
  88. package/lines/colorPickerComponent.js +60 -60
  89. package/lines/draggableLineComponent.d.ts +9 -9
  90. package/lines/draggableLineComponent.js +12 -12
  91. package/lines/fileButtonLineComponent.d.ts +17 -17
  92. package/lines/fileButtonLineComponent.js +20 -20
  93. package/lines/fileMultipleButtonLineComponent.d.ts +17 -17
  94. package/lines/fileMultipleButtonLineComponent.js +20 -20
  95. package/lines/floatLineComponent.d.ts +50 -50
  96. package/lines/floatLineComponent.js +175 -175
  97. package/lines/hexLineComponent.d.ts +40 -40
  98. package/lines/hexLineComponent.js +121 -121
  99. package/lines/iSelectedLineContainer.d.ts +4 -4
  100. package/lines/iSelectedLineContainer.js +1 -1
  101. package/lines/iconButtonLineComponent.d.ts +11 -11
  102. package/lines/iconButtonLineComponent.js +10 -10
  103. package/lines/iconComponent.d.ts +9 -9
  104. package/lines/iconComponent.js +7 -7
  105. package/lines/indentedTextLineComponent.d.ts +16 -16
  106. package/lines/indentedTextLineComponent.js +26 -26
  107. package/lines/inputArrowsComponent.d.ts +13 -13
  108. package/lines/inputArrowsComponent.js +37 -37
  109. package/lines/lineContainerComponent.d.ts +19 -19
  110. package/lines/lineContainerComponent.js +49 -49
  111. package/lines/linkButtonComponent.d.ts +16 -16
  112. package/lines/linkButtonComponent.js +20 -20
  113. package/lines/matrixLineComponent.d.ts +36 -36
  114. package/lines/matrixLineComponent.js +102 -102
  115. package/lines/messageLineComponent.d.ts +12 -12
  116. package/lines/messageLineComponent.js +14 -14
  117. package/lines/numericInputComponent.d.ts +31 -31
  118. package/lines/numericInputComponent.js +85 -85
  119. package/lines/optionsLineComponent.d.ts +48 -48
  120. package/lines/optionsLineComponent.js +118 -118
  121. package/lines/popup.d.ts +4 -4
  122. package/lines/popup.js +67 -67
  123. package/lines/radioLineComponent.d.ts +21 -21
  124. package/lines/radioLineComponent.js +26 -26
  125. package/lines/sliderLineComponent.d.ts +37 -37
  126. package/lines/sliderLineComponent.js +89 -89
  127. package/lines/targetsProxy.d.ts +11 -11
  128. package/lines/targetsProxy.js +42 -42
  129. package/lines/textInputLineComponent.d.ts +47 -47
  130. package/lines/textInputLineComponent.js +154 -154
  131. package/lines/textLineComponent.d.ts +21 -21
  132. package/lines/textLineComponent.js +30 -30
  133. package/lines/unitButton.d.ts +8 -8
  134. package/lines/unitButton.js +7 -7
  135. package/lines/valueLineComponent.d.ts +15 -15
  136. package/lines/valueLineComponent.js +12 -12
  137. package/lines/vector2LineComponent.d.ts +36 -36
  138. package/lines/vector2LineComponent.js +63 -63
  139. package/lines/vector3LineComponent.d.ts +41 -41
  140. package/lines/vector3LineComponent.js +74 -74
  141. package/lines/vector4LineComponent.d.ts +42 -42
  142. package/lines/vector4LineComponent.js +81 -81
  143. package/nodeGraphSystem/displayLedger.d.ts +5 -5
  144. package/nodeGraphSystem/displayLedger.js +3 -3
  145. package/nodeGraphSystem/frameNodePort.d.ts +25 -25
  146. package/nodeGraphSystem/frameNodePort.js +59 -59
  147. package/nodeGraphSystem/graphCanvas.d.ts +111 -111
  148. package/nodeGraphSystem/graphCanvas.js +1131 -1131
  149. package/nodeGraphSystem/graphFrame.d.ts +153 -153
  150. package/nodeGraphSystem/graphFrame.js +1328 -1328
  151. package/nodeGraphSystem/graphNode.d.ts +79 -79
  152. package/nodeGraphSystem/graphNode.js +459 -459
  153. package/nodeGraphSystem/interfaces/displayManager.d.ts +13 -13
  154. package/nodeGraphSystem/interfaces/displayManager.js +1 -1
  155. package/nodeGraphSystem/interfaces/nodeContainer.d.ts +6 -6
  156. package/nodeGraphSystem/interfaces/nodeContainer.js +1 -1
  157. package/nodeGraphSystem/interfaces/nodeData.d.ts +15 -15
  158. package/nodeGraphSystem/interfaces/nodeData.js +1 -1
  159. package/nodeGraphSystem/interfaces/nodeLocationInfo.d.ts +26 -26
  160. package/nodeGraphSystem/interfaces/nodeLocationInfo.js +1 -1
  161. package/nodeGraphSystem/interfaces/portData.d.ts +28 -28
  162. package/nodeGraphSystem/interfaces/portData.js +7 -7
  163. package/nodeGraphSystem/interfaces/propertyComponentProps.d.ts +6 -6
  164. package/nodeGraphSystem/interfaces/propertyComponentProps.js +1 -1
  165. package/nodeGraphSystem/interfaces/selectionChangedOptions.d.ts +11 -11
  166. package/nodeGraphSystem/interfaces/selectionChangedOptions.js +1 -1
  167. package/nodeGraphSystem/nodeLink.d.ts +31 -31
  168. package/nodeGraphSystem/nodeLink.js +182 -182
  169. package/nodeGraphSystem/nodePort.d.ts +35 -35
  170. package/nodeGraphSystem/nodePort.js +128 -128
  171. package/nodeGraphSystem/propertyLedger.d.ts +8 -8
  172. package/nodeGraphSystem/propertyLedger.js +3 -3
  173. package/nodeGraphSystem/stateManager.d.ts +45 -45
  174. package/nodeGraphSystem/stateManager.js +18 -18
  175. package/nodeGraphSystem/tools.d.ts +5 -5
  176. package/nodeGraphSystem/tools.js +36 -36
  177. package/nodeGraphSystem/typeLedger.d.ts +8 -8
  178. package/nodeGraphSystem/typeLedger.js +2 -2
  179. package/nodeGraphSystem/types/framePortData.d.ts +7 -7
  180. package/nodeGraphSystem/types/framePortData.js +1 -1
  181. package/package.json +4 -3
  182. package/propertyChangedEvent.d.ts +7 -7
  183. package/propertyChangedEvent.js +2 -2
  184. package/stories/Button.stories.d.ts +10 -10
  185. package/stories/Button.stories.js +19 -19
  186. package/stories/Icon.stories.d.ts +9 -9
  187. package/stories/Icon.stories.js +16 -16
  188. package/stories/Label.stories.d.ts +8 -8
  189. package/stories/Label.stories.js +10 -10
  190. package/stories/MessageDialog.stories.d.ts +9 -9
  191. package/stories/MessageDialog.stories.js +19 -19
  192. package/stories/Toggle.stories.d.ts +9 -9
  193. package/stories/Toggle.stories.js +17 -17
  194. package/stories/bars/CommandBarComponent.stories.d.ts +11 -11
  195. package/stories/bars/CommandBarComponent.stories.js +12 -12
  196. package/stories/bars/CommandButtonComponent.stories.d.ts +6 -6
  197. package/stories/bars/CommandButtonComponent.stories.js +6 -6
  198. package/stories/colorPicker/ColorPicker.stories.d.ts +11 -11
  199. package/stories/colorPicker/ColorPicker.stories.js +4 -4
  200. package/stories/layout/FlexibleGridLayout.stories.d.ts +46 -0
  201. package/stories/layout/FlexibleGridLayout.stories.js +48 -0
  202. package/stories/layout/FlexibleGridLayout.stories.js.map +1 -0
  203. package/stories/lines/ColorLineComponent.stories.d.ts +21 -21
  204. package/stories/lines/ColorLineComponent.stories.js +9 -9
  205. package/stories/lines/ColorPickerLineComponent.stories.d.ts +14 -14
  206. package/stories/lines/ColorPickerLineComponent.stories.js +10 -10
  207. package/stories/lines/FileButtonLineComponent.stories.d.ts +6 -6
  208. package/stories/lines/FileButtonLineComponent.stories.js +5 -5
  209. package/stories/lines/NumericInputComponent.stories.d.ts +11 -11
  210. package/stories/lines/NumericInputComponent.stories.js +5 -5
  211. package/stringTools.d.ts +11 -11
  212. package/stringTools.js +88 -88
  213. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.d.ts +15 -15
  214. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js +15 -15
  215. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.d.ts +15 -15
  216. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js +14 -14
  217. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.d.ts +17 -17
  218. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js +55 -55
  219. package/tabs/propertyGrids/gui/controlPropertyGridComponent.d.ts +15 -15
  220. package/tabs/propertyGrids/gui/controlPropertyGridComponent.js +12 -12
  221. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.d.ts +15 -15
  222. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js +15 -15
  223. package/tabs/propertyGrids/gui/gridPropertyGridComponent.d.ts +17 -17
  224. package/tabs/propertyGrids/gui/gridPropertyGridComponent.js +38 -38
  225. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.d.ts +15 -15
  226. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js +16 -16
  227. package/tabs/propertyGrids/gui/imagePropertyGridComponent.d.ts +15 -15
  228. package/tabs/propertyGrids/gui/imagePropertyGridComponent.js +25 -25
  229. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.d.ts +15 -15
  230. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js +17 -17
  231. package/tabs/propertyGrids/gui/linePropertyGridComponent.d.ts +16 -16
  232. package/tabs/propertyGrids/gui/linePropertyGridComponent.js +27 -27
  233. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.d.ts +15 -15
  234. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js +17 -17
  235. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.d.ts +15 -15
  236. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js +15 -15
  237. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.d.ts +15 -15
  238. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js +15 -15
  239. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.d.ts +15 -15
  240. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js +16 -16
  241. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.d.ts +15 -15
  242. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js +14 -14
  243. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.d.ts +15 -15
  244. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js +34 -34
  245. package/tabs/propertyGrids/lockObject.d.ts +9 -9
  246. package/tabs/propertyGrids/lockObject.js +11 -11
@@ -1,145 +1,145 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
4
- import { NumericInputComponent } from "./numericInputComponent.js";
5
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
- import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
7
- import { ColorPickerLineComponent } from "./colorPickerComponent.js";
8
- import { conflictingValuesPlaceholder } from "./targetsProxy.js";
9
- import copyIcon from "./copy.svg";
10
- const emptyColor = new Color4(0, 0, 0, 0);
11
- export class ColorLineComponent extends React.Component {
12
- constructor(props) {
13
- super(props);
14
- this.state = { isExpanded: false, color: this.getValue() };
15
- const target = this.props.target;
16
- target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate
17
- }
18
- shouldComponentUpdate(nextProps, nextState) {
19
- const stateColor = nextState.color;
20
- const propsColor = this.getValue(nextProps);
21
- if (stateColor !== this.state.color) {
22
- nextState.color = stateColor;
23
- return true;
24
- }
25
- if (propsColor !== this.state.color) {
26
- nextState.color = propsColor;
27
- return true;
28
- }
29
- if (nextState.isExpanded !== this.state.isExpanded) {
30
- return true;
31
- }
32
- return false;
33
- }
34
- getValue(props = this.props) {
35
- const target = props.target;
36
- const property = target[props.propertyName];
37
- if (!property)
38
- return emptyColor;
39
- if (typeof property === "string") {
40
- if (property === conflictingValuesPlaceholder) {
41
- return emptyColor;
42
- }
43
- return this._convertToColor(property);
44
- }
45
- else {
46
- if (props.isLinear) {
47
- return property.toGammaSpace();
48
- }
49
- return property.clone();
50
- }
51
- }
52
- setColorFromString(colorString) {
53
- const color = this._convertToColor(colorString);
54
- this.setColor(color);
55
- }
56
- setColor(newColor) {
57
- this.setState({ color: newColor.clone() });
58
- if (this.props.isLinear) {
59
- newColor.toLinearSpaceToRef(newColor);
60
- }
61
- // whether to set properties to color3 or color4
62
- const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;
63
- const target = this.props.target;
64
- const initialValue = target[this.props.propertyName];
65
- const value = typeof target[this.props.propertyName] === "string" ? setColor.toHexString() : setColor;
66
- // make the change
67
- target[this.props.propertyName] = value;
68
- // notify observers
69
- if (this.props.onPropertyChangedObservable) {
70
- this.props.onPropertyChangedObservable.notifyObservers({
71
- object: target,
72
- property: this.props.propertyName,
73
- value,
74
- initialValue,
75
- });
76
- }
77
- if (this.props.onChange) {
78
- this.props.onChange();
79
- }
80
- }
81
- switchExpandState() {
82
- this.setState({ isExpanded: !this.state.isExpanded });
83
- }
84
- updateStateR(value) {
85
- this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));
86
- }
87
- updateStateG(value) {
88
- this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));
89
- }
90
- updateStateB(value) {
91
- this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));
92
- }
93
- updateStateA(value) {
94
- if (this.props.disableAlpha) {
95
- return;
96
- }
97
- this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));
98
- }
99
- copyToClipboard() {
100
- const element = document.createElement("div");
101
- element.textContent = this.state.color.toHexString();
102
- document.body.appendChild(element);
103
- if (window.getSelection) {
104
- const range = document.createRange();
105
- range.selectNode(element);
106
- window.getSelection().removeAllRanges();
107
- window.getSelection().addRange(range);
108
- }
109
- document.execCommand("copy");
110
- element.remove();
111
- }
112
- _convertToColor(color) {
113
- if (color === "" || color === "transparent") {
114
- return emptyColor;
115
- }
116
- if (color.substring(0, 1) !== "#" || (color.length !== 7 && color.length !== 9)) {
117
- const d = document.createElement("div");
118
- d.style.color = color;
119
- document.body.append(d);
120
- const rgb = window.getComputedStyle(d).color;
121
- document.body.removeChild(d);
122
- const rgbArray = rgb
123
- .substring(4, rgb.length - 1)
124
- .replace(/ /g, "")
125
- .split(",");
126
- const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;
127
- return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);
128
- }
129
- if (this.props.disableAlpha) {
130
- const color3 = Color3.FromHexString(color);
131
- return new Color4(color3.r, color3.g, color3.b, 1.0);
132
- }
133
- return Color4.FromHexString(color);
134
- }
135
- _toColor3(color) {
136
- return new Color3(color.r, color.g, color.b);
137
- }
138
- render() {
139
- const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
140
- return (_jsxs("div", { className: "color3Line", 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 }), _jsx("div", { className: "color3", children: _jsx(ColorPickerLineComponent, { lockObject: this.props.lockObject, linearHint: this.props.isLinear, value: this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color, onColorChanged: (colorString) => {
141
- this.setColorFromString(colorString);
142
- } }) }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.copyToClipboard(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) }), _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: "r", value: this.state.color.r, onChange: (value) => this.updateStateR(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "g", value: this.state.color.g, onChange: (value) => this.updateStateG(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "b", value: this.state.color.b, onChange: (value) => this.updateStateB(value) }), this.props.disableAlpha || (_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "a", value: this.state.color.a, onChange: (value) => this.updateStateA(value) }))] }))] }));
143
- }
144
- }
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
4
+ import { NumericInputComponent } from "./numericInputComponent.js";
5
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
+ import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
7
+ import { ColorPickerLineComponent } from "./colorPickerComponent.js";
8
+ import { conflictingValuesPlaceholder } from "./targetsProxy.js";
9
+ import copyIcon from "./copy.svg";
10
+ const emptyColor = new Color4(0, 0, 0, 0);
11
+ export class ColorLineComponent extends React.Component {
12
+ constructor(props) {
13
+ super(props);
14
+ this.state = { isExpanded: false, color: this.getValue() };
15
+ const target = this.props.target;
16
+ target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate
17
+ }
18
+ shouldComponentUpdate(nextProps, nextState) {
19
+ const stateColor = nextState.color;
20
+ const propsColor = this.getValue(nextProps);
21
+ if (stateColor !== this.state.color) {
22
+ nextState.color = stateColor;
23
+ return true;
24
+ }
25
+ if (propsColor !== this.state.color) {
26
+ nextState.color = propsColor;
27
+ return true;
28
+ }
29
+ if (nextState.isExpanded !== this.state.isExpanded) {
30
+ return true;
31
+ }
32
+ return false;
33
+ }
34
+ getValue(props = this.props) {
35
+ const target = props.target;
36
+ const property = target[props.propertyName];
37
+ if (!property)
38
+ return emptyColor;
39
+ if (typeof property === "string") {
40
+ if (property === conflictingValuesPlaceholder) {
41
+ return emptyColor;
42
+ }
43
+ return this._convertToColor(property);
44
+ }
45
+ else {
46
+ if (props.isLinear) {
47
+ return property.toGammaSpace();
48
+ }
49
+ return property.clone();
50
+ }
51
+ }
52
+ setColorFromString(colorString) {
53
+ const color = this._convertToColor(colorString);
54
+ this.setColor(color);
55
+ }
56
+ setColor(newColor) {
57
+ this.setState({ color: newColor.clone() });
58
+ if (this.props.isLinear) {
59
+ newColor.toLinearSpaceToRef(newColor);
60
+ }
61
+ // whether to set properties to color3 or color4
62
+ const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;
63
+ const target = this.props.target;
64
+ const initialValue = target[this.props.propertyName];
65
+ const value = typeof target[this.props.propertyName] === "string" ? setColor.toHexString() : setColor;
66
+ // make the change
67
+ target[this.props.propertyName] = value;
68
+ // notify observers
69
+ if (this.props.onPropertyChangedObservable) {
70
+ this.props.onPropertyChangedObservable.notifyObservers({
71
+ object: target,
72
+ property: this.props.propertyName,
73
+ value,
74
+ initialValue,
75
+ });
76
+ }
77
+ if (this.props.onChange) {
78
+ this.props.onChange();
79
+ }
80
+ }
81
+ switchExpandState() {
82
+ this.setState({ isExpanded: !this.state.isExpanded });
83
+ }
84
+ updateStateR(value) {
85
+ this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));
86
+ }
87
+ updateStateG(value) {
88
+ this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));
89
+ }
90
+ updateStateB(value) {
91
+ this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));
92
+ }
93
+ updateStateA(value) {
94
+ if (this.props.disableAlpha) {
95
+ return;
96
+ }
97
+ this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));
98
+ }
99
+ copyToClipboard() {
100
+ const element = document.createElement("div");
101
+ element.textContent = this.state.color.toHexString();
102
+ document.body.appendChild(element);
103
+ if (window.getSelection) {
104
+ const range = document.createRange();
105
+ range.selectNode(element);
106
+ window.getSelection().removeAllRanges();
107
+ window.getSelection().addRange(range);
108
+ }
109
+ document.execCommand("copy");
110
+ element.remove();
111
+ }
112
+ _convertToColor(color) {
113
+ if (color === "" || color === "transparent") {
114
+ return emptyColor;
115
+ }
116
+ if (color.substring(0, 1) !== "#" || (color.length !== 7 && color.length !== 9)) {
117
+ const d = document.createElement("div");
118
+ d.style.color = color;
119
+ document.body.append(d);
120
+ const rgb = window.getComputedStyle(d).color;
121
+ document.body.removeChild(d);
122
+ const rgbArray = rgb
123
+ .substring(4, rgb.length - 1)
124
+ .replace(/ /g, "")
125
+ .split(",");
126
+ const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;
127
+ return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);
128
+ }
129
+ if (this.props.disableAlpha) {
130
+ const color3 = Color3.FromHexString(color);
131
+ return new Color4(color3.r, color3.g, color3.b, 1.0);
132
+ }
133
+ return Color4.FromHexString(color);
134
+ }
135
+ _toColor3(color) {
136
+ return new Color3(color.r, color.g, color.b);
137
+ }
138
+ render() {
139
+ const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
140
+ return (_jsxs("div", { className: "color3Line", 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 }), _jsx("div", { className: "color3", children: _jsx(ColorPickerLineComponent, { lockObject: this.props.lockObject, linearHint: this.props.isLinear, value: this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color, onColorChanged: (colorString) => {
141
+ this.setColorFromString(colorString);
142
+ } }) }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.copyToClipboard(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) }), _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: "r", value: this.state.color.r, onChange: (value) => this.updateStateR(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "g", value: this.state.color.g, onChange: (value) => this.updateStateG(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "b", value: this.state.color.b, onChange: (value) => this.updateStateB(value) }), this.props.disableAlpha || (_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "a", value: this.state.color.a, onChange: (value) => this.updateStateA(value) }))] }))] }));
143
+ }
144
+ }
145
145
  //# sourceMappingURL=colorLineComponent.js.map
@@ -1,31 +1,31 @@
1
- import * as React from "react";
2
- import type { Color4, Color3 } from "@babylonjs/core/Maths/math.color.js";
3
- import type { LockObject } from "../tabs/propertyGrids/lockObject";
4
- export interface IColorPickerComponentProps {
5
- value: Color4 | Color3;
6
- linearHint?: boolean;
7
- onColorChanged: (newOne: string) => void;
8
- icon?: string;
9
- iconLabel?: string;
10
- shouldPopRight?: boolean;
11
- lockObject?: LockObject;
12
- }
13
- interface IColorPickerComponentState {
14
- pickerEnabled: boolean;
15
- color: Color3 | Color4;
16
- hex: string;
17
- }
18
- export declare class ColorPickerLineComponent extends React.Component<IColorPickerComponentProps, IColorPickerComponentState> {
19
- private _floatRef;
20
- private _floatHostRef;
21
- constructor(props: IColorPickerComponentProps);
22
- syncPositions(): void;
23
- shouldComponentUpdate(nextProps: IColorPickerComponentProps, nextState: IColorPickerComponentState): boolean;
24
- getHexString(props?: Readonly<IColorPickerComponentProps> & Readonly<{
25
- children?: React.ReactNode;
26
- }>): string;
27
- componentDidUpdate(): void;
28
- componentDidMount(): void;
29
- render(): JSX.Element;
30
- }
31
- export {};
1
+ import * as React from "react";
2
+ import type { Color4, Color3 } from "@babylonjs/core/Maths/math.color.js";
3
+ import type { LockObject } from "../tabs/propertyGrids/lockObject";
4
+ export interface IColorPickerComponentProps {
5
+ value: Color4 | Color3;
6
+ linearHint?: boolean;
7
+ onColorChanged: (newOne: string) => void;
8
+ icon?: string;
9
+ iconLabel?: string;
10
+ shouldPopRight?: boolean;
11
+ lockObject?: LockObject;
12
+ }
13
+ interface IColorPickerComponentState {
14
+ pickerEnabled: boolean;
15
+ color: Color3 | Color4;
16
+ hex: string;
17
+ }
18
+ export declare class ColorPickerLineComponent extends React.Component<IColorPickerComponentProps, IColorPickerComponentState> {
19
+ private _floatRef;
20
+ private _floatHostRef;
21
+ constructor(props: IColorPickerComponentProps);
22
+ syncPositions(): void;
23
+ shouldComponentUpdate(nextProps: IColorPickerComponentProps, nextState: IColorPickerComponentState): boolean;
24
+ getHexString(props?: Readonly<IColorPickerComponentProps> & Readonly<{
25
+ children?: React.ReactNode;
26
+ }>): string;
27
+ componentDidUpdate(): void;
28
+ componentDidMount(): void;
29
+ render(): JSX.Element;
30
+ }
31
+ export {};
@@ -1,61 +1,61 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { ColorPicker } from "../colorPicker/colorPicker.js";
4
- export class ColorPickerLineComponent extends React.Component {
5
- constructor(props) {
6
- super(props);
7
- this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };
8
- this._floatRef = React.createRef();
9
- this._floatHostRef = React.createRef();
10
- }
11
- syncPositions() {
12
- const div = this._floatRef.current;
13
- const host = this._floatHostRef.current;
14
- if (!div || !host) {
15
- return;
16
- }
17
- let top = host.getBoundingClientRect().top;
18
- const height = div.getBoundingClientRect().height;
19
- if (top + height + 10 > window.innerHeight) {
20
- top = window.innerHeight - height - 10;
21
- }
22
- div.style.top = top + "px";
23
- if (!this.props.shouldPopRight) {
24
- div.style.left = host.getBoundingClientRect().left - div.getBoundingClientRect().width + "px";
25
- }
26
- else {
27
- div.style.left = host.getBoundingClientRect().left + "px";
28
- }
29
- }
30
- shouldComponentUpdate(nextProps, nextState) {
31
- const diffProps = this.getHexString(nextProps) !== this.getHexString();
32
- if (diffProps) {
33
- nextState.color = nextProps.value;
34
- nextState.hex = this.getHexString(nextProps);
35
- }
36
- return diffProps || nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;
37
- }
38
- getHexString(props = this.props) {
39
- return props.value.toHexString();
40
- }
41
- componentDidUpdate() {
42
- this.syncPositions();
43
- }
44
- componentDidMount() {
45
- this.syncPositions();
46
- }
47
- render() {
48
- return (_jsxs("div", { className: "color-picker", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "color-rect-background", ref: this._floatHostRef, onClick: () => this.setState({ pickerEnabled: true }), children: _jsx("div", { className: "color-rect", style: { background: this.state.hex } }) }), this.state.pickerEnabled && (_jsx(_Fragment, { children: _jsx("div", { className: "color-picker-cover", onClick: (evt) => {
49
- var _a, _b;
50
- if (evt.target !== ((_b = (_a = this._floatRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) === null || _b === void 0 ? void 0 : _b.querySelector(".color-picker-cover"))) {
51
- return;
52
- }
53
- this.setState({ pickerEnabled: false });
54
- }, children: _jsx("div", { className: "color-picker-float", ref: this._floatRef, children: _jsx(ColorPicker, { lockObject: this.props.lockObject || {}, color: this.state.color, linearhint: this.props.linearHint, onColorChanged: (color) => {
55
- const hex = color.toHexString();
56
- this.setState({ hex, color });
57
- this.props.onColorChanged(hex);
58
- } }) }) }) }))] }));
59
- }
60
- }
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { ColorPicker } from "../colorPicker/colorPicker.js";
4
+ export class ColorPickerLineComponent extends React.Component {
5
+ constructor(props) {
6
+ super(props);
7
+ this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };
8
+ this._floatRef = React.createRef();
9
+ this._floatHostRef = React.createRef();
10
+ }
11
+ syncPositions() {
12
+ const div = this._floatRef.current;
13
+ const host = this._floatHostRef.current;
14
+ if (!div || !host) {
15
+ return;
16
+ }
17
+ let top = host.getBoundingClientRect().top;
18
+ const height = div.getBoundingClientRect().height;
19
+ if (top + height + 10 > window.innerHeight) {
20
+ top = window.innerHeight - height - 10;
21
+ }
22
+ div.style.top = top + "px";
23
+ if (!this.props.shouldPopRight) {
24
+ div.style.left = host.getBoundingClientRect().left - div.getBoundingClientRect().width + "px";
25
+ }
26
+ else {
27
+ div.style.left = host.getBoundingClientRect().left + "px";
28
+ }
29
+ }
30
+ shouldComponentUpdate(nextProps, nextState) {
31
+ const diffProps = this.getHexString(nextProps) !== this.getHexString();
32
+ if (diffProps) {
33
+ nextState.color = nextProps.value;
34
+ nextState.hex = this.getHexString(nextProps);
35
+ }
36
+ return diffProps || nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;
37
+ }
38
+ getHexString(props = this.props) {
39
+ return props.value.toHexString();
40
+ }
41
+ componentDidUpdate() {
42
+ this.syncPositions();
43
+ }
44
+ componentDidMount() {
45
+ this.syncPositions();
46
+ }
47
+ render() {
48
+ return (_jsxs("div", { className: "color-picker", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "color-rect-background", ref: this._floatHostRef, onClick: () => this.setState({ pickerEnabled: true }), children: _jsx("div", { className: "color-rect", style: { background: this.state.hex } }) }), this.state.pickerEnabled && (_jsx(_Fragment, { children: _jsx("div", { className: "color-picker-cover", onClick: (evt) => {
49
+ var _a, _b;
50
+ if (evt.target !== ((_b = (_a = this._floatRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) === null || _b === void 0 ? void 0 : _b.querySelector(".color-picker-cover"))) {
51
+ return;
52
+ }
53
+ this.setState({ pickerEnabled: false });
54
+ }, children: _jsx("div", { className: "color-picker-float", ref: this._floatRef, children: _jsx(ColorPicker, { lockObject: this.props.lockObject || {}, color: this.state.color, linearhint: this.props.linearHint, onColorChanged: (color) => {
55
+ const hex = color.toHexString();
56
+ this.setState({ hex, color });
57
+ this.props.onColorChanged(hex);
58
+ } }) }) }) }))] }));
59
+ }
60
+ }
61
61
  //# sourceMappingURL=colorPickerComponent.js.map
@@ -1,9 +1,9 @@
1
- import * as React from "react";
2
- export interface IButtonLineComponentProps {
3
- data: string;
4
- tooltip: string;
5
- }
6
- export declare class DraggableLineComponent extends React.Component<IButtonLineComponentProps> {
7
- constructor(props: IButtonLineComponentProps);
8
- render(): JSX.Element;
9
- }
1
+ import * as React from "react";
2
+ export interface IButtonLineComponentProps {
3
+ data: string;
4
+ tooltip: string;
5
+ }
6
+ export declare class DraggableLineComponent extends React.Component<IButtonLineComponentProps> {
7
+ constructor(props: IButtonLineComponentProps);
8
+ render(): JSX.Element;
9
+ }
@@ -1,13 +1,13 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
- export class DraggableLineComponent extends React.Component {
4
- constructor(props) {
5
- super(props);
6
- }
7
- render() {
8
- return (_jsx("div", { className: "draggableLine", title: this.props.tooltip, draggable: true, onDragStart: (event) => {
9
- event.dataTransfer.setData("babylonjs-gui-node", this.props.data);
10
- }, children: this.props.data.replace("Block", "") }));
11
- }
12
- }
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ export class DraggableLineComponent extends React.Component {
4
+ constructor(props) {
5
+ super(props);
6
+ }
7
+ render() {
8
+ return (_jsx("div", { className: "draggableLine", title: this.props.tooltip, draggable: true, onDragStart: (event) => {
9
+ event.dataTransfer.setData("babylonjs-gui-node", this.props.data);
10
+ }, children: this.props.data.replace("Block", "") }));
11
+ }
12
+ }
13
13
  //# sourceMappingURL=draggableLineComponent.js.map
@@ -1,17 +1,17 @@
1
- import * as React from "react";
2
- interface IFileButtonLineComponentProps {
3
- label: string;
4
- onClick: (file: File) => void;
5
- accept: string;
6
- icon?: string;
7
- iconLabel?: string;
8
- }
9
- export declare class FileButtonLineComponent extends React.Component<IFileButtonLineComponentProps> {
10
- private static _IDGenerator;
11
- private _id;
12
- private _uploadInputRef;
13
- constructor(props: IFileButtonLineComponentProps);
14
- onChange(evt: any): void;
15
- render(): JSX.Element;
16
- }
17
- export {};
1
+ import * as React from "react";
2
+ interface IFileButtonLineComponentProps {
3
+ label: string;
4
+ onClick: (file: File) => void;
5
+ accept: string;
6
+ icon?: string;
7
+ iconLabel?: string;
8
+ }
9
+ export declare class FileButtonLineComponent extends React.Component<IFileButtonLineComponentProps> {
10
+ private static _IDGenerator;
11
+ private _id;
12
+ private _uploadInputRef;
13
+ constructor(props: IFileButtonLineComponentProps);
14
+ onChange(evt: any): void;
15
+ render(): JSX.Element;
16
+ }
17
+ export {};
@@ -1,21 +1,21 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- export class FileButtonLineComponent extends React.Component {
4
- constructor(props) {
5
- super(props);
6
- this._id = FileButtonLineComponent._IDGenerator++;
7
- this._uploadInputRef = React.createRef();
8
- }
9
- onChange(evt) {
10
- const files = evt.target.files;
11
- if (files && files.length) {
12
- this.props.onClick(files[0]);
13
- }
14
- evt.target.value = "";
15
- }
16
- render() {
17
- return (_jsxs("div", { className: "buttonLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("label", { htmlFor: "file-upload" + this._id, className: "file-upload", children: this.props.label }), _jsx("input", { ref: this._uploadInputRef, id: "file-upload" + this._id, type: "file", accept: this.props.accept, onChange: (evt) => this.onChange(evt) })] }));
18
- }
19
- }
20
- FileButtonLineComponent._IDGenerator = 0;
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ export class FileButtonLineComponent extends React.Component {
4
+ constructor(props) {
5
+ super(props);
6
+ this._id = FileButtonLineComponent._IDGenerator++;
7
+ this._uploadInputRef = React.createRef();
8
+ }
9
+ onChange(evt) {
10
+ const files = evt.target.files;
11
+ if (files && files.length) {
12
+ this.props.onClick(files[0]);
13
+ }
14
+ evt.target.value = "";
15
+ }
16
+ render() {
17
+ return (_jsxs("div", { className: "buttonLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("label", { htmlFor: "file-upload" + this._id, className: "file-upload", children: this.props.label }), _jsx("input", { ref: this._uploadInputRef, id: "file-upload" + this._id, type: "file", accept: this.props.accept, onChange: (evt) => this.onChange(evt) })] }));
18
+ }
19
+ }
20
+ FileButtonLineComponent._IDGenerator = 0;
21
21
  //# sourceMappingURL=fileButtonLineComponent.js.map
@@ -1,17 +1,17 @@
1
- import * as React from "react";
2
- interface IFileMultipleButtonLineComponentProps {
3
- label: string;
4
- onClick: (event: any) => void;
5
- accept: string;
6
- icon?: string;
7
- iconLabel?: string;
8
- }
9
- export declare class FileMultipleButtonLineComponent extends React.Component<IFileMultipleButtonLineComponentProps> {
10
- private static _IDGenerator;
11
- private _id;
12
- private _uploadInputRef;
13
- constructor(props: IFileMultipleButtonLineComponentProps);
14
- onChange(evt: any): void;
15
- render(): JSX.Element;
16
- }
17
- export {};
1
+ import * as React from "react";
2
+ interface IFileMultipleButtonLineComponentProps {
3
+ label: string;
4
+ onClick: (event: any) => void;
5
+ accept: string;
6
+ icon?: string;
7
+ iconLabel?: string;
8
+ }
9
+ export declare class FileMultipleButtonLineComponent extends React.Component<IFileMultipleButtonLineComponentProps> {
10
+ private static _IDGenerator;
11
+ private _id;
12
+ private _uploadInputRef;
13
+ constructor(props: IFileMultipleButtonLineComponentProps);
14
+ onChange(evt: any): void;
15
+ render(): JSX.Element;
16
+ }
17
+ export {};