@babylonjs/node-editor 5.24.0 → 5.26.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.
@@ -62285,7 +62285,8 @@ const MessageDialog = (props) => {
62285
62285
  "use strict";
62286
62286
  __webpack_require__.r(__webpack_exports__);
62287
62287
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
62288
- /* harmony export */ "ClassNames": () => (/* binding */ ClassNames)
62288
+ /* harmony export */ "ClassNames": () => (/* binding */ ClassNames),
62289
+ /* harmony export */ "JoinClassNames": () => (/* binding */ JoinClassNames)
62289
62290
  /* harmony export */ });
62290
62291
  function ClassNames(names, styleObject) {
62291
62292
  let string = "";
@@ -62296,6 +62297,15 @@ function ClassNames(names, styleObject) {
62296
62297
  }
62297
62298
  return string;
62298
62299
  }
62300
+ function JoinClassNames(styleObject, ...names) {
62301
+ let string = "";
62302
+ for (const name of names) {
62303
+ if (name && styleObject[name]) {
62304
+ string += styleObject[name] + " ";
62305
+ }
62306
+ }
62307
+ return string;
62308
+ }
62299
62309
 
62300
62310
 
62301
62311
  /***/ }),
@@ -63121,11 +63131,13 @@ __webpack_require__.r(__webpack_exports__);
63121
63131
 
63122
63132
  // eslint-disable-next-line @typescript-eslint/naming-convention
63123
63133
  const Null_Value = Number.MAX_SAFE_INTEGER;
63134
+ const DEFAULT_FALLBACK_VALUE = -1;
63124
63135
  class OptionsLineComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component {
63125
63136
  constructor(props) {
63137
+ // Initialize default props
63126
63138
  super(props);
63127
63139
  this._localChange = false;
63128
- this.state = { value: this._remapValueIn(this._getValue(props)) };
63140
+ this.state = { value: this._remapValueIn(this._getValue(props)), addCustom: false };
63129
63141
  }
63130
63142
  _remapValueIn(value) {
63131
63143
  return this.props.allowNullValue && value === null ? Null_Value : value;
@@ -63144,11 +63156,14 @@ class OptionsLineComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component
63144
63156
  this._localChange = false;
63145
63157
  return true;
63146
63158
  }
63147
- const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(this.props.target) : nextProps.target[nextProps.propertyName]);
63159
+ const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(nextProps.target) : nextProps.target[nextProps.propertyName]);
63148
63160
  if (newValue != null && newValue !== nextState.value) {
63149
63161
  nextState.value = newValue;
63150
63162
  return true;
63151
63163
  }
63164
+ if (this.props.options !== nextProps.options) {
63165
+ return true;
63166
+ }
63152
63167
  return false;
63153
63168
  }
63154
63169
  raiseOnPropertyChanged(newValue, previousValue) {
@@ -63167,23 +63182,65 @@ class OptionsLineComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component
63167
63182
  this.setState({ value: value });
63168
63183
  }
63169
63184
  updateValue(valueString) {
63170
- const value = this.props.valuesAreStrings ? valueString : parseInt(valueString);
63185
+ let value = this.props.valuesAreStrings ? valueString : parseInt(valueString);
63186
+ if (isNaN(Number(value))) {
63187
+ for (let i = 0; i < this.props.options.length; i++) {
63188
+ if (this.props.options.at(i)?.label === valueString) {
63189
+ value = Number(this.props.options.at(i)?.value);
63190
+ }
63191
+ }
63192
+ }
63193
+ if (value === 0 && this.props.fromFontDropdown) {
63194
+ this.setState({ addCustom: true });
63195
+ }
63171
63196
  this._localChange = true;
63172
63197
  const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
63173
63198
  if (!this.props.noDirectUpdate) {
63174
63199
  this.props.target[this.props.propertyName] = this._remapValueOut(value);
63175
63200
  }
63176
- this.setState({ value: value });
63177
- if (this.props.onSelect) {
63178
- this.props.onSelect(value);
63201
+ //selecting a regular option from font dropdown
63202
+ if (value != 0 && this.props.fromFontDropdown) {
63203
+ this.setState({ value: value });
63204
+ if (this.props.onSelect) {
63205
+ this.props.onSelect(value);
63206
+ }
63207
+ //selecting 'custom font' from font dropdown
63208
+ }
63209
+ else if (this.props.fromFontDropdown) {
63210
+ if (this.props.onSelect) {
63211
+ this.props.onSelect(this.state.value);
63212
+ }
63213
+ }
63214
+ //selecting from a dropdown that's not font dropdown
63215
+ else {
63216
+ this.setState({ value: value });
63217
+ if (this.props.onSelect) {
63218
+ this.props.onSelect(value);
63219
+ }
63179
63220
  }
63180
63221
  const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
63181
63222
  this.raiseOnPropertyChanged(newValue, store);
63182
63223
  }
63224
+ updateCustomValue() {
63225
+ this.setState({ addCustom: false });
63226
+ }
63183
63227
  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) => {
63228
+ const fallback = this.props.fallbackValue !== undefined ? this.props.fallbackValue : DEFAULT_FALLBACK_VALUE;
63229
+ 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) => {
63230
+ event.key === "Enter" && this.props.addVal != undefined
63231
+ ? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
63232
+ this.updateCustomValue(),
63233
+ this.forceUpdate())
63234
+ : null;
63235
+ }, onBlur: (event) => {
63236
+ this.props.addVal != undefined
63237
+ ? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
63238
+ this.updateCustomValue(),
63239
+ this.forceUpdate())
63240
+ : null;
63241
+ } })) : ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("select", { onChange: (evt) => this.updateValue(evt.target.value), value: this.state.value === null || this.state.value === undefined ? fallback : this.state.value, children: this.props.options.map((option, i) => {
63185
63242
  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
- }) }) })] }));
63243
+ }) })) })] }));
63187
63244
  }
63188
63245
  }
63189
63246
 
@@ -67066,7 +67123,23 @@ class NodeLink {
67066
67123
  }
67067
67124
  intersectsWith(rect) {
67068
67125
  const locatRect = this._path.getBoundingClientRect();
67069
- return rect.left < locatRect.right && rect.right > locatRect.left && rect.top < locatRect.bottom && rect.bottom > locatRect.top;
67126
+ if (rect.left > locatRect.right || rect.right < locatRect.left || rect.top > locatRect.bottom || rect.bottom < locatRect.top) {
67127
+ return false;
67128
+ }
67129
+ const svg = this._graphCanvas.svgCanvas;
67130
+ const rootRect = svg.getBoundingClientRect();
67131
+ const left = rect.x - rootRect.x;
67132
+ const top = rect.y - rootRect.y;
67133
+ const right = left + rect.width;
67134
+ const bottom = top + rect.height;
67135
+ const sampleRate = 10; // Checking 10 times on the path should be enough
67136
+ for (let index = 0; index < 1; index += 1 / sampleRate) {
67137
+ const point = this._path.getPointAtLength(index * this._path.getTotalLength());
67138
+ if (left < point.x && right > point.x && top < point.y && bottom > point.y) {
67139
+ return true;
67140
+ }
67141
+ }
67142
+ return false;
67070
67143
  }
67071
67144
  update(endX = 0, endY = 0, straight = false) {
67072
67145
  const rectA = this._portA.element.getBoundingClientRect();