@itwin/appui-react 4.16.2 → 4.16.3
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 +8 -1
- package/lib/cjs/appui-react/shared/MenuItem.d.ts +2 -2
- package/lib/cjs/appui-react/shared/MenuItem.d.ts.map +1 -1
- package/lib/cjs/appui-react/shared/MenuItem.js +4 -11
- package/lib/cjs/appui-react/shared/MenuItem.js.map +1 -1
- package/lib/esm/appui-react/shared/MenuItem.d.ts +2 -2
- package/lib/esm/appui-react/shared/MenuItem.d.ts.map +1 -1
- package/lib/esm/appui-react/shared/MenuItem.js +4 -11
- package/lib/esm/appui-react/shared/MenuItem.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @itwin/appui-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 03 Sep 2024 14:32:22 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.16.3
|
|
6
|
+
Tue, 03 Sep 2024 14:32:22 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Render `MenuItem` without `item` or `submenu` props.
|
|
4
11
|
|
|
5
12
|
## 4.16.2
|
|
6
13
|
Wed, 28 Aug 2024 06:32:12 GMT
|
|
@@ -21,13 +21,13 @@ export interface CursorMenuItemProps extends CommonProps {
|
|
|
21
21
|
* @deprecated in 4.16.0. Use {@link CursorMenuItemProps.iconNode} instead.
|
|
22
22
|
*/
|
|
23
23
|
iconSpec?: IconSpec;
|
|
24
|
-
/** The item to execute when this item is invoked. Either 'item'
|
|
24
|
+
/** The item to execute when this item is invoked. Either 'item', 'submenu' or `execute` must be specified.
|
|
25
25
|
* @deprecated in 4.15.0. Use properties of this object instead.
|
|
26
26
|
*/
|
|
27
27
|
item?: CommandItemProps;
|
|
28
28
|
/** Function to execute. */
|
|
29
29
|
execute?: () => any;
|
|
30
|
-
/** Nested array of item props. Either 'item' or '
|
|
30
|
+
/** Nested array of item props. Either 'item', 'submenu' or 'execute' must be specified. */
|
|
31
31
|
submenu?: CursorMenuItemProps[];
|
|
32
32
|
/** Icon to display on right side of the menu item.
|
|
33
33
|
* Name of icon WebFont entry or if specifying an imported SVG symbol use "webSvg:" prefix to imported symbol Id.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/shared/MenuItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAW,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE;;GAEG;AAEH,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;OAEG;IAEH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;OAEG;IAEH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC;IACpB,
|
|
1
|
+
{"version":3,"file":"MenuItem.d.ts","sourceRoot":"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,EAAE,EACpC,WAAW,CAAC,EAAE,MAAM,IAAI,GACvB,QAAQ,EAAE;WAQC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE;IAW1E,OAAO,CAAC,MAAM,CAAC,kBAAkB;CA4ClC"}
|
|
@@ -98,24 +98,17 @@ class MenuItemHelpers {
|
|
|
98
98
|
return itemNodes;
|
|
99
99
|
}
|
|
100
100
|
static createMenuItemNode(item, index) {
|
|
101
|
-
let node = null;
|
|
102
101
|
const label = item.label;
|
|
103
102
|
const iconSpec = item.iconSpec;
|
|
104
103
|
const iconRightSpec = item.iconRightSpec;
|
|
105
104
|
const badgeType = item.badgeType;
|
|
106
105
|
const badgeKind = item.badgeKind;
|
|
107
106
|
const isDisabled = appui_abstract_1.ConditionalBooleanValue.getValue(item.isDisabled);
|
|
108
|
-
if (item.
|
|
109
|
-
const
|
|
110
|
-
|
|
107
|
+
if (item.submenu && item.submenu.length > 0) {
|
|
108
|
+
const items = this.createMenuItemNodes(item.submenu);
|
|
109
|
+
return (React.createElement(core_react_1.ContextSubMenu, { key: index, icon: iconSpec, label: label, badgeType: badgeType, badgeKind: badgeKind, disabled: isDisabled }, items));
|
|
111
110
|
}
|
|
112
|
-
|
|
113
|
-
if (item.submenu && item.submenu.length > 0) {
|
|
114
|
-
const items = this.createMenuItemNodes(item.submenu);
|
|
115
|
-
node = (React.createElement(core_react_1.ContextSubMenu, { key: index, icon: iconSpec, label: label, badgeType: badgeType, badgeKind: badgeKind, disabled: isDisabled }, items));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return node;
|
|
111
|
+
return (React.createElement(core_react_1.ContextMenuItem, { key: index, onSelect: () => item.itemPicked(), icon: iconSpec, iconRight: iconRightSpec, badgeType: badgeType, badgeKind: badgeKind, disabled: isDisabled }, label));
|
|
119
112
|
}
|
|
120
113
|
}
|
|
121
114
|
exports.MenuItemHelpers = MenuItemHelpers;
|
|
@@ -1 +1 @@
|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AS,EACpB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,UAAU,IAEnB,KAAK,CACU,CACnB,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAErD,IAAI,GAAG,CACL,oBAAC,2BAAc,IACb,GAAG,EAAE,KAAK,EACV,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,UAAU,IAEnB,KAAK,CACS,CAClB,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAzED,0CAyEC","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 Item\n */\n\nimport * as React from \"react\";\nimport type {\n AbstractMenuItemProps,\n StringGetter,\n} from \"@itwin/appui-abstract\";\nimport { ConditionalBooleanValue, UiError } from \"@itwin/appui-abstract\";\nimport type {\n BadgeKind,\n BadgeType,\n CommonProps,\n IconSpec,\n} from \"@itwin/core-react\";\nimport { ContextMenuItem, ContextSubMenu } from \"@itwin/core-react\";\nimport { UiFramework } from \"../UiFramework\";\nimport type { ActionButtonItemDef } from \"./ActionButtonItemDef\";\nimport { CommandItemDef } from \"./CommandItemDef\";\nimport { ItemDefBase } from \"./ItemDefBase\";\nimport type { CommandItemProps } from \"./ItemProps\";\nimport type { ConditionalStringValue } from \"./ConditionalValue\";\n\n/** Properties for context menu items.\n * @public\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface CursorMenuItemProps extends CommonProps {\n /** The id for the menu item. */\n id: string;\n /** Icon to display. */\n iconNode?: React.ReactNode;\n /** Icon to display.\n * @deprecated in 4.16.0. Use {@link CursorMenuItemProps.iconNode} instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n iconSpec?: IconSpec;\n /** The item to execute when this item is invoked. Either 'item' or 'submenu' must be specified.\n * @deprecated in 4.15.0. Use properties of this object instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n item?: CommandItemProps;\n /** Function to execute. */\n execute?: () => any;\n /** Nested array of item props. Either 'item' or 'submenu' must be specified. */\n submenu?: CursorMenuItemProps[];\n /** Icon to display on right side of the menu item.\n * Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id.\n */\n iconRight?: string | ConditionalStringValue;\n\n // #region \"ItemProps\" properties previously extended from deprecated type.\n\n /** if true component will be hidden - defaults to false */\n isHidden?: boolean | ConditionalBooleanValue;\n /** if true component will be disabled - defaults to false */\n isDisabled?: boolean | ConditionalBooleanValue;\n /** if set, component will be considered \"active\" an will display an \"active stripe\" - defaults to false */\n isActive?: boolean;\n /** if set, component will be considered selected but will NOT display an \"active stripe\" - defaults to false. Typically used by buttons that toggle between two states. */\n isPressed?: boolean;\n /** can be used by application to store miscellaneous data. */\n applicationData?: any;\n /** Badge to be overlaid on the item.\n * @deprecated in 4.16.0. Use `badgeKind` property instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n badgeType?: BadgeType;\n /** Specifies the kind of badge, if any, to be overlaid on the item. */\n badgeKind?: BadgeKind;\n /** Abstract icon definition. Used when creating itemDef from abstract item (ie. MenuItem).\n * @deprecated in 4.16.0. Use {@link CursorMenuItemProps.iconNode} instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n icon?: IconSpec;\n\n /** if set, it is used to explicitly set the label shown by a component. */\n label?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if label is not explicitly set. */\n labelKey?: string;\n\n /** if set, it is used to explicitly set the description shown by a component. */\n description?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if description is not explicitly set. */\n descriptionKey?: string;\n /** used to explicitly set the tooltip shown by a component. */\n tooltip?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if label is not explicitly set. */\n tooltipKey?: string;\n\n // #endregion \"ItemProps\"\n}\n\n/* eslint-disable deprecation/deprecation */\n\n/** Menu Item Properties\n * @public\n * @deprecated in 4.11.0. Please use {@link CursorMenuItemProps}.\n */\nexport type MenuItemProps = AbstractMenuItemProps;\n\n/** Menu Item\n * @alpha\n * @deprecated in 4.15.0. Used in a deprecated class {@link MenuItemHelpers}.\n */\nexport class MenuItem extends ItemDefBase {\n private _id = \"\";\n private _actionItem?: ActionButtonItemDef;\n private _submenu: MenuItem[];\n private _onSelection?: () => void;\n private _execute?: () => void;\n\n /** onSelection is an optional parameter typically supplied to allow menu parent to close context menu when a menu item is selected. */\n constructor(props: CursorMenuItemProps, onSelection?: () => void) {\n super(props);\n\n this._id = props.id;\n this._submenu = new Array<MenuItem>();\n this._onSelection = onSelection;\n\n if (props.item) {\n this._actionItem = new CommandItemDef(props.item);\n\n // Copy over icon, label & badgeType from the item\n if (!this.iconSpec) this.iconSpec = this._actionItem.iconSpec;\n if (!this.label) this.setLabel(this._actionItem.label);\n if (!this.badgeType) this.badgeType = this._actionItem.badgeType;\n if (!this.badgeKind) this.badgeKind = this._actionItem.badgeKind;\n if (!this.isDisabled) this.isDisabled = this._actionItem.isDisabled;\n } else if (props.execute) {\n this._execute = props.execute;\n } else if (props.submenu) {\n props.submenu.forEach((childProps: CursorMenuItemProps) => {\n const childItem = new MenuItem(childProps, onSelection);\n this._submenu.push(childItem);\n });\n } else {\n // eslint-disable-next-line deprecation/deprecation\n throw new UiError(\n UiFramework.loggerCategory(this),\n `Either 'item', 'execute' or 'submenu' must be specified for '${props.id}'.`\n );\n }\n\n this.iconRightSpec = props.iconRight;\n }\n\n public get id(): string {\n return this._id;\n }\n\n public get submenu(): MenuItem[] {\n return this._submenu;\n }\n\n public get actionItem(): ActionButtonItemDef | undefined {\n return this._actionItem;\n }\n\n public iconRightSpec?: IconSpec;\n\n public itemPicked(): void {\n setTimeout(() => {\n if (this._actionItem) this._actionItem.execute();\n else if (this._execute) this._execute();\n });\n\n if (this._onSelection) this._onSelection();\n }\n}\n\n/** Menu Item helper methods\n * @alpha\n * @deprecated in 4.15.0. Use {@link @itwin/core-react#ContextMenuItem} and {@link @itwin/core-react#ContextSubMenu} components.\n */\nexport class MenuItemHelpers {\n public static createMenuItems(\n itemPropsList: CursorMenuItemProps[],\n onSelection?: () => void\n ): MenuItem[] {\n const menuItems = new Array<MenuItem>();\n itemPropsList.forEach((itemProps: CursorMenuItemProps) => {\n menuItems.push(new MenuItem(itemProps, onSelection));\n });\n return menuItems;\n }\n\n public static createMenuItemNodes(itemList: MenuItem[]): React.ReactNode[] {\n const itemNodes: React.ReactNode[] = [];\n\n itemList.forEach((item: MenuItem, index: number) => {\n const reactItem = this.createMenuItemNode(item, index);\n if (reactItem) itemNodes.push(reactItem);\n });\n\n return itemNodes;\n }\n\n private static createMenuItemNode(\n item: MenuItem,\n index: number\n ): React.ReactNode {\n let node: React.ReactNode = null;\n const label = item.label;\n const iconSpec = item.iconSpec;\n const iconRightSpec = item.iconRightSpec;\n const badgeType = item.badgeType;\n const badgeKind = item.badgeKind;\n const isDisabled: boolean = ConditionalBooleanValue.getValue(\n item.isDisabled\n );\n\n if (item.actionItem) {\n const sel = () => item.itemPicked();\n node = (\n <ContextMenuItem\n key={index}\n onSelect={sel}\n icon={iconSpec}\n iconRight={iconRightSpec}\n badgeType={badgeType}\n badgeKind={badgeKind}\n disabled={isDisabled}\n >\n {label}\n </ContextMenuItem>\n );\n } else {\n if (item.submenu && item.submenu.length > 0) {\n const items = this.createMenuItemNodes(item.submenu);\n\n node = (\n <ContextSubMenu\n key={index}\n icon={iconSpec}\n label={label}\n badgeType={badgeType}\n badgeKind={badgeKind}\n disabled={isDisabled}\n >\n {items}\n </ContextSubMenu>\n );\n }\n }\n\n return node;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["../../../../src/appui-react/shared/MenuItem.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAK/B,0DAAyE;AAOzE,kDAAoE;AACpE,gDAA6C;AAE7C,qDAAkD;AAClD,+CAA4C;AAkF5C;;;GAGG;AACH,MAAa,QAAS,SAAQ,yBAAW;IAOvC,uIAAuI;IACvI,YAAY,KAA0B,EAAE,WAAwB;QAC9D,KAAK,CAAC,KAAK,CAAC,CAAC;QARP,QAAG,GAAG,EAAE,CAAC;QAUf,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,EAAY,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAEhC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,GAAG,IAAI,+BAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAElD,kDAAkD;YAClD,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;YAC9D,IAAI,CAAC,IAAI,CAAC,KAAK;gBAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACvD,IAAI,CAAC,IAAI,CAAC,SAAS;gBAAE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;YACjE,IAAI,CAAC,IAAI,CAAC,SAAS;gBAAE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;YACjE,IAAI,CAAC,IAAI,CAAC,UAAU;gBAAE,IAAI,CAAC,UAAU,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,EACV,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,UAAU,IAEnB,KAAK,CACS,CAClB,CAAC;QACJ,CAAC;QAED,OAAO,CACL,oBAAC,4BAAe,IACd,GAAG,EAAE,KAAK,EACV,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,EACjC,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,UAAU,IAEnB,KAAK,CACU,CACnB,CAAC;IACJ,CAAC;CACF;AAnED,0CAmEC","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 Item\n */\n\nimport * as React from \"react\";\nimport type {\n AbstractMenuItemProps,\n StringGetter,\n} from \"@itwin/appui-abstract\";\nimport { ConditionalBooleanValue, UiError } from \"@itwin/appui-abstract\";\nimport type {\n BadgeKind,\n BadgeType,\n CommonProps,\n IconSpec,\n} from \"@itwin/core-react\";\nimport { ContextMenuItem, ContextSubMenu } from \"@itwin/core-react\";\nimport { UiFramework } from \"../UiFramework\";\nimport type { ActionButtonItemDef } from \"./ActionButtonItemDef\";\nimport { CommandItemDef } from \"./CommandItemDef\";\nimport { ItemDefBase } from \"./ItemDefBase\";\nimport type { CommandItemProps } from \"./ItemProps\";\nimport type { ConditionalStringValue } from \"./ConditionalValue\";\n\n/** Properties for context menu items.\n * @public\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface CursorMenuItemProps extends CommonProps {\n /** The id for the menu item. */\n id: string;\n /** Icon to display. */\n iconNode?: React.ReactNode;\n /** Icon to display.\n * @deprecated in 4.16.0. Use {@link CursorMenuItemProps.iconNode} instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n iconSpec?: IconSpec;\n /** The item to execute when this item is invoked. Either 'item', 'submenu' or `execute` must be specified.\n * @deprecated in 4.15.0. Use properties of this object instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n item?: CommandItemProps;\n /** Function to execute. */\n execute?: () => any;\n /** Nested array of item props. Either 'item', 'submenu' or 'execute' must be specified. */\n submenu?: CursorMenuItemProps[];\n /** Icon to display on right side of the menu item.\n * Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id.\n */\n iconRight?: string | ConditionalStringValue;\n\n // #region \"ItemProps\" properties previously extended from deprecated type.\n\n /** if true component will be hidden - defaults to false */\n isHidden?: boolean | ConditionalBooleanValue;\n /** if true component will be disabled - defaults to false */\n isDisabled?: boolean | ConditionalBooleanValue;\n /** if set, component will be considered \"active\" an will display an \"active stripe\" - defaults to false */\n isActive?: boolean;\n /** if set, component will be considered selected but will NOT display an \"active stripe\" - defaults to false. Typically used by buttons that toggle between two states. */\n isPressed?: boolean;\n /** can be used by application to store miscellaneous data. */\n applicationData?: any;\n /** Badge to be overlaid on the item.\n * @deprecated in 4.16.0. Use `badgeKind` property instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n badgeType?: BadgeType;\n /** Specifies the kind of badge, if any, to be overlaid on the item. */\n badgeKind?: BadgeKind;\n /** Abstract icon definition. Used when creating itemDef from abstract item (ie. MenuItem).\n * @deprecated in 4.16.0. Use {@link CursorMenuItemProps.iconNode} instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n icon?: IconSpec;\n\n /** if set, it is used to explicitly set the label shown by a component. */\n label?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if label is not explicitly set. */\n labelKey?: string;\n\n /** if set, it is used to explicitly set the description shown by a component. */\n description?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if description is not explicitly set. */\n descriptionKey?: string;\n /** used to explicitly set the tooltip shown by a component. */\n tooltip?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if label is not explicitly set. */\n tooltipKey?: string;\n\n // #endregion \"ItemProps\"\n}\n\n/* eslint-disable deprecation/deprecation */\n\n/** Menu Item Properties\n * @public\n * @deprecated in 4.11.0. Please use {@link CursorMenuItemProps}.\n */\nexport type MenuItemProps = AbstractMenuItemProps;\n\n/** Menu Item\n * @alpha\n * @deprecated in 4.15.0. Used in a deprecated class {@link MenuItemHelpers}.\n */\nexport class MenuItem extends ItemDefBase {\n private _id = \"\";\n private _actionItem?: ActionButtonItemDef;\n private _submenu: MenuItem[];\n private _onSelection?: () => void;\n private _execute?: () => void;\n\n /** onSelection is an optional parameter typically supplied to allow menu parent to close context menu when a menu item is selected. */\n constructor(props: CursorMenuItemProps, onSelection?: () => void) {\n super(props);\n\n this._id = props.id;\n this._submenu = new Array<MenuItem>();\n this._onSelection = onSelection;\n\n if (props.item) {\n this._actionItem = new CommandItemDef(props.item);\n\n // Copy over icon, label & badgeType from the item\n if (!this.iconSpec) this.iconSpec = this._actionItem.iconSpec;\n if (!this.label) this.setLabel(this._actionItem.label);\n if (!this.badgeType) this.badgeType = this._actionItem.badgeType;\n if (!this.badgeKind) this.badgeKind = this._actionItem.badgeKind;\n if (!this.isDisabled) this.isDisabled = this._actionItem.isDisabled;\n } else if (props.execute) {\n this._execute = props.execute;\n } else if (props.submenu) {\n props.submenu.forEach((childProps: CursorMenuItemProps) => {\n const childItem = new MenuItem(childProps, onSelection);\n this._submenu.push(childItem);\n });\n } else {\n // eslint-disable-next-line deprecation/deprecation\n throw new UiError(\n UiFramework.loggerCategory(this),\n `Either 'item', 'execute' or 'submenu' must be specified for '${props.id}'.`\n );\n }\n\n this.iconRightSpec = props.iconRight;\n }\n\n public get id(): string {\n return this._id;\n }\n\n public get submenu(): MenuItem[] {\n return this._submenu;\n }\n\n public get actionItem(): ActionButtonItemDef | undefined {\n return this._actionItem;\n }\n\n public iconRightSpec?: IconSpec;\n\n public itemPicked(): void {\n setTimeout(() => {\n if (this._actionItem) this._actionItem.execute();\n else if (this._execute) this._execute();\n });\n\n if (this._onSelection) this._onSelection();\n }\n}\n\n/** Menu Item helper methods\n * @alpha\n * @deprecated in 4.15.0. Use {@link @itwin/core-react#ContextMenuItem} and {@link @itwin/core-react#ContextSubMenu} components.\n */\nexport class MenuItemHelpers {\n public static createMenuItems(\n itemPropsList: CursorMenuItemProps[],\n onSelection?: () => void\n ): MenuItem[] {\n const menuItems = new Array<MenuItem>();\n itemPropsList.forEach((itemProps: CursorMenuItemProps) => {\n menuItems.push(new MenuItem(itemProps, onSelection));\n });\n return menuItems;\n }\n\n public static createMenuItemNodes(itemList: MenuItem[]): React.ReactNode[] {\n const itemNodes: React.ReactNode[] = [];\n\n itemList.forEach((item: MenuItem, index: number) => {\n const reactItem = this.createMenuItemNode(item, index);\n if (reactItem) itemNodes.push(reactItem);\n });\n\n return itemNodes;\n }\n\n private static createMenuItemNode(\n item: MenuItem,\n index: number\n ): React.ReactNode {\n const label = item.label;\n const iconSpec = item.iconSpec;\n const iconRightSpec = item.iconRightSpec;\n const badgeType = item.badgeType;\n const badgeKind = item.badgeKind;\n const isDisabled: boolean = ConditionalBooleanValue.getValue(\n item.isDisabled\n );\n\n if (item.submenu && item.submenu.length > 0) {\n const items = this.createMenuItemNodes(item.submenu);\n\n return (\n <ContextSubMenu\n key={index}\n icon={iconSpec}\n label={label}\n badgeType={badgeType}\n badgeKind={badgeKind}\n disabled={isDisabled}\n >\n {items}\n </ContextSubMenu>\n );\n }\n\n return (\n <ContextMenuItem\n key={index}\n onSelect={() => item.itemPicked()}\n icon={iconSpec}\n iconRight={iconRightSpec}\n badgeType={badgeType}\n badgeKind={badgeKind}\n disabled={isDisabled}\n >\n {label}\n </ContextMenuItem>\n );\n }\n}\n"]}
|
|
@@ -21,13 +21,13 @@ export interface CursorMenuItemProps extends CommonProps {
|
|
|
21
21
|
* @deprecated in 4.16.0. Use {@link CursorMenuItemProps.iconNode} instead.
|
|
22
22
|
*/
|
|
23
23
|
iconSpec?: IconSpec;
|
|
24
|
-
/** The item to execute when this item is invoked. Either 'item'
|
|
24
|
+
/** The item to execute when this item is invoked. Either 'item', 'submenu' or `execute` must be specified.
|
|
25
25
|
* @deprecated in 4.15.0. Use properties of this object instead.
|
|
26
26
|
*/
|
|
27
27
|
item?: CommandItemProps;
|
|
28
28
|
/** Function to execute. */
|
|
29
29
|
execute?: () => any;
|
|
30
|
-
/** Nested array of item props. Either 'item' or '
|
|
30
|
+
/** Nested array of item props. Either 'item', 'submenu' or 'execute' must be specified. */
|
|
31
31
|
submenu?: CursorMenuItemProps[];
|
|
32
32
|
/** Icon to display on right side of the menu item.
|
|
33
33
|
* Name of icon WebFont entry or if specifying an imported SVG symbol use "webSvg:" prefix to imported symbol Id.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/shared/MenuItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAW,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE;;GAEG;AAEH,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,gCAAgC;IAChC,EAAE,EAAE,MAA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E,MAAM,IAAI;IAkChE,IAAW,EAAE,IAAI,MAAM,CAEtB;IAED,IAAW,OAAO,IAAI,QAAQ,EAAE,CAE/B;IAED,IAAW,UAAU,IAAI,mBAAmB,GAAG,SAAS,CAEvD;IAEM,aAAa,CAAC,EAAE,QAAQ,CAAC;IAEzB,UAAU,IAAI,IAAI;CAQ1B;AAED;;;GAGG;AACH,qBAAa,eAAe;WACZ,eAAe,CAC3B,aAAa,EAAE,mBAAmB,EAAE,EACpC,WAAW,CAAC,EAAE,MAAM,IAAI,GACvB,QAAQ,EAAE;WAQC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE;IAW1E,OAAO,CAAC,MAAM,CAAC,kBAAkB;CA4ClC"}
|
|
@@ -94,24 +94,17 @@ export class MenuItemHelpers {
|
|
|
94
94
|
return itemNodes;
|
|
95
95
|
}
|
|
96
96
|
static createMenuItemNode(item, index) {
|
|
97
|
-
let node = null;
|
|
98
97
|
const label = item.label;
|
|
99
98
|
const iconSpec = item.iconSpec;
|
|
100
99
|
const iconRightSpec = item.iconRightSpec;
|
|
101
100
|
const badgeType = item.badgeType;
|
|
102
101
|
const badgeKind = item.badgeKind;
|
|
103
102
|
const isDisabled = ConditionalBooleanValue.getValue(item.isDisabled);
|
|
104
|
-
if (item.
|
|
105
|
-
const
|
|
106
|
-
|
|
103
|
+
if (item.submenu && item.submenu.length > 0) {
|
|
104
|
+
const items = this.createMenuItemNodes(item.submenu);
|
|
105
|
+
return (React.createElement(ContextSubMenu, { key: index, icon: iconSpec, label: label, badgeType: badgeType, badgeKind: badgeKind, disabled: isDisabled }, items));
|
|
107
106
|
}
|
|
108
|
-
|
|
109
|
-
if (item.submenu && item.submenu.length > 0) {
|
|
110
|
-
const items = this.createMenuItemNodes(item.submenu);
|
|
111
|
-
node = (React.createElement(ContextSubMenu, { key: index, icon: iconSpec, label: label, badgeType: badgeType, badgeKind: badgeKind, disabled: isDisabled }, items));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return node;
|
|
107
|
+
return (React.createElement(ContextMenuItem, { key: index, onSelect: () => item.itemPicked(), icon: iconSpec, iconRight: iconRightSpec, badgeType: badgeType, badgeKind: badgeKind, disabled: isDisabled }, label));
|
|
115
108
|
}
|
|
116
109
|
}
|
|
117
110
|
//# sourceMappingURL=MenuItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["../../../../src/appui-react/shared/MenuItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAOzE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAkF5C;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,WAAW;IAOvC,uIAAuI;IACvI,YAAY,KAA0B,EAAE,WAAwB;QAC9D,KAAK,CAAC,KAAK,CAAC,CAAC;QARP,QAAG,GAAG,EAAE,CAAC;QAUf,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,EAAY,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAEhC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,GAAG,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAElD,kDAAkD;YAClD,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAA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GAAG,IAAI,CAAC,aAAa,CAAC;QACzC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,MAAM,UAAU,GAAY,uBAAuB,CAAC,QAAQ,CAC1D,IAAI,CAAC,UAAU,CAChB,CAAC;QAEF,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACpC,IAAI,GAAG,CACL,oBAAC,eAAe,IACd,GAAG,EAAE,KAAK,EACV,QAAQ,EAAE,GAAG,EACb,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,UAAU,IAEnB,KAAK,CACU,CACnB,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAErD,IAAI,GAAG,CACL,oBAAC,cAAc,IACb,GAAG,EAAE,KAAK,EACV,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,UAAU,IAEnB,KAAK,CACS,CAClB,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Item\n */\n\nimport * as React from \"react\";\nimport type {\n AbstractMenuItemProps,\n StringGetter,\n} from \"@itwin/appui-abstract\";\nimport { ConditionalBooleanValue, UiError } from \"@itwin/appui-abstract\";\nimport type {\n BadgeKind,\n BadgeType,\n CommonProps,\n IconSpec,\n} from \"@itwin/core-react\";\nimport { ContextMenuItem, ContextSubMenu } from \"@itwin/core-react\";\nimport { UiFramework } from \"../UiFramework\";\nimport type { ActionButtonItemDef } from \"./ActionButtonItemDef\";\nimport { CommandItemDef } from \"./CommandItemDef\";\nimport { ItemDefBase } from \"./ItemDefBase\";\nimport type { CommandItemProps } from \"./ItemProps\";\nimport type { ConditionalStringValue } from \"./ConditionalValue\";\n\n/** Properties for context menu items.\n * @public\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface CursorMenuItemProps extends CommonProps {\n /** The id for the menu item. */\n id: string;\n /** Icon to display. */\n iconNode?: React.ReactNode;\n /** Icon to display.\n * @deprecated in 4.16.0. Use {@link CursorMenuItemProps.iconNode} instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n iconSpec?: IconSpec;\n /** The item to execute when this item is invoked. Either 'item' or 'submenu' must be specified.\n * @deprecated in 4.15.0. Use properties of this object instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n item?: CommandItemProps;\n /** Function to execute. */\n execute?: () => any;\n /** Nested array of item props. Either 'item' or 'submenu' must be specified. */\n submenu?: CursorMenuItemProps[];\n /** Icon to display on right side of the menu item.\n * Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id.\n */\n iconRight?: string | ConditionalStringValue;\n\n // #region \"ItemProps\" properties previously extended from deprecated type.\n\n /** if true component will be hidden - defaults to false */\n isHidden?: boolean | ConditionalBooleanValue;\n /** if true component will be disabled - defaults to false */\n isDisabled?: boolean | ConditionalBooleanValue;\n /** if set, component will be considered \"active\" an will display an \"active stripe\" - defaults to false */\n isActive?: boolean;\n /** if set, component will be considered selected but will NOT display an \"active stripe\" - defaults to false. Typically used by buttons that toggle between two states. */\n isPressed?: boolean;\n /** can be used by application to store miscellaneous data. */\n applicationData?: any;\n /** Badge to be overlaid on the item.\n * @deprecated in 4.16.0. Use `badgeKind` property instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n badgeType?: BadgeType;\n /** Specifies the kind of badge, if any, to be overlaid on the item. */\n badgeKind?: BadgeKind;\n /** Abstract icon definition. Used when creating itemDef from abstract item (ie. MenuItem).\n * @deprecated in 4.16.0. Use {@link CursorMenuItemProps.iconNode} instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n icon?: IconSpec;\n\n /** if set, it is used to explicitly set the label shown by a component. */\n label?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if label is not explicitly set. */\n labelKey?: string;\n\n /** if set, it is used to explicitly set the description shown by a component. */\n description?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if description is not explicitly set. */\n descriptionKey?: string;\n /** used to explicitly set the tooltip shown by a component. */\n tooltip?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if label is not explicitly set. */\n tooltipKey?: string;\n\n // #endregion \"ItemProps\"\n}\n\n/* eslint-disable deprecation/deprecation */\n\n/** Menu Item Properties\n * @public\n * @deprecated in 4.11.0. Please use {@link CursorMenuItemProps}.\n */\nexport type MenuItemProps = AbstractMenuItemProps;\n\n/** Menu Item\n * @alpha\n * @deprecated in 4.15.0. Used in a deprecated class {@link MenuItemHelpers}.\n */\nexport class MenuItem extends ItemDefBase {\n private _id = \"\";\n private _actionItem?: ActionButtonItemDef;\n private _submenu: MenuItem[];\n private _onSelection?: () => void;\n private _execute?: () => void;\n\n /** onSelection is an optional parameter typically supplied to allow menu parent to close context menu when a menu item is selected. */\n constructor(props: CursorMenuItemProps, onSelection?: () => void) {\n super(props);\n\n this._id = props.id;\n this._submenu = new Array<MenuItem>();\n this._onSelection = onSelection;\n\n if (props.item) {\n this._actionItem = new CommandItemDef(props.item);\n\n // Copy over icon, label & badgeType from the item\n if (!this.iconSpec) this.iconSpec = this._actionItem.iconSpec;\n if (!this.label) this.setLabel(this._actionItem.label);\n if (!this.badgeType) this.badgeType = this._actionItem.badgeType;\n if (!this.badgeKind) this.badgeKind = this._actionItem.badgeKind;\n if (!this.isDisabled) this.isDisabled = this._actionItem.isDisabled;\n } else if (props.execute) {\n this._execute = props.execute;\n } else if (props.submenu) {\n props.submenu.forEach((childProps: CursorMenuItemProps) => {\n const childItem = new MenuItem(childProps, onSelection);\n this._submenu.push(childItem);\n });\n } else {\n // eslint-disable-next-line deprecation/deprecation\n throw new UiError(\n UiFramework.loggerCategory(this),\n `Either 'item', 'execute' or 'submenu' must be specified for '${props.id}'.`\n );\n }\n\n this.iconRightSpec = props.iconRight;\n }\n\n public get id(): string {\n return this._id;\n }\n\n public get submenu(): MenuItem[] {\n return this._submenu;\n }\n\n public get actionItem(): ActionButtonItemDef | undefined {\n return this._actionItem;\n }\n\n public iconRightSpec?: IconSpec;\n\n public itemPicked(): void {\n setTimeout(() => {\n if (this._actionItem) this._actionItem.execute();\n else if (this._execute) this._execute();\n });\n\n if (this._onSelection) this._onSelection();\n }\n}\n\n/** Menu Item helper methods\n * @alpha\n * @deprecated in 4.15.0. Use {@link @itwin/core-react#ContextMenuItem} and {@link @itwin/core-react#ContextSubMenu} components.\n */\nexport class MenuItemHelpers {\n public static createMenuItems(\n itemPropsList: CursorMenuItemProps[],\n onSelection?: () => void\n ): MenuItem[] {\n const menuItems = new Array<MenuItem>();\n itemPropsList.forEach((itemProps: CursorMenuItemProps) => {\n menuItems.push(new MenuItem(itemProps, onSelection));\n });\n return menuItems;\n }\n\n public static createMenuItemNodes(itemList: MenuItem[]): React.ReactNode[] {\n const itemNodes: React.ReactNode[] = [];\n\n itemList.forEach((item: MenuItem, index: number) => {\n const reactItem = this.createMenuItemNode(item, index);\n if (reactItem) itemNodes.push(reactItem);\n });\n\n return itemNodes;\n }\n\n private static createMenuItemNode(\n item: MenuItem,\n index: number\n ): React.ReactNode {\n let node: React.ReactNode = null;\n const label = item.label;\n const iconSpec = item.iconSpec;\n const iconRightSpec = item.iconRightSpec;\n const badgeType = item.badgeType;\n const badgeKind = item.badgeKind;\n const isDisabled: boolean = ConditionalBooleanValue.getValue(\n item.isDisabled\n );\n\n if (item.actionItem) {\n const sel = () => item.itemPicked();\n node = (\n <ContextMenuItem\n key={index}\n onSelect={sel}\n icon={iconSpec}\n iconRight={iconRightSpec}\n badgeType={badgeType}\n badgeKind={badgeKind}\n disabled={isDisabled}\n >\n {label}\n </ContextMenuItem>\n );\n } else {\n if (item.submenu && item.submenu.length > 0) {\n const items = this.createMenuItemNodes(item.submenu);\n\n node = (\n <ContextSubMenu\n key={index}\n icon={iconSpec}\n label={label}\n badgeType={badgeType}\n badgeKind={badgeKind}\n disabled={isDisabled}\n >\n {items}\n </ContextSubMenu>\n );\n }\n }\n\n return node;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["../../../../src/appui-react/shared/MenuItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAOzE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAkF5C;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,WAAW;IAOvC,uIAAuI;IACvI,YAAY,KAA0B,EAAE,WAAwB;QAC9D,KAAK,CAAC,KAAK,CAAC,CAAC;QARP,QAAG,GAAG,EAAE,CAAC;QAUf,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,GA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AAS,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAC/B,IAAc,EACd,KAAa;QAEb,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACzC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,MAAM,UAAU,GAAY,uBAAuB,CAAC,QAAQ,CAC1D,IAAI,CAAC,UAAU,CAChB,CAAC;QAEF,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAErD,OAAO,CACL,oBAAC,cAAc,IACb,GAAG,EAAE,KAAK,EACV,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,UAAU,IAEnB,KAAK,CACS,CAClB,CAAC;QACJ,CAAC;QAED,OAAO,CACL,oBAAC,eAAe,IACd,GAAG,EAAE,KAAK,EACV,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,EACjC,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,UAAU,IAEnB,KAAK,CACU,CACnB,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Item\n */\n\nimport * as React from \"react\";\nimport type {\n AbstractMenuItemProps,\n StringGetter,\n} from \"@itwin/appui-abstract\";\nimport { ConditionalBooleanValue, UiError } from \"@itwin/appui-abstract\";\nimport type {\n BadgeKind,\n BadgeType,\n CommonProps,\n IconSpec,\n} from \"@itwin/core-react\";\nimport { ContextMenuItem, ContextSubMenu } from \"@itwin/core-react\";\nimport { UiFramework } from \"../UiFramework\";\nimport type { ActionButtonItemDef } from \"./ActionButtonItemDef\";\nimport { CommandItemDef } from \"./CommandItemDef\";\nimport { ItemDefBase } from \"./ItemDefBase\";\nimport type { CommandItemProps } from \"./ItemProps\";\nimport type { ConditionalStringValue } from \"./ConditionalValue\";\n\n/** Properties for context menu items.\n * @public\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface CursorMenuItemProps extends CommonProps {\n /** The id for the menu item. */\n id: string;\n /** Icon to display. */\n iconNode?: React.ReactNode;\n /** Icon to display.\n * @deprecated in 4.16.0. Use {@link CursorMenuItemProps.iconNode} instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n iconSpec?: IconSpec;\n /** The item to execute when this item is invoked. Either 'item', 'submenu' or `execute` must be specified.\n * @deprecated in 4.15.0. Use properties of this object instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n item?: CommandItemProps;\n /** Function to execute. */\n execute?: () => any;\n /** Nested array of item props. Either 'item', 'submenu' or 'execute' must be specified. */\n submenu?: CursorMenuItemProps[];\n /** Icon to display on right side of the menu item.\n * Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id.\n */\n iconRight?: string | ConditionalStringValue;\n\n // #region \"ItemProps\" properties previously extended from deprecated type.\n\n /** if true component will be hidden - defaults to false */\n isHidden?: boolean | ConditionalBooleanValue;\n /** if true component will be disabled - defaults to false */\n isDisabled?: boolean | ConditionalBooleanValue;\n /** if set, component will be considered \"active\" an will display an \"active stripe\" - defaults to false */\n isActive?: boolean;\n /** if set, component will be considered selected but will NOT display an \"active stripe\" - defaults to false. Typically used by buttons that toggle between two states. */\n isPressed?: boolean;\n /** can be used by application to store miscellaneous data. */\n applicationData?: any;\n /** Badge to be overlaid on the item.\n * @deprecated in 4.16.0. Use `badgeKind` property instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n badgeType?: BadgeType;\n /** Specifies the kind of badge, if any, to be overlaid on the item. */\n badgeKind?: BadgeKind;\n /** Abstract icon definition. Used when creating itemDef from abstract item (ie. MenuItem).\n * @deprecated in 4.16.0. Use {@link CursorMenuItemProps.iconNode} instead.\n */\n // eslint-disable-next-line deprecation/deprecation\n icon?: IconSpec;\n\n /** if set, it is used to explicitly set the label shown by a component. */\n label?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if label is not explicitly set. */\n labelKey?: string;\n\n /** if set, it is used to explicitly set the description shown by a component. */\n description?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if description is not explicitly set. */\n descriptionKey?: string;\n /** used to explicitly set the tooltip shown by a component. */\n tooltip?: string | StringGetter | ConditionalStringValue;\n /** if set, it is used to define a key that is used to look up a localized string. This value is used only if label is not explicitly set. */\n tooltipKey?: string;\n\n // #endregion \"ItemProps\"\n}\n\n/* eslint-disable deprecation/deprecation */\n\n/** Menu Item Properties\n * @public\n * @deprecated in 4.11.0. Please use {@link CursorMenuItemProps}.\n */\nexport type MenuItemProps = AbstractMenuItemProps;\n\n/** Menu Item\n * @alpha\n * @deprecated in 4.15.0. Used in a deprecated class {@link MenuItemHelpers}.\n */\nexport class MenuItem extends ItemDefBase {\n private _id = \"\";\n private _actionItem?: ActionButtonItemDef;\n private _submenu: MenuItem[];\n private _onSelection?: () => void;\n private _execute?: () => void;\n\n /** onSelection is an optional parameter typically supplied to allow menu parent to close context menu when a menu item is selected. */\n constructor(props: CursorMenuItemProps, onSelection?: () => void) {\n super(props);\n\n this._id = props.id;\n this._submenu = new Array<MenuItem>();\n this._onSelection = onSelection;\n\n if (props.item) {\n this._actionItem = new CommandItemDef(props.item);\n\n // Copy over icon, label & badgeType from the item\n if (!this.iconSpec) this.iconSpec = this._actionItem.iconSpec;\n if (!this.label) this.setLabel(this._actionItem.label);\n if (!this.badgeType) this.badgeType = this._actionItem.badgeType;\n if (!this.badgeKind) this.badgeKind = this._actionItem.badgeKind;\n if (!this.isDisabled) this.isDisabled = this._actionItem.isDisabled;\n } else if (props.execute) {\n this._execute = props.execute;\n } else if (props.submenu) {\n props.submenu.forEach((childProps: CursorMenuItemProps) => {\n const childItem = new MenuItem(childProps, onSelection);\n this._submenu.push(childItem);\n });\n } else {\n // eslint-disable-next-line deprecation/deprecation\n throw new UiError(\n UiFramework.loggerCategory(this),\n `Either 'item', 'execute' or 'submenu' must be specified for '${props.id}'.`\n );\n }\n\n this.iconRightSpec = props.iconRight;\n }\n\n public get id(): string {\n return this._id;\n }\n\n public get submenu(): MenuItem[] {\n return this._submenu;\n }\n\n public get actionItem(): ActionButtonItemDef | undefined {\n return this._actionItem;\n }\n\n public iconRightSpec?: IconSpec;\n\n public itemPicked(): void {\n setTimeout(() => {\n if (this._actionItem) this._actionItem.execute();\n else if (this._execute) this._execute();\n });\n\n if (this._onSelection) this._onSelection();\n }\n}\n\n/** Menu Item helper methods\n * @alpha\n * @deprecated in 4.15.0. Use {@link @itwin/core-react#ContextMenuItem} and {@link @itwin/core-react#ContextSubMenu} components.\n */\nexport class MenuItemHelpers {\n public static createMenuItems(\n itemPropsList: CursorMenuItemProps[],\n onSelection?: () => void\n ): MenuItem[] {\n const menuItems = new Array<MenuItem>();\n itemPropsList.forEach((itemProps: CursorMenuItemProps) => {\n menuItems.push(new MenuItem(itemProps, onSelection));\n });\n return menuItems;\n }\n\n public static createMenuItemNodes(itemList: MenuItem[]): React.ReactNode[] {\n const itemNodes: React.ReactNode[] = [];\n\n itemList.forEach((item: MenuItem, index: number) => {\n const reactItem = this.createMenuItemNode(item, index);\n if (reactItem) itemNodes.push(reactItem);\n });\n\n return itemNodes;\n }\n\n private static createMenuItemNode(\n item: MenuItem,\n index: number\n ): React.ReactNode {\n const label = item.label;\n const iconSpec = item.iconSpec;\n const iconRightSpec = item.iconRightSpec;\n const badgeType = item.badgeType;\n const badgeKind = item.badgeKind;\n const isDisabled: boolean = ConditionalBooleanValue.getValue(\n item.isDisabled\n );\n\n if (item.submenu && item.submenu.length > 0) {\n const items = this.createMenuItemNodes(item.submenu);\n\n return (\n <ContextSubMenu\n key={index}\n icon={iconSpec}\n label={label}\n badgeType={badgeType}\n badgeKind={badgeKind}\n disabled={isDisabled}\n >\n {items}\n </ContextSubMenu>\n );\n }\n\n return (\n <ContextMenuItem\n key={index}\n onSelect={() => item.itemPicked()}\n icon={iconSpec}\n iconRight={iconRightSpec}\n badgeType={badgeType}\n badgeKind={badgeKind}\n disabled={isDisabled}\n >\n {label}\n </ContextMenuItem>\n );\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/appui-react",
|
|
3
|
-
"version": "4.16.
|
|
3
|
+
"version": "4.16.3",
|
|
4
4
|
"description": "UI framework",
|
|
5
5
|
"main": "lib/cjs/appui-react.js",
|
|
6
6
|
"module": "lib/esm/appui-react.js",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@itwin/appui-abstract": "^3.7.0 || ^4.0.0",
|
|
26
|
-
"@itwin/components-react": "^4.16.
|
|
26
|
+
"@itwin/components-react": "^4.16.3",
|
|
27
27
|
"@itwin/core-bentley": "^3.7.0 || ^4.0.0",
|
|
28
28
|
"@itwin/core-common": "^3.7.0 || ^4.0.0",
|
|
29
29
|
"@itwin/core-frontend": "^3.7.0 || ^4.0.0",
|
|
30
30
|
"@itwin/core-geometry": "^3.7.0 || ^4.0.0",
|
|
31
31
|
"@itwin/core-quantity": "^3.7.0 || ^4.0.0",
|
|
32
|
-
"@itwin/core-react": "^4.16.
|
|
32
|
+
"@itwin/core-react": "^4.16.3",
|
|
33
33
|
"@itwin/core-telemetry": "^3.7.0 || ^4.0.0",
|
|
34
|
-
"@itwin/imodel-components-react": "^4.16.
|
|
34
|
+
"@itwin/imodel-components-react": "^4.16.3",
|
|
35
35
|
"react": "^17.0.0 || ^18.0.0",
|
|
36
36
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
37
37
|
"react-redux": "^7.2.2",
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
"typescript": "~5.3.3",
|
|
86
86
|
"upath": "^2.0.1",
|
|
87
87
|
"vitest": "^1.6.0",
|
|
88
|
-
"@itwin/components-react": "4.16.
|
|
89
|
-
"@itwin/core-react": "4.16.
|
|
90
|
-
"@itwin/imodel-components-react": "4.16.
|
|
88
|
+
"@itwin/components-react": "4.16.3",
|
|
89
|
+
"@itwin/core-react": "4.16.3",
|
|
90
|
+
"@itwin/imodel-components-react": "4.16.3"
|
|
91
91
|
},
|
|
92
92
|
"//dependencies": [
|
|
93
93
|
"NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API",
|