@plasmicapp/react-web 0.2.187 → 0.2.189
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 +71 -34
- package/dist/auth/PlasmicPageGuard.d.ts +2 -1
- package/dist/index-common.d.ts +1 -1
- package/dist/react-web.cjs.development.js +8 -1
- 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 +8 -2
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/ssr.d.ts +2 -1
- package/package.json +5 -5
- package/skinny/dist/auth/PlasmicPageGuard.d.ts +2 -1
- package/skinny/dist/{collection-utils-0bfbb8a8.js → collection-utils-0967eaf0.js} +4 -4
- package/skinny/dist/{collection-utils-0bfbb8a8.js.map → collection-utils-0967eaf0.js.map} +1 -1
- package/skinny/dist/{common-125681b4.js → common-9d6d348d.js} +2 -2
- package/skinny/dist/{common-125681b4.js.map → common-9d6d348d.js.map} +1 -1
- package/skinny/dist/index-common.d.ts +1 -1
- package/skinny/dist/index.js +12 -7
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/plume/button/index.js +2 -2
- package/skinny/dist/plume/checkbox/index.js +5 -5
- package/skinny/dist/plume/menu/index.js +6 -6
- package/skinny/dist/plume/menu-button/index.js +5 -5
- package/skinny/dist/plume/select/index.js +6 -6
- package/skinny/dist/plume/switch/index.js +5 -5
- package/skinny/dist/plume/text-input/index.js +2 -2
- package/skinny/dist/plume/triggered-overlay/index.js +4 -4
- package/skinny/dist/{plume-utils-427ac667.js → plume-utils-7d68bcc0.js} +2 -2
- package/skinny/dist/{plume-utils-427ac667.js.map → plume-utils-7d68bcc0.js.map} +1 -1
- package/skinny/dist/{props-utils-5092839e.js → props-utils-9f9c761a.js} +2 -2
- package/skinny/dist/{props-utils-5092839e.js.map → props-utils-9f9c761a.js.map} +1 -1
- package/skinny/dist/{react-utils-091cf05d.js → react-utils-ee4e03ba.js} +2 -2
- package/skinny/dist/{react-utils-091cf05d.js.map → react-utils-ee4e03ba.js.map} +1 -1
- package/skinny/dist/render/PlasmicImg/index.js +2 -2
- package/skinny/dist/render/ssr.d.ts +2 -1
- package/skinny/dist/{ssr-08aff522.js → ssr-c9834f50.js} +2 -2
- package/skinny/dist/ssr-c9834f50.js.map +1 -0
- package/skinny/dist/ssr-08aff522.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as __assign, p as pick, d as __spreadArray, e as __read, c as __rest } from '../../common-9d6d348d.js';
|
|
2
2
|
import { useMenu as useMenu$1, useMenuSection, useMenuItem as useMenuItem$1 } from '@react-aria/menu';
|
|
3
3
|
import { useTreeState } from '@react-stately/tree';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { m as mergeProps } from '../../react-utils-
|
|
6
|
-
import { a as useEnsureSSRProvider } from '../../ssr-
|
|
7
|
-
import { r as renderCollectionNode, u as useDerivedItemsFromChildren, a as renderAsCollectionChild } from '../../collection-utils-
|
|
8
|
-
import { n as noOutline, m as mergeVariantToggles } from '../../plume-utils-
|
|
9
|
-
import { g as getStyleProps } from '../../props-utils-
|
|
5
|
+
import { m as mergeProps } from '../../react-utils-ee4e03ba.js';
|
|
6
|
+
import { a as useEnsureSSRProvider } from '../../ssr-c9834f50.js';
|
|
7
|
+
import { r as renderCollectionNode, u as useDerivedItemsFromChildren, a as renderAsCollectionChild } from '../../collection-utils-0967eaf0.js';
|
|
8
|
+
import { n as noOutline, m as mergeVariantToggles } from '../../plume-utils-7d68bcc0.js';
|
|
9
|
+
import { g as getStyleProps } from '../../props-utils-9f9c761a.js';
|
|
10
10
|
import { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
|
|
11
11
|
import { useSeparator } from '@react-aria/separator';
|
|
12
12
|
import 'classnames';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useMenuTriggerState } from '@react-stately/menu';
|
|
3
|
-
import { m as mergeProps } from '../../react-utils-
|
|
3
|
+
import { m as mergeProps } from '../../react-utils-ee4e03ba.js';
|
|
4
4
|
import { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
|
|
5
|
-
import {
|
|
5
|
+
import { b as __assign, p as pick, d as __spreadArray, e as __read } from '../../common-9d6d348d.js';
|
|
6
6
|
import { useMenuTrigger as useMenuTrigger$1 } from '@react-aria/menu';
|
|
7
7
|
import { usePress } from '@react-aria/interactions';
|
|
8
|
-
import { g as getPlumeType, m as mergeVariantToggles } from '../../plume-utils-
|
|
8
|
+
import { g as getPlumeType, m as mergeVariantToggles } from '../../plume-utils-7d68bcc0.js';
|
|
9
9
|
import { useFocusable } from '@react-aria/focus';
|
|
10
|
-
import { a as useEnsureSSRProvider } from '../../ssr-
|
|
11
|
-
import { g as getStyleProps } from '../../props-utils-
|
|
10
|
+
import { a as useEnsureSSRProvider } from '../../ssr-c9834f50.js';
|
|
11
|
+
import { g as getStyleProps } from '../../props-utils-9f9c761a.js';
|
|
12
12
|
import 'classnames';
|
|
13
13
|
import '@plasmicapp/data-sources-context';
|
|
14
14
|
import '@react-aria/ssr';
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as __assign, p as pick, d as __spreadArray, e as __read, c as __rest } from '../../common-9d6d348d.js';
|
|
2
2
|
import { usePlasmicCanvasContext } from '@plasmicapp/host';
|
|
3
3
|
import { usePress } from '@react-aria/interactions';
|
|
4
4
|
import { useListBox, useOption, useListBoxSection } from '@react-aria/listbox';
|
|
5
5
|
import { useSelect as useSelect$1, HiddenSelect } from '@react-aria/select';
|
|
6
6
|
import { useSelectState } from '@react-stately/select';
|
|
7
7
|
import * as React from 'react';
|
|
8
|
-
import { m as mergeProps, d as mergeRefs } from '../../react-utils-
|
|
9
|
-
import { a as useEnsureSSRProvider } from '../../ssr-
|
|
10
|
-
import { g as getChildProp, r as renderCollectionNode, b as useDerivedItems, a as renderAsCollectionChild } from '../../collection-utils-
|
|
11
|
-
import { m as mergeVariantToggles, n as noOutline } from '../../plume-utils-
|
|
12
|
-
import { g as getStyleProps } from '../../props-utils-
|
|
8
|
+
import { m as mergeProps, d as mergeRefs } from '../../react-utils-ee4e03ba.js';
|
|
9
|
+
import { a as useEnsureSSRProvider } from '../../ssr-c9834f50.js';
|
|
10
|
+
import { g as getChildProp, r as renderCollectionNode, b as useDerivedItems, a as renderAsCollectionChild } from '../../collection-utils-0967eaf0.js';
|
|
11
|
+
import { m as mergeVariantToggles, n as noOutline } from '../../plume-utils-7d68bcc0.js';
|
|
12
|
+
import { g as getStyleProps } from '../../props-utils-9f9c761a.js';
|
|
13
13
|
import { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
|
|
14
14
|
import { useSeparator } from '@react-aria/separator';
|
|
15
15
|
import 'classnames';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as __assign, p as pick, d as __spreadArray, e as __read } from '../../common-9d6d348d.js';
|
|
2
2
|
import { useSwitch as useSwitch$1 } from '@react-aria/switch';
|
|
3
3
|
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
|
4
4
|
import { useToggleState } from '@react-stately/toggle';
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import { m as mergeProps } from '../../react-utils-
|
|
7
|
-
import { a as useEnsureSSRProvider } from '../../ssr-
|
|
8
|
-
import { m as mergeVariantToggles } from '../../plume-utils-
|
|
9
|
-
import { g as getStyleProps } from '../../props-utils-
|
|
6
|
+
import { m as mergeProps } from '../../react-utils-ee4e03ba.js';
|
|
7
|
+
import { a as useEnsureSSRProvider } from '../../ssr-c9834f50.js';
|
|
8
|
+
import { m as mergeVariantToggles } from '../../plume-utils-7d68bcc0.js';
|
|
9
|
+
import { g as getStyleProps } from '../../props-utils-9f9c761a.js';
|
|
10
10
|
import 'classnames';
|
|
11
11
|
import '@plasmicapp/data-sources-context';
|
|
12
12
|
import '@react-aria/ssr';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as __rest, b as __assign, p as pick, d as __spreadArray, e as __read, o as omit } from '../../common-9d6d348d.js';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { m as mergeVariantToggles } from '../../plume-utils-
|
|
3
|
+
import { m as mergeVariantToggles } from '../../plume-utils-7d68bcc0.js';
|
|
4
4
|
|
|
5
5
|
function useTextInput(plasmicClass, props, config, ref) {
|
|
6
6
|
var _a, _b, _c;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { e as __read,
|
|
1
|
+
import { e as __read, b as __assign, p as pick, d as __spreadArray } from '../../common-9d6d348d.js';
|
|
2
2
|
import { usePlasmicCanvasContext } from '@plasmicapp/host';
|
|
3
3
|
import { FocusScope } from '@react-aria/focus';
|
|
4
4
|
import { useOverlay, useOverlayPosition, DismissButton } from '@react-aria/overlays';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import * as ReactDOM from 'react-dom';
|
|
7
|
-
import { d as mergeRefs, u as useIsomorphicLayoutEffect, m as mergeProps } from '../../react-utils-
|
|
8
|
-
import { m as mergeVariantToggles } from '../../plume-utils-
|
|
9
|
-
import { g as getStyleProps } from '../../props-utils-
|
|
7
|
+
import { d as mergeRefs, u as useIsomorphicLayoutEffect, m as mergeProps } from '../../react-utils-ee4e03ba.js';
|
|
8
|
+
import { m as mergeVariantToggles } from '../../plume-utils-7d68bcc0.js';
|
|
9
|
+
import { g as getStyleProps } from '../../props-utils-9f9c761a.js';
|
|
10
10
|
import { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
|
|
11
11
|
export { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
|
|
12
12
|
import 'classnames';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { m as mapValues, k as groupBy } from './common-
|
|
2
|
+
import { m as mapValues, k as groupBy } from './common-9d6d348d.js';
|
|
3
3
|
|
|
4
4
|
var PLUME_STRICT_MODE = true;
|
|
5
5
|
function mergeVariantToggles() {
|
|
@@ -32,4 +32,4 @@ function getPlumeType(child) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export { PLUME_STRICT_MODE as P, getPlumeType as g, mergeVariantToggles as m, noOutline as n };
|
|
35
|
-
//# sourceMappingURL=plume-utils-
|
|
35
|
+
//# sourceMappingURL=plume-utils-7d68bcc0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plume-utils-
|
|
1
|
+
{"version":3,"file":"plume-utils-7d68bcc0.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,0DAAG,KAAK,CAAC,KAAK,CAAC,CAAA,EAExD;AAChB;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { p as pick } from './common-
|
|
1
|
+
import { p as pick } from './common-9d6d348d.js';
|
|
2
2
|
|
|
3
3
|
function getStyleProps(props) {
|
|
4
4
|
return pick(props, "className", "style");
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export { getStyleProps as g };
|
|
8
|
-
//# sourceMappingURL=props-utils-
|
|
8
|
+
//# sourceMappingURL=props-utils-9f9c761a.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props-utils-
|
|
1
|
+
{"version":3,"file":"props-utils-9f9c761a.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,4 +1,4 @@
|
|
|
1
|
-
import { f as __values, d as __spreadArray, e as __read,
|
|
1
|
+
import { f as __values, d as __spreadArray, e as __read, b as __assign } from './common-9d6d348d.js';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
|
|
@@ -198,4 +198,4 @@ function getElementTypeName(element) {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
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-
|
|
201
|
+
//# sourceMappingURL=react-utils-ee4e03ba.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-utils-
|
|
1
|
+
{"version":3,"file":"react-utils-ee4e03ba.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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GAAG,GAAG,IAAI,wCAAI,IAAI,UAAC,CAAC;aACrB;YACD,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;gBAC9B,GAAG,GAAG,IAAI,wCAAI,IAAI,UAAC,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,7 +1,7 @@
|
|
|
1
|
-
import { d as __spreadArray, e as __read,
|
|
1
|
+
import { d as __spreadArray, e as __read, c as __rest, b as __assign, p as pick } from '../../common-9d6d348d.js';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import React__default from 'react';
|
|
4
|
-
import { d as mergeRefs } from '../../react-utils-
|
|
4
|
+
import { d as mergeRefs } from '../../react-utils-ee4e03ba.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Responsive `<img/>` replacement, based on `next/image`
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PlasmicDataSourceContextValue } from "@plasmicapp/data-sources-context";
|
|
1
2
|
import { useIsSSR as useAriaIsSSR } from "@react-aria/ssr";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { PlasmicTranslator } from "./translation";
|
|
@@ -5,7 +6,7 @@ export { PlasmicDataSourceContextProvider, useCurrentUser, } from "@plasmicapp/d
|
|
|
5
6
|
export interface PlasmicRootContextValue {
|
|
6
7
|
platform?: "nextjs" | "gatsby";
|
|
7
8
|
}
|
|
8
|
-
export interface PlasmicRootProviderProps {
|
|
9
|
+
export interface PlasmicRootProviderProps extends PlasmicDataSourceContextValue {
|
|
9
10
|
platform?: "nextjs" | "gatsby";
|
|
10
11
|
children?: React.ReactNode;
|
|
11
12
|
translator?: PlasmicTranslator;
|
|
@@ -81,7 +81,7 @@ function hasKey(v, key) {
|
|
|
81
81
|
|
|
82
82
|
var PlasmicRootContext = React.createContext(undefined);
|
|
83
83
|
function PlasmicRootProvider(props) {
|
|
84
|
-
var
|
|
84
|
+
var platform = props.platform, children = props.children, userAuthToken = props.userAuthToken, isUserLoading = props.isUserLoading, authRedirectUri = props.authRedirectUri, user = props.user;
|
|
85
85
|
var context = React.useMemo(function () { return ({
|
|
86
86
|
platform: platform
|
|
87
87
|
}); }, [platform]);
|
|
@@ -115,4 +115,4 @@ function useEnsureSSRProvider() {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
export { PlasmicRootProvider as P, Trans as T, useEnsureSSRProvider as a, genTranslatableString as g, useIsSSR as u };
|
|
118
|
-
//# sourceMappingURL=ssr-
|
|
118
|
+
//# sourceMappingURL=ssr-c9834f50.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-c9834f50.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 = React.createContext<\n PlasmicTranslator | undefined\n>(undefined);\n\nexport interface TransProps {\n transKey?: string;\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({ transKey, 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(transKey ?? 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 {\n PlasmicDataSourceContextProvider,\n PlasmicDataSourceContextValue,\n} from \"@plasmicapp/data-sources-context\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"@react-aria/ssr\";\nimport * as React from \"react\";\nimport { PlasmicHeadContext } from \"./PlasmicHead\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\nexport {\n PlasmicDataSourceContextProvider,\n useCurrentUser,\n} from \"@plasmicapp/data-sources-context\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext = React.createContext<\n PlasmicRootContextValue | undefined\n>(undefined);\n\nexport interface PlasmicRootProviderProps\n extends PlasmicDataSourceContextValue {\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 {\n platform,\n children,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n user,\n } = props;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n const dataSourceContextValue = React.useMemo(\n () => ({\n userAuthToken,\n user,\n isUserLoading,\n authRedirectUri,\n }),\n [userAuthToken, isUserLoading, user, authRedirectUri]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicDataSourceContextProvider value={dataSourceContextValue}>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n <PlasmicHeadContext.Provider value={props.Head}>\n {children}\n </PlasmicHeadContext.Provider>\n </PlasmicTranslatorContext.Provider>\n </PlasmicDataSourceContextProvider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;;;AAWO,IAAM,wBAAwB,GAAGA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KAAK,EAAE,KAAK,CAAC,UAAU;oBACxD,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAC3C,QAAQ,CACmB,CACI,CACH,CACvB,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-08aff522.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 = React.createContext<\n PlasmicTranslator | undefined\n>(undefined);\n\nexport interface TransProps {\n transKey?: string;\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({ transKey, 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(transKey ?? str, componentsCount > 0 ? { components } : undefined);\n}\n\nlet hasWarned = false;\nfunction warnNoTranslationFunctionAtMostOnce() {\n if (!hasWarned) {\n console.warn(\n \"Using Plasmic Translation but no translation function has been provided\"\n );\n hasWarned = true;\n }\n}\n\nfunction hasKey<K extends string>(v: any, key: K): v is Record<K, any> {\n return typeof v === \"object\" && v !== null && key in v;\n}\n","import { PlasmicDataSourceContextProvider } from \"@plasmicapp/data-sources-context\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"@react-aria/ssr\";\nimport * as React from \"react\";\nimport { PlasmicHeadContext } from \"./PlasmicHead\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\nexport {\n PlasmicDataSourceContextProvider,\n useCurrentUser,\n} from \"@plasmicapp/data-sources-context\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext = React.createContext<\n PlasmicRootContextValue | undefined\n>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n Head?: React.ComponentType<any>;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const {\n platform,\n children,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n user,\n } = props as any;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n const dataSourceContextValue = React.useMemo(\n () => ({\n userAuthToken,\n user,\n isUserLoading,\n authRedirectUri,\n }),\n [userAuthToken, isUserLoading, user, authRedirectUri]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicDataSourceContextProvider value={dataSourceContextValue}>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n <PlasmicHeadContext.Provider value={props.Head}>\n {children}\n </PlasmicHeadContext.Provider>\n </PlasmicTranslatorContext.Provider>\n </PlasmicDataSourceContextProvider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;;;AAWO,IAAM,wBAAwB,GAAGA,cAAK,CAAC,aAAa,CAEzD,SAAS,CAAC,CAAC;AAOb,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC;AACnE,CAAC;SA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