@itwin/appui-react 3.6.0-dev.10 → 3.6.0-dev.14
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/lib/cjs/appui-react/content/FloatingViewportContent.d.ts +6 -3
- package/lib/cjs/appui-react/content/FloatingViewportContent.d.ts.map +1 -1
- package/lib/cjs/appui-react/content/FloatingViewportContent.js +11 -8
- package/lib/cjs/appui-react/content/FloatingViewportContent.js.map +1 -1
- package/lib/esm/appui-react/content/FloatingViewportContent.d.ts +6 -3
- package/lib/esm/appui-react/content/FloatingViewportContent.d.ts.map +1 -1
- package/lib/esm/appui-react/content/FloatingViewportContent.js +11 -8
- package/lib/esm/appui-react/content/FloatingViewportContent.js.map +1 -1
- package/package.json +32 -32
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import "./FloatingViewportContent.css";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import {
|
|
6
|
+
import { ScreenViewport } from "@itwin/core-frontend";
|
|
7
|
+
import { ViewStateProp } from "@itwin/imodel-components-react";
|
|
7
8
|
/**
|
|
8
9
|
* @beta
|
|
9
10
|
*/
|
|
@@ -12,8 +13,10 @@ export interface FloatingViewportContentProps {
|
|
|
12
13
|
onContextMenu?: (e: React.MouseEvent) => boolean;
|
|
13
14
|
/** viewport/content control uniqueId */
|
|
14
15
|
contentId: string;
|
|
15
|
-
/** The initial view state used to create the viewport */
|
|
16
|
-
initialViewState:
|
|
16
|
+
/** The initial view state used to create the viewport, or a function that returns it (will refresh when the function changes) */
|
|
17
|
+
initialViewState: ViewStateProp;
|
|
18
|
+
/** Function to get a reference to the ScreenViewport */
|
|
19
|
+
viewportRef?: React.Ref<ScreenViewport>;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
22
|
* FloatingViewportContent component that creates its own [FloatingViewportContentControl].
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingViewportContent.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/content/FloatingViewportContent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,+BAA+B,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"FloatingViewportContent.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/content/FloatingViewportContent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,+BAA+B,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAa,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAqB,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAUlF;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,wFAAwF;IACxF,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,OAAO,CAAC;IACjD,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,iIAAiI;IACjI,gBAAgB,EAAE,aAAa,CAAC;IAChC,wDAAwD;IACxD,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;CACzC;AAED;;;;;GAKG;AAEH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,eA2D1E"}
|
|
@@ -17,6 +17,7 @@ const ViewportContentControl_1 = require("./ViewportContentControl");
|
|
|
17
17
|
const ContentViewManager_1 = require("./ContentViewManager");
|
|
18
18
|
const UiShowHideManager_1 = require("../utils/UiShowHideManager");
|
|
19
19
|
const ContentLayout_1 = require("./ContentLayout");
|
|
20
|
+
const core_react_1 = require("@itwin/core-react");
|
|
20
21
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
21
22
|
const FloatingViewport = (0, presentation_components_1.viewWithUnifiedSelection)(imodel_components_react_1.ViewportComponent);
|
|
22
23
|
/**
|
|
@@ -27,10 +28,14 @@ const FloatingViewport = (0, presentation_components_1.viewWithUnifiedSelection)
|
|
|
27
28
|
*/
|
|
28
29
|
// istanbul ignore next
|
|
29
30
|
function FloatingViewportContent(props) {
|
|
30
|
-
const { contentId, initialViewState } = props;
|
|
31
|
+
const { contentId, initialViewState, viewportRef } = props;
|
|
31
32
|
const [viewport, setViewport] = React.useState();
|
|
32
33
|
const contentControl = React.useRef();
|
|
33
|
-
const
|
|
34
|
+
const viewState = React.useMemo(() => typeof initialViewState === "function" ? initialViewState() : initialViewState, [initialViewState]);
|
|
35
|
+
const ref = React.useCallback((v) => {
|
|
36
|
+
setViewport(v);
|
|
37
|
+
}, []);
|
|
38
|
+
const onViewportRef = (0, core_react_1.useRefs)(ref, ...(viewportRef ? [viewportRef] : []));
|
|
34
39
|
React.useEffect(() => {
|
|
35
40
|
if (!contentControl.current) {
|
|
36
41
|
contentControl.current = new ViewportContentControl_1.FloatingViewportContentControl(contentId, contentId, null);
|
|
@@ -43,19 +48,17 @@ function FloatingViewportContent(props) {
|
|
|
43
48
|
}
|
|
44
49
|
};
|
|
45
50
|
}, [contentId]);
|
|
46
|
-
const viewPortControl = React.useMemo(() =>
|
|
51
|
+
const viewPortControl = React.useMemo(() => React.createElement(FloatingViewport, { viewportRef: onViewportRef, imodel: viewState.iModel, viewState: viewState, onContextMenu: props.onContextMenu, controlId: contentId }), [onViewportRef, props.onContextMenu, viewState, contentId]);
|
|
47
52
|
React.useEffect(() => {
|
|
48
53
|
if (viewport && contentControl.current) {
|
|
49
54
|
contentControl.current.viewport = viewport;
|
|
50
55
|
if (null === contentControl.current.reactNode) {
|
|
51
56
|
contentControl.current.reactNode = viewPortControl;
|
|
52
57
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
contentControl.current.processViewSelectorChange(initialViewState.iModel, initialViewState.id, initialViewState, initialViewState.name);
|
|
56
|
-
}
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
59
|
+
contentControl.current.processViewSelectorChange(viewState.iModel, viewState.id, viewState, viewState.name);
|
|
57
60
|
}
|
|
58
|
-
}, [
|
|
61
|
+
}, [viewState, viewPortControl, viewport]);
|
|
59
62
|
React.useEffect(() => {
|
|
60
63
|
const onViewClose = (vp) => {
|
|
61
64
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingViewportContent.js","sourceRoot":"","sources":["../../../../src/appui-react/content/FloatingViewportContent.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yCAAuC;AACvC,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"FloatingViewportContent.js","sourceRoot":"","sources":["../../../../src/appui-react/content/FloatingViewportContent.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yCAAuC;AACvC,+BAA+B;AAC/B,wDAAiE;AACjE,4EAA0E;AAC1E,4EAAkF;AAClF,qEAA0E;AAC1E,6DAA0D;AAC1D,kEAA+D;AAC/D,mDAAiD;AACjD,kDAA4C;AAE5C,gEAAgE;AAChE,MAAM,gBAAgB,GAAG,IAAA,kDAAwB,EAAC,2CAAiB,CAAC,CAAC;AAgBrE;;;;;GAKG;AACH,uBAAuB;AACvB,SAAgB,uBAAuB,CAAC,KAAmC;IACzE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAC3D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,EAA8B,CAAC;IAC7E,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,EAA8C,CAAC;IAElF,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,gBAAgB,KAAK,UAAU,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC1I,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAA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AAO,CAAC,SAAS,EAAE;gBAC7C,cAAc,CAAC,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC;aACpD;YACD,mEAAmE;YACnE,cAAc,CAAC,OAAO,CAAC,yBAAyB,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;SAC7G;IACH,CAAC,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE3C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,WAAW,GAAG,CAAC,EAAkB,EAAE,EAAE;;YACzC,IAAI,CAAA,MAAA,cAAc,CAAC,OAAO,0CAAE,QAAQ,MAAK,EAAE,EAAE;gBAC3C,uCAAkB,CAAC,0BAA0B,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;gBACtE,cAAc,CAAC,OAAO,GAAG,SAAS,CAAC;aACpC;QACH,CAAC,CAAC;QACF,OAAO,yBAAS,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACpE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,6BAAK,WAAW,EAAE,qCAAiB,CAAC,sBAAsB,EAAE,SAAS,EAAC,4BAA4B,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE;QAChJ,oBAAC,8BAAc,IAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAI,CACzF,CACP,CAAC;AACJ,CAAC;AA3DD,0DA2DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ContentView\r\n */\r\n\r\nimport \"./FloatingViewportContent.css\";\r\nimport * as React from \"react\";\r\nimport { IModelApp, ScreenViewport } from \"@itwin/core-frontend\";\r\nimport { viewWithUnifiedSelection } from \"@itwin/presentation-components\";\r\nimport { ViewportComponent, ViewStateProp } from \"@itwin/imodel-components-react\";\r\nimport { FloatingViewportContentControl } from \"./ViewportContentControl\";\r\nimport { ContentViewManager } from \"./ContentViewManager\";\r\nimport { UiShowHideManager } from \"../utils/UiShowHideManager\";\r\nimport { ContentWrapper } from \"./ContentLayout\";\r\nimport { useRefs } from \"@itwin/core-react\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nconst FloatingViewport = viewWithUnifiedSelection(ViewportComponent);\r\n\r\n/**\r\n * @beta\r\n */\r\nexport interface FloatingViewportContentProps {\r\n /** callback used to construct context menu when user right-clicks on canvas/viewport */\r\n onContextMenu?: (e: React.MouseEvent) => boolean;\r\n /** viewport/content control uniqueId */\r\n contentId: string;\r\n /** The initial view state used to create the viewport, or a function that returns it (will refresh when the function changes) */\r\n initialViewState: ViewStateProp;\r\n /** Function to get a reference to the ScreenViewport */\r\n viewportRef?: React.Ref<ScreenViewport>;\r\n}\r\n\r\n/**\r\n * FloatingViewportContent component that creates its own [FloatingViewportContentControl].\r\n * This allows it to be recognized as an \"active\" content control so that tools operate on this\r\n * content.\r\n * @beta\r\n */\r\n// istanbul ignore next\r\nexport function FloatingViewportContent(props: FloatingViewportContentProps) { // eslint-disable-line @typescript-eslint/naming-convention\r\n const { contentId, initialViewState, viewportRef } = props;\r\n const [viewport, setViewport] = React.useState<ScreenViewport | undefined>();\r\n const contentControl = React.useRef<FloatingViewportContentControl | undefined>();\r\n\r\n const viewState = React.useMemo(() => typeof initialViewState === \"function\" ? initialViewState() : initialViewState, [initialViewState]);\r\n const ref = React.useCallback((v: ScreenViewport) => {\r\n setViewport(v);\r\n }, []);\r\n const onViewportRef = useRefs(ref, ...(viewportRef ? [viewportRef] : []));\r\n\r\n React.useEffect(() => {\r\n if (!contentControl.current) {\r\n contentControl.current = new FloatingViewportContentControl(contentId, contentId, null);\r\n ContentViewManager.addFloatingContentControl(contentControl.current);\r\n }\r\n return () => {\r\n if (contentControl.current) {\r\n ContentViewManager.dropFloatingContentControl(contentControl.current);\r\n contentControl.current = undefined;\r\n }\r\n };\r\n }, [contentId]);\r\n\r\n const viewPortControl = React.useMemo(() =>\r\n <FloatingViewport\r\n viewportRef={onViewportRef}\r\n imodel={viewState.iModel}\r\n viewState={viewState}\r\n onContextMenu={props.onContextMenu}\r\n controlId={contentId}\r\n />, [onViewportRef, props.onContextMenu, viewState, contentId]);\r\n\r\n React.useEffect(() => {\r\n if (viewport && contentControl.current) {\r\n contentControl.current.viewport = viewport;\r\n if (null === contentControl.current.reactNode) {\r\n contentControl.current.reactNode = viewPortControl;\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n contentControl.current.processViewSelectorChange(viewState.iModel, viewState.id, viewState, viewState.name);\r\n }\r\n }, [viewState, viewPortControl, viewport]);\r\n\r\n React.useEffect(() => {\r\n const onViewClose = (vp: ScreenViewport) => {\r\n if (contentControl.current?.viewport === vp) {\r\n ContentViewManager.dropFloatingContentControl(contentControl.current);\r\n contentControl.current = undefined;\r\n }\r\n };\r\n return IModelApp.viewManager.onViewClose.addListener(onViewClose);\r\n }, []);\r\n\r\n return (\r\n <div onMouseMove={UiShowHideManager.handleContentMouseMove} className=\"uifw-dialog-imodel-content\" style={{ height: \"100%\", position: \"relative\" }}>\r\n <ContentWrapper content={viewPortControl} style={{ height: \"100%\", position: \"relative\" }} />\r\n </div>\r\n );\r\n}\r\n"]}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import "./FloatingViewportContent.css";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import {
|
|
6
|
+
import { ScreenViewport } from "@itwin/core-frontend";
|
|
7
|
+
import { ViewStateProp } from "@itwin/imodel-components-react";
|
|
7
8
|
/**
|
|
8
9
|
* @beta
|
|
9
10
|
*/
|
|
@@ -12,8 +13,10 @@ export interface FloatingViewportContentProps {
|
|
|
12
13
|
onContextMenu?: (e: React.MouseEvent) => boolean;
|
|
13
14
|
/** viewport/content control uniqueId */
|
|
14
15
|
contentId: string;
|
|
15
|
-
/** The initial view state used to create the viewport */
|
|
16
|
-
initialViewState:
|
|
16
|
+
/** The initial view state used to create the viewport, or a function that returns it (will refresh when the function changes) */
|
|
17
|
+
initialViewState: ViewStateProp;
|
|
18
|
+
/** Function to get a reference to the ScreenViewport */
|
|
19
|
+
viewportRef?: React.Ref<ScreenViewport>;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
22
|
* FloatingViewportContent component that creates its own [FloatingViewportContentControl].
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingViewportContent.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/content/FloatingViewportContent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,+BAA+B,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"FloatingViewportContent.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/content/FloatingViewportContent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,+BAA+B,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAa,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAqB,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAUlF;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,wFAAwF;IACxF,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,OAAO,CAAC;IACjD,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,iIAAiI;IACjI,gBAAgB,EAAE,aAAa,CAAC;IAChC,wDAAwD;IACxD,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;CACzC;AAED;;;;;GAKG;AAEH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,eA2D1E"}
|
|
@@ -14,6 +14,7 @@ import { FloatingViewportContentControl } from "./ViewportContentControl";
|
|
|
14
14
|
import { ContentViewManager } from "./ContentViewManager";
|
|
15
15
|
import { UiShowHideManager } from "../utils/UiShowHideManager";
|
|
16
16
|
import { ContentWrapper } from "./ContentLayout";
|
|
17
|
+
import { useRefs } from "@itwin/core-react";
|
|
17
18
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
18
19
|
const FloatingViewport = viewWithUnifiedSelection(ViewportComponent);
|
|
19
20
|
/**
|
|
@@ -24,10 +25,14 @@ const FloatingViewport = viewWithUnifiedSelection(ViewportComponent);
|
|
|
24
25
|
*/
|
|
25
26
|
// istanbul ignore next
|
|
26
27
|
export function FloatingViewportContent(props) {
|
|
27
|
-
const { contentId, initialViewState } = props;
|
|
28
|
+
const { contentId, initialViewState, viewportRef } = props;
|
|
28
29
|
const [viewport, setViewport] = React.useState();
|
|
29
30
|
const contentControl = React.useRef();
|
|
30
|
-
const
|
|
31
|
+
const viewState = React.useMemo(() => typeof initialViewState === "function" ? initialViewState() : initialViewState, [initialViewState]);
|
|
32
|
+
const ref = React.useCallback((v) => {
|
|
33
|
+
setViewport(v);
|
|
34
|
+
}, []);
|
|
35
|
+
const onViewportRef = useRefs(ref, ...(viewportRef ? [viewportRef] : []));
|
|
31
36
|
React.useEffect(() => {
|
|
32
37
|
if (!contentControl.current) {
|
|
33
38
|
contentControl.current = new FloatingViewportContentControl(contentId, contentId, null);
|
|
@@ -40,19 +45,17 @@ export function FloatingViewportContent(props) {
|
|
|
40
45
|
}
|
|
41
46
|
};
|
|
42
47
|
}, [contentId]);
|
|
43
|
-
const viewPortControl = React.useMemo(() =>
|
|
48
|
+
const viewPortControl = React.useMemo(() => React.createElement(FloatingViewport, { viewportRef: onViewportRef, imodel: viewState.iModel, viewState: viewState, onContextMenu: props.onContextMenu, controlId: contentId }), [onViewportRef, props.onContextMenu, viewState, contentId]);
|
|
44
49
|
React.useEffect(() => {
|
|
45
50
|
if (viewport && contentControl.current) {
|
|
46
51
|
contentControl.current.viewport = viewport;
|
|
47
52
|
if (null === contentControl.current.reactNode) {
|
|
48
53
|
contentControl.current.reactNode = viewPortControl;
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
contentControl.current.processViewSelectorChange(initialViewState.iModel, initialViewState.id, initialViewState, initialViewState.name);
|
|
53
|
-
}
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
56
|
+
contentControl.current.processViewSelectorChange(viewState.iModel, viewState.id, viewState, viewState.name);
|
|
54
57
|
}
|
|
55
|
-
}, [
|
|
58
|
+
}, [viewState, viewPortControl, viewport]);
|
|
56
59
|
React.useEffect(() => {
|
|
57
60
|
const onViewClose = (vp) => {
|
|
58
61
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingViewportContent.js","sourceRoot":"","sources":["../../../../src/appui-react/content/FloatingViewportContent.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,+BAA+B,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"FloatingViewportContent.js","sourceRoot":"","sources":["../../../../src/appui-react/content/FloatingViewportContent.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,+BAA+B,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAkB,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAiB,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE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CAAC,EAAkB,EAAE,EAAE;;YACzC,IAAI,CAAA,MAAA,cAAc,CAAC,OAAO,0CAAE,QAAQ,MAAK,EAAE,EAAE;gBAC3C,kBAAkB,CAAC,0BAA0B,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;gBACtE,cAAc,CAAC,OAAO,GAAG,SAAS,CAAC;aACpC;QACH,CAAC,CAAC;QACF,OAAO,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACpE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,6BAAK,WAAW,EAAE,iBAAiB,CAAC,sBAAsB,EAAE,SAAS,EAAC,4BAA4B,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE;QAChJ,oBAAC,cAAc,IAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAI,CACzF,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ContentView\r\n */\r\n\r\nimport \"./FloatingViewportContent.css\";\r\nimport * as React from \"react\";\r\nimport { IModelApp, ScreenViewport } from \"@itwin/core-frontend\";\r\nimport { viewWithUnifiedSelection } from \"@itwin/presentation-components\";\r\nimport { ViewportComponent, ViewStateProp } from \"@itwin/imodel-components-react\";\r\nimport { FloatingViewportContentControl } from \"./ViewportContentControl\";\r\nimport { ContentViewManager } from \"./ContentViewManager\";\r\nimport { UiShowHideManager } from \"../utils/UiShowHideManager\";\r\nimport { ContentWrapper } from \"./ContentLayout\";\r\nimport { useRefs } from \"@itwin/core-react\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nconst FloatingViewport = viewWithUnifiedSelection(ViewportComponent);\r\n\r\n/**\r\n * @beta\r\n */\r\nexport interface FloatingViewportContentProps {\r\n /** callback used to construct context menu when user right-clicks on canvas/viewport */\r\n onContextMenu?: (e: React.MouseEvent) => boolean;\r\n /** viewport/content control uniqueId */\r\n contentId: string;\r\n /** The initial view state used to create the viewport, or a function that returns it (will refresh when the function changes) */\r\n initialViewState: ViewStateProp;\r\n /** Function to get a reference to the ScreenViewport */\r\n viewportRef?: React.Ref<ScreenViewport>;\r\n}\r\n\r\n/**\r\n * FloatingViewportContent component that creates its own [FloatingViewportContentControl].\r\n * This allows it to be recognized as an \"active\" content control so that tools operate on this\r\n * content.\r\n * @beta\r\n */\r\n// istanbul ignore next\r\nexport function FloatingViewportContent(props: FloatingViewportContentProps) { // eslint-disable-line @typescript-eslint/naming-convention\r\n const { contentId, initialViewState, viewportRef } = props;\r\n const [viewport, setViewport] = React.useState<ScreenViewport | undefined>();\r\n const contentControl = React.useRef<FloatingViewportContentControl | undefined>();\r\n\r\n const viewState = React.useMemo(() => typeof initialViewState === \"function\" ? initialViewState() : initialViewState, [initialViewState]);\r\n const ref = React.useCallback((v: ScreenViewport) => {\r\n setViewport(v);\r\n }, []);\r\n const onViewportRef = useRefs(ref, ...(viewportRef ? [viewportRef] : []));\r\n\r\n React.useEffect(() => {\r\n if (!contentControl.current) {\r\n contentControl.current = new FloatingViewportContentControl(contentId, contentId, null);\r\n ContentViewManager.addFloatingContentControl(contentControl.current);\r\n }\r\n return () => {\r\n if (contentControl.current) {\r\n ContentViewManager.dropFloatingContentControl(contentControl.current);\r\n contentControl.current = undefined;\r\n }\r\n };\r\n }, [contentId]);\r\n\r\n const viewPortControl = React.useMemo(() =>\r\n <FloatingViewport\r\n viewportRef={onViewportRef}\r\n imodel={viewState.iModel}\r\n viewState={viewState}\r\n onContextMenu={props.onContextMenu}\r\n controlId={contentId}\r\n />, [onViewportRef, props.onContextMenu, viewState, contentId]);\r\n\r\n React.useEffect(() => {\r\n if (viewport && contentControl.current) {\r\n contentControl.current.viewport = viewport;\r\n if (null === contentControl.current.reactNode) {\r\n contentControl.current.reactNode = viewPortControl;\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n contentControl.current.processViewSelectorChange(viewState.iModel, viewState.id, viewState, viewState.name);\r\n }\r\n }, [viewState, viewPortControl, viewport]);\r\n\r\n React.useEffect(() => {\r\n const onViewClose = (vp: ScreenViewport) => {\r\n if (contentControl.current?.viewport === vp) {\r\n ContentViewManager.dropFloatingContentControl(contentControl.current);\r\n contentControl.current = undefined;\r\n }\r\n };\r\n return IModelApp.viewManager.onViewClose.addListener(onViewClose);\r\n }, []);\r\n\r\n return (\r\n <div onMouseMove={UiShowHideManager.handleContentMouseMove} className=\"uifw-dialog-imodel-content\" style={{ height: \"100%\", position: \"relative\" }}>\r\n <ContentWrapper content={viewPortControl} style={{ height: \"100%\", position: \"relative\" }} />\r\n </div>\r\n );\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/appui-react",
|
|
3
|
-
"version": "3.6.0-dev.
|
|
3
|
+
"version": "3.6.0-dev.14",
|
|
4
4
|
"description": "UI framework",
|
|
5
5
|
"main": "lib/cjs/appui-react.js",
|
|
6
6
|
"module": "lib/esm/appui-react.js",
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"url": "http://www.bentley.com"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@itwin/appui-abstract": "^3.6.0-dev.
|
|
24
|
-
"@itwin/appui-layout-react": "^3.6.0-dev.
|
|
25
|
-
"@itwin/components-react": "^3.6.0-dev.
|
|
26
|
-
"@itwin/core-bentley": "^3.6.0-dev.
|
|
27
|
-
"@itwin/core-common": "^3.6.0-dev.
|
|
28
|
-
"@itwin/core-frontend": "^3.6.0-dev.
|
|
29
|
-
"@itwin/core-geometry": "^3.6.0-dev.
|
|
30
|
-
"@itwin/core-markup": "^3.6.0-dev.
|
|
31
|
-
"@itwin/core-quantity": "^3.6.0-dev.
|
|
32
|
-
"@itwin/core-react": "^3.6.0-dev.
|
|
33
|
-
"@itwin/imodel-components-react": "^3.6.0-dev.
|
|
34
|
-
"@itwin/presentation-common": "^3.6.0-dev.
|
|
35
|
-
"@itwin/presentation-frontend": "^3.6.0-dev.
|
|
23
|
+
"@itwin/appui-abstract": "^3.6.0-dev.14",
|
|
24
|
+
"@itwin/appui-layout-react": "^3.6.0-dev.14",
|
|
25
|
+
"@itwin/components-react": "^3.6.0-dev.14",
|
|
26
|
+
"@itwin/core-bentley": "^3.6.0-dev.14",
|
|
27
|
+
"@itwin/core-common": "^3.6.0-dev.14",
|
|
28
|
+
"@itwin/core-frontend": "^3.6.0-dev.14",
|
|
29
|
+
"@itwin/core-geometry": "^3.6.0-dev.14",
|
|
30
|
+
"@itwin/core-markup": "^3.6.0-dev.14",
|
|
31
|
+
"@itwin/core-quantity": "^3.6.0-dev.14",
|
|
32
|
+
"@itwin/core-react": "^3.6.0-dev.14",
|
|
33
|
+
"@itwin/imodel-components-react": "^3.6.0-dev.14",
|
|
34
|
+
"@itwin/presentation-common": "^3.6.0-dev.14",
|
|
35
|
+
"@itwin/presentation-frontend": "^3.6.0-dev.14",
|
|
36
36
|
"react": "^17.0.0",
|
|
37
37
|
"react-dom": "^17.0.0",
|
|
38
38
|
"react-redux": "^7.2.2",
|
|
@@ -43,22 +43,22 @@
|
|
|
43
43
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
44
44
|
],
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@itwin/appui-abstract": "3.6.0-dev.
|
|
47
|
-
"@itwin/appui-layout-react": "3.6.0-dev.
|
|
48
|
-
"@itwin/build-tools": "3.6.0-dev.
|
|
49
|
-
"@itwin/components-react": "3.6.0-dev.
|
|
50
|
-
"@itwin/core-bentley": "3.6.0-dev.
|
|
51
|
-
"@itwin/core-common": "3.6.0-dev.
|
|
52
|
-
"@itwin/core-frontend": "3.6.0-dev.
|
|
53
|
-
"@itwin/core-geometry": "3.6.0-dev.
|
|
54
|
-
"@itwin/core-markup": "3.6.0-dev.
|
|
55
|
-
"@itwin/core-quantity": "3.6.0-dev.
|
|
56
|
-
"@itwin/core-react": "3.6.0-dev.
|
|
57
|
-
"@itwin/eslint-plugin": "3.6.0-dev.
|
|
58
|
-
"@itwin/imodel-components-react": "3.6.0-dev.
|
|
59
|
-
"@itwin/presentation-common": "3.6.0-dev.
|
|
60
|
-
"@itwin/presentation-frontend": "3.6.0-dev.
|
|
61
|
-
"@itwin/presentation-testing": "3.6.0-dev.
|
|
46
|
+
"@itwin/appui-abstract": "3.6.0-dev.14",
|
|
47
|
+
"@itwin/appui-layout-react": "3.6.0-dev.14",
|
|
48
|
+
"@itwin/build-tools": "3.6.0-dev.14",
|
|
49
|
+
"@itwin/components-react": "3.6.0-dev.14",
|
|
50
|
+
"@itwin/core-bentley": "3.6.0-dev.14",
|
|
51
|
+
"@itwin/core-common": "3.6.0-dev.14",
|
|
52
|
+
"@itwin/core-frontend": "3.6.0-dev.14",
|
|
53
|
+
"@itwin/core-geometry": "3.6.0-dev.14",
|
|
54
|
+
"@itwin/core-markup": "3.6.0-dev.14",
|
|
55
|
+
"@itwin/core-quantity": "3.6.0-dev.14",
|
|
56
|
+
"@itwin/core-react": "3.6.0-dev.14",
|
|
57
|
+
"@itwin/eslint-plugin": "3.6.0-dev.14",
|
|
58
|
+
"@itwin/imodel-components-react": "3.6.0-dev.14",
|
|
59
|
+
"@itwin/presentation-common": "3.6.0-dev.14",
|
|
60
|
+
"@itwin/presentation-frontend": "3.6.0-dev.14",
|
|
61
|
+
"@itwin/presentation-testing": "3.6.0-dev.14",
|
|
62
62
|
"@testing-library/react": "^12.0.0",
|
|
63
63
|
"@testing-library/react-hooks": "^7.0.2",
|
|
64
64
|
"@testing-library/user-event": "^14.4.2",
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
"dependencies": {
|
|
115
115
|
"@bentley/icons-generic": "^1.0.15",
|
|
116
116
|
"@bentley/icons-generic-webfont": "^1.0.15",
|
|
117
|
-
"@itwin/core-telemetry": "3.6.0-dev.
|
|
118
|
-
"@itwin/presentation-components": "3.6.0-dev.
|
|
117
|
+
"@itwin/core-telemetry": "3.6.0-dev.14",
|
|
118
|
+
"@itwin/presentation-components": "3.6.0-dev.14",
|
|
119
119
|
"@itwin/itwinui-css": "0.x",
|
|
120
120
|
"@itwin/itwinui-react": "~1.42.0",
|
|
121
121
|
"@itwin/itwinui-icons-react": "^1.8.0",
|