@plasmicapp/react-web 0.2.138 → 0.2.140

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.
@@ -1280,10 +1280,16 @@ function renderPlasmicSlot(opts) {
1280
1280
  }
1281
1281
  function maybeAsString(node) {
1282
1282
  // Unwrap fragments
1283
- if (isValidElement(node) && (
1284
- // Fragment and Trans don't render DOM elements
1285
- node.type === Fragment || node.type === Trans)) {
1286
- return maybeAsString(node.props.children);
1283
+ if (isValidElement(node)) {
1284
+ // Fragment doesn't render DOM elements
1285
+ if (node.type === Fragment) {
1286
+ return maybeAsString(node.props.children);
1287
+ } else if (node.type === Trans) {
1288
+ // Trans also doesn't render DOM elements. But we don't want to just render
1289
+ // its content string, because we want to keep the <Trans/> for the localization.
1290
+ // So we render the same node, to be wrapped into __wab_slot-string-wrapper.
1291
+ return node;
1292
+ }
1287
1293
  }
1288
1294
  if (typeof node === "string") {
1289
1295
  return node;
@@ -1503,6 +1509,9 @@ function useTrigger(trigger, opts) {
1503
1509
  return TRIGGER_TO_HOOK[trigger](opts);
1504
1510
  }
1505
1511
 
1512
+ var ARRAY_SYMBOL = /*#__PURE__*/Symbol("[]");
1513
+ var PLASMIC_STATE_PROXY_SYMBOL = /*#__PURE__*/Symbol("plasmic.state.proxy");
1514
+
1506
1515
  function generateStateOnChangeProp($state, stateName, dataReps) {
1507
1516
  return function (val, path) {
1508
1517
  return set($state, [stateName].concat(dataReps, path), val);
@@ -1519,6 +1528,9 @@ function generateStateValueProp($state, path // ["parent", 0, 1, "counter"]
1519
1528
  return _get($state, path);
1520
1529
  }
1521
1530
  var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? useLayoutEffect : useEffect;
1531
+ function isPlasmicStateProxy(obj) {
1532
+ return obj != null && typeof obj === "object" && obj[PLASMIC_STATE_PROXY_SYMBOL];
1533
+ }
1522
1534
  function shallowEqual(a1, a2) {
1523
1535
  if (a1.length !== a2.length) {
1524
1536
  return false;
@@ -1589,8 +1601,6 @@ function assignValue(object, key, value) {
1589
1601
  }
1590
1602
  }
1591
1603
 
1592
- var ARRAY_SYMBOL = /*#__PURE__*/Symbol("[]");
1593
-
1594
1604
  var UNINITIALIZED = /*#__PURE__*/Symbol("plasmic.unitialized");
1595
1605
  var StateSpecNode = /*#__PURE__*/function () {
1596
1606
  function StateSpecNode(specs) {
@@ -1802,6 +1812,9 @@ function create$StateProxy($$state, leafHandlers) {
1802
1812
  return Reflect.deleteProperty(target, property);
1803
1813
  },
1804
1814
  get: function get(target, property, receiver) {
1815
+ if (property === PLASMIC_STATE_PROXY_SYMBOL) {
1816
+ return true;
1817
+ }
1805
1818
  proxyRoot = proxyRoot == null ? receiver : proxyRoot;
1806
1819
  var nextPath = getNextPath(property);
1807
1820
  if (isOutside || currNode.isLeaf()) {
@@ -1860,7 +1873,7 @@ function create$StateProxy($$state, leafHandlers) {
1860
1873
  return true;
1861
1874
  }
1862
1875
  };
1863
- var baseObject = !isOutside && !currNode.isLeaf() ? currNode.hasArrayTransition() ? [] : {} : Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
1876
+ var baseObject = !isOutside && !currNode.isLeaf() ? currNode.hasArrayTransition() ? [] : {} : Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject != null ? initialObject : {}));
1864
1877
  var proxyObj = new Proxy(baseObject, handlers);
1865
1878
  if (initialObject) {
1866
1879
  Reflect.ownKeys(initialObject).forEach(function (key) {
@@ -1893,46 +1906,43 @@ function useDollarState(specs, props, $ctx) {
1893
1906
  }()).current;
1894
1907
  $$state.props = props;
1895
1908
  $$state.ctx = $ctx != null ? $ctx : {};
1896
- var $state = React__default.useRef(function () {
1897
- var useRef$state = Object.assign(create$StateProxy($$state, function (node, path, proxyRoot) {
1898
- if (!node.hasState(path)) {
1899
- node.createStateCell(path);
1909
+ var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (node, path, proxyRoot) {
1910
+ if (!node.hasState(path)) {
1911
+ node.createStateCell(path);
1912
+ var spec = node.getSpec();
1913
+ if (spec.initFunc) {
1914
+ initializeStateValue($$state, node, path, proxyRoot);
1915
+ } else if (!spec.valueProp) {
1916
+ set(proxyRoot, path, spec.initVal);
1917
+ }
1918
+ }
1919
+ return {
1920
+ get: function get(target, property, receiver) {
1900
1921
  var spec = node.getSpec();
1901
- if (spec.initFunc) {
1902
- initializeStateValue($$state, node, path, proxyRoot);
1903
- } else if (!spec.valueProp) {
1904
- set(proxyRoot, path, spec.initVal);
1922
+ if (spec.valueProp) {
1923
+ return $$state.props[spec.valueProp];
1924
+ } else {
1925
+ return Reflect.get(target, property, receiver);
1905
1926
  }
1906
1927
  }
1907
- return {
1908
- get: function get(target, property, receiver) {
1909
- var spec = node.getSpec();
1910
- if (spec.valueProp) {
1911
- return $$state.props[spec.valueProp];
1912
- } else {
1913
- return Reflect.get(target, property, receiver);
1914
- }
1915
- }
1916
- };
1917
- }), {
1918
- registerInitFunc: function registerInitFunc(pathStr, f, repetitionIndex) {
1919
- var _findStateCell = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex),
1920
- node = _findStateCell.node,
1921
- realPath = _findStateCell.realPath;
1922
- if (!node.hasState(realPath)) {
1923
- node.createStateCell(realPath);
1924
- }
1925
- if (!deepEqual(node.getState(realPath).initialValue, f($$state.props, useRef$state, $$state.ctx))) {
1926
- $$state.registrationsQueue.push({
1927
- node: node,
1928
- path: realPath,
1929
- f: f
1930
- });
1931
- }
1928
+ };
1929
+ }), {
1930
+ registerInitFunc: function registerInitFunc(pathStr, f, repetitionIndex) {
1931
+ var _findStateCell = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex),
1932
+ node = _findStateCell.node,
1933
+ realPath = _findStateCell.realPath;
1934
+ if (!node.hasState(realPath)) {
1935
+ node.createStateCell(realPath);
1932
1936
  }
1933
- });
1934
- return useRef$state;
1935
- }()).current;
1937
+ if (!deepEqual(node.getState(realPath).initialValue, f($$state.props, $state, $$state.ctx))) {
1938
+ $$state.registrationsQueue.push({
1939
+ node: node,
1940
+ path: realPath,
1941
+ f: f
1942
+ });
1943
+ }
1944
+ }
1945
+ })).current;
1936
1946
  // For each spec with an initFunc, evaluate it and see if
1937
1947
  // the init value has changed. If so, reset its state.
1938
1948
  var resetSpecs = [];
@@ -3395,5 +3405,5 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
3395
3405
  };
3396
3406
  }
3397
3407
 
3398
- export { DropdownMenu, PlasmicHead, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicPageGuard, PlasmicRootProvider, PlasmicSlot, SelectContext, Stack, Trans, TriggeredOverlayContext, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, generateStateOnChangeProp, generateStateValueProp, getDataProps, hasVariant, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, useButton, useCheckbox, useDollarState, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
3408
+ export { DropdownMenu, PlasmicHead, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicPageGuard, PlasmicRootProvider, PlasmicSlot, SelectContext, Stack, Trans, TriggeredOverlayContext, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, generateStateOnChangeProp, generateStateValueProp, getDataProps, hasVariant, isPlasmicStateProxy, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, useButton, useCheckbox, useDollarState, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
3399
3409
  //# sourceMappingURL=react-web.esm.js.map