@itwin/appui-react 5.12.0 → 5.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # Change Log - @itwin/appui-react
2
2
 
3
+ ## 5.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0eb12bd: Added `isActiveCondition` property to `CommonToolbarItem` interface, which allows to dynamically update the active state of a toolbar item using a conditional value.
8
+
9
+ ```tsx
10
+ let isActive = false;
11
+ const eventId = "my-action-active-changed";
12
+ function toggleActive() {
13
+ isActive = !isActive;
14
+ SyncUiEventDispatcher.dispatchSyncUiEvent(eventId);
15
+ }
16
+
17
+ ToolbarItemUtilities.createActionItem({
18
+ id: "my-action",
19
+ execute: toggleActive,
20
+ isActiveCondition: new ConditionalBooleanValue(() => isActive, [eventId]),
21
+ });
22
+ ```
23
+
24
+ - 0eb12bd: Deprecated `isActive` property of `CommonToolbarItem` interface. Use `isActiveCondition` property instead.
25
+
26
+ ### Patch Changes
27
+
28
+ - @itwin/components-react@5.13.0
29
+ - @itwin/core-react@5.13.0
30
+ - @itwin/imodel-components-react@5.13.0
31
+
32
+ ## 5.12.1
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [105bf92]
37
+ - Updated dependencies [61d2af4]
38
+ - @itwin/components-react@5.12.1
39
+ - @itwin/imodel-components-react@5.12.1
40
+ - @itwin/core-react@5.12.1
41
+
3
42
  ## 5.12.0
4
43
 
5
44
  ### Minor Changes
@@ -17,12 +17,13 @@ export interface ExtensibleToolbarProps {
17
17
  orientation: ToolbarOrientation;
18
18
  /** Describes the ids of active toolbar items.
19
19
  * By default only the toolbar item with id that matches the active `Tool` id is active.
20
+ * @note Property {@link CommonToolbarItem.isActiveCondition} takes precedence when determining the active state of a toolbar item.
20
21
  */
21
22
  activeItemIds?: string[];
22
23
  }
23
24
  /**
24
25
  * Toolbar that is populated and maintained by UI item providers.
25
- * @note Overrides `isActive` property based on the active tool id, unless `activeItemIds` is specified.
26
+ * @note Overrides {@link CommonToolbarItem.isActive} property based on the active tool id, unless {@link ExtensibleToolbarProps.activeItemIds} is specified.
26
27
  * @public
27
28
  */
28
29
  export declare function ToolbarComposer(props: ExtensibleToolbarProps): React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarComposer.d.ts","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarComposer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAGV,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,kBAAkB,EAClB,YAAY,EACb,MAAM,kBAAkB,CAAC;AA4J1B;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,+EAA+E;IAC/E,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,8FAA8F;IAC9F,KAAK,EAAE,YAAY,CAAC;IACpB,2BAA2B;IAC3B,WAAW,EAAE,kBAAkB,CAAC;IAChC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;GAIG;AAEH,wBAAgB,eAAe,CAAC,KAAK,EAAE,sBAAsB,qBAwC5D;AAwBD,gBAAgB;AAChB,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAAE,EACpB,aAAa,EAAE,MAAM,EAAE,iBA0BxB"}
1
+ {"version":3,"file":"ToolbarComposer.d.ts","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarComposer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAIV,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,kBAAkB,EAClB,YAAY,EACb,MAAM,kBAAkB,CAAC;AA4J1B;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,+EAA+E;IAC/E,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,8FAA8F;IAC9F,KAAK,EAAE,YAAY,CAAC;IACpB,2BAA2B;IAC3B,WAAW,EAAE,kBAAkB,CAAC;IAChC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;GAIG;AAEH,wBAAgB,eAAe,CAAC,KAAK,EAAE,sBAAsB,qBAwC5D;AAwBD,gBAAgB;AAChB,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAAE,EACpB,aAAa,EAAE,MAAM,EAAE,iBA4BxB"}
@@ -125,7 +125,7 @@ const useSnapWidgetOpacitySetting = () => {
125
125
  };
126
126
  /**
127
127
  * Toolbar that is populated and maintained by UI item providers.
128
- * @note Overrides `isActive` property based on the active tool id, unless `activeItemIds` is specified.
128
+ * @note Overrides {@link CommonToolbarItem.isActive} property based on the active tool id, unless {@link ExtensibleToolbarProps.activeItemIds} is specified.
129
129
  * @public
130
130
  */
131
131
  // eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -173,6 +173,7 @@ export function updateActiveItems(items, activeItemIds) {
173
173
  while (stack.length > 0) {
174
174
  const [current, ancestors] = stack.pop();
175
175
  const isActive = activeItemIds.includes(current.id);
176
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
176
177
  current.isActive = isActive;
177
178
  if ("items" in current) {
178
179
  for (const child of current.items) {
@@ -183,6 +184,7 @@ export function updateActiveItems(items, activeItemIds) {
183
184
  continue;
184
185
  // Mark ancestors of active item as active.
185
186
  for (const ancestor of ancestors) {
187
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
186
188
  ancestor.isActive = true;
187
189
  }
188
190
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarComposer.js","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarComposer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OA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AAC,GAAG,EAAG,CAAC;YAE1C,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpD,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAE5B,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;gBACvB,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;oBAClC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC;YAED,IAAI,CAAC,QAAQ;gBAAE,SAAS;YAExB,2CAA2C;YAC3C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport { produce } from \"immer\";\nimport {\n Direction,\n ToolbarOpacitySetting,\n ToolbarPanelAlignment,\n} from \"@itwin/components-react\";\nimport { Logger, ProcessDetector } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport { ToolbarDragInteractionContext } from \"./DragInteraction.js\";\nimport type {\n ToolbarActionItem,\n ToolbarGroupItem,\n ToolbarItem,\n} from \"./ToolbarItem.js\";\nimport {\n isToolbarActionItem,\n isToolbarGroupItem,\n ToolbarOrientation,\n ToolbarUsage,\n} from \"./ToolbarItem.js\";\nimport { Toolbar } from \"./Toolbar.js\";\nimport { useActiveStageProvidedToolbarItems } from \"./useActiveStageProvidedToolbarItems.js\";\nimport { useActiveToolId } from \"../hooks/useActiveToolId.js\";\n\nfunction addItemToSpecifiedParentGroup<T extends ToolbarItem>(\n items: readonly T[],\n groupChildren: Array<ToolbarActionItem | ToolbarGroupItem>\n): T[] {\n const outItems: T[] = [];\n for (const toolbarItem of items) {\n if (!isToolbarGroupItem(toolbarItem)) {\n outItems.push(toolbarItem);\n continue;\n }\n\n const newChildren = addItemToSpecifiedParentGroup(\n toolbarItem.items,\n groupChildren\n );\n const foundIndices: number[] = [];\n\n groupChildren.forEach((entry, index) => {\n if (entry.parentGroupItemId === toolbarItem.id) {\n foundIndices.push(index);\n }\n });\n\n if (foundIndices.length) {\n // process in reverse order so groupChildren can be reduced as we find matches\n foundIndices\n .sort((a, b) => a - b)\n .reverse()\n .forEach((foundIndex) => {\n newChildren.push(groupChildren[foundIndex]);\n groupChildren.splice(foundIndex);\n });\n }\n\n outItems.push({ ...toolbarItem, items: newChildren });\n }\n return outItems;\n}\n\nfunction cloneGroup(inGroup: ToolbarGroupItem): ToolbarGroupItem {\n const childItems: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n inGroup.items.forEach((item) => {\n if (isToolbarGroupItem(item)) childItems.push(cloneGroup(item));\n else childItems.push(item);\n });\n\n const clonedGroup = { ...inGroup, items: childItems };\n return clonedGroup;\n}\n\nfunction getItemSortValue(item: ToolbarItem) {\n const groupValue = undefined === item.groupPriority ? 0 : item.groupPriority;\n return groupValue * 10000 + item.itemPriority;\n}\n\nfunction sortItems(items: ReadonlyArray<ToolbarItem>): ToolbarItem[] {\n return [...items]\n .sort((a, b) => getItemSortValue(a) - getItemSortValue(b))\n .map((i) => {\n if (isToolbarGroupItem(i)) {\n return { ...i, items: sortItems(i.items) };\n }\n return i;\n });\n}\n\n/**\n * Create a forEach handler that will add every element of an array of ToolbarItems\n * to a list of items that can then be replaced in its proper place, ensuring that\n * the same item, from different list, is not added multiple times.\n * @param items Output list of items\n * @param groupChildren Output list of group children to redistribute.\n * @returns Array<ToolbarItem>.forEach handler.\n */\nfunction addIfNotDuplicate(\n items: ToolbarItem[],\n groupChildren: (ToolbarActionItem | ToolbarGroupItem)[]\n): (value: ToolbarItem) => void {\n return (srcItem: ToolbarItem) => {\n if (-1 === items.findIndex((item) => item.id === srcItem.id)) {\n // if the default item is a group that an addon may insert into copy it so we don't mess with original\n const toolbarItem = isToolbarGroupItem(srcItem)\n ? cloneGroup(srcItem)\n : srcItem;\n if (\n (isToolbarGroupItem(toolbarItem) || isToolbarActionItem(toolbarItem)) &&\n toolbarItem.parentGroupItemId\n )\n groupChildren.push(toolbarItem);\n else items.push(toolbarItem);\n }\n };\n}\n\n/** local function to combine items from Stage and from Extensions */\nfunction combineItems(\n defaultItems: ReadonlyArray<ToolbarItem>,\n addonItems: ReadonlyArray<ToolbarItem>\n): ToolbarItem[] {\n let items: ToolbarItem[] = [];\n const groupChildren: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n\n defaultItems.forEach(addIfNotDuplicate(items, groupChildren));\n addonItems.forEach(addIfNotDuplicate(items, groupChildren));\n\n // if an item from an addon has specified a parent group then try to find it and insert it. If no parent is found, add item at root level.\n if (groupChildren.length) {\n items = addItemToSpecifiedParentGroup(items, groupChildren);\n\n groupChildren.forEach((toolbarItem) => {\n Logger.logWarning(\n \"ToolbarComposer\",\n `Requested Parent Group [${toolbarItem.parentGroupItemId!}] not found, so item [${\n toolbarItem.id\n }] is added directly to toolbar.`\n );\n items.push(toolbarItem);\n });\n }\n\n return sortItems(items);\n}\n\nconst useProximityOpacitySetting = () => {\n const [proximityOpacity, setProximityOpacity] = React.useState(\n UiFramework.visibility.useProximityOpacity // eslint-disable-line @typescript-eslint/no-deprecated\n );\n\n React.useEffect(() => {\n UiFramework.onUiVisibilityChanged.addListener(\n () => setProximityOpacity(UiFramework.visibility.useProximityOpacity) // eslint-disable-line @typescript-eslint/no-deprecated\n );\n }, []);\n\n return proximityOpacity;\n};\n\nconst useSnapWidgetOpacitySetting = () => {\n const [snapWidgetOpacity, setSnapWidgetOpacity] = React.useState(\n UiFramework.visibility.snapWidgetOpacity\n );\n\n React.useEffect(() => {\n UiFramework.onUiVisibilityChanged.addListener(() =>\n setSnapWidgetOpacity(UiFramework.visibility.snapWidgetOpacity)\n );\n }, []);\n\n return snapWidgetOpacity;\n};\n\n/** Properties for the [[ToolbarComposer]] React components\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof ToolbarComposer>`\n */\nexport interface ExtensibleToolbarProps {\n /** Toolbar items to be displayed in addition to the provided toolbar items. */\n items: ToolbarItem[];\n /** Toolbar usage based on which additional toolbar items are added from UI item providers. */\n usage: ToolbarUsage;\n /** Toolbar orientation. */\n orientation: ToolbarOrientation;\n /** Describes the ids of active toolbar items.\n * By default only the toolbar item with id that matches the active `Tool` id is active.\n */\n activeItemIds?: string[];\n}\n\n/**\n * Toolbar that is populated and maintained by UI item providers.\n * @note Overrides `isActive` property based on the active tool id, unless `activeItemIds` is specified.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function ToolbarComposer(props: ExtensibleToolbarProps) {\n const { usage, orientation, activeItemIds: activeItemIdsProp } = props;\n\n // process items from addon UI providers\n const addonItems = useActiveStageProvidedToolbarItems(usage, orientation);\n\n const allItems = React.useMemo(() => {\n return combineItems(props.items, addonItems);\n }, [props.items, addonItems]);\n\n const activeToolId = useActiveToolId();\n const activeItemIds = React.useMemo(\n () => activeItemIdsProp ?? (activeToolId ? [activeToolId] : []),\n [activeItemIdsProp, activeToolId]\n );\n const items = React.useMemo(() => {\n return updateActiveItems(allItems, activeItemIds);\n }, [allItems, activeItemIds]);\n\n const isDragEnabled = React.useContext(ToolbarDragInteractionContext);\n const useProximityOpacity = useProximityOpacitySetting();\n const snapWidgetOpacity = useSnapWidgetOpacitySetting();\n\n const expandsTo = toExpandsTo(orientation, usage);\n const panelAlignment = toPanelAlignment(orientation, usage);\n return (\n <Toolbar\n enableOverflow={true}\n expandsTo={expandsTo}\n panelAlignment={panelAlignment}\n items={items}\n useDragInteraction={isDragEnabled}\n toolbarOpacitySetting={\n (useProximityOpacity || snapWidgetOpacity) &&\n !ProcessDetector.isMobileBrowser\n ? ToolbarOpacitySetting.Proximity\n : ToolbarOpacitySetting.Defaults\n }\n />\n );\n}\n\nfunction toExpandsTo(orientation: ToolbarOrientation, usage: ToolbarUsage) {\n if (orientation === ToolbarOrientation.Vertical) {\n if (usage === ToolbarUsage.ViewNavigation) return Direction.Left;\n return Direction.Right;\n }\n\n return Direction.Bottom;\n}\n\nfunction toPanelAlignment(\n orientation: ToolbarOrientation,\n usage: ToolbarUsage\n) {\n if (\n orientation === ToolbarOrientation.Horizontal &&\n usage === ToolbarUsage.ViewNavigation\n )\n return ToolbarPanelAlignment.End;\n\n return ToolbarPanelAlignment.Start;\n}\n\n/** @internal */\nexport function updateActiveItems(\n items: ToolbarItem[],\n activeItemIds: string[]\n) {\n return produce(items, (draft) => {\n // Iterative DFS with ancestor backtracking.\n const stack = draft.map((item) => [item, [] as typeof draft] as const);\n\n while (stack.length > 0) {\n const [current, ancestors] = stack.pop()!;\n\n const isActive = activeItemIds.includes(current.id);\n current.isActive = isActive;\n\n if (\"items\" in current) {\n for (const child of current.items) {\n stack.push([child, [...ancestors, current]]);\n }\n }\n\n if (!isActive) continue;\n\n // Mark ancestors of active item as active.\n for (const ancestor of ancestors) {\n ancestor.isActive = true;\n }\n }\n });\n}\n"]}
1
+ {"version":3,"file":"ToolbarComposer.js","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarComposer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACh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AK,EAAE,CAAC;oBAClC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC;YAED,IAAI,CAAC,QAAQ;gBAAE,SAAS;YAExB,2CAA2C;YAC3C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,4DAA4D;gBAC5D,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport { produce } from \"immer\";\nimport {\n Direction,\n ToolbarOpacitySetting,\n ToolbarPanelAlignment,\n} from \"@itwin/components-react\";\nimport { Logger, ProcessDetector } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport { ToolbarDragInteractionContext } from \"./DragInteraction.js\";\nimport type {\n CommonToolbarItem,\n ToolbarActionItem,\n ToolbarGroupItem,\n ToolbarItem,\n} from \"./ToolbarItem.js\";\nimport {\n isToolbarActionItem,\n isToolbarGroupItem,\n ToolbarOrientation,\n ToolbarUsage,\n} from \"./ToolbarItem.js\";\nimport { Toolbar } from \"./Toolbar.js\";\nimport { useActiveStageProvidedToolbarItems } from \"./useActiveStageProvidedToolbarItems.js\";\nimport { useActiveToolId } from \"../hooks/useActiveToolId.js\";\n\nfunction addItemToSpecifiedParentGroup<T extends ToolbarItem>(\n items: readonly T[],\n groupChildren: Array<ToolbarActionItem | ToolbarGroupItem>\n): T[] {\n const outItems: T[] = [];\n for (const toolbarItem of items) {\n if (!isToolbarGroupItem(toolbarItem)) {\n outItems.push(toolbarItem);\n continue;\n }\n\n const newChildren = addItemToSpecifiedParentGroup(\n toolbarItem.items,\n groupChildren\n );\n const foundIndices: number[] = [];\n\n groupChildren.forEach((entry, index) => {\n if (entry.parentGroupItemId === toolbarItem.id) {\n foundIndices.push(index);\n }\n });\n\n if (foundIndices.length) {\n // process in reverse order so groupChildren can be reduced as we find matches\n foundIndices\n .sort((a, b) => a - b)\n .reverse()\n .forEach((foundIndex) => {\n newChildren.push(groupChildren[foundIndex]);\n groupChildren.splice(foundIndex);\n });\n }\n\n outItems.push({ ...toolbarItem, items: newChildren });\n }\n return outItems;\n}\n\nfunction cloneGroup(inGroup: ToolbarGroupItem): ToolbarGroupItem {\n const childItems: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n inGroup.items.forEach((item) => {\n if (isToolbarGroupItem(item)) childItems.push(cloneGroup(item));\n else childItems.push(item);\n });\n\n const clonedGroup = { ...inGroup, items: childItems };\n return clonedGroup;\n}\n\nfunction getItemSortValue(item: ToolbarItem) {\n const groupValue = undefined === item.groupPriority ? 0 : item.groupPriority;\n return groupValue * 10000 + item.itemPriority;\n}\n\nfunction sortItems(items: ReadonlyArray<ToolbarItem>): ToolbarItem[] {\n return [...items]\n .sort((a, b) => getItemSortValue(a) - getItemSortValue(b))\n .map((i) => {\n if (isToolbarGroupItem(i)) {\n return { ...i, items: sortItems(i.items) };\n }\n return i;\n });\n}\n\n/**\n * Create a forEach handler that will add every element of an array of ToolbarItems\n * to a list of items that can then be replaced in its proper place, ensuring that\n * the same item, from different list, is not added multiple times.\n * @param items Output list of items\n * @param groupChildren Output list of group children to redistribute.\n * @returns Array<ToolbarItem>.forEach handler.\n */\nfunction addIfNotDuplicate(\n items: ToolbarItem[],\n groupChildren: (ToolbarActionItem | ToolbarGroupItem)[]\n): (value: ToolbarItem) => void {\n return (srcItem: ToolbarItem) => {\n if (-1 === items.findIndex((item) => item.id === srcItem.id)) {\n // if the default item is a group that an addon may insert into copy it so we don't mess with original\n const toolbarItem = isToolbarGroupItem(srcItem)\n ? cloneGroup(srcItem)\n : srcItem;\n if (\n (isToolbarGroupItem(toolbarItem) || isToolbarActionItem(toolbarItem)) &&\n toolbarItem.parentGroupItemId\n )\n groupChildren.push(toolbarItem);\n else items.push(toolbarItem);\n }\n };\n}\n\n/** local function to combine items from Stage and from Extensions */\nfunction combineItems(\n defaultItems: ReadonlyArray<ToolbarItem>,\n addonItems: ReadonlyArray<ToolbarItem>\n): ToolbarItem[] {\n let items: ToolbarItem[] = [];\n const groupChildren: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n\n defaultItems.forEach(addIfNotDuplicate(items, groupChildren));\n addonItems.forEach(addIfNotDuplicate(items, groupChildren));\n\n // if an item from an addon has specified a parent group then try to find it and insert it. If no parent is found, add item at root level.\n if (groupChildren.length) {\n items = addItemToSpecifiedParentGroup(items, groupChildren);\n\n groupChildren.forEach((toolbarItem) => {\n Logger.logWarning(\n \"ToolbarComposer\",\n `Requested Parent Group [${toolbarItem.parentGroupItemId!}] not found, so item [${\n toolbarItem.id\n }] is added directly to toolbar.`\n );\n items.push(toolbarItem);\n });\n }\n\n return sortItems(items);\n}\n\nconst useProximityOpacitySetting = () => {\n const [proximityOpacity, setProximityOpacity] = React.useState(\n UiFramework.visibility.useProximityOpacity // eslint-disable-line @typescript-eslint/no-deprecated\n );\n\n React.useEffect(() => {\n UiFramework.onUiVisibilityChanged.addListener(\n () => setProximityOpacity(UiFramework.visibility.useProximityOpacity) // eslint-disable-line @typescript-eslint/no-deprecated\n );\n }, []);\n\n return proximityOpacity;\n};\n\nconst useSnapWidgetOpacitySetting = () => {\n const [snapWidgetOpacity, setSnapWidgetOpacity] = React.useState(\n UiFramework.visibility.snapWidgetOpacity\n );\n\n React.useEffect(() => {\n UiFramework.onUiVisibilityChanged.addListener(() =>\n setSnapWidgetOpacity(UiFramework.visibility.snapWidgetOpacity)\n );\n }, []);\n\n return snapWidgetOpacity;\n};\n\n/** Properties for the [[ToolbarComposer]] React components\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof ToolbarComposer>`\n */\nexport interface ExtensibleToolbarProps {\n /** Toolbar items to be displayed in addition to the provided toolbar items. */\n items: ToolbarItem[];\n /** Toolbar usage based on which additional toolbar items are added from UI item providers. */\n usage: ToolbarUsage;\n /** Toolbar orientation. */\n orientation: ToolbarOrientation;\n /** Describes the ids of active toolbar items.\n * By default only the toolbar item with id that matches the active `Tool` id is active.\n * @note Property {@link CommonToolbarItem.isActiveCondition} takes precedence when determining the active state of a toolbar item.\n */\n activeItemIds?: string[];\n}\n\n/**\n * Toolbar that is populated and maintained by UI item providers.\n * @note Overrides {@link CommonToolbarItem.isActive} property based on the active tool id, unless {@link ExtensibleToolbarProps.activeItemIds} is specified.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function ToolbarComposer(props: ExtensibleToolbarProps) {\n const { usage, orientation, activeItemIds: activeItemIdsProp } = props;\n\n // process items from addon UI providers\n const addonItems = useActiveStageProvidedToolbarItems(usage, orientation);\n\n const allItems = React.useMemo(() => {\n return combineItems(props.items, addonItems);\n }, [props.items, addonItems]);\n\n const activeToolId = useActiveToolId();\n const activeItemIds = React.useMemo(\n () => activeItemIdsProp ?? (activeToolId ? [activeToolId] : []),\n [activeItemIdsProp, activeToolId]\n );\n const items = React.useMemo(() => {\n return updateActiveItems(allItems, activeItemIds);\n }, [allItems, activeItemIds]);\n\n const isDragEnabled = React.useContext(ToolbarDragInteractionContext);\n const useProximityOpacity = useProximityOpacitySetting();\n const snapWidgetOpacity = useSnapWidgetOpacitySetting();\n\n const expandsTo = toExpandsTo(orientation, usage);\n const panelAlignment = toPanelAlignment(orientation, usage);\n return (\n <Toolbar\n enableOverflow={true}\n expandsTo={expandsTo}\n panelAlignment={panelAlignment}\n items={items}\n useDragInteraction={isDragEnabled}\n toolbarOpacitySetting={\n (useProximityOpacity || snapWidgetOpacity) &&\n !ProcessDetector.isMobileBrowser\n ? ToolbarOpacitySetting.Proximity\n : ToolbarOpacitySetting.Defaults\n }\n />\n );\n}\n\nfunction toExpandsTo(orientation: ToolbarOrientation, usage: ToolbarUsage) {\n if (orientation === ToolbarOrientation.Vertical) {\n if (usage === ToolbarUsage.ViewNavigation) return Direction.Left;\n return Direction.Right;\n }\n\n return Direction.Bottom;\n}\n\nfunction toPanelAlignment(\n orientation: ToolbarOrientation,\n usage: ToolbarUsage\n) {\n if (\n orientation === ToolbarOrientation.Horizontal &&\n usage === ToolbarUsage.ViewNavigation\n )\n return ToolbarPanelAlignment.End;\n\n return ToolbarPanelAlignment.Start;\n}\n\n/** @internal */\nexport function updateActiveItems(\n items: ToolbarItem[],\n activeItemIds: string[]\n) {\n return produce(items, (draft) => {\n // Iterative DFS with ancestor backtracking.\n const stack = draft.map((item) => [item, [] as typeof draft] as const);\n\n while (stack.length > 0) {\n const [current, ancestors] = stack.pop()!;\n\n const isActive = activeItemIds.includes(current.id);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n current.isActive = isActive;\n\n if (\"items\" in current) {\n for (const child of current.items) {\n stack.push([child, [...ancestors, current]]);\n }\n }\n\n if (!isActive) continue;\n\n // Mark ancestors of active item as active.\n for (const ancestor of ancestors) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ancestor.isActive = true;\n }\n }\n });\n}\n"]}
@@ -38,8 +38,12 @@ export interface CommonToolbarItem {
38
38
  readonly badgeKind?: BadgeKind;
39
39
  /** Optional description */
40
40
  readonly description?: string | ConditionalStringValue;
41
- /** Defines if the item is active (shown with an active stripe/bar). */
41
+ /** Defines if the item is active (shown with an active stripe/bar).
42
+ * @deprecated in 5.13.0. Ignored by `ToolbarComposer` component. Use {@link CommonToolbarItem.isActiveCondition} instead.
43
+ */
42
44
  readonly isActive?: boolean;
45
+ /** Describes if the item is active. Use conditional value to dynamically update the active state. */
46
+ readonly isActiveCondition?: boolean | ConditionalBooleanValue;
43
47
  /** Describes if the item is visible or hidden. The default is for the item to be visible. */
44
48
  readonly isHidden?: boolean | ConditionalBooleanValue;
45
49
  /** Describes if the item is enabled or disabled. The default is for the item to be enabled. */
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarItem.d.ts","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarItem.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAG5D;;GAEG;AACH,oBAAY,YAAY;IACtB,yGAAyG;IACzG,mBAAmB,IAAI;IACvB,8EAA8E;IAC9E,cAAc,IAAI;CACnB;AAED;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,0BAA0B;IAC1B,UAAU,IAAI;IACd,wBAAwB;IACxB,QAAQ,IAAI;CACb;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iIAAiI;IACjI,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACpC;;OAEG;IAEH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,2BAA2B;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAAC;IACvD,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,uBAAuB,CAAC;IACtD,+FAA+F;IAC/F,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,uBAAuB,CAAC;IACxD;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,0C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AAqC;IACrC,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;CAC1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarItem.js","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarItem.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAUH;;GAEG;AACH,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,yGAAyG;IACzG,6EAAuB,CAAA;IACvB,8EAA8E;IAC9E,mEAAkB,CAAA;AACpB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,0BAA0B;IAC1B,uEAAc,CAAA;IACd,wBAAwB;IACxB,mEAAY,CAAA;AACd,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAiGD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAiB;IAEjB,OAAO,SAAS,IAAI,IAAI,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAiB;IAEjB,OAAO,OAAO,IAAI,IAAI,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAiB;IAEjB,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport type {\n ConditionalBooleanValue,\n ConditionalStringValue,\n} from \"@itwin/appui-abstract\";\nimport type { BadgeType, IconSpec } from \"@itwin/core-react\";\nimport type { BadgeKind } from \"@itwin/core-react/internal\";\nimport { UiItemsProvider } from \"../ui-items-provider/UiItemsProvider.js\";\n\n/** Used to specify the usage of the toolbar which determine the toolbar position.\n * @public\n */\nexport enum ToolbarUsage {\n /** Contains tools to Create Update and Delete content - in AppUI this is in top left of content area. */\n ContentManipulation = 0,\n /** Manipulate view/camera - in AppUI this is in top right of content area. */\n ViewNavigation = 1,\n}\n\n/** Used to specify the orientation of the toolbar.\n * @public\n */\nexport enum ToolbarOrientation {\n /** Horizontal toolbar. */\n Horizontal = 0,\n /** Vertical toolbar. */\n Vertical = 1,\n}\n\n/** Describes the data needed to insert a UI items into an existing set of UI items.\n * @public\n */\nexport interface CommonToolbarItem {\n /** Require uniqueId for the item. To ensure uniqueness it is suggested that a namespace prefix of the extension name be used. */\n readonly id: string;\n /** Icon of a toolbar item. */\n readonly iconNode?: React.ReactNode;\n /** Describes badge. Renders no badge if not specified.\n * @deprecated in 4.16.0. Use `badgeKind` property instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n readonly badge?: BadgeType;\n /** Specifies the kind of badge, if any, to be rendered. */\n readonly badgeKind?: BadgeKind;\n /** Optional description */\n readonly description?: string | ConditionalStringValue;\n /** Defines if the item is active (shown with an active stripe/bar). */\n readonly isActive?: boolean;\n /** Describes if the item is visible or hidden. The default is for the item to be visible. */\n readonly isHidden?: boolean | ConditionalBooleanValue;\n /** Describes if the item is enabled or disabled. The default is for the item to be enabled. */\n readonly isDisabled?: boolean | ConditionalBooleanValue;\n /** Specifies the item's grouping value. Items are sorted by group and then item priority. When\n * group priority changes a separator is inserted. It is recommended using values 10 through 100, incrementing by 10. This\n * allows extensions enough gaps to insert their own groups. If the value is not specified a groupPriority of 0 is used.\n */\n readonly groupPriority?: number;\n /** Priority within a toolbar or group. */\n readonly itemPriority: number;\n /** Describes layout specific configuration of a toolbar item.\n * @note Only used by {@link UiItemsProvider.getToolbarItems}.\n */\n readonly layouts?: ToolbarItemLayouts;\n}\n\n/** Describes the data needed to insert an action button into a toolbar.\n * @public\n */\nexport interface ToolbarActionItem extends CommonToolbarItem {\n /** Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id.\n * @deprecated in 4.16.0. Use {@link CommonToolbarItem.iconNode} instead and specify `undefined` for this property. This will be made optional in 5.0.0.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n readonly icon: IconSpec;\n /** label, shown as tool tip on a button or an item label in a group. */\n readonly label: string | ConditionalStringValue;\n /** function to run when the button is pressed. */\n readonly execute: () => void;\n /** Optional parent tool group to add the tool to. */\n readonly parentGroupItemId?: string;\n}\n\n/** Describes the data needed to insert a group button into a toolbar.\n * @public\n */\nexport interface ToolbarGroupItem extends CommonToolbarItem {\n /** Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id.\n * @deprecated in 4.16.0. Use {@link CommonToolbarItem.iconNode} instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n readonly icon: IconSpec;\n /** label, shown as tool tip on group button or a group button label in a group panel. */\n readonly label: string | ConditionalStringValue;\n /** label shown as the title in at top of group panel. */\n readonly panelLabel?: string | ConditionalStringValue;\n /** children of the group */\n readonly items: ReadonlyArray<ToolbarActionItem | ToolbarGroupItem>;\n /** Optional parent tool group to add the tool to. */\n readonly parentGroupItemId?: string;\n}\n\n/** Describes the data needed to insert a custom button into a toolbar.\n * @public\n */\nexport interface ToolbarCustomItem extends CommonToolbarItem {\n /** Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id.\n * @deprecated in 4.16.0. Use {@link CommonToolbarItem.iconNode} instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n readonly icon?: IconSpec;\n /** label, shown as tool tip on group button or a group button label in a group panel. */\n readonly label?: string | ConditionalStringValue;\n /** defines the content to display in popup panel */\n readonly panelContent?: React.ReactNode;\n}\n\n/** Any Button Type that can be inserted into a toolbar.\n * @public\n */\nexport type ToolbarItem =\n | ToolbarActionItem\n | ToolbarGroupItem\n | ToolbarCustomItem;\n\n/** ToolbarActionItem type guard.\n * @public\n */\nexport function isToolbarActionItem(\n item: ToolbarItem\n): item is ToolbarActionItem {\n return \"execute\" in item;\n}\n\n/** ToolbarGroupItem type guard.\n * @public\n */\nexport function isToolbarGroupItem(\n item: ToolbarItem\n): item is ToolbarGroupItem {\n return \"items\" in item;\n}\n\n/** ToolbarCustomItem type guard.\n * @public\n */\nexport function isToolbarCustomItem(\n item: ToolbarItem\n): item is ToolbarCustomItem {\n return !isToolbarActionItem(item) && !isToolbarGroupItem(item);\n}\n\n/** Describes toolbar item configuration specific for each layout.\n * @public\n */\nexport interface ToolbarItemLayouts {\n /** Toolbar item configuration in a standard layout. */\n readonly standard?: StandardLayoutToolbarItem;\n /** Allow additional layout specific configurations.\n * @note Use unique keys to avoid conflicts.\n */\n readonly [layout: string]: unknown;\n}\n\n/** Describes toolbar item configuration specific to a standard layout.\n * @public\n */\nexport interface StandardLayoutToolbarItem {\n /** Describes toolbar usage. */\n readonly usage: ToolbarUsage;\n /** Describes toolbar orientation. */\n readonly orientation: ToolbarOrientation;\n}\n"]}
1
+ {"version":3,"file":"ToolbarItem.js","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarItem.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAUH;;GAEG;AACH,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,yGAAyG;IACzG,6EAAuB,CAAA;IACvB,8EAA8E;IAC9E,mEAAkB,CAAA;AACpB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,0BAA0B;IAC1B,uEAAc,CAAA;IACd,wBAAwB;IACxB,mEAAY,CAAA;AACd,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAqGD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAiB;IAEjB,OAAO,SAAS,IAAI,IAAI,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAiB;IAEjB,OAAO,OAAO,IAAI,IAAI,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAiB;IAEjB,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport type {\n ConditionalBooleanValue,\n ConditionalStringValue,\n} from \"@itwin/appui-abstract\";\nimport type { BadgeType, IconSpec } from \"@itwin/core-react\";\nimport type { BadgeKind } from \"@itwin/core-react/internal\";\nimport { UiItemsProvider } from \"../ui-items-provider/UiItemsProvider.js\";\n\n/** Used to specify the usage of the toolbar which determine the toolbar position.\n * @public\n */\nexport enum ToolbarUsage {\n /** Contains tools to Create Update and Delete content - in AppUI this is in top left of content area. */\n ContentManipulation = 0,\n /** Manipulate view/camera - in AppUI this is in top right of content area. */\n ViewNavigation = 1,\n}\n\n/** Used to specify the orientation of the toolbar.\n * @public\n */\nexport enum ToolbarOrientation {\n /** Horizontal toolbar. */\n Horizontal = 0,\n /** Vertical toolbar. */\n Vertical = 1,\n}\n\n/** Describes the data needed to insert a UI items into an existing set of UI items.\n * @public\n */\nexport interface CommonToolbarItem {\n /** Require uniqueId for the item. To ensure uniqueness it is suggested that a namespace prefix of the extension name be used. */\n readonly id: string;\n /** Icon of a toolbar item. */\n readonly iconNode?: React.ReactNode;\n /** Describes badge. Renders no badge if not specified.\n * @deprecated in 4.16.0. Use `badgeKind` property instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n readonly badge?: BadgeType;\n /** Specifies the kind of badge, if any, to be rendered. */\n readonly badgeKind?: BadgeKind;\n /** Optional description */\n readonly description?: string | ConditionalStringValue;\n /** Defines if the item is active (shown with an active stripe/bar).\n * @deprecated in 5.13.0. Ignored by `ToolbarComposer` component. Use {@link CommonToolbarItem.isActiveCondition} instead.\n */\n readonly isActive?: boolean;\n /** Describes if the item is active. Use conditional value to dynamically update the active state. */\n readonly isActiveCondition?: boolean | ConditionalBooleanValue;\n /** Describes if the item is visible or hidden. The default is for the item to be visible. */\n readonly isHidden?: boolean | ConditionalBooleanValue;\n /** Describes if the item is enabled or disabled. The default is for the item to be enabled. */\n readonly isDisabled?: boolean | ConditionalBooleanValue;\n /** Specifies the item's grouping value. Items are sorted by group and then item priority. When\n * group priority changes a separator is inserted. It is recommended using values 10 through 100, incrementing by 10. This\n * allows extensions enough gaps to insert their own groups. If the value is not specified a groupPriority of 0 is used.\n */\n readonly groupPriority?: number;\n /** Priority within a toolbar or group. */\n readonly itemPriority: number;\n /** Describes layout specific configuration of a toolbar item.\n * @note Only used by {@link UiItemsProvider.getToolbarItems}.\n */\n readonly layouts?: ToolbarItemLayouts;\n}\n\n/** Describes the data needed to insert an action button into a toolbar.\n * @public\n */\nexport interface ToolbarActionItem extends CommonToolbarItem {\n /** Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id.\n * @deprecated in 4.16.0. Use {@link CommonToolbarItem.iconNode} instead and specify `undefined` for this property. This will be made optional in 5.0.0.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n readonly icon: IconSpec;\n /** label, shown as tool tip on a button or an item label in a group. */\n readonly label: string | ConditionalStringValue;\n /** function to run when the button is pressed. */\n readonly execute: () => void;\n /** Optional parent tool group to add the tool to. */\n readonly parentGroupItemId?: string;\n}\n\n/** Describes the data needed to insert a group button into a toolbar.\n * @public\n */\nexport interface ToolbarGroupItem extends CommonToolbarItem {\n /** Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id.\n * @deprecated in 4.16.0. Use {@link CommonToolbarItem.iconNode} instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n readonly icon: IconSpec;\n /** label, shown as tool tip on group button or a group button label in a group panel. */\n readonly label: string | ConditionalStringValue;\n /** label shown as the title in at top of group panel. */\n readonly panelLabel?: string | ConditionalStringValue;\n /** children of the group */\n readonly items: ReadonlyArray<ToolbarActionItem | ToolbarGroupItem>;\n /** Optional parent tool group to add the tool to. */\n readonly parentGroupItemId?: string;\n}\n\n/** Describes the data needed to insert a custom button into a toolbar.\n * @public\n */\nexport interface ToolbarCustomItem extends CommonToolbarItem {\n /** Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id.\n * @deprecated in 4.16.0. Use {@link CommonToolbarItem.iconNode} instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n readonly icon?: IconSpec;\n /** label, shown as tool tip on group button or a group button label in a group panel. */\n readonly label?: string | ConditionalStringValue;\n /** defines the content to display in popup panel */\n readonly panelContent?: React.ReactNode;\n}\n\n/** Any Button Type that can be inserted into a toolbar.\n * @public\n */\nexport type ToolbarItem =\n | ToolbarActionItem\n | ToolbarGroupItem\n | ToolbarCustomItem;\n\n/** ToolbarActionItem type guard.\n * @public\n */\nexport function isToolbarActionItem(\n item: ToolbarItem\n): item is ToolbarActionItem {\n return \"execute\" in item;\n}\n\n/** ToolbarGroupItem type guard.\n * @public\n */\nexport function isToolbarGroupItem(\n item: ToolbarItem\n): item is ToolbarGroupItem {\n return \"items\" in item;\n}\n\n/** ToolbarCustomItem type guard.\n * @public\n */\nexport function isToolbarCustomItem(\n item: ToolbarItem\n): item is ToolbarCustomItem {\n return !isToolbarActionItem(item) && !isToolbarGroupItem(item);\n}\n\n/** Describes toolbar item configuration specific for each layout.\n * @public\n */\nexport interface ToolbarItemLayouts {\n /** Toolbar item configuration in a standard layout. */\n readonly standard?: StandardLayoutToolbarItem;\n /** Allow additional layout specific configurations.\n * @note Use unique keys to avoid conflicts.\n */\n readonly [layout: string]: unknown;\n}\n\n/** Describes toolbar item configuration specific to a standard layout.\n * @public\n */\nexport interface StandardLayoutToolbarItem {\n /** Describes toolbar usage. */\n readonly usage: ToolbarUsage;\n /** Describes toolbar orientation. */\n readonly orientation: ToolbarOrientation;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarItemsManager.d.ts","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarItemsManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,KAAK,EAGV,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAO1B;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CAC5C;AAED;;;;GAIG;AACH,qBAAa,mBAAmB;IAG9B,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAM;gBAEtC,KAAK,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;IAI9C;;OAEG;IACH,SAAgB,cAAc,iBACrB,uBAAuB,KAAK,IAAI,EACrC;IAEJ,OAAO,CAAC,iBAAiB;IAoBzB;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC;IAIlD,yCAAyC;IACzC,IAAW,KAAK,IAAI,aAAa,CAAC,WAAW,CAAC,CAE7C;IAED,IAAW,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,EAEjD;IAEM,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;IAkBhE,uCAAuC;IAChC,MAAM,CACX,eAAe,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAUvE,gBAAgB;IACT,SAAS;IAIhB,OAAO,CAAC,MAAM,CAAC,aAAa;WA2Bd,oBAAoB,CAAC,KAAK,EAAE,SAAS,WAAW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aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAUvE,gBAAgB;IACT,SAAS;IAIhB,OAAO,CAAC,MAAM,CAAC,aAAa;WA2Bd,oBAAoB,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,EAAE;IAM3E,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA8ChC,OAAO,CAAC,4BAA4B;IA6C7B,oBAAoB,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC;IAWjD,OAAO,CAAC,MAAM,CAAC,wCAAwC;IAqBvD,OAAO,CAAC,6BAA6B;IAyBrC,OAAO,CAAC,MAAM,CAAC,+BAA+B;IA0BvC,eAAe,CAAC,MAAM,EAAE,MAAM;CA0BtC"}
@@ -196,6 +196,7 @@ export class ToolbarItemsManager {
196
196
  return true;
197
197
  }
198
198
  else {
199
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
199
200
  const isActive = !!item.isActive;
200
201
  if ((isActive && item.id !== toolId) ||
201
202
  (!isActive && item.id === toolId))
@@ -213,6 +214,7 @@ export class ToolbarItemsManager {
213
214
  return true;
214
215
  }
215
216
  else {
217
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
216
218
  const isActive = !!item.isActive;
217
219
  if ((isActive && item.id !== toolId) ||
218
220
  (!isActive && item.id === toolId))
@@ -232,6 +234,7 @@ export class ToolbarItemsManager {
232
234
  items: ToolbarItemsManager.refreshActiveToolIdInChildItems(updatedItem, toolId),
233
235
  };
234
236
  }
237
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
235
238
  updatedItem.isActive = updatedItem.id === toolId;
236
239
  newChildren.push(updatedItem);
237
240
  }
@@ -251,6 +254,7 @@ export class ToolbarItemsManager {
251
254
  items: ToolbarItemsManager.refreshActiveToolIdInChildItems(updatedItem, toolId),
252
255
  };
253
256
  }
257
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
254
258
  updatedItem.isActive = updatedItem.id === toolId;
255
259
  newItems.push(updatedItem);
256
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AAE,CAAC;YAE9B,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;gBACpC,WAAW,GAAG;oBACZ,GAAG,WAAW;oBACd,4DAA4D;oBAC5D,KAAK,EAAE,mBAAmB,CAAC,+BAA+B,CACxD,WAAW,EACX,MAAM,CACP;iBACF,CAAC;YACJ,CAAC;YAED,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC;YACjD,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAEM,eAAe,CAAC,MAAc;QACnC,gDAAgD;QAChD,IAAI,CAAC,IAAI,CAAC,6BAA6B,CAAC,MAAM,CAAC;YAAE,OAAO;QAExD,MAAM,QAAQ,GAAkB,EAAE,CAAC;QACnC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,IAAI,WAAW,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;YAE9B,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;gBACpC,WAAW,GAAG;oBACZ,GAAG,WAAW;oBACd,4DAA4D;oBAC5D,KAAK,EAAE,mBAAmB,CAAC,+BAA+B,CACxD,WAAW,EACX,MAAM,CACP;iBACF,CAAC;YACJ,CAAC;YAED,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC;YACjD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;IACxB,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 Toolbar\n */\n\nimport {\n ConditionalBooleanValue,\n ConditionalStringValue,\n} from \"@itwin/appui-abstract\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { ConditionalIconItem } from \"@itwin/core-react\";\nimport type {\n ToolbarActionItem,\n ToolbarGroupItem,\n ToolbarItem,\n} from \"./ToolbarItem.js\";\nimport { isToolbarGroupItem } from \"./ToolbarItem.js\";\n\nfunction isInstance<T>(args: T | ReadonlyArray<T>): args is T {\n return !Array.isArray(args);\n}\n\n/** Arguments of [[ToolbarItemsManager.onChanged]] event.\n * @internal\n */\nexport interface ToolbarItemsChangedArgs {\n readonly items: ReadonlyArray<ToolbarItem>;\n}\n\n/**\n * Controls status bar items.\n * @internal\n * @deprecated in 4.4.0. This is no longer used internally, left because of an erroneous public dependency that is also deprecated.\n */\nexport class ToolbarItemsManager {\n // This class should be removed once `useDefaultToolbarItems` and `useUiItemsProviderToolbarItems` (public version) get removed.\n // If you are attempting to fix/clean this class, it is probably an error as it is no longer used and should not be reintroduced, use Hooks instead.\n protected _items: ReadonlyArray<ToolbarItem> = [];\n\n constructor(items?: ReadonlyArray<ToolbarItem>) {\n if (items) this.loadItemsInternal(items, true, false);\n }\n\n /** Event raised when Toolbar items are changed.\n * @internal\n */\n public readonly onItemsChanged = new BeEvent<\n (args: ToolbarItemsChangedArgs) => void\n >();\n\n private loadItemsInternal(\n items: ReadonlyArray<ToolbarItem>,\n processConditions: boolean,\n sendItemChanged: boolean\n ) {\n if (processConditions && items) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const eventIds = ToolbarItemsManager.getSyncIdsOfInterest(items);\n if (0 !== eventIds.length) {\n const { itemsUpdated, updatedItems } =\n this.internalRefreshAffectedItems(items, new Set(eventIds));\n\n if (itemsUpdated) items = updatedItems;\n }\n }\n\n this._items = items;\n if (sendItemChanged) this.onItemsChanged.raiseEvent({ items });\n }\n\n /** load items but do not fire onItemsChanged\n * @internal\n */\n public loadItems(items: ReadonlyArray<ToolbarItem>) {\n this.loadItemsInternal(items, true, false);\n }\n\n /** Get an array of the Toolbar items */\n public get items(): ReadonlyArray<ToolbarItem> {\n return this._items;\n }\n\n public set items(items: ReadonlyArray<ToolbarItem>) {\n if (items !== this._items) this.loadItemsInternal(items, true, true);\n }\n\n public add(itemOrItems: ToolbarItem | ReadonlyArray<ToolbarItem>) {\n let itemsToAdd;\n if (isInstance(itemOrItems)) itemsToAdd = [itemOrItems];\n else {\n itemsToAdd = itemOrItems.filter(\n (itemToAdd, index) =>\n itemOrItems.findIndex((item) => item.id === itemToAdd.id) === index\n );\n }\n itemsToAdd = itemsToAdd.filter(\n (itemToAdd) =>\n this._items.find((item) => item.id === itemToAdd.id) === undefined\n );\n if (itemsToAdd.length === 0) return;\n const items = [...this._items, ...itemsToAdd];\n this.items = items;\n }\n\n /** Remove Toolbar items based on id */\n public remove(\n itemIdOrItemIds: ToolbarItem[\"id\"] | ReadonlyArray<ToolbarItem[\"id\"]>\n ) {\n const items = this._items.filter((item) => {\n return isInstance(itemIdOrItemIds)\n ? item.id !== itemIdOrItemIds\n : !itemIdOrItemIds.find((itemId) => itemId === item.id);\n });\n this.items = items;\n }\n\n /** @internal */\n public removeAll() {\n this._items = [];\n }\n\n private static gatherSyncIds(\n eventIds: Set<string>,\n items: readonly ToolbarItem[]\n ) {\n for (const item of items) {\n for (const [, entry] of Object.entries(item)) {\n if (entry instanceof ConditionalBooleanValue) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n } else if (entry instanceof ConditionalStringValue) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n } else if (entry instanceof ConditionalIconItem) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n }\n }\n if (isToolbarGroupItem(item)) {\n this.gatherSyncIds(eventIds, item.items);\n }\n }\n }\n\n public static getSyncIdsOfInterest(items: readonly ToolbarItem[]): string[] {\n const eventIds = new Set<string>();\n this.gatherSyncIds(eventIds, items);\n return [...eventIds.values()];\n }\n\n private static refreshChildItems(\n parentItem: ToolbarGroupItem,\n eventIds: Set<string>\n ): {\n childrenUpdated: boolean;\n childItems: ReadonlyArray<ToolbarActionItem | ToolbarGroupItem>;\n } {\n const updatedItems: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n let itemsUpdated = false;\n\n for (const item of parentItem.items) {\n let updatedItem;\n if (isToolbarGroupItem(item)) {\n updatedItem = { ...item };\n const { childrenUpdated, childItems } = this.refreshChildItems(\n updatedItem,\n eventIds\n );\n if (childrenUpdated) {\n updatedItem.items = childItems;\n itemsUpdated = true;\n }\n } else {\n updatedItem = { ...item };\n }\n\n for (const [, entry] of Object.entries(updatedItem)) {\n if (entry instanceof ConditionalBooleanValue) {\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\n itemsUpdated = true;\n } else if (entry instanceof ConditionalStringValue) {\n if (ConditionalStringValue.refreshValue(entry, eventIds))\n itemsUpdated = true;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n } else if (entry instanceof ConditionalIconItem) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (ConditionalIconItem.refreshValue(entry, eventIds))\n itemsUpdated = true;\n }\n }\n\n updatedItems.push(updatedItem);\n }\n return { childrenUpdated: itemsUpdated, childItems: updatedItems };\n }\n\n private internalRefreshAffectedItems(\n items: readonly ToolbarItem[],\n eventIds: Set<string>\n ): { itemsUpdated: boolean; updatedItems: ToolbarItem[] } {\n if (0 === eventIds.size) return { itemsUpdated: false, updatedItems: [] };\n\n let updateRequired = false;\n\n const newItems: ToolbarItem[] = [];\n for (const item of items) {\n let updatedItem = { ...item };\n if (isToolbarGroupItem(updatedItem)) {\n const { childrenUpdated, childItems } =\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ToolbarItemsManager.refreshChildItems(updatedItem, eventIds);\n if (childrenUpdated) {\n updatedItem = {\n ...updatedItem,\n items: childItems,\n };\n updateRequired = true;\n }\n }\n\n for (const [, entry] of Object.entries(updatedItem)) {\n if (entry instanceof ConditionalBooleanValue) {\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\n updateRequired = true;\n } else if (entry instanceof ConditionalStringValue) {\n if (ConditionalStringValue.refreshValue(entry, eventIds))\n updateRequired = true;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n } else if (entry instanceof ConditionalIconItem) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (ConditionalIconItem.refreshValue(entry, eventIds))\n updateRequired = true;\n }\n }\n\n newItems.push(updatedItem);\n }\n\n return { itemsUpdated: updateRequired, updatedItems: newItems };\n }\n\n public refreshAffectedItems(eventIds: Set<string>) {\n if (0 === eventIds.size) return;\n\n const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(\n this.items,\n eventIds\n );\n\n if (itemsUpdated) this.loadItemsInternal(updatedItems, false, true);\n }\n\n private static isActiveToolIdRefreshRequiredForChildren(\n children: ReadonlyArray<ToolbarActionItem | ToolbarGroupItem>,\n toolId: string\n ): boolean {\n for (const item of children) {\n if (isToolbarGroupItem(item)) {\n if (this.isActiveToolIdRefreshRequiredForChildren(item.items, toolId))\n return true;\n } else {\n const isActive = !!item.isActive;\n if (\n (isActive && item.id !== toolId) ||\n (!isActive && item.id === toolId)\n )\n return true;\n }\n }\n return false;\n }\n\n private isActiveToolIdRefreshRequired(toolId: string): boolean {\n for (const item of this.items) {\n if (isToolbarGroupItem(item)) {\n if (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ToolbarItemsManager.isActiveToolIdRefreshRequiredForChildren(\n item.items,\n toolId\n )\n )\n return true;\n } else {\n const isActive = !!item.isActive;\n if (\n (isActive && item.id !== toolId) ||\n (!isActive && item.id === toolId)\n )\n return true;\n }\n }\n\n return false;\n }\n\n private static refreshActiveToolIdInChildItems(\n parentItem: ToolbarGroupItem,\n toolId: string\n ): Array<ToolbarActionItem | ToolbarGroupItem> {\n const newChildren: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n for (const item of parentItem.items) {\n let updatedItem = { ...item };\n\n if (isToolbarGroupItem(updatedItem)) {\n updatedItem = {\n ...updatedItem,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n items: ToolbarItemsManager.refreshActiveToolIdInChildItems(\n updatedItem,\n toolId\n ),\n };\n }\n\n updatedItem.isActive = updatedItem.id === toolId;\n newChildren.push(updatedItem);\n }\n return newChildren;\n }\n\n public setActiveToolId(toolId: string) {\n // first see if any updates are really necessary\n if (!this.isActiveToolIdRefreshRequired(toolId)) return;\n\n const newItems: ToolbarItem[] = [];\n for (const item of this.items) {\n let updatedItem = { ...item };\n\n if (isToolbarGroupItem(updatedItem)) {\n updatedItem = {\n ...updatedItem,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n items: ToolbarItemsManager.refreshActiveToolIdInChildItems(\n updatedItem,\n toolId\n ),\n };\n }\n\n updatedItem.isActive = updatedItem.id === toolId;\n newItems.push(updatedItem);\n }\n\n this.items = newItems;\n }\n}\n"]}
1
+ {"version":3,"file":"ToolbarItemsManager.js","sourceRoot":"","sources":["../../../src/appui-react/toolbar/ToolbarItemsManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAMxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,SAAS,UAAU,CAAI,IAA0B;IAC/C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AASD;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAK9B,YAAY,KAAkC;QAJ9C,gIAAgI;QAChI,oJAAoJ;QAC1I,WAAM,GAA+B,EAAE,CAAC;QAMlD;;WAEG;QACa,mBAAc,GAAG,IAAI,OAAO,EAEzC,CAAC;QARF,IA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EAAE,CAAC;YAE9B,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;gBACpC,WAAW,GAAG;oBACZ,GAAG,WAAW;oBACd,4DAA4D;oBAC5D,KAAK,EAAE,mBAAmB,CAAC,+BAA+B,CACxD,WAAW,EACX,MAAM,CACP;iBACF,CAAC;YACJ,CAAC;YAED,4DAA4D;YAC5D,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC;YACjD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;IACxB,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 Toolbar\n */\n\nimport {\n ConditionalBooleanValue,\n ConditionalStringValue,\n} from \"@itwin/appui-abstract\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { ConditionalIconItem } from \"@itwin/core-react\";\nimport type {\n ToolbarActionItem,\n ToolbarGroupItem,\n ToolbarItem,\n} from \"./ToolbarItem.js\";\nimport { isToolbarGroupItem } from \"./ToolbarItem.js\";\n\nfunction isInstance<T>(args: T | ReadonlyArray<T>): args is T {\n return !Array.isArray(args);\n}\n\n/** Arguments of [[ToolbarItemsManager.onChanged]] event.\n * @internal\n */\nexport interface ToolbarItemsChangedArgs {\n readonly items: ReadonlyArray<ToolbarItem>;\n}\n\n/**\n * Controls status bar items.\n * @internal\n * @deprecated in 4.4.0. This is no longer used internally, left because of an erroneous public dependency that is also deprecated.\n */\nexport class ToolbarItemsManager {\n // This class should be removed once `useDefaultToolbarItems` and `useUiItemsProviderToolbarItems` (public version) get removed.\n // If you are attempting to fix/clean this class, it is probably an error as it is no longer used and should not be reintroduced, use Hooks instead.\n protected _items: ReadonlyArray<ToolbarItem> = [];\n\n constructor(items?: ReadonlyArray<ToolbarItem>) {\n if (items) this.loadItemsInternal(items, true, false);\n }\n\n /** Event raised when Toolbar items are changed.\n * @internal\n */\n public readonly onItemsChanged = new BeEvent<\n (args: ToolbarItemsChangedArgs) => void\n >();\n\n private loadItemsInternal(\n items: ReadonlyArray<ToolbarItem>,\n processConditions: boolean,\n sendItemChanged: boolean\n ) {\n if (processConditions && items) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const eventIds = ToolbarItemsManager.getSyncIdsOfInterest(items);\n if (0 !== eventIds.length) {\n const { itemsUpdated, updatedItems } =\n this.internalRefreshAffectedItems(items, new Set(eventIds));\n\n if (itemsUpdated) items = updatedItems;\n }\n }\n\n this._items = items;\n if (sendItemChanged) this.onItemsChanged.raiseEvent({ items });\n }\n\n /** load items but do not fire onItemsChanged\n * @internal\n */\n public loadItems(items: ReadonlyArray<ToolbarItem>) {\n this.loadItemsInternal(items, true, false);\n }\n\n /** Get an array of the Toolbar items */\n public get items(): ReadonlyArray<ToolbarItem> {\n return this._items;\n }\n\n public set items(items: ReadonlyArray<ToolbarItem>) {\n if (items !== this._items) this.loadItemsInternal(items, true, true);\n }\n\n public add(itemOrItems: ToolbarItem | ReadonlyArray<ToolbarItem>) {\n let itemsToAdd;\n if (isInstance(itemOrItems)) itemsToAdd = [itemOrItems];\n else {\n itemsToAdd = itemOrItems.filter(\n (itemToAdd, index) =>\n itemOrItems.findIndex((item) => item.id === itemToAdd.id) === index\n );\n }\n itemsToAdd = itemsToAdd.filter(\n (itemToAdd) =>\n this._items.find((item) => item.id === itemToAdd.id) === undefined\n );\n if (itemsToAdd.length === 0) return;\n const items = [...this._items, ...itemsToAdd];\n this.items = items;\n }\n\n /** Remove Toolbar items based on id */\n public remove(\n itemIdOrItemIds: ToolbarItem[\"id\"] | ReadonlyArray<ToolbarItem[\"id\"]>\n ) {\n const items = this._items.filter((item) => {\n return isInstance(itemIdOrItemIds)\n ? item.id !== itemIdOrItemIds\n : !itemIdOrItemIds.find((itemId) => itemId === item.id);\n });\n this.items = items;\n }\n\n /** @internal */\n public removeAll() {\n this._items = [];\n }\n\n private static gatherSyncIds(\n eventIds: Set<string>,\n items: readonly ToolbarItem[]\n ) {\n for (const item of items) {\n for (const [, entry] of Object.entries(item)) {\n if (entry instanceof ConditionalBooleanValue) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n } else if (entry instanceof ConditionalStringValue) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n } else if (entry instanceof ConditionalIconItem) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n }\n }\n if (isToolbarGroupItem(item)) {\n this.gatherSyncIds(eventIds, item.items);\n }\n }\n }\n\n public static getSyncIdsOfInterest(items: readonly ToolbarItem[]): string[] {\n const eventIds = new Set<string>();\n this.gatherSyncIds(eventIds, items);\n return [...eventIds.values()];\n }\n\n private static refreshChildItems(\n parentItem: ToolbarGroupItem,\n eventIds: Set<string>\n ): {\n childrenUpdated: boolean;\n childItems: ReadonlyArray<ToolbarActionItem | ToolbarGroupItem>;\n } {\n const updatedItems: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n let itemsUpdated = false;\n\n for (const item of parentItem.items) {\n let updatedItem;\n if (isToolbarGroupItem(item)) {\n updatedItem = { ...item };\n const { childrenUpdated, childItems } = this.refreshChildItems(\n updatedItem,\n eventIds\n );\n if (childrenUpdated) {\n updatedItem.items = childItems;\n itemsUpdated = true;\n }\n } else {\n updatedItem = { ...item };\n }\n\n for (const [, entry] of Object.entries(updatedItem)) {\n if (entry instanceof ConditionalBooleanValue) {\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\n itemsUpdated = true;\n } else if (entry instanceof ConditionalStringValue) {\n if (ConditionalStringValue.refreshValue(entry, eventIds))\n itemsUpdated = true;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n } else if (entry instanceof ConditionalIconItem) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (ConditionalIconItem.refreshValue(entry, eventIds))\n itemsUpdated = true;\n }\n }\n\n updatedItems.push(updatedItem);\n }\n return { childrenUpdated: itemsUpdated, childItems: updatedItems };\n }\n\n private internalRefreshAffectedItems(\n items: readonly ToolbarItem[],\n eventIds: Set<string>\n ): { itemsUpdated: boolean; updatedItems: ToolbarItem[] } {\n if (0 === eventIds.size) return { itemsUpdated: false, updatedItems: [] };\n\n let updateRequired = false;\n\n const newItems: ToolbarItem[] = [];\n for (const item of items) {\n let updatedItem = { ...item };\n if (isToolbarGroupItem(updatedItem)) {\n const { childrenUpdated, childItems } =\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ToolbarItemsManager.refreshChildItems(updatedItem, eventIds);\n if (childrenUpdated) {\n updatedItem = {\n ...updatedItem,\n items: childItems,\n };\n updateRequired = true;\n }\n }\n\n for (const [, entry] of Object.entries(updatedItem)) {\n if (entry instanceof ConditionalBooleanValue) {\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\n updateRequired = true;\n } else if (entry instanceof ConditionalStringValue) {\n if (ConditionalStringValue.refreshValue(entry, eventIds))\n updateRequired = true;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n } else if (entry instanceof ConditionalIconItem) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (ConditionalIconItem.refreshValue(entry, eventIds))\n updateRequired = true;\n }\n }\n\n newItems.push(updatedItem);\n }\n\n return { itemsUpdated: updateRequired, updatedItems: newItems };\n }\n\n public refreshAffectedItems(eventIds: Set<string>) {\n if (0 === eventIds.size) return;\n\n const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(\n this.items,\n eventIds\n );\n\n if (itemsUpdated) this.loadItemsInternal(updatedItems, false, true);\n }\n\n private static isActiveToolIdRefreshRequiredForChildren(\n children: ReadonlyArray<ToolbarActionItem | ToolbarGroupItem>,\n toolId: string\n ): boolean {\n for (const item of children) {\n if (isToolbarGroupItem(item)) {\n if (this.isActiveToolIdRefreshRequiredForChildren(item.items, toolId))\n return true;\n } else {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const isActive = !!item.isActive;\n if (\n (isActive && item.id !== toolId) ||\n (!isActive && item.id === toolId)\n )\n return true;\n }\n }\n return false;\n }\n\n private isActiveToolIdRefreshRequired(toolId: string): boolean {\n for (const item of this.items) {\n if (isToolbarGroupItem(item)) {\n if (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ToolbarItemsManager.isActiveToolIdRefreshRequiredForChildren(\n item.items,\n toolId\n )\n )\n return true;\n } else {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const isActive = !!item.isActive;\n if (\n (isActive && item.id !== toolId) ||\n (!isActive && item.id === toolId)\n )\n return true;\n }\n }\n\n return false;\n }\n\n private static refreshActiveToolIdInChildItems(\n parentItem: ToolbarGroupItem,\n toolId: string\n ): Array<ToolbarActionItem | ToolbarGroupItem> {\n const newChildren: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n for (const item of parentItem.items) {\n let updatedItem = { ...item };\n\n if (isToolbarGroupItem(updatedItem)) {\n updatedItem = {\n ...updatedItem,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n items: ToolbarItemsManager.refreshActiveToolIdInChildItems(\n updatedItem,\n toolId\n ),\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n updatedItem.isActive = updatedItem.id === toolId;\n newChildren.push(updatedItem);\n }\n return newChildren;\n }\n\n public setActiveToolId(toolId: string) {\n // first see if any updates are really necessary\n if (!this.isActiveToolIdRefreshRequired(toolId)) return;\n\n const newItems: ToolbarItem[] = [];\n for (const item of this.items) {\n let updatedItem = { ...item };\n\n if (isToolbarGroupItem(updatedItem)) {\n updatedItem = {\n ...updatedItem,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n items: ToolbarItemsManager.refreshActiveToolIdInChildItems(\n updatedItem,\n toolId\n ),\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n updatedItem.isActive = updatedItem.id === toolId;\n newItems.push(updatedItem);\n }\n\n this.items = newItems;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"GroupItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/GroupItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAStC,UAAU,cAAc;IACtB,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAED,gBAAgB;AAChB,eAAO,MAAM,SAAS,0FAyBrB,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,mBAAmB,sHAGlC;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,kBAAkB,4BAwClE"}
1
+ {"version":3,"file":"GroupItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/GroupItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAStC,UAAU,cAAc;IACtB,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAED,gBAAgB;AAChB,eAAO,MAAM,SAAS,0FAyBrB,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,mBAAmB,sHAGlC;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,kBAAkB,4BAyClE"}
@@ -45,7 +45,7 @@ export function GroupMenuItem({ item, onClose }) {
45
45
  const label = useConditionalProp(item.label);
46
46
  const isDisabled = useConditionalProp(item.isDisabled);
47
47
  const isHidden = useConditionalProp(item.isHidden);
48
- const isActive = useConditionalProp(item.isActive);
48
+ const isActiveCondition = useConditionalProp(item.isActiveCondition);
49
49
  if (isHidden) {
50
50
  return null;
51
51
  }
@@ -59,7 +59,9 @@ export function GroupMenuItem({ item, onClose }) {
59
59
  onItemExecuted?.(item);
60
60
  onClose?.();
61
61
  }
62
- }, isSelected: isActive, "data-item-id": item.id },
62
+ },
63
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
64
+ isSelected: isActiveCondition ?? item.isActive, "data-item-id": item.id },
63
65
  React.createElement(Badge, { badge: item.badge, badgeKind: item.badgeKind }),
64
66
  label));
65
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"GroupItem.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/GroupItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,GAEnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,Y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AAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,GAAI;QACtD,KAAK,CACG,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAiB,EAAE,OAAoB;IAC1D,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAClC,OAAO,CACL,oBAAC,aAAa,IAAC,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAI,CACxE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,oBAAC,gBAAgB,IAAC,GAAG,EAAE,IAAI,CAAC,EAAE,IAAG,IAAI,CAAC,YAAY,CAAoB;SACvE,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { DropdownMenu, MenuExtraContent, MenuItem } from \"@itwin/itwinui-react\";\nimport type { ToolbarItem } from \"../../toolbar/ToolbarItem.js\";\nimport {\n isToolbarActionItem,\n isToolbarCustomItem,\n isToolbarGroupItem,\n type ToolbarGroupItem,\n} from \"../../toolbar/ToolbarItem.js\";\nimport { useConditionalProp } from \"../../hooks/useConditionalProp.js\";\nimport { ExpandIndicator } from \"./ExpandIndicator.js\";\nimport { Item } from \"./Item.js\";\nimport { Badge } from \"./Badge.js\";\nimport { ToolGroupOverflowContext } from \"./OverflowButton.js\";\nimport { ToolbarContext } from \"./Toolbar.js\";\nimport { useSafeContext } from \"../../hooks/useSafeContext.js\";\n\ninterface GroupItemProps {\n item: ToolbarGroupItem;\n}\n\n/** @internal */\nexport const GroupItem = React.forwardRef<HTMLButtonElement, GroupItemProps>(\n function GroupItem({ item }, ref) {\n const placement = usePopoverPlacement();\n const { setPopoverOpen } = useSafeContext(ToolbarContext);\n const overflowContext = React.useContext(ToolGroupOverflowContext);\n\n if (overflowContext) {\n return <GroupMenuItem item={item} onClose={overflowContext.onClose} />;\n }\n return (\n <DropdownMenu\n menuItems={(close) => {\n return toMenuItems(item, close);\n }}\n placement={placement}\n onVisibleChange={(newVisible) => {\n setPopoverOpen(newVisible);\n }}\n >\n <Item item={item} ref={ref}>\n <ExpandIndicator />\n </Item>\n </DropdownMenu>\n );\n }\n);\n\n/** @internal */\nexport function usePopoverPlacement() {\n const { expandsTo, panelAlignment } = useSafeContext(ToolbarContext);\n return `${expandsTo}-${panelAlignment}` as const;\n}\n\ninterface GroupMenuItemProps {\n item: ToolbarItem;\n onClose?: () => void;\n}\n\n/** @internal */\nexport function GroupMenuItem({ item, onClose }: GroupMenuItemProps) {\n const { onItemExecuted } = useSafeContext(ToolbarContext);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const iconSpec = useConditionalProp(item.icon);\n const label = useConditionalProp(item.label);\n const isDisabled = useConditionalProp(item.isDisabled);\n const isHidden = useConditionalProp(item.isHidden);\n const isActive = useConditionalProp(item.isActive);\n\n if (isHidden) {\n return null;\n }\n\n const subMenuItems = isDisabled ? undefined : toMenuItems(item, onClose);\n const startIcon = item.iconNode ? (\n <>{item.iconNode}</>\n ) : (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={iconSpec} />\n );\n return (\n <MenuItem\n startIcon={startIcon}\n disabled={isDisabled}\n subMenuItems={subMenuItems}\n onClick={() => {\n if (isToolbarActionItem(item)) {\n item.execute();\n onItemExecuted?.(item);\n onClose?.();\n }\n }}\n isSelected={isActive}\n data-item-id={item.id}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Badge badge={item.badge} badgeKind={item.badgeKind} />\n {label}\n </MenuItem>\n );\n}\n\nfunction toMenuItems(item: ToolbarItem, onClose?: () => void) {\n if (isToolbarGroupItem(item)) {\n return item.items.map((groupItem) => {\n return (\n <GroupMenuItem key={groupItem.id} item={groupItem} onClose={onClose} />\n );\n });\n }\n if (isToolbarCustomItem(item)) {\n return [\n <MenuExtraContent key={item.id}>{item.panelContent}</MenuExtraContent>,\n ];\n }\n return [];\n}\n"]}
1
+ {"version":3,"file":"GroupItem.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/GroupItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,GAEnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAM/D,gBAAgB;AAChB,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CACvC,SAAS,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG;IAC9B,MAAM,SAAS,GAAG,mBAAmB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AE;YAClC,OAAO,CACL,oBAAC,aAAa,IAAC,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAI,CACxE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,oBAAC,gBAAgB,IAAC,GAAG,EAAE,IAAI,CAAC,EAAE,IAAG,IAAI,CAAC,YAAY,CAAoB;SACvE,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { DropdownMenu, MenuExtraContent, MenuItem } from \"@itwin/itwinui-react\";\nimport type { ToolbarItem } from \"../../toolbar/ToolbarItem.js\";\nimport {\n isToolbarActionItem,\n isToolbarCustomItem,\n isToolbarGroupItem,\n type ToolbarGroupItem,\n} from \"../../toolbar/ToolbarItem.js\";\nimport { useConditionalProp } from \"../../hooks/useConditionalProp.js\";\nimport { ExpandIndicator } from \"./ExpandIndicator.js\";\nimport { Item } from \"./Item.js\";\nimport { Badge } from \"./Badge.js\";\nimport { ToolGroupOverflowContext } from \"./OverflowButton.js\";\nimport { ToolbarContext } from \"./Toolbar.js\";\nimport { useSafeContext } from \"../../hooks/useSafeContext.js\";\n\ninterface GroupItemProps {\n item: ToolbarGroupItem;\n}\n\n/** @internal */\nexport const GroupItem = React.forwardRef<HTMLButtonElement, GroupItemProps>(\n function GroupItem({ item }, ref) {\n const placement = usePopoverPlacement();\n const { setPopoverOpen } = useSafeContext(ToolbarContext);\n const overflowContext = React.useContext(ToolGroupOverflowContext);\n\n if (overflowContext) {\n return <GroupMenuItem item={item} onClose={overflowContext.onClose} />;\n }\n return (\n <DropdownMenu\n menuItems={(close) => {\n return toMenuItems(item, close);\n }}\n placement={placement}\n onVisibleChange={(newVisible) => {\n setPopoverOpen(newVisible);\n }}\n >\n <Item item={item} ref={ref}>\n <ExpandIndicator />\n </Item>\n </DropdownMenu>\n );\n }\n);\n\n/** @internal */\nexport function usePopoverPlacement() {\n const { expandsTo, panelAlignment } = useSafeContext(ToolbarContext);\n return `${expandsTo}-${panelAlignment}` as const;\n}\n\ninterface GroupMenuItemProps {\n item: ToolbarItem;\n onClose?: () => void;\n}\n\n/** @internal */\nexport function GroupMenuItem({ item, onClose }: GroupMenuItemProps) {\n const { onItemExecuted } = useSafeContext(ToolbarContext);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const iconSpec = useConditionalProp(item.icon);\n const label = useConditionalProp(item.label);\n const isDisabled = useConditionalProp(item.isDisabled);\n const isHidden = useConditionalProp(item.isHidden);\n const isActiveCondition = useConditionalProp(item.isActiveCondition);\n\n if (isHidden) {\n return null;\n }\n\n const subMenuItems = isDisabled ? undefined : toMenuItems(item, onClose);\n const startIcon = item.iconNode ? (\n <>{item.iconNode}</>\n ) : (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={iconSpec} />\n );\n return (\n <MenuItem\n startIcon={startIcon}\n disabled={isDisabled}\n subMenuItems={subMenuItems}\n onClick={() => {\n if (isToolbarActionItem(item)) {\n item.execute();\n onItemExecuted?.(item);\n onClose?.();\n }\n }}\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n isSelected={isActiveCondition ?? item.isActive}\n data-item-id={item.id}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Badge badge={item.badge} badgeKind={item.badgeKind} />\n {label}\n </MenuItem>\n );\n}\n\nfunction toMenuItems(item: ToolbarItem, onClose?: () => void) {\n if (isToolbarGroupItem(item)) {\n return item.items.map((groupItem) => {\n return (\n <GroupMenuItem key={groupItem.id} item={groupItem} onClose={onClose} />\n );\n });\n }\n if (isToolbarCustomItem(item)) {\n return [\n <MenuExtraContent key={item.id}>{item.panelContent}</MenuExtraContent>,\n ];\n }\n return [];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/Item.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAOhE,UAAU,SAAU,SAAQ,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;IAC1E,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,gBAAgB;AAChB,eAAO,MAAM,IAAI,kGAsChB,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,aAAa;;;;EAS5B"}
1
+ {"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/Item.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAOhE,UAAU,SAAU,SAAQ,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;IAC1E,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,gBAAgB;AAChB,eAAO,MAAM,IAAI,kGAwChB,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,aAAa;;;;EAS5B"}
@@ -18,13 +18,16 @@ export const Item = React.forwardRef(function Item(props, ref) {
18
18
  const { item, ...other } = props;
19
19
  const { renderSeparator } = useSafeContext(ToolbarItemContext);
20
20
  const label = useConditionalProp(item.label);
21
+ const isActiveCondition = useConditionalProp(item.isActiveCondition);
21
22
  const isDisabled = useConditionalProp(item.isDisabled);
22
23
  const isHidden = useConditionalProp(item.isHidden);
23
24
  // eslint-disable-next-line @typescript-eslint/no-deprecated
24
25
  const iconSpec = useConditionalProp(item.icon);
25
26
  const labelProps = useLabelProps();
26
27
  return (React.createElement(React.Fragment, null,
27
- isHidden ? undefined : (React.createElement(IconButton, { styleType: "borderless", disabled: isDisabled, isActive: item.isActive, label: label, labelProps: labelProps, style: props.style, ref: ref, "data-item-id": item.id, ...other },
28
+ isHidden ? undefined : (React.createElement(IconButton, { styleType: "borderless", disabled: isDisabled,
29
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
30
+ isActive: isActiveCondition ?? item.isActive, label: label, labelProps: labelProps, style: props.style, ref: ref, "data-item-id": item.id, ...other },
28
31
  item.iconNode ?? (
29
32
  /* eslint-disable-next-line @typescript-eslint/no-deprecated */
30
33
  React.createElement(Icon, { iconSpec: iconSpec })),
@@ -1 +1 @@
1
- {"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/Item.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAM3C,gBAAgB;AAChB,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAClC,SAAS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Ac,CAAC,cAAc,CAAC,CAAC;IAClE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC;IACtD,OAAO;QACL,SAAS,EAAE,SAAS;QACpB,OAAO;QACP,eAAe,EAAE,kBAAkB;KAC3B,CAAC;AACb,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport type { ToolbarItem } from \"../../toolbar/ToolbarItem.js\";\nimport { useConditionalProp } from \"../../hooks/useConditionalProp.js\";\nimport { Badge } from \"./Badge.js\";\nimport { ToolbarContext, ToolbarItemContext } from \"./Toolbar.js\";\nimport { useSafeContext } from \"../../hooks/useSafeContext.js\";\nimport { Separator } from \"./Separator.js\";\n\ninterface ItemProps extends Partial<React.ComponentProps<typeof IconButton>> {\n item: ToolbarItem;\n}\n\n/** @internal */\nexport const Item = React.forwardRef<HTMLButtonElement, ItemProps>(\n function Item(props, ref) {\n const { item, ...other } = props;\n const { renderSeparator } = useSafeContext(ToolbarItemContext);\n const label = useConditionalProp(item.label);\n const isDisabled = useConditionalProp(item.isDisabled);\n const isHidden = useConditionalProp(item.isHidden);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const iconSpec = useConditionalProp(item.icon);\n const labelProps = useLabelProps();\n\n return (\n <>\n {isHidden ? undefined : (\n <IconButton\n styleType=\"borderless\"\n disabled={isDisabled}\n isActive={item.isActive}\n label={label}\n labelProps={labelProps}\n style={props.style}\n ref={ref}\n data-item-id={item.id}\n {...other}\n >\n {item.iconNode ?? (\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n <Icon iconSpec={iconSpec} />\n )}\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Badge badge={item.badge} badgeKind={item.badgeKind} />\n {props.children}\n </IconButton>\n )}\n {renderSeparator && <Separator />}\n </>\n );\n }\n);\n\n/** @internal */\nexport function useLabelProps() {\n const { popoverOpen, expandsTo } = useSafeContext(ToolbarContext);\n const [internalVisible, setInternalVisible] = React.useState(false);\n const visible = popoverOpen ? false : internalVisible;\n return {\n placement: expandsTo,\n visible,\n onVisibleChange: setInternalVisible,\n } as const;\n}\n"]}
1
+ {"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/Item.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAM3C,gBAAgB;AAChB,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAClC,SAAS,IAAI,CAAC,KAAK,EAAE,GAAG;IACtB,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;IACjC,MAAM,EAAE,eAAe,EAAE,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CA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IACpE,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC;IACtD,OAAO;QACL,SAAS,EAAE,SAAS;QACpB,OAAO;QACP,eAAe,EAAE,kBAAkB;KAC3B,CAAC;AACb,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport type { ToolbarItem } from \"../../toolbar/ToolbarItem.js\";\nimport { useConditionalProp } from \"../../hooks/useConditionalProp.js\";\nimport { Badge } from \"./Badge.js\";\nimport { ToolbarContext, ToolbarItemContext } from \"./Toolbar.js\";\nimport { useSafeContext } from \"../../hooks/useSafeContext.js\";\nimport { Separator } from \"./Separator.js\";\n\ninterface ItemProps extends Partial<React.ComponentProps<typeof IconButton>> {\n item: ToolbarItem;\n}\n\n/** @internal */\nexport const Item = React.forwardRef<HTMLButtonElement, ItemProps>(\n function Item(props, ref) {\n const { item, ...other } = props;\n const { renderSeparator } = useSafeContext(ToolbarItemContext);\n const label = useConditionalProp(item.label);\n const isActiveCondition = useConditionalProp(item.isActiveCondition);\n const isDisabled = useConditionalProp(item.isDisabled);\n const isHidden = useConditionalProp(item.isHidden);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const iconSpec = useConditionalProp(item.icon);\n const labelProps = useLabelProps();\n\n return (\n <>\n {isHidden ? undefined : (\n <IconButton\n styleType=\"borderless\"\n disabled={isDisabled}\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n isActive={isActiveCondition ?? item.isActive}\n label={label}\n labelProps={labelProps}\n style={props.style}\n ref={ref}\n data-item-id={item.id}\n {...other}\n >\n {item.iconNode ?? (\n /* eslint-disable-next-line @typescript-eslint/no-deprecated */\n <Icon iconSpec={iconSpec} />\n )}\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Badge badge={item.badge} badgeKind={item.badgeKind} />\n {props.children}\n </IconButton>\n )}\n {renderSeparator && <Separator />}\n </>\n );\n }\n);\n\n/** @internal */\nexport function useLabelProps() {\n const { popoverOpen, expandsTo } = useSafeContext(ToolbarContext);\n const [internalVisible, setInternalVisible] = React.useState(false);\n const visible = popoverOpen ? false : internalVisible;\n return {\n placement: expandsTo,\n visible,\n onVisibleChange: setInternalVisible,\n } as const;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/appui-react",
3
- "version": "5.12.0",
3
+ "version": "5.13.0",
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",
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.12.0",
49
- "@itwin/core-react": "5.12.0",
50
- "@itwin/imodel-components-react": "5.12.0"
48
+ "@itwin/components-react": "5.13.0",
49
+ "@itwin/core-react": "5.13.0",
50
+ "@itwin/imodel-components-react": "5.13.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@itwin/appui-abstract": "rc",
@@ -91,9 +91,9 @@
91
91
  "typescript": "~5.6.2",
92
92
  "upath": "^2.0.1",
93
93
  "vitest": "^3.0.6",
94
- "@itwin/core-react": "5.12.0",
95
- "@itwin/components-react": "5.12.0",
96
- "@itwin/imodel-components-react": "5.12.0"
94
+ "@itwin/components-react": "5.13.0",
95
+ "@itwin/core-react": "5.13.0",
96
+ "@itwin/imodel-components-react": "5.13.0"
97
97
  },
98
98
  "dependencies": {
99
99
  "@itwin/itwinui-icons-react": "^2.8.0",