@babylonjs/node-editor 5.24.0 → 5.25.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.
@@ -63125,7 +63125,7 @@ class OptionsLineComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component
63125
63125
  constructor(props) {
63126
63126
  super(props);
63127
63127
  this._localChange = false;
63128
- this.state = { value: this._remapValueIn(this._getValue(props)) };
63128
+ this.state = { value: this._remapValueIn(this._getValue(props)), addCustom: false };
63129
63129
  }
63130
63130
  _remapValueIn(value) {
63131
63131
  return this.props.allowNullValue && value === null ? Null_Value : value;
@@ -63144,11 +63144,14 @@ class OptionsLineComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component
63144
63144
  this._localChange = false;
63145
63145
  return true;
63146
63146
  }
63147
- const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(this.props.target) : nextProps.target[nextProps.propertyName]);
63147
+ const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(nextProps.target) : nextProps.target[nextProps.propertyName]);
63148
63148
  if (newValue != null && newValue !== nextState.value) {
63149
63149
  nextState.value = newValue;
63150
63150
  return true;
63151
63151
  }
63152
+ if (this.props.options !== nextProps.options) {
63153
+ return true;
63154
+ }
63152
63155
  return false;
63153
63156
  }
63154
63157
  raiseOnPropertyChanged(newValue, previousValue) {
@@ -63167,23 +63170,64 @@ class OptionsLineComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component
63167
63170
  this.setState({ value: value });
63168
63171
  }
63169
63172
  updateValue(valueString) {
63170
- const value = this.props.valuesAreStrings ? valueString : parseInt(valueString);
63173
+ let value = this.props.valuesAreStrings ? valueString : parseInt(valueString);
63174
+ if (isNaN(Number(value))) {
63175
+ for (let i = 0; i < this.props.options.length; i++) {
63176
+ if (this.props.options.at(i)?.label === valueString) {
63177
+ value = Number(this.props.options.at(i)?.value);
63178
+ }
63179
+ }
63180
+ }
63181
+ if (value === 0 && this.props.fromFontDropdown) {
63182
+ this.setState({ addCustom: true });
63183
+ }
63171
63184
  this._localChange = true;
63172
63185
  const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
63173
63186
  if (!this.props.noDirectUpdate) {
63174
63187
  this.props.target[this.props.propertyName] = this._remapValueOut(value);
63175
63188
  }
63176
- this.setState({ value: value });
63177
- if (this.props.onSelect) {
63178
- this.props.onSelect(value);
63189
+ //selecting a regular option from font dropdown
63190
+ if (value != 0 && this.props.fromFontDropdown) {
63191
+ this.setState({ value: value });
63192
+ if (this.props.onSelect) {
63193
+ this.props.onSelect(value);
63194
+ }
63195
+ //selecting 'custom font' from font dropdown
63196
+ }
63197
+ else if (this.props.fromFontDropdown) {
63198
+ if (this.props.onSelect) {
63199
+ this.props.onSelect(this.state.value);
63200
+ }
63201
+ }
63202
+ //selecting from a dropdown that's not font dropdown
63203
+ else {
63204
+ this.setState({ value: value });
63205
+ if (this.props.onSelect) {
63206
+ this.props.onSelect(value);
63207
+ }
63179
63208
  }
63180
63209
  const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
63181
63210
  this.raiseOnPropertyChanged(newValue, store);
63182
63211
  }
63212
+ updateCustomValue() {
63213
+ this.setState({ addCustom: false });
63214
+ }
63183
63215
  render() {
63184
- return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "listLine" + (this.props.className ? " " + this.props.className : ""), children: [this.props.icon && (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, color: "black", className: "icon" }), (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: "label", title: this.props.label, children: this.props.label }), (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: "options", children: (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("select", { onChange: (evt) => this.updateValue(evt.target.value), value: this.state.value ?? "", children: this.props.options.map((option, i) => {
63216
+ return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: `listLine ${this.props.className ?? ""}`, children: [this.props.icon && (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, color: "black", className: "icon" }), (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: "label", title: this.props.label, children: this.props.label }), (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: "options", children: this.state.addCustom ? ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("input", { type: "text", placeholder: "Enter a custom font here", onKeyDown: (event) => {
63217
+ event.key === "Enter" && this.props.addVal != undefined
63218
+ ? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
63219
+ this.updateCustomValue(),
63220
+ this.forceUpdate())
63221
+ : null;
63222
+ }, onBlur: (event) => {
63223
+ this.props.addVal != undefined
63224
+ ? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
63225
+ this.updateCustomValue(),
63226
+ this.forceUpdate())
63227
+ : null;
63228
+ } })) : ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("select", { onChange: (evt) => this.updateValue(evt.target.value), value: this.state.value === -1 || this.state.value === null || this.state.value === undefined ? 1 : this.state.value, children: this.props.options.map((option, i) => {
63185
63229
  return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("option", { selected: option.selected, value: option.value, title: option.label, children: option.label }, option.label + i));
63186
- }) }) })] }));
63230
+ }) })) })] }));
63187
63231
  }
63188
63232
  }
63189
63233
 
@@ -67066,7 +67110,23 @@ class NodeLink {
67066
67110
  }
67067
67111
  intersectsWith(rect) {
67068
67112
  const locatRect = this._path.getBoundingClientRect();
67069
- return rect.left < locatRect.right && rect.right > locatRect.left && rect.top < locatRect.bottom && rect.bottom > locatRect.top;
67113
+ if (rect.left > locatRect.right || rect.right < locatRect.left || rect.top > locatRect.bottom || rect.bottom < locatRect.top) {
67114
+ return false;
67115
+ }
67116
+ const svg = this._graphCanvas.svgCanvas;
67117
+ const rootRect = svg.getBoundingClientRect();
67118
+ const left = rect.x - rootRect.x;
67119
+ const top = rect.y - rootRect.y;
67120
+ const right = left + rect.width;
67121
+ const bottom = top + rect.height;
67122
+ const sampleRate = 10; // Checking 10 times on the path should be enough
67123
+ for (let index = 0; index < 1; index += 1 / sampleRate) {
67124
+ const point = this._path.getPointAtLength(index * this._path.getTotalLength());
67125
+ if (left < point.x && right > point.x && top < point.y && bottom > point.y) {
67126
+ return true;
67127
+ }
67128
+ }
67129
+ return false;
67070
67130
  }
67071
67131
  update(endX = 0, endY = 0, straight = false) {
67072
67132
  const rectA = this._portA.element.getBoundingClientRect();