@itwin/appui-react 5.31.0 → 5.32.1
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 +26 -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/frontstage/ModalFrontstage.d.ts +1 -1
- package/lib/appui-react/frontstage/ModalFrontstage.js.map +1 -1
- package/lib/cjs/appui-react/backstage/Backstage.scss +42 -0
- package/lib/esm/appui-react/backstage/Backstage.scss +42 -0
- 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
|
+
//# sourceMappingURL=Backstage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Backstage.js","sourceRoot":"","sources":["../../../src/appui-react/backstage/Backstage.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAe5D,gBAAgB;AAChB,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GA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AC,CAAC,CAAC;IAC5B,MAAM,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;IACnD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,QAAQ,CAC/C,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,KAAK,kBAAkB,CACrD,CAAC;IACF,OAAO,CACL,oBAAC,aAAa,IACZ,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,QAAQ,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;I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;IAEtE,MAAM,sBAAsB,GAAG,KAAK,CAAC,OAAO,CAC1C,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,EACxE,CAAC,YAAY,EAAE,UAAU,EAAE,KAAK,CAAC,kBAAkB,CAAC,CACrD,CAAC;IACF,MAAM,MAAM,GAAG,eAAe,CAAC,sBAAsB,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;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,cAAc,EACd,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,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,aAAa,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YAC9D,IA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,EACpB,WAAW,EAAE,WAAW,KACpB,IAAI;QAEP,MAAM;QACN,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE;YACrC,OAAO,CACL,oBAAC,cAAc,IAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,IAC/C,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;gBAClC,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"]}
|
|
@@ -32,7 +32,7 @@ export interface ModalFrontstageProps extends CommonProps {
|
|
|
32
32
|
interface Props extends Omit<ModalFrontstageProps, "closeModal"> {
|
|
33
33
|
/**
|
|
34
34
|
* Callback for closing the modal Frontstage.
|
|
35
|
-
* @deprecated in 5.31.0. Use
|
|
35
|
+
* @deprecated in 5.31.0. Use `navigateBack` prop instead.
|
|
36
36
|
*/
|
|
37
37
|
closeModal?: () => void;
|
|
38
38
|
}
|
|
@@ -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;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
|
|
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"]}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"backstage": {
|
|
3
|
+
"label": "Backstage"
|
|
4
|
+
},
|
|
2
5
|
"iModelPanelHeader": {
|
|
3
6
|
"projects": "Projects"
|
|
4
7
|
},
|
|
@@ -124,7 +127,7 @@
|
|
|
124
127
|
"yes": "Yes",
|
|
125
128
|
"no": "No",
|
|
126
129
|
"clearSelection": "Clear Selection",
|
|
127
|
-
"openBackstageMenu": "Open backstage
|
|
130
|
+
"openBackstageMenu": "Open backstage"
|
|
128
131
|
},
|
|
129
132
|
"navigationAid": {
|
|
130
133
|
"sheetsModalFrontstage": "Sheet Views"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/appui-react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.32.1",
|
|
4
4
|
"description": "A react component library for AppUI framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./lib/appui-react.d.ts",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
46
46
|
"react-redux": "^7.2.2 || ^8.0.0 || ^9.0.0",
|
|
47
47
|
"redux": "^4.1.0 || ^5.0.0",
|
|
48
|
-
"@itwin/components-react": "5.
|
|
49
|
-
"@itwin/core-react": "5.
|
|
50
|
-
"@itwin/imodel-components-react": "5.
|
|
48
|
+
"@itwin/components-react": "5.32.1",
|
|
49
|
+
"@itwin/core-react": "5.32.1",
|
|
50
|
+
"@itwin/imodel-components-react": "5.32.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@itwin/appui-abstract": "^5.8.1",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"typescript": "~5.6.3",
|
|
90
90
|
"upath": "^2.0.1",
|
|
91
91
|
"vitest": "^3.2.4",
|
|
92
|
-
"@itwin/components-react": "5.
|
|
93
|
-
"@itwin/
|
|
94
|
-
"@itwin/
|
|
92
|
+
"@itwin/components-react": "5.32.1",
|
|
93
|
+
"@itwin/core-react": "5.32.1",
|
|
94
|
+
"@itwin/imodel-components-react": "5.32.1"
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
97
|
"@itwin/itwinui-icons-react": "^2.11.0",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Backstage
|
|
3
|
-
*/
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
import type { BackstageActionItem, BackstageItem, BackstageStageLauncher } from "./BackstageItem.js";
|
|
6
|
-
/** @internal */
|
|
7
|
-
export interface BackstageComposerActionItemProps {
|
|
8
|
-
readonly item: BackstageActionItem;
|
|
9
|
-
}
|
|
10
|
-
/** @internal */
|
|
11
|
-
export declare function BackstageComposerActionItem({ item, }: BackstageComposerActionItemProps): React.JSX.Element;
|
|
12
|
-
/** @internal */
|
|
13
|
-
export interface BackstageComposerStageLauncherProps {
|
|
14
|
-
readonly item: BackstageStageLauncher;
|
|
15
|
-
}
|
|
16
|
-
/** @internal */
|
|
17
|
-
export declare function BackstageComposerStageLauncher({ item, }: BackstageComposerStageLauncherProps): React.JSX.Element;
|
|
18
|
-
/** Props of [[BackstageComposerItem]] component.
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
export interface BackstageComposerItemProps {
|
|
22
|
-
/** Backstage item to render */
|
|
23
|
-
readonly item: BackstageItem;
|
|
24
|
-
}
|
|
25
|
-
/** Item of [[BackstageComposer]].
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export declare function BackstageComposerItem({ item }: BackstageComposerItemProps): React.JSX.Element;
|
|
29
|
-
//# sourceMappingURL=BackstageComposerItem.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BackstageComposerItem.d.ts","sourceRoot":"","sources":["../../../src/appui-react/backstage/BackstageComposerItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AASH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EAEvB,MAAM,oBAAoB,CAAC;AAK5B,gBAAgB;AAChB,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;CACpC;AAED,gBAAgB;AAChB,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,GACL,EAAE,gCAAgC,qBAwBlC;AAED,gBAAgB;AAChB,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;CACvC;AAED,gBAAgB;AAChB,wBAAgB,8BAA8B,CAAC,EAC7C,IAAI,GACL,EAAE,mCAAmC,qBAiCrC;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,IAAI,EAAE,EAAE,0BAA0B,qBAKzE"}
|
|
@@ -1,66 +0,0 @@
|
|
|
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 { ConditionalBooleanValue, ConditionalStringValue, } from "@itwin/appui-abstract";
|
|
9
|
-
import { Logger } from "@itwin/core-bentley";
|
|
10
|
-
import { Icon as CoreIcon } from "@itwin/core-react";
|
|
11
|
-
import { Badge } from "@itwin/core-react/internal";
|
|
12
|
-
import * as React from "react";
|
|
13
|
-
import { UiFramework } from "../UiFramework.js";
|
|
14
|
-
import { useActiveFrontstageId } from "../frontstage/FrontstageDef.js";
|
|
15
|
-
import { BackstageItem as NZ_BackstageItem } from "../layout/backstage/Item.js";
|
|
16
|
-
import { isProviderItem } from "../ui-items-provider/isProviderItem.js";
|
|
17
|
-
import { isBackstageStageLauncher } from "./BackstageItem.js";
|
|
18
|
-
import { useBackstageManager } from "./BackstageManager.js";
|
|
19
|
-
import { Icon } from "@itwin/itwinui-react";
|
|
20
|
-
/** @internal */
|
|
21
|
-
export function BackstageComposerActionItem({ item, }) {
|
|
22
|
-
const manager = useBackstageManager();
|
|
23
|
-
const handleClick = React.useCallback(() => {
|
|
24
|
-
manager.close();
|
|
25
|
-
item.execute();
|
|
26
|
-
}, [manager, item]);
|
|
27
|
-
return (React.createElement(NZ_BackstageItem, { itemId: item.id, providerId: isProviderItem(item) ? item.providerId : undefined, itemPriority: item.itemPriority, groupPriority: item.groupPriority,
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
29
|
-
icon: React.createElement(ItemIcon, { iconNode: item.iconNode, icon: item.icon }), isActive: ConditionalBooleanValue.getValue(item.isActive), isDisabled: ConditionalBooleanValue.getValue(item.isDisabled), onClick: handleClick, subtitle: ConditionalStringValue.getValue(item.subtitle),
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
31
|
-
badge: React.createElement(Badge, { type: item.badgeKind || item.badge }) }, ConditionalStringValue.getValue(item.label)));
|
|
32
|
-
}
|
|
33
|
-
/** @internal */
|
|
34
|
-
export function BackstageComposerStageLauncher({ item, }) {
|
|
35
|
-
const manager = useBackstageManager();
|
|
36
|
-
const handleClick = React.useCallback(() => {
|
|
37
|
-
manager.close();
|
|
38
|
-
if (!UiFramework.frontstages.hasFrontstage(item.stageId))
|
|
39
|
-
return Logger.logError("BackstageComposerStageLauncher", `Frontstage with id '${item.stageId}' not found`);
|
|
40
|
-
void UiFramework.frontstages.setActiveFrontstage(item.stageId);
|
|
41
|
-
}, [manager, item.stageId]);
|
|
42
|
-
const activeFrontstageId = useActiveFrontstageId();
|
|
43
|
-
const isActive = ConditionalBooleanValue.getValue(item.isActive ?? item.stageId === activeFrontstageId);
|
|
44
|
-
return (React.createElement(NZ_BackstageItem, { itemId: item.id, providerId: isProviderItem(item) ? item.providerId : undefined, itemPriority: item.itemPriority, groupPriority: item.groupPriority,
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
46
|
-
icon: React.createElement(ItemIcon, { iconNode: item.iconNode, icon: item.icon }), isActive: isActive, isDisabled: ConditionalBooleanValue.getValue(item.isDisabled), onClick: handleClick, subtitle: ConditionalStringValue.getValue(item.subtitle),
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
48
|
-
badge: React.createElement(Badge, { type: item.badgeKind || item.badge }) }, ConditionalStringValue.getValue(item.label)));
|
|
49
|
-
}
|
|
50
|
-
/** Item of [[BackstageComposer]].
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
|
-
export function BackstageComposerItem({ item }) {
|
|
54
|
-
if (isBackstageStageLauncher(item)) {
|
|
55
|
-
return React.createElement(BackstageComposerStageLauncher, { item: item });
|
|
56
|
-
}
|
|
57
|
-
return React.createElement(BackstageComposerActionItem, { item: item });
|
|
58
|
-
}
|
|
59
|
-
function ItemIcon({ icon, iconNode, }) {
|
|
60
|
-
if (iconNode) {
|
|
61
|
-
return React.createElement(Icon, null, iconNode);
|
|
62
|
-
}
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
64
|
-
return React.createElement(CoreIcon, { iconSpec: icon });
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=BackstageComposerItem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BackstageComposerItem.js","sourceRoot":"","sources":["../../../src/appui-react/backstage/BackstageComposerItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAOxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAO5C,gBAAgB;AAChB,MAAM,UAAU,2BAA2B,CAAC,EAC1C,IAAI,GAC6B;IACjC,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IACtC,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,C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UAAU,qBAAqB,CAAC,EAAE,IAAI,EAA8B;IACxE,IAAI,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,OAAO,oBAAC,8BAA8B,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC;IACxD,CAAC;IACD,OAAO,oBAAC,2BAA2B,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC;AACrD,CAAC;AAED,SAAS,QAAQ,CAAC,EAChB,IAAI,EACJ,QAAQ,GAIT;IACC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,oBAAC,IAAI,QAAE,QAAQ,CAAQ,CAAC;IACjC,CAAC;IAED,4DAA4D;IAC5D,OAAO,oBAAC,QAAQ,IAAC,QAAQ,EAAE,IAAI,GAAI,CAAC;AACtC,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 {\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 * as React from \"react\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport { useActiveFrontstageId } from \"../frontstage/FrontstageDef.js\";\nimport { BackstageItem as NZ_BackstageItem } from \"../layout/backstage/Item.js\";\nimport { isProviderItem } from \"../ui-items-provider/isProviderItem.js\";\nimport type {\n BackstageActionItem,\n BackstageItem,\n BackstageStageLauncher,\n CommonBackstageItem,\n} from \"./BackstageItem.js\";\nimport { isBackstageStageLauncher } from \"./BackstageItem.js\";\nimport { useBackstageManager } from \"./BackstageManager.js\";\nimport { Icon } from \"@itwin/itwinui-react\";\n\n/** @internal */\nexport interface BackstageComposerActionItemProps {\n readonly item: BackstageActionItem;\n}\n\n/** @internal */\nexport function BackstageComposerActionItem({\n item,\n}: BackstageComposerActionItemProps) {\n const manager = useBackstageManager();\n const handleClick = React.useCallback(() => {\n manager.close();\n item.execute();\n }, [manager, item]);\n return (\n <NZ_BackstageItem\n itemId={item.id}\n providerId={isProviderItem(item) ? item.providerId : undefined}\n itemPriority={item.itemPriority}\n groupPriority={item.groupPriority}\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n icon={<ItemIcon iconNode={item.iconNode} icon={item.icon} />}\n isActive={ConditionalBooleanValue.getValue(item.isActive)}\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\n onClick={handleClick}\n subtitle={ConditionalStringValue.getValue(item.subtitle)}\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n badge={<Badge type={item.badgeKind || item.badge} />}\n >\n {ConditionalStringValue.getValue(item.label)}\n </NZ_BackstageItem>\n );\n}\n\n/** @internal */\nexport interface BackstageComposerStageLauncherProps {\n readonly item: BackstageStageLauncher;\n}\n\n/** @internal */\nexport function BackstageComposerStageLauncher({\n item,\n}: BackstageComposerStageLauncherProps) {\n const manager = useBackstageManager();\n const handleClick = React.useCallback(() => {\n manager.close();\n if (!UiFramework.frontstages.hasFrontstage(item.stageId))\n return Logger.logError(\n \"BackstageComposerStageLauncher\",\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 <NZ_BackstageItem\n itemId={item.id}\n providerId={isProviderItem(item) ? item.providerId : undefined}\n itemPriority={item.itemPriority}\n groupPriority={item.groupPriority}\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n icon={<ItemIcon iconNode={item.iconNode} icon={item.icon} />}\n isActive={isActive}\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\n onClick={handleClick}\n subtitle={ConditionalStringValue.getValue(item.subtitle)}\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n badge={<Badge type={item.badgeKind || item.badge} />}\n >\n {ConditionalStringValue.getValue(item.label)}\n </NZ_BackstageItem>\n );\n}\n\n/** Props of [[BackstageComposerItem]] component.\n * @internal\n */\nexport interface BackstageComposerItemProps {\n /** Backstage item to render */\n readonly item: BackstageItem;\n}\n\n/** Item of [[BackstageComposer]].\n * @internal\n */\nexport function BackstageComposerItem({ item }: BackstageComposerItemProps) {\n if (isBackstageStageLauncher(item)) {\n return <BackstageComposerStageLauncher item={item} />;\n }\n return <BackstageComposerActionItem item={item} />;\n}\n\nfunction ItemIcon({\n icon,\n iconNode,\n}: {\n icon: CommonBackstageItem[\"icon\"];\n iconNode: CommonBackstageItem[\"iconNode\"];\n}) {\n if (iconNode) {\n return <Icon>{iconNode}</Icon>;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return <CoreIcon iconSpec={icon} />;\n}\n"]}
|