@plasmicapp/react-web 0.2.93 → 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 (64) hide show
  1. package/dist/all.d.ts +19 -1
  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/react-utils.d.ts +2 -2
  6. package/dist/react-web.cjs.development.js +95 -1
  7. package/dist/react-web.cjs.development.js.map +1 -1
  8. package/dist/react-web.cjs.production.min.js +1 -1
  9. package/dist/react-web.cjs.production.min.js.map +1 -1
  10. package/dist/react-web.esm.js +94 -2
  11. package/dist/react-web.esm.js.map +1 -1
  12. package/dist/render/ssr.d.ts +2 -0
  13. package/dist/render/translation.d.ts +18 -0
  14. package/package.json +1 -1
  15. package/skinny/dist/collection-utils-47e89cbe.js +238 -0
  16. package/skinny/dist/collection-utils-47e89cbe.js.map +1 -0
  17. package/skinny/dist/collection-utils-4dae6efa.js +292 -0
  18. package/skinny/dist/collection-utils-4dae6efa.js.map +1 -0
  19. package/skinny/dist/collection-utils-57ec40f9.js +292 -0
  20. package/skinny/dist/collection-utils-57ec40f9.js.map +1 -0
  21. package/skinny/dist/collection-utils-96cde83c.js +238 -0
  22. package/skinny/dist/collection-utils-96cde83c.js.map +1 -0
  23. package/skinny/dist/collection-utils-b0b8f30e.js +291 -0
  24. package/skinny/dist/collection-utils-b0b8f30e.js.map +1 -0
  25. package/skinny/dist/index-common.d.ts +1 -0
  26. package/skinny/dist/index.js +1 -1
  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-utils-5c413fd1.js +35 -0
  34. package/skinny/dist/plume-utils-5c413fd1.js.map +1 -0
  35. package/skinny/dist/props-utils-4633caf6.js +8 -0
  36. package/skinny/dist/props-utils-4633caf6.js.map +1 -0
  37. package/skinny/dist/props-utils-5c0ad25a.js +59 -0
  38. package/skinny/dist/props-utils-5c0ad25a.js.map +1 -0
  39. package/skinny/dist/props-utils-754f655a.js +39 -0
  40. package/skinny/dist/props-utils-754f655a.js.map +1 -0
  41. package/skinny/dist/props-utils-c632595f.js +59 -0
  42. package/skinny/dist/props-utils-c632595f.js.map +1 -0
  43. package/skinny/dist/props-utils-fd5f444e.js +59 -0
  44. package/skinny/dist/props-utils-fd5f444e.js.map +1 -0
  45. package/skinny/dist/react-utils-118d8539.js +190 -0
  46. package/skinny/dist/react-utils-118d8539.js.map +1 -0
  47. package/skinny/dist/react-utils-2a2fd6c9.js +339 -0
  48. package/skinny/dist/react-utils-2a2fd6c9.js.map +1 -0
  49. package/skinny/dist/react-utils-2d70bbbe.js +172 -0
  50. package/skinny/dist/react-utils-2d70bbbe.js.map +1 -0
  51. package/skinny/dist/react-utils-675565b4.js +334 -0
  52. package/skinny/dist/react-utils-675565b4.js.map +1 -0
  53. package/skinny/dist/react-utils.d.ts +1 -1
  54. package/skinny/dist/render/PlasmicImg.d.ts +62 -0
  55. package/skinny/dist/render/ssr.d.ts +2 -0
  56. package/skinny/dist/render/translation.d.ts +18 -0
  57. package/skinny/dist/ssr-902d1292.js +105 -0
  58. package/skinny/dist/ssr-902d1292.js.map +1 -0
  59. package/skinny/dist/ssr-a8081074.js +108 -0
  60. package/skinny/dist/ssr-a8081074.js.map +1 -0
  61. package/skinny/dist/tslib.es6-00014098.js +148 -0
  62. package/skinny/dist/tslib.es6-00014098.js.map +1 -0
  63. package/skinny/dist/tslib.es6-73236e8e.js +141 -0
  64. package/skinny/dist/tslib.es6-73236e8e.js.map +1 -0
@@ -1338,6 +1338,96 @@ function createUseScreenVariants(isMulti, screenQueries) {
1338
1338
  };
1339
1339
  }
1340
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
+
1341
1431
  var PlasmicRootContext = /*#__PURE__*/createContext(undefined);
1342
1432
  function PlasmicRootProvider(props) {
1343
1433
  var platform = props.platform,
@@ -1349,7 +1439,9 @@ function PlasmicRootProvider(props) {
1349
1439
  }, [platform]);
1350
1440
  return createElement(PlasmicRootContext.Provider, {
1351
1441
  value: context
1352
- }, createElement(SSRProvider, null, children));
1442
+ }, createElement(SSRProvider, null, createElement(PlasmicTranslatorContext.Provider, {
1443
+ value: props.translator
1444
+ }, children)));
1353
1445
  }
1354
1446
  var useIsSSR = useIsSSR$1;
1355
1447
  function useHasPlasmicRoot() {
@@ -3008,5 +3100,5 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef) {
3008
3100
  };
3009
3101
  }
3010
3102
 
3011
- 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 };
3012
3104
  //# sourceMappingURL=react-web.esm.js.map