@plasmicapp/react-web 1.0.5 → 1.0.7

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 CHANGED
@@ -12158,7 +12158,7 @@ interface Defaultable<Ctx extends any[], T> {
12158
12158
  /**
12159
12159
  * Default value to set for this prop when the component is instantiated
12160
12160
  */
12161
- defaultValue?: T;
12161
+ defaultValue?: T | ContextDependentConfig<Ctx, T | undefined>;
12162
12162
  /**
12163
12163
  * Specify that default when no prop/param is provided,
12164
12164
  * so the Plasmic user can see it in the studio UI
@@ -12974,8 +12974,14 @@ interface SimplifiedField {
12974
12974
  type PartialParams<P extends any[]> = {
12975
12975
  [K in keyof P]: P[K] | undefined;
12976
12976
  };
12977
+ interface FunctionControlExtras {
12978
+ path: (string | number)[];
12979
+ item?: any;
12980
+ mode?: "query" | "mutation";
12981
+ }
12977
12982
  type FunctionControlContext<P extends any[]> = GenericContext<PartialParams<P>, // Function params, each may be undefined
12978
- any>;
12983
+ any, // Data from fnContext
12984
+ FunctionControlExtras>;
12979
12985
  type FunctionContextConfig<P extends any[], R> = ContextDependentConfig<FunctionControlContext<P>, R>;
12980
12986
  interface TypeBaseDefault<Ctx extends any[], T> extends CommonTypeBase, Defaultable<Ctx, T> {
12981
12987
  displayName?: string;
@@ -13751,6 +13757,63 @@ interface PlasmicRootProviderProps extends PlasmicDataSourceContextValue {
13751
13757
  disableLoadingBoundary?: boolean;
13752
13758
  suspenseFallback?: React$1.ReactNode;
13753
13759
  }
13760
+ /**
13761
+ * PlasmicRootProvider sets up the React context that Plasmic-generated components
13762
+ * rely on including data sources, i18n, Head, and Link.
13763
+ *
13764
+ * In Next.js app router, props passed from a Server to a Client Components must be serializable
13765
+ * but several PlasmicRootProvider props are not (e.g. `loader`, `Link` from `next/link`).
13766
+ * We recommend defining a Client Component wrapper (`ClientPlasmicRootProvider` in
13767
+ * `plasmic-init-client.tsx`) that imports non-serializable values and passes them to
13768
+ * PlasmicRootProvider (and only accepts serializable props from its caller).
13769
+ *
13770
+ * Loader example:
13771
+ *
13772
+ * ```tsx
13773
+ * // plasmic-init-client.tsx
13774
+ * "use client";
13775
+ * import { PlasmicRootProvider } from "@plasmicapp/loader-nextjs";
13776
+ * import { PLASMIC } from "@/plasmic-init";
13777
+ * export function ClientPlasmicRootProvider(
13778
+ * props: Omit<React.ComponentProps<typeof PlasmicRootProvider>, "loader">
13779
+ * ) {
13780
+ * return <PlasmicRootProvider loader={PLASMIC} {...props} />;
13781
+ * }
13782
+ * ```
13783
+ *
13784
+ * Codegen example:
13785
+ *
13786
+ * ```tsx
13787
+ * // plasmic-init-client.tsx
13788
+ * "use client";
13789
+ * import { PlasmicRootProvider } from "@plasmicapp/react-web";
13790
+ * import Link from "next/link";
13791
+ * export function ClientPlasmicRootProvider(
13792
+ * props: Omit<React.ComponentProps<typeof PlasmicRootProvider>, "Link">
13793
+ * ) {
13794
+ * return <PlasmicRootProvider Link={Link} {...props} />;
13795
+ * }
13796
+ * ```
13797
+ *
13798
+ * A Server Component can then render `ClientPlasmicRootProvider` and pass
13799
+ * serializable props such as prefetched data and children:
13800
+ *
13801
+ * ```tsx
13802
+ * import { PLASMIC } from "@/plasmic-init";
13803
+ * import { ClientPlasmicRootProvider } from "@/plasmic-init-client";
13804
+ * export default async function MyPage() {
13805
+ * const prefetchedData = await PLASMIC.fetchComponentData("YourPage");
13806
+ * return (
13807
+ * <ClientPlasmicRootProvider prefetchedData={prefetchedData}>
13808
+ * {yourContent()}
13809
+ * </ClientPlasmicRootProvider>
13810
+ * );
13811
+ * }
13812
+ * ```
13813
+ *
13814
+ * See https://nextjs.org/docs/app/getting-started/server-and-client-components#passing-data-from-server-to-client-components
13815
+ * for more on the Server/Client Component boundary.
13816
+ */
13754
13817
  declare function PlasmicRootProvider(props: PlasmicRootProviderProps): React$1.JSX.Element;
13755
13818
  declare const useIsSSR: typeof useIsSSR$1;
13756
13819
 
package/dist/index.cjs.js CHANGED
@@ -1795,6 +1795,63 @@ function createUseScreenVariants(isMulti, screenQueries) {
1795
1795
  }
1796
1796
 
1797
1797
  var PlasmicRootContext = React__namespace.createContext(undefined);
1798
+ /**
1799
+ * PlasmicRootProvider sets up the React context that Plasmic-generated components
1800
+ * rely on including data sources, i18n, Head, and Link.
1801
+ *
1802
+ * In Next.js app router, props passed from a Server to a Client Components must be serializable
1803
+ * but several PlasmicRootProvider props are not (e.g. `loader`, `Link` from `next/link`).
1804
+ * We recommend defining a Client Component wrapper (`ClientPlasmicRootProvider` in
1805
+ * `plasmic-init-client.tsx`) that imports non-serializable values and passes them to
1806
+ * PlasmicRootProvider (and only accepts serializable props from its caller).
1807
+ *
1808
+ * Loader example:
1809
+ *
1810
+ * ```tsx
1811
+ * // plasmic-init-client.tsx
1812
+ * "use client";
1813
+ * import { PlasmicRootProvider } from "@plasmicapp/loader-nextjs";
1814
+ * import { PLASMIC } from "@/plasmic-init";
1815
+ * export function ClientPlasmicRootProvider(
1816
+ * props: Omit<React.ComponentProps<typeof PlasmicRootProvider>, "loader">
1817
+ * ) {
1818
+ * return <PlasmicRootProvider loader={PLASMIC} {...props} />;
1819
+ * }
1820
+ * ```
1821
+ *
1822
+ * Codegen example:
1823
+ *
1824
+ * ```tsx
1825
+ * // plasmic-init-client.tsx
1826
+ * "use client";
1827
+ * import { PlasmicRootProvider } from "@plasmicapp/react-web";
1828
+ * import Link from "next/link";
1829
+ * export function ClientPlasmicRootProvider(
1830
+ * props: Omit<React.ComponentProps<typeof PlasmicRootProvider>, "Link">
1831
+ * ) {
1832
+ * return <PlasmicRootProvider Link={Link} {...props} />;
1833
+ * }
1834
+ * ```
1835
+ *
1836
+ * A Server Component can then render `ClientPlasmicRootProvider` and pass
1837
+ * serializable props such as prefetched data and children:
1838
+ *
1839
+ * ```tsx
1840
+ * import { PLASMIC } from "@/plasmic-init";
1841
+ * import { ClientPlasmicRootProvider } from "@/plasmic-init-client";
1842
+ * export default async function MyPage() {
1843
+ * const prefetchedData = await PLASMIC.fetchComponentData("YourPage");
1844
+ * return (
1845
+ * <ClientPlasmicRootProvider prefetchedData={prefetchedData}>
1846
+ * {yourContent()}
1847
+ * </ClientPlasmicRootProvider>
1848
+ * );
1849
+ * }
1850
+ * ```
1851
+ *
1852
+ * See https://nextjs.org/docs/app/getting-started/server-and-client-components#passing-data-from-server-to-client-components
1853
+ * for more on the Server/Client Component boundary.
1854
+ */
1798
1855
  function PlasmicRootProvider(props) {
1799
1856
  var _a;
1800
1857
  var platform = props.platform, children = props.children, userAuthToken = props.userAuthToken, isUserLoading = props.isUserLoading, authRedirectUri = props.authRedirectUri, user = props.user, disableLoadingBoundary = props.disableLoadingBoundary, suspenseFallback = props.suspenseFallback;