@plasmicapp/loader-react 1.0.399 → 1.0.400

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/index.d.ts CHANGED
@@ -159,7 +159,7 @@ declare class ComponentLookup {
159
159
  context: any;
160
160
  }[];
161
161
  /** Returns StyleTokensProvider if the project has style token overrides. */
162
- maybeGetStyleTokensProvider(spec: ComponentLookupSpec): any;
162
+ maybeGetStyleTokensProvider(spec: ComponentLookupSpec, styleTokenOverridesProjectId?: string): any;
163
163
  getGlobalContextsProvider(spec: ComponentLookupSpec): any;
164
164
  getRootProvider(): any;
165
165
  getCss(): AssetModule[];
@@ -581,6 +581,13 @@ export declare function PlasmicRootProvider(props: {
581
581
  * Fallback value for React.Suspense boundary
582
582
  */
583
583
  suspenseFallback?: React_2.ReactNode;
584
+ /**
585
+ * When Plasmic loads components from multiple projects, we must choose a style token overrides to use that will apply to all components under the root PlasmicComponent.
586
+ *
587
+ * If styleTokenOverridesProjectId is set, all PlasmicComponents and their subtrees will use the specified project's style token overrides.
588
+ * If styleTokenOverridesProjectId it not set, each PlasmicComponent and its subtree will use the style token overrides of the root PlasmicComponent's project.
589
+ */
590
+ styleTokenOverridesProjectId?: string;
584
591
  } & PlasmicDataSourceContextValue): React_2.JSX.Element;
585
592
 
586
593
  declare interface PlasmicRootWatcher {
package/dist/index.esm.js CHANGED
@@ -295,7 +295,8 @@ function PlasmicRootProvider(props) {
295
295
  pageQuery,
296
296
  suspenseFallback,
297
297
  disableLoadingBoundary,
298
- disableRootLoadingBoundary
298
+ disableRootLoadingBoundary,
299
+ styleTokenOverridesProjectId
299
300
  } = props;
300
301
  const loader = props.loader.__internal;
301
302
  if (prefetchedData) {
@@ -357,7 +358,8 @@ function PlasmicRootProvider(props) {
357
358
  disableLoadingBoundary: withCurrentContextValueFallback(
358
359
  disableLoadingBoundary,
359
360
  "disableLoadingBoundary"
360
- )
361
+ ),
362
+ styleTokenOverridesProjectId
361
363
  };
362
364
  }, [
363
365
  globalVariants,
@@ -374,6 +376,7 @@ function PlasmicRootProvider(props) {
374
376
  authRedirectUri,
375
377
  suspenseFallback,
376
378
  disableLoadingBoundary,
379
+ styleTokenOverridesProjectId,
377
380
  currentContextValue
378
381
  ]);
379
382
  React2.useEffect(() => {
@@ -706,9 +709,24 @@ var ComponentLookup = class {
706
709
  }));
707
710
  }
708
711
  /** Returns StyleTokensProvider if the project has style token overrides. */
709
- maybeGetStyleTokensProvider(spec) {
712
+ maybeGetStyleTokensProvider(spec, styleTokenOverridesProjectId) {
710
713
  const compMeta = getFirstCompMeta(this.bundle.components, spec);
711
- const projectMeta = compMeta ? this.bundle.projects.find((x) => x.id === compMeta.projectId) : void 0;
714
+ let projectMeta;
715
+ if (styleTokenOverridesProjectId) {
716
+ projectMeta = this.bundle.projects.find(
717
+ (x) => x.id === styleTokenOverridesProjectId
718
+ );
719
+ if (!projectMeta) {
720
+ console.warn(
721
+ `styleTokenOverridesProjectId "${styleTokenOverridesProjectId}" not found. Defaulting to root component's project.`
722
+ );
723
+ }
724
+ }
725
+ if (!projectMeta && (compMeta == null ? void 0 : compMeta.projectId)) {
726
+ projectMeta = this.bundle.projects.find(
727
+ (x) => x.id === compMeta.projectId
728
+ );
729
+ }
712
730
  if (!projectMeta || !projectMeta.styleTokensProviderFileName || !this.registry.hasModule(projectMeta.styleTokensProviderFileName) || !projectMeta.hasStyleTokenOverrides) {
713
731
  return void 0;
714
732
  }
@@ -1365,10 +1383,13 @@ function PlasmicComponent(props) {
1365
1383
  if (isRootLoader) {
1366
1384
  const lookup = loader.getLookup();
1367
1385
  const ReactWebRootProvider = lookup.getRootProvider();
1368
- const StyleTokensProvider = lookup.maybeGetStyleTokensProvider({
1369
- name: component,
1370
- projectId
1371
- });
1386
+ const StyleTokensProvider = lookup.maybeGetStyleTokensProvider(
1387
+ {
1388
+ name: component,
1389
+ projectId
1390
+ },
1391
+ rootContext.styleTokenOverridesProjectId
1392
+ );
1372
1393
  const GlobalContextsProvider = lookup.getGlobalContextsProvider({
1373
1394
  name: component,
1374
1395
  projectId