@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
@@ -1 +1 @@
1
- {"version":3,"file":"props-utils-1f98cfd3.js","sources":["../../src/plume/plume-utils.ts","../../src/plume/props-utils.ts"],"sourcesContent":["import * as React from \"react\";\nimport { groupBy, mapValues } from \"../common\";\nimport { SingleChoiceArg } from \"../render/elements\";\n\nexport let PLUME_STRICT_MODE = true;\n\nexport function setPlumeStrictMode(mode: boolean) {\n PLUME_STRICT_MODE = mode;\n}\n\ntype VariantArgChoices<T> = T extends (infer M)[]\n ? M\n : T extends SingleChoiceArg<infer M>\n ? M\n : never;\ntype VariantArgsChoices<V> = { [k in keyof V]-?: VariantArgChoices<V[k]> };\ntype DictValues<V extends Record<string, any>> = V[keyof V];\ntype DictTuples<V extends Record<string, any>> = DictValues<\n { [K in keyof V]: [K, V[K]] }\n>;\nexport type VariantDefTuple<V> = DictTuples<VariantArgsChoices<V>>;\n\ntype DistributeTuple<T> = T extends [infer T1, infer T2]\n ? { group: T1; variant: T2 }\n : never;\n\nexport type VariantDef<V> = DistributeTuple<VariantDefTuple<V>>;\n\nexport type PlasmicClass<\n V extends Record<string, any>,\n A extends Record<string, any>,\n O extends Record<string, any>\n> = {\n (props: { variants?: V; args?: A; overrides?: O }): React.ReactElement | null;\n internalVariantProps: (keyof V)[];\n internalArgProps: (keyof A)[];\n};\n\nexport type AnyPlasmicClass = PlasmicClass<any, any, any>;\n\nexport type PlasmicClassVariants<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<infer V, any, any> ? V : unknown;\nexport type PlasmicClassArgs<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<any, infer A, any> ? A : unknown;\nexport type PlasmicClassOverrides<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<any, any, infer O> ? O : unknown;\n\ntype BooleanLike = boolean | undefined | null;\n\nexport function mergeVariantToggles<V>(\n ...toggles: { def?: VariantDef<V>; active: BooleanLike }[]\n) {\n const definedToggles = toggles.filter((x) => !!x.def) as {\n def: VariantDef<V>;\n active: BooleanLike;\n }[];\n const grouped = groupBy(definedToggles, ({ def }) => def.group as string);\n return mapValues(grouped, (subToggles) => {\n return Object.fromEntries(\n subToggles.map(({ def, active }) => [def.variant, !!active])\n );\n });\n}\n\nexport function noOutline() {\n return { outline: \"none\" };\n}\n\nexport function getPlumeType(child: React.ReactChild): string | undefined {\n if (!React.isValidElement(child)) {\n return undefined;\n }\n const childType = child.type as any;\n return (childType.__plumeType || childType.getPlumeType?.(child.props)) as\n | string\n | undefined;\n}\n","import * as React from \"react\";\nimport { pick, pickBy } from \"../common\";\nimport {\n AnyPlasmicClass,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n} from \"./plume-utils\";\n\nexport interface StyleProps {\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function getStyleProps<P extends StyleProps>(props: P): StyleProps {\n return pick(props, \"className\", \"style\");\n}\n\nexport function getDefaultPlasmicProps<C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: Record<string, any>\n) {\n return {\n plasmicProps: {\n variants: pick(\n props,\n ...plasmicClass.internalVariantProps\n ) as PlasmicClassVariants<C>,\n args: pick(\n props,\n ...plasmicClass.internalArgProps\n ) as PlasmicClassArgs<C>,\n overrides: {} as PlasmicClassOverrides<C>,\n },\n };\n}\n\nconst RE_DATA_PROP = /^(data-.*)$/;\n\nexport function getDataProps(props: Record<string, any>) {\n return pickBy(props, (k) => RE_DATA_PROP.test(k));\n}\n"],"names":[],"mappings":";;;;IAIW,iBAAiB,GAAG,KAAK;SAgDpB,mBAAmB;IACjC,iBAA0D;SAA1D,UAA0D,EAA1D,qBAA0D,EAA1D,IAA0D;QAA1D,4BAA0D;;IAE1D,IAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,CAAC,GAAG,GAAA,CAGjD,CAAC;IACJ,IAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,UAAC,EAAO;YAAL,GAAG,SAAA;QAAO,OAAA,GAAG,CAAC,KAAe;KAAA,CAAC,CAAC;IAC1E,OAAO,SAAS,CAAC,OAAO,EAAE,UAAC,UAAU;QACnC,OAAO,MAAM,CAAC,WAAW,CACvB,UAAU,CAAC,GAAG,CAAC,UAAC,EAAe;gBAAb,GAAG,SAAA,EAAE,MAAM,YAAA;YAAO,OAAA,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;SAAA,CAAC,CAC7D,CAAC;KACH,CAAC,CAAC;AACL,CAAC;SAEe,SAAS;IACvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;SAEe,YAAY,CAAC,KAAuB;;IAClD,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;QAChC,OAAO,SAAS,CAAC;KAClB;IACD,IAAM,SAAS,GAAG,KAAK,CAAC,IAAW,CAAC;IACpC,QAAQ,SAAS,CAAC,WAAW,KAAI,MAAA,SAAS,CAAC,YAAY,+CAAtB,SAAS,EAAgB,KAAK,CAAC,KAAK,CAAC,CAAA,EAExD;AAChB;;SCjEgB,aAAa,CAAuB,KAAQ;IAC1D,OAAO,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC3C;;;;"}
1
+ {"version":3,"file":"props-utils-fd5f444e.js","sources":["../../src/plume/plume-utils.ts","../../src/plume/props-utils.ts"],"sourcesContent":["import * as React from \"react\";\nimport { groupBy, mapValues } from \"../common\";\nimport { SingleChoiceArg } from \"../render/elements\";\n\nexport let PLUME_STRICT_MODE = true;\n\nexport function setPlumeStrictMode(mode: boolean) {\n PLUME_STRICT_MODE = mode;\n}\n\ntype VariantArgChoices<T> = T extends (infer M)[]\n ? M\n : T extends SingleChoiceArg<infer M>\n ? M\n : never;\ntype VariantArgsChoices<V> = { [k in keyof V]-?: VariantArgChoices<V[k]> };\ntype DictValues<V extends Record<string, any>> = V[keyof V];\ntype DictTuples<V extends Record<string, any>> = DictValues<\n { [K in keyof V]: [K, V[K]] }\n>;\nexport type VariantDefTuple<V> = DictTuples<VariantArgsChoices<V>>;\n\ntype DistributeTuple<T> = T extends [infer T1, infer T2]\n ? { group: T1; variant: T2 }\n : never;\n\nexport type VariantDef<V> = DistributeTuple<VariantDefTuple<V>>;\n\nexport type PlasmicClass<\n V extends Record<string, any>,\n A extends Record<string, any>,\n O extends Record<string, any>\n> = {\n (props: { variants?: V; args?: A; overrides?: O }): React.ReactElement | null;\n internalVariantProps: (keyof V)[];\n internalArgProps: (keyof A)[];\n};\n\nexport type AnyPlasmicClass = PlasmicClass<any, any, any>;\n\nexport type PlasmicClassVariants<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<infer V, any, any> ? V : unknown;\nexport type PlasmicClassArgs<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<any, infer A, any> ? A : unknown;\nexport type PlasmicClassOverrides<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<any, any, infer O> ? O : unknown;\n\ntype BooleanLike = boolean | undefined | null;\n\nexport function mergeVariantToggles<V>(\n ...toggles: { def?: VariantDef<V>; active: BooleanLike }[]\n) {\n const definedToggles = toggles.filter((x) => !!x.def) as {\n def: VariantDef<V>;\n active: BooleanLike;\n }[];\n const grouped = groupBy(definedToggles, ({ def }) => def.group as string);\n return mapValues(grouped, (subToggles) => {\n return Object.fromEntries(\n subToggles.map(({ def, active }) => [def.variant, !!active])\n );\n });\n}\n\nexport function noOutline() {\n return { outline: \"none\" };\n}\n\nexport function getPlumeType(child: React.ReactChild): string | undefined {\n if (!React.isValidElement(child)) {\n return undefined;\n }\n const childType = child.type as any;\n return (childType.__plumeType || childType.getPlumeType?.(child.props)) as\n | string\n | undefined;\n}\n","import * as React from \"react\";\nimport { pick, pickBy } from \"../common\";\nimport {\n AnyPlasmicClass,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n} from \"./plume-utils\";\n\nexport interface StyleProps {\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function getStyleProps<P extends StyleProps>(props: P): StyleProps {\n return pick(props, \"className\", \"style\");\n}\n\nexport function getDefaultPlasmicProps<C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: Record<string, any>\n) {\n return {\n plasmicProps: {\n variants: pick(\n props,\n ...plasmicClass.internalVariantProps\n ) as PlasmicClassVariants<C>,\n args: pick(\n props,\n ...plasmicClass.internalArgProps\n ) as PlasmicClassArgs<C>,\n overrides: {} as PlasmicClassOverrides<C>,\n },\n };\n}\n\nconst RE_DATA_PROP = /^(data-.*)$/;\n\nexport function getDataProps(props: Record<string, any>) {\n return pickBy(props, (k) => RE_DATA_PROP.test(k));\n}\n"],"names":[],"mappings":";;;IAIW,iBAAiB,GAAG,KAAK;SAgDpB,mBAAmB;IACjC,iBAA0D;SAA1D,UAA0D,EAA1D,qBAA0D,EAA1D,IAA0D;QAA1D,4BAA0D;;IAE1D,IAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,CAAC,GAAG,GAAA,CAGjD,CAAC;IACJ,IAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,UAAC,EAAO;YAAL,GAAG,SAAA;QAAO,OAAA,GAAG,CAAC,KAAe;KAAA,CAAC,CAAC;IAC1E,OAAO,SAAS,CAAC,OAAO,EAAE,UAAC,UAAU;QACnC,OAAO,MAAM,CAAC,WAAW,CACvB,UAAU,CAAC,GAAG,CAAC,UAAC,EAAe;gBAAb,GAAG,SAAA,EAAE,MAAM,YAAA;YAAO,OAAA,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;SAAA,CAAC,CAC7D,CAAC;KACH,CAAC,CAAC;AACL,CAAC;SAEe,SAAS;IACvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;SAEe,YAAY,CAAC,KAAuB;;IAClD,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;QAChC,OAAO,SAAS,CAAC;KAClB;IACD,IAAM,SAAS,GAAG,KAAK,CAAC,IAAW,CAAC;IACpC,QAAQ,SAAS,CAAC,WAAW,KAAI,MAAA,SAAS,CAAC,YAAY,+CAAtB,SAAS,EAAgB,KAAK,CAAC,KAAK,CAAC,CAAA,EAExD;AAChB;;SCjEgB,aAAa,CAAuB,KAAQ;IAC1D,OAAO,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC3C;;;;"}
@@ -1,172 +1,190 @@
1
- import { b as __spreadArray, a as __assign } from './tslib.es6-00014098.js';
2
- import classNames from 'classnames';
3
- import React__default from 'react';
1
+ import { b as __spreadArray, a as __assign } from "./tslib.es6-00014098.js";
2
+ import classNames from "classnames";
3
+ import React__default from "react";
4
4
 
5
- var isBrowser = typeof window !== "undefined";
6
- var NONE = Symbol("NONE");
7
- var useIsomorphicLayoutEffect = isBrowser
8
- ? React__default.useLayoutEffect
9
- : React__default.useEffect;
10
- function createElementWithChildren(elementType, props, children) {
11
- if (Array.isArray(children)) {
12
- return React__default.createElement.apply(React__default, __spreadArray([elementType,
13
- props], children));
14
- }
15
- else if (children || "children" in props) {
16
- // Only call React.createElement with `children` if there are actual children,
17
- // or if there was an explicit (albeit undefined) children passed via
18
- // props. Otherwise, if you pass `undefined` as the children argument
19
- // to React.createElement, the created element will have prop {children: undefined}.
20
- // If the `root` is an PlasmicGeneratedComponent, and these props with {children: undefined}
21
- // are used, then it will be taken as a `children` override, and will thus blank out
22
- // everything under the root node.
23
- return React__default.createElement(elementType, props, children);
24
- }
25
- else {
26
- return React__default.createElement(elementType, props);
27
- }
28
- }
29
- function ensureNotArray(children) {
30
- if (Array.isArray(children)) {
31
- if (children.length === 1) {
32
- return children[0];
33
- }
34
- else {
35
- return React__default.createElement.apply(React__default, __spreadArray([React__default.Fragment, {}], children));
36
- }
37
- }
38
- else {
39
- return children;
40
- }
41
- }
42
- /**
43
- * Flattens ReactNode into an array of ReactChild, but does NOT replace
44
- * missing keys with array index, as React.Children.toArray() does.
45
- */
46
- function toChildArray(children) {
47
- if (isReactChild(children)) {
48
- return [children];
49
- }
50
- else if (Array.isArray(children)) {
51
- return children.flatMap(toChildArray);
52
- }
53
- else {
54
- return [];
55
- }
56
- }
57
- function isReactText(child) {
58
- return typeof child === "string" || typeof child === "number";
59
- }
60
- function isReactChild(child) {
61
- return React__default.isValidElement(child) || isReactText(child);
62
- }
63
- function isReactNode(x) {
64
- return (typeof x === "string" || typeof x === "number" || React__default.isValidElement(x));
65
- }
66
- function mergeProps(props) {
67
- var restProps = [];
68
- for (var _i = 1; _i < arguments.length; _i++) {
69
- restProps[_i - 1] = arguments[_i];
70
- }
71
- if (restProps.every(function (rest) { return Object.keys(rest).length === 0; })) {
72
- return props;
73
- }
74
- var result = __assign({}, props);
75
- for (var _a = 0, restProps_1 = restProps; _a < restProps_1.length; _a++) {
76
- var rest = restProps_1[_a];
77
- for (var _b = 0, _c = Object.keys(rest); _b < _c.length; _b++) {
78
- var key = _c[_b];
79
- result[key] = mergePropVals(key, result[key], rest[key]);
80
- }
81
- }
82
- return result;
83
- }
84
- function updateRef(ref, value) {
85
- if (!ref) {
86
- return;
87
- }
88
- if (typeof ref === "function") {
89
- ref(value);
90
- }
91
- else {
92
- if (!Object.isFrozen(ref)) {
93
- ref.current = value;
94
- }
95
- }
96
- }
97
- function mergeRefs() {
98
- var refs = [];
99
- for (var _i = 0; _i < arguments.length; _i++) {
100
- refs[_i] = arguments[_i];
101
- }
102
- return function (value) {
103
- for (var _i = 0, refs_1 = refs; _i < refs_1.length; _i++) {
104
- var ref = refs_1[_i];
105
- updateRef(ref, value);
106
- }
107
- };
108
- }
109
- function mergePropVals(name, val1, val2) {
110
- if (val1 === NONE || val2 === NONE) {
111
- // The NONE sentinel always skips all merging and returns null
112
- return null;
113
- }
114
- else if (val1 == null) {
115
- // If either of them is nil, prefer the other
116
- return val2;
117
- }
118
- else if (val2 == null) {
119
- return val1;
120
- }
121
- else if (name === "className") {
122
- // Special case for className -- always combine both class names
123
- return classNames(val1, val2);
124
- }
125
- else if (name === "style") {
126
- // Special case for style -- always shallow-merge style dicts
127
- return __assign(__assign({}, val1), val2);
128
- }
129
- else if (name === "ref") {
130
- // Special case for ref
131
- return mergeRefs(val1, val2);
132
- }
133
- else if (typeof val1 !== typeof val2) {
134
- // If the type of the two values are different, then no way to merge them.
135
- // Prefer val2.
136
- return val2;
137
- }
138
- else if (name.startsWith("on") && typeof val1 === "function") {
139
- // Special case for event handlers -- always call both handlers
140
- return function () {
141
- var args = [];
142
- for (var _i = 0; _i < arguments.length; _i++) {
143
- args[_i] = arguments[_i];
144
- }
145
- var res;
146
- if (typeof val1 === "function") {
147
- res = val1.apply(void 0, args);
148
- }
149
- if (typeof val2 === "function") {
150
- res = val2.apply(void 0, args);
151
- }
152
- return res;
153
- };
154
- }
155
- else {
156
- // For all else, prefer val2
157
- return val2;
158
- }
159
- }
160
- function getElementTypeName(element) {
161
- var _a, _b, _c, _d;
162
- if (typeof element.type === "string") {
163
- return element.type;
164
- }
165
- else {
166
- var comp = element.type;
167
- return (_d = (_b = (_a = comp.displayName) !== null && _a !== void 0 ? _a : comp.name) !== null && _b !== void 0 ? _b : (_c = comp.render) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : "Component";
168
- }
5
+ var isBrowser = typeof window !== "undefined";
6
+ var NONE = Symbol("NONE");
7
+ var useIsomorphicLayoutEffect = isBrowser
8
+ ? React__default.useLayoutEffect
9
+ : React__default.useEffect;
10
+ function createElementWithChildren(elementType, props, children) {
11
+ if (Array.isArray(children)) {
12
+ return React__default.createElement.apply(
13
+ React__default,
14
+ __spreadArray([elementType, props], children)
15
+ );
16
+ } else if (children || "children" in props) {
17
+ // Only call React.createElement with `children` if there are actual children,
18
+ // or if there was an explicit (albeit undefined) children passed via
19
+ // props. Otherwise, if you pass `undefined` as the children argument
20
+ // to React.createElement, the created element will have prop {children: undefined}.
21
+ // If the `root` is an PlasmicGeneratedComponent, and these props with {children: undefined}
22
+ // are used, then it will be taken as a `children` override, and will thus blank out
23
+ // everything under the root node.
24
+ return React__default.createElement(elementType, props, children);
25
+ } else {
26
+ return React__default.createElement(elementType, props);
27
+ }
28
+ }
29
+ function ensureNotArray(children) {
30
+ if (Array.isArray(children)) {
31
+ if (children.length === 1) {
32
+ return children[0];
33
+ } else {
34
+ return React__default.createElement.apply(
35
+ React__default,
36
+ __spreadArray([React__default.Fragment, {}], children)
37
+ );
38
+ }
39
+ } else {
40
+ return children;
41
+ }
42
+ }
43
+ /**
44
+ * Flattens ReactNode into an array of ReactChild, but does NOT replace
45
+ * missing keys with array index, as React.Children.toArray() does.
46
+ */
47
+ function toChildArray(children) {
48
+ if (isReactChild(children)) {
49
+ return [children];
50
+ } else if (Array.isArray(children)) {
51
+ return children.flatMap(toChildArray);
52
+ } else {
53
+ return [];
54
+ }
55
+ }
56
+ function isReactText(child) {
57
+ return typeof child === "string" || typeof child === "number";
58
+ }
59
+ function isReactChild(child) {
60
+ return React__default.isValidElement(child) || isReactText(child);
61
+ }
62
+ function isReactNode(x) {
63
+ return (
64
+ typeof x === "string" ||
65
+ typeof x === "number" ||
66
+ React__default.isValidElement(x)
67
+ );
68
+ }
69
+ function mergeProps(props) {
70
+ var restProps = [];
71
+ for (var _i = 1; _i < arguments.length; _i++) {
72
+ restProps[_i - 1] = arguments[_i];
73
+ }
74
+ if (
75
+ restProps.every(function (rest) {
76
+ return Object.keys(rest).length === 0;
77
+ })
78
+ ) {
79
+ return props;
80
+ }
81
+ var result = __assign({}, props);
82
+ for (var _a = 0, restProps_1 = restProps; _a < restProps_1.length; _a++) {
83
+ var rest = restProps_1[_a];
84
+ for (var _b = 0, _c = Object.keys(rest); _b < _c.length; _b++) {
85
+ var key = _c[_b];
86
+ result[key] = mergePropVals(key, result[key], rest[key]);
87
+ }
88
+ }
89
+ return result;
90
+ }
91
+ function updateRef(ref, value) {
92
+ if (!ref) {
93
+ return;
94
+ }
95
+ if (typeof ref === "function") {
96
+ ref(value);
97
+ } else {
98
+ if (!Object.isFrozen(ref)) {
99
+ ref.current = value;
100
+ }
101
+ }
102
+ }
103
+ function mergeRefs() {
104
+ var refs = [];
105
+ for (var _i = 0; _i < arguments.length; _i++) {
106
+ refs[_i] = arguments[_i];
107
+ }
108
+ return function (value) {
109
+ for (var _i = 0, refs_1 = refs; _i < refs_1.length; _i++) {
110
+ var ref = refs_1[_i];
111
+ updateRef(ref, value);
112
+ }
113
+ };
114
+ }
115
+ function mergePropVals(name, val1, val2) {
116
+ if (val1 === NONE || val2 === NONE) {
117
+ // The NONE sentinel always skips all merging and returns null
118
+ return null;
119
+ } else if (val1 == null) {
120
+ // If either of them is nil, prefer the other
121
+ return val2;
122
+ } else if (val2 == null) {
123
+ return val1;
124
+ } else if (name === "className") {
125
+ // Special case for className -- always combine both class names
126
+ return classNames(val1, val2);
127
+ } else if (name === "style") {
128
+ // Special case for style -- always shallow-merge style dicts
129
+ return __assign(__assign({}, val1), val2);
130
+ } else if (name === "ref") {
131
+ // Special case for ref
132
+ return mergeRefs(val1, val2);
133
+ } else if (typeof val1 !== typeof val2) {
134
+ // If the type of the two values are different, then no way to merge them.
135
+ // Prefer val2.
136
+ return val2;
137
+ } else if (name.startsWith("on") && typeof val1 === "function") {
138
+ // Special case for event handlers -- always call both handlers
139
+ return function () {
140
+ var args = [];
141
+ for (var _i = 0; _i < arguments.length; _i++) {
142
+ args[_i] = arguments[_i];
143
+ }
144
+ var res;
145
+ if (typeof val1 === "function") {
146
+ res = val1.apply(void 0, args);
147
+ }
148
+ if (typeof val2 === "function") {
149
+ res = val2.apply(void 0, args);
150
+ }
151
+ return res;
152
+ };
153
+ } else {
154
+ // For all else, prefer val2
155
+ return val2;
156
+ }
157
+ }
158
+ function getElementTypeName(element) {
159
+ var _a, _b, _c, _d;
160
+ if (typeof element.type === "string") {
161
+ return element.type;
162
+ } else {
163
+ var comp = element.type;
164
+ return (_d =
165
+ (_b =
166
+ (_a = comp.displayName) !== null && _a !== void 0 ? _a : comp.name) !==
167
+ null && _b !== void 0
168
+ ? _b
169
+ : (_c = comp.render) === null || _c === void 0
170
+ ? void 0
171
+ : _c.name) !== null && _d !== void 0
172
+ ? _d
173
+ : "Component";
174
+ }
169
175
  }
170
176
 
171
- export { NONE as N, mergePropVals as a, isBrowser as b, createElementWithChildren as c, mergeRefs as d, ensureNotArray as e, getElementTypeName as g, isReactNode as i, mergeProps as m, toChildArray as t, useIsomorphicLayoutEffect as u };
177
+ export {
178
+ NONE as N,
179
+ mergePropVals as a,
180
+ isBrowser as b,
181
+ createElementWithChildren as c,
182
+ mergeRefs as d,
183
+ ensureNotArray as e,
184
+ getElementTypeName as g,
185
+ isReactNode as i,
186
+ mergeProps as m,
187
+ toChildArray as t,
188
+ useIsomorphicLayoutEffect as u,
189
+ };
172
190
  //# sourceMappingURL=react-utils-118d8539.js.map