@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
package/dist/all.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import * as React from 'react';
3
2
  import React__default, { FocusEvent, KeyboardEvent as KeyboardEvent$1, SyntheticEvent, ReactNode } from 'react';
4
3
 
@@ -163,7 +162,7 @@ interface PlasmicImgProps extends ImgTagProps {
163
162
  }
164
163
  declare const PlasmicImg: React__default.ForwardRefExoticComponent<PlasmicImgProps & React__default.RefAttributes<HTMLElement>>;
165
164
 
166
- declare function PlasmicLink(props: any): JSX.Element;
165
+ declare const PlasmicLink: React__default.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React__default.RefAttributes<any>>;
167
166
 
168
167
  declare function PlasmicSlot<T extends keyof JSX.IntrinsicElements = "div">(props: React.ComponentProps<T> & {
169
168
  as?: T;
@@ -448,9 +447,27 @@ interface AriaSwitchBase extends SwitchBase, FocusableDOMProps, AriaLabelingProp
448
447
  }
449
448
  interface AriaSwitchProps extends SwitchProps$1, AriaSwitchBase {}
450
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
+
451
467
  interface PlasmicRootProviderProps {
452
468
  platform?: "nextjs" | "gatsby";
453
469
  children?: React.ReactNode;
470
+ translator?: PlasmicTranslator;
454
471
  }
455
472
  declare function PlasmicRootProvider(props: PlasmicRootProviderProps): JSX.Element;
456
473
  declare const useIsSSR: typeof useIsSSR$1;
@@ -1110,7 +1127,7 @@ interface BaseTextInputProps extends Omit<React.ComponentProps<"input">, "type"
1110
1127
  startIcon?: React.ReactNode;
1111
1128
  endIcon?: React.ReactNode;
1112
1129
  isDisabled?: boolean;
1113
- type?: "text" | "password" | "email" | "url";
1130
+ type?: "text" | "password" | "email" | "url" | string;
1114
1131
  inputClassName?: string;
1115
1132
  inputStyle?: React.CSSProperties;
1116
1133
  }
@@ -1159,4 +1176,4 @@ declare function useTriggeredOverlay<P extends BaseTriggeredOverlayProps, C exte
1159
1176
  };
1160
1177
  };
1161
1178
 
1162
- 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.
@@ -1165,22 +1165,27 @@ var PLASMIC_IMAGE_LOADER = {
1165
1165
  }
1166
1166
  };
1167
1167
 
1168
- function PlasmicLink(props) {
1168
+ var PlasmicLink = /*#__PURE__*/React__default.forwardRef(function PlasmicLink(props, ref) {
1169
1169
  // props.href is required for nextjs; if no props.href,
1170
1170
  // then we just render the default anchor element
1171
1171
  if (props.platform === "nextjs" && props.href) {
1172
1172
  var nextjsProps = ["href", "replace", "scroll", "shallow", "passHref", "prefetch", "locale"];
1173
- 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)))));
1173
+ 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)), {
1174
+ ref: ref
1175
+ })));
1174
1176
  }
1175
1177
 
1176
1178
  if (props.platform === "gatsby" && isInternalHref(props.href)) {
1177
1179
  return React__default.createElement(props.component, _extends({}, omit(props, "component", "platform", "href"), {
1178
- to: props.href
1180
+ to: props.href,
1181
+ ref: ref
1179
1182
  }));
1180
1183
  }
1181
1184
 
1182
- return React__default.createElement("a", Object.assign({}, omit(props, "component", "platform")));
1183
- }
1185
+ return React__default.createElement("a", Object.assign({}, omit(props, "component", "platform"), {
1186
+ ref: ref
1187
+ }));
1188
+ });
1184
1189
 
1185
1190
  function isInternalHref(href) {
1186
1191
  return /^\/(?!\/)/.test(href);
@@ -1340,6 +1345,96 @@ function createUseScreenVariants(isMulti, screenQueries) {
1340
1345
  };
1341
1346
  }
1342
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;
1391
+ componentsCount++;
1392
+ components["t" + componentId] = React__default.isValidElement(node) ? React__default.cloneElement(node, {
1393
+ key: componentId,
1394
+ children: undefined
1395
+ }) : node;
1396
+ return "<t" + componentId + ">" + contents + "</t" + 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
+
1343
1438
  var PlasmicRootContext = /*#__PURE__*/React.createContext(undefined);
1344
1439
  function PlasmicRootProvider(props) {
1345
1440
  var platform = props.platform,
@@ -1351,7 +1446,9 @@ function PlasmicRootProvider(props) {
1351
1446
  }, [platform]);
1352
1447
  return React.createElement(PlasmicRootContext.Provider, {
1353
1448
  value: context
1354
- }, React.createElement(reactAria.SSRProvider, null, children));
1449
+ }, React.createElement(reactAria.SSRProvider, null, React.createElement(PlasmicTranslatorContext.Provider, {
1450
+ value: props.translator
1451
+ }, children)));
1355
1452
  }
1356
1453
  var useIsSSR = reactAria.useIsSSR;
1357
1454
  function useHasPlasmicRoot() {
@@ -3017,11 +3114,13 @@ exports.PlasmicLink = PlasmicLink;
3017
3114
  exports.PlasmicRootProvider = PlasmicRootProvider;
3018
3115
  exports.PlasmicSlot = PlasmicSlot;
3019
3116
  exports.Stack = Stack;
3117
+ exports.Trans = Trans;
3020
3118
  exports.classNames = classNames;
3021
3119
  exports.createPlasmicElementProxy = createPlasmicElementProxy;
3022
3120
  exports.createUseScreenVariants = createUseScreenVariants;
3023
3121
  exports.deriveRenderOpts = deriveRenderOpts;
3024
3122
  exports.ensureGlobalVariants = ensureGlobalVariants;
3123
+ exports.genTranslatableString = genTranslatableString;
3025
3124
  exports.getDataProps = getDataProps;
3026
3125
  exports.hasVariant = hasVariant;
3027
3126
  exports.makeFragment = makeFragment;