Skip to content

Commit

Permalink
Add ability to initialize Presentation with custom props (#314)
Browse files Browse the repository at this point in the history
* Add ability to supply presentation props

* rush change

* rush audit
  • Loading branch information
saskliutas authored May 24, 2024
1 parent 7189dae commit d0ae151
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/viewer-react",
"comment": "Added ability to supply custom Presentation initialization props",
"type": "minor"
}
],
"packageName": "@itwin/viewer-react"
}
44 changes: 22 additions & 22 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,7 @@ export class BaseInitializer {
yield UiFramework.initialize(undefined);

// initialize Presentation
yield Presentation.initialize({
presentation: {
activeLocale: IModelApp.localization.getLanguageList()[0],
},
});
yield Presentation.initialize(viewerOptions?.presentationProps);

// Sync selection count & active selection scope between Presentation and AppUi. Runs after the Presentation is initialized.
syncSelectionCount();
Expand Down
4 changes: 4 additions & 0 deletions packages/modules/viewer-react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import type {
XAndY,
XYAndZ,
} from "@itwin/core-geometry";
import { PresentationProps } from "@itwin/presentation-frontend";

export type Without<T1, T2> = { [P in Exclude<keyof T1, keyof T2>]?: never };
export type XOR<T1, T2> = T1 | T2 extends Record<string, unknown>
Expand Down Expand Up @@ -137,6 +138,8 @@ export interface ViewerInitializerParams extends ViewerIModelAppOptions {
additionalI18nNamespaces?: string[];
/** array of iTwin.js Extensions */
extensions?: ExtensionProvider[];
/** Props for presentation initialization */
presentationProps?: PresentationProps
}
export type RequiredViewerProps = XOR<
XOR<ConnectedViewerProps, FileViewerProps>,
Expand Down Expand Up @@ -192,6 +195,7 @@ const iTwinViewerInitializerParamSample: OptionalToUndefinedUnion<ViewerInitiali
additionalI18nNamespaces: undefined,
extensions: undefined,
userPreferences: undefined,
presentationProps: undefined,
};

export const iTwinViewerInitializerParamList = Object.keys(
Expand Down

0 comments on commit d0ae151

Please sign in to comment.