@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 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-d3321868.js","sources":["../../src/render/translation.tsx","../../src/render/ssr.tsx"],"sourcesContent":["import React from \"react\";\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement;\n };\n }\n) => React.ReactNode;\n\nexport const PlasmicTranslatorContext =\n React.createContext<PlasmicTranslator | undefined>(undefined);\n\nexport interface TransProps {\n children?: React.ReactNode;\n}\n\nfunction isIterable(val: any): val is Iterable<any> {\n return val != null && typeof val[Symbol.iterator] === \"function\";\n}\n\nexport function genTranslatableString(elt: React.ReactNode) {\n const components: {\n [key: string]: React.ReactElement;\n } = {};\n let componentsCount = 0;\n\n const getText = (node: React.ReactNode): string => {\n if (!node) {\n return \"\";\n }\n if (\n typeof node === \"number\" ||\n typeof node === \"boolean\" ||\n typeof node === \"string\"\n ) {\n return node.toString();\n }\n if (typeof node !== \"object\") {\n return \"\";\n }\n if (Array.isArray(node) || isIterable(node)) {\n return Array.from(node)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\");\n }\n const nodeChildren: React.ReactNode =\n (hasKey(node, \"props\") &&\n hasKey(node.props, \"children\") &&\n (node.props.children as React.ReactNode | undefined)) ||\n (hasKey(node, \"children\") && node.children) ||\n [];\n const contents = `${React.Children.toArray(nodeChildren)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\")}`;\n if (React.isValidElement(node) && node.type === React.Fragment) {\n return contents;\n }\n const componentId = componentsCount + 1;\n componentsCount++;\n components[componentId] = React.isValidElement(node)\n ? React.cloneElement(node as any, {\n key: componentId,\n children: undefined,\n })\n : (node as never);\n return `<${componentId}>${contents}</${componentId}>`;\n };\n\n const str = getText(elt);\n return {\n str,\n components,\n componentsCount,\n };\n}\n\nexport function Trans({ children }: TransProps) {\n const _t = React.useContext(PlasmicTranslatorContext);\n if (!_t) {\n warnNoTranslationFunctionAtMostOnce();\n return children;\n }\n\n const { str, components, componentsCount } = genTranslatableString(children);\n return _t(str, componentsCount > 0 ? { components } : undefined);\n}\n\nlet hasWarned = false;\nfunction warnNoTranslationFunctionAtMostOnce() {\n if (!hasWarned) {\n console.warn(\n \"Using Plasmic Translation but no translation function has been provided\"\n );\n hasWarned = true;\n }\n}\n\nfunction hasKey<K extends string>(v: any, key: K): v is Record<K, any> {\n return typeof v === \"object\" && v !== null && key in v;\n}\n","import { PlasmicDataSourceContextProvider } from \"@plasmicapp/data-sources-context\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"@react-aria/ssr\";\nimport * as React from \"react\";\nimport { PlasmicHeadContext } from \"./PlasmicHead\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext = React.createContext<\n PlasmicRootContextValue | undefined\n>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n Head?: React.ComponentType<any>;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const { platform, children, userAuthToken } = props as any;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n const dataSourceContextValue = React.useMemo(\n () => ({\n userAuthToken,\n }),\n [userAuthToken]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicDataSourceContextProvider value={dataSourceContextValue}>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n <PlasmicHeadContext.Provider value={props.Head}>\n {children}\n </PlasmicHeadContext.Provider>\n </PlasmicTranslatorContext.Provider>\n </PlasmicDataSourceContextProvider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;;;AAWO,IAAM,wBAAwB,GACnCA,cAAK,CAAC,aAAa,CAAgC,SAAS,CAAC,CAAC;AAMhE,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC;AACnE,CAAC;SAEe,qBAAqB,CAAC,GAAoB;IACxD,IAAM,UAAU,GAEZ,EAAE,CAAC;IACP,IAAI,eAAe,GAAG,CAAC,CAAC;IAExB,IAAM,OAAO,GAAG,UAAC,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,UAAC,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AAA;KACd,IAAC,EACF,CAAC,aAAa,CAAC,CAChB,CAAC;IACF,QACE,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO;QACzC,oBAAC,WAAW;YACV,oBAAC,gCAAgC,IAAC,KAAK,EAAE,sBAAsB;gBAC7D,oBAAC,wBAAwB,CAAC,QAAQ,IAAC,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-
|
|
1
|
+
{"version":3,"file":"ssr-f4053cdd.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 { SSRProvider, useIsSSR as useAriaIsSSR } from \"@react-aria/ssr\";\nimport * as React from \"react\";\nimport { PlasmicHeadContext } from \"./PlasmicHead\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext = React.createContext<\n PlasmicRootContextValue | undefined\n>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n Head?: React.ComponentType<any>;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const { platform, children } = 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. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;;AAWO,IAAM,wBAAwB,GACnCA,cAAK,CAAC,aAAa,CAAgC,SAAS,CAAC,CAAC;AAMhE,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC;AACnE,CAAC;SAEe,qBAAqB,CAAC,GAAoB;IACxD,IAAM,UAAU,GAEZ,EAAE,CAAC;IACP,IAAI,eAAe,GAAG,CAAC,CAAC;IAExB,IAA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KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,IAAI,CAAC,CAAC;AACzD;;AC9FA,IAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAE5C,SAAS,CAAC,CAAC;SASG,mBAAmB,CAAC,KAA+B;IACzD,IAAA,QAAQ,GAAe,KAAK,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;;;;"}
|
|
@@ -7,3 +7,8 @@ export declare function generateStateOnChangeProp($state: $State, stateName: str
|
|
|
7
7
|
* We need to pass `parent[index1][index2].counter to the child component
|
|
8
8
|
*/
|
|
9
9
|
export declare function generateStateValueProp($state: $State, path: (string | number)[]): any;
|
|
10
|
+
/**
|
|
11
|
+
* Forked from https://github.com/lukeed/dset
|
|
12
|
+
* Changes: fixed setting a deep value to a proxy object
|
|
13
|
+
*/
|
|
14
|
+
export declare function set(obj: any, keys: any, val: any): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare type InitFunc<T> = ($props: Record<string, any>, $state: $State) => T;
|
|
2
2
|
export interface $State {
|
|
3
3
|
[key: string]: any;
|
|
4
|
-
registerInitFunc
|
|
4
|
+
registerInitFunc?: (path: string, f: InitFunc<any>) => any;
|
|
5
5
|
}
|
|
6
6
|
export interface $StateSpec<T> {
|
|
7
7
|
path: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare type InitFunc<T> = ($props: Record<string, any>, $state: $State) => T;
|
|
2
|
+
export interface $State {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
registerInitFunc: (path: string, f: InitFunc<any>) => any;
|
|
5
|
+
}
|
|
6
|
+
export interface $StateSpec<T> {
|
|
7
|
+
path: string;
|
|
8
|
+
initFunc?: InitFunc<T>;
|
|
9
|
+
initVal?: T;
|
|
10
|
+
type: "private" | "readonly" | "writable";
|
|
11
|
+
valueProp?: string;
|
|
12
|
+
onChangeProp?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function useDollarState(specs: $StateSpec<any>[], props: Record<string, any>): any;
|
|
15
|
+
export default useDollarState;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare type InitFunc<T> = ($props: Record<string, any>, $state: $State, indexes: number[]) => T;
|
|
2
|
+
export interface $State {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
registerInitFunc?: (path: string, f: InitFunc<any>) => any;
|
|
5
|
+
}
|
|
6
|
+
export interface $StateSpec<T> {
|
|
7
|
+
path: string;
|
|
8
|
+
initFunc?: InitFunc<T>;
|
|
9
|
+
initVal?: T;
|
|
10
|
+
type: "private" | "readonly" | "writable";
|
|
11
|
+
valueProp?: string;
|
|
12
|
+
onChangeProp?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function useDollarState(specs: $StateSpec<any>[], props: Record<string, any>): any;
|
|
15
|
+
export default useDollarState;
|
|
16
|
+
export declare function useCanvasDollarState(specs: $StateSpec<any>[], props: Record<string, any>): any;
|
|
@@ -39,3 +39,14 @@ export declare const InitFuncFromContextData: Story<{
|
|
|
39
39
|
}[];
|
|
40
40
|
}>;
|
|
41
41
|
export declare const RepeatedImplicitState: Story<{}>;
|
|
42
|
+
interface Person {
|
|
43
|
+
firstName: string;
|
|
44
|
+
lastName: string;
|
|
45
|
+
nicknames: string[];
|
|
46
|
+
}
|
|
47
|
+
export declare const FormBuilder: Story<{
|
|
48
|
+
people: Person[];
|
|
49
|
+
}>;
|
|
50
|
+
export declare const FormBuilderImplicitStates: Story<{
|
|
51
|
+
people: Person[];
|
|
52
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
title: string;
|
|
3
|
+
};
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const PrivateCounter: any;
|
|
6
|
+
export declare const ReadonlyCounter: any;
|
|
7
|
+
export declare const WritableCounter: any;
|
|
8
|
+
export declare const DynamicInitCount: any;
|
|
9
|
+
export declare const ResetInput: any;
|
|
10
|
+
export declare const RepeatedStates: any;
|
|
11
|
+
export declare const NestedRepeatedCounter: any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collection-utils-3487dd27.js","sources":["../../src/plume/collection-utils.tsx"],"sourcesContent":["/**\n * In general, we try not to expose react-aria's Collections API to Plume users.\n * The Collections API is how react-aria users pass data about collections of\n * things using the built-in Item and Section components, which are abstract,\n * metadata-only components that don't render anything but only serve to specify\n * data. For example, here's how you would use react-spectrum's Picker:\n *\n * <Picker>\n * <Section title=\"Asia\">\n * <Item key=\"taiwan\">Taiwan</Item>\n * <Item key=\"japan\">Japan</Item>\n * <Item key=\"china\">China</Item>\n * </Section>\n * <Section title=\"Europe\">\n * <Item key=\"germany\">Germany</Item>\n * <Item key=\"france\">France</Item>\n * </Section>\n * </Picker>\n *\n * You would re-use this same Item/Section components to pass similar things to\n * Menu, Tabs, etc.\n *\n * For Plasmic, this API is too abstract. The user has explicitly designed components\n * like Select.Option and Select.OptionGroup, and it is weird that they don't actually\n * use these components. It is more natural to do:\n *\n * <Select>\n * <Select.OptionGroup title=\"Asia\">\n * <Select.Option key=\"taiwan\">Taiwan</Select>\n * </Select.OptionGroup>\n * </Select>\n *\n * For Plume, we let users directly use the components they designed, both to collect\n * information and to perform actual rendering. For example, for Plume,\n * you'd use Select.Option instead of Item, and Select.OptionGroup instead of Section.\n * This means that the Select.Option props will collect the same information Item\n * does.\n *\n * A component like Select.Option then serves two purposes:\n *\n * 1. Allow users to specify the collection of data, like in the above example\n * Here, we're mainly interested in the props in those ReactElements so\n * we can pass the Item/Section data onto react-aria's APIs. We are not\n * actually rendering these elements.\n * 2. Once react-aria's Collections API has gone through them and built\n * Collection \"nodes\", we then create cloned versions of these elements\n * with the corresponding node passed in as a secret prop. These ReactElements\n * are then actually used to _render_ the corresponding Option / OptionGroup.\n *\n * This file contains helper functions to help with implementing the above.\n *\n * Note also that most of the collections-based react-aria components expose\n * a parallel API that accepts a list of \"items\" and a render prop, instead\n * of list of Item/Section elements. This is for efficiency, but we are opting\n * to only support the composite-component pattern for now for simplicity.\n */\n\nimport { Node } from \"@react-types/shared\";\nimport React from \"react\";\nimport { Item, Section } from \"react-stately\";\nimport { isString } from \"../common\";\nimport { getElementTypeName, toChildArray } from \"../react-utils\";\nimport { getPlumeType, PLUME_STRICT_MODE } from \"./plume-utils\";\n\nexport interface PlasmicLoaderProps<T> {\n component: string;\n componentProps: T;\n}\n\n/**\n * Props for a Plume component that corresponds to an Item\n */\nexport interface ItemLikeProps {\n /**\n * value key corresponding to this item. Not required if you use the\n * `key` prop instead.\n */\n value?: string | null;\n\n /**\n * The text string value corresponding to this item. Used to support\n * keyboard type-ahead. If not specified, then will be derived from\n * `children` if it is a string, or the `value` or `key`.\n */\n textValue?: string;\n\n /**\n * aria-label for this item.\n */\n \"aria-label\"?: string;\n\n /**\n * Primary content label for this item.\n */\n children?: React.ReactNode;\n\n /**\n * If true, this item will not be selectable.\n */\n isDisabled?: boolean;\n}\n\ntype LoaderAwareItemLikeProps =\n | ItemLikeProps\n | PlasmicLoaderProps<ItemLikeProps>;\n\n/**\n * Props for a Plume component that corresponds to a Section\n */\nexport interface SectionLikeProps {\n /**\n * Heading content of the title\n */\n title?: React.ReactNode;\n\n /**\n * aria-label for this section\n */\n \"aria-label\"?: string;\n\n /**\n * A list of items that belong in this group\n */\n children?: React.ReactNode;\n}\n\ntype LoaderAwareSectionLikeProps =\n | SectionLikeProps\n | PlasmicLoaderProps<SectionLikeProps>;\n\n/**\n * Given children of a component like Select or Menu, derive the items\n * that we will pass into the Collections API. These will be\n * ReactElement<ItemLikeProps|SectionLikeProps>[].\n *\n * Will also assign keys to items by their index in the collection,\n * and collect the keys of disabled items.\n */\nexport function deriveItemsFromChildren<T extends React.ReactElement>(\n children: React.ReactNode,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n invalidChildError?: string;\n requireItemValue: boolean;\n }\n) {\n if (!children) {\n return {\n items: [] as T[],\n disabledKeys: [] as React.Key[],\n };\n }\n\n const { itemPlumeType, sectionPlumeType, invalidChildError } = opts;\n\n // For Plume items without an explicit key, we assign a key as the index\n // of the collection.\n let itemCount = 0;\n let sectionCount = 0;\n\n const ensureValue = (element: React.ReactElement) => {\n if (!propInChild(element, \"value\")) {\n if (opts.requireItemValue && PLUME_STRICT_MODE) {\n throw new Error(\n `Must specify a \"value\" prop for ${getElementTypeName(element)}`\n );\n } else {\n return cloneChild(element, { value: `${itemCount++}` });\n }\n } else {\n // Still increment count even if key is present, so that the\n // auto-assigned key really reflects the index\n itemCount++;\n return element;\n }\n };\n\n const disabledKeys: React.Key[] = [];\n\n const flattenedChildren = (\n children: React.ReactNode\n ): React.ReactElement[] => {\n return toChildArray(children).flatMap((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n return flattenedChildren(child.props.children);\n }\n const type = getPlumeType(child);\n if (type === itemPlumeType) {\n child = ensureValue(child);\n const childKey = getItemLikeKey(child);\n if (getChildProp(child, \"isDisabled\") && !!childKey) {\n disabledKeys.push(childKey);\n }\n return [child];\n }\n if (type === sectionPlumeType) {\n return [\n cloneChild(child, {\n // key of section doesn't actually matter, just needs\n // to be unique\n key: child.key ?? `section-${sectionCount++}`,\n children: flattenedChildren(getChildProp(child, \"children\")),\n }),\n ];\n }\n }\n\n if (PLUME_STRICT_MODE) {\n throw new Error(invalidChildError ?? `Unexpected child`);\n } else {\n return [];\n }\n });\n };\n\n return { items: flattenedChildren(children) as T[], disabledKeys };\n}\n\nexport function useDerivedItemsFromChildren<T extends React.ReactElement>(\n children: React.ReactNode,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n invalidChildError?: string;\n requireItemValue: boolean;\n }\n) {\n const {\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n } = opts;\n return React.useMemo(() => {\n return deriveItemsFromChildren<T>(children, {\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n });\n }, [\n children,\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n ]);\n}\n\n/**\n * Given a Collection node, create the React element that we should use\n * to render it.\n */\nexport function renderCollectionNode(node: Node<any>) {\n // node.rendered should already have our item-like or section-like Plume\n // component elements, so we just need to clone them with a secret\n // _node prop that we use to render.\n return cloneChild(node.rendered as React.ReactElement, {\n _node: node,\n key: node.key,\n });\n}\n\n/**\n * Renders a item-like or section-like Plume component element into an\n * Item or a Section element.\n */\nexport function renderAsCollectionChild<\n T extends React.ReactElement<\n LoaderAwareItemLikeProps | LoaderAwareSectionLikeProps\n >\n>(\n child: T,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n }\n) {\n const plumeType = getPlumeType(child);\n if (plumeType === opts.itemPlumeType) {\n const option = child as React.ReactElement<LoaderAwareItemLikeProps>;\n\n // We look at the children passed to the item-like element, and derive key\n // or textValue from it if it is a string\n const content = getChildProp(option, \"children\");\n\n // The children render prop needs to return an <Item/>\n return (\n <Item\n // We use ItemLike.value if the user explicitly specified a value,\n // and we fallback to key. If the user specified neither, then\n // the Collections API will generate a unique key for this item.\n key={getItemLikeKey(option)}\n // textValue is either explicitly specified by the user, or we\n // try to derive it if `content` is a string.\n textValue={\n getChildProp(option, \"textValue\") ??\n (isString(content)\n ? content\n : propInChild(option, \"value\")\n ? getChildProp(option, \"value\")\n : option.key)\n }\n aria-label={getChildProp(option, \"aria-label\")}\n >\n {\n // Note that what we setting the item-like element as the children\n // here, and not content; we want the entire item-like Plume element to\n // end up as Node.rendered.\n }\n {option}\n </Item>\n );\n } else {\n const group = child as React.ReactElement<LoaderAwareSectionLikeProps>;\n return (\n <Section\n // Note that we are using the whole section-like element as the title\n // here, and not group.props.title; we want the entire section-like\n // Plume element to end up as Node.rendered.\n title={group}\n aria-label={getChildProp(group, \"aria-label\")}\n // We are flattening and deriving the descendant Options as items here.\n // group.props.children should've already been cleaned up by\n // deriveItemsFromChildren()\n items={getChildProp(group, \"children\") as React.ReactElement[]}\n >\n {\n // We use the same render function to turn descendent Options into Items\n }\n {(c: React.ReactElement) => renderAsCollectionChild(c, opts)}\n </Section>\n );\n }\n}\n\nfunction getItemLikeKey(element: React.ReactElement<LoaderAwareItemLikeProps>) {\n return getChildProp(element, \"value\") ?? element.key;\n}\n\n// PlasmicLoader-aware function to get prop from child.\nexport function getChildProp(child: React.ReactElement, prop: string) {\n return \"componentProps\" in child.props\n ? child.props.componentProps[prop]\n : child.props[prop];\n}\n\n// PlasmicLoader-aware function to check `if (prop in element.props)`.\nfunction propInChild(child: React.ReactElement, prop: string): boolean {\n return \"componentProps\" in child.props\n ? prop in child.props.componentProps\n : prop in child.props;\n}\n\n// PlasmicLoader-aware function to clone React element.\nfunction cloneChild(child: React.ReactElement, props: Record<string, any>) {\n if ((child.type as any).getPlumeType) {\n // If React element has getPlumeType(), assume that it is PlasmicLoader,\n // so add nodeProps to componentProps instead of element props.\n return React.cloneElement(child, {\n componentProps: {\n ...child.props.componentProps,\n ...props,\n },\n ...(props.key ? { key: props.key } : {}),\n });\n }\n\n return React.cloneElement(child, props);\n}\n"],"names":["React"],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIA;;;;;;;;SAQgB,uBAAuB,CACrC,QAAyB,EACzB,IAKC;IAED,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO;YACL,KAAK,EAAE,EAAS;YAChB,YAAY,EAAE,EAAiB;SAChC,CAAC;KACH;IAEO,IAAA,aAAa,GAA0C,IAAI,cAA9C,EAAE,gBAAgB,GAAwB,IAAI,iBAA5B,EAAE,iBAAiB,GAAK,IAAI,kBAAT,CAAU;;;IAIpE,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,IAAM,WAAW,GAAG,UAAC,OAA2B;QAC9C,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE;YAClC,IAAI,IAAI,CAAC,gBAAgB,IAAI,iBAAiB,EAAE;gBAC9C,MAAM,IAAI,KAAK,CACb,uCAAmC,kBAAkB,CAAC,OAAO,CAAG,CACjE,CAAC;aACH;iBAAM;gBACL,OAAO,UAAU,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAG,SAAS,EAAI,EAAE,CAAC,CAAC;aACzD;SACF;aAAM;;;YAGL,SAAS,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC;SAChB;KACF,CAAC;IAEF,IAAM,YAAY,GAAgB,EAAE,CAAC;IAErC,IAAM,iBAAiB,GAAG,UACxB,QAAyB;QAEzB,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,UAAC,KAAK;;YAC1C,IAAIA,cAAK,CAAC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,EAAE,YAAY,CAAC;;;;YAI7C,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,UAAU,CAAyB,IAK7D,UAAC,CAAqB,IAAK,OAAA,uBAAuB,CAAC,CAAC,EAAE,IAAI,CAAC,GAAA,CACpD,EACV;KACH;AACH,CAAC;AAED,SAAS,cAAc,CAAC,OAAqD;;IAC3E,OAAO,MAAA,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,mCAAI,OAAO,CAAC,GAAG,CAAC;AACvD,CAAC;AAED;SACgB,YAAY,CAAC,KAAyB,EAAE,IAAY;IAClE,OAAO,gBAAgB,IAAI,KAAK,CAAC,KAAK;UAClC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;UAChC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAED;AACA,SAAS,WAAW,CAAC,KAAyB,EAAE,IAAY;IAC1D,OAAO,gBAAgB,IAAI,KAAK,CAAC,KAAK;UAClC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,cAAc;UAClC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC;AAC1B,CAAC;AAED;AACA,SAAS,UAAU,CAAC,KAAyB,EAAE,KAA0B;IACvE,IAAK,KAAK,CAAC,IAAY,CAAC,YAAY,EAAE;;;QAGpC,OAAOA,cAAK,CAAC,YAAY,CAAC,KAAK,aAC7B,cAAc,wBACT,KAAK,CAAC,KAAK,CAAC,cAAc,GAC1B,KAAK,MAEN,KAAK,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GACvC,CAAC;KACJ;IAED,OAAOA,cAAK,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC1C;;;;"}
|
|
@@ -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. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;AAGO,IAAM,kBAAkB,GAC7B,KAAK,CAAC,aAAa,CAAuC,SAAS,CAAC,CAAC;SASvD,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;IAED,QACE,oBAAC,IAAI;QACF,KAAK,CAAC,KAAK,IACV;YACE,8BAAM,IAAI,EAAC,cAAc,EAAC,OAAO,EAAC,qBAAqB,GAAG;YAC1D,8BAAM,GAAG,EAAC,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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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-5141fc77.js","sources":["../../src/render/PlasmicHead/index.tsx","../../src/render/translation.tsx","../../src/render/ssr.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 <>\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 = {\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 { SSRProvider, useIsSSR as useAriaIsSSR } from \"@react-aria/ssr\";\nimport * as React from \"react\";\nimport { PlasmicHeadContext } from \"./PlasmicHead\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext = React.createContext<\n PlasmicRootContextValue | undefined\n>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n Head?: React.ComponentType<any>;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const { platform, children } = 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. See https://docs.pl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