@plasmicapp/react-web 0.2.143 → 0.2.144

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.
@@ -2420,7 +2420,14 @@ var StateSpecNode = /*#__PURE__*/function () {
2420
2420
  this._state = {};
2421
2421
  };
2422
2422
  _proto.states = function states() {
2423
- return Object.values(this._state);
2423
+ return Object.entries(this._state).map(function (_ref) {
2424
+ var key = _ref[0],
2425
+ stateCell = _ref[1];
2426
+ return {
2427
+ path: JSON.parse(key),
2428
+ stateCell: stateCell
2429
+ };
2430
+ });
2424
2431
  };
2425
2432
  _proto.hasState = function hasState(path) {
2426
2433
  var key = JSON.stringify(path);
@@ -2765,8 +2772,15 @@ function useDollarState(specs, props, $ctx, opts) {
2765
2772
  $$state.rootSpecTree = updateTree($$state.rootSpecTree, specs);
2766
2773
  var newLeaves = getStateCells($$state.rootSpecTree);
2767
2774
  if (!arrayEq(newLeaves, $$state.specTreeLeaves)) {
2775
+ var old$State = $state;
2768
2776
  $state = ref.current = create$State();
2769
2777
  $$state.specTreeLeaves = newLeaves;
2778
+ $$state.specTreeLeaves.flatMap(function (node) {
2779
+ return node.states();
2780
+ }).forEach(function (_ref2) {
2781
+ var path = _ref2.path;
2782
+ set($state, path, _get(old$State, path));
2783
+ });
2770
2784
  }
2771
2785
  // we need to eager initialize all states in canvas to populate the data picker
2772
2786
  $$state.specTreeLeaves.forEach(function (node) {
@@ -2783,15 +2797,16 @@ function useDollarState(specs, props, $ctx, opts) {
2783
2797
  // the init value has changed. If so, reset its state.
2784
2798
  var resetSpecs = [];
2785
2799
  $$state.specTreeLeaves.flatMap(function (node) {
2786
- return node.states().map(function (stateCell) {
2800
+ return node.states().map(function (_ref3) {
2801
+ var stateCell = _ref3.stateCell;
2787
2802
  return {
2788
2803
  stateCell: stateCell,
2789
2804
  node: node
2790
2805
  };
2791
2806
  });
2792
- }).forEach(function (_ref2) {
2793
- var node = _ref2.node,
2794
- stateCell = _ref2.stateCell;
2807
+ }).forEach(function (_ref4) {
2808
+ var node = _ref4.node,
2809
+ stateCell = _ref4.stateCell;
2795
2810
  var initFunc = node.getInitFunc(stateCell);
2796
2811
  if (initFunc) {
2797
2812
  var newInit = initFunc(props, $state, $ctx != null ? $ctx : {});
@@ -2812,9 +2827,9 @@ function useDollarState(specs, props, $ctx, opts) {
2812
2827
  }
2813
2828
  };
2814
2829
  useIsomorphicLayoutEffect$1(function () {
2815
- resetSpecs.forEach(function (_ref3) {
2816
- var stateCell = _ref3.stateCell,
2817
- node = _ref3.node;
2830
+ resetSpecs.forEach(function (_ref5) {
2831
+ var stateCell = _ref5.stateCell,
2832
+ node = _ref5.node;
2818
2833
  reInitializeState(node, stateCell);
2819
2834
  });
2820
2835
  }, [props, resetSpecs]);