@itwin/appui-react 5.30.1 → 5.32.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 +32 -0
- package/lib/appui-react/UiFramework.d.ts.map +1 -1
- package/lib/appui-react/UiFramework.js +2 -0
- package/lib/appui-react/UiFramework.js.map +1 -1
- package/lib/appui-react/UiFramework.json +4 -1
- package/lib/appui-react/backstage/Backstage.d.ts +33 -0
- package/lib/appui-react/backstage/Backstage.d.ts.map +1 -0
- package/lib/appui-react/backstage/Backstage.js +88 -0
- package/lib/appui-react/backstage/Backstage.js.map +1 -0
- package/lib/appui-react/backstage/Backstage.scss +42 -0
- package/lib/appui-react/backstage/BackstageComposer.d.ts +2 -2
- package/lib/appui-react/backstage/BackstageComposer.d.ts.map +1 -1
- package/lib/appui-react/backstage/BackstageComposer.js +25 -19
- package/lib/appui-react/backstage/BackstageComposer.js.map +1 -1
- package/lib/appui-react/configurableui/ConfigurableUiContent.d.ts +12 -0
- package/lib/appui-react/configurableui/ConfigurableUiContent.d.ts.map +1 -1
- package/lib/appui-react/configurableui/ConfigurableUiContent.js.map +1 -1
- package/lib/appui-react/frontstage/ModalFrontstage.d.ts +27 -15
- package/lib/appui-react/frontstage/ModalFrontstage.d.ts.map +1 -1
- package/lib/appui-react/frontstage/ModalFrontstage.js +16 -20
- package/lib/appui-react/frontstage/ModalFrontstage.js.map +1 -1
- package/lib/appui-react/frontstage/ModalFrontstage.scss +11 -17
- package/lib/appui-react/hooks/useActiveModalFrontstage.d.ts +8 -0
- package/lib/appui-react/hooks/useActiveModalFrontstage.d.ts.map +1 -0
- package/lib/appui-react/hooks/useActiveModalFrontstage.js +23 -0
- package/lib/appui-react/hooks/useActiveModalFrontstage.js.map +1 -0
- package/lib/appui-react/layout/StandardLayout.d.ts +1 -2
- package/lib/appui-react/layout/StandardLayout.d.ts.map +1 -1
- package/lib/appui-react/layout/StandardLayout.js +9 -9
- package/lib/appui-react/layout/StandardLayout.js.map +1 -1
- package/lib/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
- package/lib/appui-react/widget-panels/Frontstage.js +9 -4
- package/lib/appui-react/widget-panels/Frontstage.js.map +1 -1
- package/lib/appui-react/widget-panels/ModalFrontstageComposer.d.ts +1 -6
- package/lib/appui-react/widget-panels/ModalFrontstageComposer.d.ts.map +1 -1
- package/lib/appui-react/widget-panels/ModalFrontstageComposer.js +7 -16
- package/lib/appui-react/widget-panels/ModalFrontstageComposer.js.map +1 -1
- package/lib/cjs/appui-react/backstage/Backstage.scss +42 -0
- package/lib/cjs/appui-react/frontstage/ModalFrontstage.scss +11 -17
- package/lib/esm/appui-react/backstage/Backstage.scss +42 -0
- package/lib/esm/appui-react/frontstage/ModalFrontstage.scss +11 -17
- package/lib/public/locales/en/UiFramework.json +4 -1
- package/package.json +7 -7
- package/lib/appui-react/backstage/BackstageComposerItem.d.ts +0 -29
- package/lib/appui-react/backstage/BackstageComposerItem.d.ts.map +0 -1
- package/lib/appui-react/backstage/BackstageComposerItem.js +0 -66
- package/lib/appui-react/backstage/BackstageComposerItem.js.map +0 -1
- package/lib/appui-react/layout/backstage/Backstage.d.ts +0 -42
- package/lib/appui-react/layout/backstage/Backstage.d.ts.map +0 -1
- package/lib/appui-react/layout/backstage/Backstage.js +0 -46
- package/lib/appui-react/layout/backstage/Backstage.js.map +0 -1
- package/lib/appui-react/layout/backstage/Backstage.scss +0 -90
- package/lib/appui-react/layout/backstage/Item.d.ts +0 -38
- package/lib/appui-react/layout/backstage/Item.d.ts.map +0 -1
- package/lib/appui-react/layout/backstage/Item.js +0 -29
- package/lib/appui-react/layout/backstage/Item.js.map +0 -1
- package/lib/appui-react/layout/backstage/Item.scss +0 -107
- package/lib/appui-react/layout/backstage/Separator.d.ts +0 -13
- package/lib/appui-react/layout/backstage/Separator.d.ts.map +0 -1
- package/lib/appui-react/layout/backstage/Separator.js +0 -21
- package/lib/appui-react/layout/backstage/Separator.js.map +0 -1
- package/lib/appui-react/layout/backstage/Separator.scss +0 -10
- package/lib/cjs/appui-react/layout/backstage/Backstage.scss +0 -90
- package/lib/cjs/appui-react/layout/backstage/Item.scss +0 -107
- package/lib/cjs/appui-react/layout/backstage/Separator.scss +0 -10
- package/lib/esm/appui-react/layout/backstage/Backstage.scss +0 -90
- package/lib/esm/appui-react/layout/backstage/Item.scss +0 -107
- package/lib/esm/appui-react/layout/backstage/Separator.scss +0 -10
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Backstage
|
|
7
|
+
*/
|
|
8
|
+
import "./Backstage.scss";
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
import classnames from "classnames";
|
|
11
|
+
import { ConditionalBooleanValue, ConditionalStringValue, } from "@itwin/appui-abstract";
|
|
12
|
+
import { Logger } from "@itwin/core-bentley";
|
|
13
|
+
import { Icon as CoreIcon } from "@itwin/core-react";
|
|
14
|
+
import { Badge } from "@itwin/core-react/internal";
|
|
15
|
+
import { Dialog, Divider, Icon, List, ListItem } from "@itwin/itwinui-react";
|
|
16
|
+
import { UiFramework } from "../UiFramework.js";
|
|
17
|
+
import { useActiveFrontstageId } from "../frontstage/FrontstageDef.js";
|
|
18
|
+
import { isProviderItem } from "../ui-items-provider/isProviderItem.js";
|
|
19
|
+
import { useBackstageManager } from "./BackstageManager.js";
|
|
20
|
+
import { useTranslation } from "../hooks/useTranslation.js";
|
|
21
|
+
/** @internal */
|
|
22
|
+
export function Backstage(props) {
|
|
23
|
+
const { isOpen, onClose, showOverlay, ...rest } = props;
|
|
24
|
+
const { translate } = useTranslation();
|
|
25
|
+
return (React.createElement(Dialog, { className: "uifw-backstage-backstage_wrapper", placement: "top-left", isOpen: isOpen, onClose: onClose, closeOnExternalClick: true, preventDocumentScroll: true, trapFocus: true, setFocus: false },
|
|
26
|
+
React.createElement(Dialog.Backdrop, { className: classnames("uifw-backstage-backstage_backdrop", !showOverlay && "uifw-transparent") }),
|
|
27
|
+
React.createElement(Dialog.Main, { "aria-label": translate("backstage.label"), ...rest, className: classnames("uifw-backstage-backstage", props.className) },
|
|
28
|
+
React.createElement(Dialog.Content, { className: "uifw-backstage-backstage_content" }, props.children))));
|
|
29
|
+
}
|
|
30
|
+
function BackstageDivider() {
|
|
31
|
+
return React.createElement(Divider, { className: "uifw-backstage-backstage_divider" });
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
export function BackstageGroup(props) {
|
|
35
|
+
const { index, ...rest } = props;
|
|
36
|
+
return (React.createElement(React.Fragment, null,
|
|
37
|
+
index > 0 ? React.createElement(BackstageDivider, null) : null,
|
|
38
|
+
React.createElement(List, { ...rest }, props.children)));
|
|
39
|
+
}
|
|
40
|
+
function ItemIcon({ icon, iconNode, }) {
|
|
41
|
+
if (iconNode) {
|
|
42
|
+
return React.createElement(Icon, { "aria-hidden": "true" }, iconNode);
|
|
43
|
+
}
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
45
|
+
return React.createElement(CoreIcon, { iconSpec: icon });
|
|
46
|
+
}
|
|
47
|
+
function BackstageItem(props) {
|
|
48
|
+
const { item, active, onClick, autoFocus, ...rest } = props;
|
|
49
|
+
const descriptionId = React.useId();
|
|
50
|
+
const description = ConditionalStringValue.getValue(item.subtitle);
|
|
51
|
+
const label = ConditionalStringValue.getValue(item.label);
|
|
52
|
+
const disabled = ConditionalBooleanValue.getValue(item.isDisabled);
|
|
53
|
+
return (React.createElement(ListItem, { "data-item-id": item.id, "data-item-type": "backstage-item", "data-item-group-priority": item.groupPriority, "data-item-priority": item.itemPriority, "data-item-provider-id": isProviderItem(item) ? item.providerId : undefined, disabled: disabled, size: "large", active: active, actionable: true, ...rest },
|
|
54
|
+
React.createElement("div", { className: "uifw-backstage-backstage_badge" },
|
|
55
|
+
React.createElement(Badge, { type: item.badgeKind || item.badge })),
|
|
56
|
+
React.createElement(ListItem.Icon, null,
|
|
57
|
+
React.createElement(ItemIcon, { iconNode: item.iconNode, icon: item.icon })),
|
|
58
|
+
React.createElement(ListItem.Content, null,
|
|
59
|
+
React.createElement(ListItem.Action, { onClick: onClick, "aria-describedby": descriptionId,
|
|
60
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
61
|
+
autoFocus: autoFocus, "aria-current": active ? "true" : undefined }, label),
|
|
62
|
+
React.createElement(ListItem.Description, { id: descriptionId }, description))));
|
|
63
|
+
}
|
|
64
|
+
/** @internal */
|
|
65
|
+
export function BackstageActionItem(props) {
|
|
66
|
+
const { item, ...rest } = props;
|
|
67
|
+
const manager = useBackstageManager();
|
|
68
|
+
const handleClick = React.useCallback(() => {
|
|
69
|
+
manager.close();
|
|
70
|
+
item.execute();
|
|
71
|
+
}, [manager, item]);
|
|
72
|
+
return React.createElement(BackstageItem, { item: item, onClick: handleClick, ...rest });
|
|
73
|
+
}
|
|
74
|
+
/** @internal */
|
|
75
|
+
export function BackstageStageLauncher(props) {
|
|
76
|
+
const { item, ...rest } = props;
|
|
77
|
+
const manager = useBackstageManager();
|
|
78
|
+
const handleClick = React.useCallback(() => {
|
|
79
|
+
manager.close();
|
|
80
|
+
if (!UiFramework.frontstages.hasFrontstage(item.stageId))
|
|
81
|
+
return Logger.logError("BackstageStageLauncher", `Frontstage with id '${item.stageId}' not found`);
|
|
82
|
+
void UiFramework.frontstages.setActiveFrontstage(item.stageId);
|
|
83
|
+
}, [manager, item.stageId]);
|
|
84
|
+
const activeFrontstageId = useActiveFrontstageId();
|
|
85
|
+
const isActive = ConditionalBooleanValue.getValue(item.isActive ?? item.stageId === activeFrontstageId);
|
|
86
|
+
return (React.createElement(BackstageItem, { item: item, active: isActive, onClick: handleClick, ...rest }));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMapping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,EAChB,OAAO,EAAE,WAAW,KAChB,IAAI,GACR,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 Backstage\n */\n\nimport \"./Backstage.scss\";\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport {\n ConditionalBooleanValue,\n ConditionalStringValue,\n} from \"@itwin/appui-abstract\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { Icon as CoreIcon } from \"@itwin/core-react\";\nimport { Badge } from \"@itwin/core-react/internal\";\nimport { Dialog, Divider, Icon, List, ListItem } from \"@itwin/itwinui-react\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport { useActiveFrontstageId } from \"../frontstage/FrontstageDef.js\";\nimport { isProviderItem } from \"../ui-items-provider/isProviderItem.js\";\nimport { useBackstageManager } from \"./BackstageManager.js\";\nimport { useTranslation } from \"../hooks/useTranslation.js\";\n\nimport type {\n BackstageActionItem as BackstageActionItemDef,\n BackstageItem as BackstageItemDef,\n BackstageStageLauncher as BackstageStageLauncherDef,\n CommonBackstageItem,\n} from \"./BackstageItem.js\";\n\ninterface BackstageProps extends React.ComponentProps<\"div\"> {\n isOpen: boolean;\n onClose: () => void;\n showOverlay: boolean;\n}\n\n/** @internal */\nexport function Backstage(props: BackstageProps) {\n const { isOpen, onClose, showOverlay, ...rest } = props;\n\n const { translate } = useTranslation();\n\n return (\n <Dialog\n className=\"uifw-backstage-backstage_wrapper\"\n placement=\"top-left\"\n isOpen={isOpen}\n onClose={onClose}\n closeOnExternalClick\n preventDocumentScroll\n trapFocus\n setFocus={false}\n >\n <Dialog.Backdrop\n className={classnames(\n \"uifw-backstage-backstage_backdrop\",\n !showOverlay && \"uifw-transparent\"\n )}\n />\n <Dialog.Main\n aria-label={translate(\"backstage.label\")}\n {...rest}\n className={classnames(\"uifw-backstage-backstage\", props.className)}\n >\n <Dialog.Content className=\"uifw-backstage-backstage_content\">\n {props.children}\n </Dialog.Content>\n </Dialog.Main>\n </Dialog>\n );\n}\n\nfunction BackstageDivider() {\n return <Divider className=\"uifw-backstage-backstage_divider\" />;\n}\n\ninterface BackstageGroupProps {\n children?: React.ReactNode;\n index: number;\n}\n\n/** @internal */\nexport function BackstageGroup(props: BackstageGroupProps) {\n const { index, ...rest } = props;\n return (\n <>\n {index > 0 ? <BackstageDivider /> : null}\n <List {...rest}>{props.children}</List>\n </>\n );\n}\n\nfunction ItemIcon({\n icon,\n iconNode,\n}: {\n icon: CommonBackstageItem[\"icon\"];\n iconNode: CommonBackstageItem[\"iconNode\"];\n}) {\n if (iconNode) {\n return <Icon aria-hidden=\"true\">{iconNode}</Icon>;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return <CoreIcon iconSpec={icon} />;\n}\n\ntype ListItemProps = React.ComponentProps<typeof ListItem>;\n\ninterface BackstageItemProps\n extends Pick<ListItemProps, \"active\" | \"onClick\" | \"autoFocus\"> {\n item: BackstageItemDef;\n onClick?: () => void;\n}\n\nfunction BackstageItem(props: BackstageItemProps) {\n const { item, active, onClick, autoFocus, ...rest } = props;\n\n const descriptionId = React.useId();\n\n const description = ConditionalStringValue.getValue(item.subtitle);\n const label = ConditionalStringValue.getValue(item.label);\n const disabled = ConditionalBooleanValue.getValue(item.isDisabled);\n return (\n <ListItem\n data-item-id={item.id}\n data-item-type=\"backstage-item\"\n data-item-group-priority={item.groupPriority}\n data-item-priority={item.itemPriority}\n data-item-provider-id={isProviderItem(item) ? item.providerId : undefined}\n disabled={disabled}\n size=\"large\"\n active={active}\n actionable\n {...rest}\n >\n <div className=\"uifw-backstage-backstage_badge\">\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Badge type={item.badgeKind || item.badge} />\n </div>\n <ListItem.Icon>\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <ItemIcon iconNode={item.iconNode} icon={item.icon} />\n </ListItem.Icon>\n <ListItem.Content>\n <ListItem.Action\n onClick={onClick}\n aria-describedby={descriptionId}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n aria-current={active ? \"true\" : undefined}\n >\n {label}\n </ListItem.Action>\n <ListItem.Description id={descriptionId}>\n {description}\n </ListItem.Description>\n </ListItem.Content>\n </ListItem>\n );\n}\n\ninterface BackstageActionItemProps extends Pick<ListItemProps, \"autoFocus\"> {\n readonly item: BackstageActionItemDef;\n}\n\n/** @internal */\nexport function BackstageActionItem(props: BackstageActionItemProps) {\n const { item, ...rest } = props;\n\n const manager = useBackstageManager();\n const handleClick = React.useCallback(() => {\n manager.close();\n item.execute();\n }, [manager, item]);\n return <BackstageItem item={item} onClick={handleClick} {...rest} />;\n}\n\ninterface BackstageStageLauncherProps extends Pick<ListItemProps, \"autoFocus\"> {\n readonly item: BackstageStageLauncherDef;\n}\n\n/** @internal */\nexport function BackstageStageLauncher(props: BackstageStageLauncherProps) {\n const { item, ...rest } = props;\n\n const manager = useBackstageManager();\n const handleClick = React.useCallback(() => {\n manager.close();\n if (!UiFramework.frontstages.hasFrontstage(item.stageId))\n return Logger.logError(\n \"BackstageStageLauncher\",\n `Frontstage with id '${item.stageId}' not found`\n );\n void UiFramework.frontstages.setActiveFrontstage(item.stageId);\n }, [manager, item.stageId]);\n const activeFrontstageId = useActiveFrontstageId();\n const isActive = ConditionalBooleanValue.getValue(\n item.isActive ?? item.stageId === activeFrontstageId\n );\n return (\n <BackstageItem\n item={item}\n active={isActive}\n onClick={handleClick}\n {...rest}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
@use "~@itwin/core-react/lib/core-react/z-index" as zIndex;
|
|
6
|
+
|
|
7
|
+
.uifw-backstage-backstage_wrapper {
|
|
8
|
+
@include zIndex.uicore-z-index(backstage);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.uifw-backstage-backstage {
|
|
12
|
+
inset-block-end: 0;
|
|
13
|
+
border-radius: 0;
|
|
14
|
+
margin-block-start: 0;
|
|
15
|
+
margin-inline-start: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.uifw-backstage-backstage_backdrop {
|
|
19
|
+
&:where(.uifw-transparent) {
|
|
20
|
+
background-color: transparent;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.uifw-backstage-backstage_content {
|
|
25
|
+
padding-inline: var(--iui-size-xs);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.uifw-backstage-backstage_divider {
|
|
29
|
+
$margin-block: var(--iui-size-2xs);
|
|
30
|
+
$margin-inline: calc(-1 * var(--iui-size-xs));
|
|
31
|
+
|
|
32
|
+
margin-block-start: $margin-block;
|
|
33
|
+
margin-block-end: $margin-block;
|
|
34
|
+
margin-inline-start: $margin-inline;
|
|
35
|
+
margin-inline-end: $margin-inline;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.uifw-backstage-backstage_badge {
|
|
39
|
+
position: absolute;
|
|
40
|
+
inset-block-start: 0;
|
|
41
|
+
inset-inline-start: 0;
|
|
42
|
+
}
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import type { CommonProps } from "@itwin/core-react";
|
|
6
6
|
import type { BackstageItem } from "./BackstageItem.js";
|
|
7
|
-
|
|
8
|
-
export type GroupedItems = ReadonlyArray<ReadonlyArray<BackstageItem>>;
|
|
7
|
+
type GroupedItems = ReadonlyArray<ReadonlyArray<BackstageItem>>;
|
|
9
8
|
/** @internal */
|
|
10
9
|
export declare const useGroupedItems: (items: ReadonlyArray<BackstageItem>) => GroupedItems;
|
|
11
10
|
/** Props of [[BackstageComposer]] component.
|
|
@@ -26,4 +25,5 @@ export interface BackstageComposerProps extends CommonProps {
|
|
|
26
25
|
* @public
|
|
27
26
|
*/
|
|
28
27
|
export declare function BackstageComposer(props: BackstageComposerProps): React.JSX.Element;
|
|
28
|
+
export {};
|
|
29
29
|
//# sourceMappingURL=BackstageComposer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackstageComposer.d.ts","sourceRoot":"","sources":["../../../src/appui-react/backstage/BackstageComposer.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"BackstageComposer.d.ts","sourceRoot":"","sources":["../../../src/appui-react/backstage/BackstageComposer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAqExD,KAAK,YAAY,GAAG,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;AAEhE,gBAAgB;AAChB,eAAO,MAAM,eAAe,UACnB,aAAa,CAAC,aAAa,CAAC,KAClC,YAyBF,CAAC;AAEF;;;GAGG;AAEH,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC,gGAAgG;IAChG,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,mHAAmH;IACnH,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,wFAAwF;IACxF,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;GAEG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAsF9D"}
|
|
@@ -5,13 +5,10 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Backstage
|
|
7
7
|
*/
|
|
8
|
-
import { ConditionalBooleanValue } from "@itwin/appui-abstract";
|
|
9
8
|
import * as React from "react";
|
|
10
|
-
import {
|
|
11
|
-
import { BackstageSeparator } from "../layout/backstage/Separator.js";
|
|
12
|
-
import { SafeAreaContext } from "../safearea/SafeAreaContext.js";
|
|
9
|
+
import { ConditionalBooleanValue } from "@itwin/appui-abstract";
|
|
13
10
|
import { SyncUiEventDispatcher } from "../syncui/SyncUiEventDispatcher.js";
|
|
14
|
-
import {
|
|
11
|
+
import { Backstage, BackstageActionItem, BackstageGroup, BackstageStageLauncher, } from "./Backstage.js";
|
|
15
12
|
import { isBackstageStageLauncher } from "./BackstageItem.js";
|
|
16
13
|
import { BackstageItemsManager } from "./BackstageItemsManager.js";
|
|
17
14
|
import { useBackstageManager, useIsBackstageOpen } from "./BackstageManager.js";
|
|
@@ -90,17 +87,17 @@ export const useGroupedItems = (items) => {
|
|
|
90
87
|
*/
|
|
91
88
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
92
89
|
export function BackstageComposer(props) {
|
|
93
|
-
const
|
|
94
|
-
const
|
|
90
|
+
const { header, showOverlay = true, items, hideSoloStageEntry, itemId, ...rest } = props;
|
|
91
|
+
const [defaultItemsManager, setDefaultItemsManager] = React.useState(new BackstageItemsManager(items));
|
|
92
|
+
const initialItems = React.useRef(items);
|
|
95
93
|
React.useEffect(() => {
|
|
96
|
-
if (initialItems.current !==
|
|
97
|
-
initialItems.current =
|
|
98
|
-
setDefaultItemsManager(new BackstageItemsManager(
|
|
94
|
+
if (initialItems.current !== items) {
|
|
95
|
+
initialItems.current = items;
|
|
96
|
+
setDefaultItemsManager(new BackstageItemsManager(items));
|
|
99
97
|
}
|
|
100
|
-
}, [
|
|
98
|
+
}, [items]);
|
|
101
99
|
const manager = useBackstageManager();
|
|
102
100
|
const isOpen = useIsBackstageOpen(manager);
|
|
103
|
-
const safeAreaInsets = React.useContext(SafeAreaContext);
|
|
104
101
|
const handleClose = React.useCallback(() => {
|
|
105
102
|
manager.close();
|
|
106
103
|
}, [manager]);
|
|
@@ -112,13 +109,22 @@ export function BackstageComposer(props) {
|
|
|
112
109
|
const addonItems = useUiItemsProviderBackstageItems(addonItemsManager);
|
|
113
110
|
const addonSyncIdsOfInterest = React.useMemo(() => BackstageItemsManager.getSyncIdsOfInterest(addonItems), [addonItems]);
|
|
114
111
|
useBackstageItemSyncEffect(addonItemsManager, addonSyncIdsOfInterest);
|
|
115
|
-
const combinedBackstageItems = React.useMemo(() => combineItems(defaultItems, addonItems, !!
|
|
112
|
+
const combinedBackstageItems = React.useMemo(() => combineItems(defaultItems, addonItems, !!hideSoloStageEntry), [defaultItems, addonItems, hideSoloStageEntry]);
|
|
116
113
|
const groups = useGroupedItems(combinedBackstageItems);
|
|
117
|
-
return (React.createElement(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
React.createElement(
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
return (React.createElement(Backstage, { isOpen: isOpen, onClose: handleClose, showOverlay: showOverlay, ...rest },
|
|
115
|
+
header,
|
|
116
|
+
groups.map((groupItems, groupIndex) => {
|
|
117
|
+
return (React.createElement(BackstageGroup, { key: groupIndex, index: groupIndex }, groupItems.map((item, itemIndex) => {
|
|
118
|
+
const autoFocus = groupIndex === 0 && itemIndex === 0;
|
|
119
|
+
if (isBackstageStageLauncher(item)) {
|
|
120
|
+
return (React.createElement(BackstageStageLauncher, { key: item.id, item: item,
|
|
121
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus -- autoFocus first item in the dialog
|
|
122
|
+
autoFocus: autoFocus }));
|
|
123
|
+
}
|
|
124
|
+
return (React.createElement(BackstageActionItem, { key: item.id, item: item,
|
|
125
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus -- autoFocus first item in the dialog
|
|
126
|
+
autoFocus: autoFocus }));
|
|
127
|
+
})));
|
|
128
|
+
})));
|
|
123
129
|
}
|
|
124
130
|
//# sourceMappingURL=BackstageComposer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackstageComposer.js","sourceRoot":"","sources":["../../../src/appui-react/backstage/BackstageComposer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAKzF,0EAA0E;AAC1E,SAAS,0BAA0B,CACjC,YAAmC,EACnC,iBAA2B;IAE3B,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE1C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC;YAC3B,cAAc,CAAC,OAAO,GAAG,KAAK,CAAC;YAC/B,2EAA2E;YAC3E,YAAY,CAAC,oBAAoB,CAAC,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,qBAAqB,CAAC,aAA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B,CAAC,CAAC;IACvD,OAAO,CACL,oBAAC,YAAY,IACX,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,KAAK,EAAE,KAAK,CAAC,KAAK,IAEjB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,CAChC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QAC5B,MAAM,YAAY,GAAG,CACnB,oBAAC,qBAAqB,IAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAI,CACpD,CAAC;QACF,OAAO,SAAS,KAAK,CAAC,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CACzC,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,UAAU;YAC7B,oBAAC,kBAAkB,OAAG;YACrB,YAAY,CACE,CAClB,CAAC,CAAC,CAAC,CACF,YAAY,CACb,CAAC;IACJ,CAAC,CAAC,CACH,CACY,CAChB,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 Backstage\n */\n\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport * as React from \"react\";\nimport { Backstage as NZ_Backstage } from \"../layout/backstage/Backstage.js\";\nimport { BackstageSeparator } from \"../layout/backstage/Separator.js\";\nimport { SafeAreaContext } from \"../safearea/SafeAreaContext.js\";\nimport { SyncUiEventDispatcher } from \"../syncui/SyncUiEventDispatcher.js\";\nimport { BackstageComposerItem } from \"./BackstageComposerItem.js\";\nimport { isBackstageStageLauncher } from \"./BackstageItem.js\";\nimport { BackstageItemsManager } from \"./BackstageItemsManager.js\";\nimport { useBackstageManager, useIsBackstageOpen } from \"./BackstageManager.js\";\nimport { useDefaultBackstageItems } from \"./useDefaultBackstageItems.js\";\nimport { useUiItemsProviderBackstageItems } from \"./useUiItemsProviderBackstageItems.js\";\n\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { BackstageItem } from \"./BackstageItem.js\";\n\n/** Private function to set up sync event monitoring of backstage items */\nfunction useBackstageItemSyncEffect(\n itemsManager: BackstageItemsManager,\n syncIdsOfInterest: string[]\n) {\n const isInitialMount = React.useRef(true);\n\n React.useEffect(() => {\n if (isInitialMount.current) {\n isInitialMount.current = false;\n // initialize the display state of any items with syncIds/condition defined\n itemsManager.refreshAffectedItems(new Set(syncIdsOfInterest));\n }\n\n return SyncUiEventDispatcher.onSyncUiEvent.addListener((args) => {\n if (0 === syncIdsOfInterest.length) return;\n\n if (\n syncIdsOfInterest.some((value: string): boolean =>\n args.eventIds.has(value.toLowerCase())\n )\n ) {\n // process each item that has interest\n itemsManager.refreshAffectedItems(args.eventIds);\n }\n });\n }, [itemsManager, itemsManager.items, syncIdsOfInterest]);\n}\n\n/** local function to combine items from Stage and from Extensions */\nfunction combineItems(\n stageItems: ReadonlyArray<BackstageItem>,\n addonItems: ReadonlyArray<BackstageItem>,\n hideSoloStageEntry: boolean\n): ReadonlyArray<BackstageItem> {\n let items: Array<BackstageItem> = [];\n if (stageItems.length) {\n // Walk through each and ensure no duplicate ids are added.\n stageItems.forEach((srcItem) => {\n if (-1 === items.findIndex((item) => item.id === srcItem.id)) {\n items.push(srcItem);\n }\n });\n }\n if (addonItems.length) {\n // Walk through each and ensure no duplicate ids are added.\n addonItems.forEach((srcItem) => {\n if (-1 === items.findIndex((item) => item.id === srcItem.id)) {\n items.push(srcItem);\n }\n });\n }\n\n if (hideSoloStageEntry) {\n // per user request don't show stage launcher if only one stage is available\n const numberOfFrontstageItems = items.reduce(\n (accumulator, item) =>\n accumulator + (isBackstageStageLauncher(item) ? 1 : 0),\n 0\n );\n if (1 === numberOfFrontstageItems)\n items = items.filter((item) => !isBackstageStageLauncher(item));\n }\n\n return items;\n}\n\n/** @internal */\nexport type GroupedItems = ReadonlyArray<ReadonlyArray<BackstageItem>>;\n\n/** @internal */\nexport const useGroupedItems = (\n items: ReadonlyArray<BackstageItem>\n): GroupedItems => {\n return React.useMemo(() => {\n const grouped = items.reduce<GroupedItems>((acc, item) => {\n if (ConditionalBooleanValue.getValue(item.isHidden)) return acc;\n const groupIndex = acc.findIndex(\n (group) => group[0].groupPriority === item.groupPriority\n );\n if (groupIndex >= 0)\n return [\n ...acc.slice(0, groupIndex),\n [...acc[groupIndex], item],\n ...acc.slice(groupIndex + 1),\n ];\n return [...acc, [item]];\n }, []);\n const sortedGroups = grouped.reduce<GroupedItems>((acc, group) => {\n const sortedGroup = [...group].sort(\n (a, b) => a.itemPriority - b.itemPriority\n );\n return [...acc, sortedGroup];\n }, []);\n return [...sortedGroups].sort(\n (a, b) => a[0].groupPriority - b[0].groupPriority\n );\n }, [items]);\n};\n\n/** Props of [[BackstageComposer]] component.\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof BackstageComposer>`\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface BackstageComposerProps extends CommonProps {\n /** React node for an optional header item */\n readonly header?: React.ReactNode;\n /** Indicates whether to place an overlay over the frontstage when the backstage is displayed */\n readonly showOverlay?: boolean;\n /** List of static backstage items to show. Can be undefined in UiItemsProviders are used to populate backstage. */\n readonly items?: BackstageItem[];\n /** If true and only one stage launcher item is found, do not show entry in backstage */\n readonly hideSoloStageEntry?: boolean;\n}\n\n/** Backstage component composed from [[UiFramework.backstage]] items.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function BackstageComposer(props: BackstageComposerProps) {\n const [defaultItemsManager, setDefaultItemsManager] = React.useState(\n new BackstageItemsManager(props.items)\n );\n const initialItems = React.useRef(props.items);\n\n React.useEffect(() => {\n if (initialItems.current !== props.items) {\n initialItems.current = props.items;\n setDefaultItemsManager(new BackstageItemsManager(props.items));\n }\n }, [props.items]);\n\n const manager = useBackstageManager();\n const isOpen = useIsBackstageOpen(manager);\n const safeAreaInsets = React.useContext(SafeAreaContext);\n const handleClose = React.useCallback(() => {\n manager.close();\n }, [manager]);\n\n const defaultItems = useDefaultBackstageItems(defaultItemsManager);\n const syncIdsOfInterest = React.useMemo(\n () => BackstageItemsManager.getSyncIdsOfInterest(defaultItems),\n [defaultItems]\n );\n useBackstageItemSyncEffect(defaultItemsManager, syncIdsOfInterest);\n\n const [addonItemsManager] = React.useState(new BackstageItemsManager());\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const addonItems = useUiItemsProviderBackstageItems(addonItemsManager);\n const addonSyncIdsOfInterest = React.useMemo(\n () => BackstageItemsManager.getSyncIdsOfInterest(addonItems),\n [addonItems]\n );\n useBackstageItemSyncEffect(addonItemsManager, addonSyncIdsOfInterest);\n\n const combinedBackstageItems = React.useMemo(\n () => combineItems(defaultItems, addonItems, !!props.hideSoloStageEntry),\n [defaultItems, addonItems, props.hideSoloStageEntry]\n );\n const groups = useGroupedItems(combinedBackstageItems);\n return (\n <NZ_Backstage\n className={props.className}\n header={props.header}\n isOpen={isOpen}\n onClose={handleClose}\n safeAreaInsets={safeAreaInsets}\n showOverlay={props.showOverlay}\n style={props.style}\n >\n {groups.map((group, groupIndex) =>\n group.map((item, itemIndex) => {\n const composerItem = (\n <BackstageComposerItem item={item} key={item.id} />\n );\n return itemIndex === 0 && groupIndex > 0 ? (\n <React.Fragment key={groupIndex}>\n <BackstageSeparator />\n {composerItem}\n </React.Fragment>\n ) : (\n composerItem\n );\n })\n )}\n </NZ_Backstage>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BackstageComposer.js","sourceRoot":"","sources":["../../../src/appui-react/backstage/BackstageComposer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG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AClC,MAAM,SAAS,GAAG,UAAU,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC;gBACtD,IAAI,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;oBACnC,OAAO,CACL,oBAAC,sBAAsB,IACrB,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,IAAI,EAAE,IAAI;wBACV,uFAAuF;wBACvF,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;gBACJ,CAAC;gBACD,OAAO,CACL,oBAAC,mBAAmB,IAClB,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,IAAI,EAAE,IAAI;oBACV,uFAAuF;oBACvF,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;YACJ,CAAC,CAAC,CACa,CAClB,CAAC;QACJ,CAAC,CAAC,CACQ,CACb,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 Backstage\n */\n\nimport * as React from \"react\";\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport { SyncUiEventDispatcher } from \"../syncui/SyncUiEventDispatcher.js\";\nimport {\n Backstage,\n BackstageActionItem,\n BackstageGroup,\n BackstageStageLauncher,\n} from \"./Backstage.js\";\nimport { isBackstageStageLauncher } from \"./BackstageItem.js\";\nimport { BackstageItemsManager } from \"./BackstageItemsManager.js\";\nimport { useBackstageManager, useIsBackstageOpen } from \"./BackstageManager.js\";\nimport { useDefaultBackstageItems } from \"./useDefaultBackstageItems.js\";\nimport { useUiItemsProviderBackstageItems } from \"./useUiItemsProviderBackstageItems.js\";\n\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { BackstageItem } from \"./BackstageItem.js\";\n\n/** Private function to set up sync event monitoring of backstage items */\nfunction useBackstageItemSyncEffect(\n itemsManager: BackstageItemsManager,\n syncIdsOfInterest: string[]\n) {\n const isInitialMount = React.useRef(true);\n\n React.useEffect(() => {\n if (isInitialMount.current) {\n isInitialMount.current = false;\n // initialize the display state of any items with syncIds/condition defined\n itemsManager.refreshAffectedItems(new Set(syncIdsOfInterest));\n }\n\n return SyncUiEventDispatcher.onSyncUiEvent.addListener((args) => {\n if (0 === syncIdsOfInterest.length) return;\n\n if (\n syncIdsOfInterest.some((value: string): boolean =>\n args.eventIds.has(value.toLowerCase())\n )\n ) {\n // process each item that has interest\n itemsManager.refreshAffectedItems(args.eventIds);\n }\n });\n }, [itemsManager, itemsManager.items, syncIdsOfInterest]);\n}\n\n/** local function to combine items from Stage and from Extensions */\nfunction combineItems(\n stageItems: ReadonlyArray<BackstageItem>,\n addonItems: ReadonlyArray<BackstageItem>,\n hideSoloStageEntry: boolean\n): ReadonlyArray<BackstageItem> {\n let items: Array<BackstageItem> = [];\n if (stageItems.length) {\n // Walk through each and ensure no duplicate ids are added.\n stageItems.forEach((srcItem) => {\n if (-1 === items.findIndex((item) => item.id === srcItem.id)) {\n items.push(srcItem);\n }\n });\n }\n if (addonItems.length) {\n // Walk through each and ensure no duplicate ids are added.\n addonItems.forEach((srcItem) => {\n if (-1 === items.findIndex((item) => item.id === srcItem.id)) {\n items.push(srcItem);\n }\n });\n }\n\n if (hideSoloStageEntry) {\n // per user request don't show stage launcher if only one stage is available\n const numberOfFrontstageItems = items.reduce(\n (accumulator, item) =>\n accumulator + (isBackstageStageLauncher(item) ? 1 : 0),\n 0\n );\n if (1 === numberOfFrontstageItems)\n items = items.filter((item) => !isBackstageStageLauncher(item));\n }\n\n return items;\n}\n\ntype GroupedItems = ReadonlyArray<ReadonlyArray<BackstageItem>>;\n\n/** @internal */\nexport const useGroupedItems = (\n items: ReadonlyArray<BackstageItem>\n): GroupedItems => {\n return React.useMemo(() => {\n const grouped = items.reduce<GroupedItems>((acc, item) => {\n if (ConditionalBooleanValue.getValue(item.isHidden)) return acc;\n const groupIndex = acc.findIndex(\n (group) => group[0].groupPriority === item.groupPriority\n );\n if (groupIndex >= 0)\n return [\n ...acc.slice(0, groupIndex),\n [...acc[groupIndex], item],\n ...acc.slice(groupIndex + 1),\n ];\n return [...acc, [item]];\n }, []);\n const sortedGroups = grouped.reduce<GroupedItems>((acc, group) => {\n const sortedGroup = [...group].sort(\n (a, b) => a.itemPriority - b.itemPriority\n );\n return [...acc, sortedGroup];\n }, []);\n return [...sortedGroups].sort(\n (a, b) => a[0].groupPriority - b[0].groupPriority\n );\n }, [items]);\n};\n\n/** Props of [[BackstageComposer]] component.\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof BackstageComposer>`\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface BackstageComposerProps extends CommonProps {\n /** React node for an optional header item */\n readonly header?: React.ReactNode;\n /** Indicates whether to place an overlay over the frontstage when the backstage is displayed */\n readonly showOverlay?: boolean;\n /** List of static backstage items to show. Can be undefined in UiItemsProviders are used to populate backstage. */\n readonly items?: BackstageItem[];\n /** If true and only one stage launcher item is found, do not show entry in backstage */\n readonly hideSoloStageEntry?: boolean;\n}\n\n/** Backstage component composed from [[UiFramework.backstage]] items.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function BackstageComposer(props: BackstageComposerProps) {\n const {\n header,\n showOverlay = true,\n items,\n hideSoloStageEntry,\n itemId,\n ...rest\n } = props;\n\n const [defaultItemsManager, setDefaultItemsManager] = React.useState(\n new BackstageItemsManager(items)\n );\n const initialItems = React.useRef(items);\n\n React.useEffect(() => {\n if (initialItems.current !== items) {\n initialItems.current = items;\n setDefaultItemsManager(new BackstageItemsManager(items));\n }\n }, [items]);\n\n const manager = useBackstageManager();\n const isOpen = useIsBackstageOpen(manager);\n const handleClose = React.useCallback(() => {\n manager.close();\n }, [manager]);\n\n const defaultItems = useDefaultBackstageItems(defaultItemsManager);\n const syncIdsOfInterest = React.useMemo(\n () => BackstageItemsManager.getSyncIdsOfInterest(defaultItems),\n [defaultItems]\n );\n useBackstageItemSyncEffect(defaultItemsManager, syncIdsOfInterest);\n\n const [addonItemsManager] = React.useState(new BackstageItemsManager());\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const addonItems = useUiItemsProviderBackstageItems(addonItemsManager);\n const addonSyncIdsOfInterest = React.useMemo(\n () => BackstageItemsManager.getSyncIdsOfInterest(addonItems),\n [addonItems]\n );\n useBackstageItemSyncEffect(addonItemsManager, addonSyncIdsOfInterest);\n\n const combinedBackstageItems = React.useMemo(\n () => combineItems(defaultItems, addonItems, !!hideSoloStageEntry),\n [defaultItems, addonItems, hideSoloStageEntry]\n );\n const groups = useGroupedItems(combinedBackstageItems);\n return (\n <Backstage\n isOpen={isOpen}\n onClose={handleClose}\n showOverlay={showOverlay}\n {...rest}\n >\n {header}\n {groups.map((groupItems, groupIndex) => {\n return (\n <BackstageGroup key={groupIndex} index={groupIndex}>\n {groupItems.map((item, itemIndex) => {\n const autoFocus = groupIndex === 0 && itemIndex === 0;\n if (isBackstageStageLauncher(item)) {\n return (\n <BackstageStageLauncher\n key={item.id}\n item={item}\n // eslint-disable-next-line jsx-a11y/no-autofocus -- autoFocus first item in the dialog\n autoFocus={autoFocus}\n />\n );\n }\n return (\n <BackstageActionItem\n key={item.id}\n item={item}\n // eslint-disable-next-line jsx-a11y/no-autofocus -- autoFocus first item in the dialog\n autoFocus={autoFocus}\n />\n );\n })}\n </BackstageGroup>\n );\n })}\n </Backstage>\n );\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import * as React from "react";
|
|
|
6
6
|
import type { CommonProps } from "@itwin/core-react";
|
|
7
7
|
import type { StagePanelSection } from "../stagepanels/StagePanelSection.js";
|
|
8
8
|
import type { StagePanelLocation } from "../stagepanels/StagePanelLocation.js";
|
|
9
|
+
import type { ModalFrontstageInfo } from "../framework/FrameworkFrontstages.js";
|
|
9
10
|
/** @internal */
|
|
10
11
|
export declare const ConfigurableUiContext: React.Context<ConfigurableUiContentProps & {
|
|
11
12
|
contentElementRef?: React.RefObject<HTMLElement | null>;
|
|
@@ -40,6 +41,17 @@ export interface ConfigurableUiContentProps extends CommonProps {
|
|
|
40
41
|
toolbarOpacity?: number;
|
|
41
42
|
/** Component to wrap all popout widgets and other child windows opened via {@link UiFramework.childWindows}. */
|
|
42
43
|
childWindow?: React.ComponentType;
|
|
44
|
+
/**
|
|
45
|
+
* Overrides the default modal frontstage.
|
|
46
|
+
* Use the {@link ModalFrontstage} component to customize the default layout and behavior.
|
|
47
|
+
* @alpha
|
|
48
|
+
*/
|
|
49
|
+
renderModalFrontstage?: (args: {
|
|
50
|
+
/** Information about the modal frontstage to be rendered. */
|
|
51
|
+
info: ModalFrontstageInfo;
|
|
52
|
+
/** Might be used for open/close animations in the future. */
|
|
53
|
+
isOpen: boolean;
|
|
54
|
+
}) => React.ReactNode;
|
|
43
55
|
/** @internal */
|
|
44
56
|
idleTimeout?: number;
|
|
45
57
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurableUiContent.d.ts","sourceRoot":"","sources":["../../../src/appui-react/configurableui/ConfigurableUiContent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAgCrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfigurableUiContent.d.ts","sourceRoot":"","sources":["../../../src/appui-react/configurableui/ConfigurableUiContent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAgCrD,OAAO,KAAK,EAAE,iBAAiB,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AGG;AACH,eAAO,MAAM,cAAc,4BAAkD,CAAC;AAE9E;;GAEG;AAEH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,qBAatE;AAED,UAAU,oBAAoB;IAC5B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,UAAU,mBAAmB;IAC3B;;;OAGG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE;QACb;;;;WAIG;QACH,eAAe,CAAC,EAAE,oBAAoB,CAAC;KACxC,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,qBA0FxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurableUiContent.js","sourceRoot":"","sources":["../../../src/appui-react/configurableui/ConfigurableUiContent.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+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,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,EAAE,QAAQ,EAAmC;IACnE,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,OAAO,CACL,oBAAC,wBAAwB,IAAC,gBAAgB,EAAE,MAAM,IAC/C,QAAQ,CACgB,CAC5B,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 ConfigurableUi\n */\n\nimport \"./ConfigurableUiContent.scss\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Point } from \"@itwin/core-react/internal\";\nimport {\n IModelConnectionProvider,\n QuantityEditorSpec,\n WeightEditorSpec,\n} from \"@itwin/imodel-components-react\";\nimport { ThemeProvider } from \"@itwin/itwinui-react\";\nimport { CursorInformation } from \"../cursor/CursorInformation.js\";\nimport { CursorPopupMenu } from \"../cursor/cursormenu/CursorMenu.js\";\nimport { CursorPopupRenderer } from \"../cursor/cursorpopup/CursorPopupManager.js\";\nimport { ModalDialogRenderer } from \"../dialog/ModalDialogManager.js\";\nimport { ModelessDialogRenderer } from \"../dialog/ModelessDialogManager.js\";\nimport { ElementTooltip } from \"../feedback/ElementTooltip.js\";\nimport { KeyboardShortcutMenu } from \"../keyboardshortcut/KeyboardShortcutMenu.js\";\nimport { InputFieldMessage } from \"../messages/InputField.js\";\nimport { PointerMessage } from \"../messages/Pointer.js\";\nimport { PopupRenderer } from \"../popup/PopupManager.js\";\nimport { WidgetPanelsFrontstage } from \"../widget-panels/Frontstage.js\";\nimport { ContentDialogRenderer } from \"../dialog/ContentDialogManager.js\";\nimport { appUi, UiFramework } from \"../UiFramework.js\";\nimport { InternalConfigurableUiManager } from \"./InternalConfigurableUiManager.js\";\nimport { MessageRenderer } from \"../messages/MessageRenderer.js\";\nimport {\n TOOLBAR_OPACITY_DEFAULT,\n WIDGET_OPACITY_DEFAULT,\n} from \"../theme/ThemeId.js\";\nimport { useReduxFrameworkState } from \"../uistate/useReduxFrameworkState.js\";\nimport type { ContentProps } from \"../content/ContentGroup.js\";\nimport { ChildWindowRenderer } from \"../childwindow/ChildWindowRenderer.js\";\nimport { useActiveFrontstageDef } from \"../frontstage/FrontstageDef.js\";\nimport type { WidgetActions } from \"../layout/widget/WidgetActions.js\";\nimport type { StagePanelSection } from \"../stagepanels/StagePanelSection.js\";\nimport type { StagePanelLocation } from \"../stagepanels/StagePanelLocation.js\";\nimport type { Widget } from \"../widgets/Widget.js\";\nimport type { WidgetState } from \"../widgets/WidgetState.js\";\nimport { useActiveIModelConnection } from \"../hooks/useActiveIModelConnection.js\";\nimport { EditorsRegistryProvider } from \"@itwin/components-react\";\nimport { AccuDrawStoreProvider } from \"../accudraw/AccuDrawStoreProvider.js\";\n\n/** @internal */\nexport const ConfigurableUiContext = React.createContext<\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n ConfigurableUiContentProps & {\n contentElementRef?: React.RefObject<HTMLElement | null>;\n widgetActions?: StandardLayoutProps[\"widgetActions\"];\n toolSettings?: StandardLayoutProps[\"toolSettings\"];\n }\n>({});\n\n/** Properties for [[ConfigurableUiContent]]\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof ConfigurableUiContent>`\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ConfigurableUiContentProps extends CommonProps {\n /** React node of the Backstage */\n appBackstage?: React.ReactNode;\n /** Controls if the view overlay should be displayed. Uses redux store as a fallback. Defaults to `true`.\n * @note Only used by configurable control APIs. See {@link ContentProps.classId}.\n * @deprecated in 4.16.0. View overlay visibility should be controlled by the components used in {@link ContentProps.content}.\n */\n viewOverlay?: boolean;\n /** Describes the opacity of widgets. Uses redux store as a fallback. Defaults to {@link WIDGET_OPACITY_DEFAULT}. */\n widgetOpacity?: number;\n /** Controls if the widget icons should be displayed. Uses redux store as a fallback. Defaults to `true`. */\n widgetIcon?: boolean;\n /** Controls if the active widget's label should always be displayed. Defaults to `false`. */\n showActiveWidgetLabel?: boolean;\n /** Controls if the unpinned panels should be collapsed automatically. Uses redux store as a fallback. Defaults to `false`. */\n collapsePanels?: boolean;\n /** Controls if the tool settings should be animated. Uses redux store as a fallback. Defaults to `false`. */\n animateToolSettings?: boolean;\n /** Controls if the tool settings label should be set based on activated tool. Uses redux store as a fallback. Defaults to `false`. */\n toolAsToolSettingsLabel?: boolean;\n /** Describes the opacity of toolbars. Uses redux store as a fallback. Defaults to {@link TOOLBAR_OPACITY_DEFAULT}. */\n toolbarOpacity?: number;\n /** Component to wrap all popout widgets and other child windows opened via {@link UiFramework.childWindows}. */\n childWindow?: React.ComponentType;\n\n /** @internal */\n idleTimeout?: number;\n /** @internal */\n intervalTimeout?: number;\n}\n\n/**\n * Allows children to get the bounds or other properties of the wrapper element.\n * @internal\n */\nexport const WrapperContext = React.createContext<HTMLElement>(document.body);\n\n/** The main component of `AppUI` that sets up the configurable UI.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function ConfigurableUiContent(props: ConfigurableUiContentProps) {\n const frontstageDef = useActiveFrontstageDef();\n const layout = frontstageDef?.initialConfig?.layout;\n return (\n <ConfigurableUiContext.Provider\n // eslint-disable-next-line react-hooks/exhaustive-deps\n value={React.useMemo(() => props, [...Object.values(props)])}\n >\n <AccuDrawStoreProvider>\n {layout ?? <StandardLayout />}\n </AccuDrawStoreProvider>\n </ConfigurableUiContext.Provider>\n );\n}\n\ninterface ToolSettingsLocation {\n section: StagePanelSection;\n location: StagePanelLocation;\n}\n\ninterface StandardLayoutProps {\n /** Overrides widget specific actions displayed in the title bar area.\n * Use {@link WidgetActions} component to customize widget actions.\n * @alpha\n */\n widgetActions?: React.ReactNode;\n /** When enabled keeps the tool settings visible to the end user.\n * This is especially useful when the tool settings is undocked as a regular widget.\n * @alpha\n */\n visibleToolSettings?: boolean;\n /** Tool settings related configuration.\n * @alpha\n */\n toolSettings?: {\n /** The default location of the tool settings. Only used when initializing the layout and ignored when restoring a saved layout.\n * When this is specified, the tool settings will be initialized as a widget, instead of the default docked state.\n * @note Use {@link Widget} for further configuration. I.e. set {@link Widget.defaultState} to {@link WidgetState.Floating} to initialize the tool settings as a floating widget.\n * @alpha\n */\n defaultLocation?: ToolSettingsLocation;\n };\n}\n\n/** The standard widget based layout used as a default layout for all frontstages.\n * @alpha\n */\nexport function StandardLayout(props: StandardLayoutProps) {\n const { widgetActions, visibleToolSettings = false, toolSettings } = props;\n const context = React.useContext(ConfigurableUiContext);\n const {\n appBackstage,\n widgetOpacity,\n toolbarOpacity,\n idleTimeout,\n intervalTimeout,\n } = context;\n\n const contentElementRef = React.useRef<HTMLElement>(null);\n useWidgetOpacity(widgetOpacity);\n useToolbarOpacity(toolbarOpacity);\n const [mainElement, setMainElement] = React.useState<HTMLElement>();\n const [portalContainer, setPortalContainer] = React.useState<HTMLElement>();\n React.useEffect(() => {\n UiFramework.keyboardShortcuts.setFocusToHome();\n }, []);\n\n React.useEffect(() => {\n InternalConfigurableUiManager.activityTracker.initialize({\n idleTimeout,\n intervalTimeout,\n });\n return () => {\n InternalConfigurableUiManager.activityTracker.terminate();\n };\n }, [idleTimeout, intervalTimeout]);\n useVisibleToolSettings(visibleToolSettings);\n\n return (\n <ConfigurableUiContext.Provider\n value={React.useMemo(\n () => ({\n ...context,\n contentElementRef,\n widgetActions,\n toolSettings,\n }),\n [context, widgetActions, toolSettings]\n )}\n >\n <main\n role=\"main\"\n id=\"uifw-configurableui-wrapper\"\n className={context.className}\n style={context.style}\n onMouseMove={(e) => {\n const point = new Point(e.pageX, e.pageY);\n CursorInformation.handleMouseMove(point, e.view.document);\n }}\n ref={(el) => setMainElement(el ?? undefined)}\n >\n <WrapperContext.Provider value={mainElement ?? document.body}>\n <ThemeProvider\n style={{ height: \"100%\" }}\n portalContainer={portalContainer}\n >\n <IModelProvider>\n <EditorsRegistryProvider editors={defaultEditors}>\n {appBackstage}\n <WidgetPanelsFrontstage />\n\n <PointerMessage />\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <KeyboardShortcutMenu />\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <InputFieldMessage />\n <CursorPopupMenu />\n <CursorPopupRenderer />\n <PopupRenderer />\n <ElementTooltip />\n <MessageRenderer />\n <ChildWindowRenderer windowManager={appUi.windowManager} />\n <div\n className=\"uifw-configurableui-portalContainer\"\n ref={(instance) => setPortalContainer(instance ?? undefined)}\n >\n <ContentDialogRenderer />\n <ModelessDialogRenderer />\n <ModalDialogRenderer />\n </div>\n </EditorsRegistryProvider>\n </IModelProvider>\n </ThemeProvider>\n </WrapperContext.Provider>\n </main>\n </ConfigurableUiContext.Provider>\n );\n}\n\nconst defaultEditors = [QuantityEditorSpec, WeightEditorSpec];\n\nfunction useWidgetOpacity(\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n widgetOpacity: ConfigurableUiContentProps[\"widgetOpacity\"]\n) {\n const reduxWidgetOpacity = useReduxFrameworkState((state) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return state?.configurableUiState.widgetOpacity;\n });\n const opacity = widgetOpacity ?? reduxWidgetOpacity ?? WIDGET_OPACITY_DEFAULT;\n\n React.useEffect(() => {\n const currentWidgetOpacity =\n document.documentElement.style.getPropertyValue(\"--buic-widget-opacity\");\n if (currentWidgetOpacity === opacity.toString()) return;\n document.documentElement.style.setProperty(\n \"--buic-widget-opacity\",\n opacity.toString()\n );\n return () => {\n document.documentElement.style.removeProperty(\"--buic-widget-opacity\");\n };\n }, [opacity]);\n}\n\nfunction useToolbarOpacity(\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n toolbarOpacity: ConfigurableUiContentProps[\"toolbarOpacity\"]\n) {\n const reduxToolbarOpacity = useReduxFrameworkState((state) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return state?.configurableUiState.toolbarOpacity;\n });\n\n const opacity =\n toolbarOpacity ?? reduxToolbarOpacity ?? TOOLBAR_OPACITY_DEFAULT;\n\n React.useEffect(() => {\n const currentToolbarOpacity =\n document.documentElement.style.getPropertyValue(\"--buic-toolbar-opacity\");\n if (currentToolbarOpacity === opacity.toString()) return;\n document.documentElement.style.setProperty(\n \"--buic-toolbar-opacity\",\n opacity.toString()\n );\n return () => {\n document.documentElement.style.removeProperty(\"--buic-toolbar-opacity\");\n };\n }, [opacity]);\n}\n\nfunction useVisibleToolSettings(enabled: boolean) {\n React.useEffect(() => {\n if (!enabled) return;\n return UiFramework.frontstages.onToolSettingsReloadEvent.addListener(() => {\n const frontstage = UiFramework.frontstages.activeFrontstageDef;\n const toolSettings = frontstage?.toolSettings;\n if (!toolSettings) return;\n toolSettings.show();\n });\n }, [enabled]);\n}\n\nfunction IModelProvider({ children }: React.PropsWithChildren<object>) {\n const imodel = useActiveIModelConnection();\n\n return (\n <IModelConnectionProvider iModelConnection={imodel}>\n {children}\n </IModelConnectionProvider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigurableUiContent.js","sourceRoot":"","sources":["../../../src/appui-react/configurableui/ConfigurableUiContent.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC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,YAAY;gBAAE,OAAO;YAC1B,YAAY,CAAC,IAAI,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,EAAE,QAAQ,EAAmC;IACnE,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,OAAO,CACL,oBAAC,wBAAwB,IAAC,gBAAgB,EAAE,MAAM,IAC/C,QAAQ,CACgB,CAC5B,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 ConfigurableUi\n */\n\nimport \"./ConfigurableUiContent.scss\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Point } from \"@itwin/core-react/internal\";\nimport {\n IModelConnectionProvider,\n QuantityEditorSpec,\n WeightEditorSpec,\n} from \"@itwin/imodel-components-react\";\nimport { ThemeProvider } from \"@itwin/itwinui-react\";\nimport { CursorInformation } from \"../cursor/CursorInformation.js\";\nimport { CursorPopupMenu } from \"../cursor/cursormenu/CursorMenu.js\";\nimport { CursorPopupRenderer } from \"../cursor/cursorpopup/CursorPopupManager.js\";\nimport { ModalDialogRenderer } from \"../dialog/ModalDialogManager.js\";\nimport { ModelessDialogRenderer } from \"../dialog/ModelessDialogManager.js\";\nimport { ElementTooltip } from \"../feedback/ElementTooltip.js\";\nimport { KeyboardShortcutMenu } from \"../keyboardshortcut/KeyboardShortcutMenu.js\";\nimport { InputFieldMessage } from \"../messages/InputField.js\";\nimport { PointerMessage } from \"../messages/Pointer.js\";\nimport { PopupRenderer } from \"../popup/PopupManager.js\";\nimport { WidgetPanelsFrontstage } from \"../widget-panels/Frontstage.js\";\nimport { ContentDialogRenderer } from \"../dialog/ContentDialogManager.js\";\nimport { appUi, UiFramework } from \"../UiFramework.js\";\nimport { InternalConfigurableUiManager } from \"./InternalConfigurableUiManager.js\";\nimport { MessageRenderer } from \"../messages/MessageRenderer.js\";\nimport {\n TOOLBAR_OPACITY_DEFAULT,\n WIDGET_OPACITY_DEFAULT,\n} from \"../theme/ThemeId.js\";\nimport { useReduxFrameworkState } from \"../uistate/useReduxFrameworkState.js\";\nimport type { ContentProps } from \"../content/ContentGroup.js\";\nimport { ChildWindowRenderer } from \"../childwindow/ChildWindowRenderer.js\";\nimport { useActiveFrontstageDef } from \"../frontstage/FrontstageDef.js\";\nimport type { WidgetActions } from \"../layout/widget/WidgetActions.js\";\nimport type { StagePanelSection } from \"../stagepanels/StagePanelSection.js\";\nimport type { StagePanelLocation } from \"../stagepanels/StagePanelLocation.js\";\nimport type { Widget } from \"../widgets/Widget.js\";\nimport type { WidgetState } from \"../widgets/WidgetState.js\";\nimport { useActiveIModelConnection } from \"../hooks/useActiveIModelConnection.js\";\nimport { EditorsRegistryProvider } from \"@itwin/components-react\";\nimport { AccuDrawStoreProvider } from \"../accudraw/AccuDrawStoreProvider.js\";\nimport type { ModalFrontstageInfo } from \"../framework/FrameworkFrontstages.js\";\nimport type { ModalFrontstage } from \"../frontstage/ModalFrontstage.js\";\n\n/** @internal */\nexport const ConfigurableUiContext = React.createContext<\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n ConfigurableUiContentProps & {\n contentElementRef?: React.RefObject<HTMLElement | null>;\n widgetActions?: StandardLayoutProps[\"widgetActions\"];\n toolSettings?: StandardLayoutProps[\"toolSettings\"];\n }\n>({});\n\n/** Properties for [[ConfigurableUiContent]]\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof ConfigurableUiContent>`\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ConfigurableUiContentProps extends CommonProps {\n /** React node of the Backstage */\n appBackstage?: React.ReactNode;\n /** Controls if the view overlay should be displayed. Uses redux store as a fallback. Defaults to `true`.\n * @note Only used by configurable control APIs. See {@link ContentProps.classId}.\n * @deprecated in 4.16.0. View overlay visibility should be controlled by the components used in {@link ContentProps.content}.\n */\n viewOverlay?: boolean;\n /** Describes the opacity of widgets. Uses redux store as a fallback. Defaults to {@link WIDGET_OPACITY_DEFAULT}. */\n widgetOpacity?: number;\n /** Controls if the widget icons should be displayed. Uses redux store as a fallback. Defaults to `true`. */\n widgetIcon?: boolean;\n /** Controls if the active widget's label should always be displayed. Defaults to `false`. */\n showActiveWidgetLabel?: boolean;\n /** Controls if the unpinned panels should be collapsed automatically. Uses redux store as a fallback. Defaults to `false`. */\n collapsePanels?: boolean;\n /** Controls if the tool settings should be animated. Uses redux store as a fallback. Defaults to `false`. */\n animateToolSettings?: boolean;\n /** Controls if the tool settings label should be set based on activated tool. Uses redux store as a fallback. Defaults to `false`. */\n toolAsToolSettingsLabel?: boolean;\n /** Describes the opacity of toolbars. Uses redux store as a fallback. Defaults to {@link TOOLBAR_OPACITY_DEFAULT}. */\n toolbarOpacity?: number;\n /** Component to wrap all popout widgets and other child windows opened via {@link UiFramework.childWindows}. */\n childWindow?: React.ComponentType;\n /**\n * Overrides the default modal frontstage.\n * Use the {@link ModalFrontstage} component to customize the default layout and behavior.\n * @alpha\n */\n renderModalFrontstage?: (args: {\n /** Information about the modal frontstage to be rendered. */\n info: ModalFrontstageInfo;\n /** Might be used for open/close animations in the future. */\n isOpen: boolean;\n }) => React.ReactNode;\n\n /** @internal */\n idleTimeout?: number;\n /** @internal */\n intervalTimeout?: number;\n}\n\n/**\n * Allows children to get the bounds or other properties of the wrapper element.\n * @internal\n */\nexport const WrapperContext = React.createContext<HTMLElement>(document.body);\n\n/** The main component of `AppUI` that sets up the configurable UI.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function ConfigurableUiContent(props: ConfigurableUiContentProps) {\n const frontstageDef = useActiveFrontstageDef();\n const layout = frontstageDef?.initialConfig?.layout;\n return (\n <ConfigurableUiContext.Provider\n // eslint-disable-next-line react-hooks/exhaustive-deps\n value={React.useMemo(() => props, [...Object.values(props)])}\n >\n <AccuDrawStoreProvider>\n {layout ?? <StandardLayout />}\n </AccuDrawStoreProvider>\n </ConfigurableUiContext.Provider>\n );\n}\n\ninterface ToolSettingsLocation {\n section: StagePanelSection;\n location: StagePanelLocation;\n}\n\ninterface StandardLayoutProps {\n /** Overrides widget specific actions displayed in the title bar area.\n * Use {@link WidgetActions} component to customize widget actions.\n * @alpha\n */\n widgetActions?: React.ReactNode;\n /** When enabled keeps the tool settings visible to the end user.\n * This is especially useful when the tool settings is undocked as a regular widget.\n * @alpha\n */\n visibleToolSettings?: boolean;\n /** Tool settings related configuration.\n * @alpha\n */\n toolSettings?: {\n /** The default location of the tool settings. Only used when initializing the layout and ignored when restoring a saved layout.\n * When this is specified, the tool settings will be initialized as a widget, instead of the default docked state.\n * @note Use {@link Widget} for further configuration. I.e. set {@link Widget.defaultState} to {@link WidgetState.Floating} to initialize the tool settings as a floating widget.\n * @alpha\n */\n defaultLocation?: ToolSettingsLocation;\n };\n}\n\n/** The standard widget based layout used as a default layout for all frontstages.\n * @alpha\n */\nexport function StandardLayout(props: StandardLayoutProps) {\n const { widgetActions, visibleToolSettings = false, toolSettings } = props;\n const context = React.useContext(ConfigurableUiContext);\n const {\n appBackstage,\n widgetOpacity,\n toolbarOpacity,\n idleTimeout,\n intervalTimeout,\n } = context;\n\n const contentElementRef = React.useRef<HTMLElement>(null);\n useWidgetOpacity(widgetOpacity);\n useToolbarOpacity(toolbarOpacity);\n const [mainElement, setMainElement] = React.useState<HTMLElement>();\n const [portalContainer, setPortalContainer] = React.useState<HTMLElement>();\n React.useEffect(() => {\n UiFramework.keyboardShortcuts.setFocusToHome();\n }, []);\n\n React.useEffect(() => {\n InternalConfigurableUiManager.activityTracker.initialize({\n idleTimeout,\n intervalTimeout,\n });\n return () => {\n InternalConfigurableUiManager.activityTracker.terminate();\n };\n }, [idleTimeout, intervalTimeout]);\n useVisibleToolSettings(visibleToolSettings);\n\n return (\n <ConfigurableUiContext.Provider\n value={React.useMemo(\n () => ({\n ...context,\n contentElementRef,\n widgetActions,\n toolSettings,\n }),\n [context, widgetActions, toolSettings]\n )}\n >\n <main\n role=\"main\"\n id=\"uifw-configurableui-wrapper\"\n className={context.className}\n style={context.style}\n onMouseMove={(e) => {\n const point = new Point(e.pageX, e.pageY);\n CursorInformation.handleMouseMove(point, e.view.document);\n }}\n ref={(el) => setMainElement(el ?? undefined)}\n >\n <WrapperContext.Provider value={mainElement ?? document.body}>\n <ThemeProvider\n style={{ height: \"100%\" }}\n portalContainer={portalContainer}\n >\n <IModelProvider>\n <EditorsRegistryProvider editors={defaultEditors}>\n {appBackstage}\n <WidgetPanelsFrontstage />\n\n <PointerMessage />\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <KeyboardShortcutMenu />\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <InputFieldMessage />\n <CursorPopupMenu />\n <CursorPopupRenderer />\n <PopupRenderer />\n <ElementTooltip />\n <MessageRenderer />\n <ChildWindowRenderer windowManager={appUi.windowManager} />\n <div\n className=\"uifw-configurableui-portalContainer\"\n ref={(instance) => setPortalContainer(instance ?? undefined)}\n >\n <ContentDialogRenderer />\n <ModelessDialogRenderer />\n <ModalDialogRenderer />\n </div>\n </EditorsRegistryProvider>\n </IModelProvider>\n </ThemeProvider>\n </WrapperContext.Provider>\n </main>\n </ConfigurableUiContext.Provider>\n );\n}\n\nconst defaultEditors = [QuantityEditorSpec, WeightEditorSpec];\n\nfunction useWidgetOpacity(\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n widgetOpacity: ConfigurableUiContentProps[\"widgetOpacity\"]\n) {\n const reduxWidgetOpacity = useReduxFrameworkState((state) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return state?.configurableUiState.widgetOpacity;\n });\n const opacity = widgetOpacity ?? reduxWidgetOpacity ?? WIDGET_OPACITY_DEFAULT;\n\n React.useEffect(() => {\n const currentWidgetOpacity =\n document.documentElement.style.getPropertyValue(\"--buic-widget-opacity\");\n if (currentWidgetOpacity === opacity.toString()) return;\n document.documentElement.style.setProperty(\n \"--buic-widget-opacity\",\n opacity.toString()\n );\n return () => {\n document.documentElement.style.removeProperty(\"--buic-widget-opacity\");\n };\n }, [opacity]);\n}\n\nfunction useToolbarOpacity(\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n toolbarOpacity: ConfigurableUiContentProps[\"toolbarOpacity\"]\n) {\n const reduxToolbarOpacity = useReduxFrameworkState((state) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return state?.configurableUiState.toolbarOpacity;\n });\n\n const opacity =\n toolbarOpacity ?? reduxToolbarOpacity ?? TOOLBAR_OPACITY_DEFAULT;\n\n React.useEffect(() => {\n const currentToolbarOpacity =\n document.documentElement.style.getPropertyValue(\"--buic-toolbar-opacity\");\n if (currentToolbarOpacity === opacity.toString()) return;\n document.documentElement.style.setProperty(\n \"--buic-toolbar-opacity\",\n opacity.toString()\n );\n return () => {\n document.documentElement.style.removeProperty(\"--buic-toolbar-opacity\");\n };\n }, [opacity]);\n}\n\nfunction useVisibleToolSettings(enabled: boolean) {\n React.useEffect(() => {\n if (!enabled) return;\n return UiFramework.frontstages.onToolSettingsReloadEvent.addListener(() => {\n const frontstage = UiFramework.frontstages.activeFrontstageDef;\n const toolSettings = frontstage?.toolSettings;\n if (!toolSettings) return;\n toolSettings.show();\n });\n }, [enabled]);\n}\n\nfunction IModelProvider({ children }: React.PropsWithChildren<object>) {\n const imodel = useActiveIModelConnection();\n\n return (\n <IModelConnectionProvider iModelConnection={imodel}>\n {children}\n </IModelConnectionProvider>\n );\n}\n"]}
|
|
@@ -6,29 +6,41 @@ import * as React from "react";
|
|
|
6
6
|
import type { CommonProps } from "@itwin/core-react";
|
|
7
7
|
/** Properties for the [[ModalFrontstage]] React component
|
|
8
8
|
* @public
|
|
9
|
+
* @deprecated in 5.31.0. Use `React.ComponentProps<typeof ModalFrontstage>` instead.
|
|
9
10
|
*/
|
|
10
11
|
export interface ModalFrontstageProps extends CommonProps {
|
|
11
|
-
/** Title displayed at the top of the modal
|
|
12
|
+
/** Title displayed at the top of the modal frontstage. */
|
|
12
13
|
title: string;
|
|
13
|
-
/** Indicates whether the modal
|
|
14
|
+
/** Indicates whether the modal frontstage is open. */
|
|
14
15
|
isOpen?: boolean;
|
|
15
|
-
/** Callback for navigating back from the modal
|
|
16
|
-
navigateBack?: () =>
|
|
17
|
-
/** Callback for closing the modal
|
|
18
|
-
closeModal: () =>
|
|
19
|
-
/**
|
|
16
|
+
/** Callback for navigating back from the modal frontstage. */
|
|
17
|
+
navigateBack?: () => void;
|
|
18
|
+
/** Callback for closing the modal frontstage. */
|
|
19
|
+
closeModal: () => void;
|
|
20
|
+
/** Optional content displayed in the upper right of the modal frontstage. */
|
|
20
21
|
appBarRight?: React.ReactNode;
|
|
21
|
-
/** If specified overrides the default
|
|
22
|
+
/** If specified overrides the default {@link ModalFrontstageButton}. */
|
|
22
23
|
backButton?: React.ReactNode;
|
|
23
|
-
/** Content */
|
|
24
|
+
/** Content of the modal frontstage. */
|
|
24
25
|
children?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* If `true`, hides the header of the modal frontstage and renders the `children` prop in the root element.
|
|
28
|
+
* @note When set to `true`, the `title`, `navigateBack`, `closeModal`, `appBarRight`, and `backButton` props are ignored.
|
|
29
|
+
*/
|
|
30
|
+
hideHeader?: boolean;
|
|
25
31
|
}
|
|
26
|
-
|
|
32
|
+
interface Props extends Omit<ModalFrontstageProps, "closeModal"> {
|
|
33
|
+
/**
|
|
34
|
+
* Callback for closing the modal Frontstage.
|
|
35
|
+
* @deprecated in 5.31.0. Use `navigateBack` prop instead.
|
|
36
|
+
*/
|
|
37
|
+
closeModal?: () => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The default layout used for modal frontstages.
|
|
41
|
+
* Use `renderModalFrontstage` prop of {@link ConfigurableUiContent} to override the modal frontstage layout.
|
|
27
42
|
* @public
|
|
28
43
|
*/
|
|
29
|
-
export declare
|
|
30
|
-
|
|
31
|
-
private _onGoBack;
|
|
32
|
-
render(): React.JSX.Element;
|
|
33
|
-
}
|
|
44
|
+
export declare function ModalFrontstage(props: Props): React.JSX.Element;
|
|
45
|
+
export {};
|
|
34
46
|
//# sourceMappingURL=ModalFrontstage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalFrontstage.d.ts","sourceRoot":"","sources":["../../../src/appui-react/frontstage/ModalFrontstage.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ModalFrontstage.d.ts","sourceRoot":"","sources":["../../../src/appui-react/frontstage/ModalFrontstage.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD;;;GAGG;AAEH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,iDAAiD;IACjD,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,wEAAwE;IACxE,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,uCAAuC;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAGD,UAAU,KAAM,SAAQ,IAAI,CAAC,oBAAoB,EAAE,YAAY,CAAC;IAC9D;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,qBAkD3C"}
|
|
@@ -10,28 +10,24 @@ import * as React from "react";
|
|
|
10
10
|
import classnames from "classnames";
|
|
11
11
|
import { Text } from "@itwin/itwinui-react";
|
|
12
12
|
import { ModalFrontstageButton } from "./ModalFrontstageButton.js";
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* The default layout used for modal frontstages.
|
|
15
|
+
* Use `renderModalFrontstage` prop of {@link ConfigurableUiContent} to override the modal frontstage layout.
|
|
14
16
|
* @public
|
|
15
17
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.props.closeModal();
|
|
18
|
+
export function ModalFrontstage(props) {
|
|
19
|
+
const { isOpen, navigateBack,
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
21
|
+
closeModal, backButton, title, appBarRight, hideHeader, ...rest } = props;
|
|
22
|
+
const handleBack = () => {
|
|
23
|
+
navigateBack?.();
|
|
24
|
+
closeModal?.();
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
React.createElement(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
React.createElement(Text, { variant: "headline", className: "uifw-headline" }, this.props.title),
|
|
32
|
-
this.props.appBarRight && (React.createElement("span", { className: "uifw-modal-app-bar-right" }, this.props.appBarRight))),
|
|
33
|
-
React.createElement("div", { className: "uifw-modal-stage-content" }, this.props.children)),
|
|
34
|
-
React.createElement("div", { className: "uifw-modal-frontstage-overlay" })));
|
|
35
|
-
}
|
|
26
|
+
return (React.createElement("div", { ...rest, className: classnames("uifw-modal-frontstage", isOpen && "uifw-modal-open", hideHeader && "uifw-no-header", props.className) }, hideHeader ? (props.children) : (React.createElement(React.Fragment, null,
|
|
27
|
+
React.createElement("div", { className: "uifw-modal-app-bar" },
|
|
28
|
+
backButton ? (backButton) : (React.createElement(ModalFrontstageButton, { onClick: handleBack })),
|
|
29
|
+
React.createElement(Text, { variant: "headline", className: "uifw-headline" }, title),
|
|
30
|
+
appBarRight && (React.createElement("span", { className: "uifw-modal-app-bar-right" }, appBarRight))),
|
|
31
|
+
React.createElement("div", { className: "uifw-modal-stage-content" }, props.children)))));
|
|
36
32
|
}
|
|
37
33
|
//# sourceMappingURL=ModalFrontstage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalFrontstage.js","sourceRoot":"","sources":["../../../src/appui-react/frontstage/ModalFrontstage.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"ModalFrontstage.js","sourceRoot":"","sources":["../../../src/appui-react/frontstage/ModalFrontstage.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAuCnE;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAY;IAC1C,MAAM,EACJ,MAAM,EACN,YAAY;IACZ,4DAA4D;IAC5D,UAAU,EACV,UAAU,EACV,KAAK,EACL,WAAW,EACX,UAAU,EACV,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IAEV,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,YAAY,EAAE,EAAE,CAAC;QACjB,UAAU,EAAE,EAAE,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO,CACL,gCACM,IAAI,EACR,SAAS,EAAE,UAAU,CACnB,uBAAuB,EACvB,MAAM,IAAI,iBAAiB,EAC3B,UAAU,IAAI,gBAAgB,EAC9B,KAAK,CAAC,SAAS,CAChB,IAEA,UAAU,CAAC,CAAC,CAAC,CACZ,KAAK,CAAC,QAAQ,CACf,CAAC,CAAC,CAAC,CACF;QACE,6BAAK,SAAS,EAAC,oBAAoB;YAChC,UAAU,CAAC,CAAC,CAAC,CACZ,UAAU,CACX,CAAC,CAAC,CAAC,CACF,oBAAC,qBAAqB,IAAC,OAAO,EAAE,UAAU,GAAI,CAC/C;YACD,oBAAC,IAAI,IAAC,OAAO,EAAC,UAAU,EAAC,SAAS,EAAC,eAAe,IAC/C,KAAK,CACD;YACN,WAAW,IAAI,CACd,8BAAM,SAAS,EAAC,0BAA0B,IAAE,WAAW,CAAQ,CAChE,CACG;QACN,6BAAK,SAAS,EAAC,0BAA0B,IAAE,KAAK,CAAC,QAAQ,CAAO,CAC/D,CACJ,CACG,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 Frontstage\n */\n\nimport \"./ModalFrontstage.scss\";\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { ModalFrontstageButton } from \"./ModalFrontstageButton.js\";\nimport type { ConfigurableUiContent } from \"../configurableui/ConfigurableUiContent.js\";\n\n/** Properties for the [[ModalFrontstage]] React component\n * @public\n * @deprecated in 5.31.0. Use `React.ComponentProps<typeof ModalFrontstage>` instead.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ModalFrontstageProps extends CommonProps {\n /** Title displayed at the top of the modal frontstage. */\n title: string;\n /** Indicates whether the modal frontstage is open. */\n isOpen?: boolean;\n /** Callback for navigating back from the modal frontstage. */\n navigateBack?: () => void;\n /** Callback for closing the modal frontstage. */\n closeModal: () => void;\n /** Optional content displayed in the upper right of the modal frontstage. */\n appBarRight?: React.ReactNode;\n /** If specified overrides the default {@link ModalFrontstageButton}. */\n backButton?: React.ReactNode;\n /** Content of the modal frontstage. */\n children?: React.ReactNode;\n /**\n * If `true`, hides the header of the modal frontstage and renders the `children` prop in the root element.\n * @note When set to `true`, the `title`, `navigateBack`, `closeModal`, `appBarRight`, and `backButton` props are ignored.\n */\n hideHeader?: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\ninterface Props extends Omit<ModalFrontstageProps, \"closeModal\"> {\n /**\n * Callback for closing the modal Frontstage.\n * @deprecated in 5.31.0. Use `navigateBack` prop instead.\n */\n closeModal?: () => void;\n}\n\n/**\n * The default layout used for modal frontstages.\n * Use `renderModalFrontstage` prop of {@link ConfigurableUiContent} to override the modal frontstage layout.\n * @public\n */\nexport function ModalFrontstage(props: Props) {\n const {\n isOpen,\n navigateBack,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n closeModal,\n backButton,\n title,\n appBarRight,\n hideHeader,\n ...rest\n } = props;\n\n const handleBack = () => {\n navigateBack?.();\n closeModal?.();\n };\n\n return (\n <div\n {...rest}\n className={classnames(\n \"uifw-modal-frontstage\",\n isOpen && \"uifw-modal-open\",\n hideHeader && \"uifw-no-header\",\n props.className\n )}\n >\n {hideHeader ? (\n props.children\n ) : (\n <>\n <div className=\"uifw-modal-app-bar\">\n {backButton ? (\n backButton\n ) : (\n <ModalFrontstageButton onClick={handleBack} />\n )}\n <Text variant=\"headline\" className=\"uifw-headline\">\n {title}\n </Text>\n {appBarRight && (\n <span className=\"uifw-modal-app-bar-right\">{appBarRight}</span>\n )}\n </div>\n <div className=\"uifw-modal-stage-content\">{props.children}</div>\n </>\n )}\n </div>\n );\n}\n"]}
|