@plasmicapp/react-web 0.2.109 → 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.
- package/dist/all.d.ts +30 -13
- package/dist/index-common.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react-web.cjs.development.js +378 -349
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +375 -349
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/elements.d.ts +5 -0
- package/dist/states/helpers.d.ts +5 -0
- package/dist/states/index.d.ts +1 -1
- package/dist/states/valtio.d.ts +16 -0
- package/dist/stories/UseDollarState.stories.d.ts +11 -0
- package/package.json +6 -2
- package/skinny/dist/collection-utils-42de4441.js +244 -0
- package/skinny/dist/collection-utils-42de4441.js.map +1 -0
- package/skinny/dist/{collection-utils-3487dd27.js → collection-utils-bf37b8fb.js} +5 -5
- package/skinny/dist/collection-utils-bf37b8fb.js.map +1 -0
- package/skinny/dist/common-98719219.js +68 -0
- package/skinny/dist/common-98719219.js.map +1 -0
- package/skinny/dist/common-9efbae57.js +201 -0
- package/skinny/dist/common-9efbae57.js.map +1 -0
- package/skinny/dist/context-4ca6f5cd.js +6 -0
- package/skinny/dist/context-4ca6f5cd.js.map +1 -0
- package/skinny/dist/index-common.d.ts +1 -1
- package/skinny/dist/index.d.ts +1 -1
- package/skinny/dist/index.js +17 -4
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/plume/checkbox/index.js +2 -1
- package/skinny/dist/plume/checkbox/index.js.map +1 -1
- package/skinny/dist/plume/menu/index.js +2 -1
- package/skinny/dist/plume/menu/index.js.map +1 -1
- package/skinny/dist/plume/menu-button/index.js +2 -1
- package/skinny/dist/plume/menu-button/index.js.map +1 -1
- package/skinny/dist/plume/select/index.js +2 -1
- package/skinny/dist/plume/select/index.js.map +1 -1
- package/skinny/dist/plume/switch/index.js +2 -1
- package/skinny/dist/plume/switch/index.js.map +1 -1
- package/skinny/dist/plume-utils-1e225de5.js +25 -0
- package/skinny/dist/plume-utils-1e225de5.js.map +1 -0
- package/skinny/dist/plume-utils-d2476af1.js +35 -0
- package/skinny/dist/plume-utils-d2476af1.js.map +1 -0
- package/skinny/dist/props-utils-c60d3105.js +8 -0
- package/skinny/dist/props-utils-c60d3105.js.map +1 -0
- package/skinny/dist/props-utils-cac0cccf.js +8 -0
- package/skinny/dist/props-utils-cac0cccf.js.map +1 -0
- package/skinny/dist/react-utils-6050fadc.js +201 -0
- package/skinny/dist/react-utils-6050fadc.js.map +1 -0
- package/skinny/dist/react-utils-b5dc6320.js +155 -0
- package/skinny/dist/react-utils-b5dc6320.js.map +1 -0
- package/skinny/dist/render/PlasmicHead/index.js +14 -9
- package/skinny/dist/render/PlasmicHead/index.js.map +1 -1
- package/skinny/dist/render/elements.d.ts +5 -0
- package/skinny/dist/ssr-68913b60.js +107 -0
- package/skinny/dist/ssr-68913b60.js.map +1 -0
- package/skinny/dist/{ssr-84e27ffb.js → ssr-d3321868.js} +9 -4
- package/skinny/dist/ssr-d3321868.js.map +1 -0
- package/skinny/dist/{ssr-b1615b80.js → ssr-f4053cdd.js} +1 -1
- package/skinny/dist/{ssr-84e27ffb.js.map → ssr-f4053cdd.js.map} +1 -1
- package/skinny/dist/states/helpers.d.ts +5 -0
- package/skinny/dist/states/index.d.ts +1 -1
- package/skinny/dist/states/valtio copy.d.ts +15 -0
- package/skinny/dist/states/valtio.d.ts +16 -0
- package/skinny/dist/stories/UseDollarState.stories.d.ts +11 -0
- package/skinny/dist/stories/UseDollarState.test.d.ts +11 -0
- package/skinny/dist/stories/UseDollarState2.stories.d.ts +7 -0
- package/skinny/dist/collection-utils-3487dd27.js.map +0 -1
- package/skinny/dist/ssr-14264281.js +0 -158
- package/skinny/dist/ssr-14264281.js.map +0 -1
- package/skinny/dist/ssr-5141fc77.js +0 -158
- package/skinny/dist/ssr-5141fc77.js.map +0 -1
- package/skinny/dist/ssr-579df58f.js +0 -158
- package/skinny/dist/ssr-579df58f.js.map +0 -1
- package/skinny/dist/ssr-b1615b80.js.map +0 -1
- package/skinny/dist/ssr-d2fd94f2.js +0 -31
- 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,I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AAG,IAAI,wCAAI,IAAI,GAAC,CAAC;aACrB;YACD,OAAO,GAAG,CAAC;SACZ,CAAC;KACH;SAAM;;QAEL,OAAO,IAAI,CAAC;KACb;AACH,CAAC;SAEe,kBAAkB,CAAC,OAA2B;;IAC5D,IAAI,OAAO,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,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,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;;;;"}
|
|
@@ -8,25 +8,30 @@ function PlasmicHead(props) {
|
|
|
8
8
|
// TODO: Link to doc about Head.
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
|
+
// Helmet does not support React.Fragments, so we need to use `[<meta />,
|
|
12
|
+
// <meta />]` instead of `<><meta /><meta /></>`.
|
|
11
13
|
return (React.createElement(Head, null,
|
|
12
|
-
props.image ? (
|
|
13
|
-
React.createElement("meta", { name: "twitter:card", content: "summary_large_image" }),
|
|
14
|
+
props.image ? ([
|
|
15
|
+
React.createElement("meta", { key: "twitter:card", name: "twitter:card", content: "summary_large_image" }),
|
|
14
16
|
React.createElement("meta", { key: "og:image", property: "og:image", content: props.image }),
|
|
15
|
-
React.createElement("meta", { key: "twitter:image", name: "twitter:image", content: props.image })
|
|
16
|
-
|
|
17
|
+
React.createElement("meta", { key: "twitter:image", name: "twitter:image", content: props.image }),
|
|
18
|
+
]) : (React.createElement("meta", { key: "twitter:card", name: "twitter:card", content: "summary" })),
|
|
19
|
+
props.title && [
|
|
17
20
|
React.createElement("title", { key: "title" }, props.title),
|
|
18
21
|
React.createElement("meta", { key: "og:title", property: "og:title", content: props.title }),
|
|
19
|
-
React.createElement("meta", { key: "twitter:title", property: "twitter:title", content: props.title })
|
|
20
|
-
|
|
22
|
+
React.createElement("meta", { key: "twitter:title", property: "twitter:title", content: props.title }),
|
|
23
|
+
],
|
|
24
|
+
props.description && [
|
|
21
25
|
React.createElement("meta", { key: "description", name: "description", content: props.description }),
|
|
22
26
|
React.createElement("meta", { key: "og:description", property: "og:description", content: props.description }),
|
|
23
|
-
React.createElement("meta", { key: "twitter:description", name: "twitter:description", content: props.description })
|
|
24
|
-
|
|
27
|
+
React.createElement("meta", { key: "twitter:description", name: "twitter:description", content: props.description }),
|
|
28
|
+
],
|
|
29
|
+
props.canonical && (React.createElement("link", { key: "canonical", ref: "canonical", href: props.canonical }))));
|
|
25
30
|
}
|
|
26
31
|
var plasmicHeadMeta = {
|
|
27
32
|
name: "hostless-plasmic-head",
|
|
28
33
|
displayName: "Head",
|
|
29
|
-
description: "Used to add page metadata to
|
|
34
|
+
description: "Used to add page metadata to HTML <head />.",
|
|
30
35
|
importName: "PlasmicHead",
|
|
31
36
|
importPath: "@plasmicapp/react-web",
|
|
32
37
|
isRepeatable: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/render/PlasmicHead/index.tsx"],"sourcesContent":["import * as React from \"react\";\n\nexport const PlasmicHeadContext = React.createContext<\n React.ComponentType<any> | undefined\n>(undefined);\n\ntype PlasmicHeadProps = {\n title?: string;\n description?: string;\n image?: string;\n canonical?: string;\n};\n\nexport function PlasmicHead(props: PlasmicHeadProps) {\n const Head = React.useContext(PlasmicHeadContext);\n if (!Head) {\n console.warn(\n `Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.`\n );\n // TODO: Link to doc about Head.\n return null;\n }\n\n return (\n <Head>\n {props.image ? (\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/render/PlasmicHead/index.tsx"],"sourcesContent":["import * as React from \"react\";\n\nexport const PlasmicHeadContext = React.createContext<\n React.ComponentType<any> | undefined\n>(undefined);\n\ntype PlasmicHeadProps = {\n title?: string;\n description?: string;\n image?: string;\n canonical?: string;\n};\n\nexport function PlasmicHead(props: PlasmicHeadProps) {\n const Head = React.useContext(PlasmicHeadContext);\n if (!Head) {\n console.warn(\n `Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.`\n );\n // TODO: Link to doc about Head.\n return null;\n }\n\n // Helmet does not support React.Fragments, so we need to use `[<meta />,\n // <meta />]` instead of `<><meta /><meta /></>`.\n return (\n <Head>\n {props.image ? (\n [\n <meta\n key=\"twitter:card\"\n name=\"twitter:card\"\n content=\"summary_large_image\"\n />,\n <meta key=\"og:image\" property=\"og:image\" content={props.image} />,\n <meta\n key=\"twitter:image\"\n name=\"twitter:image\"\n content={props.image}\n />,\n ]\n ) : (\n <meta key=\"twitter:card\" name=\"twitter:card\" content=\"summary\" />\n )}\n {props.title && [\n <title key=\"title\">{props.title}</title>,\n <meta key=\"og:title\" property=\"og:title\" content={props.title} />,\n <meta\n key=\"twitter:title\"\n property=\"twitter:title\"\n content={props.title}\n />,\n ]}\n {props.description && [\n <meta\n key=\"description\"\n name=\"description\"\n content={props.description}\n />,\n <meta\n key=\"og:description\"\n property=\"og:description\"\n content={props.description}\n />,\n <meta\n key=\"twitter:description\"\n name=\"twitter:description\"\n content={props.description}\n />,\n ]}\n {props.canonical && (\n <link key=\"canonical\" ref=\"canonical\" href={props.canonical} />\n )}\n </Head>\n );\n}\n\nexport const plasmicHeadMeta = {\n name: \"hostless-plasmic-head\",\n displayName: \"Head\",\n description: \"Used to add page metadata to HTML <head />.\",\n importName: \"PlasmicHead\",\n importPath: \"@plasmicapp/react-web\",\n isRepeatable: false,\n styleSections: false,\n props: {\n title: {\n type: \"string\",\n displayName: \"Title\",\n },\n description: {\n type: \"string\",\n displayName: \"Description\",\n },\n image: {\n type: \"imageUrl\",\n displayName: \"Image\",\n },\n canonical: {\n type: \"string\",\n displayName: \"Canonical URL\",\n },\n },\n};\n"],"names":[],"mappings":";;IAEa,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAEnD,SAAS,EAAE;SASG,WAAW,CAAC,KAAuB;IACjD,IAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAClD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,CAAC,IAAI,CACV,+GAA+G,CAChH,CAAC;;QAEF,OAAO,IAAI,CAAC;KACb;;;IAID,QACE,oBAAC,IAAI;QACF,KAAK,CAAC,KAA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WAAW,EAAE,6CAA6C;IAC1D,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,uBAAuB;IACnC,YAAY,EAAE,KAAK;IACnB,aAAa,EAAE,KAAK;IACpB,KAAK,EAAE;QACL,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,OAAO;SACrB;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,aAAa;SAC3B;QACD,KAAK,EAAE;YACL,IAAI,EAAE,UAAU;YAChB,WAAW,EAAE,OAAO;SACrB;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,eAAe;SAC7B;KACF;;;;;"}
|
|
@@ -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[];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { SSRProvider, useIsSSR as useIsSSR$1 } from '@react-aria/ssr';
|
|
4
|
+
|
|
5
|
+
const PlasmicTranslatorContext = React__default.createContext(undefined);
|
|
6
|
+
function isIterable(val) {
|
|
7
|
+
return val != null && typeof val[Symbol.iterator] === "function";
|
|
8
|
+
}
|
|
9
|
+
function genTranslatableString(elt) {
|
|
10
|
+
const components = {};
|
|
11
|
+
let componentsCount = 0;
|
|
12
|
+
const getText = (node) => {
|
|
13
|
+
if (!node) {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
if (typeof node === "number" ||
|
|
17
|
+
typeof node === "boolean" ||
|
|
18
|
+
typeof node === "string") {
|
|
19
|
+
return node.toString();
|
|
20
|
+
}
|
|
21
|
+
if (typeof node !== "object") {
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(node) || isIterable(node)) {
|
|
25
|
+
return Array.from(node)
|
|
26
|
+
.map((child) => getText(child))
|
|
27
|
+
.filter((child) => !!child)
|
|
28
|
+
.join("");
|
|
29
|
+
}
|
|
30
|
+
const nodeChildren = (hasKey(node, "props") &&
|
|
31
|
+
hasKey(node.props, "children") &&
|
|
32
|
+
node.props.children) ||
|
|
33
|
+
(hasKey(node, "children") && node.children) ||
|
|
34
|
+
[];
|
|
35
|
+
const contents = `${React__default.Children.toArray(nodeChildren)
|
|
36
|
+
.map((child) => getText(child))
|
|
37
|
+
.filter((child) => !!child)
|
|
38
|
+
.join("")}`;
|
|
39
|
+
if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
|
|
40
|
+
return contents;
|
|
41
|
+
}
|
|
42
|
+
const componentId = componentsCount + 1;
|
|
43
|
+
componentsCount++;
|
|
44
|
+
components[componentId] = React__default.isValidElement(node)
|
|
45
|
+
? React__default.cloneElement(node, {
|
|
46
|
+
key: componentId,
|
|
47
|
+
children: undefined,
|
|
48
|
+
})
|
|
49
|
+
: node;
|
|
50
|
+
return `<${componentId}>${contents}</${componentId}>`;
|
|
51
|
+
};
|
|
52
|
+
const str = getText(elt);
|
|
53
|
+
return {
|
|
54
|
+
str,
|
|
55
|
+
components,
|
|
56
|
+
componentsCount,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function Trans({ children }) {
|
|
60
|
+
const _t = React__default.useContext(PlasmicTranslatorContext);
|
|
61
|
+
if (!_t) {
|
|
62
|
+
warnNoTranslationFunctionAtMostOnce();
|
|
63
|
+
return children;
|
|
64
|
+
}
|
|
65
|
+
const { str, components, componentsCount } = genTranslatableString(children);
|
|
66
|
+
return _t(str, componentsCount > 0 ? { components } : undefined);
|
|
67
|
+
}
|
|
68
|
+
let hasWarned = false;
|
|
69
|
+
function warnNoTranslationFunctionAtMostOnce() {
|
|
70
|
+
if (!hasWarned) {
|
|
71
|
+
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
72
|
+
hasWarned = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function hasKey(v, key) {
|
|
76
|
+
return typeof v === "object" && v !== null && key in v;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const PlasmicRootContext = React.createContext(undefined);
|
|
80
|
+
function PlasmicRootProvider(props) {
|
|
81
|
+
const { platform, children } = props;
|
|
82
|
+
const context = React.useMemo(() => ({
|
|
83
|
+
platform,
|
|
84
|
+
}), [platform]);
|
|
85
|
+
return (React.createElement(PlasmicRootContext.Provider, { value: context },
|
|
86
|
+
React.createElement(SSRProvider, null,
|
|
87
|
+
React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator }, children))));
|
|
88
|
+
}
|
|
89
|
+
const useIsSSR = useIsSSR$1;
|
|
90
|
+
function useHasPlasmicRoot() {
|
|
91
|
+
return !!React.useContext(PlasmicRootContext);
|
|
92
|
+
}
|
|
93
|
+
let hasWarnedSSR = false;
|
|
94
|
+
/**
|
|
95
|
+
* Warns the user if PlasmicRootProvider is not used
|
|
96
|
+
*/
|
|
97
|
+
function useEnsureSSRProvider() {
|
|
98
|
+
const hasRoot = useHasPlasmicRoot();
|
|
99
|
+
if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
hasWarnedSSR = true;
|
|
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`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { PlasmicRootProvider as P, Trans as T, useEnsureSSRProvider as a, genTranslatableString as g, useIsSSR as u };
|
|
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,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC;AACnE,CAAC;SAEe,qBAAqB,CAAC,GAAoB;IACxD,MAAM,UAAU,GAEZ,EAAE,CAAC;IACP,IAAI,eAAe,GAAG,CAAC,CAAC;IAExB,MAAM,OAAO,GAAG,CAAC,IAAqB;QACpC,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,EAAE,CAAC;SACX;QACD,IACE,OAAO,IAAI,KAAK,QAAQ;YACxB,OAAO,IAAI,KAAK,SAAS;YACzB,OAAO,IAAI,KAAK,QAAQ,EACxB;YACA,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;SACxB;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,OAAO,EAAE,CAAC;SACX;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;YAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;iBACpB,GAAG,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;iBAC9B,MAAM,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC;iBAC1B,IAAI,CAAC,EAAE,CAAC,CAAC;SACb;QACD,MAAM,YAAY,GAChB,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC;YAC7B,IAAI,CAAC,KAAK,CAAC,QAAwC;aACrD,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAA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pB,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 =
|
|
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(
|
|
90
|
-
React.createElement(
|
|
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-
|
|
115
|
+
//# sourceMappingURL=ssr-d3321868.js.map
|