@plasmicapp/react-web 0.2.110 → 0.2.113
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/LICENSE.md +21 -0
- package/dist/all.d.ts +65 -28
- package/dist/common.d.ts +3 -3
- package/dist/index-common.d.ts +4 -3
- package/dist/index.d.ts +1 -1
- package/dist/react-web.cjs.development.js +415 -370
- 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 +401 -370
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/elements.d.ts +5 -0
- package/dist/render/ssr.d.ts +1 -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 +8 -3
- package/skinny/dist/{collection-utils-57c273dc.js → collection-utils-43f97262.js} +14 -13
- package/skinny/dist/collection-utils-43f97262.js.map +1 -0
- package/skinny/dist/{common-182a0b0c.js → common-9ebe374e.js} +1 -1
- package/skinny/dist/common-9ebe374e.js.map +1 -0
- package/skinny/dist/common.d.ts +3 -3
- package/skinny/dist/index-common.d.ts +4 -3
- package/skinny/dist/index.d.ts +1 -1
- package/skinny/dist/index.js +53 -42
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/plume/button/index.js +7 -7
- package/skinny/dist/plume/button/index.js.map +1 -1
- package/skinny/dist/plume/checkbox/index.js +18 -17
- package/skinny/dist/plume/checkbox/index.js.map +1 -1
- package/skinny/dist/plume/menu/index.js +39 -39
- package/skinny/dist/plume/menu/index.js.map +1 -1
- package/skinny/dist/plume/menu-button/index.js +23 -22
- package/skinny/dist/plume/menu-button/index.js.map +1 -1
- package/skinny/dist/plume/select/index.js +42 -43
- package/skinny/dist/plume/select/index.js.map +1 -1
- package/skinny/dist/plume/switch/index.js +17 -16
- package/skinny/dist/plume/switch/index.js.map +1 -1
- package/skinny/dist/plume/text-input/index.js +10 -10
- package/skinny/dist/plume/text-input/index.js.map +1 -1
- package/skinny/dist/plume/triggered-overlay/index.js +14 -14
- package/skinny/dist/plume/triggered-overlay/index.js.map +1 -1
- package/skinny/dist/{plume-utils-623b91cc.js → plume-utils-d9811bf3.js} +2 -2
- package/skinny/dist/{plume-utils-27cd384f.js.map → plume-utils-d9811bf3.js.map} +1 -1
- package/skinny/dist/{props-utils-b2ad4997.js → props-utils-228208e6.js} +2 -2
- package/skinny/dist/{props-utils-7c02c0a8.js.map → props-utils-228208e6.js.map} +1 -1
- package/skinny/dist/{react-utils-35cb2a4e.js → react-utils-7bc53870.js} +6 -6
- package/skinny/dist/{react-utils-35cb2a4e.js.map → react-utils-7bc53870.js.map} +1 -1
- package/skinny/dist/render/PlasmicHead/index.js +6 -6
- package/skinny/dist/render/PlasmicImg/index.js +27 -27
- package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
- package/skinny/dist/render/elements.d.ts +5 -0
- package/skinny/dist/render/ssr.d.ts +1 -0
- package/skinny/dist/{ssr-b1615b80.js → ssr-b16a1854.js} +16 -10
- package/skinny/dist/ssr-b16a1854.js.map +1 -0
- package/skinny/dist/states/helpers.d.ts +5 -0
- package/skinny/dist/states/index.d.ts +1 -1
- package/skinny/dist/states/valtio.d.ts +16 -0
- package/skinny/dist/stories/UseDollarState.stories.d.ts +11 -0
- package/skinny/dist/collection-utils-2745acd4.js +0 -238
- package/skinny/dist/collection-utils-2745acd4.js.map +0 -1
- package/skinny/dist/collection-utils-3487dd27.js +0 -238
- package/skinny/dist/collection-utils-3487dd27.js.map +0 -1
- package/skinny/dist/collection-utils-57c273dc.js.map +0 -1
- package/skinny/dist/common-182a0b0c.js.map +0 -1
- package/skinny/dist/plume-utils-27cd384f.js +0 -35
- package/skinny/dist/plume-utils-623b91cc.js.map +0 -1
- package/skinny/dist/props-utils-7c02c0a8.js +0 -8
- package/skinny/dist/props-utils-b2ad4997.js.map +0 -1
- package/skinny/dist/react-utils-7c01e440.js +0 -172
- package/skinny/dist/react-utils-7c01e440.js.map +0 -1
- package/skinny/dist/render/PlasmicHead.d.ts +0 -35
- 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-84e27ffb.js +0 -110
- package/skinny/dist/ssr-84e27ffb.js.map +0 -1
- package/skinny/dist/ssr-9ebd98ed.js +0 -158
- package/skinny/dist/ssr-9ebd98ed.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
- package/skinny/dist/ssr-f4053cdd.js +0 -110
- package/skinny/dist/ssr-f4053cdd.js.map +0 -1
- package/skinny/dist/ssr-fbf922f6.js +0 -108
- package/skinny/dist/ssr-fbf922f6.js.map +0 -1
- package/skinny/dist/tslib.es6-d26ffe68.js +0 -132
- package/skinny/dist/tslib.es6-d26ffe68.js.map +0 -1
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { m as mapValues, g as groupBy } from './tslib.es6-d26ffe68.js';
|
|
3
|
-
|
|
4
|
-
var PLUME_STRICT_MODE = true;
|
|
5
|
-
function mergeVariantToggles() {
|
|
6
|
-
var toggles = [];
|
|
7
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8
|
-
toggles[_i] = arguments[_i];
|
|
9
|
-
}
|
|
10
|
-
var definedToggles = toggles.filter(function (x) { return !!x.def; });
|
|
11
|
-
var grouped = groupBy(definedToggles, function (_a) {
|
|
12
|
-
var def = _a.def;
|
|
13
|
-
return def.group;
|
|
14
|
-
});
|
|
15
|
-
return mapValues(grouped, function (subToggles) {
|
|
16
|
-
return Object.fromEntries(subToggles.map(function (_a) {
|
|
17
|
-
var def = _a.def, active = _a.active;
|
|
18
|
-
return [def.variant, !!active];
|
|
19
|
-
}));
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function noOutline() {
|
|
23
|
-
return { outline: "none" };
|
|
24
|
-
}
|
|
25
|
-
function getPlumeType(child) {
|
|
26
|
-
var _a;
|
|
27
|
-
if (!React.isValidElement(child)) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
var childType = child.type;
|
|
31
|
-
return (childType.__plumeType || ((_a = childType.getPlumeType) === null || _a === void 0 ? void 0 : _a.call(childType, child.props)));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { PLUME_STRICT_MODE as P, getPlumeType as g, mergeVariantToggles as m, noOutline as n };
|
|
35
|
-
//# sourceMappingURL=plume-utils-27cd384f.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plume-utils-623b91cc.js","sources":["../../src/plume/plume-utils.ts"],"sourcesContent":["import * as React from \"react\";\nimport { groupBy, mapValues } from \"../common\";\nimport { SingleChoiceArg } from \"../render/elements\";\n\nexport let PLUME_STRICT_MODE = true;\n\nexport function setPlumeStrictMode(mode: boolean) {\n PLUME_STRICT_MODE = mode;\n}\n\ntype VariantArgChoices<T> = T extends (infer M)[]\n ? M\n : T extends SingleChoiceArg<infer M>\n ? M\n : never;\ntype VariantArgsChoices<V> = { [k in keyof V]-?: VariantArgChoices<V[k]> };\ntype DictValues<V extends Record<string, any>> = V[keyof V];\ntype DictTuples<V extends Record<string, any>> = DictValues<\n { [K in keyof V]: [K, V[K]] }\n>;\nexport type VariantDefTuple<V> = DictTuples<VariantArgsChoices<V>>;\n\ntype DistributeTuple<T> = T extends [infer T1, infer T2]\n ? { group: T1; variant: T2 }\n : never;\n\nexport type VariantDef<V> = DistributeTuple<VariantDefTuple<V>>;\n\nexport type PlasmicClass<\n V extends Record<string, any>,\n A extends Record<string, any>,\n O extends Record<string, any>\n> = {\n (props: { variants?: V; args?: A; overrides?: O }): React.ReactElement | null;\n internalVariantProps: (keyof V)[];\n internalArgProps: (keyof A)[];\n};\n\nexport type AnyPlasmicClass = PlasmicClass<any, any, any>;\n\nexport type PlasmicClassVariants<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<infer V, any, any> ? V : unknown;\nexport type PlasmicClassArgs<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<any, infer A, any> ? A : unknown;\nexport type PlasmicClassOverrides<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<any, any, infer O> ? O : unknown;\n\ntype BooleanLike = boolean | undefined | null;\n\nexport function mergeVariantToggles<V>(\n ...toggles: { def?: VariantDef<V>; active: BooleanLike }[]\n) {\n const definedToggles = toggles.filter((x) => !!x.def) as {\n def: VariantDef<V>;\n active: BooleanLike;\n }[];\n const grouped = groupBy(definedToggles, ({ def }) => def.group as string);\n return mapValues(grouped, (subToggles) => {\n return Object.fromEntries(\n subToggles.map(({ def, active }) => [def.variant, !!active])\n );\n });\n}\n\nexport function noOutline() {\n return { outline: \"none\" };\n}\n\nexport function getPlumeType(child: React.ReactChild): string | undefined {\n if (!React.isValidElement(child)) {\n return undefined;\n }\n const childType = child.type as any;\n return (childType.__plumeType || childType.getPlumeType?.(child.props)) as\n | string\n | undefined;\n}\n"],"names":[],"mappings":";;;IAIW,iBAAiB,GAAG,KAAK;SAgDpB,mBAAmB;IACjC,iBAA0D;SAA1D,UAA0D,EAA1D,qBAA0D,EAA1D,IAA0D;QAA1D,4BAA0D;;IAE1D,IAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,CAAC,GAAG,GAAA,CAGjD,CAAC;IACJ,IAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,UAAC,EAAO;YAAL,GAAG,SAAA;QAAO,OAAA,GAAG,CAAC,KAAe;KAAA,CAAC,CAAC;IAC1E,OAAO,SAAS,CAAC,OAAO,EAAE,UAAC,UAAU;QACnC,OAAO,MAAM,CAAC,WAAW,CACvB,UAAU,CAAC,GAAG,CAAC,UAAC,EAAe;gBAAb,GAAG,SAAA,EAAE,MAAM,YAAA;YAAO,OAAA,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;SAAA,CAAC,CAC7D,CAAC;KACH,CAAC,CAAC;AACL,CAAC;SAEe,SAAS;IACvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;SAEe,YAAY,CAAC,KAAuB;;IAClD,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;QAChC,OAAO,SAAS,CAAC;KAClB;IACD,IAAM,SAAS,GAAG,KAAK,CAAC,IAAW,CAAC;IACpC,QAAQ,SAAS,CAAC,WAAW,KAAI,MAAA,SAAS,CAAC,YAAY,+CAAtB,SAAS,EAAgB,KAAK,CAAC,KAAK,CAAC,CAAA,EAExD;AAChB;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"props-utils-b2ad4997.js","sources":["../../src/plume/props-utils.ts"],"sourcesContent":["import * as React from \"react\";\nimport { pick, pickBy } from \"../common\";\nimport {\n AnyPlasmicClass,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n} from \"./plume-utils\";\n\nexport interface StyleProps {\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function getStyleProps<P extends StyleProps>(props: P): StyleProps {\n return pick(props, \"className\", \"style\");\n}\n\nexport function getDefaultPlasmicProps<C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: Record<string, any>\n) {\n return {\n plasmicProps: {\n variants: pick(\n props,\n ...plasmicClass.internalVariantProps\n ) as PlasmicClassVariants<C>,\n args: pick(\n props,\n ...plasmicClass.internalArgProps\n ) as PlasmicClassArgs<C>,\n overrides: {} as PlasmicClassOverrides<C>,\n },\n };\n}\n\nconst RE_DATA_PROP = /^(data-.*)$/;\n\nexport function getDataProps(props: Record<string, any>) {\n return pickBy(props, (k) => RE_DATA_PROP.test(k));\n}\n"],"names":[],"mappings":";;SAcgB,aAAa,CAAuB,KAAQ;IAC1D,OAAO,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC3C;;;;"}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { b as __spreadArray, a as __assign } from './tslib.es6-d26ffe68.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], children));
|
|
14
|
-
}
|
|
15
|
-
else if (children || "children" in props) {
|
|
16
|
-
// Only call React.createElement with `children` if there are actual children,
|
|
17
|
-
// or if there was an explicit (albeit undefined) children passed via
|
|
18
|
-
// props. Otherwise, if you pass `undefined` as the children argument
|
|
19
|
-
// to React.createElement, the created element will have prop {children: undefined}.
|
|
20
|
-
// If the `root` is an PlasmicGeneratedComponent, and these props with {children: undefined}
|
|
21
|
-
// are used, then it will be taken as a `children` override, and will thus blank out
|
|
22
|
-
// everything under the root node.
|
|
23
|
-
return React__default.createElement(elementType, props, children);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return React__default.createElement(elementType, props);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function ensureNotArray(children) {
|
|
30
|
-
if (Array.isArray(children)) {
|
|
31
|
-
if (children.length === 1) {
|
|
32
|
-
return children[0];
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return React__default.createElement.apply(React__default, __spreadArray([React__default.Fragment, {}], children));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return children;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Flattens ReactNode into an array of ReactChild, but does NOT replace
|
|
44
|
-
* missing keys with array index, as React.Children.toArray() does.
|
|
45
|
-
*/
|
|
46
|
-
function toChildArray(children) {
|
|
47
|
-
if (isReactChild(children)) {
|
|
48
|
-
return [children];
|
|
49
|
-
}
|
|
50
|
-
else if (Array.isArray(children)) {
|
|
51
|
-
return children.flatMap(toChildArray);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function isReactText(child) {
|
|
58
|
-
return typeof child === "string" || typeof child === "number";
|
|
59
|
-
}
|
|
60
|
-
function isReactChild(child) {
|
|
61
|
-
return React__default.isValidElement(child) || isReactText(child);
|
|
62
|
-
}
|
|
63
|
-
function isReactNode(x) {
|
|
64
|
-
return (typeof x === "string" || typeof x === "number" || React__default.isValidElement(x));
|
|
65
|
-
}
|
|
66
|
-
function mergeProps(props) {
|
|
67
|
-
var restProps = [];
|
|
68
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
69
|
-
restProps[_i - 1] = arguments[_i];
|
|
70
|
-
}
|
|
71
|
-
if (restProps.every(function (rest) { return Object.keys(rest).length === 0; })) {
|
|
72
|
-
return props;
|
|
73
|
-
}
|
|
74
|
-
var result = __assign({}, props);
|
|
75
|
-
for (var _a = 0, restProps_1 = restProps; _a < restProps_1.length; _a++) {
|
|
76
|
-
var rest = restProps_1[_a];
|
|
77
|
-
for (var _b = 0, _c = Object.keys(rest); _b < _c.length; _b++) {
|
|
78
|
-
var key = _c[_b];
|
|
79
|
-
result[key] = mergePropVals(key, result[key], rest[key]);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
function updateRef(ref, value) {
|
|
85
|
-
if (!ref) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (typeof ref === "function") {
|
|
89
|
-
ref(value);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
if (!Object.isFrozen(ref)) {
|
|
93
|
-
ref.current = value;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function mergeRefs() {
|
|
98
|
-
var refs = [];
|
|
99
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
100
|
-
refs[_i] = arguments[_i];
|
|
101
|
-
}
|
|
102
|
-
return function (value) {
|
|
103
|
-
for (var _i = 0, refs_1 = refs; _i < refs_1.length; _i++) {
|
|
104
|
-
var ref = refs_1[_i];
|
|
105
|
-
updateRef(ref, value);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function mergePropVals(name, val1, val2) {
|
|
110
|
-
if (val1 === NONE || val2 === NONE) {
|
|
111
|
-
// The NONE sentinel always skips all merging and returns null
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
else if (val1 == null) {
|
|
115
|
-
// If either of them is nil, prefer the other
|
|
116
|
-
return val2;
|
|
117
|
-
}
|
|
118
|
-
else if (val2 == null) {
|
|
119
|
-
return val1;
|
|
120
|
-
}
|
|
121
|
-
else if (name === "className") {
|
|
122
|
-
// Special case for className -- always combine both class names
|
|
123
|
-
return classNames(val1, val2);
|
|
124
|
-
}
|
|
125
|
-
else if (name === "style") {
|
|
126
|
-
// Special case for style -- always shallow-merge style dicts
|
|
127
|
-
return __assign(__assign({}, val1), val2);
|
|
128
|
-
}
|
|
129
|
-
else if (name === "ref") {
|
|
130
|
-
// Special case for ref
|
|
131
|
-
return mergeRefs(val1, val2);
|
|
132
|
-
}
|
|
133
|
-
else if (typeof val1 !== typeof val2) {
|
|
134
|
-
// If the type of the two values are different, then no way to merge them.
|
|
135
|
-
// Prefer val2.
|
|
136
|
-
return val2;
|
|
137
|
-
}
|
|
138
|
-
else if (name.startsWith("on") && typeof val1 === "function") {
|
|
139
|
-
// Special case for event handlers -- always call both handlers
|
|
140
|
-
return function () {
|
|
141
|
-
var args = [];
|
|
142
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
143
|
-
args[_i] = arguments[_i];
|
|
144
|
-
}
|
|
145
|
-
var res;
|
|
146
|
-
if (typeof val1 === "function") {
|
|
147
|
-
res = val1.apply(void 0, args);
|
|
148
|
-
}
|
|
149
|
-
if (typeof val2 === "function") {
|
|
150
|
-
res = val2.apply(void 0, args);
|
|
151
|
-
}
|
|
152
|
-
return res;
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
// For all else, prefer val2
|
|
157
|
-
return val2;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function getElementTypeName(element) {
|
|
161
|
-
var _a, _b, _c, _d;
|
|
162
|
-
if (typeof element.type === "string") {
|
|
163
|
-
return element.type;
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
var comp = element.type;
|
|
167
|
-
return (_d = (_b = (_a = comp.displayName) !== null && _a !== void 0 ? _a : comp.name) !== null && _b !== void 0 ? _b : (_c = comp.render) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : "Component";
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export { NONE as N, mergePropVals as a, isBrowser as b, createElementWithChildren as c, mergeRefs as d, ensureNotArray as e, getElementTypeName as g, isReactNode as i, mergeProps as m, toChildArray as t, useIsomorphicLayoutEffect as u };
|
|
172
|
-
//# sourceMappingURL=react-utils-7c01e440.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-utils-7c01e440.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,GACF,QAAQ,EACU,CAAC;KACzB;SAAM,IAAI,QAAQ,IAAI,UAAU,IAAI,KAAK,EAAE;;;;;;;;QAQ1C,OAAOA,cAAK,CAAC,aAAa,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;KAC1D;SAAM;QACL,OAAOA,cAAK,CAAC,aAAa,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;KAChD;AACH,CAAC;SAEe,cAAc,CAAC,QAAyB;IACtD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;SACpB;aAAM;YACL,OAAOA,cAAK,CAAC,aAAa,OAAnBA,cAAK,iBAAeA,cAAK,CAAC,QAAQ,EAAE,EAAE,GAAK,QAAQ,GAAE;SAC7D;KACF;SAAM;QACL,OAAO,QAAQ,CAAC;KACjB;AACH,CAAC;AAED;;;;SAIgB,YAAY,CAAC,QAAyB;IACpD,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE;QAC1B,OAAO,CAAC,QAAQ,CAAC,CAAC;KACnB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I,CAAC;KACb;SAAM,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;;QAE9D,OAAO;YAAC,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YACpB,IAAI,GAAQ,CAAC;YACb,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;gBAC9B,GAAG,GAAG,IAAI,eAAI,IAAI,CAAC,CAAC;aACrB;YACD,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;gBAC9B,GAAG,GAAG,IAAI,eAAI,IAAI,CAAC,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;;;;"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
export declare const PlasmicHeadContext: React.Context<React.ComponentType<any> | undefined>;
|
|
3
|
-
declare type PlasmicHeadProps = {
|
|
4
|
-
title?: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
image?: string;
|
|
7
|
-
canonical?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare function PlasmicHead(props: PlasmicHeadProps): JSX.Element | null;
|
|
10
|
-
export declare const plasmicHeadMeta: {
|
|
11
|
-
name: string;
|
|
12
|
-
displayName: string;
|
|
13
|
-
description: string;
|
|
14
|
-
importName: string;
|
|
15
|
-
importPath: string;
|
|
16
|
-
props: {
|
|
17
|
-
title: {
|
|
18
|
-
type: string;
|
|
19
|
-
displayName: string;
|
|
20
|
-
};
|
|
21
|
-
description: {
|
|
22
|
-
type: string;
|
|
23
|
-
displayName: string;
|
|
24
|
-
};
|
|
25
|
-
image: {
|
|
26
|
-
type: string;
|
|
27
|
-
displayName: string;
|
|
28
|
-
};
|
|
29
|
-
canonical: {
|
|
30
|
-
type: string;
|
|
31
|
-
displayName: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export {};
|
|
@@ -1,158 +0,0 @@
|
|
|
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
|
-
var PlasmicHeadContext = React.createContext(undefined);
|
|
6
|
-
function PlasmicHead(props) {
|
|
7
|
-
var Head = React.useContext(PlasmicHeadContext);
|
|
8
|
-
if (!Head) {
|
|
9
|
-
console.warn("Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.");
|
|
10
|
-
// TODO: Link to doc about Head.
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
return (React.createElement(Head, null,
|
|
14
|
-
props.image ? (React.createElement(React.Fragment, null,
|
|
15
|
-
React.createElement("meta", { name: "twitter:card", content: "summary_large_image" }),
|
|
16
|
-
React.createElement("meta", { key: "og:image", property: "og:image", content: props.image }),
|
|
17
|
-
React.createElement("meta", { key: "twitter:image", name: "twitter:image", content: props.image }))) : (React.createElement("meta", { name: "twitter:card", content: "summary" })),
|
|
18
|
-
props.title && (React.createElement(React.Fragment, null,
|
|
19
|
-
React.createElement("title", { key: "title" }, props.title),
|
|
20
|
-
React.createElement("meta", { key: "og:title", property: "og:title", content: props.title }),
|
|
21
|
-
React.createElement("meta", { key: "twitter:title", property: "twitter:title", content: props.title }))),
|
|
22
|
-
props.description && (React.createElement(React.Fragment, null,
|
|
23
|
-
React.createElement("meta", { key: "description", name: "description", content: props.description }),
|
|
24
|
-
React.createElement("meta", { key: "og:description", property: "og:description", content: props.description }),
|
|
25
|
-
React.createElement("meta", { key: "twitter:description", name: "twitter:description", content: props.description }))),
|
|
26
|
-
props.canonical && React.createElement("link", { ref: "canonical", href: props.canonical })));
|
|
27
|
-
}
|
|
28
|
-
var plasmicHeadMeta = {
|
|
29
|
-
name: "hostless-plasmic-head",
|
|
30
|
-
displayName: "Head",
|
|
31
|
-
description: "Used to add page metadata to HEAD tag",
|
|
32
|
-
importName: "PlasmicHead",
|
|
33
|
-
importPath: "@plasmicapp/react-web",
|
|
34
|
-
props: {
|
|
35
|
-
title: {
|
|
36
|
-
type: "string",
|
|
37
|
-
displayName: "Title",
|
|
38
|
-
},
|
|
39
|
-
description: {
|
|
40
|
-
type: "string",
|
|
41
|
-
displayName: "Description",
|
|
42
|
-
},
|
|
43
|
-
image: {
|
|
44
|
-
type: "imageUrl",
|
|
45
|
-
displayName: "Image",
|
|
46
|
-
},
|
|
47
|
-
canonical: {
|
|
48
|
-
type: "string",
|
|
49
|
-
displayName: "Canonical URL",
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var PlasmicTranslatorContext = React__default.createContext(undefined);
|
|
55
|
-
function isIterable(val) {
|
|
56
|
-
return val != null && typeof val[Symbol.iterator] === "function";
|
|
57
|
-
}
|
|
58
|
-
function genTranslatableString(elt) {
|
|
59
|
-
var components = {};
|
|
60
|
-
var componentsCount = 0;
|
|
61
|
-
var getText = function (node) {
|
|
62
|
-
if (!node) {
|
|
63
|
-
return "";
|
|
64
|
-
}
|
|
65
|
-
if (typeof node === "number" ||
|
|
66
|
-
typeof node === "boolean" ||
|
|
67
|
-
typeof node === "string") {
|
|
68
|
-
return node.toString();
|
|
69
|
-
}
|
|
70
|
-
if (typeof node !== "object") {
|
|
71
|
-
return "";
|
|
72
|
-
}
|
|
73
|
-
if (Array.isArray(node) || isIterable(node)) {
|
|
74
|
-
return Array.from(node)
|
|
75
|
-
.map(function (child) { return getText(child); })
|
|
76
|
-
.filter(function (child) { return !!child; })
|
|
77
|
-
.join("");
|
|
78
|
-
}
|
|
79
|
-
var nodeChildren = (hasKey(node, "props") &&
|
|
80
|
-
hasKey(node.props, "children") &&
|
|
81
|
-
node.props.children) ||
|
|
82
|
-
(hasKey(node, "children") && node.children) ||
|
|
83
|
-
[];
|
|
84
|
-
var contents = "" + React__default.Children.toArray(nodeChildren)
|
|
85
|
-
.map(function (child) { return getText(child); })
|
|
86
|
-
.filter(function (child) { return !!child; })
|
|
87
|
-
.join("");
|
|
88
|
-
if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
|
|
89
|
-
return contents;
|
|
90
|
-
}
|
|
91
|
-
var componentId = componentsCount + 1;
|
|
92
|
-
componentsCount++;
|
|
93
|
-
components[componentId] = React__default.isValidElement(node)
|
|
94
|
-
? React__default.cloneElement(node, {
|
|
95
|
-
key: componentId,
|
|
96
|
-
children: undefined,
|
|
97
|
-
})
|
|
98
|
-
: node;
|
|
99
|
-
return "<" + componentId + ">" + contents + "</" + componentId + ">";
|
|
100
|
-
};
|
|
101
|
-
var str = getText(elt);
|
|
102
|
-
return {
|
|
103
|
-
str: str,
|
|
104
|
-
components: components,
|
|
105
|
-
componentsCount: componentsCount,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function Trans(_a) {
|
|
109
|
-
var children = _a.children;
|
|
110
|
-
var _t = React__default.useContext(PlasmicTranslatorContext);
|
|
111
|
-
if (!_t) {
|
|
112
|
-
warnNoTranslationFunctionAtMostOnce();
|
|
113
|
-
return children;
|
|
114
|
-
}
|
|
115
|
-
var _b = genTranslatableString(children), str = _b.str, components = _b.components, componentsCount = _b.componentsCount;
|
|
116
|
-
return _t(str, componentsCount > 0 ? { components: components } : undefined);
|
|
117
|
-
}
|
|
118
|
-
var hasWarned = false;
|
|
119
|
-
function warnNoTranslationFunctionAtMostOnce() {
|
|
120
|
-
if (!hasWarned) {
|
|
121
|
-
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
122
|
-
hasWarned = true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function hasKey(v, key) {
|
|
126
|
-
return typeof v === "object" && v !== null && key in v;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
var PlasmicRootContext = React.createContext(undefined);
|
|
130
|
-
function PlasmicRootProvider(props) {
|
|
131
|
-
var platform = props.platform, children = props.children;
|
|
132
|
-
var context = React.useMemo(function () { return ({
|
|
133
|
-
platform: platform,
|
|
134
|
-
}); }, [platform]);
|
|
135
|
-
return (React.createElement(PlasmicRootContext.Provider, { value: context },
|
|
136
|
-
React.createElement(SSRProvider, null,
|
|
137
|
-
React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator },
|
|
138
|
-
React.createElement(PlasmicHeadContext.Provider, { value: props.head }, children)))));
|
|
139
|
-
}
|
|
140
|
-
var useIsSSR = useIsSSR$1;
|
|
141
|
-
function useHasPlasmicRoot() {
|
|
142
|
-
return !!React.useContext(PlasmicRootContext);
|
|
143
|
-
}
|
|
144
|
-
var hasWarnedSSR = false;
|
|
145
|
-
/**
|
|
146
|
-
* Warns the user if PlasmicRootProvider is not used
|
|
147
|
-
*/
|
|
148
|
-
function useEnsureSSRProvider() {
|
|
149
|
-
var hasRoot = useHasPlasmicRoot();
|
|
150
|
-
if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
hasWarnedSSR = true;
|
|
154
|
-
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");
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export { PlasmicHead as P, Trans as T, PlasmicRootProvider as a, useEnsureSSRProvider as b, genTranslatableString as g, plasmicHeadMeta as p, useIsSSR as u };
|
|
158
|
-
//# sourceMappingURL=ssr-14264281.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-14264281.js","sources":["../../src/render/PlasmicHead.tsx","../../src/render/translation.tsx","../../src/render/ssr.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { ComponentMeta } from \"@plasmicapp/host/registerComponent\";\n\nexport const PlasmicHeadContext =\n React.createContext<React.ComponentType<any> | undefined>(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 <>\n <meta name=\"twitter:card\" content=\"summary_large_image\" />\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 name=\"twitter:card\" content=\"summary\" />\n )}\n {props.title && (\n <>\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 )}\n {props.description && (\n <>\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 )}\n {props.canonical && <link ref=\"canonical\" href={props.canonical} />}\n </Head>\n );\n}\n\nexport const plasmicHeadMeta: ComponentMeta<PlasmicHeadProps> = {\n name: \"hostless-plasmic-head\",\n displayName: \"Head\",\n description: \"Used to add page metadata to HEAD tag\",\n importName: \"PlasmicHead\",\n importPath: \"@plasmicapp/react-web\",\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","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\";\nimport { PlasmicHeadContext } from \"./PlasmicHead\";\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 head?: React.ComponentType<any>;\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 <PlasmicHeadContext.Provider value={props.head}>\n {children}\n </PlasmicHeadContext.Provider>\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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,SAApB,EAAE,QAAQ,GAAK,KAAK,SAAV,CAAW;IACrC,IAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAC3B,cAAM,QAAC;QACL,QAAQ,UAAA;KACT,IAAC,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;gBACxD,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAC3C,QAAQ,CACmB,CACI,CACxB,CACc,EAC9B;AACJ,CAAC;IAEY,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,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;;;;"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { SSRProvider, useIsSSR as useIsSSR$1 } from '@react-aria/ssr';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import React__default from 'react';
|
|
4
|
-
|
|
5
|
-
var PlasmicHeadContext = React.createContext(undefined);
|
|
6
|
-
function PlasmicHead(props) {
|
|
7
|
-
var Head = React.useContext(PlasmicHeadContext);
|
|
8
|
-
if (!Head) {
|
|
9
|
-
console.warn("Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.");
|
|
10
|
-
// TODO: Link to doc about Head.
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
return (React.createElement(Head, null,
|
|
14
|
-
props.image ? (React.createElement(React.Fragment, null,
|
|
15
|
-
React.createElement("meta", { name: "twitter:card", content: "summary_large_image" }),
|
|
16
|
-
React.createElement("meta", { key: "og:image", property: "og:image", content: props.image }),
|
|
17
|
-
React.createElement("meta", { key: "twitter:image", name: "twitter:image", content: props.image }))) : (React.createElement("meta", { name: "twitter:card", content: "summary" })),
|
|
18
|
-
props.title && (React.createElement(React.Fragment, null,
|
|
19
|
-
React.createElement("title", { key: "title" }, props.title),
|
|
20
|
-
React.createElement("meta", { key: "og:title", property: "og:title", content: props.title }),
|
|
21
|
-
React.createElement("meta", { key: "twitter:title", property: "twitter:title", content: props.title }))),
|
|
22
|
-
props.description && (React.createElement(React.Fragment, null,
|
|
23
|
-
React.createElement("meta", { key: "description", name: "description", content: props.description }),
|
|
24
|
-
React.createElement("meta", { key: "og:description", property: "og:description", content: props.description }),
|
|
25
|
-
React.createElement("meta", { key: "twitter:description", name: "twitter:description", content: props.description }))),
|
|
26
|
-
props.canonical && React.createElement("link", { ref: "canonical", href: props.canonical })));
|
|
27
|
-
}
|
|
28
|
-
var plasmicHeadMeta = {
|
|
29
|
-
name: "hostless-plasmic-head",
|
|
30
|
-
displayName: "Head",
|
|
31
|
-
description: "Used to add page metadata to HEAD tag",
|
|
32
|
-
importName: "PlasmicHead",
|
|
33
|
-
importPath: "@plasmicapp/react-web",
|
|
34
|
-
props: {
|
|
35
|
-
title: {
|
|
36
|
-
type: "string",
|
|
37
|
-
displayName: "Title",
|
|
38
|
-
},
|
|
39
|
-
description: {
|
|
40
|
-
type: "string",
|
|
41
|
-
displayName: "Description",
|
|
42
|
-
},
|
|
43
|
-
image: {
|
|
44
|
-
type: "imageUrl",
|
|
45
|
-
displayName: "Image",
|
|
46
|
-
},
|
|
47
|
-
canonical: {
|
|
48
|
-
type: "string",
|
|
49
|
-
displayName: "Canonical URL",
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var PlasmicTranslatorContext = React__default.createContext(undefined);
|
|
55
|
-
function isIterable(val) {
|
|
56
|
-
return val != null && typeof val[Symbol.iterator] === "function";
|
|
57
|
-
}
|
|
58
|
-
function genTranslatableString(elt) {
|
|
59
|
-
var components = {};
|
|
60
|
-
var componentsCount = 0;
|
|
61
|
-
var getText = function (node) {
|
|
62
|
-
if (!node) {
|
|
63
|
-
return "";
|
|
64
|
-
}
|
|
65
|
-
if (typeof node === "number" ||
|
|
66
|
-
typeof node === "boolean" ||
|
|
67
|
-
typeof node === "string") {
|
|
68
|
-
return node.toString();
|
|
69
|
-
}
|
|
70
|
-
if (typeof node !== "object") {
|
|
71
|
-
return "";
|
|
72
|
-
}
|
|
73
|
-
if (Array.isArray(node) || isIterable(node)) {
|
|
74
|
-
return Array.from(node)
|
|
75
|
-
.map(function (child) { return getText(child); })
|
|
76
|
-
.filter(function (child) { return !!child; })
|
|
77
|
-
.join("");
|
|
78
|
-
}
|
|
79
|
-
var nodeChildren = (hasKey(node, "props") &&
|
|
80
|
-
hasKey(node.props, "children") &&
|
|
81
|
-
node.props.children) ||
|
|
82
|
-
(hasKey(node, "children") && node.children) ||
|
|
83
|
-
[];
|
|
84
|
-
var contents = "" + React__default.Children.toArray(nodeChildren)
|
|
85
|
-
.map(function (child) { return getText(child); })
|
|
86
|
-
.filter(function (child) { return !!child; })
|
|
87
|
-
.join("");
|
|
88
|
-
if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
|
|
89
|
-
return contents;
|
|
90
|
-
}
|
|
91
|
-
var componentId = componentsCount + 1;
|
|
92
|
-
componentsCount++;
|
|
93
|
-
components[componentId] = React__default.isValidElement(node)
|
|
94
|
-
? React__default.cloneElement(node, {
|
|
95
|
-
key: componentId,
|
|
96
|
-
children: undefined,
|
|
97
|
-
})
|
|
98
|
-
: node;
|
|
99
|
-
return "<" + componentId + ">" + contents + "</" + componentId + ">";
|
|
100
|
-
};
|
|
101
|
-
var str = getText(elt);
|
|
102
|
-
return {
|
|
103
|
-
str: str,
|
|
104
|
-
components: components,
|
|
105
|
-
componentsCount: componentsCount,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function Trans(_a) {
|
|
109
|
-
var children = _a.children;
|
|
110
|
-
var _t = React__default.useContext(PlasmicTranslatorContext);
|
|
111
|
-
if (!_t) {
|
|
112
|
-
warnNoTranslationFunctionAtMostOnce();
|
|
113
|
-
return children;
|
|
114
|
-
}
|
|
115
|
-
var _b = genTranslatableString(children), str = _b.str, components = _b.components, componentsCount = _b.componentsCount;
|
|
116
|
-
return _t(str, componentsCount > 0 ? { components: components } : undefined);
|
|
117
|
-
}
|
|
118
|
-
var hasWarned = false;
|
|
119
|
-
function warnNoTranslationFunctionAtMostOnce() {
|
|
120
|
-
if (!hasWarned) {
|
|
121
|
-
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
122
|
-
hasWarned = true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function hasKey(v, key) {
|
|
126
|
-
return typeof v === "object" && v !== null && key in v;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
var PlasmicRootContext = React.createContext(undefined);
|
|
130
|
-
function PlasmicRootProvider(props) {
|
|
131
|
-
var platform = props.platform, children = props.children;
|
|
132
|
-
var context = React.useMemo(function () { return ({
|
|
133
|
-
platform: platform,
|
|
134
|
-
}); }, [platform]);
|
|
135
|
-
return (React.createElement(PlasmicRootContext.Provider, { value: context },
|
|
136
|
-
React.createElement(SSRProvider, null,
|
|
137
|
-
React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator },
|
|
138
|
-
React.createElement(PlasmicHeadContext.Provider, { value: props.Head }, children)))));
|
|
139
|
-
}
|
|
140
|
-
var useIsSSR = useIsSSR$1;
|
|
141
|
-
function useHasPlasmicRoot() {
|
|
142
|
-
return !!React.useContext(PlasmicRootContext);
|
|
143
|
-
}
|
|
144
|
-
var hasWarnedSSR = false;
|
|
145
|
-
/**
|
|
146
|
-
* Warns the user if PlasmicRootProvider is not used
|
|
147
|
-
*/
|
|
148
|
-
function useEnsureSSRProvider() {
|
|
149
|
-
var hasRoot = useHasPlasmicRoot();
|
|
150
|
-
if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
hasWarnedSSR = true;
|
|
154
|
-
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");
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export { PlasmicHead as P, Trans as T, PlasmicRootProvider as a, useEnsureSSRProvider as b, genTranslatableString as g, plasmicHeadMeta as p, useIsSSR as u };
|
|
158
|
-
//# sourceMappingURL=ssr-5141fc77.js.map
|