@plasmicapp/react-web 0.2.116 → 0.2.118

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.
@@ -1,4 +1,5 @@
1
1
  import classNames$1 from 'classnames';
2
+ export { Fetcher, executePlasmicDataOp, usePlasmicDataConfig, usePlasmicDataMutationOp, usePlasmicDataOp } from '@plasmicapp/data-sources';
2
3
  import _get from 'dlv';
3
4
  export { default as get } from 'dlv';
4
5
  import * as React from 'react';
@@ -1977,13 +1978,33 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
1977
1978
  });
1978
1979
  $$state.unsubscriptionsByState[initialStateKey].push(unsubscribe);
1979
1980
  });
1980
- var untrackedInitialValue = mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(initialStatePath, initialSpec)));
1981
+ var initialValue = initialSpec.initFunc($$state.props, $state, getIndexes(initialStatePath, initialSpec));
1982
+ saveStateInitialValue($$state, initialStatePath, initialSpec, initialValue);
1983
+ return initialValue;
1984
+ }
1985
+
1986
+ function saveStateInitialValue($$state, path, spec, initialValue) {
1987
+ // array states are a special case.Wwe listen for changes in the array and in the array cells.
1988
+ // for example: $state.people.push(...), $state.people.splice(...), $state.people[0] = ...
1989
+ // that's why we need to track the array object
1990
+ if (spec.isArray && Array.isArray(initialValue)) {
1991
+ var array = initialValue.map(function (val) {
1992
+ return mkUntrackedValue(val);
1993
+ });
1994
+
1995
+ set($$state.stateValues, path, array); // we need to make the array untracked for initStateValues
1996
+ // so we can distinguish between stateValue and initStateValue.
1997
+ // otherwise they would reference the same array.
1981
1998
 
1982
- set($$state.initStateValues, initialStatePath, untrackedInitialValue);
1983
1999
 
1984
- set($$state.stateValues, initialStatePath, untrackedInitialValue);
2000
+ set($$state.initStateValues, path, mkUntrackedValue(array));
2001
+ } else {
2002
+ var untrackedValue = mkUntrackedValue(initialValue);
2003
+
2004
+ set($$state.stateValues, path, untrackedValue);
1985
2005
 
1986
- return untrackedInitialValue;
2006
+ set($$state.initStateValues, path, untrackedValue);
2007
+ }
1987
2008
  }
1988
2009
 
1989
2010
  function useDollarState(specs, props) {
@@ -2012,11 +2033,8 @@ function useDollarState(specs, props) {
2012
2033
  var _spec$initVal;
2013
2034
 
2014
2035
  saveNewState($$state, path, spec);
2015
- var untrackedValue = !spec.initFunc ? mkUntrackedValue((_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined) : initializeStateValue($$state, path, spec);
2016
-
2017
- set($$state.stateValues, path, untrackedValue);
2018
-
2019
- set($$state.initStateValues, path, untrackedValue);
2036
+ var initialValue = !spec.initFunc ? (_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined : initializeStateValue($$state, path, spec);
2037
+ saveStateInitialValue($$state, path, spec, initialValue);
2020
2038
  }
2021
2039
 
2022
2040
  return {
@@ -2313,9 +2331,7 @@ function useCheckbox(plasmicClass, props, config, ref) {
2313
2331
  ref: rootRef
2314
2332
  }),
2315
2333
  wrapChildren: function wrapChildren(children) {
2316
- return createElement(Fragment, null, createElement(VisuallyHidden, {
2317
- isFocusable: true
2318
- }, createElement("input", Object.assign({}, inputProps, {
2334
+ return createElement(Fragment, null, createElement(VisuallyHidden, null, createElement("input", Object.assign({}, inputProps, {
2319
2335
  ref: inputRef
2320
2336
  }))), children);
2321
2337
  }
@@ -3456,9 +3472,7 @@ function useSwitch(plasmicClass, props, config, ref) {
3456
3472
  ref: rootRef
3457
3473
  }),
3458
3474
  wrapChildren: function wrapChildren(children) {
3459
- return createElement(Fragment, null, createElement(VisuallyHidden, {
3460
- isFocusable: true
3461
- }, createElement("input", Object.assign({}, inputProps, {
3475
+ return createElement(Fragment, null, createElement(VisuallyHidden, null, createElement("input", Object.assign({}, inputProps, {
3462
3476
  ref: inputRef
3463
3477
  }))), children);
3464
3478
  }