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