@plasmicapp/react-web 0.2.357 → 0.2.359

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.
@@ -2092,7 +2092,7 @@ function subscribeToValtio($$state, statePath, node) {
2092
2092
  }
2093
2093
  }
2094
2094
  function initializeStateValue($$state, initialStateCell, proxyRoot) {
2095
- var _a, _b, _c;
2095
+ var _a;
2096
2096
  var initialStateName = initialStateCell.node.getSpec().path;
2097
2097
  var stateAccess = new Set();
2098
2098
  $$state.stateInitializationEnv.visited.add(initialStateName);
@@ -2149,16 +2149,12 @@ function initializeStateValue($$state, initialStateCell, proxyRoot) {
2149
2149
  : clonedValue;
2150
2150
  set(proxyRoot, initialStateCell.path, value);
2151
2151
  }
2152
- catch (_d) {
2152
+ catch (_b) {
2153
2153
  // Setting the state to undefined to make sure it gets re-initialized
2154
2154
  // in case it changes values.
2155
2155
  initialStateCell.initialValue = undefined;
2156
2156
  set(proxyRoot, initialStateCell.path, undefined);
2157
2157
  }
2158
- //immediately fire onChange
2159
- if (initialSpec.onChangeProp) {
2160
- (_c = (_b = $$state.env.$props)[initialSpec.onChangeProp]) === null || _c === void 0 ? void 0 : _c.call(_b, initialValue);
2161
- }
2162
2158
  $$state.stateInitializationEnv.visited.delete(initialStateName);
2163
2159
  $$state.stateInitializationEnv.stack.pop();
2164
2160
  return initialValue;
@@ -2224,7 +2220,15 @@ function create$StateProxy($$state, leafHandlers) {
2224
2220
  (_b = (_a = leafHandlers(ensureStateCell(receiver, property, nextPath, nextNode))).set) === null || _b === void 0 ? void 0 : _b.call(_a, target, property, value, receiver);
2225
2221
  Reflect.set(target, property, value, receiver);
2226
2222
  if (nextSpec === null || nextSpec === void 0 ? void 0 : nextSpec.onChangeProp) {
2227
- (_d = (_c = $$state.env.$props)[nextSpec.onChangeProp]) === null || _d === void 0 ? void 0 : _d.call(_c, value);
2223
+ var pathKey = JSON.stringify(nextPath);
2224
+ var isInitOnChange = !$$state.initializedLeafPaths.has(pathKey);
2225
+ // We need to call the onChangeProp during initialization process so that the parent
2226
+ // state can be updated with the correct value. We will provide an addtionnal parameter
2227
+ // to the onChangeProp function to indicate that the call is made during initialization.
2228
+ (_d = (_c = $$state.env.$props)[nextSpec.onChangeProp]) === null || _d === void 0 ? void 0 : _d.call(_c, value, isInitOnChange);
2229
+ if (isInitOnChange) {
2230
+ $$state.initializedLeafPaths.add(pathKey);
2231
+ }
2228
2232
  }
2229
2233
  }
2230
2234
  if (!nextNode) {
@@ -2349,6 +2353,7 @@ function useDollarState(specs) {
2349
2353
  specs: [],
2350
2354
  registrationsQueue: [],
2351
2355
  stateInitializationEnv: { stack: [], visited: new Set() },
2356
+ initializedLeafPaths: new Set(),
2352
2357
  };
2353
2358
  })()).current;
2354
2359
  $$state.env = envFieldsAreNonNill(env);
@@ -2499,7 +2504,9 @@ function useDollarState(specs) {
2499
2504
  var spec = node.getSpec();
2500
2505
  if (!spec.isRepeated && spec.type !== "private" && spec.initFunc) {
2501
2506
  var stateCell = getStateCellFrom$StateRoot($state, spec.pathObj);
2502
- initializeStateValue($$state, stateCell, $state);
2507
+ if (stateCell.initialValue === UNINITIALIZED) {
2508
+ initializeStateValue($$state, stateCell, $state);
2509
+ }
2503
2510
  }
2504
2511
  });
2505
2512
  }, []);