@plasmicapp/react-web 0.2.110 → 0.2.112

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 (74) hide show
  1. package/dist/all.d.ts +30 -13
  2. package/dist/index-common.d.ts +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/react-web.cjs.development.js +366 -342
  5. package/dist/react-web.cjs.development.js.map +1 -1
  6. package/dist/react-web.cjs.production.min.js +1 -1
  7. package/dist/react-web.cjs.production.min.js.map +1 -1
  8. package/dist/react-web.esm.js +363 -342
  9. package/dist/react-web.esm.js.map +1 -1
  10. package/dist/render/elements.d.ts +5 -0
  11. package/dist/states/helpers.d.ts +5 -0
  12. package/dist/states/index.d.ts +1 -1
  13. package/dist/states/valtio.d.ts +16 -0
  14. package/dist/stories/UseDollarState.stories.d.ts +11 -0
  15. package/package.json +6 -2
  16. package/skinny/dist/collection-utils-42de4441.js +244 -0
  17. package/skinny/dist/collection-utils-42de4441.js.map +1 -0
  18. package/skinny/dist/{collection-utils-3487dd27.js → collection-utils-bf37b8fb.js} +5 -5
  19. package/skinny/dist/collection-utils-bf37b8fb.js.map +1 -0
  20. package/skinny/dist/common-98719219.js +68 -0
  21. package/skinny/dist/common-98719219.js.map +1 -0
  22. package/skinny/dist/common-9efbae57.js +201 -0
  23. package/skinny/dist/common-9efbae57.js.map +1 -0
  24. package/skinny/dist/context-4ca6f5cd.js +6 -0
  25. package/skinny/dist/context-4ca6f5cd.js.map +1 -0
  26. package/skinny/dist/index-common.d.ts +1 -1
  27. package/skinny/dist/index.d.ts +1 -1
  28. package/skinny/dist/index.js +17 -4
  29. package/skinny/dist/index.js.map +1 -1
  30. package/skinny/dist/plume/checkbox/index.js +2 -1
  31. package/skinny/dist/plume/checkbox/index.js.map +1 -1
  32. package/skinny/dist/plume/menu/index.js +2 -1
  33. package/skinny/dist/plume/menu/index.js.map +1 -1
  34. package/skinny/dist/plume/menu-button/index.js +2 -1
  35. package/skinny/dist/plume/menu-button/index.js.map +1 -1
  36. package/skinny/dist/plume/select/index.js +2 -1
  37. package/skinny/dist/plume/select/index.js.map +1 -1
  38. package/skinny/dist/plume/switch/index.js +2 -1
  39. package/skinny/dist/plume/switch/index.js.map +1 -1
  40. package/skinny/dist/plume-utils-1e225de5.js +25 -0
  41. package/skinny/dist/plume-utils-1e225de5.js.map +1 -0
  42. package/skinny/dist/plume-utils-d2476af1.js +35 -0
  43. package/skinny/dist/plume-utils-d2476af1.js.map +1 -0
  44. package/skinny/dist/props-utils-c60d3105.js +8 -0
  45. package/skinny/dist/props-utils-c60d3105.js.map +1 -0
  46. package/skinny/dist/props-utils-cac0cccf.js +8 -0
  47. package/skinny/dist/props-utils-cac0cccf.js.map +1 -0
  48. package/skinny/dist/react-utils-6050fadc.js +201 -0
  49. package/skinny/dist/react-utils-6050fadc.js.map +1 -0
  50. package/skinny/dist/react-utils-b5dc6320.js +155 -0
  51. package/skinny/dist/react-utils-b5dc6320.js.map +1 -0
  52. package/skinny/dist/render/elements.d.ts +5 -0
  53. package/skinny/dist/{ssr-84e27ffb.js → ssr-68913b60.js} +34 -37
  54. package/skinny/dist/ssr-68913b60.js.map +1 -0
  55. package/skinny/dist/{ssr-b1615b80.js → ssr-d3321868.js} +9 -4
  56. package/skinny/dist/ssr-d3321868.js.map +1 -0
  57. package/skinny/dist/states/helpers.d.ts +5 -0
  58. package/skinny/dist/states/index.d.ts +1 -1
  59. package/skinny/dist/states/valtio copy.d.ts +15 -0
  60. package/skinny/dist/states/valtio.d.ts +16 -0
  61. package/skinny/dist/stories/UseDollarState.stories.d.ts +11 -0
  62. package/skinny/dist/stories/UseDollarState.test.d.ts +11 -0
  63. package/skinny/dist/stories/UseDollarState2.stories.d.ts +7 -0
  64. package/skinny/dist/collection-utils-3487dd27.js.map +0 -1
  65. package/skinny/dist/ssr-14264281.js +0 -158
  66. package/skinny/dist/ssr-14264281.js.map +0 -1
  67. package/skinny/dist/ssr-5141fc77.js +0 -158
  68. package/skinny/dist/ssr-5141fc77.js.map +0 -1
  69. package/skinny/dist/ssr-579df58f.js +0 -158
  70. package/skinny/dist/ssr-579df58f.js.map +0 -1
  71. package/skinny/dist/ssr-84e27ffb.js.map +0 -1
  72. package/skinny/dist/ssr-b1615b80.js.map +0 -1
  73. package/skinny/dist/ssr-d2fd94f2.js +0 -31
  74. package/skinny/dist/ssr-d2fd94f2.js.map +0 -1
@@ -0,0 +1,201 @@
1
+ import { c as __values, a as __spreadArray, b as __read, _ as __assign } from './common-9efbae57.js';
2
+ import classNames from 'classnames';
3
+ import React__default from 'react';
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], __read(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, {}], __read(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 e_1, _a, e_2, _b;
68
+ var restProps = [];
69
+ for (var _i = 1; _i < arguments.length; _i++) {
70
+ restProps[_i - 1] = arguments[_i];
71
+ }
72
+ if (restProps.every(function (rest) { return Object.keys(rest).length === 0; })) {
73
+ return props;
74
+ }
75
+ var result = __assign({}, props);
76
+ try {
77
+ for (var restProps_1 = __values(restProps), restProps_1_1 = restProps_1.next(); !restProps_1_1.done; restProps_1_1 = restProps_1.next()) {
78
+ var rest = restProps_1_1.value;
79
+ try {
80
+ for (var _c = (e_2 = void 0, __values(Object.keys(rest))), _d = _c.next(); !_d.done; _d = _c.next()) {
81
+ var key = _d.value;
82
+ result[key] = mergePropVals(key, result[key], rest[key]);
83
+ }
84
+ }
85
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
86
+ finally {
87
+ try {
88
+ if (_d && !_d.done && (_b = _c["return"])) _b.call(_c);
89
+ }
90
+ finally { if (e_2) throw e_2.error; }
91
+ }
92
+ }
93
+ }
94
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
95
+ finally {
96
+ try {
97
+ if (restProps_1_1 && !restProps_1_1.done && (_a = restProps_1["return"])) _a.call(restProps_1);
98
+ }
99
+ finally { if (e_1) throw e_1.error; }
100
+ }
101
+ return result;
102
+ }
103
+ function updateRef(ref, value) {
104
+ if (!ref) {
105
+ return;
106
+ }
107
+ if (typeof ref === "function") {
108
+ ref(value);
109
+ }
110
+ else {
111
+ if (!Object.isFrozen(ref)) {
112
+ ref.current = value;
113
+ }
114
+ }
115
+ }
116
+ function mergeRefs() {
117
+ var refs = [];
118
+ for (var _i = 0; _i < arguments.length; _i++) {
119
+ refs[_i] = arguments[_i];
120
+ }
121
+ return function (value) {
122
+ var e_3, _a;
123
+ try {
124
+ for (var refs_1 = __values(refs), refs_1_1 = refs_1.next(); !refs_1_1.done; refs_1_1 = refs_1.next()) {
125
+ var ref = refs_1_1.value;
126
+ updateRef(ref, value);
127
+ }
128
+ }
129
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
130
+ finally {
131
+ try {
132
+ if (refs_1_1 && !refs_1_1.done && (_a = refs_1["return"])) _a.call(refs_1);
133
+ }
134
+ finally { if (e_3) throw e_3.error; }
135
+ }
136
+ };
137
+ }
138
+ function mergePropVals(name, val1, val2) {
139
+ if (val1 === NONE || val2 === NONE) {
140
+ // The NONE sentinel always skips all merging and returns null
141
+ return null;
142
+ }
143
+ else if (val1 == null) {
144
+ // If either of them is nil, prefer the other
145
+ return val2;
146
+ }
147
+ else if (val2 == null) {
148
+ return val1;
149
+ }
150
+ else if (name === "className") {
151
+ // Special case for className -- always combine both class names
152
+ return classNames(val1, val2);
153
+ }
154
+ else if (name === "style") {
155
+ // Special case for style -- always shallow-merge style dicts
156
+ return __assign(__assign({}, val1), val2);
157
+ }
158
+ else if (name === "ref") {
159
+ // Special case for ref
160
+ return mergeRefs(val1, val2);
161
+ }
162
+ else if (typeof val1 !== typeof val2) {
163
+ // If the type of the two values are different, then no way to merge them.
164
+ // Prefer val2.
165
+ return val2;
166
+ }
167
+ else if (name.startsWith("on") && typeof val1 === "function") {
168
+ // Special case for event handlers -- always call both handlers
169
+ return function () {
170
+ var args = [];
171
+ for (var _i = 0; _i < arguments.length; _i++) {
172
+ args[_i] = arguments[_i];
173
+ }
174
+ var res;
175
+ if (typeof val1 === "function") {
176
+ res = val1.apply(void 0, __spreadArray([], __read(args)));
177
+ }
178
+ if (typeof val2 === "function") {
179
+ res = val2.apply(void 0, __spreadArray([], __read(args)));
180
+ }
181
+ return res;
182
+ };
183
+ }
184
+ else {
185
+ // For all else, prefer val2
186
+ return val2;
187
+ }
188
+ }
189
+ function getElementTypeName(element) {
190
+ var _a, _b, _c, _d;
191
+ if (typeof element.type === "string") {
192
+ return element.type;
193
+ }
194
+ else {
195
+ var comp = element.type;
196
+ 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";
197
+ }
198
+ }
199
+
200
+ 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 };
201
+ //# sourceMappingURL=react-utils-6050fadc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-utils-6050fadc.js","sources":["../../src/react-utils.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport React from \"react\";\n\nexport const isBrowser = typeof window !== \"undefined\";\nexport const NONE = Symbol(\"NONE\");\n\nexport const useIsomorphicLayoutEffect = isBrowser\n ? React.useLayoutEffect\n : React.useEffect;\n\nexport function createElementWithChildren(\n elementType: any,\n props: any,\n children: React.ReactNode\n) {\n if (Array.isArray(children)) {\n return React.createElement(\n elementType,\n props,\n ...children\n ) as React.ReactElement;\n } else if (children || \"children\" in props) {\n // Only call React.createElement with `children` if there are actual children,\n // or if there was an explicit (albeit undefined) children passed via\n // props. Otherwise, if you pass `undefined` as the children argument\n // to React.createElement, the created element will have prop {children: undefined}.\n // If the `root` is an PlasmicGeneratedComponent, and these props with {children: undefined}\n // are used, then it will be taken as a `children` override, and will thus blank out\n // everything under the root node.\n return React.createElement(elementType, props, children);\n } else {\n return React.createElement(elementType, props);\n }\n}\n\nexport function ensureNotArray(children: React.ReactNode) {\n if (Array.isArray(children)) {\n if (children.length === 1) {\n return children[0];\n } else {\n return React.createElement(React.Fragment, {}, ...children);\n }\n } else {\n return children;\n }\n}\n\n/**\n * Flattens ReactNode into an array of ReactChild, but does NOT replace\n * missing keys with array index, as React.Children.toArray() does.\n */\nexport function toChildArray(children: React.ReactNode): React.ReactChild[] {\n if (isReactChild(children)) {\n return [children];\n } else if (Array.isArray(children)) {\n return children.flatMap(toChildArray);\n } else {\n return [];\n }\n}\n\nexport function isReactText(child: React.ReactNode): child is React.ReactText {\n return typeof child === \"string\" || typeof child === \"number\";\n}\n\nexport function isReactChild(\n child: React.ReactNode\n): child is React.ReactChild {\n return React.isValidElement(child) || isReactText(child);\n}\n\nexport function isReactFragment(\n child: React.ReactNode\n): child is React.ReactElement {\n return React.isValidElement(child) && child.type === React.Fragment;\n}\n\nexport function isReactNode(x: any) {\n return (\n typeof x === \"string\" || typeof x === \"number\" || React.isValidElement(x)\n );\n}\n\n// From https://stackoverflow.com/questions/54775790/forcing-excess-property-checking-on-variable-passed-to-typescript-function\n// We also wrap the error message in a Partial<> because otherwise Jetbrains IDEs will autocomplete the component with all the string methods as props - see https://github.com/plasmicapp/plasmic/issues/16.\nexport type StrictProps<T, TExpected> = Exclude<\n keyof T,\n keyof TExpected\n> extends never\n ? {}\n : Partial<\"Unexpected extraneous props\">;\n\nexport type HTMLElementRefOf<T extends keyof JSX.IntrinsicElements> = Exclude<\n React.ComponentProps<T>[\"ref\"],\n string\n>;\n\nexport function mergeProps(\n props: Record<string, any>,\n ...restProps: Record<string, any>[]\n): Record<string, any> {\n if (restProps.every((rest) => Object.keys(rest).length === 0)) {\n return props;\n }\n\n const result = { ...props };\n\n for (const rest of restProps) {\n for (const key of Object.keys(rest)) {\n result[key] = mergePropVals(key, result[key], rest[key]);\n }\n }\n\n return result;\n}\n\nfunction updateRef<T>(ref: React.Ref<T> | undefined, value: T | null) {\n if (!ref) {\n return;\n }\n\n if (typeof ref === \"function\") {\n ref(value);\n } else {\n if (!Object.isFrozen(ref)) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n }\n}\n\nexport function mergeRefs<T>(...refs: (React.Ref<T> | undefined)[]) {\n return (value: T) => {\n for (const ref of refs) {\n updateRef(ref, value);\n }\n };\n}\n\nexport function mergePropVals(name: string, val1: any, val2: any): any {\n if (val1 === NONE || val2 === NONE) {\n // The NONE sentinel always skips all merging and returns null\n return null;\n } else if (val1 == null) {\n // If either of them is nil, prefer the other\n return val2;\n } else if (val2 == null) {\n return val1;\n } else if (name === \"className\") {\n // Special case for className -- always combine both class names\n return classNames(val1, val2);\n } else if (name === \"style\") {\n // Special case for style -- always shallow-merge style dicts\n return { ...val1, ...val2 };\n } else if (name === \"ref\") {\n // Special case for ref\n return mergeRefs(val1, val2);\n } else if (typeof val1 !== typeof val2) {\n // If the type of the two values are different, then no way to merge them.\n // Prefer val2.\n return val2;\n } else if (name.startsWith(\"on\") && typeof val1 === \"function\") {\n // Special case for event handlers -- always call both handlers\n return (...args: any[]) => {\n let res: any;\n if (typeof val1 === \"function\") {\n res = val1(...args);\n }\n if (typeof val2 === \"function\") {\n res = val2(...args);\n }\n return res;\n };\n } else {\n // For all else, prefer val2\n return val2;\n }\n}\n\nexport function getElementTypeName(element: React.ReactElement) {\n if (typeof element.type === \"string\") {\n return element.type;\n } else {\n const comp = element.type as any;\n return comp.displayName ?? comp.name ?? comp.render?.name ?? \"Component\";\n }\n}\n"],"names":["React"],"mappings":";;;;IAGa,SAAS,GAAG,OAAO,MAAM,KAAK,YAAY;IAC1C,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE;IAEtB,yBAAyB,GAAG,SAAS;MAC9CA,cAAK,CAAC,eAAe;MACrBA,cAAK,CAAC,UAAU;SAEJ,yBAAyB,CACvC,WAAgB,EAChB,KAAU,EACV,QAAyB;IAEzB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,OAAOA,cAAK,CAAC,aAAa,OAAnBA,cAAK,iBACV,WAAW;YACX,KAAK,UACF,QAAQ,GACU,CAAC;KACzB;SAAM,IAAI,QAAQ,IAAI,U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AO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;QACpC,OAAO,OAAO,CAAC,IAAI,CAAC;KACrB;SAAM;QACL,IAAM,IAAI,GAAG,OAAO,CAAC,IAAW,CAAC;QACjC,OAAO,MAAA,MAAA,MAAA,IAAI,CAAC,WAAW,mCAAI,IAAI,CAAC,IAAI,mCAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,mCAAI,WAAW,CAAC;KAC1E;AACH;;;;"}
@@ -0,0 +1,155 @@
1
+ import classNames from 'classnames';
2
+ import React__default from 'react';
3
+
4
+ const isBrowser = typeof window !== "undefined";
5
+ const NONE = Symbol("NONE");
6
+ const useIsomorphicLayoutEffect = isBrowser
7
+ ? React__default.useLayoutEffect
8
+ : React__default.useEffect;
9
+ function createElementWithChildren(elementType, props, children) {
10
+ if (Array.isArray(children)) {
11
+ return React__default.createElement(elementType, props, ...children);
12
+ }
13
+ else if (children || "children" in props) {
14
+ // Only call React.createElement with `children` if there are actual children,
15
+ // or if there was an explicit (albeit undefined) children passed via
16
+ // props. Otherwise, if you pass `undefined` as the children argument
17
+ // to React.createElement, the created element will have prop {children: undefined}.
18
+ // If the `root` is an PlasmicGeneratedComponent, and these props with {children: undefined}
19
+ // are used, then it will be taken as a `children` override, and will thus blank out
20
+ // everything under the root node.
21
+ return React__default.createElement(elementType, props, children);
22
+ }
23
+ else {
24
+ return React__default.createElement(elementType, props);
25
+ }
26
+ }
27
+ function ensureNotArray(children) {
28
+ if (Array.isArray(children)) {
29
+ if (children.length === 1) {
30
+ return children[0];
31
+ }
32
+ else {
33
+ return React__default.createElement(React__default.Fragment, {}, ...children);
34
+ }
35
+ }
36
+ else {
37
+ return children;
38
+ }
39
+ }
40
+ /**
41
+ * Flattens ReactNode into an array of ReactChild, but does NOT replace
42
+ * missing keys with array index, as React.Children.toArray() does.
43
+ */
44
+ function toChildArray(children) {
45
+ if (isReactChild(children)) {
46
+ return [children];
47
+ }
48
+ else if (Array.isArray(children)) {
49
+ return children.flatMap(toChildArray);
50
+ }
51
+ else {
52
+ return [];
53
+ }
54
+ }
55
+ function isReactText(child) {
56
+ return typeof child === "string" || typeof child === "number";
57
+ }
58
+ function isReactChild(child) {
59
+ return React__default.isValidElement(child) || isReactText(child);
60
+ }
61
+ function isReactNode(x) {
62
+ return (typeof x === "string" || typeof x === "number" || React__default.isValidElement(x));
63
+ }
64
+ function mergeProps(props, ...restProps) {
65
+ if (restProps.every((rest) => Object.keys(rest).length === 0)) {
66
+ return props;
67
+ }
68
+ const result = { ...props };
69
+ for (const rest of restProps) {
70
+ for (const key of Object.keys(rest)) {
71
+ result[key] = mergePropVals(key, result[key], rest[key]);
72
+ }
73
+ }
74
+ return result;
75
+ }
76
+ function updateRef(ref, value) {
77
+ if (!ref) {
78
+ return;
79
+ }
80
+ if (typeof ref === "function") {
81
+ ref(value);
82
+ }
83
+ else {
84
+ if (!Object.isFrozen(ref)) {
85
+ ref.current = value;
86
+ }
87
+ }
88
+ }
89
+ function mergeRefs(...refs) {
90
+ return (value) => {
91
+ for (const ref of refs) {
92
+ updateRef(ref, value);
93
+ }
94
+ };
95
+ }
96
+ function mergePropVals(name, val1, val2) {
97
+ if (val1 === NONE || val2 === NONE) {
98
+ // The NONE sentinel always skips all merging and returns null
99
+ return null;
100
+ }
101
+ else if (val1 == null) {
102
+ // If either of them is nil, prefer the other
103
+ return val2;
104
+ }
105
+ else if (val2 == null) {
106
+ return val1;
107
+ }
108
+ else if (name === "className") {
109
+ // Special case for className -- always combine both class names
110
+ return classNames(val1, val2);
111
+ }
112
+ else if (name === "style") {
113
+ // Special case for style -- always shallow-merge style dicts
114
+ return { ...val1, ...val2 };
115
+ }
116
+ else if (name === "ref") {
117
+ // Special case for ref
118
+ return mergeRefs(val1, val2);
119
+ }
120
+ else if (typeof val1 !== typeof val2) {
121
+ // If the type of the two values are different, then no way to merge them.
122
+ // Prefer val2.
123
+ return val2;
124
+ }
125
+ else if (name.startsWith("on") && typeof val1 === "function") {
126
+ // Special case for event handlers -- always call both handlers
127
+ return (...args) => {
128
+ let res;
129
+ if (typeof val1 === "function") {
130
+ res = val1(...args);
131
+ }
132
+ if (typeof val2 === "function") {
133
+ res = val2(...args);
134
+ }
135
+ return res;
136
+ };
137
+ }
138
+ else {
139
+ // For all else, prefer val2
140
+ return val2;
141
+ }
142
+ }
143
+ function getElementTypeName(element) {
144
+ var _a, _b, _c, _d;
145
+ if (typeof element.type === "string") {
146
+ return element.type;
147
+ }
148
+ else {
149
+ const comp = element.type;
150
+ 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";
151
+ }
152
+ }
153
+
154
+ 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 };
155
+ //# sourceMappingURL=react-utils-b5dc6320.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-utils-b5dc6320.js","sources":["../../src/react-utils.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport React from \"react\";\n\nexport const isBrowser = typeof window !== \"undefined\";\nexport const NONE = Symbol(\"NONE\");\n\nexport const useIsomorphicLayoutEffect = isBrowser\n ? React.useLayoutEffect\n : React.useEffect;\n\nexport function createElementWithChildren(\n elementType: any,\n props: any,\n children: React.ReactNode\n) {\n if (Array.isArray(children)) {\n return React.createElement(\n elementType,\n props,\n ...children\n ) as React.ReactElement;\n } else if (children || \"children\" in props) {\n // Only call React.createElement with `children` if there are actual children,\n // or if there was an explicit (albeit undefined) children passed via\n // props. Otherwise, if you pass `undefined` as the children argument\n // to React.createElement, the created element will have prop {children: undefined}.\n // If the `root` is an PlasmicGeneratedComponent, and these props with {children: undefined}\n // are used, then it will be taken as a `children` override, and will thus blank out\n // everything under the root node.\n return React.createElement(elementType, props, children);\n } else {\n return React.createElement(elementType, props);\n }\n}\n\nexport function ensureNotArray(children: React.ReactNode) {\n if (Array.isArray(children)) {\n if (children.length === 1) {\n return children[0];\n } else {\n return React.createElement(React.Fragment, {}, ...children);\n }\n } else {\n return children;\n }\n}\n\n/**\n * Flattens ReactNode into an array of ReactChild, but does NOT replace\n * missing keys with array index, as React.Children.toArray() does.\n */\nexport function toChildArray(children: React.ReactNode): React.ReactChild[] {\n if (isReactChild(children)) {\n return [children];\n } else if (Array.isArray(children)) {\n return children.flatMap(toChildArray);\n } else {\n return [];\n }\n}\n\nexport function isReactText(child: React.ReactNode): child is React.ReactText {\n return typeof child === \"string\" || typeof child === \"number\";\n}\n\nexport function isReactChild(\n child: React.ReactNode\n): child is React.ReactChild {\n return React.isValidElement(child) || isReactText(child);\n}\n\nexport function isReactFragment(\n child: React.ReactNode\n): child is React.ReactElement {\n return React.isValidElement(child) && child.type === React.Fragment;\n}\n\nexport function isReactNode(x: any) {\n return (\n typeof x === \"string\" || typeof x === \"number\" || React.isValidElement(x)\n );\n}\n\n// From https://stackoverflow.com/questions/54775790/forcing-excess-property-checking-on-variable-passed-to-typescript-function\n// We also wrap the error message in a Partial<> because otherwise Jetbrains IDEs will autocomplete the component with all the string methods as props - see https://github.com/plasmicapp/plasmic/issues/16.\nexport type StrictProps<T, TExpected> = Exclude<\n keyof T,\n keyof TExpected\n> extends never\n ? {}\n : Partial<\"Unexpected extraneous props\">;\n\nexport type HTMLElementRefOf<T extends keyof JSX.IntrinsicElements> = Exclude<\n React.ComponentProps<T>[\"ref\"],\n string\n>;\n\nexport function mergeProps(\n props: Record<string, any>,\n ...restProps: Record<string, any>[]\n): Record<string, any> {\n if (restProps.every((rest) => Object.keys(rest).length === 0)) {\n return props;\n }\n\n const result = { ...props };\n\n for (const rest of restProps) {\n for (const key of Object.keys(rest)) {\n result[key] = mergePropVals(key, result[key], rest[key]);\n }\n }\n\n return result;\n}\n\nfunction updateRef<T>(ref: React.Ref<T> | undefined, value: T | null) {\n if (!ref) {\n return;\n }\n\n if (typeof ref === \"function\") {\n ref(value);\n } else {\n if (!Object.isFrozen(ref)) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n }\n}\n\nexport function mergeRefs<T>(...refs: (React.Ref<T> | undefined)[]) {\n return (value: T) => {\n for (const ref of refs) {\n updateRef(ref, value);\n }\n };\n}\n\nexport function mergePropVals(name: string, val1: any, val2: any): any {\n if (val1 === NONE || val2 === NONE) {\n // The NONE sentinel always skips all merging and returns null\n return null;\n } else if (val1 == null) {\n // If either of them is nil, prefer the other\n return val2;\n } else if (val2 == null) {\n return val1;\n } else if (name === \"className\") {\n // Special case for className -- always combine both class names\n return classNames(val1, val2);\n } else if (name === \"style\") {\n // Special case for style -- always shallow-merge style dicts\n return { ...val1, ...val2 };\n } else if (name === \"ref\") {\n // Special case for ref\n return mergeRefs(val1, val2);\n } else if (typeof val1 !== typeof val2) {\n // If the type of the two values are different, then no way to merge them.\n // Prefer val2.\n return val2;\n } else if (name.startsWith(\"on\") && typeof val1 === \"function\") {\n // Special case for event handlers -- always call both handlers\n return (...args: any[]) => {\n let res: any;\n if (typeof val1 === \"function\") {\n res = val1(...args);\n }\n if (typeof val2 === \"function\") {\n res = val2(...args);\n }\n return res;\n };\n } else {\n // For all else, prefer val2\n return val2;\n }\n}\n\nexport function getElementTypeName(element: React.ReactElement) {\n if (typeof element.type === \"string\") {\n return element.type;\n } else {\n const comp = element.type as any;\n return comp.displayName ?? comp.name ?? comp.render?.name ?? \"Component\";\n }\n}\n"],"names":["React"],"mappings":";;;MAGa,SAAS,GAAG,OAAO,MAAM,KAAK,YAAY;MAC1C,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE;MAEtB,yBAAyB,GAAG,SAAS;MAC9CA,cAAK,CAAC,eAAe;MACrBA,cAAK,CAAC,UAAU;SAEJ,yBAAyB,CACvC,WAAgB,EAChB,KAAU,EACV,QAAyB;IAEzB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;Q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AAI,IAAI,CAAC,IAAI,mCAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,mCAAI,WAAW,CAAC;KAC1E;AACH;;;;"}
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import { $State } from "../states/valtio";
2
3
  interface Variants {
3
4
  [vg: string]: any;
4
5
  }
@@ -54,6 +55,10 @@ export declare function wrapWithClassName(element: React.ReactNode, className: s
54
55
  display: "grid";
55
56
  };
56
57
  }, HTMLElement>;
58
+ export declare function mergeVariantsWithStates(variants: Variants, $state: $State, linkedStates: {
59
+ variantGroup: string;
60
+ statePath: (string | number)[];
61
+ }[]): Variants;
57
62
  export declare function deriveRenderOpts(props: Record<string, any>, config: {
58
63
  name: string;
59
64
  descendantNames: string[];
@@ -1,16 +1,15 @@
1
- import { SSRProvider, useIsSSR as useIsSSR$1 } from '@react-aria/ssr';
2
1
  import * as React from 'react';
3
2
  import React__default from 'react';
4
- import { PlasmicHeadContext } from './render/PlasmicHead/index.js';
3
+ import { SSRProvider, useIsSSR as useIsSSR$1 } from '@react-aria/ssr';
5
4
 
6
- var PlasmicTranslatorContext = React__default.createContext(undefined);
5
+ const PlasmicTranslatorContext = React__default.createContext(undefined);
7
6
  function isIterable(val) {
8
7
  return val != null && typeof val[Symbol.iterator] === "function";
9
8
  }
10
9
  function genTranslatableString(elt) {
11
- var components = {};
12
- var componentsCount = 0;
13
- var getText = function (node) {
10
+ const components = {};
11
+ let componentsCount = 0;
12
+ const getText = (node) => {
14
13
  if (!node) {
15
14
  return "";
16
15
  }
@@ -24,23 +23,23 @@ function genTranslatableString(elt) {
24
23
  }
25
24
  if (Array.isArray(node) || isIterable(node)) {
26
25
  return Array.from(node)
27
- .map(function (child) { return getText(child); })
28
- .filter(function (child) { return !!child; })
26
+ .map((child) => getText(child))
27
+ .filter((child) => !!child)
29
28
  .join("");
30
29
  }
31
- var nodeChildren = (hasKey(node, "props") &&
30
+ const nodeChildren = (hasKey(node, "props") &&
32
31
  hasKey(node.props, "children") &&
33
32
  node.props.children) ||
34
33
  (hasKey(node, "children") && node.children) ||
35
34
  [];
36
- var contents = "" + React__default.Children.toArray(nodeChildren)
37
- .map(function (child) { return getText(child); })
38
- .filter(function (child) { return !!child; })
39
- .join("");
35
+ const contents = `${React__default.Children.toArray(nodeChildren)
36
+ .map((child) => getText(child))
37
+ .filter((child) => !!child)
38
+ .join("")}`;
40
39
  if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
41
40
  return contents;
42
41
  }
43
- var componentId = componentsCount + 1;
42
+ const componentId = componentsCount + 1;
44
43
  componentsCount++;
45
44
  components[componentId] = React__default.isValidElement(node)
46
45
  ? React__default.cloneElement(node, {
@@ -48,26 +47,25 @@ function genTranslatableString(elt) {
48
47
  children: undefined,
49
48
  })
50
49
  : node;
51
- return "<" + componentId + ">" + contents + "</" + componentId + ">";
50
+ return `<${componentId}>${contents}</${componentId}>`;
52
51
  };
53
- var str = getText(elt);
52
+ const str = getText(elt);
54
53
  return {
55
- str: str,
56
- components: components,
57
- componentsCount: componentsCount,
54
+ str,
55
+ components,
56
+ componentsCount,
58
57
  };
59
58
  }
60
- function Trans(_a) {
61
- var children = _a.children;
62
- var _t = React__default.useContext(PlasmicTranslatorContext);
59
+ function Trans({ children }) {
60
+ const _t = React__default.useContext(PlasmicTranslatorContext);
63
61
  if (!_t) {
64
62
  warnNoTranslationFunctionAtMostOnce();
65
63
  return children;
66
64
  }
67
- var _b = genTranslatableString(children), str = _b.str, components = _b.components, componentsCount = _b.componentsCount;
68
- return _t(str, componentsCount > 0 ? { components: components } : undefined);
65
+ const { str, components, componentsCount } = genTranslatableString(children);
66
+ return _t(str, componentsCount > 0 ? { components } : undefined);
69
67
  }
70
- var hasWarned = false;
68
+ let hasWarned = false;
71
69
  function warnNoTranslationFunctionAtMostOnce() {
72
70
  if (!hasWarned) {
73
71
  console.warn("Using Plasmic Translation but no translation function has been provided");
@@ -78,33 +76,32 @@ function hasKey(v, key) {
78
76
  return typeof v === "object" && v !== null && key in v;
79
77
  }
80
78
 
81
- var PlasmicRootContext = React.createContext(undefined);
79
+ const PlasmicRootContext = React.createContext(undefined);
82
80
  function PlasmicRootProvider(props) {
83
- var platform = props.platform, children = props.children;
84
- var context = React.useMemo(function () { return ({
85
- platform: platform,
86
- }); }, [platform]);
81
+ const { platform, children } = props;
82
+ const context = React.useMemo(() => ({
83
+ platform,
84
+ }), [platform]);
87
85
  return (React.createElement(PlasmicRootContext.Provider, { value: context },
88
86
  React.createElement(SSRProvider, null,
89
- React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator },
90
- React.createElement(PlasmicHeadContext.Provider, { value: props.Head }, children)))));
87
+ React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator }, children))));
91
88
  }
92
- var useIsSSR = useIsSSR$1;
89
+ const useIsSSR = useIsSSR$1;
93
90
  function useHasPlasmicRoot() {
94
91
  return !!React.useContext(PlasmicRootContext);
95
92
  }
96
- var hasWarnedSSR = false;
93
+ let hasWarnedSSR = false;
97
94
  /**
98
95
  * Warns the user if PlasmicRootProvider is not used
99
96
  */
100
97
  function useEnsureSSRProvider() {
101
- var hasRoot = useHasPlasmicRoot();
98
+ const hasRoot = useHasPlasmicRoot();
102
99
  if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
103
100
  return;
104
101
  }
105
102
  hasWarnedSSR = true;
106
- console.warn("Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr");
103
+ console.warn(`Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`);
107
104
  }
108
105
 
109
106
  export { PlasmicRootProvider as P, Trans as T, useEnsureSSRProvider as a, genTranslatableString as g, useIsSSR as u };
110
- //# sourceMappingURL=ssr-84e27ffb.js.map
107
+ //# sourceMappingURL=ssr-68913b60.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr-68913b60.js","sources":["../../src/render/translation.tsx","../../src/render/ssr.tsx"],"sourcesContent":["import React from \"react\";\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement;\n };\n }\n) => React.ReactNode;\n\nexport const PlasmicTranslatorContext =\n React.createContext<PlasmicTranslator | undefined>(undefined);\n\nexport interface TransProps {\n children?: React.ReactNode;\n}\n\nfunction isIterable(val: any): val is Iterable<any> {\n return val != null && typeof val[Symbol.iterator] === \"function\";\n}\n\nexport function genTranslatableString(elt: React.ReactNode) {\n const components: {\n [key: string]: React.ReactElement;\n } = {};\n let componentsCount = 0;\n\n const getText = (node: React.ReactNode): string => {\n if (!node) {\n return \"\";\n }\n if (\n typeof node === \"number\" ||\n typeof node === \"boolean\" ||\n typeof node === \"string\"\n ) {\n return node.toString();\n }\n if (typeof node !== \"object\") {\n return \"\";\n }\n if (Array.isArray(node) || isIterable(node)) {\n return Array.from(node)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\");\n }\n const nodeChildren: React.ReactNode =\n (hasKey(node, \"props\") &&\n hasKey(node.props, \"children\") &&\n (node.props.children as React.ReactNode | undefined)) ||\n (hasKey(node, \"children\") && node.children) ||\n [];\n const contents = `${React.Children.toArray(nodeChildren)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\")}`;\n if (React.isValidElement(node) && node.type === React.Fragment) {\n return contents;\n }\n const componentId = componentsCount + 1;\n componentsCount++;\n components[componentId] = React.isValidElement(node)\n ? React.cloneElement(node as any, {\n key: componentId,\n children: undefined,\n })\n : (node as never);\n return `<${componentId}>${contents}</${componentId}>`;\n };\n\n const str = getText(elt);\n return {\n str,\n components,\n componentsCount,\n };\n}\n\nexport function Trans({ children }: TransProps) {\n const _t = React.useContext(PlasmicTranslatorContext);\n if (!_t) {\n warnNoTranslationFunctionAtMostOnce();\n return children;\n }\n\n const { str, components, componentsCount } = genTranslatableString(children);\n return _t(str, componentsCount > 0 ? { components } : undefined);\n}\n\nlet hasWarned = false;\nfunction warnNoTranslationFunctionAtMostOnce() {\n if (!hasWarned) {\n console.warn(\n \"Using Plasmic Translation but no translation function has been provided\"\n );\n hasWarned = true;\n }\n}\n\nfunction hasKey<K extends string>(v: any, key: K): v is Record<K, any> {\n return typeof v === \"object\" && v !== null && key in v;\n}\n","import * as React from \"react\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"@react-aria/ssr\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext =\n React.createContext<PlasmicRootContextValue | undefined>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const { platform, children } = props;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n {children}\n </PlasmicTranslatorContext.Provider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;AAWO,MAAM,wBAAwB,GACnCA,cAAK,CAAC,aAAa,CAAgC,SAAS,CAAC,CAAC;AAMhE,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,G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ACF,SAAS,GAAG,IAAI,CAAC;KAClB;AACH,CAAC;AAED,SAAS,MAAM,CAAmB,CAAM,EAAE,GAAM;IAC9C,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,IAAI,CAAC,CAAC;AACzD;;AC/FA,MAAM,kBAAkB,GACtB,KAAK,CAAC,aAAa,CAAsC,SAAS,CAAC,CAAC;SAQtD,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACrC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAC3B,OAAO;QACL,QAAQ;KACT,CAAC,EACF,CAAC,QAAQ,CAAC,CACX,CAAC;IACF,QACE,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO;QACzC,oBAAC,WAAW;YACV,oBAAC,wBAAwB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,UAAU,IACvD,QAAQ,CACyB,CACxB,CACc,EAC9B;AACJ,CAAC;MAEY,QAAQ,GAAGC,WAAa;SAErB,iBAAiB;IAC/B,OAAO,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAChD,CAAC;AAED,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB;;;SAGgB,oBAAoB;IAClC,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,IAAI,OAAO,IAAI,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QACrE,OAAO;KACR;IAED,YAAY,GAAG,IAAI,CAAC;IACpB,OAAO,CAAC,IAAI,CACV,uLAAuL,CACxL,CAAC;AACJ;;;;"}
@@ -1,3 +1,4 @@
1
+ import { PlasmicDataSourceContextProvider } from '@plasmicapp/data-sources-context';
1
2
  import { SSRProvider, useIsSSR as useIsSSR$1 } from '@react-aria/ssr';
2
3
  import * as React from 'react';
3
4
  import React__default from 'react';
@@ -80,14 +81,18 @@ function hasKey(v, key) {
80
81
 
81
82
  var PlasmicRootContext = React.createContext(undefined);
82
83
  function PlasmicRootProvider(props) {
83
- var platform = props.platform, children = props.children;
84
+ var _a = props, platform = _a.platform, children = _a.children, userAuthToken = _a.userAuthToken;
84
85
  var context = React.useMemo(function () { return ({
85
86
  platform: platform,
86
87
  }); }, [platform]);
88
+ var dataSourceContextValue = React.useMemo(function () { return ({
89
+ userAuthToken: userAuthToken,
90
+ }); }, [userAuthToken]);
87
91
  return (React.createElement(PlasmicRootContext.Provider, { value: context },
88
92
  React.createElement(SSRProvider, null,
89
- React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator },
90
- React.createElement(PlasmicHeadContext.Provider, { value: props.Head }, children)))));
93
+ React.createElement(PlasmicDataSourceContextProvider, { value: dataSourceContextValue },
94
+ React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator },
95
+ React.createElement(PlasmicHeadContext.Provider, { value: props.Head }, children))))));
91
96
  }
92
97
  var useIsSSR = useIsSSR$1;
93
98
  function useHasPlasmicRoot() {
@@ -107,4 +112,4 @@ function useEnsureSSRProvider() {
107
112
  }
108
113
 
109
114
  export { PlasmicRootProvider as P, Trans as T, useEnsureSSRProvider as a, genTranslatableString as g, useIsSSR as u };
110
- //# sourceMappingURL=ssr-b1615b80.js.map
115
+ //# sourceMappingURL=ssr-d3321868.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr-d3321868.js","sources":["../../src/render/translation.tsx","../../src/render/ssr.tsx"],"sourcesContent":["import React from \"react\";\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement;\n };\n }\n) => React.ReactNode;\n\nexport const PlasmicTranslatorContext =\n React.createContext<PlasmicTranslator | undefined>(undefined);\n\nexport interface TransProps {\n children?: React.ReactNode;\n}\n\nfunction isIterable(val: any): val is Iterable<any> {\n return val != null && typeof val[Symbol.iterator] === \"function\";\n}\n\nexport function genTranslatableString(elt: React.ReactNode) {\n const components: {\n [key: string]: React.ReactElement;\n } = {};\n let componentsCount = 0;\n\n const getText = (node: React.ReactNode): string => {\n if (!node) {\n return \"\";\n }\n if (\n typeof node === \"number\" ||\n typeof node === \"boolean\" ||\n typeof node === \"string\"\n ) {\n return node.toString();\n }\n if (typeof node !== \"object\") {\n return \"\";\n }\n if (Array.isArray(node) || isIterable(node)) {\n return Array.from(node)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\");\n }\n const nodeChildren: React.ReactNode =\n (hasKey(node, \"props\") &&\n hasKey(node.props, \"children\") &&\n (node.props.children as React.ReactNode | undefined)) ||\n (hasKey(node, \"children\") && node.children) ||\n [];\n const contents = `${React.Children.toArray(nodeChildren)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\")}`;\n if (React.isValidElement(node) && node.type === React.Fragment) {\n return contents;\n }\n const componentId = componentsCount + 1;\n componentsCount++;\n components[componentId] = React.isValidElement(node)\n ? React.cloneElement(node as any, {\n key: componentId,\n children: undefined,\n })\n : (node as never);\n return `<${componentId}>${contents}</${componentId}>`;\n };\n\n const str = getText(elt);\n return {\n str,\n components,\n componentsCount,\n };\n}\n\nexport function Trans({ children }: TransProps) {\n const _t = React.useContext(PlasmicTranslatorContext);\n if (!_t) {\n warnNoTranslationFunctionAtMostOnce();\n return children;\n }\n\n const { str, components, componentsCount } = genTranslatableString(children);\n return _t(str, componentsCount > 0 ? { components } : undefined);\n}\n\nlet hasWarned = false;\nfunction warnNoTranslationFunctionAtMostOnce() {\n if (!hasWarned) {\n console.warn(\n \"Using Plasmic Translation but no translation function has been provided\"\n );\n hasWarned = true;\n }\n}\n\nfunction hasKey<K extends string>(v: any, key: K): v is Record<K, any> {\n return typeof v === \"object\" && v !== null && key in v;\n}\n","import { PlasmicDataSourceContextProvider } from \"@plasmicapp/data-sources-context\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"@react-aria/ssr\";\nimport * as React from \"react\";\nimport { PlasmicHeadContext } from \"./PlasmicHead\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext = React.createContext<\n PlasmicRootContextValue | undefined\n>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n Head?: React.ComponentType<any>;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const { platform, children, userAuthToken } = props as any;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n const dataSourceContextValue = React.useMemo(\n () => ({\n userAuthToken,\n }),\n [userAuthToken]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicDataSourceContextProvider value={dataSourceContextValue}>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n <PlasmicHeadContext.Provider value={props.Head}>\n {children}\n </PlasmicHeadContext.Provider>\n </PlasmicTranslatorContext.Provider>\n </PlasmicDataSourceContextProvider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;;;AAWO,IAAM,wBAAwB,GACnCA,cAAK,CAAC,aAAa,CAAgC,SAAS,CAAC,CAAC;AAMhE,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,IAA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ClC,IAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,IAAI,OAAO,IAAI,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QACrE,OAAO;KACR;IAED,YAAY,GAAG,IAAI,CAAC;IACpB,OAAO,CAAC,IAAI,CACV,uLAAuL,CACxL,CAAC;AACJ;;;;"}
@@ -7,3 +7,8 @@ export declare function generateStateOnChangeProp($state: $State, stateName: str
7
7
  * We need to pass `parent[index1][index2].counter to the child component
8
8
  */
9
9
  export declare function generateStateValueProp($state: $State, path: (string | number)[]): any;
10
+ /**
11
+ * Forked from https://github.com/lukeed/dset
12
+ * Changes: fixed setting a deep value to a proxy object
13
+ */
14
+ export declare function set(obj: any, keys: any, val: any): void;
@@ -1,7 +1,7 @@
1
1
  declare type InitFunc<T> = ($props: Record<string, any>, $state: $State) => T;
2
2
  export interface $State {
3
3
  [key: string]: any;
4
- registerInitFunc: (path: string, f: InitFunc<any>) => any;
4
+ registerInitFunc?: (path: string, f: InitFunc<any>) => any;
5
5
  }
6
6
  export interface $StateSpec<T> {
7
7
  path: string;