@babylonjs/shared-ui-components 7.52.1 → 7.52.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.
- package/lines/checkBoxLineComponent.d.ts +1 -1
- package/lines/checkBoxLineComponent.js +7 -4
- package/lines/checkBoxLineComponent.js.map +1 -1
- package/lines/colorLineComponent.js +1 -1
- package/lines/colorLineComponent.js.map +1 -1
- package/lines/textLineComponent.d.ts +1 -0
- package/lines/textLineComponent.js +12 -1
- package/lines/textLineComponent.js.map +1 -1
- package/nodeGraphSystem/graphCanvas.js +3 -16
- package/nodeGraphSystem/graphCanvas.js.map +1 -1
- package/nodeGraphSystem/graphNode.d.ts +1 -0
- package/nodeGraphSystem/graphNode.js +30 -5
- package/nodeGraphSystem/graphNode.js.map +1 -1
- package/package.json +1 -1
- package/styleHelper.d.ts +11 -0
- package/styleHelper.js +20 -0
- package/styleHelper.js.map +1 -1
@@ -6,7 +6,7 @@ export interface ICheckBoxLineComponentProps {
|
|
6
6
|
label?: string;
|
7
7
|
target?: any;
|
8
8
|
propertyName?: string;
|
9
|
-
isSelected?: () => boolean;
|
9
|
+
isSelected?: boolean | (() => boolean);
|
10
10
|
onSelect?: (value: boolean) => void;
|
11
11
|
onValueChanged?: () => void;
|
12
12
|
onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
|
@@ -25,8 +25,11 @@ export class CheckBoxLineComponent extends React.Component {
|
|
25
25
|
constructor(props) {
|
26
26
|
super(props);
|
27
27
|
this._localChange = false;
|
28
|
-
if (this.props.isSelected) {
|
29
|
-
this.state = {
|
28
|
+
if (this.props.isSelected !== undefined) {
|
29
|
+
this.state = {
|
30
|
+
isSelected: typeof this.props.isSelected === "boolean" ? this.props.isSelected : this.props.isSelected(),
|
31
|
+
isConflict: false,
|
32
|
+
};
|
30
33
|
}
|
31
34
|
else {
|
32
35
|
this.state = {
|
@@ -40,8 +43,8 @@ export class CheckBoxLineComponent extends React.Component {
|
|
40
43
|
}
|
41
44
|
shouldComponentUpdate(nextProps, nextState) {
|
42
45
|
let selected;
|
43
|
-
if (nextProps.isSelected) {
|
44
|
-
selected = nextProps.isSelected();
|
46
|
+
if (nextProps.isSelected !== undefined) {
|
47
|
+
selected = typeof nextProps.isSelected === "boolean" ? nextProps.isSelected : nextProps.isSelected();
|
45
48
|
}
|
46
49
|
else {
|
47
50
|
selected = nextProps.target[nextProps.propertyName] === true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"checkBoxLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/checkBoxLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAiBxC,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAE/D,MAAM,KAAK,GAAG;IACV,MAAM,EAAE;QACJ,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,mBAAmB;QAC1B,GAAG,EAAE,iBAAiB;KACzB;IACD,MAAM,EAAE;QACJ,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,EAAE,EAAE,WAAW;QACtB,GAAG,EAAE,iBAAiB;KACzB;CACJ,CAAC;AAEF,MAAM,OAAO,qBAAsB,SAAQ,KAAK,CAAC,SAA0G;IAEvJ,YAAY,KAAkC;QAC1C,KAAK,CAAC,KAAK,CAAC,CAAC;QAFT,i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U,EACf,SAAS,EAAE,cAAc,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAClE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAC9B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAC/B,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GACjC,EACF,cAAK,SAAS,EAAC,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAI,IACtD,GACN,CACT,EACD,cAAK,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAC,mBAAmB,YACxF,cAAK,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAC,MAAM,GAAG,GAC/B,IACJ,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"./../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport type { IconDefinition } from \"@fortawesome/fontawesome-common-types\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport copyIcon from \"../imgs/copy.svg\";\r\n\r\nexport interface ICheckBoxLineComponentProps {\r\n label?: string;\r\n target?: any;\r\n propertyName?: string;\r\n isSelected?: () => boolean;\r\n onSelect?: (value: boolean) => void;\r\n onValueChanged?: () => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n disabled?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n faIcons?: { enabled: IconDefinition; disabled: IconDefinition };\r\n large?: boolean;\r\n}\r\n\r\nimport toggleOnIcon40px from \"../imgs/toggleOnIcon_40px.svg\";\r\nimport toggleOffIcon40px from \"../imgs/toggleOffIcon_40px.svg\";\r\nimport toggleOnIcon30px from \"../imgs/toggleOnIcon_30px.svg\";\r\nimport toggleMixedIcon30px from \"../imgs/toggleMixedIcon_30px.svg\";\r\nimport toggleOffIcon30px from \"../imgs/toggleOffIcon_30px.svg\";\r\n\r\nconst Icons = {\r\n size30: {\r\n on: toggleOnIcon30px,\r\n mixed: toggleMixedIcon30px,\r\n off: toggleOffIcon30px,\r\n },\r\n size40: {\r\n on: toggleOnIcon40px,\r\n mixed: \"\", // unneeded\r\n off: toggleOffIcon40px,\r\n },\r\n};\r\n\r\nexport class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponentProps, { isSelected: boolean; isDisabled?: boolean; isConflict: boolean }> {\r\n private _localChange = false;\r\n constructor(props: ICheckBoxLineComponentProps) {\r\n super(props);\r\n\r\n if (this.props.isSelected) {\r\n this.state = { isSelected: this.props.isSelected(), isConflict: false };\r\n } else {\r\n this.state = {\r\n isSelected: this.props.target[this.props.propertyName!] === true,\r\n isConflict: this.props.target[this.props.propertyName!] === conflictingValuesPlaceholder,\r\n };\r\n }\r\n\r\n if (this.props.disabled) {\r\n this.state = { ...this.state, isDisabled: this.props.disabled };\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: ICheckBoxLineComponentProps, nextState: { isSelected: boolean; isDisabled: boolean; isConflict: boolean }) {\r\n let selected: boolean;\r\n\r\n if (nextProps.isSelected) {\r\n selected = nextProps.isSelected!();\r\n } else {\r\n selected = nextProps.target[nextProps.propertyName!] === true;\r\n if (nextProps.target[nextProps.propertyName!] === conflictingValuesPlaceholder) {\r\n nextState.isConflict = true;\r\n }\r\n }\r\n\r\n if (selected !== nextState.isSelected || this._localChange) {\r\n nextState.isSelected = selected;\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.disabled !== nextState.isDisabled) {\r\n return true;\r\n }\r\n\r\n return nextProps.label !== this.props.label || nextProps.target !== this.props.target || nextState.isConflict !== this.state.isConflict;\r\n }\r\n\r\n onChange() {\r\n this._localChange = true;\r\n if (this.props.onSelect) {\r\n this.props.onSelect(!this.state.isSelected);\r\n } else {\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName!,\r\n value: !this.state.isSelected,\r\n initialValue: this.state.isSelected,\r\n });\r\n }\r\n\r\n if (this.props.target && this.props.propertyName) {\r\n this.props.target[this.props.propertyName!] = !this.state.isSelected;\r\n }\r\n }\r\n\r\n if (this.props.onValueChanged) {\r\n this.props.onValueChanged();\r\n }\r\n\r\n this.setState({ isSelected: !this.state.isSelected, isConflict: false });\r\n }\r\n\r\n // Copy to clipboard the code this checkbox actually does\r\n // Example : mesh.checkCollisions = true;\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.target[this.props.propertyName!];\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + value + \";// (debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n override render() {\r\n const icons = this.props.large ? Icons.size40 : Icons.size30;\r\n const icon = this.state.isConflict ? icons.mixed : this.state.isSelected ? icons.on : icons.off;\r\n return (\r\n <div className=\"checkBoxLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {this.props.label && (\r\n <div className=\"label\" title={this.props.iconLabel}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n {this.props.faIcons && (\r\n <FontAwesomeIcon\r\n className={`cbx ${this.props.disabled ? \"disabled\" : \"\"}`}\r\n icon={this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled}\r\n onClick={() => !this.props.disabled && this.onChange()}\r\n />\r\n )}\r\n {!this.props.faIcons && (\r\n <div className=\"checkBox\">\r\n <label className={`container lbl${this.props.disabled ? \" disabled\" : \"\"} ${this.state.isSelected ? \"checked\" : \"\"}`}>\r\n <input\r\n type=\"checkbox\"\r\n className={`cbx hidden ${this.state.isConflict ? \"conflict\" : \"\"}`}\r\n checked={this.state.isSelected}\r\n onChange={() => this.onChange()}\r\n disabled={!!this.props.disabled}\r\n />\r\n <img className=\"icon\" src={icon} alt={this.props.label} />\r\n </label>\r\n </div>\r\n )}\r\n <div className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"checkBoxLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/checkBoxLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAiBxC,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAE/D,MAAM,KAAK,GAAG;IACV,MAAM,EAAE;QACJ,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,mBAAmB;QAC1B,GAAG,EAAE,iBAAiB;KACzB;IACD,MAAM,EAAE;QACJ,EAAE,EAAE,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AAC,QAAQ,EACtF,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,GACxD,CACL,EACA,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CACpB,cAAK,SAAS,EAAC,UAAU,YACrB,iBAAO,SAAS,EAAE,gBAAgB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,aAChH,gBACI,IAAI,EAAC,UAAU,EACf,SAAS,EAAE,cAAc,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAClE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAC9B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAC/B,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GACjC,EACF,cAAK,SAAS,EAAC,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAI,IACtD,GACN,CACT,EACD,cAAK,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAC,mBAAmB,YACxF,cAAK,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAC,MAAM,GAAG,GAC/B,IACJ,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"./../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport type { IconDefinition } from \"@fortawesome/fontawesome-common-types\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport copyIcon from \"../imgs/copy.svg\";\r\n\r\nexport interface ICheckBoxLineComponentProps {\r\n label?: string;\r\n target?: any;\r\n propertyName?: string;\r\n isSelected?: boolean | (() => boolean);\r\n onSelect?: (value: boolean) => void;\r\n onValueChanged?: () => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n disabled?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n faIcons?: { enabled: IconDefinition; disabled: IconDefinition };\r\n large?: boolean;\r\n}\r\n\r\nimport toggleOnIcon40px from \"../imgs/toggleOnIcon_40px.svg\";\r\nimport toggleOffIcon40px from \"../imgs/toggleOffIcon_40px.svg\";\r\nimport toggleOnIcon30px from \"../imgs/toggleOnIcon_30px.svg\";\r\nimport toggleMixedIcon30px from \"../imgs/toggleMixedIcon_30px.svg\";\r\nimport toggleOffIcon30px from \"../imgs/toggleOffIcon_30px.svg\";\r\n\r\nconst Icons = {\r\n size30: {\r\n on: toggleOnIcon30px,\r\n mixed: toggleMixedIcon30px,\r\n off: toggleOffIcon30px,\r\n },\r\n size40: {\r\n on: toggleOnIcon40px,\r\n mixed: \"\", // unneeded\r\n off: toggleOffIcon40px,\r\n },\r\n};\r\n\r\nexport class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponentProps, { isSelected: boolean; isDisabled?: boolean; isConflict: boolean }> {\r\n private _localChange = false;\r\n constructor(props: ICheckBoxLineComponentProps) {\r\n super(props);\r\n\r\n if (this.props.isSelected !== undefined) {\r\n this.state = {\r\n isSelected: typeof this.props.isSelected === \"boolean\" ? this.props.isSelected : this.props.isSelected(),\r\n isConflict: false,\r\n };\r\n } else {\r\n this.state = {\r\n isSelected: this.props.target[this.props.propertyName!] === true,\r\n isConflict: this.props.target[this.props.propertyName!] === conflictingValuesPlaceholder,\r\n };\r\n }\r\n\r\n if (this.props.disabled) {\r\n this.state = { ...this.state, isDisabled: this.props.disabled };\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: ICheckBoxLineComponentProps, nextState: { isSelected: boolean; isDisabled: boolean; isConflict: boolean }) {\r\n let selected: boolean;\r\n\r\n if (nextProps.isSelected !== undefined) {\r\n selected = typeof nextProps.isSelected === \"boolean\" ? nextProps.isSelected : nextProps.isSelected();\r\n } else {\r\n selected = nextProps.target[nextProps.propertyName!] === true;\r\n if (nextProps.target[nextProps.propertyName!] === conflictingValuesPlaceholder) {\r\n nextState.isConflict = true;\r\n }\r\n }\r\n\r\n if (selected !== nextState.isSelected || this._localChange) {\r\n nextState.isSelected = selected;\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.disabled !== nextState.isDisabled) {\r\n return true;\r\n }\r\n\r\n return nextProps.label !== this.props.label || nextProps.target !== this.props.target || nextState.isConflict !== this.state.isConflict;\r\n }\r\n\r\n onChange() {\r\n this._localChange = true;\r\n if (this.props.onSelect) {\r\n this.props.onSelect(!this.state.isSelected);\r\n } else {\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName!,\r\n value: !this.state.isSelected,\r\n initialValue: this.state.isSelected,\r\n });\r\n }\r\n\r\n if (this.props.target && this.props.propertyName) {\r\n this.props.target[this.props.propertyName!] = !this.state.isSelected;\r\n }\r\n }\r\n\r\n if (this.props.onValueChanged) {\r\n this.props.onValueChanged();\r\n }\r\n\r\n this.setState({ isSelected: !this.state.isSelected, isConflict: false });\r\n }\r\n\r\n // Copy to clipboard the code this checkbox actually does\r\n // Example : mesh.checkCollisions = true;\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.target[this.props.propertyName!];\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + value + \";// (debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n override render() {\r\n const icons = this.props.large ? Icons.size40 : Icons.size30;\r\n const icon = this.state.isConflict ? icons.mixed : this.state.isSelected ? icons.on : icons.off;\r\n return (\r\n <div className=\"checkBoxLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {this.props.label && (\r\n <div className=\"label\" title={this.props.iconLabel}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n {this.props.faIcons && (\r\n <FontAwesomeIcon\r\n className={`cbx ${this.props.disabled ? \"disabled\" : \"\"}`}\r\n icon={this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled}\r\n onClick={() => !this.props.disabled && this.onChange()}\r\n />\r\n )}\r\n {!this.props.faIcons && (\r\n <div className=\"checkBox\">\r\n <label className={`container lbl${this.props.disabled ? \" disabled\" : \"\"} ${this.state.isSelected ? \"checked\" : \"\"}`}>\r\n <input\r\n type=\"checkbox\"\r\n className={`cbx hidden ${this.state.isConflict ? \"conflict\" : \"\"}`}\r\n checked={this.state.isSelected}\r\n onChange={() => this.onChange()}\r\n disabled={!!this.props.disabled}\r\n />\r\n <img className=\"icon\" src={icon} alt={this.props.label} />\r\n </label>\r\n </div>\r\n )}\r\n <div className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -151,7 +151,7 @@ export class ColorLine extends React.Component {
|
|
151
151
|
const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
|
152
152
|
return (_jsxs("div", { className: "color3Line", children: [_jsxs("div", { className: "firstLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsx("div", { className: "color3", children: _jsx(ColorPickerLine, { lockObject: this.props.lockObject, linearHint: this.props.isLinear, value: this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color, onColorChanged: (colorString) => {
|
153
153
|
this.setColorFromString(colorString);
|
154
|
-
} }) }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }), this.state.isExpanded && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInput, { lockObject: this.props.lockObject, label: "r", labelTooltip: "Red", value: this.state.color.r, onChange: (value) => this.updateStateR(value) }), _jsx(NumericInput, { lockObject: this.props.lockObject, label: "g", labelTooltip: "Green", value: this.state.color.g, onChange: (value) => this.updateStateG(value) }), _jsx(NumericInput, { lockObject: this.props.lockObject, label: "b", labelTooltip: "Blue", value: this.state.color.b, onChange: (value) => this.updateStateB(value) }), this.props.disableAlpha || (_jsx(NumericInput, { lockObject: this.props.lockObject, label: "a", labelTooltip: "Alpha", value: this.state.color.a, onChange: (value) => this.updateStateA(value) }))] }))] }));
|
154
|
+
} }) }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }), this.state.isExpanded && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInput, { lockObject: this.props.lockObject, label: "r", labelTooltip: "Red", value: this.state.color.r, step: 0.1, onChange: (value) => this.updateStateR(value) }), _jsx(NumericInput, { lockObject: this.props.lockObject, label: "g", labelTooltip: "Green", value: this.state.color.g, step: 0.1, onChange: (value) => this.updateStateG(value) }), _jsx(NumericInput, { lockObject: this.props.lockObject, label: "b", labelTooltip: "Blue", value: this.state.color.b, step: 0.1, onChange: (value) => this.updateStateB(value) }), this.props.disableAlpha || (_jsx(NumericInput, { lockObject: this.props.lockObject, label: "a", labelTooltip: "Alpha", value: this.state.color.a, step: 0.1, onChange: (value) => this.updateStateA(value) }))] }))] }));
|
155
155
|
}
|
156
156
|
}
|
157
157
|
//# sourceMappingURL=colorLineComponent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"colorLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/colorLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAExC,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAoB1C,MAAM,OAAO,SAAU,SAAQ,KAAK,CAAC,SAAoD;IACrF,YAAY,KAAsB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;QAE3D,MAAM,MAAM,GAAG,IAAI,CAAC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AO,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,EAC5J,KAAC,YAAY,IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAC,YAAY,EAAC,MAAM,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,EAC1J,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CACxB,KAAC,YAAY,IACT,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,YAAY,EAAC,OAAO,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,CACL,IACC,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { NumericInput } from \"./numericInputComponent\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faMinus, faPlus } from \"@fortawesome/free-solid-svg-icons\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport { ColorPickerLine } from \"./colorPickerComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport copyIcon from \"../imgs/copy.svg\";\r\n\r\nconst emptyColor = new Color4(0, 0, 0, 0);\r\n\r\nexport interface IColorLineProps {\r\n label: string;\r\n target?: any;\r\n propertyName: string;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n onChange?: () => void;\r\n isLinear?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n disableAlpha?: boolean;\r\n lockObject: LockObject;\r\n}\r\n\r\ninterface IColorLineComponentState {\r\n isExpanded: boolean;\r\n color: Color4;\r\n}\r\n\r\nexport class ColorLine extends React.Component<IColorLineProps, IColorLineComponentState> {\r\n constructor(props: IColorLineProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, color: this.getValue() };\r\n\r\n const target = this.props.target;\r\n target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorLineProps, nextState: IColorLineComponentState) {\r\n const stateColor = nextState.color;\r\n const propsColor = this.getValue(nextProps);\r\n if (stateColor !== this.state.color) {\r\n nextState.color = stateColor;\r\n return true;\r\n }\r\n if (propsColor !== this.state.color) {\r\n nextState.color = propsColor;\r\n return true;\r\n }\r\n if (nextState.isExpanded !== this.state.isExpanded) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n getValue(props = this.props): Color4 {\r\n const target = props.target;\r\n const property = target[props.propertyName];\r\n if (!property) return emptyColor;\r\n if (typeof property === \"string\") {\r\n if (property === conflictingValuesPlaceholder) {\r\n return emptyColor;\r\n }\r\n return this._convertToColor(property);\r\n } else {\r\n if (props.isLinear) {\r\n return property.toGammaSpace();\r\n }\r\n return property.clone();\r\n }\r\n }\r\n\r\n setColorFromString(colorString: string) {\r\n const color = this._convertToColor(colorString);\r\n this.setColor(color);\r\n }\r\n\r\n setColor(newColor: Color4) {\r\n this.setState({ color: newColor.clone() });\r\n if (this.props.isLinear) {\r\n newColor.toLinearSpaceToRef(newColor);\r\n }\r\n // whether to set properties to color3 or color4\r\n const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;\r\n\r\n const target = this.props.target;\r\n const initialValue = target[this.props.propertyName];\r\n const value = typeof target[this.props.propertyName] === \"string\" ? setColor.toHexString() : setColor;\r\n // make the change\r\n target[this.props.propertyName] = value;\r\n // notify observers\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: target,\r\n property: this.props.propertyName,\r\n value,\r\n initialValue,\r\n });\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange();\r\n }\r\n }\r\n\r\n switchExpandState() {\r\n this.setState({ isExpanded: !this.state.isExpanded });\r\n }\r\n\r\n updateStateR(value: number) {\r\n this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateG(value: number) {\r\n this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateB(value: number) {\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));\r\n }\r\n\r\n updateStateA(value: number) {\r\n if (this.props.disableAlpha) {\r\n return;\r\n }\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));\r\n }\r\n\r\n private _convertToColor(color: string): Color4 {\r\n if (color === \"\" || color === \"transparent\") {\r\n return emptyColor;\r\n }\r\n\r\n if (color.substring(0, 1) !== \"#\" || (color.length !== 7 && color.length !== 9)) {\r\n const d = document.createElement(\"div\");\r\n d.style.color = color;\r\n document.body.append(d);\r\n const rgb = window.getComputedStyle(d).color;\r\n document.body.removeChild(d);\r\n\r\n const rgbArray = rgb\r\n .substring(4, rgb.length - 1)\r\n .replace(/ /g, \"\")\r\n .split(\",\");\r\n\r\n const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;\r\n\r\n return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);\r\n }\r\n\r\n if (this.props.disableAlpha) {\r\n const color3 = Color3.FromHexString(color);\r\n return new Color4(color3.r, color3.g, color3.b, 1.0);\r\n }\r\n\r\n return Color4.FromHexString(color);\r\n }\r\n\r\n private _toColor3(color: Color4) {\r\n return new Color3(color.r, color.g, color.b);\r\n }\r\n\r\n // Copy to clipboard the code this Color3 actually does\r\n // Example : material.diffuseColor = new BABYLON.Vector3(0,1,0);\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.target[this.props.propertyName!];\r\n const hex = this.state.color.toHexString();\r\n let strColor;\r\n if (value.a) {\r\n strColor = \"new \" + babylonNamespace + \"Color4(\" + value.r + \", \" + value.g + \", \" + value.b + \", \" + value.a + \")\";\r\n } else {\r\n strColor = \"new \" + babylonNamespace + \"Color3(\" + value.r + \", \" + value.g + \", \" + value.b + \")\";\r\n }\r\n strColor += \";// (HEX : \" + hex;\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + strColor + \" , debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n override render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className=\"color3Line\">\r\n <div className=\"firstLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"color3\">\r\n <ColorPickerLine\r\n lockObject={this.props.lockObject}\r\n linearHint={this.props.isLinear}\r\n value={this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color}\r\n onColorChanged={(colorString) => {\r\n this.setColorFromString(colorString);\r\n }}\r\n />\r\n </div>\r\n <div className=\"expand hoverIcon\" onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n <div className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className=\"secondLine\">\r\n <NumericInput lockObject={this.props.lockObject} label=\"r\" labelTooltip=\"Red\" value={this.state.color.r} onChange={(value) => this.updateStateR(value)} />\r\n <NumericInput lockObject={this.props.lockObject} label=\"g\" labelTooltip=\"Green\" value={this.state.color.g} onChange={(value) => this.updateStateG(value)} />\r\n <NumericInput lockObject={this.props.lockObject} label=\"b\" labelTooltip=\"Blue\" value={this.state.color.b} onChange={(value) => this.updateStateB(value)} />\r\n {this.props.disableAlpha || (\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"a\"\r\n labelTooltip=\"Alpha\"\r\n value={this.state.color.a}\r\n onChange={(value) => this.updateStateA(value)}\r\n />\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"colorLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/colorLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAEx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import type { Observable } from \"core/Misc/observable\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { NumericInput } from \"./numericInputComponent\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faMinus, faPlus } from \"@fortawesome/free-solid-svg-icons\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport { ColorPickerLine } from \"./colorPickerComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport copyIcon from \"../imgs/copy.svg\";\r\n\r\nconst emptyColor = new Color4(0, 0, 0, 0);\r\n\r\nexport interface IColorLineProps {\r\n label: string;\r\n target?: any;\r\n propertyName: string;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n onChange?: () => void;\r\n isLinear?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n disableAlpha?: boolean;\r\n lockObject: LockObject;\r\n}\r\n\r\ninterface IColorLineComponentState {\r\n isExpanded: boolean;\r\n color: Color4;\r\n}\r\n\r\nexport class ColorLine extends React.Component<IColorLineProps, IColorLineComponentState> {\r\n constructor(props: IColorLineProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, color: this.getValue() };\r\n\r\n const target = this.props.target;\r\n target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorLineProps, nextState: IColorLineComponentState) {\r\n const stateColor = nextState.color;\r\n const propsColor = this.getValue(nextProps);\r\n if (stateColor !== this.state.color) {\r\n nextState.color = stateColor;\r\n return true;\r\n }\r\n if (propsColor !== this.state.color) {\r\n nextState.color = propsColor;\r\n return true;\r\n }\r\n if (nextState.isExpanded !== this.state.isExpanded) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n getValue(props = this.props): Color4 {\r\n const target = props.target;\r\n const property = target[props.propertyName];\r\n if (!property) return emptyColor;\r\n if (typeof property === \"string\") {\r\n if (property === conflictingValuesPlaceholder) {\r\n return emptyColor;\r\n }\r\n return this._convertToColor(property);\r\n } else {\r\n if (props.isLinear) {\r\n return property.toGammaSpace();\r\n }\r\n return property.clone();\r\n }\r\n }\r\n\r\n setColorFromString(colorString: string) {\r\n const color = this._convertToColor(colorString);\r\n this.setColor(color);\r\n }\r\n\r\n setColor(newColor: Color4) {\r\n this.setState({ color: newColor.clone() });\r\n if (this.props.isLinear) {\r\n newColor.toLinearSpaceToRef(newColor);\r\n }\r\n // whether to set properties to color3 or color4\r\n const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;\r\n\r\n const target = this.props.target;\r\n const initialValue = target[this.props.propertyName];\r\n const value = typeof target[this.props.propertyName] === \"string\" ? setColor.toHexString() : setColor;\r\n // make the change\r\n target[this.props.propertyName] = value;\r\n // notify observers\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: target,\r\n property: this.props.propertyName,\r\n value,\r\n initialValue,\r\n });\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange();\r\n }\r\n }\r\n\r\n switchExpandState() {\r\n this.setState({ isExpanded: !this.state.isExpanded });\r\n }\r\n\r\n updateStateR(value: number) {\r\n this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateG(value: number) {\r\n this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateB(value: number) {\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));\r\n }\r\n\r\n updateStateA(value: number) {\r\n if (this.props.disableAlpha) {\r\n return;\r\n }\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));\r\n }\r\n\r\n private _convertToColor(color: string): Color4 {\r\n if (color === \"\" || color === \"transparent\") {\r\n return emptyColor;\r\n }\r\n\r\n if (color.substring(0, 1) !== \"#\" || (color.length !== 7 && color.length !== 9)) {\r\n const d = document.createElement(\"div\");\r\n d.style.color = color;\r\n document.body.append(d);\r\n const rgb = window.getComputedStyle(d).color;\r\n document.body.removeChild(d);\r\n\r\n const rgbArray = rgb\r\n .substring(4, rgb.length - 1)\r\n .replace(/ /g, \"\")\r\n .split(\",\");\r\n\r\n const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;\r\n\r\n return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);\r\n }\r\n\r\n if (this.props.disableAlpha) {\r\n const color3 = Color3.FromHexString(color);\r\n return new Color4(color3.r, color3.g, color3.b, 1.0);\r\n }\r\n\r\n return Color4.FromHexString(color);\r\n }\r\n\r\n private _toColor3(color: Color4) {\r\n return new Color3(color.r, color.g, color.b);\r\n }\r\n\r\n // Copy to clipboard the code this Color3 actually does\r\n // Example : material.diffuseColor = new BABYLON.Vector3(0,1,0);\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.target[this.props.propertyName!];\r\n const hex = this.state.color.toHexString();\r\n let strColor;\r\n if (value.a) {\r\n strColor = \"new \" + babylonNamespace + \"Color4(\" + value.r + \", \" + value.g + \", \" + value.b + \", \" + value.a + \")\";\r\n } else {\r\n strColor = \"new \" + babylonNamespace + \"Color3(\" + value.r + \", \" + value.g + \", \" + value.b + \")\";\r\n }\r\n strColor += \";// (HEX : \" + hex;\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + strColor + \" , debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n override render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className=\"color3Line\">\r\n <div className=\"firstLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"color3\">\r\n <ColorPickerLine\r\n lockObject={this.props.lockObject}\r\n linearHint={this.props.isLinear}\r\n value={this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color}\r\n onColorChanged={(colorString) => {\r\n this.setColorFromString(colorString);\r\n }}\r\n />\r\n </div>\r\n <div className=\"expand hoverIcon\" onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n <div className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className=\"secondLine\">\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"r\"\r\n labelTooltip=\"Red\"\r\n value={this.state.color.r}\r\n step={0.1}\r\n onChange={(value) => this.updateStateR(value)}\r\n />\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"g\"\r\n labelTooltip=\"Green\"\r\n value={this.state.color.g}\r\n step={0.1}\r\n onChange={(value) => this.updateStateG(value)}\r\n />\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"b\"\r\n labelTooltip=\"Blue\"\r\n value={this.state.color.b}\r\n step={0.1}\r\n onChange={(value) => this.updateStateB(value)}\r\n />\r\n {this.props.disableAlpha || (\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"a\"\r\n labelTooltip=\"Alpha\"\r\n value={this.state.color.a}\r\n step={0.1}\r\n onChange={(value) => this.updateStateA(value)}\r\n />\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -11,6 +11,7 @@ interface ITextLineComponentProps {
|
|
11
11
|
icon?: string;
|
12
12
|
iconLabel?: string;
|
13
13
|
tooltip?: string;
|
14
|
+
onCopy?: true | (() => string);
|
14
15
|
}
|
15
16
|
export declare class TextLineComponent extends React.Component<ITextLineComponentProps> {
|
16
17
|
constructor(props: ITextLineComponentProps);
|
@@ -1,5 +1,8 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
|
+
import copyIcon from "shared-ui-components/imgs/copy.svg";
|
4
|
+
import { copyCommandToClipboard } from "shared-ui-components/copyCommandToClipboard";
|
5
|
+
import { MergeClassNames } from "shared-ui-components/styleHelper";
|
3
6
|
export class TextLineComponent extends React.Component {
|
4
7
|
constructor(props) {
|
5
8
|
super(props);
|
@@ -24,7 +27,15 @@ export class TextLineComponent extends React.Component {
|
|
24
27
|
return (_jsx("div", { className: "value", title: this.props.tooltip ?? this.props.label ?? "", style: { color: this.props.color ? this.props.color : "" }, children: this.props.value || "no name" }));
|
25
28
|
}
|
26
29
|
render() {
|
27
|
-
return (_jsxs("div", { className:
|
30
|
+
return (_jsxs("div", { className: MergeClassNames(["textLine", ["underline", this.props.underline], this.props.additionalClass, ["icon", this.props.onCopy]]), children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "label", title: this.props.tooltip ?? this.props.label ?? "", children: this.props.label ?? "" }), this.renderContent(), this.props.onCopy && (_jsx("div", { className: "copy hoverIcon", onClick: () => {
|
31
|
+
const onCopy = this.props.onCopy;
|
32
|
+
if (onCopy === true && this.props.value !== undefined) {
|
33
|
+
copyCommandToClipboard(this.props.value);
|
34
|
+
}
|
35
|
+
else if (typeof onCopy === "function") {
|
36
|
+
copyCommandToClipboard(onCopy());
|
37
|
+
}
|
38
|
+
}, title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) }))] }));
|
28
39
|
}
|
29
40
|
}
|
30
41
|
//# sourceMappingURL=textLineComponent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"textLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/textLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"textLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/textLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,QAAQ,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAiBnE,MAAM,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAkC;IAC3E,YAAY,KAA8B;QACtC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,MAAM;QACF,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YACjB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACtC,OAAO;QACX,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;IAED,aAAa;QACT,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YACtC,OAAO,CACH,cAAK,SAAS,EAAC,YAAY,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,KA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ACL,IAAI,CAAC,aAAa,EAAE,EACpB,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAClB,cACI,SAAS,EAAC,gBAAgB,EAC1B,OAAO,EAAE,GAAG,EAAE;wBACV,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;wBACjC,IAAI,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;4BACpD,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;wBAC7C,CAAC;6BAAM,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;4BACtC,sBAAsB,CAAC,MAAM,EAAE,CAAC,CAAC;wBACrC,CAAC;oBACL,CAAC,EACD,KAAK,EAAC,mBAAmB,YAEzB,cAAK,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAC,MAAM,GAAG,GAC/B,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport copyIcon from \"shared-ui-components/imgs/copy.svg\";\r\nimport { copyCommandToClipboard } from \"shared-ui-components/copyCommandToClipboard\";\r\nimport { MergeClassNames } from \"shared-ui-components/styleHelper\";\r\n\r\ninterface ITextLineComponentProps {\r\n label?: string;\r\n value?: string;\r\n color?: string;\r\n underline?: boolean;\r\n onLink?: () => void;\r\n url?: string;\r\n ignoreValue?: boolean;\r\n additionalClass?: string;\r\n icon?: string;\r\n iconLabel?: string;\r\n tooltip?: string;\r\n onCopy?: true | (() => string);\r\n}\r\n\r\nexport class TextLineComponent extends React.Component<ITextLineComponentProps> {\r\n constructor(props: ITextLineComponentProps) {\r\n super(props);\r\n }\r\n\r\n onLink() {\r\n if (this.props.url) {\r\n window.open(this.props.url, \"_blank\");\r\n return;\r\n }\r\n if (!this.props.onLink) {\r\n return;\r\n }\r\n\r\n this.props.onLink();\r\n }\r\n\r\n renderContent() {\r\n if (this.props.ignoreValue) {\r\n return null;\r\n }\r\n\r\n if (this.props.onLink || this.props.url) {\r\n return (\r\n <div className=\"link-value\" title={this.props.tooltip ?? this.props.label ?? \"\"} onClick={() => this.onLink()}>\r\n {this.props.url ? \"doc\" : this.props.value || \"no name\"}\r\n </div>\r\n );\r\n }\r\n return (\r\n <div className=\"value\" title={this.props.tooltip ?? this.props.label ?? \"\"} style={{ color: this.props.color ? this.props.color : \"\" }}>\r\n {this.props.value || \"no name\"}\r\n </div>\r\n );\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className={MergeClassNames([\"textLine\", [\"underline\", this.props.underline], this.props.additionalClass, [\"icon\", this.props.onCopy]])}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"label\" title={this.props.tooltip ?? this.props.label ?? \"\"}>\r\n {this.props.label ?? \"\"}\r\n </div>\r\n {this.renderContent()}\r\n {this.props.onCopy && (\r\n <div\r\n className=\"copy hoverIcon\"\r\n onClick={() => {\r\n const onCopy = this.props.onCopy;\r\n if (onCopy === true && this.props.value !== undefined) {\r\n copyCommandToClipboard(this.props.value);\r\n } else if (typeof onCopy === \"function\") {\r\n copyCommandToClipboard(onCopy());\r\n }\r\n }}\r\n title=\"Copy to clipboard\"\r\n >\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -665,20 +665,10 @@ export class GraphCanvasComponent extends React.Component {
|
|
665
665
|
if (this._frames.some((f) => f.nodes.indexOf(node) !== -1)) {
|
666
666
|
return;
|
667
667
|
}
|
668
|
-
graph.setNode(node.id.toString(), {
|
669
|
-
id: node.id,
|
670
|
-
type: "node",
|
671
|
-
width: node.width,
|
672
|
-
height: node.height,
|
673
|
-
});
|
668
|
+
graph.setNode(node.id.toString(), { id: node.id, type: "node", width: node.width, height: node.height });
|
674
669
|
});
|
675
670
|
this._frames.forEach((frame) => {
|
676
|
-
graph.setNode(frame.id.toString(), {
|
677
|
-
id: frame.id,
|
678
|
-
type: "frame",
|
679
|
-
width: frame.element.clientWidth,
|
680
|
-
height: frame.element.clientHeight,
|
681
|
-
});
|
671
|
+
graph.setNode(frame.id.toString(), { id: frame.id, type: "frame", width: frame.element.clientWidth, height: frame.element.clientHeight });
|
682
672
|
});
|
683
673
|
this._nodes.forEach((node) => {
|
684
674
|
node.content.outputs.forEach((output) => {
|
@@ -916,10 +906,7 @@ export class GraphCanvasComponent extends React.Component {
|
|
916
906
|
const port = this._candidateLink.portA;
|
917
907
|
const frame = this.frames.find((frame) => frame.id === port.parentFrameId);
|
918
908
|
if (frame) {
|
919
|
-
const data = {
|
920
|
-
frame,
|
921
|
-
port,
|
922
|
-
};
|
909
|
+
const data = { frame, port };
|
923
910
|
this.props.stateManager.onSelectionChangedObservable.notifyObservers({ selection: data });
|
924
911
|
}
|
925
912
|
}
|