@babylonjs/shared-ui-components 6.34.1 → 6.34.3

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.
@@ -4,6 +4,7 @@ import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
4
4
  import { ColorComponentEntry } from "./colorComponentEntry.js";
5
5
  import { HexColor } from "./hexColor.js";
6
6
  import "./colorPicker.scss";
7
+ import { Logger } from "@babylonjs/core/Misc/logger.js";
7
8
  /**
8
9
  * Class used to create a color picker
9
10
  */
@@ -58,8 +59,8 @@ export class ColorPicker extends React.Component {
58
59
  const saturation = Math.min(1, Math.max(0.0001, left / this._saturationRef.current.clientWidth));
59
60
  const value = Math.min(1, Math.max(0.0001, 1 - top / this._saturationRef.current.clientHeight));
60
61
  if (this.props.debugMode) {
61
- console.log("Saturation: " + saturation);
62
- console.log("Value: " + value);
62
+ Logger.Log("Saturation: " + saturation);
63
+ Logger.Log("Value: " + value);
63
64
  }
64
65
  const hsv = this.state.color.toHSV();
65
66
  Color3.HSVtoRGBToRef(hsv.r, saturation, value, this.state.color);
@@ -72,7 +73,7 @@ export class ColorPicker extends React.Component {
72
73
  const left = evt.nativeEvent.offsetX;
73
74
  const hue = 360 * Math.min(0.9999, Math.max(0.0001, left / this._hueRef.current.clientWidth));
74
75
  if (this.props.debugMode) {
75
- console.log("Hue: " + hue);
76
+ Logger.Log("Hue: " + hue);
76
77
  }
77
78
  const hsv = this.state.color.toHSV();
78
79
  Color3.HSVtoRGBToRef(hue, Math.max(hsv.g, 0.01), Math.max(hsv.b, 0.01), this.state.color);
@@ -1 +1 @@
1
- {"version":3,"file":"colorPicker.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/colorPicker/colorPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AACvD,OAAO,EAAE,mBAAmB,EAAE,M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AAwB,oBAAU,EACjD,cAAK,SAAS,EAAC,wBAAwB,YACnC,KAAC,QAAQ,IACL,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAChC,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;oCAChB,IAAI,QAAQ,EAAE;wCACV,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;wCAC3C,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;qCACvF;yCAAM;wCACH,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;qCACzD;gCACL,CAAC,GACH,GACA,IACJ,EACL,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CACtB,cAAK,SAAS,EAAC,sBAAsB,0IAE/B,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { ColorComponentEntry } from \"./colorComponentEntry\";\r\nimport { HexColor } from \"./hexColor\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\nimport \"./colorPicker.scss\";\r\n\r\n/**\r\n * Interface used to specify creation options for color picker\r\n */\r\nexport interface IColorPickerProps {\r\n color: Color3 | Color4;\r\n linearhint?: boolean;\r\n debugMode?: boolean;\r\n onColorChanged?: (color: Color3 | Color4) => void;\r\n lockObject: LockObject;\r\n}\r\n\r\n/**\r\n * Interface used to specify creation options for color picker\r\n */\r\nexport interface IColorPickerState {\r\n color: Color3;\r\n alpha: number;\r\n}\r\n\r\n/**\r\n * Class used to create a color picker\r\n */\r\nexport class ColorPicker extends React.Component<IColorPickerProps, IColorPickerState> {\r\n private _saturationRef: React.RefObject<HTMLDivElement>;\r\n private _hueRef: React.RefObject<HTMLDivElement>;\r\n private _isSaturationPointerDown: boolean;\r\n private _isHuePointerDown: boolean;\r\n\r\n constructor(props: IColorPickerProps) {\r\n super(props);\r\n if (this.props.color instanceof Color4) {\r\n this.state = { color: new Color3(this.props.color.r, this.props.color.g, this.props.color.b), alpha: this.props.color.a };\r\n } else {\r\n this.state = { color: this.props.color.clone(), alpha: 1 };\r\n }\r\n this._saturationRef = React.createRef();\r\n this._hueRef = React.createRef();\r\n }\r\n\r\n shouldComponentUpdate(nextProps: IColorPickerProps, nextState: IColorPickerState) {\r\n return nextProps.color.toHexString() !== this.props.color.toHexString() || nextState.color.toHexString() !== this.props.color.toHexString();\r\n }\r\n\r\n onSaturationPointerDown(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._evaluateSaturation(evt);\r\n this._isSaturationPointerDown = true;\r\n\r\n evt.currentTarget.setPointerCapture(evt.pointerId);\r\n }\r\n\r\n onSaturationPointerUp(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._isSaturationPointerDown = false;\r\n evt.currentTarget.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n onSaturationPointerMove(evt: React.PointerEvent<HTMLDivElement>) {\r\n if (!this._isSaturationPointerDown) {\r\n return;\r\n }\r\n this._evaluateSaturation(evt);\r\n }\r\n\r\n onHuePointerDown(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._evaluateHue(evt);\r\n this._isHuePointerDown = true;\r\n\r\n evt.currentTarget.setPointerCapture(evt.pointerId);\r\n }\r\n\r\n onHuePointerUp(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._isHuePointerDown = false;\r\n evt.currentTarget.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n onHuePointerMove(evt: React.PointerEvent<HTMLDivElement>) {\r\n if (!this._isHuePointerDown) {\r\n return;\r\n }\r\n this._evaluateHue(evt);\r\n }\r\n\r\n private _evaluateSaturation(evt: React.PointerEvent<HTMLDivElement>) {\r\n const left = evt.nativeEvent.offsetX;\r\n const top = evt.nativeEvent.offsetY;\r\n\r\n const saturation = Math.min(1, Math.max(0.0001, left / this._saturationRef.current!.clientWidth));\r\n const value = Math.min(1, Math.max(0.0001, 1 - top / this._saturationRef.current!.clientHeight));\r\n\r\n if (this.props.debugMode) {\r\n console.log(\"Saturation: \" + saturation);\r\n console.log(\"Value: \" + value);\r\n }\r\n\r\n const hsv = this.state.color.toHSV();\r\n Color3.HSVtoRGBToRef(hsv.r, saturation, value, this.state.color);\r\n if (this.state.alpha === 0) {\r\n this.setState({ alpha: 1 });\r\n }\r\n this.setState({ color: this.state.color });\r\n }\r\n\r\n private _evaluateHue(evt: React.PointerEvent<HTMLDivElement>) {\r\n const left = evt.nativeEvent.offsetX;\r\n\r\n const hue = 360 * Math.min(0.9999, Math.max(0.0001, left / this._hueRef.current!.clientWidth));\r\n\r\n if (this.props.debugMode) {\r\n console.log(\"Hue: \" + hue);\r\n }\r\n\r\n const hsv = this.state.color.toHSV();\r\n Color3.HSVtoRGBToRef(hue, Math.max(hsv.g, 0.01), Math.max(hsv.b, 0.01), this.state.color);\r\n this.setState({ color: this.state.color });\r\n }\r\n\r\n componentDidUpdate() {\r\n this.raiseOnColorChanged();\r\n }\r\n\r\n raiseOnColorChanged() {\r\n if (!this.props.onColorChanged) {\r\n return;\r\n }\r\n\r\n if (this.props.color instanceof Color4) {\r\n const newColor4 = Color4.FromColor3(this.state.color, this.state.alpha);\r\n\r\n this.props.onColorChanged(newColor4);\r\n\r\n return;\r\n }\r\n\r\n this.props.onColorChanged(this.state.color.clone());\r\n }\r\n\r\n public render() {\r\n const color4 = Color4.FromColor3(this.state.color);\r\n color4.a = this.state.alpha;\r\n const colorHex = color4.toHexString();\r\n const hsv = this.state.color.toHSV();\r\n const colorRef = new Color3();\r\n Color3.HSVtoRGBToRef(hsv.r, 1, 1, colorRef);\r\n const colorHexRef = colorRef.toHexString();\r\n const hasAlpha = this.props.color instanceof Color4;\r\n\r\n return (\r\n <div className={\"color-picker-container\" + (this.props.linearhint ? \" with-hints\" : \"\")}>\r\n <div\r\n className=\"color-picker-saturation\"\r\n onPointerMove={(e) => this.onSaturationPointerMove(e)}\r\n onPointerDown={(e) => this.onSaturationPointerDown(e)}\r\n onPointerUp={(e) => this.onSaturationPointerUp(e)}\r\n ref={this._saturationRef}\r\n style={{\r\n background: colorHexRef,\r\n }}\r\n >\r\n <div className=\"color-picker-saturation-white\"></div>\r\n <div className=\"color-picker-saturation-black\"></div>\r\n <div\r\n className=\"color-picker-saturation-cursor\"\r\n style={{\r\n top: `${-(hsv.b * 100) + 100}%`,\r\n left: `${hsv.g * 100}%`,\r\n }}\r\n ></div>\r\n </div>\r\n <div className=\"color-picker-hue\">\r\n <div\r\n className=\"color-picker-hue-color\"\r\n style={{\r\n background: colorHex,\r\n }}\r\n ></div>\r\n <div\r\n className=\"color-picker-hue-slider\"\r\n ref={this._hueRef}\r\n onPointerMove={(e) => this.onHuePointerMove(e)}\r\n onPointerDown={(e) => this.onHuePointerDown(e)}\r\n onPointerUp={(e) => this.onHuePointerUp(e)}\r\n >\r\n <div\r\n className=\"color-picker-hue-cursor\"\r\n style={{\r\n left: `${(hsv.r / 360.0) * 100}%`,\r\n border: `1px solid ` + colorHexRef,\r\n }}\r\n ></div>\r\n </div>\r\n </div>\r\n <div className=\"color-picker-alpha\"></div>\r\n <div className=\"color-picker-rgb\">\r\n <div className=\"red\">\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"R\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.r * 255)}\r\n onChange={(value) => {\r\n this.state.color.r = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className=\"green\">\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"G\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.g * 255)}\r\n onChange={(value) => {\r\n this.state.color.g = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className=\"blue\">\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"B\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.b * 255)}\r\n onChange={(value) => {\r\n this.state.color.b = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className={\"alpha\" + (hasAlpha ? \"\" : \" grayed\")}>\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"A\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.alpha * 255)}\r\n onChange={(value) => {\r\n this.setState({ alpha: value / 255.0 });\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n </div>\r\n <div className=\"color-picker-hex\">\r\n <div className=\"color-picker-hex-label\">Hex</div>\r\n <div className=\"color-picker-hex-value\">\r\n <HexColor\r\n lockObject={this.props.lockObject}\r\n expectedLength={hasAlpha ? 8 : 6}\r\n value={colorHex}\r\n onChange={(value) => {\r\n if (hasAlpha) {\r\n const color4 = Color4.FromHexString(value);\r\n this.setState({ color: new Color3(color4.r, color4.g, color4.b), alpha: color4.a });\r\n } else {\r\n this.setState({ color: Color3.FromHexString(value) });\r\n }\r\n }}\r\n />\r\n </div>\r\n </div>\r\n {this.props.linearhint && (\r\n <div className=\"color-picker-warning\">\r\n (Note: color is stored in linear mode and was converted to gamma to be displayed here (toGammaSpace() / toLinearSpace()))\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"colorPicker.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/colorPicker/colorPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAA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vB,CAAC,GACH,GACA,IACJ,EACN,eAAK,SAAS,EAAC,kBAAkB,aAC7B,cAAK,SAAS,EAAC,wBAAwB,oBAAU,EACjD,cAAK,SAAS,EAAC,wBAAwB,YACnC,KAAC,QAAQ,IACL,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAChC,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;oCAChB,IAAI,QAAQ,EAAE;wCACV,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;wCAC3C,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;qCACvF;yCAAM;wCACH,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;qCACzD;gCACL,CAAC,GACH,GACA,IACJ,EACL,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CACtB,cAAK,SAAS,EAAC,sBAAsB,0IAE/B,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { ColorComponentEntry } from \"./colorComponentEntry\";\r\nimport { HexColor } from \"./hexColor\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\nimport \"./colorPicker.scss\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Interface used to specify creation options for color picker\r\n */\r\nexport interface IColorPickerProps {\r\n color: Color3 | Color4;\r\n linearhint?: boolean;\r\n debugMode?: boolean;\r\n onColorChanged?: (color: Color3 | Color4) => void;\r\n lockObject: LockObject;\r\n}\r\n\r\n/**\r\n * Interface used to specify creation options for color picker\r\n */\r\nexport interface IColorPickerState {\r\n color: Color3;\r\n alpha: number;\r\n}\r\n\r\n/**\r\n * Class used to create a color picker\r\n */\r\nexport class ColorPicker extends React.Component<IColorPickerProps, IColorPickerState> {\r\n private _saturationRef: React.RefObject<HTMLDivElement>;\r\n private _hueRef: React.RefObject<HTMLDivElement>;\r\n private _isSaturationPointerDown: boolean;\r\n private _isHuePointerDown: boolean;\r\n\r\n constructor(props: IColorPickerProps) {\r\n super(props);\r\n if (this.props.color instanceof Color4) {\r\n this.state = { color: new Color3(this.props.color.r, this.props.color.g, this.props.color.b), alpha: this.props.color.a };\r\n } else {\r\n this.state = { color: this.props.color.clone(), alpha: 1 };\r\n }\r\n this._saturationRef = React.createRef();\r\n this._hueRef = React.createRef();\r\n }\r\n\r\n shouldComponentUpdate(nextProps: IColorPickerProps, nextState: IColorPickerState) {\r\n return nextProps.color.toHexString() !== this.props.color.toHexString() || nextState.color.toHexString() !== this.props.color.toHexString();\r\n }\r\n\r\n onSaturationPointerDown(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._evaluateSaturation(evt);\r\n this._isSaturationPointerDown = true;\r\n\r\n evt.currentTarget.setPointerCapture(evt.pointerId);\r\n }\r\n\r\n onSaturationPointerUp(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._isSaturationPointerDown = false;\r\n evt.currentTarget.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n onSaturationPointerMove(evt: React.PointerEvent<HTMLDivElement>) {\r\n if (!this._isSaturationPointerDown) {\r\n return;\r\n }\r\n this._evaluateSaturation(evt);\r\n }\r\n\r\n onHuePointerDown(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._evaluateHue(evt);\r\n this._isHuePointerDown = true;\r\n\r\n evt.currentTarget.setPointerCapture(evt.pointerId);\r\n }\r\n\r\n onHuePointerUp(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._isHuePointerDown = false;\r\n evt.currentTarget.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n onHuePointerMove(evt: React.PointerEvent<HTMLDivElement>) {\r\n if (!this._isHuePointerDown) {\r\n return;\r\n }\r\n this._evaluateHue(evt);\r\n }\r\n\r\n private _evaluateSaturation(evt: React.PointerEvent<HTMLDivElement>) {\r\n const left = evt.nativeEvent.offsetX;\r\n const top = evt.nativeEvent.offsetY;\r\n\r\n const saturation = Math.min(1, Math.max(0.0001, left / this._saturationRef.current!.clientWidth));\r\n const value = Math.min(1, Math.max(0.0001, 1 - top / this._saturationRef.current!.clientHeight));\r\n\r\n if (this.props.debugMode) {\r\n Logger.Log(\"Saturation: \" + saturation);\r\n Logger.Log(\"Value: \" + value);\r\n }\r\n\r\n const hsv = this.state.color.toHSV();\r\n Color3.HSVtoRGBToRef(hsv.r, saturation, value, this.state.color);\r\n if (this.state.alpha === 0) {\r\n this.setState({ alpha: 1 });\r\n }\r\n this.setState({ color: this.state.color });\r\n }\r\n\r\n private _evaluateHue(evt: React.PointerEvent<HTMLDivElement>) {\r\n const left = evt.nativeEvent.offsetX;\r\n\r\n const hue = 360 * Math.min(0.9999, Math.max(0.0001, left / this._hueRef.current!.clientWidth));\r\n\r\n if (this.props.debugMode) {\r\n Logger.Log(\"Hue: \" + hue);\r\n }\r\n\r\n const hsv = this.state.color.toHSV();\r\n Color3.HSVtoRGBToRef(hue, Math.max(hsv.g, 0.01), Math.max(hsv.b, 0.01), this.state.color);\r\n this.setState({ color: this.state.color });\r\n }\r\n\r\n componentDidUpdate() {\r\n this.raiseOnColorChanged();\r\n }\r\n\r\n raiseOnColorChanged() {\r\n if (!this.props.onColorChanged) {\r\n return;\r\n }\r\n\r\n if (this.props.color instanceof Color4) {\r\n const newColor4 = Color4.FromColor3(this.state.color, this.state.alpha);\r\n\r\n this.props.onColorChanged(newColor4);\r\n\r\n return;\r\n }\r\n\r\n this.props.onColorChanged(this.state.color.clone());\r\n }\r\n\r\n public render() {\r\n const color4 = Color4.FromColor3(this.state.color);\r\n color4.a = this.state.alpha;\r\n const colorHex = color4.toHexString();\r\n const hsv = this.state.color.toHSV();\r\n const colorRef = new Color3();\r\n Color3.HSVtoRGBToRef(hsv.r, 1, 1, colorRef);\r\n const colorHexRef = colorRef.toHexString();\r\n const hasAlpha = this.props.color instanceof Color4;\r\n\r\n return (\r\n <div className={\"color-picker-container\" + (this.props.linearhint ? \" with-hints\" : \"\")}>\r\n <div\r\n className=\"color-picker-saturation\"\r\n onPointerMove={(e) => this.onSaturationPointerMove(e)}\r\n onPointerDown={(e) => this.onSaturationPointerDown(e)}\r\n onPointerUp={(e) => this.onSaturationPointerUp(e)}\r\n ref={this._saturationRef}\r\n style={{\r\n background: colorHexRef,\r\n }}\r\n >\r\n <div className=\"color-picker-saturation-white\"></div>\r\n <div className=\"color-picker-saturation-black\"></div>\r\n <div\r\n className=\"color-picker-saturation-cursor\"\r\n style={{\r\n top: `${-(hsv.b * 100) + 100}%`,\r\n left: `${hsv.g * 100}%`,\r\n }}\r\n ></div>\r\n </div>\r\n <div className=\"color-picker-hue\">\r\n <div\r\n className=\"color-picker-hue-color\"\r\n style={{\r\n background: colorHex,\r\n }}\r\n ></div>\r\n <div\r\n className=\"color-picker-hue-slider\"\r\n ref={this._hueRef}\r\n onPointerMove={(e) => this.onHuePointerMove(e)}\r\n onPointerDown={(e) => this.onHuePointerDown(e)}\r\n onPointerUp={(e) => this.onHuePointerUp(e)}\r\n >\r\n <div\r\n className=\"color-picker-hue-cursor\"\r\n style={{\r\n left: `${(hsv.r / 360.0) * 100}%`,\r\n border: `1px solid ` + colorHexRef,\r\n }}\r\n ></div>\r\n </div>\r\n </div>\r\n <div className=\"color-picker-alpha\"></div>\r\n <div className=\"color-picker-rgb\">\r\n <div className=\"red\">\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"R\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.r * 255)}\r\n onChange={(value) => {\r\n this.state.color.r = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className=\"green\">\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"G\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.g * 255)}\r\n onChange={(value) => {\r\n this.state.color.g = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className=\"blue\">\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"B\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.b * 255)}\r\n onChange={(value) => {\r\n this.state.color.b = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className={\"alpha\" + (hasAlpha ? \"\" : \" grayed\")}>\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"A\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.alpha * 255)}\r\n onChange={(value) => {\r\n this.setState({ alpha: value / 255.0 });\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n </div>\r\n <div className=\"color-picker-hex\">\r\n <div className=\"color-picker-hex-label\">Hex</div>\r\n <div className=\"color-picker-hex-value\">\r\n <HexColor\r\n lockObject={this.props.lockObject}\r\n expectedLength={hasAlpha ? 8 : 6}\r\n value={colorHex}\r\n onChange={(value) => {\r\n if (hasAlpha) {\r\n const color4 = Color4.FromHexString(value);\r\n this.setState({ color: new Color3(color4.r, color4.g, color4.b), alpha: color4.a });\r\n } else {\r\n this.setState({ color: Color3.FromHexString(value) });\r\n }\r\n }}\r\n />\r\n </div>\r\n </div>\r\n {this.props.linearhint && (\r\n <div className=\"color-picker-warning\">\r\n (Note: color is stored in linear mode and was converted to gamma to be displayed here (toGammaSpace() / toLinearSpace()))\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -41,6 +41,7 @@ export class CommandDropdownComponent extends React.Component {
41
41
  }) }))] }, m.label));
42
42
  }
43
43
  else {
44
+ // eslint-disable-next-line no-console
44
45
  return _jsx(FileButtonLineComponent, { label: "Load", onClick: (file) => console.log("file btn clicked"), accept: ".json" }, m.label);
45
46
  }
46
47
  }) }))] })] }));
@@ -1 +1 @@
1
- {"version":3,"file":"CommandDropdownComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/bars/CommandDropdownComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,MAAM,gCAAgC,CAAC;AAoBnD,MAAM,OAAO,wBAAyB,SAAQ,KAAK,CAAC,SAAuF;IACvI,YAAmB,KAAqC;QACpD,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACxD,CAAC;IAEM,MAAM;QACT,OAAO,CACH,8BACK,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CACtB,cACI,SAAS,EAAE,KAAK,CAAC,sBAAsB,EACvC,OAAO,EAAE,GAAG,EAAE;wBACV,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;oBACzC,CAAC,GACE,CACV,EACD,eAAK,SAAS,EAAE,KAAK,CAAC,mBAAmB,aACrC,eACI,SAAS,EAAE,cAAc,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAC7F,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EACzB,OAAO,EAAE,GAAG,EAAE;gCACV,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,KA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AAQ,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;wDACzC,CAAC,YAED,wBAAM,CAAC,GAAO,IAPT,CAAC,CAQJ,CACT,CAAC;gDACN,CAAC,CAAC,GACA,CACT,KAjDI,CAAC,CAAC,KAAK,CAkDV,CACT,CAAC;iCACL;qCAAM;oCACH,OAAO,KAAC,uBAAuB,IAAe,KAAK,EAAC,MAAM,EAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAC,OAAO,IAAxF,CAAC,CAAC,KAAK,CAAoF,CAAC;iCACpI;4BACL,CAAC,CAAC,GACA,CACT,IACC,IACP,CACN,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { FileButtonLineComponent } from \"../lines/FileButtonLineComponent\";\r\nimport { JoinClassNames } from \"../classNames\";\r\n\r\nimport style from \"./CommandDropdown.modules.scss\";\r\n\r\ninterface ICommandDropdownComponentProps {\r\n icon?: string;\r\n tooltip: string;\r\n defaultValue?: string;\r\n items: {\r\n label: string;\r\n icon?: string;\r\n fileButton?: boolean;\r\n onClick?: () => void;\r\n onCheck?: (value: boolean) => void;\r\n storeKey?: string;\r\n isActive?: boolean;\r\n defaultValue?: boolean | string;\r\n subItems?: string[];\r\n }[];\r\n toRight?: boolean;\r\n}\r\n\r\nexport class CommandDropdownComponent extends React.Component<ICommandDropdownComponentProps, { isExpanded: boolean; activeState: string }> {\r\n public constructor(props: ICommandDropdownComponentProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, activeState: \"\" };\r\n }\r\n\r\n public render() {\r\n return (\r\n <>\r\n {this.state.isExpanded && (\r\n <div\r\n className={style.commandDropdownBlocker}\r\n onClick={() => {\r\n this.setState({ isExpanded: false });\r\n }}\r\n ></div>\r\n )}\r\n <div className={style.commandDropdownRoot}>\r\n <div\r\n className={JoinClassNames(style, \"commandDropdown\", this.state.isExpanded ? \"activated\" : \"\")}\r\n title={this.props.tooltip}\r\n onClick={() => {\r\n this.setState({ isExpanded: false });\r\n const newState = !this.state.isExpanded;\r\n const pgHost = document.getElementById(\"embed-host\");\r\n\r\n if (pgHost) {\r\n pgHost.style.zIndex = newState ? \"0\" : \"10\";\r\n }\r\n\r\n this.setState({ isExpanded: newState });\r\n }}\r\n >\r\n {this.props.icon && (\r\n <div className={style.commandDropdownIcon}>\r\n <img src={this.props.icon} />\r\n </div>\r\n )}\r\n {!this.props.icon && <div className={style.commandDropdownActive}></div>}\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className={JoinClassNames(style, \"commandDropdownContent\", this.props.toRight ? \"toRight\" : \"\")}>\r\n {this.props.items.map((m) => {\r\n if (!m.fileButton) {\r\n return (\r\n <div\r\n className={JoinClassNames(style, \"commandDropdownLabel\", m.isActive ? \"active\" : \"\")}\r\n key={m.label}\r\n onClick={() => {\r\n if (!m.onClick) {\r\n this.forceUpdate();\r\n return;\r\n }\r\n if (!m.subItems) {\r\n m.onClick();\r\n\r\n this.setState({ isExpanded: false, activeState: m.label });\r\n }\r\n }}\r\n title={m.label}\r\n >\r\n {!m.icon && <div className={style.commandDropdownLabelText}>{(m.isActive ? \"> \" : \"\") + m.label}</div>}\r\n {m.icon && (\r\n <div className={style.commandDropdownIcon}>\r\n <img src={m.icon} />\r\n </div>\r\n )}\r\n {m.onCheck && (\r\n <input\r\n type=\"checkBox\"\r\n className={style.commandDropdownLabelCheck}\r\n onChange={(evt) => {\r\n this.forceUpdate();\r\n m.onCheck!(evt.target.checked);\r\n }}\r\n checked={false}\r\n />\r\n )}\r\n {m.subItems && <div className={style.commandDropdownArrow}>{\">\"}</div>}\r\n {m.subItems && (\r\n <div className={style.subItems}>\r\n {m.subItems.map((s) => {\r\n return (\r\n <div\r\n key={s}\r\n className={style.subItem}\r\n onClick={() => {\r\n m.onClick!();\r\n this.setState({ isExpanded: false });\r\n }}\r\n >\r\n <div>{s}</div>\r\n </div>\r\n );\r\n })}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n } else {\r\n return <FileButtonLineComponent key={m.label} label=\"Load\" onClick={(file) => console.log(\"file btn clicked\")} accept=\".json\" />;\r\n }\r\n })}\r\n </div>\r\n )}\r\n </div>\r\n </>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandDropdownComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/bars/CommandDropdownComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,MAAM,gCAAgC,CAAC;AAoBnD,MAAM,OAAO,wBAAyB,SAAQ,KAAK,CAAC,SAAuF;IACvI,YAAmB,KAAqC;QACpD,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACxD,CAAC;IAEM,MAAM;QACT,OAAO,CACH,8BACK,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CACtB,cACI,SAAS,EAAE,KAAK,CAAC,sBAAsB,EACvC,OAAO,EAAE,GAAG,EAAE;wBACV,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;oBACzC,CAAC,GACE,CACV,EACD,eAAK,SAAS,EAAE,KAAK,CAAC,mBAAmB,aACrC,eACI,SAAS,EAAE,cAAc,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAC7F,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EACzB,OAAO,EAAE,GAAG,EAAE;gCACV,IAAI,CAAC,QAAQ,C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CAAC;4DACb,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;wDACzC,CAAC,YAED,wBAAM,CAAC,GAAO,IAPT,CAAC,CAQJ,CACT,CAAC;gDACN,CAAC,CAAC,GACA,CACT,KAjDI,CAAC,CAAC,KAAK,CAkDV,CACT,CAAC;iCACL;qCAAM;oCACH,sCAAsC;oCACtC,OAAO,KAAC,uBAAuB,IAAe,KAAK,EAAC,MAAM,EAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAC,OAAO,IAAxF,CAAC,CAAC,KAAK,CAAoF,CAAC;iCACpI;4BACL,CAAC,CAAC,GACA,CACT,IACC,IACP,CACN,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { FileButtonLineComponent } from \"../lines/FileButtonLineComponent\";\r\nimport { JoinClassNames } from \"../classNames\";\r\n\r\nimport style from \"./CommandDropdown.modules.scss\";\r\n\r\ninterface ICommandDropdownComponentProps {\r\n icon?: string;\r\n tooltip: string;\r\n defaultValue?: string;\r\n items: {\r\n label: string;\r\n icon?: string;\r\n fileButton?: boolean;\r\n onClick?: () => void;\r\n onCheck?: (value: boolean) => void;\r\n storeKey?: string;\r\n isActive?: boolean;\r\n defaultValue?: boolean | string;\r\n subItems?: string[];\r\n }[];\r\n toRight?: boolean;\r\n}\r\n\r\nexport class CommandDropdownComponent extends React.Component<ICommandDropdownComponentProps, { isExpanded: boolean; activeState: string }> {\r\n public constructor(props: ICommandDropdownComponentProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, activeState: \"\" };\r\n }\r\n\r\n public render() {\r\n return (\r\n <>\r\n {this.state.isExpanded && (\r\n <div\r\n className={style.commandDropdownBlocker}\r\n onClick={() => {\r\n this.setState({ isExpanded: false });\r\n }}\r\n ></div>\r\n )}\r\n <div className={style.commandDropdownRoot}>\r\n <div\r\n className={JoinClassNames(style, \"commandDropdown\", this.state.isExpanded ? \"activated\" : \"\")}\r\n title={this.props.tooltip}\r\n onClick={() => {\r\n this.setState({ isExpanded: false });\r\n const newState = !this.state.isExpanded;\r\n const pgHost = document.getElementById(\"embed-host\");\r\n\r\n if (pgHost) {\r\n pgHost.style.zIndex = newState ? \"0\" : \"10\";\r\n }\r\n\r\n this.setState({ isExpanded: newState });\r\n }}\r\n >\r\n {this.props.icon && (\r\n <div className={style.commandDropdownIcon}>\r\n <img src={this.props.icon} />\r\n </div>\r\n )}\r\n {!this.props.icon && <div className={style.commandDropdownActive}></div>}\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className={JoinClassNames(style, \"commandDropdownContent\", this.props.toRight ? \"toRight\" : \"\")}>\r\n {this.props.items.map((m) => {\r\n if (!m.fileButton) {\r\n return (\r\n <div\r\n className={JoinClassNames(style, \"commandDropdownLabel\", m.isActive ? \"active\" : \"\")}\r\n key={m.label}\r\n onClick={() => {\r\n if (!m.onClick) {\r\n this.forceUpdate();\r\n return;\r\n }\r\n if (!m.subItems) {\r\n m.onClick();\r\n\r\n this.setState({ isExpanded: false, activeState: m.label });\r\n }\r\n }}\r\n title={m.label}\r\n >\r\n {!m.icon && <div className={style.commandDropdownLabelText}>{(m.isActive ? \"> \" : \"\") + m.label}</div>}\r\n {m.icon && (\r\n <div className={style.commandDropdownIcon}>\r\n <img src={m.icon} />\r\n </div>\r\n )}\r\n {m.onCheck && (\r\n <input\r\n type=\"checkBox\"\r\n className={style.commandDropdownLabelCheck}\r\n onChange={(evt) => {\r\n this.forceUpdate();\r\n m.onCheck!(evt.target.checked);\r\n }}\r\n checked={false}\r\n />\r\n )}\r\n {m.subItems && <div className={style.commandDropdownArrow}>{\">\"}</div>}\r\n {m.subItems && (\r\n <div className={style.subItems}>\r\n {m.subItems.map((s) => {\r\n return (\r\n <div\r\n key={s}\r\n className={style.subItem}\r\n onClick={() => {\r\n m.onClick!();\r\n this.setState({ isExpanded: false });\r\n }}\r\n >\r\n <div>{s}</div>\r\n </div>\r\n );\r\n })}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n } else {\r\n // eslint-disable-next-line no-console\r\n return <FileButtonLineComponent key={m.label} label=\"Load\" onClick={(file) => console.log(\"file btn clicked\")} accept=\".json\" />;\r\n }\r\n })}\r\n </div>\r\n )}\r\n </div>\r\n </>\r\n );\r\n }\r\n}\r\n"]}
@@ -5,6 +5,7 @@ import { ColorComponentEntry } from "./ColorComponentEntry.js";
5
5
  import { HexColor } from "./HexColor.js";
6
6
  import style from "./ColorPicker.modules.scss";
7
7
  import { ClassNames } from "../classNames.js";
8
+ import { Logger } from "@babylonjs/core/Misc/logger.js";
8
9
  /**
9
10
  * Class used to create a color picker
10
11
  */
@@ -59,8 +60,8 @@ export class ColorPicker extends React.Component {
59
60
  const saturation = Math.min(1, Math.max(0.0001, left / this._saturationRef.current.clientWidth));
60
61
  const value = Math.min(1, Math.max(0.0001, 1 - top / this._saturationRef.current.clientHeight));
61
62
  if (this.props.debugMode) {
62
- console.log("Saturation: " + saturation);
63
- console.log("Value: " + value);
63
+ Logger.Log("Saturation: " + saturation);
64
+ Logger.Log("Value: " + value);
64
65
  }
65
66
  const hsv = this.state.color.toHSV();
66
67
  Color3.HSVtoRGBToRef(hsv.r, saturation, value, this.state.color);
@@ -73,7 +74,7 @@ export class ColorPicker extends React.Component {
73
74
  const left = evt.nativeEvent.offsetX;
74
75
  const hue = 360 * Math.min(0.9999, Math.max(0.0001, left / this._hueRef.current.clientWidth));
75
76
  if (this.props.debugMode) {
76
- console.log("Hue: " + hue);
77
+ Logger.Log("Hue: " + hue);
77
78
  }
78
79
  const hsv = this.state.color.toHSV();
79
80
  Color3.HSVtoRGBToRef(hue, Math.max(hsv.g, 0.01), Math.max(hsv.b, 0.01), this.state.color);
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/colorPicker/ColorPicker.tsx"],"names":[],"mappings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EACT,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,EACzC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;oCAChB,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,CAAC,CAAC;oCACxC,IAAI,CAAC,WAAW,EAAE,CAAC;gCACvB,CAAC,GACH,GACA,IACJ,EACN,KAAC,QAAQ,IACL,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAChC,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;wBAChB,IAAI,QAAQ,EAAE;4BACV,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;4BAC3C,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;yBACvF;6BAAM;4BACH,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;yBACzD;oBACL,CAAC,GACH,EACD,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CACtB,cAAK,SAAS,EAAE,KAAK,CAAC,kBAAkB,0IAElC,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { ColorComponentEntry } from \"./ColorComponentEntry\";\r\nimport { HexColor } from \"./HexColor\";\r\nimport type { LockObject } from \"../../tabs/propertyGrids/lockObject\";\r\n\r\nimport style from \"./ColorPicker.modules.scss\";\r\nimport { ClassNames } from \"../classNames\";\r\n\r\n/**\r\n * Interface used to specify creation options for color picker\r\n */\r\nexport interface IColorPickerProps {\r\n color: Color3 | Color4;\r\n linearhint?: boolean;\r\n debugMode?: boolean;\r\n onColorChanged?: (color: Color3 | Color4) => void;\r\n lockObject: LockObject;\r\n backgroundColor?: string;\r\n}\r\n\r\n/**\r\n * Interface used to specify creation options for color picker\r\n */\r\nexport interface IColorPickerState {\r\n color: Color3;\r\n alpha: number;\r\n}\r\n\r\n/**\r\n * Class used to create a color picker\r\n */\r\nexport class ColorPicker extends React.Component<IColorPickerProps, IColorPickerState> {\r\n private _saturationRef: React.RefObject<HTMLDivElement>;\r\n private _hueRef: React.RefObject<HTMLDivElement>;\r\n private _isSaturationPointerDown: boolean;\r\n private _isHuePointerDown: boolean;\r\n\r\n constructor(props: IColorPickerProps) {\r\n super(props);\r\n if (this.props.color instanceof Color4) {\r\n this.state = { color: new Color3(this.props.color.r, this.props.color.g, this.props.color.b), alpha: this.props.color.a };\r\n } else {\r\n this.state = { color: this.props.color.clone(), alpha: 1 };\r\n }\r\n this._saturationRef = React.createRef();\r\n this._hueRef = React.createRef();\r\n }\r\n\r\n shouldComponentUpdate(nextProps: IColorPickerProps, nextState: IColorPickerState) {\r\n return nextProps.color.toHexString() !== this.props.color.toHexString() || nextState.color.toHexString() !== this.props.color.toHexString();\r\n }\r\n\r\n onSaturationPointerDown(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._evaluateSaturation(evt);\r\n this._isSaturationPointerDown = true;\r\n\r\n evt.currentTarget.setPointerCapture(evt.pointerId);\r\n }\r\n\r\n onSaturationPointerUp(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._isSaturationPointerDown = false;\r\n evt.currentTarget.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n onSaturationPointerMove(evt: React.PointerEvent<HTMLDivElement>) {\r\n if (!this._isSaturationPointerDown) {\r\n return;\r\n }\r\n this._evaluateSaturation(evt);\r\n }\r\n\r\n onHuePointerDown(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._evaluateHue(evt);\r\n this._isHuePointerDown = true;\r\n\r\n evt.currentTarget.setPointerCapture(evt.pointerId);\r\n }\r\n\r\n onHuePointerUp(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._isHuePointerDown = false;\r\n evt.currentTarget.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n onHuePointerMove(evt: React.PointerEvent<HTMLDivElement>) {\r\n if (!this._isHuePointerDown) {\r\n return;\r\n }\r\n this._evaluateHue(evt);\r\n }\r\n\r\n private _evaluateSaturation(evt: React.PointerEvent<HTMLDivElement>) {\r\n const left = evt.nativeEvent.offsetX;\r\n const top = evt.nativeEvent.offsetY;\r\n\r\n const saturation = Math.min(1, Math.max(0.0001, left / this._saturationRef.current!.clientWidth));\r\n const value = Math.min(1, Math.max(0.0001, 1 - top / this._saturationRef.current!.clientHeight));\r\n\r\n if (this.props.debugMode) {\r\n console.log(\"Saturation: \" + saturation);\r\n console.log(\"Value: \" + value);\r\n }\r\n\r\n const hsv = this.state.color.toHSV();\r\n Color3.HSVtoRGBToRef(hsv.r, saturation, value, this.state.color);\r\n if (this.state.alpha === 0) {\r\n this.setState({ alpha: 1 });\r\n }\r\n this.setState({ color: this.state.color });\r\n }\r\n\r\n private _evaluateHue(evt: React.PointerEvent<HTMLDivElement>) {\r\n const left = evt.nativeEvent.offsetX;\r\n\r\n const hue = 360 * Math.min(0.9999, Math.max(0.0001, left / this._hueRef.current!.clientWidth));\r\n\r\n if (this.props.debugMode) {\r\n console.log(\"Hue: \" + hue);\r\n }\r\n\r\n const hsv = this.state.color.toHSV();\r\n Color3.HSVtoRGBToRef(hue, Math.max(hsv.g, 0.01), Math.max(hsv.b, 0.01), this.state.color);\r\n this.setState({ color: this.state.color });\r\n }\r\n\r\n componentDidUpdate() {\r\n this.raiseOnColorChanged();\r\n }\r\n\r\n raiseOnColorChanged() {\r\n if (!this.props.onColorChanged) {\r\n return;\r\n }\r\n\r\n if (this.props.color instanceof Color4) {\r\n const newColor4 = Color4.FromColor3(this.state.color, this.state.alpha);\r\n\r\n this.props.onColorChanged(newColor4);\r\n\r\n return;\r\n }\r\n\r\n this.props.onColorChanged(this.state.color.clone());\r\n }\r\n\r\n public render() {\r\n const color4 = Color4.FromColor3(this.state.color);\r\n color4.a = this.state.alpha;\r\n const colorHex = color4.toHexString();\r\n const hsv = this.state.color.toHSV();\r\n const colorRef = new Color3();\r\n Color3.HSVtoRGBToRef(hsv.r, 1, 1, colorRef);\r\n const colorHexRef = colorRef.toHexString();\r\n const hasAlpha = this.props.color instanceof Color4;\r\n\r\n return (\r\n <div\r\n className={ClassNames({ colorPickerContainer: true, withHints: this.props.linearhint }, style)}\r\n style={{ backgroundColor: this.props.backgroundColor || \"inherit\" }}\r\n >\r\n <div\r\n className={style.colorPickerSaturation}\r\n onPointerMove={(e) => this.onSaturationPointerMove(e)}\r\n onPointerDown={(e) => this.onSaturationPointerDown(e)}\r\n onPointerUp={(e) => this.onSaturationPointerUp(e)}\r\n ref={this._saturationRef}\r\n style={{\r\n background: colorHexRef,\r\n }}\r\n >\r\n <div className={style.colorPickerSaturationWhite}></div>\r\n <div className={style.colorPickerSaturationBlack}></div>\r\n <div\r\n className={style.colorPickerSaturationCursor}\r\n style={{\r\n top: `${-(hsv.b * 100) + 100}%`,\r\n left: `${hsv.g * 100}%`,\r\n }}\r\n ></div>\r\n </div>\r\n <div className={style.colorPickerHue}>\r\n <div\r\n className={style.colorPickerHueColor}\r\n style={{\r\n background: colorHex,\r\n }}\r\n ></div>\r\n <div\r\n className={style.colorPickerHueSlider}\r\n ref={this._hueRef}\r\n onPointerMove={(e) => this.onHuePointerMove(e)}\r\n onPointerDown={(e) => this.onHuePointerDown(e)}\r\n onPointerUp={(e) => this.onHuePointerUp(e)}\r\n >\r\n <div\r\n className={style.colorPickerHueCursor}\r\n style={{\r\n left: `${(hsv.r / 360.0) * 100}%`,\r\n border: `1px solid ` + colorHexRef,\r\n }}\r\n ></div>\r\n </div>\r\n </div>\r\n {/* <div className=\"color-picker-alpha\"></div> */}\r\n <div className={style.colorPickerRgb}>\r\n <div className={style.red}>\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"R\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.r * 255)}\r\n onChange={(value) => {\r\n this.state.color.r = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className={style.green}>\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"G\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.g * 255)}\r\n onChange={(value) => {\r\n this.state.color.g = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className={style.blue}>\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"B\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.b * 255)}\r\n onChange={(value) => {\r\n this.state.color.b = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className={ClassNames({ alpha: true, grayed: hasAlpha }, style)}>\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"A\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.alpha * 255)}\r\n onChange={(value) => {\r\n this.setState({ alpha: value / 255.0 });\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n </div>\r\n <HexColor\r\n lockObject={this.props.lockObject}\r\n expectedLength={hasAlpha ? 8 : 6}\r\n value={colorHex}\r\n onChange={(value) => {\r\n if (hasAlpha) {\r\n const color4 = Color4.FromHexString(value);\r\n this.setState({ color: new Color3(color4.r, color4.g, color4.b), alpha: color4.a });\r\n } else {\r\n this.setState({ color: Color3.FromHexString(value) });\r\n }\r\n }}\r\n />\r\n {this.props.linearhint && (\r\n <div className={style.colorPickerWarning}>\r\n (Note: color is stored in linear mode and was converted to gamma to be displayed here (toGammaSpace() / toLinearSpace()))\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/colorPicker/ColorPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,KAAK,MAAM,4BAA4B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAsB1C;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,SAA+C;IAMlF,YAAY,KAAwB;QAChC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,YAAY,MAAM,EAAE;YACpC,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;SAC7H;aAAM;YACH,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;SAC9D;QACD,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACxC,IAAI,CAAC,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AC,KAAK,CAAC,UAAU,IAAI,CACtB,cAAK,SAAS,EAAE,KAAK,CAAC,kBAAkB,0IAElC,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { ColorComponentEntry } from \"./ColorComponentEntry\";\r\nimport { HexColor } from \"./HexColor\";\r\nimport type { LockObject } from \"../../tabs/propertyGrids/lockObject\";\r\n\r\nimport style from \"./ColorPicker.modules.scss\";\r\nimport { ClassNames } from \"../classNames\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Interface used to specify creation options for color picker\r\n */\r\nexport interface IColorPickerProps {\r\n color: Color3 | Color4;\r\n linearhint?: boolean;\r\n debugMode?: boolean;\r\n onColorChanged?: (color: Color3 | Color4) => void;\r\n lockObject: LockObject;\r\n backgroundColor?: string;\r\n}\r\n\r\n/**\r\n * Interface used to specify creation options for color picker\r\n */\r\nexport interface IColorPickerState {\r\n color: Color3;\r\n alpha: number;\r\n}\r\n\r\n/**\r\n * Class used to create a color picker\r\n */\r\nexport class ColorPicker extends React.Component<IColorPickerProps, IColorPickerState> {\r\n private _saturationRef: React.RefObject<HTMLDivElement>;\r\n private _hueRef: React.RefObject<HTMLDivElement>;\r\n private _isSaturationPointerDown: boolean;\r\n private _isHuePointerDown: boolean;\r\n\r\n constructor(props: IColorPickerProps) {\r\n super(props);\r\n if (this.props.color instanceof Color4) {\r\n this.state = { color: new Color3(this.props.color.r, this.props.color.g, this.props.color.b), alpha: this.props.color.a };\r\n } else {\r\n this.state = { color: this.props.color.clone(), alpha: 1 };\r\n }\r\n this._saturationRef = React.createRef();\r\n this._hueRef = React.createRef();\r\n }\r\n\r\n shouldComponentUpdate(nextProps: IColorPickerProps, nextState: IColorPickerState) {\r\n return nextProps.color.toHexString() !== this.props.color.toHexString() || nextState.color.toHexString() !== this.props.color.toHexString();\r\n }\r\n\r\n onSaturationPointerDown(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._evaluateSaturation(evt);\r\n this._isSaturationPointerDown = true;\r\n\r\n evt.currentTarget.setPointerCapture(evt.pointerId);\r\n }\r\n\r\n onSaturationPointerUp(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._isSaturationPointerDown = false;\r\n evt.currentTarget.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n onSaturationPointerMove(evt: React.PointerEvent<HTMLDivElement>) {\r\n if (!this._isSaturationPointerDown) {\r\n return;\r\n }\r\n this._evaluateSaturation(evt);\r\n }\r\n\r\n onHuePointerDown(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._evaluateHue(evt);\r\n this._isHuePointerDown = true;\r\n\r\n evt.currentTarget.setPointerCapture(evt.pointerId);\r\n }\r\n\r\n onHuePointerUp(evt: React.PointerEvent<HTMLDivElement>) {\r\n this._isHuePointerDown = false;\r\n evt.currentTarget.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n onHuePointerMove(evt: React.PointerEvent<HTMLDivElement>) {\r\n if (!this._isHuePointerDown) {\r\n return;\r\n }\r\n this._evaluateHue(evt);\r\n }\r\n\r\n private _evaluateSaturation(evt: React.PointerEvent<HTMLDivElement>) {\r\n const left = evt.nativeEvent.offsetX;\r\n const top = evt.nativeEvent.offsetY;\r\n\r\n const saturation = Math.min(1, Math.max(0.0001, left / this._saturationRef.current!.clientWidth));\r\n const value = Math.min(1, Math.max(0.0001, 1 - top / this._saturationRef.current!.clientHeight));\r\n\r\n if (this.props.debugMode) {\r\n Logger.Log(\"Saturation: \" + saturation);\r\n Logger.Log(\"Value: \" + value);\r\n }\r\n\r\n const hsv = this.state.color.toHSV();\r\n Color3.HSVtoRGBToRef(hsv.r, saturation, value, this.state.color);\r\n if (this.state.alpha === 0) {\r\n this.setState({ alpha: 1 });\r\n }\r\n this.setState({ color: this.state.color });\r\n }\r\n\r\n private _evaluateHue(evt: React.PointerEvent<HTMLDivElement>) {\r\n const left = evt.nativeEvent.offsetX;\r\n\r\n const hue = 360 * Math.min(0.9999, Math.max(0.0001, left / this._hueRef.current!.clientWidth));\r\n\r\n if (this.props.debugMode) {\r\n Logger.Log(\"Hue: \" + hue);\r\n }\r\n\r\n const hsv = this.state.color.toHSV();\r\n Color3.HSVtoRGBToRef(hue, Math.max(hsv.g, 0.01), Math.max(hsv.b, 0.01), this.state.color);\r\n this.setState({ color: this.state.color });\r\n }\r\n\r\n componentDidUpdate() {\r\n this.raiseOnColorChanged();\r\n }\r\n\r\n raiseOnColorChanged() {\r\n if (!this.props.onColorChanged) {\r\n return;\r\n }\r\n\r\n if (this.props.color instanceof Color4) {\r\n const newColor4 = Color4.FromColor3(this.state.color, this.state.alpha);\r\n\r\n this.props.onColorChanged(newColor4);\r\n\r\n return;\r\n }\r\n\r\n this.props.onColorChanged(this.state.color.clone());\r\n }\r\n\r\n public render() {\r\n const color4 = Color4.FromColor3(this.state.color);\r\n color4.a = this.state.alpha;\r\n const colorHex = color4.toHexString();\r\n const hsv = this.state.color.toHSV();\r\n const colorRef = new Color3();\r\n Color3.HSVtoRGBToRef(hsv.r, 1, 1, colorRef);\r\n const colorHexRef = colorRef.toHexString();\r\n const hasAlpha = this.props.color instanceof Color4;\r\n\r\n return (\r\n <div\r\n className={ClassNames({ colorPickerContainer: true, withHints: this.props.linearhint }, style)}\r\n style={{ backgroundColor: this.props.backgroundColor || \"inherit\" }}\r\n >\r\n <div\r\n className={style.colorPickerSaturation}\r\n onPointerMove={(e) => this.onSaturationPointerMove(e)}\r\n onPointerDown={(e) => this.onSaturationPointerDown(e)}\r\n onPointerUp={(e) => this.onSaturationPointerUp(e)}\r\n ref={this._saturationRef}\r\n style={{\r\n background: colorHexRef,\r\n }}\r\n >\r\n <div className={style.colorPickerSaturationWhite}></div>\r\n <div className={style.colorPickerSaturationBlack}></div>\r\n <div\r\n className={style.colorPickerSaturationCursor}\r\n style={{\r\n top: `${-(hsv.b * 100) + 100}%`,\r\n left: `${hsv.g * 100}%`,\r\n }}\r\n ></div>\r\n </div>\r\n <div className={style.colorPickerHue}>\r\n <div\r\n className={style.colorPickerHueColor}\r\n style={{\r\n background: colorHex,\r\n }}\r\n ></div>\r\n <div\r\n className={style.colorPickerHueSlider}\r\n ref={this._hueRef}\r\n onPointerMove={(e) => this.onHuePointerMove(e)}\r\n onPointerDown={(e) => this.onHuePointerDown(e)}\r\n onPointerUp={(e) => this.onHuePointerUp(e)}\r\n >\r\n <div\r\n className={style.colorPickerHueCursor}\r\n style={{\r\n left: `${(hsv.r / 360.0) * 100}%`,\r\n border: `1px solid ` + colorHexRef,\r\n }}\r\n ></div>\r\n </div>\r\n </div>\r\n {/* <div className=\"color-picker-alpha\"></div> */}\r\n <div className={style.colorPickerRgb}>\r\n <div className={style.red}>\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"R\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.r * 255)}\r\n onChange={(value) => {\r\n this.state.color.r = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className={style.green}>\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"G\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.g * 255)}\r\n onChange={(value) => {\r\n this.state.color.g = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className={style.blue}>\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"B\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.color.b * 255)}\r\n onChange={(value) => {\r\n this.state.color.b = value / 255.0;\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n <div className={ClassNames({ alpha: true, grayed: hasAlpha }, style)}>\r\n <ColorComponentEntry\r\n lockObject={this.props.lockObject}\r\n label=\"A\"\r\n min={0}\r\n max={255}\r\n value={Math.round(this.state.alpha * 255)}\r\n onChange={(value) => {\r\n this.setState({ alpha: value / 255.0 });\r\n this.forceUpdate();\r\n }}\r\n />\r\n </div>\r\n </div>\r\n <HexColor\r\n lockObject={this.props.lockObject}\r\n expectedLength={hasAlpha ? 8 : 6}\r\n value={colorHex}\r\n onChange={(value) => {\r\n if (hasAlpha) {\r\n const color4 = Color4.FromHexString(value);\r\n this.setState({ color: new Color3(color4.r, color4.g, color4.b), alpha: color4.a });\r\n } else {\r\n this.setState({ color: Color3.FromHexString(value) });\r\n }\r\n }}\r\n />\r\n {this.props.linearhint && (\r\n <div className={style.colorPickerWarning}>\r\n (Note: color is stored in linear mode and was converted to gamma to be displayed here (toGammaSpace() / toLinearSpace()))\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
package/lines/popup.js CHANGED
@@ -60,6 +60,7 @@ export class Popup {
60
60
  }
61
61
  }
62
62
  catch (e) {
63
+ // eslint-disable-next-line no-console
63
64
  console.log(e);
64
65
  }
65
66
  }
@@ -1 +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,CA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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"]}
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,IAAI,CAAC;SACf;QAED,MAAM,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC;QAE5C,OAAO;QACP,MAAM,SAAS,GAAG,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC,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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,sCAAsC;gBACtC,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 // eslint-disable-next-line no-console\r\n console.log(e);\r\n }\r\n }\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/shared-ui-components",
3
- "version": "6.34.1",
3
+ "version": "6.34.3",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -3,6 +3,7 @@ export default { component: CommandBarComponent };
3
3
  // Default rendering function.
4
4
  export const Default = {};
5
5
  const artBoardColorChange = (color) => {
6
+ // eslint-disable-next-line no-console
6
7
  console.log("new color", color);
7
8
  };
8
9
  // With Artboard color
@@ -1 +1 @@
1
- {"version":3,"file":"CommandBarComponent.stories.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/stories/bars/CommandBarComponent.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAGhF,eAAe,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;AAElD,8BAA8B;AAC9B,MAAM,CAAC,MAAM,OAAO,GAAyC,EAAE,CAAC;AAEhE,MAAM,mBAAmB,GAAG,CAAC,KAAa,EAAE,EAAE;IAC1C,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,sBAAsB;AACtB,MAAM,CAAC,MAAM,iBAAiB,GAAyC;IACnE,GAAG,OAAO;IACV,UAAU,EAAE,EAAE,sBAAsB,EAAE,mBAAmB,EAAE;CAC9D,CAAC","sourcesContent":["import { CommandBarComponent } from \"../../components/bars/CommandBarComponent\";\r\nimport type { StoryObj } from \"@storybook/react\";\r\n\r\nexport default { component: CommandBarComponent };\r\n\r\n// Default rendering function.\r\nexport const Default: StoryObj<typeof CommandBarComponent> = {};\r\n\r\nconst artBoardColorChange = (color: string) => {\r\n console.log(\"new color\", color);\r\n};\r\n\r\n// With Artboard color\r\nexport const WithArtboardColor: StoryObj<typeof CommandBarComponent> = {\r\n ...Default,\r\n parameters: { onArtboardColorChanged: artBoardColorChange },\r\n};\r\n"]}
1
+ {"version":3,"file":"CommandBarComponent.stories.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/stories/bars/CommandBarComponent.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAGhF,eAAe,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;AAElD,8BAA8B;AAC9B,MAAM,CAAC,MAAM,OAAO,GAAyC,EAAE,CAAC;AAEhE,MAAM,mBAAmB,GAAG,CAAC,KAAa,EAAE,EAAE;IAC1C,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,sBAAsB;AACtB,MAAM,CAAC,MAAM,iBAAiB,GAAyC;IACnE,GAAG,OAAO;IACV,UAAU,EAAE,EAAE,sBAAsB,EAAE,mBAAmB,EAAE;CAC9D,CAAC","sourcesContent":["import { CommandBarComponent } from \"../../components/bars/CommandBarComponent\";\r\nimport type { StoryObj } from \"@storybook/react\";\r\n\r\nexport default { component: CommandBarComponent };\r\n\r\n// Default rendering function.\r\nexport const Default: StoryObj<typeof CommandBarComponent> = {};\r\n\r\nconst artBoardColorChange = (color: string) => {\r\n // eslint-disable-next-line no-console\r\n console.log(\"new color\", color);\r\n};\r\n\r\n// With Artboard color\r\nexport const WithArtboardColor: StoryObj<typeof CommandBarComponent> = {\r\n ...Default,\r\n parameters: { onArtboardColorChanged: artBoardColorChange },\r\n};\r\n"]}