@plasmicapp/react-web 0.2.91 → 0.2.95

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 (70) hide show
  1. package/dist/all.d.ts +20 -2
  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 +95 -1
  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 +94 -2
  12. package/dist/react-web.esm.js.map +1 -1
  13. package/dist/render/ssr.d.ts +2 -0
  14. package/dist/render/translation.d.ts +18 -0
  15. package/lib/plasmic.css +1 -1
  16. package/package.json +3 -3
  17. package/skinny/dist/collection-utils-47e89cbe.js +238 -0
  18. package/skinny/dist/collection-utils-47e89cbe.js.map +1 -0
  19. package/skinny/dist/collection-utils-4dae6efa.js +292 -0
  20. package/skinny/dist/collection-utils-4dae6efa.js.map +1 -0
  21. package/skinny/dist/collection-utils-57ec40f9.js +292 -0
  22. package/skinny/dist/collection-utils-57ec40f9.js.map +1 -0
  23. package/skinny/dist/collection-utils-96cde83c.js +238 -0
  24. package/skinny/dist/collection-utils-96cde83c.js.map +1 -0
  25. package/skinny/dist/collection-utils-b0b8f30e.js +291 -0
  26. package/skinny/dist/collection-utils-b0b8f30e.js.map +1 -0
  27. package/skinny/dist/index-common.d.ts +1 -0
  28. package/skinny/dist/index.js +1 -1
  29. package/skinny/dist/index.js.map +1 -1
  30. package/skinny/dist/plume/checkbox/index.js +1 -1
  31. package/skinny/dist/plume/menu/index.js +1 -1
  32. package/skinny/dist/plume/menu-button/index.js +1 -1
  33. package/skinny/dist/plume/select/index.js +1 -1
  34. package/skinny/dist/plume/switch/index.js +1 -1
  35. package/skinny/dist/plume/text-input/index.d.ts +1 -1
  36. package/skinny/dist/plume/text-input/index.js.map +1 -1
  37. package/skinny/dist/plume-utils-5c413fd1.js +35 -0
  38. package/skinny/dist/plume-utils-5c413fd1.js.map +1 -0
  39. package/skinny/dist/props-utils-4633caf6.js +8 -0
  40. package/skinny/dist/props-utils-4633caf6.js.map +1 -0
  41. package/skinny/dist/props-utils-5c0ad25a.js +59 -0
  42. package/skinny/dist/props-utils-5c0ad25a.js.map +1 -0
  43. package/skinny/dist/props-utils-754f655a.js +39 -0
  44. package/skinny/dist/props-utils-754f655a.js.map +1 -0
  45. package/skinny/dist/props-utils-c632595f.js +59 -0
  46. package/skinny/dist/props-utils-c632595f.js.map +1 -0
  47. package/skinny/dist/props-utils-fd5f444e.js +59 -0
  48. package/skinny/dist/props-utils-fd5f444e.js.map +1 -0
  49. package/skinny/dist/react-utils-118d8539.js +190 -0
  50. package/skinny/dist/react-utils-118d8539.js.map +1 -0
  51. package/skinny/dist/react-utils-2a2fd6c9.js +339 -0
  52. package/skinny/dist/react-utils-2a2fd6c9.js.map +1 -0
  53. package/skinny/dist/react-utils-2d70bbbe.js +172 -0
  54. package/skinny/dist/react-utils-2d70bbbe.js.map +1 -0
  55. package/skinny/dist/react-utils-675565b4.js +334 -0
  56. package/skinny/dist/react-utils-675565b4.js.map +1 -0
  57. package/skinny/dist/react-utils.d.ts +1 -1
  58. package/skinny/dist/render/PlasmicImg.d.ts +62 -0
  59. package/skinny/dist/render/ssr.d.ts +2 -0
  60. package/skinny/dist/render/translation.d.ts +18 -0
  61. package/skinny/dist/ssr-64e38713.js +108 -0
  62. package/skinny/dist/ssr-64e38713.js.map +1 -0
  63. package/skinny/dist/ssr-902d1292.js +105 -0
  64. package/skinny/dist/ssr-902d1292.js.map +1 -0
  65. package/skinny/dist/ssr-a8081074.js +108 -0
  66. package/skinny/dist/ssr-a8081074.js.map +1 -0
  67. package/skinny/dist/tslib.es6-00014098.js +148 -0
  68. package/skinny/dist/tslib.es6-00014098.js.map +1 -0
  69. package/skinny/dist/tslib.es6-73236e8e.js +141 -0
  70. package/skinny/dist/tslib.es6-73236e8e.js.map +1 -0
package/dist/all.d.ts CHANGED
@@ -447,9 +447,27 @@ interface AriaSwitchBase extends SwitchBase, FocusableDOMProps, AriaLabelingProp
447
447
  }
448
448
  interface AriaSwitchProps extends SwitchProps$1, AriaSwitchBase {}
449
449
 
450
+ declare type PlasmicTranslator = (str: string, opts?: {
451
+ components?: {
452
+ [key: string]: React__default.ReactElement;
453
+ };
454
+ }) => React__default.ReactNode;
455
+ interface TransProps {
456
+ children?: React__default.ReactNode;
457
+ }
458
+ declare function genTranslatableString(elt: React__default.ReactNode): {
459
+ str: string;
460
+ components: {
461
+ [key: string]: React__default.ReactElement<any, string | ((props: any) => React__default.ReactElement<any, any> | null) | (new (props: any) => React__default.Component<any, any, any>)>;
462
+ };
463
+ componentsCount: number;
464
+ };
465
+ declare function Trans({ children }: TransProps): React__default.ReactNode;
466
+
450
467
  interface PlasmicRootProviderProps {
451
468
  platform?: "nextjs" | "gatsby";
452
469
  children?: React.ReactNode;
470
+ translator?: PlasmicTranslator;
453
471
  }
454
472
  declare function PlasmicRootProvider(props: PlasmicRootProviderProps): JSX.Element;
455
473
  declare const useIsSSR: typeof useIsSSR$1;
@@ -1109,7 +1127,7 @@ interface BaseTextInputProps extends Omit<React.ComponentProps<"input">, "type"
1109
1127
  startIcon?: React.ReactNode;
1110
1128
  endIcon?: React.ReactNode;
1111
1129
  isDisabled?: boolean;
1112
- type?: "text" | "password" | "email" | "url";
1130
+ type?: "text" | "password" | "email" | "url" | string;
1113
1131
  inputClassName?: string;
1114
1132
  inputStyle?: React.CSSProperties;
1115
1133
  }
@@ -1158,4 +1176,4 @@ declare function useTriggeredOverlay<P extends BaseTriggeredOverlayProps, C exte
1158
1176
  };
1159
1177
  };
1160
1178
 
1161
- export { BaseButtonProps, BaseMenuButtonProps, BaseMenuGroupProps, BaseMenuItemProps, BaseMenuProps, BaseSelectOptionGroupProps, BaseSelectOptionProps, BaseSelectProps, BaseTextInputProps, BaseTriggeredOverlayProps, ButtonRef, CheckboxProps, CheckboxRef, CheckboxRefValue, DropdownMenu, Flex, HTMLElementRefOf, HtmlAnchorOnlyProps, HtmlButtonOnlyProps, MenuButtonRef, MenuButtonRefValue, MenuRef, MenuRefValue, MultiChoiceArg, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicRootProvider, PlasmicSlot, SelectOptionRef, SelectRef, SelectRefValue, SingleBooleanChoiceArg, SingleChoiceArg, Stack, StrictProps, SwitchProps, SwitchRef, SwitchRefValue, TextInputRef, TextInputRefValue, TriggeredOverlayConfig, TriggeredOverlayRef, 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 };
1179
+ export { BaseButtonProps, BaseMenuButtonProps, BaseMenuGroupProps, BaseMenuItemProps, BaseMenuProps, BaseSelectOptionGroupProps, BaseSelectOptionProps, BaseSelectProps, BaseTextInputProps, BaseTriggeredOverlayProps, ButtonRef, CheckboxProps, CheckboxRef, CheckboxRefValue, DropdownMenu, Flex, HTMLElementRefOf, HtmlAnchorOnlyProps, HtmlButtonOnlyProps, MenuButtonRef, MenuButtonRefValue, MenuRef, MenuRefValue, MultiChoiceArg, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicRootProvider, PlasmicSlot, SelectOptionRef, SelectRef, SelectRefValue, SingleBooleanChoiceArg, SingleChoiceArg, Stack, StrictProps, SwitchProps, SwitchRef, SwitchRefValue, TextInputRef, TextInputRefValue, Trans, TriggeredOverlayConfig, TriggeredOverlayRef, 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 };
@@ -11,3 +11,4 @@ export { createUseScreenVariants } from "./render/screen-variants";
11
11
  export { PlasmicRootProvider, useIsSSR } from "./render/ssr";
12
12
  export { Stack } from "./render/Stack";
13
13
  export { useTrigger } from "./render/triggers";
14
+ export { Trans, genTranslatableString } from "./render/translation";
@@ -137,7 +137,7 @@ export declare function useDerivedItemsFromChildren<T extends React.ReactElement
137
137
  * Given a Collection node, create the React element that we should use
138
138
  * to render it.
139
139
  */
140
- export declare function renderCollectionNode(node: Node<any>): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
140
+ export declare function renderCollectionNode(node: Node<any>): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>;
141
141
  /**
142
142
  * Renders a item-like or section-like Plume component element into an
143
143
  * Item or a Section element.
@@ -16,6 +16,6 @@ export declare function useMenuTrigger(opts: {
16
16
  menu: React.ReactElement<BaseMenuProps> | (() => React.ReactElement<BaseMenuProps>);
17
17
  }, state: MenuTriggerState): {
18
18
  triggerProps: React.HTMLAttributes<HTMLElement>;
19
- makeMenu: () => React.ReactElement<BaseMenuProps, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null;
19
+ makeMenu: () => React.ReactElement<BaseMenuProps, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | null;
20
20
  triggerContext: TriggeredOverlayContextValue;
21
21
  };
@@ -6,7 +6,7 @@ export interface BaseTextInputProps extends Omit<React.ComponentProps<"input">,
6
6
  startIcon?: React.ReactNode;
7
7
  endIcon?: React.ReactNode;
8
8
  isDisabled?: boolean;
9
- type?: "text" | "password" | "email" | "url";
9
+ type?: "text" | "password" | "email" | "url" | string;
10
10
  inputClassName?: string;
11
11
  inputStyle?: React.CSSProperties;
12
12
  }
@@ -2,8 +2,8 @@ import React from "react";
2
2
  export declare const isBrowser: boolean;
3
3
  export declare const NONE: unique symbol;
4
4
  export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
5
- export declare function createElementWithChildren(elementType: any, props: any, children: React.ReactNode): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.CElement<any, React.Component<any, any, any>>;
6
- export declare function ensureNotArray(children: React.ReactNode): {} | null | undefined;
5
+ export declare function createElementWithChildren(elementType: any, props: any, children: React.ReactNode): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | React.CElement<any, React.Component<any, any, any>>;
6
+ export declare function ensureNotArray(children: React.ReactNode): any;
7
7
  /**
8
8
  * Flattens ReactNode into an array of ReactChild, but does NOT replace
9
9
  * missing keys with array index, as React.Children.toArray() does.
@@ -1345,6 +1345,96 @@ function createUseScreenVariants(isMulti, screenQueries) {
1345
1345
  };
1346
1346
  }
1347
1347
 
1348
+ var PlasmicTranslatorContext = /*#__PURE__*/React__default.createContext(undefined);
1349
+
1350
+ function isIterable(val) {
1351
+ return val != null && typeof val[Symbol.iterator] === "function";
1352
+ }
1353
+
1354
+ function genTranslatableString(elt) {
1355
+ var components = {};
1356
+ var componentsCount = 0;
1357
+
1358
+ var getText = function getText(node) {
1359
+ if (!node) {
1360
+ return "";
1361
+ }
1362
+
1363
+ if (typeof node === "number" || typeof node === "boolean" || typeof node === "string") {
1364
+ return node.toString();
1365
+ }
1366
+
1367
+ if (typeof node !== "object") {
1368
+ return "";
1369
+ }
1370
+
1371
+ if (Array.isArray(node) || isIterable(node)) {
1372
+ return Array.from(node).map(function (child) {
1373
+ return getText(child);
1374
+ }).filter(function (child) {
1375
+ return !!child;
1376
+ }).join("");
1377
+ }
1378
+
1379
+ var nodeChildren = hasKey(node, "props") && hasKey(node.props, "children") && node.props.children || hasKey(node, "children") && node.children || [];
1380
+ var contents = "" + React__default.Children.toArray(nodeChildren).map(function (child) {
1381
+ return getText(child);
1382
+ }).filter(function (child) {
1383
+ return !!child;
1384
+ }).join("");
1385
+
1386
+ if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
1387
+ return contents;
1388
+ }
1389
+
1390
+ var componentId = componentsCount + 1;
1391
+ componentsCount++;
1392
+ components[componentId] = React__default.isValidElement(node) ? React__default.cloneElement(node, {
1393
+ key: componentId,
1394
+ children: undefined
1395
+ }) : node;
1396
+ return "<" + componentId + ">" + contents + "</" + componentId + ">";
1397
+ };
1398
+
1399
+ var str = getText(elt);
1400
+ return {
1401
+ str: str,
1402
+ components: components,
1403
+ componentsCount: componentsCount
1404
+ };
1405
+ }
1406
+ function Trans(_ref) {
1407
+ var children = _ref.children;
1408
+
1409
+ var _t = React__default.useContext(PlasmicTranslatorContext);
1410
+
1411
+ if (!_t) {
1412
+ warnNoTranslationFunctionAtMostOnce();
1413
+ return children;
1414
+ }
1415
+
1416
+ var _genTranslatableStrin = genTranslatableString(children),
1417
+ str = _genTranslatableStrin.str,
1418
+ components = _genTranslatableStrin.components,
1419
+ componentsCount = _genTranslatableStrin.componentsCount;
1420
+
1421
+ return _t(str, componentsCount > 0 ? {
1422
+ components: components
1423
+ } : undefined);
1424
+ }
1425
+ var hasWarned = false;
1426
+
1427
+ function warnNoTranslationFunctionAtMostOnce() {
1428
+ if (!hasWarned) {
1429
+ console.warn("Using Plasmic Translation but no translation function has been provided");
1430
+ hasWarned = true;
1431
+ }
1432
+ }
1433
+
1434
+ function hasKey(v, key) {
1435
+ return typeof v === "object" && v !== null && key in v;
1436
+ }
1437
+
1348
1438
  var PlasmicRootContext = /*#__PURE__*/React.createContext(undefined);
1349
1439
  function PlasmicRootProvider(props) {
1350
1440
  var platform = props.platform,
@@ -1356,7 +1446,9 @@ function PlasmicRootProvider(props) {
1356
1446
  }, [platform]);
1357
1447
  return React.createElement(PlasmicRootContext.Provider, {
1358
1448
  value: context
1359
- }, React.createElement(reactAria.SSRProvider, null, children));
1449
+ }, React.createElement(reactAria.SSRProvider, null, React.createElement(PlasmicTranslatorContext.Provider, {
1450
+ value: props.translator
1451
+ }, children)));
1360
1452
  }
1361
1453
  var useIsSSR = reactAria.useIsSSR;
1362
1454
  function useHasPlasmicRoot() {
@@ -3022,11 +3114,13 @@ exports.PlasmicLink = PlasmicLink;
3022
3114
  exports.PlasmicRootProvider = PlasmicRootProvider;
3023
3115
  exports.PlasmicSlot = PlasmicSlot;
3024
3116
  exports.Stack = Stack;
3117
+ exports.Trans = Trans;
3025
3118
  exports.classNames = classNames;
3026
3119
  exports.createPlasmicElementProxy = createPlasmicElementProxy;
3027
3120
  exports.createUseScreenVariants = createUseScreenVariants;
3028
3121
  exports.deriveRenderOpts = deriveRenderOpts;
3029
3122
  exports.ensureGlobalVariants = ensureGlobalVariants;
3123
+ exports.genTranslatableString = genTranslatableString;
3030
3124
  exports.getDataProps = getDataProps;
3031
3125
  exports.hasVariant = hasVariant;
3032
3126
  exports.makeFragment = makeFragment;