@plasmicapp/react-web 0.2.90 → 0.2.94

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.
Files changed (88) hide show
  1. package/dist/all.d.ts +21 -4
  2. package/dist/index-common.d.ts +1 -0
  3. package/dist/plume/collection-utils.d.ts +1 -1
  4. package/dist/plume/menu-button/menu-trigger.d.ts +1 -1
  5. package/dist/plume/text-input/index.d.ts +1 -1
  6. package/dist/react-utils.d.ts +2 -2
  7. package/dist/react-web.cjs.development.js +105 -6
  8. package/dist/react-web.cjs.development.js.map +1 -1
  9. package/dist/react-web.cjs.production.min.js +1 -1
  10. package/dist/react-web.cjs.production.min.js.map +1 -1
  11. package/dist/react-web.esm.js +104 -7
  12. package/dist/react-web.esm.js.map +1 -1
  13. package/dist/render/PlasmicLink.d.ts +2 -2
  14. package/dist/render/ssr.d.ts +2 -0
  15. package/dist/render/translation.d.ts +18 -0
  16. package/lib/plasmic.css +1 -1
  17. package/package.json +3 -3
  18. package/skinny/dist/{collection-utils-aadc3a43.js → collection-utils-47e89cbe.js} +4 -4
  19. package/skinny/dist/{collection-utils-976df07d.js.map → collection-utils-47e89cbe.js.map} +1 -1
  20. package/skinny/dist/collection-utils-4dae6efa.js +292 -0
  21. package/skinny/dist/{collection-utils-21ad9cae.js.map → collection-utils-4dae6efa.js.map} +1 -1
  22. package/skinny/dist/collection-utils-57ec40f9.js +292 -0
  23. package/skinny/dist/{collection-utils-aadc3a43.js.map → collection-utils-57ec40f9.js.map} +1 -1
  24. package/skinny/dist/collection-utils-b0b8f30e.js +287 -234
  25. package/skinny/dist/index-common.d.ts +1 -0
  26. package/skinny/dist/index.js +6 -6
  27. package/skinny/dist/index.js.map +1 -1
  28. package/skinny/dist/plume/checkbox/index.js +1 -1
  29. package/skinny/dist/plume/menu/index.js +1 -1
  30. package/skinny/dist/plume/menu-button/index.js +1 -1
  31. package/skinny/dist/plume/select/index.js +1 -1
  32. package/skinny/dist/plume/switch/index.js +1 -1
  33. package/skinny/dist/plume/text-input/index.d.ts +1 -1
  34. package/skinny/dist/plume/text-input/index.js.map +1 -1
  35. package/skinny/dist/{props-utils-6cf101b2.js → plume-utils-5c413fd1.js} +3 -7
  36. package/skinny/dist/plume-utils-5c413fd1.js.map +1 -0
  37. package/skinny/dist/props-utils-4633caf6.js +8 -0
  38. package/skinny/dist/props-utils-4633caf6.js.map +1 -0
  39. package/skinny/dist/props-utils-5c0ad25a.js +59 -0
  40. package/skinny/dist/{props-utils-6cf101b2.js.map → props-utils-5c0ad25a.js.map} +1 -1
  41. package/skinny/dist/props-utils-c632595f.js +53 -33
  42. package/skinny/dist/props-utils-fd5f444e.js +59 -0
  43. package/skinny/dist/{props-utils-1f98cfd3.js.map → props-utils-fd5f444e.js.map} +1 -1
  44. package/skinny/dist/react-utils-118d8539.js +186 -168
  45. package/skinny/dist/react-utils-2a2fd6c9.js +339 -0
  46. package/skinny/dist/react-utils-2a2fd6c9.js.map +1 -0
  47. package/skinny/dist/{react-utils-14af9d28.js → react-utils-2d70bbbe.js} +2 -2
  48. package/skinny/dist/react-utils-2d70bbbe.js.map +1 -0
  49. package/skinny/dist/react-utils-675565b4.js +334 -0
  50. package/skinny/dist/react-utils-675565b4.js.map +1 -0
  51. package/skinny/dist/react-utils.d.ts +1 -1
  52. package/skinny/dist/render/PlasmicImg.d.ts +62 -55
  53. package/skinny/dist/render/PlasmicLink.d.ts +2 -2
  54. package/skinny/dist/render/ssr.d.ts +2 -0
  55. package/skinny/dist/render/translation.d.ts +18 -0
  56. package/skinny/dist/ssr-902d1292.js +105 -0
  57. package/skinny/dist/ssr-902d1292.js.map +1 -0
  58. package/skinny/dist/ssr-a8081074.js +108 -0
  59. package/skinny/dist/ssr-a8081074.js.map +1 -0
  60. package/skinny/dist/tslib.es6-00014098.js +143 -123
  61. package/skinny/dist/{tslib.es6-10d3f595.js → tslib.es6-73236e8e.js} +12 -3
  62. package/skinny/dist/tslib.es6-73236e8e.js.map +1 -0
  63. package/skinny/dist/collection-utils-21ad9cae.js +0 -238
  64. package/skinny/dist/collection-utils-87ffc0ed.js +0 -238
  65. package/skinny/dist/collection-utils-87ffc0ed.js.map +0 -1
  66. package/skinny/dist/collection-utils-976df07d.js +0 -238
  67. package/skinny/dist/collection-utils-b8a2fd59.js +0 -238
  68. package/skinny/dist/collection-utils-b8a2fd59.js.map +0 -1
  69. package/skinny/dist/props-utils-1f98cfd3.js +0 -40
  70. package/skinny/dist/props-utils-40224c71.js +0 -40
  71. package/skinny/dist/props-utils-40224c71.js.map +0 -1
  72. package/skinny/dist/props-utils-69f9ba8b.js +0 -40
  73. package/skinny/dist/props-utils-69f9ba8b.js.map +0 -1
  74. package/skinny/dist/props-utils-85691c9c.js +0 -40
  75. package/skinny/dist/props-utils-85691c9c.js.map +0 -1
  76. package/skinny/dist/react-utils-06bae09a.js +0 -254
  77. package/skinny/dist/react-utils-06bae09a.js.map +0 -1
  78. package/skinny/dist/react-utils-14af9d28.js.map +0 -1
  79. package/skinny/dist/react-utils-834a65c3.js +0 -254
  80. package/skinny/dist/react-utils-834a65c3.js.map +0 -1
  81. package/skinny/dist/react-utils-ae69f4e0.js +0 -254
  82. package/skinny/dist/react-utils-ae69f4e0.js.map +0 -1
  83. package/skinny/dist/react-utils-cca81efc.js +0 -245
  84. package/skinny/dist/react-utils-cca81efc.js.map +0 -1
  85. package/skinny/dist/stories/Button.d.ts +0 -29
  86. package/skinny/dist/stories/Header.d.ts +0 -10
  87. package/skinny/dist/stories/Page.d.ts +0 -10
  88. package/skinny/dist/tslib.es6-10d3f595.js.map +0 -1
@@ -1158,22 +1158,27 @@ var PLASMIC_IMAGE_LOADER = {
1158
1158
  }
1159
1159
  };
1160
1160
 
1161
- function PlasmicLink(props) {
1161
+ var PlasmicLink = /*#__PURE__*/React__default.forwardRef(function PlasmicLink(props, ref) {
1162
1162
  // props.href is required for nextjs; if no props.href,
1163
1163
  // then we just render the default anchor element
1164
1164
  if (props.platform === "nextjs" && props.href) {
1165
1165
  var nextjsProps = ["href", "replace", "scroll", "shallow", "passHref", "prefetch", "locale"];
1166
- return React__default.createElement(props.component, pick.apply(void 0, [props].concat(nextjsProps)), React__default.createElement("a", Object.assign({}, omit.apply(void 0, [props, "component", "platform"].concat(nextjsProps)))));
1166
+ return React__default.createElement(props.component, pick.apply(void 0, [props].concat(nextjsProps)), React__default.createElement("a", Object.assign({}, omit.apply(void 0, [props, "component", "platform"].concat(nextjsProps)), {
1167
+ ref: ref
1168
+ })));
1167
1169
  }
1168
1170
 
1169
1171
  if (props.platform === "gatsby" && isInternalHref(props.href)) {
1170
1172
  return React__default.createElement(props.component, _extends({}, omit(props, "component", "platform", "href"), {
1171
- to: props.href
1173
+ to: props.href,
1174
+ ref: ref
1172
1175
  }));
1173
1176
  }
1174
1177
 
1175
- return React__default.createElement("a", Object.assign({}, omit(props, "component", "platform")));
1176
- }
1178
+ return React__default.createElement("a", Object.assign({}, omit(props, "component", "platform"), {
1179
+ ref: ref
1180
+ }));
1181
+ });
1177
1182
 
1178
1183
  function isInternalHref(href) {
1179
1184
  return /^\/(?!\/)/.test(href);
@@ -1333,6 +1338,96 @@ function createUseScreenVariants(isMulti, screenQueries) {
1333
1338
  };
1334
1339
  }
1335
1340
 
1341
+ var PlasmicTranslatorContext = /*#__PURE__*/React__default.createContext(undefined);
1342
+
1343
+ function isIterable(val) {
1344
+ return val != null && typeof val[Symbol.iterator] === "function";
1345
+ }
1346
+
1347
+ function genTranslatableString(elt) {
1348
+ var components = {};
1349
+ var componentsCount = 0;
1350
+
1351
+ var getText = function getText(node) {
1352
+ if (!node) {
1353
+ return "";
1354
+ }
1355
+
1356
+ if (typeof node === "number" || typeof node === "boolean" || typeof node === "string") {
1357
+ return node.toString();
1358
+ }
1359
+
1360
+ if (typeof node !== "object") {
1361
+ return "";
1362
+ }
1363
+
1364
+ if (Array.isArray(node) || isIterable(node)) {
1365
+ return Array.from(node).map(function (child) {
1366
+ return getText(child);
1367
+ }).filter(function (child) {
1368
+ return !!child;
1369
+ }).join("");
1370
+ }
1371
+
1372
+ var nodeChildren = hasKey(node, "props") && hasKey(node.props, "children") && node.props.children || hasKey(node, "children") && node.children || [];
1373
+ var contents = "" + React__default.Children.toArray(nodeChildren).map(function (child) {
1374
+ return getText(child);
1375
+ }).filter(function (child) {
1376
+ return !!child;
1377
+ }).join("");
1378
+
1379
+ if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
1380
+ return contents;
1381
+ }
1382
+
1383
+ var componentId = componentsCount;
1384
+ componentsCount++;
1385
+ components["t" + componentId] = React__default.isValidElement(node) ? React__default.cloneElement(node, {
1386
+ key: componentId,
1387
+ children: undefined
1388
+ }) : node;
1389
+ return "<t" + componentId + ">" + contents + "</t" + componentId + ">";
1390
+ };
1391
+
1392
+ var str = getText(elt);
1393
+ return {
1394
+ str: str,
1395
+ components: components,
1396
+ componentsCount: componentsCount
1397
+ };
1398
+ }
1399
+ function Trans(_ref) {
1400
+ var children = _ref.children;
1401
+
1402
+ var _t = React__default.useContext(PlasmicTranslatorContext);
1403
+
1404
+ if (!_t) {
1405
+ warnNoTranslationFunctionAtMostOnce();
1406
+ return children;
1407
+ }
1408
+
1409
+ var _genTranslatableStrin = genTranslatableString(children),
1410
+ str = _genTranslatableStrin.str,
1411
+ components = _genTranslatableStrin.components,
1412
+ componentsCount = _genTranslatableStrin.componentsCount;
1413
+
1414
+ return _t(str, componentsCount > 0 ? {
1415
+ components: components
1416
+ } : undefined);
1417
+ }
1418
+ var hasWarned = false;
1419
+
1420
+ function warnNoTranslationFunctionAtMostOnce() {
1421
+ if (!hasWarned) {
1422
+ console.warn("Using Plasmic Translation but no translation function has been provided");
1423
+ hasWarned = true;
1424
+ }
1425
+ }
1426
+
1427
+ function hasKey(v, key) {
1428
+ return typeof v === "object" && v !== null && key in v;
1429
+ }
1430
+
1336
1431
  var PlasmicRootContext = /*#__PURE__*/createContext(undefined);
1337
1432
  function PlasmicRootProvider(props) {
1338
1433
  var platform = props.platform,
@@ -1344,7 +1439,9 @@ function PlasmicRootProvider(props) {
1344
1439
  }, [platform]);
1345
1440
  return createElement(PlasmicRootContext.Provider, {
1346
1441
  value: context
1347
- }, createElement(SSRProvider, null, children));
1442
+ }, createElement(SSRProvider, null, createElement(PlasmicTranslatorContext.Provider, {
1443
+ value: props.translator
1444
+ }, children)));
1348
1445
  }
1349
1446
  var useIsSSR = useIsSSR$1;
1350
1447
  function useHasPlasmicRoot() {
@@ -3003,5 +3100,5 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef) {
3003
3100
  };
3004
3101
  }
3005
3102
 
3006
- export { DropdownMenu, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicRootProvider, PlasmicSlot, Stack, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, getDataProps, hasVariant, makeFragment, omit, pick, renderPlasmicSlot, setPlumeStrictMode, useButton, useCheckbox, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
3103
+ export { DropdownMenu, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicRootProvider, PlasmicSlot, Stack, Trans, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, getDataProps, hasVariant, makeFragment, omit, pick, renderPlasmicSlot, setPlumeStrictMode, useButton, useCheckbox, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
3007
3104
  //# sourceMappingURL=react-web.esm.js.map