@itwin/appui-react 5.11.2 → 5.12.0
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/CHANGELOG.md +100 -0
- package/lib/appui-react/hooks/useActiveToolId.d.ts +4 -2
- package/lib/appui-react/hooks/useActiveToolId.d.ts.map +1 -1
- package/lib/appui-react/hooks/useActiveToolId.js +6 -10
- package/lib/appui-react/hooks/useActiveToolId.js.map +1 -1
- package/lib/appui-react/layout/widget/NavigationArea.d.ts +1 -0
- package/lib/appui-react/layout/widget/NavigationArea.d.ts.map +1 -1
- package/lib/appui-react/layout/widget/NavigationArea.js +1 -1
- package/lib/appui-react/layout/widget/NavigationArea.js.map +1 -1
- package/lib/appui-react/layout/widget/ToolsArea.d.ts +1 -0
- package/lib/appui-react/layout/widget/ToolsArea.d.ts.map +1 -1
- package/lib/appui-react/layout/widget/ToolsArea.js +1 -1
- package/lib/appui-react/layout/widget/ToolsArea.js.map +1 -1
- package/lib/appui-react/toolbar/ToolbarComposer.d.ts +8 -2
- package/lib/appui-react/toolbar/ToolbarComposer.d.ts.map +1 -1
- package/lib/appui-react/toolbar/ToolbarComposer.js +49 -17
- package/lib/appui-react/toolbar/ToolbarComposer.js.map +1 -1
- package/lib/appui-react/widget-panels/ToolSettings.js +1 -1
- package/lib/appui-react/widget-panels/ToolSettings.js.map +1 -1
- package/lib/appui-react/widgets/BasicNavigationWidget.d.ts.map +1 -1
- package/lib/appui-react/widgets/BasicNavigationWidget.js +1 -5
- package/lib/appui-react/widgets/BasicNavigationWidget.js.map +1 -1
- package/lib/appui-react/widgets/BasicToolWidget.d.ts.map +1 -1
- package/lib/appui-react/widgets/BasicToolWidget.js +3 -5
- package/lib/appui-react/widgets/BasicToolWidget.js.map +1 -1
- package/lib/appui-react/widgets/ContentToolWidgetComposer.d.ts.map +1 -1
- package/lib/appui-react/widgets/ContentToolWidgetComposer.js +1 -6
- package/lib/appui-react/widgets/ContentToolWidgetComposer.js.map +1 -1
- package/lib/appui-react/widgets/NavigationWidgetComposer.d.ts.map +1 -1
- package/lib/appui-react/widgets/NavigationWidgetComposer.js +3 -1
- package/lib/appui-react/widgets/NavigationWidgetComposer.js.map +1 -1
- package/lib/appui-react/widgets/ToolWidgetComposer.d.ts.map +1 -1
- package/lib/appui-react/widgets/ToolWidgetComposer.js +3 -1
- package/lib/appui-react/widgets/ToolWidgetComposer.js.map +1 -1
- package/lib/appui-react/widgets/ViewToolWidgetComposer.d.ts.map +1 -1
- package/lib/appui-react/widgets/ViewToolWidgetComposer.js +1 -5
- package/lib/appui-react/widgets/ViewToolWidgetComposer.js.map +1 -1
- package/lib/appui-react.d.ts +1 -0
- package/lib/appui-react.d.ts.map +1 -1
- package/lib/appui-react.js +1 -0
- package/lib/appui-react.js.map +1 -1
- package/package.json +7 -7
- package/lib/appui-react/toolbar/useActiveToolIdSynchedItems.d.ts +0 -25
- package/lib/appui-react/toolbar/useActiveToolIdSynchedItems.d.ts.map +0 -1
- package/lib/appui-react/toolbar/useActiveToolIdSynchedItems.js +0 -47
- package/lib/appui-react/toolbar/useActiveToolIdSynchedItems.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,105 @@
|
|
|
1
1
|
# Change Log - @itwin/appui-react
|
|
2
2
|
|
|
3
|
+
## 5.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 46df665: Added `activeItemIds` prop to `ToolbarComposer` component. When specified, it overrides the default behavior where the active toolbar item is determined by the active `Tool`.
|
|
8
|
+
|
|
9
|
+
This change enables the toolbars to display the items without the `Tool` system and to display multiple items as active:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
<ToolbarComposer
|
|
13
|
+
items={[
|
|
14
|
+
ToolbarItemUtilities.createActionItem({ id: "item1" }),
|
|
15
|
+
ToolbarItemUtilities.createActionItem({ id: "item2" }),
|
|
16
|
+
ToolbarItemUtilities.createActionItem({ id: "item3" }),
|
|
17
|
+
]}
|
|
18
|
+
activeItemIds={["item1", "item3"]}
|
|
19
|
+
/>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
To continue using the default behavior where the `Tool` determines the active toolbar item, but still display additional toolbar items as active, you can combine the `activeItemIds` prop with the `useActiveToolId` hook.
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
const activeToolId = useActiveToolId();
|
|
26
|
+
|
|
27
|
+
// Filter our undefined values and ensure type safety.
|
|
28
|
+
const activeItemIds = [activeToolId, "item1"].filter(
|
|
29
|
+
(id): id is string => id !== undefined
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
<ToolbarComposer
|
|
33
|
+
items={[
|
|
34
|
+
ToolbarItemUtilities.createActionItem({ id: "item1" }),
|
|
35
|
+
ToolbarItemUtilities.createForTool(SelectionTool),
|
|
36
|
+
]}
|
|
37
|
+
activeItemIds={activeItemIds}
|
|
38
|
+
/>;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`ToolbarComposer` component might be used indirectly, since it is rendered by `BasicNavigationWidget`, `BasicToolWidget`, `ContentToolWidgetComposer` and `ViewToolWidgetComposer` components. In that case use the underlying `ToolWidgetComposer` or `NavigationWidgetComposer` component to compose and configure the toolbars.
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
// Before
|
|
45
|
+
<ContentToolWidgetComposer cornerButton={props.cornerButton} />;
|
|
46
|
+
|
|
47
|
+
// After
|
|
48
|
+
const activeItemIds = ["item1", "item2"];
|
|
49
|
+
<ToolWidgetComposer
|
|
50
|
+
cornerItem={props.cornerButton}
|
|
51
|
+
horizontalToolbar={
|
|
52
|
+
<ToolbarComposer
|
|
53
|
+
items={[]}
|
|
54
|
+
usage={ToolbarUsage.ContentManipulation}
|
|
55
|
+
orientation={ToolbarOrientation.Horizontal}
|
|
56
|
+
activeItemIds={activeItemIds}
|
|
57
|
+
/>
|
|
58
|
+
}
|
|
59
|
+
verticalToolbar={
|
|
60
|
+
<ToolbarComposer
|
|
61
|
+
items={[]}
|
|
62
|
+
usage={ToolbarUsage.ContentManipulation}
|
|
63
|
+
orientation={ToolbarOrientation.Vertical}
|
|
64
|
+
activeItemIds={activeItemIds}
|
|
65
|
+
/>
|
|
66
|
+
}
|
|
67
|
+
/>;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Similarly, the `contentManipulation` and `viewNavigation` widgets might need to be configured when the `FrontstageUtilities` is used to create a standard `Frontstage`.
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
function ContentManipulationWidget() {
|
|
74
|
+
return (
|
|
75
|
+
<ToolWidgetComposer
|
|
76
|
+
// ...
|
|
77
|
+
activeItemIds={["item1", "item3"]}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const frontstage: Frontstage = {
|
|
83
|
+
...FrontstageUtilities.createStandardFrontstage({
|
|
84
|
+
// ...
|
|
85
|
+
}),
|
|
86
|
+
contentManipulation: {
|
|
87
|
+
id: "content-manipulation",
|
|
88
|
+
content: <ContentManipulationWidget />,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- 46df665: Added `useActiveToolId` hook to track the active `Tool` id of the `IModelApp.toolAdmin`.
|
|
94
|
+
- 46df665: Updated `NavigationWidgetComposer` and `ToolWidgetComposer` to support hidden UI visibility setting controlled via the `UiFramework.visibility` object.
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- Updated dependencies [d4db451]
|
|
99
|
+
- @itwin/imodel-components-react@5.12.0
|
|
100
|
+
- @itwin/components-react@5.12.0
|
|
101
|
+
- @itwin/core-react@5.12.0
|
|
102
|
+
|
|
3
103
|
## 5.11.2
|
|
4
104
|
|
|
5
105
|
### Patch Changes
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Hooks
|
|
3
3
|
*/
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/** React hook that maintains the active `Tool` id.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare function useActiveToolId(): string | undefined;
|
|
6
8
|
//# sourceMappingURL=useActiveToolId.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActiveToolId.d.ts","sourceRoot":"","sources":["../../../src/appui-react/hooks/useActiveToolId.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"useActiveToolId.d.ts","sourceRoot":"","sources":["../../../src/appui-react/hooks/useActiveToolId.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,eAAe,uBAG9B"}
|
|
@@ -5,16 +5,12 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Hooks
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { useActiveTool } from "./useActiveTool.js";
|
|
9
|
+
/** React hook that maintains the active `Tool` id.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
11
12
|
export function useActiveToolId() {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
return UiFramework.frontstages.onToolActivatedEvent.addListener((args) => {
|
|
15
|
-
setToolId(args.toolId);
|
|
16
|
-
});
|
|
17
|
-
}, []);
|
|
18
|
-
return toolId;
|
|
13
|
+
const activeTool = useActiveTool();
|
|
14
|
+
return activeTool?.toolId;
|
|
19
15
|
}
|
|
20
16
|
//# sourceMappingURL=useActiveToolId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActiveToolId.js","sourceRoot":"","sources":["../../../src/appui-react/hooks/useActiveToolId.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"useActiveToolId.js","sourceRoot":"","sources":["../../../src/appui-react/hooks/useActiveToolId.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,OAAO,UAAU,EAAE,MAAM,CAAC;AAC5B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Hooks\n */\n\nimport { useActiveTool } from \"./useActiveTool.js\";\n\n/** React hook that maintains the active `Tool` id.\n * @public\n */\nexport function useActiveToolId() {\n const activeTool = useActiveTool();\n return activeTool?.toolId;\n}\n"]}
|
|
@@ -21,6 +21,7 @@ export interface NavigationAreaProps extends CommonProps, NoChildrenProps {
|
|
|
21
21
|
onMouseEnter?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
22
22
|
/** Handler for mouse leave */
|
|
23
23
|
onMouseLeave?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
24
|
+
hidden?: boolean;
|
|
24
25
|
}
|
|
25
26
|
/** A component that renders toolbars in the top right corner of standard layout.
|
|
26
27
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationArea.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/layout/widget/NavigationArea.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;GAEG;AAEH,MAAM,WAAW,mBAAoB,SAAQ,WAAW,EAAE,eAAe;IACvE;;;OAGG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC,0CAA0C;IAC1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
|
|
@@ -12,7 +12,7 @@ import * as React from "react";
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
export function NavigationArea(props) {
|
|
15
|
-
const className = classnames("nz-widget-navigationArea", props.className);
|
|
15
|
+
const className = classnames("nz-widget-navigationArea", props.hidden && "nz-hidden", props.className);
|
|
16
16
|
return (React.createElement("div", { className: className, style: props.style },
|
|
17
17
|
React.createElement("div", { className: "nz-horizontal-toolbar-container", onMouseEnter: props.onMouseEnter, onMouseLeave: props.onMouseLeave }, props.horizontalToolbar),
|
|
18
18
|
props.navigationAid && (React.createElement("div", { className: "nz-navigation-aid-container", onMouseEnter: props.onMouseEnter, onMouseLeave: props.onMouseLeave }, props.navigationAid)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationArea.js","sourceRoot":"","sources":["../../../../src/appui-react/layout/widget/NavigationArea.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"NavigationArea.js","sourceRoot":"","sources":["../../../../src/appui-react/layout/widget/NavigationArea.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAwB/B;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,SAAS,GAAG,UAAU,CAC1B,0BAA0B,EAC1B,KAAK,CAAC,MAAM,IAAI,WAAW,EAC3B,KAAK,CAAC,SAAS,CAChB,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK;QAC3C,6BACE,SAAS,EAAC,iCAAiC,EAC3C,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,YAAY,EAAE,KAAK,CAAC,YAAY,IAE/B,KAAK,CAAC,iBAAiB,CACpB;QACL,KAAK,CAAC,aAAa,IAAI,CACtB,6BACE,SAAS,EAAC,6BAA6B,EACvC,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,YAAY,EAAE,KAAK,CAAC,YAAY,IAE/B,KAAK,CAAC,aAAa,CAChB,CACP;QACD,6BACE,SAAS,EAAE,UAAU,CACnB,+BAA+B,EAC/B,CAAC,KAAK,CAAC,aAAa,IAAI,SAAS,CAClC,EACD,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,YAAY,EAAE,KAAK,CAAC,YAAY,IAE/B,KAAK,CAAC,eAAe,CAClB,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Widget\n */\n\nimport \"./NavigationArea.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps, NoChildrenProps } from \"@itwin/core-react\";\n\n/** Properties of [[NavigationArea]] component.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface NavigationAreaProps extends CommonProps, NoChildrenProps {\n /**\n * Button displayed between horizontal and vertical toolbars.\n * I.e. [[AppButton]] in NavigationArea zone or navigation aid control in Navigation zone.\n */\n navigationAid?: React.ReactNode;\n /** Horizontal toolbar. See [[Toolbar]] */\n horizontalToolbar?: React.ReactNode;\n /** Vertical toolbar. See [[Toolbar]] */\n verticalToolbar?: React.ReactNode;\n /** Handler for mouse enter */\n onMouseEnter?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Handler for mouse leave */\n onMouseLeave?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n hidden?: boolean;\n}\n\n/** A component that renders toolbars in the top right corner of standard layout.\n * @internal\n */\nexport function NavigationArea(props: NavigationAreaProps) {\n const className = classnames(\n \"nz-widget-navigationArea\",\n props.hidden && \"nz-hidden\",\n props.className\n );\n return (\n <div className={className} style={props.style}>\n <div\n className=\"nz-horizontal-toolbar-container\"\n onMouseEnter={props.onMouseEnter}\n onMouseLeave={props.onMouseLeave}\n >\n {props.horizontalToolbar}\n </div>\n {props.navigationAid && (\n <div\n className=\"nz-navigation-aid-container\"\n onMouseEnter={props.onMouseEnter}\n onMouseLeave={props.onMouseLeave}\n >\n {props.navigationAid}\n </div>\n )}\n <div\n className={classnames(\n \"nz-vertical-toolbar-container\",\n !props.navigationAid && \"nz-span\"\n )}\n onMouseEnter={props.onMouseEnter}\n onMouseLeave={props.onMouseLeave}\n >\n {props.verticalToolbar}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -21,6 +21,7 @@ export interface ToolsAreaProps extends CommonProps, NoChildrenProps {
|
|
|
21
21
|
onMouseEnter?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
22
22
|
/** Handler for mouse leave */
|
|
23
23
|
onMouseLeave?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
24
|
+
hidden?: boolean;
|
|
24
25
|
}
|
|
25
26
|
/** A component that renders toolbars in the top left corner of standard layout.
|
|
26
27
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolsArea.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/layout/widget/ToolsArea.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGtE;;GAEG;AAEH,MAAM,WAAW,cAAe,SAAQ,WAAW,EAAE,eAAe;IAClE;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC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,CAAC,cAAc,CAAC;IAChD,MAAM;CAuCvB"}
|
|
@@ -16,7 +16,7 @@ export class ToolsArea extends React.PureComponent {
|
|
|
16
16
|
const button = React.isValidElement(this.props.button)
|
|
17
17
|
? React.cloneElement(this.props.button, { small: true })
|
|
18
18
|
: null; // ensure button is small
|
|
19
|
-
const className = classnames("nz-tools-widget", this.props.className);
|
|
19
|
+
const className = classnames("nz-tools-widget", this.props.hidden && "nz-hidden", this.props.className);
|
|
20
20
|
return (React.createElement("div", { className: className, style: this.props.style },
|
|
21
21
|
React.createElement("div", { className: "nz-app-button", onMouseEnter: this.props.onMouseEnter, onMouseLeave: this.props.onMouseLeave }, button),
|
|
22
22
|
React.createElement("div", { className: classnames("nz-vertical-toolbar-container", !button && "nz-span"), onMouseEnter: this.props.onMouseEnter, onMouseLeave: this.props.onMouseLeave }, this.props.verticalToolbar),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolsArea.js","sourceRoot":"","sources":["../../../../src/appui-react/layout/widget/ToolsArea.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ToolsArea.js","sourceRoot":"","sources":["../../../../src/appui-react/layout/widget/ToolsArea.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAyB/B;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK,CAAC,aAA6B;IAChD,MAAM;QACpB,MAAM,MAAM,GAAG,KAAK,CAAC,cAAc,CAAqB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;YACxE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACxD,CAAC,CAAC,IAAI,CAAC,CAAC,yBAAyB;QACnC,MAAM,SAAS,GAAG,UAAU,CAC1B,iBAAiB,EACjB,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,WAAW,EAChC,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,CAAC;QAEF,OAAO,CACL,6BAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;YAChD,6BACE,SAAS,EAAC,eAAe,EACzB,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EACrC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IAEpC,MAAM,CACH;YACN,6BACE,SAAS,EAAE,UAAU,CACnB,+BAA+B,EAC/B,CAAC,MAAM,IAAI,SAAS,CACrB,EACD,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EACrC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IAEpC,IAAI,CAAC,KAAK,CAAC,eAAe,CACvB;YACN,6BACE,SAAS,EAAC,iCAAiC,EAC3C,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EACrC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IAEpC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CACzB,CACF,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Widget\n */\n\nimport \"./ToolsArea.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps, NoChildrenProps } from \"@itwin/core-react\";\nimport type { ToolbarButtonProps } from \"./tools/button/Button.js\";\n\n/** Properties of [[ToolsArea]] component.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ToolsAreaProps extends CommonProps, NoChildrenProps {\n /**\n * Button displayed between horizontal and vertical toolbars.\n * I.e. [[AppButton]] in ToolsArea zone.\n */\n button?: React.ReactNode;\n /** Horizontal toolbar. See [[Toolbar]] */\n horizontalToolbar?: React.ReactNode;\n /** Vertical toolbar. See [[Toolbar]] */\n verticalToolbar?: React.ReactNode;\n /** Handler for mouse enter */\n onMouseEnter?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Handler for mouse leave */\n onMouseLeave?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n hidden?: boolean;\n}\n\n/** A component that renders toolbars in the top left corner of standard layout.\n * @internal\n */\nexport class ToolsArea extends React.PureComponent<ToolsAreaProps> {\n public override render() {\n const button = React.isValidElement<ToolbarButtonProps>(this.props.button)\n ? React.cloneElement(this.props.button, { small: true })\n : null; // ensure button is small\n const className = classnames(\n \"nz-tools-widget\",\n this.props.hidden && \"nz-hidden\",\n this.props.className\n );\n\n return (\n <div className={className} style={this.props.style}>\n <div\n className=\"nz-app-button\"\n onMouseEnter={this.props.onMouseEnter}\n onMouseLeave={this.props.onMouseLeave}\n >\n {button}\n </div>\n <div\n className={classnames(\n \"nz-vertical-toolbar-container\",\n !button && \"nz-span\"\n )}\n onMouseEnter={this.props.onMouseEnter}\n onMouseLeave={this.props.onMouseLeave}\n >\n {this.props.verticalToolbar}\n </div>\n <div\n className=\"nz-horizontal-toolbar-container\"\n onMouseEnter={this.props.onMouseEnter}\n onMouseLeave={this.props.onMouseLeave}\n >\n {this.props.horizontalToolbar}\n </div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -9,17 +9,23 @@ import { ToolbarOrientation, ToolbarUsage } from "./ToolbarItem.js";
|
|
|
9
9
|
* @deprecated in 4.17.0. Use `React.ComponentProps<typeof ToolbarComposer>`
|
|
10
10
|
*/
|
|
11
11
|
export interface ExtensibleToolbarProps {
|
|
12
|
-
/** Toolbar items. */
|
|
12
|
+
/** Toolbar items to be displayed in addition to the provided toolbar items. */
|
|
13
13
|
items: ToolbarItem[];
|
|
14
14
|
/** Toolbar usage based on which additional toolbar items are added from UI item providers. */
|
|
15
15
|
usage: ToolbarUsage;
|
|
16
16
|
/** Toolbar orientation. */
|
|
17
17
|
orientation: ToolbarOrientation;
|
|
18
|
+
/** Describes the ids of active toolbar items.
|
|
19
|
+
* By default only the toolbar item with id that matches the active `Tool` id is active.
|
|
20
|
+
*/
|
|
21
|
+
activeItemIds?: string[];
|
|
18
22
|
}
|
|
19
23
|
/**
|
|
20
24
|
* Toolbar that is populated and maintained by UI item providers.
|
|
21
|
-
* @note Overrides `isActive` property based on the active tool id.
|
|
25
|
+
* @note Overrides `isActive` property based on the active tool id, unless `activeItemIds` is specified.
|
|
22
26
|
* @public
|
|
23
27
|
*/
|
|
24
28
|
export declare function ToolbarComposer(props: ExtensibleToolbarProps): React.JSX.Element;
|
|
29
|
+
/** @internal */
|
|
30
|
+
export declare function updateActiveItems(items: ToolbarItem[], activeItemIds: string[]): ToolbarItem[];
|
|
25
31
|
//# sourceMappingURL=ToolbarComposer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarComposer.d.ts","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarComposer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAGV,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,kBAAkB,EAClB,YAAY,EACb,MAAM,kBAAkB,CAAC;AA4J1B;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC
|
|
1
|
+
{"version":3,"file":"ToolbarComposer.d.ts","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarComposer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAGV,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,kBAAkB,EAClB,YAAY,EACb,MAAM,kBAAkB,CAAC;AA4J1B;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,+EAA+E;IAC/E,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,8FAA8F;IAC9F,KAAK,EAAE,YAAY,CAAC;IACpB,2BAA2B;IAC3B,WAAW,EAAE,kBAAkB,CAAC;IAChC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;GAIG;AAEH,wBAAgB,eAAe,CAAC,KAAK,EAAE,sBAAsB,qBAwC5D;AAwBD,gBAAgB;AAChB,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAAE,EACpB,aAAa,EAAE,MAAM,EAAE,iBA0BxB"}
|
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
* @module Toolbar
|
|
7
7
|
*/
|
|
8
8
|
import * as React from "react";
|
|
9
|
-
import {
|
|
9
|
+
import { produce } from "immer";
|
|
10
|
+
import { Direction, ToolbarOpacitySetting, ToolbarPanelAlignment, } from "@itwin/components-react";
|
|
10
11
|
import { Logger, ProcessDetector } from "@itwin/core-bentley";
|
|
11
12
|
import { UiFramework } from "../UiFramework.js";
|
|
12
13
|
import { ToolbarDragInteractionContext } from "./DragInteraction.js";
|
|
13
14
|
import { isToolbarActionItem, isToolbarGroupItem, ToolbarOrientation, ToolbarUsage, } from "./ToolbarItem.js";
|
|
14
15
|
import { Toolbar } from "./Toolbar.js";
|
|
15
|
-
import { useActiveToolIdSynchedItems } from "./useActiveToolIdSynchedItems.js";
|
|
16
16
|
import { useActiveStageProvidedToolbarItems } from "./useActiveStageProvidedToolbarItems.js";
|
|
17
|
+
import { useActiveToolId } from "../hooks/useActiveToolId.js";
|
|
17
18
|
function addItemToSpecifiedParentGroup(items, groupChildren) {
|
|
18
19
|
const outItems = [];
|
|
19
20
|
for (const toolbarItem of items) {
|
|
@@ -124,36 +125,67 @@ const useSnapWidgetOpacitySetting = () => {
|
|
|
124
125
|
};
|
|
125
126
|
/**
|
|
126
127
|
* Toolbar that is populated and maintained by UI item providers.
|
|
127
|
-
* @note Overrides `isActive` property based on the active tool id.
|
|
128
|
+
* @note Overrides `isActive` property based on the active tool id, unless `activeItemIds` is specified.
|
|
128
129
|
* @public
|
|
129
130
|
*/
|
|
130
131
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
131
132
|
export function ToolbarComposer(props) {
|
|
132
|
-
const { usage, orientation } = props;
|
|
133
|
+
const { usage, orientation, activeItemIds: activeItemIdsProp } = props;
|
|
133
134
|
// process items from addon UI providers
|
|
134
135
|
const addonItems = useActiveStageProvidedToolbarItems(usage, orientation);
|
|
135
136
|
const allItems = React.useMemo(() => {
|
|
136
137
|
return combineItems(props.items, addonItems);
|
|
137
138
|
}, [props.items, addonItems]);
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
? Direction.Bottom
|
|
144
|
-
: usage === ToolbarUsage.ViewNavigation
|
|
145
|
-
? Direction.Left
|
|
146
|
-
: Direction.Right;
|
|
147
|
-
const panelAlignment = toolbarOrientation === Orientation.Horizontal &&
|
|
148
|
-
usage === ToolbarUsage.ViewNavigation
|
|
149
|
-
? ToolbarPanelAlignment.End
|
|
150
|
-
: ToolbarPanelAlignment.Start;
|
|
139
|
+
const activeToolId = useActiveToolId();
|
|
140
|
+
const activeItemIds = React.useMemo(() => activeItemIdsProp ?? (activeToolId ? [activeToolId] : []), [activeItemIdsProp, activeToolId]);
|
|
141
|
+
const items = React.useMemo(() => {
|
|
142
|
+
return updateActiveItems(allItems, activeItemIds);
|
|
143
|
+
}, [allItems, activeItemIds]);
|
|
151
144
|
const isDragEnabled = React.useContext(ToolbarDragInteractionContext);
|
|
152
145
|
const useProximityOpacity = useProximityOpacitySetting();
|
|
153
146
|
const snapWidgetOpacity = useSnapWidgetOpacitySetting();
|
|
147
|
+
const expandsTo = toExpandsTo(orientation, usage);
|
|
148
|
+
const panelAlignment = toPanelAlignment(orientation, usage);
|
|
154
149
|
return (React.createElement(Toolbar, { enableOverflow: true, expandsTo: expandsTo, panelAlignment: panelAlignment, items: items, useDragInteraction: isDragEnabled, toolbarOpacitySetting: (useProximityOpacity || snapWidgetOpacity) &&
|
|
155
150
|
!ProcessDetector.isMobileBrowser
|
|
156
151
|
? ToolbarOpacitySetting.Proximity
|
|
157
152
|
: ToolbarOpacitySetting.Defaults }));
|
|
158
153
|
}
|
|
154
|
+
function toExpandsTo(orientation, usage) {
|
|
155
|
+
if (orientation === ToolbarOrientation.Vertical) {
|
|
156
|
+
if (usage === ToolbarUsage.ViewNavigation)
|
|
157
|
+
return Direction.Left;
|
|
158
|
+
return Direction.Right;
|
|
159
|
+
}
|
|
160
|
+
return Direction.Bottom;
|
|
161
|
+
}
|
|
162
|
+
function toPanelAlignment(orientation, usage) {
|
|
163
|
+
if (orientation === ToolbarOrientation.Horizontal &&
|
|
164
|
+
usage === ToolbarUsage.ViewNavigation)
|
|
165
|
+
return ToolbarPanelAlignment.End;
|
|
166
|
+
return ToolbarPanelAlignment.Start;
|
|
167
|
+
}
|
|
168
|
+
/** @internal */
|
|
169
|
+
export function updateActiveItems(items, activeItemIds) {
|
|
170
|
+
return produce(items, (draft) => {
|
|
171
|
+
// Iterative DFS with ancestor backtracking.
|
|
172
|
+
const stack = draft.map((item) => [item, []]);
|
|
173
|
+
while (stack.length > 0) {
|
|
174
|
+
const [current, ancestors] = stack.pop();
|
|
175
|
+
const isActive = activeItemIds.includes(current.id);
|
|
176
|
+
current.isActive = isActive;
|
|
177
|
+
if ("items" in current) {
|
|
178
|
+
for (const child of current.items) {
|
|
179
|
+
stack.push([child, [...ancestors, current]]);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (!isActive)
|
|
183
|
+
continue;
|
|
184
|
+
// Mark ancestors of active item as active.
|
|
185
|
+
for (const ancestor of ancestors) {
|
|
186
|
+
ancestor.isActive = true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
159
191
|
//# sourceMappingURL=ToolbarComposer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarComposer.js","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarComposer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAMrE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAE7F,SAAS,6BAA6B,CACpC,KAAmB,EACnB,aAA0D;IAE1D,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,KAAK,MAAM,WAAW,IAAI,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC3B,SAAS;QACX,CAAC;QAED,MAAM,WAAW,GAAG,6BAA6B,CAC/C,WAAW,CAAC,KAAK,EACjB,aAAa,CACd,CAAC;QACF,MAAM,YAAY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C,KAAK,CAAC;IACtB,MAAM,cAAc,GAClB,kBAAkB,KAAK,WAAW,CAAC,UAAU;QAC7C,KAAK,KAAK,YAAY,CAAC,cAAc;QACnC,CAAC,CAAC,qBAAqB,CAAC,GAAG;QAC3B,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC;IAClC,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACtE,MAAM,mBAAmB,GAAG,0BAA0B,EAAE,CAAC;IACzD,MAAM,iBAAiB,GAAG,2BAA2B,EAAE,CAAC;IAExD,OAAO,CACL,oBAAC,OAAO,IACN,cAAc,EAAE,IAAI,EACpB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,KAAK,EACZ,kBAAkB,EAAE,aAAa,EACjC,qBAAqB,EACnB,CAAC,mBAAmB,IAAI,iBAAiB,CAAC;YAC1C,CAAC,eAAe,CAAC,eAAe;YAC9B,CAAC,CAAC,qBAAqB,CAAC,SAAS;YACjC,CAAC,CAAC,qBAAqB,CAAC,QAAQ,GAEpC,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport {\n Direction,\n Orientation,\n ToolbarOpacitySetting,\n ToolbarPanelAlignment,\n} from \"@itwin/components-react\";\nimport { Logger, ProcessDetector } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport { ToolbarDragInteractionContext } from \"./DragInteraction.js\";\nimport type {\n ToolbarActionItem,\n ToolbarGroupItem,\n ToolbarItem,\n} from \"./ToolbarItem.js\";\nimport {\n isToolbarActionItem,\n isToolbarGroupItem,\n ToolbarOrientation,\n ToolbarUsage,\n} from \"./ToolbarItem.js\";\nimport { Toolbar } from \"./Toolbar.js\";\nimport { useActiveToolIdSynchedItems } from \"./useActiveToolIdSynchedItems.js\";\nimport { useActiveStageProvidedToolbarItems } from \"./useActiveStageProvidedToolbarItems.js\";\n\nfunction addItemToSpecifiedParentGroup<T extends ToolbarItem>(\n items: readonly T[],\n groupChildren: Array<ToolbarActionItem | ToolbarGroupItem>\n): T[] {\n const outItems: T[] = [];\n for (const toolbarItem of items) {\n if (!isToolbarGroupItem(toolbarItem)) {\n outItems.push(toolbarItem);\n continue;\n }\n\n const newChildren = addItemToSpecifiedParentGroup(\n toolbarItem.items,\n groupChildren\n );\n const foundIndices: number[] = [];\n\n groupChildren.forEach((entry, index) => {\n if (entry.parentGroupItemId === toolbarItem.id) {\n foundIndices.push(index);\n }\n });\n\n if (foundIndices.length) {\n // process in reverse order so groupChildren can be reduced as we find matches\n foundIndices\n .sort((a, b) => a - b)\n .reverse()\n .forEach((foundIndex) => {\n newChildren.push(groupChildren[foundIndex]);\n groupChildren.splice(foundIndex);\n });\n }\n\n outItems.push({ ...toolbarItem, items: newChildren });\n }\n return outItems;\n}\n\nfunction cloneGroup(inGroup: ToolbarGroupItem): ToolbarGroupItem {\n const childItems: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n inGroup.items.forEach((item) => {\n if (isToolbarGroupItem(item)) childItems.push(cloneGroup(item));\n else childItems.push(item);\n });\n\n const clonedGroup = { ...inGroup, items: childItems };\n return clonedGroup;\n}\n\nfunction getItemSortValue(item: ToolbarItem) {\n const groupValue = undefined === item.groupPriority ? 0 : item.groupPriority;\n return groupValue * 10000 + item.itemPriority;\n}\n\nfunction sortItems(items: ReadonlyArray<ToolbarItem>): ToolbarItem[] {\n return [...items]\n .sort((a, b) => getItemSortValue(a) - getItemSortValue(b))\n .map((i) => {\n if (isToolbarGroupItem(i)) {\n return { ...i, items: sortItems(i.items) };\n }\n return i;\n });\n}\n\n/**\n * Create a forEach handler that will add every element of an array of ToolbarItems\n * to a list of items that can then be replaced in its proper place, ensuring that\n * the same item, from different list, is not added multiple times.\n * @param items Output list of items\n * @param groupChildren Output list of group children to redistribute.\n * @returns Array<ToolbarItem>.forEach handler.\n */\nfunction addIfNotDuplicate(\n items: ToolbarItem[],\n groupChildren: (ToolbarActionItem | ToolbarGroupItem)[]\n): (value: ToolbarItem) => void {\n return (srcItem: ToolbarItem) => {\n if (-1 === items.findIndex((item) => item.id === srcItem.id)) {\n // if the default item is a group that an addon may insert into copy it so we don't mess with original\n const toolbarItem = isToolbarGroupItem(srcItem)\n ? cloneGroup(srcItem)\n : srcItem;\n if (\n (isToolbarGroupItem(toolbarItem) || isToolbarActionItem(toolbarItem)) &&\n toolbarItem.parentGroupItemId\n )\n groupChildren.push(toolbarItem);\n else items.push(toolbarItem);\n }\n };\n}\n\n/** local function to combine items from Stage and from Extensions */\nfunction combineItems(\n defaultItems: ReadonlyArray<ToolbarItem>,\n addonItems: ReadonlyArray<ToolbarItem>\n): ToolbarItem[] {\n let items: ToolbarItem[] = [];\n const groupChildren: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n\n defaultItems.forEach(addIfNotDuplicate(items, groupChildren));\n addonItems.forEach(addIfNotDuplicate(items, groupChildren));\n\n // if an item from an addon has specified a parent group then try to find it and insert it. If no parent is found, add item at root level.\n if (groupChildren.length) {\n items = addItemToSpecifiedParentGroup(items, groupChildren);\n\n groupChildren.forEach((toolbarItem) => {\n Logger.logWarning(\n \"ToolbarComposer\",\n `Requested Parent Group [${toolbarItem.parentGroupItemId!}] not found, so item [${\n toolbarItem.id\n }] is added directly to toolbar.`\n );\n items.push(toolbarItem);\n });\n }\n\n return sortItems(items);\n}\n\nconst useProximityOpacitySetting = () => {\n const [proximityOpacity, setProximityOpacity] = React.useState(\n UiFramework.visibility.useProximityOpacity // eslint-disable-line @typescript-eslint/no-deprecated\n );\n\n React.useEffect(() => {\n UiFramework.onUiVisibilityChanged.addListener(\n () => setProximityOpacity(UiFramework.visibility.useProximityOpacity) // eslint-disable-line @typescript-eslint/no-deprecated\n );\n }, []);\n\n return proximityOpacity;\n};\n\nconst useSnapWidgetOpacitySetting = () => {\n const [snapWidgetOpacity, setSnapWidgetOpacity] = React.useState(\n UiFramework.visibility.snapWidgetOpacity\n );\n\n React.useEffect(() => {\n UiFramework.onUiVisibilityChanged.addListener(() =>\n setSnapWidgetOpacity(UiFramework.visibility.snapWidgetOpacity)\n );\n }, []);\n\n return snapWidgetOpacity;\n};\n\n/** Properties for the [[ToolbarComposer]] React components\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof ToolbarComposer>`\n */\nexport interface ExtensibleToolbarProps {\n /** Toolbar items. */\n items: ToolbarItem[];\n /** Toolbar usage based on which additional toolbar items are added from UI item providers. */\n usage: ToolbarUsage;\n /** Toolbar orientation. */\n orientation: ToolbarOrientation;\n}\n\n/**\n * Toolbar that is populated and maintained by UI item providers.\n * @note Overrides `isActive` property based on the active tool id.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function ToolbarComposer(props: ExtensibleToolbarProps) {\n const { usage, orientation } = props;\n\n // process items from addon UI providers\n const addonItems = useActiveStageProvidedToolbarItems(usage, orientation);\n\n const allItems = React.useMemo(() => {\n return combineItems(props.items, addonItems);\n }, [props.items, addonItems]);\n\n const items = useActiveToolIdSynchedItems(allItems, UiFramework.frontstages);\n\n const toolbarOrientation =\n orientation === ToolbarOrientation.Horizontal\n ? Orientation.Horizontal\n : Orientation.Vertical;\n const expandsTo =\n toolbarOrientation === Orientation.Horizontal\n ? Direction.Bottom\n : usage === ToolbarUsage.ViewNavigation\n ? Direction.Left\n : Direction.Right;\n const panelAlignment =\n toolbarOrientation === Orientation.Horizontal &&\n usage === ToolbarUsage.ViewNavigation\n ? ToolbarPanelAlignment.End\n : ToolbarPanelAlignment.Start;\n const isDragEnabled = React.useContext(ToolbarDragInteractionContext);\n const useProximityOpacity = useProximityOpacitySetting();\n const snapWidgetOpacity = useSnapWidgetOpacitySetting();\n\n return (\n <Toolbar\n enableOverflow={true}\n expandsTo={expandsTo}\n panelAlignment={panelAlignment}\n items={items}\n useDragInteraction={isDragEnabled}\n toolbarOpacitySetting={\n (useProximityOpacity || snapWidgetOpacity) &&\n !ProcessDetector.isMobileBrowser\n ? ToolbarOpacitySetting.Proximity\n : ToolbarOpacitySetting.Defaults\n }\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ToolbarComposer.js","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarComposer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAMrE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,SAAS,6BAA6B,CACpC,KAAmB,EACnB,aAA0D;IAE1D,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,KAAK,MAAM,WAAW,IAAI,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC3B,SAAS;QACX,CAAC;QAED,MAAM,WAAW,GAAG,6BAA6B,CAC/C,WAAW,CAAC,KA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AChB,MAAM,UAAU,iBAAiB,CAC/B,KAAoB,EACpB,aAAuB;IAEvB,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QAC9B,4CAA4C;QAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAkB,CAAU,CAAC,CAAC;QAEvE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,GAAG,EAAG,CAAC;YAE1C,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpD,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAE5B,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;gBACvB,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;oBAClC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC;YAED,IAAI,CAAC,QAAQ;gBAAE,SAAS;YAExB,2CAA2C;YAC3C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport { produce } from \"immer\";\nimport {\n Direction,\n ToolbarOpacitySetting,\n ToolbarPanelAlignment,\n} from \"@itwin/components-react\";\nimport { Logger, ProcessDetector } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport { ToolbarDragInteractionContext } from \"./DragInteraction.js\";\nimport type {\n ToolbarActionItem,\n ToolbarGroupItem,\n ToolbarItem,\n} from \"./ToolbarItem.js\";\nimport {\n isToolbarActionItem,\n isToolbarGroupItem,\n ToolbarOrientation,\n ToolbarUsage,\n} from \"./ToolbarItem.js\";\nimport { Toolbar } from \"./Toolbar.js\";\nimport { useActiveStageProvidedToolbarItems } from \"./useActiveStageProvidedToolbarItems.js\";\nimport { useActiveToolId } from \"../hooks/useActiveToolId.js\";\n\nfunction addItemToSpecifiedParentGroup<T extends ToolbarItem>(\n items: readonly T[],\n groupChildren: Array<ToolbarActionItem | ToolbarGroupItem>\n): T[] {\n const outItems: T[] = [];\n for (const toolbarItem of items) {\n if (!isToolbarGroupItem(toolbarItem)) {\n outItems.push(toolbarItem);\n continue;\n }\n\n const newChildren = addItemToSpecifiedParentGroup(\n toolbarItem.items,\n groupChildren\n );\n const foundIndices: number[] = [];\n\n groupChildren.forEach((entry, index) => {\n if (entry.parentGroupItemId === toolbarItem.id) {\n foundIndices.push(index);\n }\n });\n\n if (foundIndices.length) {\n // process in reverse order so groupChildren can be reduced as we find matches\n foundIndices\n .sort((a, b) => a - b)\n .reverse()\n .forEach((foundIndex) => {\n newChildren.push(groupChildren[foundIndex]);\n groupChildren.splice(foundIndex);\n });\n }\n\n outItems.push({ ...toolbarItem, items: newChildren });\n }\n return outItems;\n}\n\nfunction cloneGroup(inGroup: ToolbarGroupItem): ToolbarGroupItem {\n const childItems: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n inGroup.items.forEach((item) => {\n if (isToolbarGroupItem(item)) childItems.push(cloneGroup(item));\n else childItems.push(item);\n });\n\n const clonedGroup = { ...inGroup, items: childItems };\n return clonedGroup;\n}\n\nfunction getItemSortValue(item: ToolbarItem) {\n const groupValue = undefined === item.groupPriority ? 0 : item.groupPriority;\n return groupValue * 10000 + item.itemPriority;\n}\n\nfunction sortItems(items: ReadonlyArray<ToolbarItem>): ToolbarItem[] {\n return [...items]\n .sort((a, b) => getItemSortValue(a) - getItemSortValue(b))\n .map((i) => {\n if (isToolbarGroupItem(i)) {\n return { ...i, items: sortItems(i.items) };\n }\n return i;\n });\n}\n\n/**\n * Create a forEach handler that will add every element of an array of ToolbarItems\n * to a list of items that can then be replaced in its proper place, ensuring that\n * the same item, from different list, is not added multiple times.\n * @param items Output list of items\n * @param groupChildren Output list of group children to redistribute.\n * @returns Array<ToolbarItem>.forEach handler.\n */\nfunction addIfNotDuplicate(\n items: ToolbarItem[],\n groupChildren: (ToolbarActionItem | ToolbarGroupItem)[]\n): (value: ToolbarItem) => void {\n return (srcItem: ToolbarItem) => {\n if (-1 === items.findIndex((item) => item.id === srcItem.id)) {\n // if the default item is a group that an addon may insert into copy it so we don't mess with original\n const toolbarItem = isToolbarGroupItem(srcItem)\n ? cloneGroup(srcItem)\n : srcItem;\n if (\n (isToolbarGroupItem(toolbarItem) || isToolbarActionItem(toolbarItem)) &&\n toolbarItem.parentGroupItemId\n )\n groupChildren.push(toolbarItem);\n else items.push(toolbarItem);\n }\n };\n}\n\n/** local function to combine items from Stage and from Extensions */\nfunction combineItems(\n defaultItems: ReadonlyArray<ToolbarItem>,\n addonItems: ReadonlyArray<ToolbarItem>\n): ToolbarItem[] {\n let items: ToolbarItem[] = [];\n const groupChildren: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n\n defaultItems.forEach(addIfNotDuplicate(items, groupChildren));\n addonItems.forEach(addIfNotDuplicate(items, groupChildren));\n\n // if an item from an addon has specified a parent group then try to find it and insert it. If no parent is found, add item at root level.\n if (groupChildren.length) {\n items = addItemToSpecifiedParentGroup(items, groupChildren);\n\n groupChildren.forEach((toolbarItem) => {\n Logger.logWarning(\n \"ToolbarComposer\",\n `Requested Parent Group [${toolbarItem.parentGroupItemId!}] not found, so item [${\n toolbarItem.id\n }] is added directly to toolbar.`\n );\n items.push(toolbarItem);\n });\n }\n\n return sortItems(items);\n}\n\nconst useProximityOpacitySetting = () => {\n const [proximityOpacity, setProximityOpacity] = React.useState(\n UiFramework.visibility.useProximityOpacity // eslint-disable-line @typescript-eslint/no-deprecated\n );\n\n React.useEffect(() => {\n UiFramework.onUiVisibilityChanged.addListener(\n () => setProximityOpacity(UiFramework.visibility.useProximityOpacity) // eslint-disable-line @typescript-eslint/no-deprecated\n );\n }, []);\n\n return proximityOpacity;\n};\n\nconst useSnapWidgetOpacitySetting = () => {\n const [snapWidgetOpacity, setSnapWidgetOpacity] = React.useState(\n UiFramework.visibility.snapWidgetOpacity\n );\n\n React.useEffect(() => {\n UiFramework.onUiVisibilityChanged.addListener(() =>\n setSnapWidgetOpacity(UiFramework.visibility.snapWidgetOpacity)\n );\n }, []);\n\n return snapWidgetOpacity;\n};\n\n/** Properties for the [[ToolbarComposer]] React components\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof ToolbarComposer>`\n */\nexport interface ExtensibleToolbarProps {\n /** Toolbar items to be displayed in addition to the provided toolbar items. */\n items: ToolbarItem[];\n /** Toolbar usage based on which additional toolbar items are added from UI item providers. */\n usage: ToolbarUsage;\n /** Toolbar orientation. */\n orientation: ToolbarOrientation;\n /** Describes the ids of active toolbar items.\n * By default only the toolbar item with id that matches the active `Tool` id is active.\n */\n activeItemIds?: string[];\n}\n\n/**\n * Toolbar that is populated and maintained by UI item providers.\n * @note Overrides `isActive` property based on the active tool id, unless `activeItemIds` is specified.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function ToolbarComposer(props: ExtensibleToolbarProps) {\n const { usage, orientation, activeItemIds: activeItemIdsProp } = props;\n\n // process items from addon UI providers\n const addonItems = useActiveStageProvidedToolbarItems(usage, orientation);\n\n const allItems = React.useMemo(() => {\n return combineItems(props.items, addonItems);\n }, [props.items, addonItems]);\n\n const activeToolId = useActiveToolId();\n const activeItemIds = React.useMemo(\n () => activeItemIdsProp ?? (activeToolId ? [activeToolId] : []),\n [activeItemIdsProp, activeToolId]\n );\n const items = React.useMemo(() => {\n return updateActiveItems(allItems, activeItemIds);\n }, [allItems, activeItemIds]);\n\n const isDragEnabled = React.useContext(ToolbarDragInteractionContext);\n const useProximityOpacity = useProximityOpacitySetting();\n const snapWidgetOpacity = useSnapWidgetOpacitySetting();\n\n const expandsTo = toExpandsTo(orientation, usage);\n const panelAlignment = toPanelAlignment(orientation, usage);\n return (\n <Toolbar\n enableOverflow={true}\n expandsTo={expandsTo}\n panelAlignment={panelAlignment}\n items={items}\n useDragInteraction={isDragEnabled}\n toolbarOpacitySetting={\n (useProximityOpacity || snapWidgetOpacity) &&\n !ProcessDetector.isMobileBrowser\n ? ToolbarOpacitySetting.Proximity\n : ToolbarOpacitySetting.Defaults\n }\n />\n );\n}\n\nfunction toExpandsTo(orientation: ToolbarOrientation, usage: ToolbarUsage) {\n if (orientation === ToolbarOrientation.Vertical) {\n if (usage === ToolbarUsage.ViewNavigation) return Direction.Left;\n return Direction.Right;\n }\n\n return Direction.Bottom;\n}\n\nfunction toPanelAlignment(\n orientation: ToolbarOrientation,\n usage: ToolbarUsage\n) {\n if (\n orientation === ToolbarOrientation.Horizontal &&\n usage === ToolbarUsage.ViewNavigation\n )\n return ToolbarPanelAlignment.End;\n\n return ToolbarPanelAlignment.Start;\n}\n\n/** @internal */\nexport function updateActiveItems(\n items: ToolbarItem[],\n activeItemIds: string[]\n) {\n return produce(items, (draft) => {\n // Iterative DFS with ancestor backtracking.\n const stack = draft.map((item) => [item, [] as typeof draft] as const);\n\n while (stack.length > 0) {\n const [current, ancestors] = stack.pop()!;\n\n const isActive = activeItemIds.includes(current.id);\n current.isActive = isActive;\n\n if (\"items\" in current) {\n for (const child of current.items) {\n stack.push([child, [...ancestors, current]]);\n }\n }\n\n if (!isActive) continue;\n\n // Mark ancestors of active item as active.\n for (const ancestor of ancestors) {\n ancestor.isActive = true;\n }\n }\n });\n}\n"]}
|
|
@@ -24,7 +24,7 @@ import { ToolSettingsEditorsProvider } from "../preview/tool-settings-lock-butto
|
|
|
24
24
|
import { ToolSettingsContext } from "../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js";
|
|
25
25
|
function EmptyToolSettingsLabel({ toolId }) {
|
|
26
26
|
const { translate } = useTranslation();
|
|
27
|
-
const tool = IModelApp.tools.find(toolId);
|
|
27
|
+
const tool = toolId ? IModelApp.tools.find(toolId) : undefined;
|
|
28
28
|
const toolName = tool?.flyover;
|
|
29
29
|
return (React.createElement(Text, { as: "i", isMuted: true, className: "uifw-toolSettings-label-empty" },
|
|
30
30
|
translate("tools.noToolSettingsStart"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolSettings.js","sourceRoot":"","sources":["../../../src/appui-react/widget-panels/ToolSettings.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EA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,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI;gBACvC,oBAAC,2BAA2B,QACzB,IAAI,IAAI,aAAa,EAAE,mBAAmB,IAAI,CAC7C,oBAAC,sBAAsB,IAAC,MAAM,EAAE,YAAY,GAAI,CACjD,CAC2B,CACD,CACP,CACtB,CACP,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,gBAAqB;IAC1C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,+EAA+E;QAC/E,0BAA0B;QAC1B,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvB,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ToolSettings\n */\n\nimport * as React from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport { InternalFrontstageManager } from \"../frontstage/InternalFrontstageManager.js\";\nimport { useLayout } from \"../layout/base/LayoutStore.js\";\nimport { DockedToolSettings } from \"../layout/tool-settings/Docked.js\";\nimport { DockedToolSetting } from \"../layout/tool-settings/Setting.js\";\nimport { ScrollableWidgetContent } from \"../layout/widget/Content.js\";\nimport \"./ToolSettings.scss\";\nimport { useActiveToolId } from \"../hooks/useActiveToolId.js\";\nimport { useTranslation } from \"../hooks/useTranslation.js\";\nimport { DockedBar } from \"./DockedBar.js\";\nimport { useActiveFrontstageDef } from \"../frontstage/FrontstageDef.js\";\nimport { LockProvider } from \"../editors/LockProvider.js\";\nimport { ToolSettingsEditorsProvider } from \"../preview/tool-settings-lock-button/useToolSettingsLockButton.js\";\nimport { ToolSettingsContext } from \"../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js\";\n\n/** Defines a ToolSettings property entry.\n * @public\n */\nexport interface ToolSettingsEntry {\n // label node which potentially can contain a lock node as well.\n labelNode: React.ReactNode;\n // editor entry used to display and edit the property value\n editorNode: React.ReactNode;\n}\n\nfunction EmptyToolSettingsLabel({ toolId }: { toolId: string }) {\n const { translate } = useTranslation();\n const tool = IModelApp.tools.find(toolId);\n const toolName = tool?.flyover;\n return (\n <Text as=\"i\" isMuted={true} className=\"uifw-toolSettings-label-empty\">\n {translate(\"tools.noToolSettingsStart\")}\n {toolName || translate(\"tools.noToolSettingsPlaceholderName\")}\n {translate(\"tools.noToolSettingsEnd\")}\n </Text>\n );\n}\n\n/**\n * Hook that returns true if the tool settings should be rendered docked.\n * @internal */\nexport function useShouldRenderDockedToolSettings() {\n return useLayout((state) => {\n const toolSettings = state.toolSettings;\n if (!toolSettings || toolSettings.type === \"widget\") return false;\n return !toolSettings.hidden;\n });\n}\n\n/** @internal */\nexport function WidgetPanelsToolSettings() {\n if (!useShouldRenderDockedToolSettings()) return null;\n return <ToolSettingsDockedContent />;\n}\n\n/** @internal */\nexport function ToolSettingsDockedContent() {\n const activeToolId = useActiveToolId();\n const toolSettingEntries = useHorizontalToolSettingEntries();\n const forceRefreshKey = useRefreshKey(toolSettingEntries);\n const frontstageDef = useActiveFrontstageDef();\n\n const emptySettings = React.useMemo<ToolSettingsEntry[]>(\n () => [\n {\n editorNode: null,\n labelNode: frontstageDef?.activeToolEmptyNode ?? (\n <EmptyToolSettingsLabel toolId={activeToolId} />\n ),\n },\n ],\n [activeToolId, frontstageDef]\n );\n const entries =\n !toolSettingEntries || toolSettingEntries.length === 0\n ? emptySettings\n : toolSettingEntries;\n\n // for the overflow to work properly each setting in the DockedToolSettings should be wrapped by a DockedToolSetting component\n return (\n <DockedBar placement=\"top\">\n <ToolSettingsContext.Provider value={true}>\n <ToolSettingsEditorsProvider>\n <DockedToolSettings\n itemId={\n InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ??\n \"none\"\n }\n key={forceRefreshKey}\n >\n {entries.map((entry, index) => (\n <DockedToolSetting key={index}>\n <LockProvider>\n {entry.labelNode}\n {entry.editorNode}\n </LockProvider>\n </DockedToolSetting>\n ))}\n </DockedToolSettings>\n </ToolSettingsEditorsProvider>\n </ToolSettingsContext.Provider>\n </DockedBar>\n );\n}\n\n/** @internal */\nexport function useHorizontalToolSettingEntries() {\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n UiFramework.frontstages.activeToolInformation?.toolUiProvider?.reloadPropertiesFromTool();\n }, []);\n const [settings, setSettings] = React.useState(\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes\n );\n React.useEffect(() => {\n return UiFramework.frontstages.onToolActivatedEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes;\n setSettings(nodes);\n });\n }, []);\n\n React.useEffect(() => {\n return UiFramework.frontstages.onToolSettingsReloadEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes;\n setSettings(nodes);\n });\n }, []);\n\n return settings;\n}\n\n/** @internal */\nexport function useToolSettingsNode() {\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n UiFramework.frontstages.activeToolInformation?.toolUiProvider?.reloadPropertiesFromTool();\n }, []);\n const [settings, setSettings] = React.useState(\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode\n );\n React.useEffect(() => {\n return UiFramework.frontstages.onToolActivatedEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode;\n setSettings(nodes);\n });\n }, [setSettings]);\n\n React.useEffect(() => {\n return UiFramework.frontstages.onToolSettingsReloadEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode;\n setSettings(nodes);\n });\n }, [setSettings]);\n return settings;\n}\n\n/** @internal */\nexport function ToolSettingsContent() {\n const toolSettingsType = useLayout((state) => state.toolSettings?.type);\n // This is needed to remount underlying components tree when going into widget state.\n if (!toolSettingsType || toolSettingsType === \"docked\") return null;\n return <ToolSettingsWidgetContent />;\n}\n\n/** @internal */\nexport function ToolSettingsWidgetContent() {\n const floatingToolSettingsContainerRef = React.useRef<HTMLDivElement>(null);\n const node = useToolSettingsNode();\n const activeToolId = useActiveToolId();\n const forceRefreshKey = useRefreshKey(node);\n const frontstageDef = useActiveFrontstageDef();\n\n const providerId =\n InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ?? \"none\";\n return (\n <div\n data-toolsettings-provider={providerId}\n className=\"uifw-floating-toolSettings-container\"\n ref={floatingToolSettingsContainerRef}\n key={forceRefreshKey}\n >\n <ScrollableWidgetContent>\n <ToolSettingsContext.Provider value={true}>\n <ToolSettingsEditorsProvider>\n {node ?? frontstageDef?.activeToolEmptyNode ?? (\n <EmptyToolSettingsLabel toolId={activeToolId} />\n )}\n </ToolSettingsEditorsProvider>\n </ToolSettingsContext.Provider>\n </ScrollableWidgetContent>\n </div>\n );\n}\n\n/**\n * Hook that returns a key that can be used to force refresh the tool settings.\n * @param toolSettingNodes Nodes that are used to determine if the tool settings should be refreshed.\n * @returns a new key if the dependency changes.\n */\nfunction useRefreshKey(toolSettingNodes: any) {\n const [forceRefreshKey, setForceRefreshKey] = React.useState(Date.now());\n React.useEffect(() => {\n // We cant work with the content of the settings, but we can force refresh when\n // the array is different.\n setForceRefreshKey(Date.now());\n }, [toolSettingNodes]);\n return forceRefreshKey;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ToolSettings.js","sourceRoot":"","sources":["../../../src/appui-react/widget-panels/ToolSettings.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;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AC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvB,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ToolSettings\n */\n\nimport * as React from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport { InternalFrontstageManager } from \"../frontstage/InternalFrontstageManager.js\";\nimport { useLayout } from \"../layout/base/LayoutStore.js\";\nimport { DockedToolSettings } from \"../layout/tool-settings/Docked.js\";\nimport { DockedToolSetting } from \"../layout/tool-settings/Setting.js\";\nimport { ScrollableWidgetContent } from \"../layout/widget/Content.js\";\nimport \"./ToolSettings.scss\";\nimport { useActiveToolId } from \"../hooks/useActiveToolId.js\";\nimport { useTranslation } from \"../hooks/useTranslation.js\";\nimport { DockedBar } from \"./DockedBar.js\";\nimport { useActiveFrontstageDef } from \"../frontstage/FrontstageDef.js\";\nimport { LockProvider } from \"../editors/LockProvider.js\";\nimport { ToolSettingsEditorsProvider } from \"../preview/tool-settings-lock-button/useToolSettingsLockButton.js\";\nimport { ToolSettingsContext } from \"../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js\";\n\n/** Defines a ToolSettings property entry.\n * @public\n */\nexport interface ToolSettingsEntry {\n // label node which potentially can contain a lock node as well.\n labelNode: React.ReactNode;\n // editor entry used to display and edit the property value\n editorNode: React.ReactNode;\n}\n\nfunction EmptyToolSettingsLabel({ toolId }: { toolId?: string }) {\n const { translate } = useTranslation();\n const tool = toolId ? IModelApp.tools.find(toolId) : undefined;\n const toolName = tool?.flyover;\n return (\n <Text as=\"i\" isMuted={true} className=\"uifw-toolSettings-label-empty\">\n {translate(\"tools.noToolSettingsStart\")}\n {toolName || translate(\"tools.noToolSettingsPlaceholderName\")}\n {translate(\"tools.noToolSettingsEnd\")}\n </Text>\n );\n}\n\n/**\n * Hook that returns true if the tool settings should be rendered docked.\n * @internal */\nexport function useShouldRenderDockedToolSettings() {\n return useLayout((state) => {\n const toolSettings = state.toolSettings;\n if (!toolSettings || toolSettings.type === \"widget\") return false;\n return !toolSettings.hidden;\n });\n}\n\n/** @internal */\nexport function WidgetPanelsToolSettings() {\n if (!useShouldRenderDockedToolSettings()) return null;\n return <ToolSettingsDockedContent />;\n}\n\n/** @internal */\nexport function ToolSettingsDockedContent() {\n const activeToolId = useActiveToolId();\n const toolSettingEntries = useHorizontalToolSettingEntries();\n const forceRefreshKey = useRefreshKey(toolSettingEntries);\n const frontstageDef = useActiveFrontstageDef();\n\n const emptySettings = React.useMemo<ToolSettingsEntry[]>(\n () => [\n {\n editorNode: null,\n labelNode: frontstageDef?.activeToolEmptyNode ?? (\n <EmptyToolSettingsLabel toolId={activeToolId} />\n ),\n },\n ],\n [activeToolId, frontstageDef]\n );\n const entries =\n !toolSettingEntries || toolSettingEntries.length === 0\n ? emptySettings\n : toolSettingEntries;\n\n // for the overflow to work properly each setting in the DockedToolSettings should be wrapped by a DockedToolSetting component\n return (\n <DockedBar placement=\"top\">\n <ToolSettingsContext.Provider value={true}>\n <ToolSettingsEditorsProvider>\n <DockedToolSettings\n itemId={\n InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ??\n \"none\"\n }\n key={forceRefreshKey}\n >\n {entries.map((entry, index) => (\n <DockedToolSetting key={index}>\n <LockProvider>\n {entry.labelNode}\n {entry.editorNode}\n </LockProvider>\n </DockedToolSetting>\n ))}\n </DockedToolSettings>\n </ToolSettingsEditorsProvider>\n </ToolSettingsContext.Provider>\n </DockedBar>\n );\n}\n\n/** @internal */\nexport function useHorizontalToolSettingEntries() {\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n UiFramework.frontstages.activeToolInformation?.toolUiProvider?.reloadPropertiesFromTool();\n }, []);\n const [settings, setSettings] = React.useState(\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes\n );\n React.useEffect(() => {\n return UiFramework.frontstages.onToolActivatedEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes;\n setSettings(nodes);\n });\n }, []);\n\n React.useEffect(() => {\n return UiFramework.frontstages.onToolSettingsReloadEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes;\n setSettings(nodes);\n });\n }, []);\n\n return settings;\n}\n\n/** @internal */\nexport function useToolSettingsNode() {\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n UiFramework.frontstages.activeToolInformation?.toolUiProvider?.reloadPropertiesFromTool();\n }, []);\n const [settings, setSettings] = React.useState(\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode\n );\n React.useEffect(() => {\n return UiFramework.frontstages.onToolActivatedEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode;\n setSettings(nodes);\n });\n }, [setSettings]);\n\n React.useEffect(() => {\n return UiFramework.frontstages.onToolSettingsReloadEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode;\n setSettings(nodes);\n });\n }, [setSettings]);\n return settings;\n}\n\n/** @internal */\nexport function ToolSettingsContent() {\n const toolSettingsType = useLayout((state) => state.toolSettings?.type);\n // This is needed to remount underlying components tree when going into widget state.\n if (!toolSettingsType || toolSettingsType === \"docked\") return null;\n return <ToolSettingsWidgetContent />;\n}\n\n/** @internal */\nexport function ToolSettingsWidgetContent() {\n const floatingToolSettingsContainerRef = React.useRef<HTMLDivElement>(null);\n const node = useToolSettingsNode();\n const activeToolId = useActiveToolId();\n const forceRefreshKey = useRefreshKey(node);\n const frontstageDef = useActiveFrontstageDef();\n\n const providerId =\n InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ?? \"none\";\n return (\n <div\n data-toolsettings-provider={providerId}\n className=\"uifw-floating-toolSettings-container\"\n ref={floatingToolSettingsContainerRef}\n key={forceRefreshKey}\n >\n <ScrollableWidgetContent>\n <ToolSettingsContext.Provider value={true}>\n <ToolSettingsEditorsProvider>\n {node ?? frontstageDef?.activeToolEmptyNode ?? (\n <EmptyToolSettingsLabel toolId={activeToolId} />\n )}\n </ToolSettingsEditorsProvider>\n </ToolSettingsContext.Provider>\n </ScrollableWidgetContent>\n </div>\n );\n}\n\n/**\n * Hook that returns a key that can be used to force refresh the tool settings.\n * @param toolSettingNodes Nodes that are used to determine if the tool settings should be refreshed.\n * @returns a new key if the dependency changes.\n */\nfunction useRefreshKey(toolSettingNodes: any) {\n const [forceRefreshKey, setForceRefreshKey] = React.useState(Date.now());\n React.useEffect(() => {\n // We cant work with the content of the settings, but we can force refresh when\n // the array is different.\n setForceRefreshKey(Date.now());\n }, [toolSettingNodes]);\n return forceRefreshKey;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicNavigationWidget.d.ts","sourceRoot":"","sources":["../../../src/appui-react/widgets/BasicNavigationWidget.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"BasicNavigationWidget.d.ts","sourceRoot":"","sources":["../../../src/appui-react/widgets/BasicNavigationWidget.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAI7D;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,wEAAwE;IACxE,yBAAyB,CAAC,EAAE,WAAW,EAAE,CAAC;IAC1C,sEAAsE;IACtE,uBAAuB,CAAC,EAAE,WAAW,EAAE,CAAC;CACzC;AAED;;;GAGG;AAEH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,qBAiFtE"}
|
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Widget
|
|
7
7
|
*/
|
|
8
|
-
import classnames from "classnames";
|
|
9
8
|
import * as React from "react";
|
|
10
9
|
import { ToolbarComposer } from "../toolbar/ToolbarComposer.js";
|
|
11
|
-
import { useUiVisibility } from "../hooks/useUiVisibility.js";
|
|
12
10
|
import { NavigationWidgetComposer } from "./NavigationWidgetComposer.js";
|
|
13
11
|
import { ToolbarOrientation, ToolbarUsage } from "../toolbar/ToolbarItem.js";
|
|
14
12
|
import { ToolbarItems } from "../tools/ToolbarItems.js";
|
|
@@ -70,8 +68,6 @@ export function BasicNavigationWidget(props) {
|
|
|
70
68
|
getHorizontalToolbarItems,
|
|
71
69
|
getVerticalToolbarItems,
|
|
72
70
|
]);
|
|
73
|
-
|
|
74
|
-
const className = classnames(!uiIsVisible && "nz-hidden");
|
|
75
|
-
return (React.createElement(NavigationWidgetComposer, { className: className, horizontalToolbar: React.createElement(ToolbarComposer, { items: horizontalItems, usage: ToolbarUsage.ViewNavigation, orientation: ToolbarOrientation.Horizontal }), verticalToolbar: React.createElement(ToolbarComposer, { items: verticalItems, usage: ToolbarUsage.ViewNavigation, orientation: ToolbarOrientation.Vertical }) }));
|
|
71
|
+
return (React.createElement(NavigationWidgetComposer, { horizontalToolbar: React.createElement(ToolbarComposer, { items: horizontalItems, usage: ToolbarUsage.ViewNavigation, orientation: ToolbarOrientation.Horizontal }), verticalToolbar: React.createElement(ToolbarComposer, { items: verticalItems, usage: ToolbarUsage.ViewNavigation, orientation: ToolbarOrientation.Vertical }) }));
|
|
76
72
|
}
|
|
77
73
|
//# sourceMappingURL=BasicNavigationWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicNavigationWidget.js","sourceRoot":"","sources":["../../../src/appui-react/widgets/BasicNavigationWidget.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"BasicNavigationWidget.js","sourceRoot":"","sources":["../../../src/appui-react/widgets/BasicNavigationWidget.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAaxD;;;GAGG;AACH,4DAA4D;AAC5D,MAAM,UAAU,qBAAqB,CAAC,KAAiC;IACrE,MAAM,yBAAyB,GAAG,KAAK,CAAC,WAAW,CAAC,GAAkB,EAAE;QACtE,MAAM,KAAK,GAAkB;YAC3B,YAAY,CAAC,gBAAgB,CAAC;gBAC5B,YAAY,EAAE,EAAE;aACjB,CAAC;YACF,YAAY,CAAC,aAAa,CAAC;gBACzB,YAAY,EAAE,EAAE;aACjB,CAAC;YACF,YAAY,CAAC,aAAa,CAAC;gBACzB,YAAY,EAAE,EAAE;aACjB,CAAC;YACF,YAAY,CAAC,gBAAgB,CAAC;gBAC5B,YAAY,EAAE,EAAE;aACjB,CAAC;YACF,YAAY,CAAC,cAAc,CAAC;gBAC1B,YAAY,EAAE,EAAE;aACjB,CAAC;YACF,YAAY,CAAC,cAAc,CAAC;gBAC1B,YAAY,EAAE,EAAE;aACjB,CAAC;SACH,CAAC;QACF,IAAI,KAAK,CAAC,yBAAyB;YACjC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAEtC,MAAM,uBAAuB,GAAG,KAAK,CAAC,WAA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C,UAAU,GAC1C,EAEJ,eAAe,EACb,oBAAC,eAAe,IACd,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,YAAY,CAAC,cAAc,EAClC,WAAW,EAAE,kBAAkB,CAAC,QAAQ,GACxC,GAEJ,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Widget\n */\n\nimport * as React from \"react\";\nimport { ToolbarComposer } from \"../toolbar/ToolbarComposer.js\";\nimport { NavigationWidgetComposer } from \"./NavigationWidgetComposer.js\";\nimport type { ToolbarItem } from \"../toolbar/ToolbarItem.js\";\nimport { ToolbarOrientation, ToolbarUsage } from \"../toolbar/ToolbarItem.js\";\nimport { ToolbarItems } from \"../tools/ToolbarItems.js\";\n\n/** Properties that can be used to append items to the default set of toolbar items.\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof BasicNavigationWidget>`\n */\nexport interface BasicNavigationWidgetProps {\n /** optional set of additional items to include in horizontal toolbar */\n additionalHorizontalItems?: ToolbarItem[];\n /** optional set of additional items to include in vertical toolbar */\n additionalVerticalItems?: ToolbarItem[];\n}\n\n/** Basic Navigation Widget that provides standard tools to manipulate views containing element data.\n * Supports the specification of additional horizontal and vertical toolbar items through props.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function BasicNavigationWidget(props: BasicNavigationWidgetProps) {\n const getHorizontalToolbarItems = React.useCallback((): ToolbarItem[] => {\n const items: ToolbarItem[] = [\n ToolbarItems.createRotateView({\n itemPriority: 10,\n }),\n ToolbarItems.createPanView({\n itemPriority: 20,\n }),\n ToolbarItems.createFitView({\n itemPriority: 30,\n }),\n ToolbarItems.createWindowArea({\n itemPriority: 40,\n }),\n ToolbarItems.createViewUndo({\n itemPriority: 50,\n }),\n ToolbarItems.createViewRedo({\n itemPriority: 60,\n }),\n ];\n if (props.additionalHorizontalItems)\n items.push(...props.additionalHorizontalItems);\n return items;\n }, [props.additionalHorizontalItems]);\n\n const getVerticalToolbarItems = React.useCallback((): ToolbarItem[] => {\n const items: ToolbarItem[] = [];\n items.push(\n ToolbarItems.createWalkView({\n itemPriority: 10,\n }),\n ToolbarItems.createToggleCameraView({\n itemPriority: 20,\n })\n );\n if (props.additionalVerticalItems)\n items.push(...props.additionalVerticalItems);\n return items;\n }, [props.additionalVerticalItems]);\n\n const [horizontalItems, setHorizontalItems] = React.useState(() =>\n getHorizontalToolbarItems()\n );\n const [verticalItems, setVerticalItems] = React.useState(() =>\n getVerticalToolbarItems()\n );\n\n const isInitialMount = React.useRef(true);\n React.useEffect(() => {\n if (isInitialMount.current) isInitialMount.current = false;\n else {\n setHorizontalItems(getHorizontalToolbarItems());\n setVerticalItems(getVerticalToolbarItems());\n }\n }, [\n props.additionalHorizontalItems,\n props.additionalVerticalItems,\n getHorizontalToolbarItems,\n getVerticalToolbarItems,\n ]);\n\n return (\n <NavigationWidgetComposer\n horizontalToolbar={\n <ToolbarComposer\n items={horizontalItems}\n usage={ToolbarUsage.ViewNavigation}\n orientation={ToolbarOrientation.Horizontal}\n />\n }\n verticalToolbar={\n <ToolbarComposer\n items={verticalItems}\n usage={ToolbarUsage.ViewNavigation}\n orientation={ToolbarOrientation.Vertical}\n />\n }\n />\n );\n}\n"]}
|