@babylonjs/shared-ui-components 9.36.1-preview.163731020 → 9.37.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.
@@ -20,9 +20,11 @@ export declare class ColorPickerLineComponent extends React.Component<IColorPick
20
20
  private _floatRef;
21
21
  private _floatHostRef;
22
22
  private _coverRef;
23
+ private _latestColor;
23
24
  constructor(props: IColorPickerLineComponentProps);
24
25
  syncPositions(): void;
25
26
  shouldComponentUpdate(nextProps: IColorPickerLineComponentProps, nextState: IColorPickerComponentState): boolean;
27
+ private _areSameColor;
26
28
  getHexString(props?: Readonly<IColorPickerLineComponentProps>): string;
27
29
  componentDidUpdate(): void;
28
30
  componentDidMount(): void;
@@ -5,6 +5,7 @@ import * as style from "./ColorPickerLineComponent.module.scss";
5
5
  export class ColorPickerLineComponent extends React.Component {
6
6
  constructor(props) {
7
7
  super(props);
8
+ this._latestColor = props.value;
8
9
  this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };
9
10
  this._floatRef = React.createRef();
10
11
  this._floatHostRef = React.createRef();
@@ -30,12 +31,21 @@ export class ColorPickerLineComponent extends React.Component {
30
31
  }
31
32
  }
32
33
  shouldComponentUpdate(nextProps, nextState) {
33
- const diffProps = this.getHexString(nextProps) !== this.getHexString();
34
+ const diffProps = !this._areSameColor(nextProps.value, this.props.value);
34
35
  if (diffProps) {
35
- nextState.color = nextProps.value;
36
+ // Cache the latest prop color for when the picker next opens. Don't sync nextState.color
37
+ // here: passing a new color to an already-open ColorPicker can trigger onColorChanged from
38
+ // a prop-driven update rather than user interaction.
39
+ this._latestColor = nextProps.value;
36
40
  nextState.hex = this.getHexString(nextProps);
37
41
  }
38
- return diffProps || nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;
42
+ // Only rerender when what is displayed changes. A raw value change that keeps the same hex
43
+ // (HDR components clamp to the same string) must not rerender an open picker, because the
44
+ // picker's componentDidUpdate reports its current color back through onColorChanged.
45
+ return nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;
46
+ }
47
+ _areSameColor(a, b) {
48
+ return a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a;
39
49
  }
40
50
  getHexString(props = this.props) {
41
51
  return props.value.toHexString();
@@ -47,7 +57,7 @@ export class ColorPickerLineComponent extends React.Component {
47
57
  this.syncPositions();
48
58
  }
49
59
  render() {
50
- return (_jsxs("div", { className: style.colorPicker, children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: style.colorRectBackground, ref: this._floatHostRef, onClick: () => this.setState({ pickerEnabled: true }), children: _jsx("div", { className: style.colorRect, style: { background: this.state.hex } }) }), this.state.pickerEnabled && (_jsx(_Fragment, { children: _jsx("div", { ref: this._coverRef, className: style.colorPickerCover, onClick: (evt) => {
60
+ return (_jsxs("div", { className: style.colorPicker, children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: style.colorRectBackground, ref: this._floatHostRef, onClick: () => this.setState({ pickerEnabled: true, color: this._latestColor }), children: _jsx("div", { className: style.colorRect, style: { background: this.state.hex } }) }), this.state.pickerEnabled && (_jsx(_Fragment, { children: _jsx("div", { ref: this._coverRef, className: style.colorPickerCover, onClick: (evt) => {
51
61
  if (evt.target !== this._coverRef.current) {
52
62
  return;
53
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/lines/ColorPickerLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,KAAK,KAAK,MAAM,wCAAwC,CAAC;AAmBhE,MAAM,OAAO,wBAAyB,SAAQ,KAAK,CAAC,SAAqE;IAKrH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AAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,YACrH,cAAK,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAQ,GAC5E,EACL,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CACzB,4BACI,cACI,GAAG,EAAE,IAAI,CAAC,SAAS,EACnB,SAAS,EAAE,KAAK,CAAC,gBAAgB,EACjC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;4BACb,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;gCACxC,OAAO;4BACX,CAAC;4BACD,IAAI,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;wBAC5C,CAAC,YAED,cAAK,SAAS,EAAE,KAAK,CAAC,gBAAgB,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,YACvD,KAAC,oBAAoB,IACjB,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,EAC3C,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,IAAK,EAAU,EAChD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,cAAc,EAAE,CAAC,KAAsB,EAAE,EAAE;oCACvC,MAAM,GAAG,GAAW,KAAK,CAAC,WAAW,EAAE,CAAC;oCACxC,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;oCAC9B,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;gCACnC,CAAC,GACH,GACA,GACJ,GACP,CACN,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { type Color4, type Color3 } from \"core/Maths/math.color\";\r\nimport { ColorPickerComponent } from \"../colorPicker/ColorPicker\";\r\nimport { type LockObject } from \"../../tabs/propertyGrids/lockObject\";\r\nimport * as style from \"./ColorPickerLineComponent.module.scss\";\r\n\r\nexport interface IColorPickerLineComponentProps {\r\n value: Color4 | Color3;\r\n linearHint?: boolean;\r\n onColorChanged: (newOne: string) => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n shouldPopRight?: boolean;\r\n lockObject?: LockObject;\r\n backgroundColor?: string;\r\n}\r\n\r\ninterface IColorPickerComponentState {\r\n pickerEnabled: boolean;\r\n color: Color3 | Color4;\r\n hex: string;\r\n}\r\n\r\nexport class ColorPickerLineComponent extends React.Component<IColorPickerLineComponentProps, IColorPickerComponentState> {\r\n private _floatRef: React.RefObject<HTMLDivElement>;\r\n private _floatHostRef: React.RefObject<HTMLDivElement>;\r\n private _coverRef: React.RefObject<HTMLDivElement>;\r\n\r\n constructor(props: IColorPickerLineComponentProps) {\r\n super(props);\r\n\r\n this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };\r\n\r\n this._floatRef = React.createRef();\r\n this._floatHostRef = React.createRef();\r\n this._coverRef = React.createRef();\r\n }\r\n\r\n syncPositions() {\r\n const div = this._floatRef.current as HTMLDivElement;\r\n const host = this._floatHostRef.current as HTMLDivElement;\r\n\r\n if (!div || !host) {\r\n return;\r\n }\r\n\r\n let top = host.getBoundingClientRect().top;\r\n const height = div.getBoundingClientRect().height;\r\n\r\n if (top + height + 10 > window.innerHeight) {\r\n top = window.innerHeight - height - 10;\r\n }\r\n\r\n div.style.top = top + \"px\";\r\n if (!this.props.shouldPopRight) {\r\n div.style.left = host.getBoundingClientRect().left - div.getBoundingClientRect().width + \"px\";\r\n } else {\r\n div.style.left = host.getBoundingClientRect().left + \"px\";\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorPickerLineComponentProps, nextState: IColorPickerComponentState) {\r\n const diffProps = this.getHexString(nextProps) !== this.getHexString();\r\n\r\n if (diffProps) {\r\n nextState.color = nextProps.value;\r\n nextState.hex = this.getHexString(nextProps);\r\n }\r\n\r\n return diffProps || nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;\r\n }\r\n\r\n getHexString(props = this.props) {\r\n return props.value.toHexString();\r\n }\r\n\r\n override componentDidUpdate() {\r\n this.syncPositions();\r\n }\r\n\r\n override componentDidMount() {\r\n this.syncPositions();\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className={style.colorPicker}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className={style.colorRectBackground} ref={this._floatHostRef} onClick={() => this.setState({ pickerEnabled: true })}>\r\n <div className={style.colorRect} style={{ background: this.state.hex }}></div>\r\n </div>\r\n {this.state.pickerEnabled && (\r\n <>\r\n <div\r\n ref={this._coverRef}\r\n className={style.colorPickerCover}\r\n onClick={(evt) => {\r\n if (evt.target !== this._coverRef.current) {\r\n return;\r\n }\r\n this.setState({ pickerEnabled: false });\r\n }}\r\n >\r\n <div className={style.colorPickerFloat} ref={this._floatRef}>\r\n <ColorPickerComponent\r\n backgroundColor={this.props.backgroundColor}\r\n lockObject={this.props.lockObject || ({} as any)}\r\n color={this.state.color}\r\n linearhint={this.props.linearHint}\r\n onColorChanged={(color: Color3 | Color4) => {\r\n const hex: string = color.toHexString();\r\n this.setState({ hex, color });\r\n this.props.onColorChanged(hex);\r\n }}\r\n />\r\n </div>\r\n </div>\r\n </>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ColorPickerLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/lines/ColorPickerLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,KAAK,KAAK,MAAM,wCAAwC,CAAC;AAmBhE,MAAM,OAAO,wBAAyB,SAAQ,KAAK,CA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AC,KAAK,CAAC,KAAK,EACvB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,cAAc,EAAE,CAAC,KAAsB,EAAE,EAAE;oCACvC,MAAM,GAAG,GAAW,KAAK,CAAC,WAAW,EAAE,CAAC;oCACxC,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;oCAC9B,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;gCACnC,CAAC,GACH,GACA,GACJ,GACP,CACN,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { type Color4, type Color3 } from \"core/Maths/math.color\";\r\nimport { ColorPickerComponent } from \"../colorPicker/ColorPicker\";\r\nimport { type LockObject } from \"../../tabs/propertyGrids/lockObject\";\r\nimport * as style from \"./ColorPickerLineComponent.module.scss\";\r\n\r\nexport interface IColorPickerLineComponentProps {\r\n value: Color4 | Color3;\r\n linearHint?: boolean;\r\n onColorChanged: (newOne: string) => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n shouldPopRight?: boolean;\r\n lockObject?: LockObject;\r\n backgroundColor?: string;\r\n}\r\n\r\ninterface IColorPickerComponentState {\r\n pickerEnabled: boolean;\r\n color: Color3 | Color4;\r\n hex: string;\r\n}\r\n\r\nexport class ColorPickerLineComponent extends React.Component<IColorPickerLineComponentProps, IColorPickerComponentState> {\r\n private _floatRef: React.RefObject<HTMLDivElement>;\r\n private _floatHostRef: React.RefObject<HTMLDivElement>;\r\n private _coverRef: React.RefObject<HTMLDivElement>;\r\n private _latestColor: Color3 | Color4;\r\n\r\n constructor(props: IColorPickerLineComponentProps) {\r\n super(props);\r\n\r\n this._latestColor = props.value;\r\n this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };\r\n\r\n this._floatRef = React.createRef();\r\n this._floatHostRef = React.createRef();\r\n this._coverRef = React.createRef();\r\n }\r\n\r\n syncPositions() {\r\n const div = this._floatRef.current as HTMLDivElement;\r\n const host = this._floatHostRef.current as HTMLDivElement;\r\n\r\n if (!div || !host) {\r\n return;\r\n }\r\n\r\n let top = host.getBoundingClientRect().top;\r\n const height = div.getBoundingClientRect().height;\r\n\r\n if (top + height + 10 > window.innerHeight) {\r\n top = window.innerHeight - height - 10;\r\n }\r\n\r\n div.style.top = top + \"px\";\r\n if (!this.props.shouldPopRight) {\r\n div.style.left = host.getBoundingClientRect().left - div.getBoundingClientRect().width + \"px\";\r\n } else {\r\n div.style.left = host.getBoundingClientRect().left + \"px\";\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorPickerLineComponentProps, nextState: IColorPickerComponentState) {\r\n const diffProps = !this._areSameColor(nextProps.value, this.props.value);\r\n\r\n if (diffProps) {\r\n // Cache the latest prop color for when the picker next opens. Don't sync nextState.color\r\n // here: passing a new color to an already-open ColorPicker can trigger onColorChanged from\r\n // a prop-driven update rather than user interaction.\r\n this._latestColor = nextProps.value;\r\n nextState.hex = this.getHexString(nextProps);\r\n }\r\n\r\n // Only rerender when what is displayed changes. A raw value change that keeps the same hex\r\n // (HDR components clamp to the same string) must not rerender an open picker, because the\r\n // picker's componentDidUpdate reports its current color back through onColorChanged.\r\n return nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;\r\n }\r\n\r\n private _areSameColor(a: Color3 | Color4, b: Color3 | Color4) {\r\n return a.r === b.r && a.g === b.g && a.b === b.b && (a as Color4).a === (b as Color4).a;\r\n }\r\n\r\n getHexString(props = this.props) {\r\n return props.value.toHexString();\r\n }\r\n\r\n override componentDidUpdate() {\r\n this.syncPositions();\r\n }\r\n\r\n override componentDidMount() {\r\n this.syncPositions();\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className={style.colorPicker}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className={style.colorRectBackground} ref={this._floatHostRef} onClick={() => this.setState({ pickerEnabled: true, color: this._latestColor })}>\r\n <div className={style.colorRect} style={{ background: this.state.hex }}></div>\r\n </div>\r\n {this.state.pickerEnabled && (\r\n <>\r\n <div\r\n ref={this._coverRef}\r\n className={style.colorPickerCover}\r\n onClick={(evt) => {\r\n if (evt.target !== this._coverRef.current) {\r\n return;\r\n }\r\n this.setState({ pickerEnabled: false });\r\n }}\r\n >\r\n <div className={style.colorPickerFloat} ref={this._floatRef}>\r\n <ColorPickerComponent\r\n backgroundColor={this.props.backgroundColor}\r\n lockObject={this.props.lockObject || ({} as any)}\r\n color={this.state.color}\r\n linearhint={this.props.linearHint}\r\n onColorChanged={(color: Color3 | Color4) => {\r\n const hex: string = color.toHexString();\r\n this.setState({ hex, color });\r\n this.props.onColorChanged(hex);\r\n }}\r\n />\r\n </div>\r\n </div>\r\n </>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -18,9 +18,11 @@ interface IColorPickerComponentState {
18
18
  export declare class ColorPickerLine extends React.Component<IColorPickerLineProps, IColorPickerComponentState> {
19
19
  private _floatRef;
20
20
  private _floatHostRef;
21
+ private _latestColor;
21
22
  constructor(props: IColorPickerLineProps);
22
23
  syncPositions(): void;
23
24
  shouldComponentUpdate(nextProps: IColorPickerLineProps, nextState: IColorPickerComponentState): boolean;
25
+ private _areSameColor;
24
26
  getHexString(props?: Readonly<IColorPickerLineProps>): string;
25
27
  componentDidUpdate(): void;
26
28
  componentDidMount(): void;
@@ -4,6 +4,7 @@ import { ColorPicker } from "../colorPicker/colorPicker.js";
4
4
  export class ColorPickerLine extends React.Component {
5
5
  constructor(props) {
6
6
  super(props);
7
+ this._latestColor = props.value;
7
8
  this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };
8
9
  this._floatRef = React.createRef();
9
10
  this._floatHostRef = React.createRef();
@@ -28,12 +29,21 @@ export class ColorPickerLine extends React.Component {
28
29
  }
29
30
  }
30
31
  shouldComponentUpdate(nextProps, nextState) {
31
- const diffProps = this.getHexString(nextProps) !== this.getHexString();
32
+ const diffProps = !this._areSameColor(nextProps.value, this.props.value);
32
33
  if (diffProps) {
33
- nextState.color = nextProps.value;
34
+ // Cache the latest prop color for when the picker next opens. Don't sync nextState.color
35
+ // here: passing a new color to an already-open ColorPicker can trigger onColorChanged from
36
+ // a prop-driven update rather than user interaction.
37
+ this._latestColor = nextProps.value;
34
38
  nextState.hex = this.getHexString(nextProps);
35
39
  }
36
- return diffProps || nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;
40
+ // Only rerender when what is displayed changes. A raw value change that keeps the same hex
41
+ // (HDR components clamp to the same string) must not rerender an open picker, because the
42
+ // picker's componentDidUpdate reports its current color back through onColorChanged.
43
+ return nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;
44
+ }
45
+ _areSameColor(a, b) {
46
+ return a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a;
37
47
  }
38
48
  getHexString(props = this.props) {
39
49
  return props.value.toHexString();
@@ -45,7 +55,7 @@ export class ColorPickerLine extends React.Component {
45
55
  this.syncPositions();
46
56
  }
47
57
  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) => {
58
+ 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, color: this._latestColor }), 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
59
  if (evt.target !== this._floatRef.current?.ownerDocument?.querySelector(".color-picker-cover")) {
50
60
  return;
51
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"colorPickerComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/colorPickerComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAmBzD,MAAM,OAAO,eAAgB,SAAQ,KAAK,CAAC,SAA4D;IAInG,YAAY,KAA4B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAE9F,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC3C,CAAC;IAED,aAAa;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,OAAyB,CAAC;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,OAAyB,CAAC;QAE1D,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO;QACX,CAAC;QAED,IAAI,GAAG,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC;QAC3C,MAAM,MAAM,GAAG,GAAG,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC;QAElD,IAAI,GAAG,GAAG,MAAM,GAAG,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;YACzC,GAAG,GAAG,MAAM,CAAC,WAAW,GAAG,MAAM,GAAG,EAAE,CAAC;QAC3C,CAAC;QAED,GAAG,CAAC,KA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c,CAAC,GAAG,CAAC,CAAC;gCACnC,CAAC,GACH,GACA,GACJ,GACP,CACN,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { type Color4, type Color3 } from \"core/Maths/math.color\";\r\nimport { ColorPicker } from \"../colorPicker/colorPicker\";\r\nimport { type LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\nexport interface IColorPickerLineProps {\r\n value: Color4 | Color3;\r\n linearHint?: boolean;\r\n onColorChanged: (newOne: string) => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n shouldPopRight?: boolean;\r\n lockObject?: LockObject;\r\n}\r\n\r\ninterface IColorPickerComponentState {\r\n pickerEnabled: boolean;\r\n color: Color3 | Color4;\r\n hex: string;\r\n}\r\n\r\nexport class ColorPickerLine extends React.Component<IColorPickerLineProps, IColorPickerComponentState> {\r\n private _floatRef: React.RefObject<HTMLDivElement>;\r\n private _floatHostRef: React.RefObject<HTMLDivElement>;\r\n\r\n constructor(props: IColorPickerLineProps) {\r\n super(props);\r\n\r\n this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };\r\n\r\n this._floatRef = React.createRef();\r\n this._floatHostRef = React.createRef();\r\n }\r\n\r\n syncPositions() {\r\n const div = this._floatRef.current as HTMLDivElement;\r\n const host = this._floatHostRef.current as HTMLDivElement;\r\n\r\n if (!div || !host) {\r\n return;\r\n }\r\n\r\n let top = host.getBoundingClientRect().top;\r\n const height = div.getBoundingClientRect().height;\r\n\r\n if (top + height + 10 > window.innerHeight) {\r\n top = window.innerHeight - height - 10;\r\n }\r\n\r\n div.style.top = top + \"px\";\r\n if (!this.props.shouldPopRight) {\r\n div.style.left = host.getBoundingClientRect().left - div.getBoundingClientRect().width + \"px\";\r\n } else {\r\n div.style.left = host.getBoundingClientRect().left + \"px\";\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorPickerLineProps, nextState: IColorPickerComponentState) {\r\n const diffProps = this.getHexString(nextProps) !== this.getHexString();\r\n\r\n if (diffProps) {\r\n nextState.color = nextProps.value;\r\n nextState.hex = this.getHexString(nextProps);\r\n }\r\n\r\n return diffProps || nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;\r\n }\r\n\r\n getHexString(props = this.props) {\r\n return props.value.toHexString();\r\n }\r\n\r\n override componentDidUpdate() {\r\n this.syncPositions();\r\n }\r\n\r\n override componentDidMount() {\r\n this.syncPositions();\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className=\"color-picker\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"color-rect-background\" ref={this._floatHostRef} onClick={() => this.setState({ pickerEnabled: true })}>\r\n <div className=\"color-rect\" style={{ background: this.state.hex }}></div>\r\n </div>\r\n {this.state.pickerEnabled && (\r\n <>\r\n <div\r\n className=\"color-picker-cover\"\r\n onClick={(evt) => {\r\n if (evt.target !== this._floatRef.current?.ownerDocument?.querySelector(\".color-picker-cover\")) {\r\n return;\r\n }\r\n this.setState({ pickerEnabled: false });\r\n }}\r\n >\r\n <div className=\"color-picker-float\" ref={this._floatRef}>\r\n <ColorPicker\r\n lockObject={this.props.lockObject || ({} as any)}\r\n color={this.state.color}\r\n linearhint={this.props.linearHint}\r\n onColorChanged={(color: Color3 | Color4) => {\r\n const hex: string = color.toHexString();\r\n this.setState({ hex, color });\r\n this.props.onColorChanged(hex);\r\n }}\r\n />\r\n </div>\r\n </div>\r\n </>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"colorPickerComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/colorPickerComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAmBzD,MAAM,OAAO,eAAgB,SAAQ,KAAK,CAAC,SAA4D;IAKnG,Y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C,QAAQ,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;oCAC9B,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;gCACnC,CAAC,GACH,GACA,GACJ,GACP,CACN,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { type Color4, type Color3 } from \"core/Maths/math.color\";\r\nimport { ColorPicker } from \"../colorPicker/colorPicker\";\r\nimport { type LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\nexport interface IColorPickerLineProps {\r\n value: Color4 | Color3;\r\n linearHint?: boolean;\r\n onColorChanged: (newOne: string) => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n shouldPopRight?: boolean;\r\n lockObject?: LockObject;\r\n}\r\n\r\ninterface IColorPickerComponentState {\r\n pickerEnabled: boolean;\r\n color: Color3 | Color4;\r\n hex: string;\r\n}\r\n\r\nexport class ColorPickerLine extends React.Component<IColorPickerLineProps, IColorPickerComponentState> {\r\n private _floatRef: React.RefObject<HTMLDivElement>;\r\n private _floatHostRef: React.RefObject<HTMLDivElement>;\r\n private _latestColor: Color3 | Color4;\r\n\r\n constructor(props: IColorPickerLineProps) {\r\n super(props);\r\n\r\n this._latestColor = props.value;\r\n this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };\r\n\r\n this._floatRef = React.createRef();\r\n this._floatHostRef = React.createRef();\r\n }\r\n\r\n syncPositions() {\r\n const div = this._floatRef.current as HTMLDivElement;\r\n const host = this._floatHostRef.current as HTMLDivElement;\r\n\r\n if (!div || !host) {\r\n return;\r\n }\r\n\r\n let top = host.getBoundingClientRect().top;\r\n const height = div.getBoundingClientRect().height;\r\n\r\n if (top + height + 10 > window.innerHeight) {\r\n top = window.innerHeight - height - 10;\r\n }\r\n\r\n div.style.top = top + \"px\";\r\n if (!this.props.shouldPopRight) {\r\n div.style.left = host.getBoundingClientRect().left - div.getBoundingClientRect().width + \"px\";\r\n } else {\r\n div.style.left = host.getBoundingClientRect().left + \"px\";\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorPickerLineProps, nextState: IColorPickerComponentState) {\r\n const diffProps = !this._areSameColor(nextProps.value, this.props.value);\r\n\r\n if (diffProps) {\r\n // Cache the latest prop color for when the picker next opens. Don't sync nextState.color\r\n // here: passing a new color to an already-open ColorPicker can trigger onColorChanged from\r\n // a prop-driven update rather than user interaction.\r\n this._latestColor = nextProps.value;\r\n nextState.hex = this.getHexString(nextProps);\r\n }\r\n\r\n // Only rerender when what is displayed changes. A raw value change that keeps the same hex\r\n // (HDR components clamp to the same string) must not rerender an open picker, because the\r\n // picker's componentDidUpdate reports its current color back through onColorChanged.\r\n return nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;\r\n }\r\n\r\n private _areSameColor(a: Color3 | Color4, b: Color3 | Color4) {\r\n return a.r === b.r && a.g === b.g && a.b === b.b && (a as Color4).a === (b as Color4).a;\r\n }\r\n\r\n getHexString(props = this.props) {\r\n return props.value.toHexString();\r\n }\r\n\r\n override componentDidUpdate() {\r\n this.syncPositions();\r\n }\r\n\r\n override componentDidMount() {\r\n this.syncPositions();\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className=\"color-picker\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"color-rect-background\" ref={this._floatHostRef} onClick={() => this.setState({ pickerEnabled: true, color: this._latestColor })}>\r\n <div className=\"color-rect\" style={{ background: this.state.hex }}></div>\r\n </div>\r\n {this.state.pickerEnabled && (\r\n <>\r\n <div\r\n className=\"color-picker-cover\"\r\n onClick={(evt) => {\r\n if (evt.target !== this._floatRef.current?.ownerDocument?.querySelector(\".color-picker-cover\")) {\r\n return;\r\n }\r\n this.setState({ pickerEnabled: false });\r\n }}\r\n >\r\n <div className=\"color-picker-float\" ref={this._floatRef}>\r\n <ColorPicker\r\n lockObject={this.props.lockObject || ({} as any)}\r\n color={this.state.color}\r\n linearhint={this.props.linearHint}\r\n onColorChanged={(color: Color3 | Color4) => {\r\n const hex: string = color.toHexString();\r\n this.setState({ hex, color });\r\n this.props.onColorChanged(hex);\r\n }}\r\n />\r\n </div>\r\n </div>\r\n </>\r\n )}\r\n </div>\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": "9.36.1-preview.163731020",
3
+ "version": "9.37.0",
4
4
  "exports": {
5
5
  "./lite": {
6
6
  "types": "./lite/index.d.ts",
@@ -48,7 +48,7 @@
48
48
  "postcompile": "build-tools -c add-js-to-es6"
49
49
  },
50
50
  "devDependencies": {
51
- "@babylonjs/lite": "1.39.1",
51
+ "@babylonjs/lite": "1.39.3",
52
52
  "@dev/build-tools": "^1.0.0",
53
53
  "@dev/shared-ui-components": "^1.0.0"
54
54
  },
@@ -85,12 +85,12 @@
85
85
  "url": "https://github.com/BabylonJS/Babylon.js/issues"
86
86
  },
87
87
  "publishConfig": {
88
- "tag": "preview"
88
+ "tag": "latest"
89
89
  },
90
90
  "babylonEngineRelease": {
91
91
  "sourceRepository": "https://github.com/BabylonJS/Babylon.js.git",
92
- "sourceCommit": "9495e735517f76d0a9a3661089ecf8f8d7e8b653",
93
- "publisherCommit": "796e9e1f94f8a9915cc9a70072476de1548e951a",
94
- "npmTag": "preview"
92
+ "sourceCommit": "090545f042aa15d85853cfc3d96369f491ea8650",
93
+ "publisherCommit": "09b86c652000c75694181bf68d89ad453c3f59d0",
94
+ "npmTag": "latest"
95
95
  }
96
96
  }