@itwin/appui-react 4.3.1 → 4.4.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.
Files changed (108) hide show
  1. package/CHANGELOG.md +12 -4
  2. package/lib/cjs/appui-react/UiFramework.d.ts.map +1 -1
  3. package/lib/cjs/appui-react/UiFramework.js +11 -10
  4. package/lib/cjs/appui-react/UiFramework.js.map +1 -1
  5. package/lib/cjs/appui-react/cursor/cursormenu/CursorMenu.d.ts +1 -1
  6. package/lib/cjs/appui-react/cursor/cursormenu/CursorMenu.d.ts.map +1 -1
  7. package/lib/cjs/appui-react/cursor/cursormenu/CursorMenu.js +4 -3
  8. package/lib/cjs/appui-react/cursor/cursormenu/CursorMenu.js.map +1 -1
  9. package/lib/cjs/appui-react/selection/HideIsolateEmphasizeManager.d.ts.map +1 -1
  10. package/lib/cjs/appui-react/selection/HideIsolateEmphasizeManager.js +3 -0
  11. package/lib/cjs/appui-react/selection/HideIsolateEmphasizeManager.js.map +1 -1
  12. package/lib/cjs/appui-react/selection/SelectionContextItemDef.d.ts.map +1 -1
  13. package/lib/cjs/appui-react/selection/SelectionContextItemDef.js +12 -8
  14. package/lib/cjs/appui-react/selection/SelectionContextItemDef.js.map +1 -1
  15. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.d.ts +6 -4
  16. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.d.ts.map +1 -1
  17. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.js +49 -78
  18. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.js.map +1 -1
  19. package/lib/cjs/appui-react/toolbar/Toolbar.d.ts +10 -0
  20. package/lib/cjs/appui-react/toolbar/Toolbar.d.ts.map +1 -1
  21. package/lib/cjs/appui-react/toolbar/Toolbar.js +3 -2
  22. package/lib/cjs/appui-react/toolbar/Toolbar.js.map +1 -1
  23. package/lib/cjs/appui-react/toolbar/ToolbarComposer.d.ts +2 -1
  24. package/lib/cjs/appui-react/toolbar/ToolbarComposer.d.ts.map +1 -1
  25. package/lib/cjs/appui-react/toolbar/ToolbarComposer.js +45 -129
  26. package/lib/cjs/appui-react/toolbar/ToolbarComposer.js.map +1 -1
  27. package/lib/cjs/appui-react/toolbar/ToolbarItem.d.ts +2 -2
  28. package/lib/cjs/appui-react/toolbar/ToolbarItem.d.ts.map +1 -1
  29. package/lib/cjs/appui-react/toolbar/ToolbarItem.js +2 -2
  30. package/lib/cjs/appui-react/toolbar/ToolbarItem.js.map +1 -1
  31. package/lib/cjs/appui-react/toolbar/ToolbarItemsManager.d.ts +1 -0
  32. package/lib/cjs/appui-react/toolbar/ToolbarItemsManager.d.ts.map +1 -1
  33. package/lib/cjs/appui-react/toolbar/ToolbarItemsManager.js +12 -2
  34. package/lib/cjs/appui-react/toolbar/ToolbarItemsManager.js.map +1 -1
  35. package/lib/cjs/appui-react/toolbar/ToolbarWithOverflow.d.ts +2 -1
  36. package/lib/cjs/appui-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
  37. package/lib/cjs/appui-react/toolbar/ToolbarWithOverflow.js +5 -9
  38. package/lib/cjs/appui-react/toolbar/ToolbarWithOverflow.js.map +1 -1
  39. package/lib/cjs/appui-react/toolbar/useActiveStageProvidedToolbarItems.d.ts +11 -0
  40. package/lib/cjs/appui-react/toolbar/useActiveStageProvidedToolbarItems.d.ts.map +1 -0
  41. package/lib/cjs/appui-react/toolbar/useActiveStageProvidedToolbarItems.js +46 -0
  42. package/lib/cjs/appui-react/toolbar/useActiveStageProvidedToolbarItems.js.map +1 -0
  43. package/lib/cjs/appui-react/toolbar/useActiveToolIdSynchedItems.d.ts +25 -0
  44. package/lib/cjs/appui-react/toolbar/useActiveToolIdSynchedItems.d.ts.map +1 -0
  45. package/lib/cjs/appui-react/toolbar/useActiveToolIdSynchedItems.js +63 -0
  46. package/lib/cjs/appui-react/toolbar/useActiveToolIdSynchedItems.js.map +1 -0
  47. package/lib/cjs/appui-react/toolbar/useDefaultToolbarItems.d.ts +1 -0
  48. package/lib/cjs/appui-react/toolbar/useDefaultToolbarItems.d.ts.map +1 -1
  49. package/lib/cjs/appui-react/toolbar/useDefaultToolbarItems.js +4 -1
  50. package/lib/cjs/appui-react/toolbar/useDefaultToolbarItems.js.map +1 -1
  51. package/lib/cjs/appui-react/toolbar/useUiItemsProviderToolbarItems.d.ts +2 -1
  52. package/lib/cjs/appui-react/toolbar/useUiItemsProviderToolbarItems.d.ts.map +1 -1
  53. package/lib/cjs/appui-react/toolbar/useUiItemsProviderToolbarItems.js +13 -30
  54. package/lib/cjs/appui-react/toolbar/useUiItemsProviderToolbarItems.js.map +1 -1
  55. package/lib/esm/appui-react/UiFramework.d.ts.map +1 -1
  56. package/lib/esm/appui-react/UiFramework.js +11 -10
  57. package/lib/esm/appui-react/UiFramework.js.map +1 -1
  58. package/lib/esm/appui-react/cursor/cursormenu/CursorMenu.d.ts +1 -1
  59. package/lib/esm/appui-react/cursor/cursormenu/CursorMenu.d.ts.map +1 -1
  60. package/lib/esm/appui-react/cursor/cursormenu/CursorMenu.js +4 -3
  61. package/lib/esm/appui-react/cursor/cursormenu/CursorMenu.js.map +1 -1
  62. package/lib/esm/appui-react/selection/HideIsolateEmphasizeManager.d.ts.map +1 -1
  63. package/lib/esm/appui-react/selection/HideIsolateEmphasizeManager.js +3 -0
  64. package/lib/esm/appui-react/selection/HideIsolateEmphasizeManager.js.map +1 -1
  65. package/lib/esm/appui-react/selection/SelectionContextItemDef.d.ts.map +1 -1
  66. package/lib/esm/appui-react/selection/SelectionContextItemDef.js +12 -8
  67. package/lib/esm/appui-react/selection/SelectionContextItemDef.js.map +1 -1
  68. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.d.ts +6 -4
  69. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.d.ts.map +1 -1
  70. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.js +49 -78
  71. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.js.map +1 -1
  72. package/lib/esm/appui-react/toolbar/Toolbar.d.ts +10 -0
  73. package/lib/esm/appui-react/toolbar/Toolbar.d.ts.map +1 -1
  74. package/lib/esm/appui-react/toolbar/Toolbar.js +3 -2
  75. package/lib/esm/appui-react/toolbar/Toolbar.js.map +1 -1
  76. package/lib/esm/appui-react/toolbar/ToolbarComposer.d.ts +2 -1
  77. package/lib/esm/appui-react/toolbar/ToolbarComposer.d.ts.map +1 -1
  78. package/lib/esm/appui-react/toolbar/ToolbarComposer.js +45 -129
  79. package/lib/esm/appui-react/toolbar/ToolbarComposer.js.map +1 -1
  80. package/lib/esm/appui-react/toolbar/ToolbarItem.d.ts +2 -2
  81. package/lib/esm/appui-react/toolbar/ToolbarItem.d.ts.map +1 -1
  82. package/lib/esm/appui-react/toolbar/ToolbarItem.js +2 -2
  83. package/lib/esm/appui-react/toolbar/ToolbarItem.js.map +1 -1
  84. package/lib/esm/appui-react/toolbar/ToolbarItemsManager.d.ts +1 -0
  85. package/lib/esm/appui-react/toolbar/ToolbarItemsManager.d.ts.map +1 -1
  86. package/lib/esm/appui-react/toolbar/ToolbarItemsManager.js +12 -2
  87. package/lib/esm/appui-react/toolbar/ToolbarItemsManager.js.map +1 -1
  88. package/lib/esm/appui-react/toolbar/ToolbarWithOverflow.d.ts +2 -1
  89. package/lib/esm/appui-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
  90. package/lib/esm/appui-react/toolbar/ToolbarWithOverflow.js +5 -9
  91. package/lib/esm/appui-react/toolbar/ToolbarWithOverflow.js.map +1 -1
  92. package/lib/esm/appui-react/toolbar/useActiveStageProvidedToolbarItems.d.ts +11 -0
  93. package/lib/esm/appui-react/toolbar/useActiveStageProvidedToolbarItems.d.ts.map +1 -0
  94. package/lib/esm/appui-react/toolbar/useActiveStageProvidedToolbarItems.js +42 -0
  95. package/lib/esm/appui-react/toolbar/useActiveStageProvidedToolbarItems.js.map +1 -0
  96. package/lib/esm/appui-react/toolbar/useActiveToolIdSynchedItems.d.ts +25 -0
  97. package/lib/esm/appui-react/toolbar/useActiveToolIdSynchedItems.d.ts.map +1 -0
  98. package/lib/esm/appui-react/toolbar/useActiveToolIdSynchedItems.js +59 -0
  99. package/lib/esm/appui-react/toolbar/useActiveToolIdSynchedItems.js.map +1 -0
  100. package/lib/esm/appui-react/toolbar/useDefaultToolbarItems.d.ts +1 -0
  101. package/lib/esm/appui-react/toolbar/useDefaultToolbarItems.d.ts.map +1 -1
  102. package/lib/esm/appui-react/toolbar/useDefaultToolbarItems.js +4 -1
  103. package/lib/esm/appui-react/toolbar/useDefaultToolbarItems.js.map +1 -1
  104. package/lib/esm/appui-react/toolbar/useUiItemsProviderToolbarItems.d.ts +2 -1
  105. package/lib/esm/appui-react/toolbar/useUiItemsProviderToolbarItems.d.ts.map +1 -1
  106. package/lib/esm/appui-react/toolbar/useUiItemsProviderToolbarItems.js +13 -30
  107. package/lib/esm/appui-react/toolbar/useUiItemsProviderToolbarItems.js.map +1 -1
  108. package/package.json +13 -14
@@ -6,68 +6,15 @@
6
6
  * @module Toolbar
7
7
  */
8
8
  import * as React from "react";
9
- import { ConditionalBooleanValue } from "@itwin/appui-abstract";
10
9
  import { Direction, ToolbarOpacitySetting, ToolbarPanelAlignment, } from "@itwin/components-react";
11
10
  import { Logger } from "@itwin/core-bentley";
12
11
  import { Orientation } from "@itwin/core-react";
13
- import { SyncUiEventDispatcher } from "../syncui/SyncUiEventDispatcher";
14
12
  import { UiFramework } from "../UiFramework";
15
13
  import { ToolbarDragInteractionContext } from "./DragInteraction";
16
- import { useDefaultToolbarItems } from "./useDefaultToolbarItems";
17
- import { useUiItemsProviderToolbarItems } from "./useUiItemsProviderToolbarItems";
18
14
  import { isToolbarActionItem, isToolbarGroupItem, ToolbarOrientation, ToolbarUsage, } from "./ToolbarItem";
19
- import { ToolbarItemsManager } from "./ToolbarItemsManager";
20
- import { ToolbarWithOverflow } from "./ToolbarWithOverflow";
21
- /** Private function to set up sync event monitoring of toolbar items */
22
- function useToolbarItemSyncEffect(uiDataProvider, syncIdsOfInterest) {
23
- React.useEffect(() => {
24
- return SyncUiEventDispatcher.onSyncUiEvent.addListener((args) => {
25
- if (0 === syncIdsOfInterest.length)
26
- return;
27
- // istanbul ignore else
28
- if (syncIdsOfInterest.some((value) => args.eventIds.has(value.toLowerCase()))) {
29
- // process each item that has interest
30
- uiDataProvider.refreshAffectedItems(args.eventIds);
31
- }
32
- });
33
- }, [uiDataProvider, syncIdsOfInterest, uiDataProvider.items]);
34
- React.useEffect(() => {
35
- return UiFramework.frontstages.onToolActivatedEvent.addListener(({ toolId }) => {
36
- uiDataProvider.setActiveToolId(toolId);
37
- });
38
- }, [uiDataProvider, uiDataProvider.items]);
39
- }
40
- function nestedAddItemToSpecifiedParentGroup(items, groupChildren) {
41
- const outItems = [];
42
- for (const toolbarItem of items) {
43
- if (!isToolbarGroupItem(toolbarItem)) {
44
- outItems.push(toolbarItem);
45
- continue;
46
- }
47
- const newChildren = nestedAddItemToSpecifiedParentGroup(toolbarItem.items, groupChildren);
48
- const foundIndices = [];
49
- groupChildren.forEach((entry, index) => {
50
- if (entry.parentGroupItemId === toolbarItem.id) {
51
- foundIndices.push(index);
52
- }
53
- });
54
- // istanbul ignore else
55
- if (foundIndices.length) {
56
- // process in reverse order so groupChildren can be reduced as we find matches
57
- foundIndices
58
- .sort(
59
- // istanbul ignore next
60
- (a, b) => a - b)
61
- .reverse()
62
- .forEach((foundIndex) => {
63
- newChildren.push(groupChildren[foundIndex]);
64
- groupChildren.splice(foundIndex);
65
- });
66
- }
67
- outItems.push({ ...toolbarItem, items: newChildren });
68
- }
69
- return outItems;
70
- }
15
+ import { Toolbar } from "./Toolbar";
16
+ import { useActiveToolIdSynchedItems } from "./useActiveToolIdSynchedItems";
17
+ import { useActiveStageProvidedToolbarItems } from "./useActiveStageProvidedToolbarItems";
71
18
  function addItemToSpecifiedParentGroup(items, groupChildren) {
72
19
  const outItems = [];
73
20
  for (const toolbarItem of items) {
@@ -75,7 +22,7 @@ function addItemToSpecifiedParentGroup(items, groupChildren) {
75
22
  outItems.push(toolbarItem);
76
23
  continue;
77
24
  }
78
- const newChildren = nestedAddItemToSpecifiedParentGroup(toolbarItem.items, groupChildren);
25
+ const newChildren = addItemToSpecifiedParentGroup(toolbarItem.items, groupChildren);
79
26
  const foundIndices = [];
80
27
  groupChildren.forEach((entry, index) => {
81
28
  if (entry.parentGroupItemId === toolbarItem.id) {
@@ -116,76 +63,54 @@ function getItemSortValue(item) {
116
63
  : /* istanbul ignore next */ item.groupPriority;
117
64
  return groupValue * 10000 + item.itemPriority;
118
65
  }
119
- function getSortedChildren(group) {
120
- const sortedChildren = group.items
121
- .filter((item) => !ConditionalBooleanValue.getValue(item.isHidden))
66
+ function sortItems(items) {
67
+ return [...items]
122
68
  .sort((a, b) => getItemSortValue(a) - getItemSortValue(b))
123
69
  .map((i) => {
124
70
  if (isToolbarGroupItem(i)) {
125
- return { ...i, items: getSortedChildren(i) };
71
+ return { ...i, items: sortItems(i.items) };
126
72
  }
127
73
  return i;
128
74
  });
129
- return sortedChildren;
75
+ }
76
+ /**
77
+ * Create a forEach handler that will add every element of an array of ToolbarItems
78
+ * to a list of items that can then be replaced in its proper place, ensuring that
79
+ * the same item, from different list, is not added multiple times.
80
+ * @param items Output list of items
81
+ * @param groupChildren Output list of group children to redistribute.
82
+ * @returns Array<ToolbarItem>.forEach handler.
83
+ */
84
+ function addIfNotDuplicate(items, groupChildren) {
85
+ return (srcItem) => {
86
+ if (-1 === items.findIndex((item) => item.id === srcItem.id)) {
87
+ // if the default item is a group that an addon may insert into copy it so we don't mess with original
88
+ const toolbarItem = isToolbarGroupItem(srcItem)
89
+ ? cloneGroup(srcItem)
90
+ : srcItem;
91
+ if ((isToolbarGroupItem(toolbarItem) || isToolbarActionItem(toolbarItem)) &&
92
+ toolbarItem.parentGroupItemId)
93
+ groupChildren.push(toolbarItem);
94
+ else
95
+ items.push(toolbarItem);
96
+ }
97
+ };
130
98
  }
131
99
  /** local function to combine items from Stage and from Extensions */
132
100
  function combineItems(defaultItems, addonItems) {
133
101
  let items = [];
134
102
  const groupChildren = [];
135
- // istanbul ignore else
136
- if (defaultItems.length) {
137
- defaultItems.forEach((srcItem) => {
138
- if (-1 === items.findIndex((item) => item.id === srcItem.id)) {
139
- // if the default item is a group that an addon may insert into copy it so we don't mess with original
140
- const toolbarItem = isToolbarGroupItem(srcItem)
141
- ? cloneGroup(srcItem)
142
- : srcItem;
143
- if ((isToolbarGroupItem(toolbarItem) ||
144
- isToolbarActionItem(toolbarItem)) &&
145
- toolbarItem.parentGroupItemId)
146
- groupChildren.push(toolbarItem);
147
- else
148
- items.push(toolbarItem);
149
- }
150
- });
151
- }
152
- // istanbul ignore else
153
- if (addonItems.length) {
154
- addonItems.forEach((srcItem) => {
155
- if (-1 === items.findIndex((item) => item.id === srcItem.id)) {
156
- // if the default item is a group that an addon may insert into copy it so we don't mess with original
157
- const toolbarItem = isToolbarGroupItem(srcItem)
158
- ? cloneGroup(srcItem)
159
- : srcItem;
160
- if ((isToolbarGroupItem(toolbarItem) ||
161
- isToolbarActionItem(toolbarItem)) &&
162
- toolbarItem.parentGroupItemId)
163
- groupChildren.push(toolbarItem);
164
- else
165
- items.push(toolbarItem);
166
- }
167
- });
168
- }
103
+ defaultItems.forEach(addIfNotDuplicate(items, groupChildren));
104
+ addonItems.forEach(addIfNotDuplicate(items, groupChildren));
169
105
  // 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.
170
106
  if (groupChildren.length) {
171
107
  items = addItemToSpecifiedParentGroup(items, groupChildren);
172
- if (groupChildren.length) {
173
- groupChildren.forEach((toolbarItem) => {
174
- Logger.logWarning("ToolbarComposer", `Requested Parent Group [${toolbarItem.parentGroupItemId}] not found, so item [${toolbarItem.id}] is added directly to toolbar.`);
175
- items.push(toolbarItem);
176
- });
177
- }
108
+ groupChildren.forEach((toolbarItem) => {
109
+ Logger.logWarning("ToolbarComposer", `Requested Parent Group [${toolbarItem.parentGroupItemId}] not found, so item [${toolbarItem.id}] is added directly to toolbar.`);
110
+ items.push(toolbarItem);
111
+ });
178
112
  }
179
- const availableItems = items
180
- .filter((item) => !ConditionalBooleanValue.getValue(item.isHidden))
181
- .sort((a, b) => getItemSortValue(a) - getItemSortValue(b))
182
- .map((i) => {
183
- if (isToolbarGroupItem(i)) {
184
- return { ...i, items: getSortedChildren(i) };
185
- }
186
- return i;
187
- });
188
- return availableItems;
113
+ return sortItems(items);
189
114
  }
190
115
  const useProximityOpacitySetting = () => {
191
116
  const [proximityOpacity, setProximityOpacity] = React.useState(UiFramework.visibility.useProximityOpacity);
@@ -202,27 +127,18 @@ const useProximityOpacitySetting = () => {
202
127
  return proximityOpacity;
203
128
  };
204
129
  /**
205
- * Toolbar that is populated and maintained by item managers.
130
+ * Toolbar that is populated and maintained by item managers, will override
131
+ * isActive property based on the active tool id.
206
132
  * @public
207
133
  */
208
134
  export function ToolbarComposer(props) {
209
135
  const { usage, orientation } = props;
210
- const [defaultItemsManager, setDefaultItemsManager] = React.useState(() => new ToolbarItemsManager(props.items));
211
- React.useEffect(() => {
212
- setDefaultItemsManager(new ToolbarItemsManager(props.items));
213
- }, [props.items]);
214
- // process default items
215
- const defaultItems = useDefaultToolbarItems(defaultItemsManager);
216
- const syncIdsOfInterest = React.useMemo(() => ToolbarItemsManager.getSyncIdsOfInterest(defaultItems), [defaultItems]);
217
- useToolbarItemSyncEffect(defaultItemsManager, syncIdsOfInterest);
218
136
  // process items from addon UI providers
219
- const [addonItemsManager] = React.useState(() => new ToolbarItemsManager());
220
- const addonItems = useUiItemsProviderToolbarItems(addonItemsManager, usage, orientation);
221
- const addonSyncIdsOfInterest = React.useMemo(() => ToolbarItemsManager.getSyncIdsOfInterest(addonItems), [addonItems]);
222
- useToolbarItemSyncEffect(addonItemsManager, addonSyncIdsOfInterest);
223
- const items = React.useMemo(() => {
224
- return combineItems(defaultItems, addonItems);
225
- }, [defaultItems, addonItems]);
137
+ const addonItems = useActiveStageProvidedToolbarItems(usage, orientation);
138
+ const allItems = React.useMemo(() => {
139
+ return combineItems(props.items, addonItems);
140
+ }, [props.items, addonItems]);
141
+ const items = useActiveToolIdSynchedItems(allItems, UiFramework.frontstages);
226
142
  const toolbarOrientation = orientation === ToolbarOrientation.Horizontal
227
143
  ? Orientation.Horizontal
228
144
  : Orientation.Vertical;
@@ -237,7 +153,7 @@ export function ToolbarComposer(props) {
237
153
  : ToolbarPanelAlignment.Start;
238
154
  const isDragEnabled = React.useContext(ToolbarDragInteractionContext);
239
155
  const useProximityOpacity = useProximityOpacitySetting();
240
- return (React.createElement(ToolbarWithOverflow, { expandsTo: expandsTo, panelAlignment: panelAlignment, items: items, useDragInteraction: isDragEnabled, toolbarOpacitySetting: useProximityOpacity && !UiFramework.isMobile()
156
+ return (React.createElement(Toolbar, { enableOverflow: true, expandsTo: expandsTo, panelAlignment: panelAlignment, items: items, useDragInteraction: isDragEnabled, toolbarOpacitySetting: useProximityOpacity && !UiFramework.isMobile()
241
157
  ? ToolbarOpacitySetting.Proximity
242
158
  : /* istanbul ignore next */ ToolbarOpacitySetting.Defaults }));
243
159
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarComposer.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/ToolbarComposer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,mB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AC","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 { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport {\n Direction,\n ToolbarOpacitySetting,\n ToolbarPanelAlignment,\n} from \"@itwin/components-react\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { Orientation } from \"@itwin/core-react\";\nimport { SyncUiEventDispatcher } from \"../syncui/SyncUiEventDispatcher\";\nimport { UiFramework } from \"../UiFramework\";\nimport { ToolbarDragInteractionContext } from \"./DragInteraction\";\nimport { useDefaultToolbarItems } from \"./useDefaultToolbarItems\";\nimport { useUiItemsProviderToolbarItems } from \"./useUiItemsProviderToolbarItems\";\nimport type {\n ToolbarActionItem,\n ToolbarGroupItem,\n ToolbarItem,\n} from \"./ToolbarItem\";\nimport {\n isToolbarActionItem,\n isToolbarGroupItem,\n ToolbarOrientation,\n ToolbarUsage,\n} from \"./ToolbarItem\";\nimport { ToolbarItemsManager } from \"./ToolbarItemsManager\";\nimport { ToolbarWithOverflow } from \"./ToolbarWithOverflow\";\n\n/** Private function to set up sync event monitoring of toolbar items */\nfunction useToolbarItemSyncEffect(\n uiDataProvider: ToolbarItemsManager,\n syncIdsOfInterest: string[]\n) {\n React.useEffect(() => {\n return SyncUiEventDispatcher.onSyncUiEvent.addListener((args) => {\n if (0 === syncIdsOfInterest.length) return;\n\n // istanbul ignore else\n if (\n syncIdsOfInterest.some((value: string): boolean =>\n args.eventIds.has(value.toLowerCase())\n )\n ) {\n // process each item that has interest\n uiDataProvider.refreshAffectedItems(args.eventIds);\n }\n });\n }, [uiDataProvider, syncIdsOfInterest, uiDataProvider.items]);\n\n React.useEffect(() => {\n return UiFramework.frontstages.onToolActivatedEvent.addListener(\n ({ toolId }) => {\n uiDataProvider.setActiveToolId(toolId);\n }\n );\n }, [uiDataProvider, uiDataProvider.items]);\n}\n\nfunction nestedAddItemToSpecifiedParentGroup(\n items: ReadonlyArray<ToolbarActionItem | ToolbarGroupItem>,\n groupChildren: Array<ToolbarActionItem | ToolbarGroupItem>\n): Array<ToolbarActionItem | ToolbarGroupItem> {\n const outItems: Array<ToolbarActionItem | ToolbarGroupItem> = [];\n for (const toolbarItem of items) {\n if (!isToolbarGroupItem(toolbarItem)) {\n outItems.push(toolbarItem);\n continue;\n }\n\n const newChildren: Array<ToolbarActionItem | ToolbarGroupItem> =\n nestedAddItemToSpecifiedParentGroup(toolbarItem.items, groupChildren);\n const foundIndices: number[] = [];\n\n groupChildren.forEach((entry, index) => {\n if (entry.parentGroupItemId === toolbarItem.id) {\n foundIndices.push(index);\n }\n });\n\n // istanbul ignore else\n if (foundIndices.length) {\n // process in reverse order so groupChildren can be reduced as we find matches\n foundIndices\n .sort(\n // istanbul ignore next\n (a, b) => a - b\n )\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 addItemToSpecifiedParentGroup(\n items: readonly ToolbarItem[],\n groupChildren: Array<ToolbarActionItem | ToolbarGroupItem>\n): ToolbarItem[] {\n const outItems: ToolbarItem[] = [];\n for (const toolbarItem of items) {\n if (!isToolbarGroupItem(toolbarItem)) {\n outItems.push(toolbarItem);\n continue;\n }\n\n const newChildren: Array<ToolbarActionItem | ToolbarGroupItem> =\n nestedAddItemToSpecifiedParentGroup(toolbarItem.items, groupChildren);\n const foundIndices: number[] = [];\n\n groupChildren.forEach((entry, index) => {\n if (entry.parentGroupItemId === toolbarItem.id) {\n foundIndices.push(index);\n }\n });\n\n // istanbul ignore else\n if (foundIndices.length) {\n // process in reverse order so groupChildren can be reduced as we find matches\n foundIndices\n .sort(\n // istanbul ignore next\n (a, b) => a - b\n )\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 =\n undefined === item.groupPriority\n ? 0\n : /* istanbul ignore next */ item.groupPriority;\n return groupValue * 10000 + item.itemPriority;\n}\n\nfunction getSortedChildren(\n group: ToolbarGroupItem\n): ReadonlyArray<ToolbarActionItem | ToolbarGroupItem> {\n const sortedChildren = group.items\n .filter((item) => !ConditionalBooleanValue.getValue(item.isHidden))\n .sort((a, b) => getItemSortValue(a) - getItemSortValue(b))\n .map((i) => {\n if (isToolbarGroupItem(i)) {\n return { ...i, items: getSortedChildren(i) };\n }\n return i;\n });\n return sortedChildren;\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 // istanbul ignore else\n if (defaultItems.length) {\n defaultItems.forEach((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) ||\n isToolbarActionItem(toolbarItem)) &&\n toolbarItem.parentGroupItemId\n )\n groupChildren.push(toolbarItem);\n else items.push(toolbarItem);\n }\n });\n }\n // istanbul ignore else\n if (addonItems.length) {\n addonItems.forEach((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) ||\n isToolbarActionItem(toolbarItem)) &&\n toolbarItem.parentGroupItemId\n )\n groupChildren.push(toolbarItem);\n else items.push(toolbarItem);\n }\n });\n }\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 if (groupChildren.length) {\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\n const availableItems = items\n .filter((item) => !ConditionalBooleanValue.getValue(item.isHidden))\n .sort((a, b) => getItemSortValue(a) - getItemSortValue(b))\n .map((i) => {\n if (isToolbarGroupItem(i)) {\n return { ...i, items: getSortedChildren(i) };\n }\n return i;\n });\n\n return availableItems;\n}\n\nconst useProximityOpacitySetting = () => {\n const [proximityOpacity, setProximityOpacity] = React.useState(\n UiFramework.visibility.useProximityOpacity\n );\n React.useEffect(() => {\n // istanbul ignore next\n const handleUiVisibilityChanged = () => {\n setProximityOpacity(UiFramework.visibility.useProximityOpacity);\n };\n UiFramework.onUiVisibilityChanged.addListener(handleUiVisibilityChanged);\n return () => {\n UiFramework.onUiVisibilityChanged.removeListener(\n handleUiVisibilityChanged\n );\n };\n }, []);\n return proximityOpacity;\n};\n\n/** Properties for the [[ToolbarComposer]] React components\n * @public\n */\nexport interface ExtensibleToolbarProps {\n items: ToolbarItem[];\n usage: ToolbarUsage;\n /** Toolbar orientation. */\n orientation: ToolbarOrientation;\n}\n\n/**\n * Toolbar that is populated and maintained by item managers.\n * @public\n */\nexport function ToolbarComposer(props: ExtensibleToolbarProps) {\n const { usage, orientation } = props;\n\n const [defaultItemsManager, setDefaultItemsManager] = React.useState(\n () => new ToolbarItemsManager(props.items)\n );\n React.useEffect(() => {\n setDefaultItemsManager(new ToolbarItemsManager(props.items));\n }, [props.items]);\n\n // process default items\n const defaultItems = useDefaultToolbarItems(defaultItemsManager);\n const syncIdsOfInterest = React.useMemo(\n () => ToolbarItemsManager.getSyncIdsOfInterest(defaultItems),\n [defaultItems]\n );\n useToolbarItemSyncEffect(defaultItemsManager, syncIdsOfInterest);\n\n // process items from addon UI providers\n const [addonItemsManager] = React.useState(() => new ToolbarItemsManager());\n const addonItems = useUiItemsProviderToolbarItems(\n addonItemsManager,\n usage,\n orientation\n );\n const addonSyncIdsOfInterest = React.useMemo(\n () => ToolbarItemsManager.getSyncIdsOfInterest(addonItems),\n [addonItems]\n );\n useToolbarItemSyncEffect(addonItemsManager, addonSyncIdsOfInterest);\n\n const items = React.useMemo(() => {\n return combineItems(defaultItems, addonItems);\n }, [defaultItems, addonItems]);\n\n const toolbarOrientation =\n orientation === ToolbarOrientation.Horizontal\n ? Orientation.Horizontal\n : Orientation.Vertical;\n const expandsTo =\n toolbarOrientation === Orientation.Horizontal\n ? Direction.Bottom\n : usage === ToolbarUsage.ViewNavigation\n ? Direction.Left\n : Direction.Right;\n const panelAlignment =\n toolbarOrientation === Orientation.Horizontal &&\n usage === ToolbarUsage.ViewNavigation\n ? ToolbarPanelAlignment.End\n : ToolbarPanelAlignment.Start;\n const isDragEnabled = React.useContext(ToolbarDragInteractionContext);\n const useProximityOpacity = useProximityOpacitySetting();\n\n return (\n <ToolbarWithOverflow\n expandsTo={expandsTo}\n panelAlignment={panelAlignment}\n items={items}\n useDragInteraction={isDragEnabled}\n toolbarOpacitySetting={\n useProximityOpacity && !UiFramework.isMobile()\n ? ToolbarOpacitySetting.Proximity\n : /* istanbul ignore next */ ToolbarOpacitySetting.Defaults\n }\n />\n );\n}\n"]}
1
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WAAW,CAAC,QAAQ,EAAE;YAC5C,CAAC,CAAC,qBAAqB,CAAC,SAAS;YACjC,CAAC,CAAC,0BAA0B,CAAC,qBAAqB,CAAC,QAAQ,GAE/D,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport {\n Direction,\n ToolbarOpacitySetting,\n ToolbarPanelAlignment,\n} from \"@itwin/components-react\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { Orientation } from \"@itwin/core-react\";\nimport { UiFramework } from \"../UiFramework\";\nimport { ToolbarDragInteractionContext } from \"./DragInteraction\";\nimport type {\n ToolbarActionItem,\n ToolbarGroupItem,\n ToolbarItem,\n} from \"./ToolbarItem\";\nimport {\n isToolbarActionItem,\n isToolbarGroupItem,\n ToolbarOrientation,\n ToolbarUsage,\n} from \"./ToolbarItem\";\nimport { Toolbar } from \"./Toolbar\";\nimport { useActiveToolIdSynchedItems } from \"./useActiveToolIdSynchedItems\";\nimport { useActiveStageProvidedToolbarItems } from \"./useActiveStageProvidedToolbarItems\";\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 // istanbul ignore else\n if (foundIndices.length) {\n // process in reverse order so groupChildren can be reduced as we find matches\n foundIndices\n .sort(\n // istanbul ignore next\n (a, b) => a - b\n )\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 =\n undefined === item.groupPriority\n ? 0\n : /* istanbul ignore next */ 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\n );\n React.useEffect(() => {\n // istanbul ignore next\n const handleUiVisibilityChanged = () => {\n setProximityOpacity(UiFramework.visibility.useProximityOpacity);\n };\n UiFramework.onUiVisibilityChanged.addListener(handleUiVisibilityChanged);\n return () => {\n UiFramework.onUiVisibilityChanged.removeListener(\n handleUiVisibilityChanged\n );\n };\n }, []);\n return proximityOpacity;\n};\n\n/** Properties for the [[ToolbarComposer]] React components\n * @public\n */\nexport interface ExtensibleToolbarProps {\n items: ToolbarItem[];\n usage: ToolbarUsage;\n /** Toolbar orientation. */\n orientation: ToolbarOrientation;\n}\n\n/**\n * Toolbar that is populated and maintained by item managers, will override\n * isActive property based on the active tool id.\n * @public\n */\nexport function ToolbarComposer(props: ExtensibleToolbarProps) {\n const { usage, orientation } = props;\n\n // process items from addon UI providers\n const addonItems = useActiveStageProvidedToolbarItems(usage, orientation);\n\n const allItems = React.useMemo(() => {\n return combineItems(props.items, addonItems);\n }, [props.items, addonItems]);\n\n const items = useActiveToolIdSynchedItems(allItems, UiFramework.frontstages);\n\n const toolbarOrientation =\n orientation === ToolbarOrientation.Horizontal\n ? Orientation.Horizontal\n : Orientation.Vertical;\n const expandsTo =\n toolbarOrientation === Orientation.Horizontal\n ? Direction.Bottom\n : usage === ToolbarUsage.ViewNavigation\n ? Direction.Left\n : Direction.Right;\n const panelAlignment =\n toolbarOrientation === Orientation.Horizontal &&\n usage === ToolbarUsage.ViewNavigation\n ? ToolbarPanelAlignment.End\n : ToolbarPanelAlignment.Start;\n const isDragEnabled = React.useContext(ToolbarDragInteractionContext);\n const useProximityOpacity = useProximityOpacitySetting();\n\n return (\n <Toolbar\n enableOverflow={true}\n expandsTo={expandsTo}\n panelAlignment={panelAlignment}\n items={items}\n useDragInteraction={isDragEnabled}\n toolbarOpacitySetting={\n useProximityOpacity && !UiFramework.isMobile()\n ? ToolbarOpacitySetting.Proximity\n : /* istanbul ignore next */ ToolbarOpacitySetting.Defaults\n }\n />\n );\n}\n"]}
@@ -8,9 +8,9 @@ import type { IconSpec } from "@itwin/core-react";
8
8
  * @public
9
9
  */
10
10
  export declare enum ToolbarUsage {
11
- /** Contains tools to Create Update and Delete content - in ninezone this is in top left of content area. */
11
+ /** Contains tools to Create Update and Delete content - in AppUI this is in top left of content area. */
12
12
  ContentManipulation = 0,
13
- /** Manipulate view/camera - in ninezone this is in top right of content area. */
13
+ /** Manipulate view/camera - in AppUI this is in top right of content area. */
14
14
  ViewNavigation = 1
15
15
  }
16
16
  /** Used to specify the orientation of the toolbar.
@@ -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,SAAS,EACT,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;GAEG;AACH,oBAAY,YAAY;IACtB,4GAA4G;IAC5G,mBAAmB,IAAI;IACvB,iFAAiF;IAC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zD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAAC;IACtD,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,CAAC;IACpE,qDAAqD;IACrD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,qHAAqH;IACrH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,yFAAyF;IACzF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAAC;IACjD,oDAAoD;IACpD,QAAQ,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,GAChB,IAAI,IAAI,iBAAiB,CAE3B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,WAAW,GAChB,IAAI,IAAI,gBAAgB,CAE1B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,GAChB,IAAI,IAAI,iBAAiB,CAE3B"}
@@ -10,9 +10,9 @@
10
10
  */
11
11
  export var ToolbarUsage;
12
12
  (function (ToolbarUsage) {
13
- /** Contains tools to Create Update and Delete content - in ninezone this is in top left of content area. */
13
+ /** Contains tools to Create Update and Delete content - in AppUI this is in top left of content area. */
14
14
  ToolbarUsage[ToolbarUsage["ContentManipulation"] = 0] = "ContentManipulation";
15
- /** Manipulate view/camera - in ninezone this is in top right of content area. */
15
+ /** Manipulate view/camera - in AppUI this is in top right of content area. */
16
16
  ToolbarUsage[ToolbarUsage["ViewNavigation"] = 1] = "ViewNavigation";
17
17
  })(ToolbarUsage || (ToolbarUsage = {}));
18
18
  /** Used to specify the orientation of the toolbar.
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarItem.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/ToolbarItem.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AASH;;GAEG;AACH,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,4GAA4G;IAC5G,6EAAuB,CAAA;IACvB,iFAAiF;IACjF,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;AA6ED;;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 BadgeType,\n ConditionalBooleanValue,\n ConditionalStringValue,\n} from \"@itwin/appui-abstract\";\nimport type { IconSpec } from \"@itwin/core-react\";\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 ninezone this is in top left of content area. */\n ContentManipulation = 0,\n /** Manipulate view/camera - in ninezone 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 /** Describes badge. Renders no badge if not specified. */\n readonly badge?: BadgeType;\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}\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 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 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 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"]}
1
+ {"version":3,"file":"ToolbarItem.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/ToolbarItem.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AASH;;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;AA6ED;;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 BadgeType,\n ConditionalBooleanValue,\n ConditionalStringValue,\n} from \"@itwin/appui-abstract\";\nimport type { IconSpec } from \"@itwin/core-react\";\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 /** Describes badge. Renders no badge if not specified. */\n readonly badge?: BadgeType;\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}\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 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 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 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"]}
@@ -12,6 +12,7 @@ export interface ToolbarItemsChangedArgs {
12
12
  /**
13
13
  * Controls status bar items.
14
14
  * @internal
15
+ * @deprecated in 4.4.0. This is no longer used internally, left because of an erroneous public dependency that is also deprecated.
15
16
  */
16
17
  export declare class ToolbarItemsManager {
17
18
  protected _items: ReadonlyArray<ToolbarItem>;
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarItemsManager.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/ToolbarItemsManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAOH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAGV,WAAW,EACZ,MAAM,eAAe,CAAC;AAOvB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CAC5C;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAM;gBAEtC,KAAK,CAAC,EAAE,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,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;IAqBzB;;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,EAGjD;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;WA6Bd,oBAAoB,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,EAAE;IAM3E,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAoDhC,OAAO,CAAC,4BAA4B;IAkD7B,oBAAoB,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC;IAajD,OAAO,CAAC,MAAM,CAAC,wCAAwC;IAoBvD,OAAO,CAAC,6BAA6B;IAwBrC,OAAO,CAAC,MAAM,CAAC,+BAA+B;IAyBvC,eAAe,CAAC,MAAM,EAAE,MAAM;CAyBtC"}
@@ -15,9 +15,12 @@ function isInstance(args) {
15
15
  /**
16
16
  * Controls status bar items.
17
17
  * @internal
18
+ * @deprecated in 4.4.0. This is no longer used internally, left because of an erroneous public dependency that is also deprecated.
18
19
  */
19
20
  export class ToolbarItemsManager {
20
21
  constructor(items) {
22
+ // This class should be removed once `useDefaultToolbarItems` and `useUiItemsProviderToolbarItems` (public version) get removed.
23
+ // 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.
21
24
  this._items = [];
22
25
  /** Event raised when Toolbar items are changed.
23
26
  * @internal
@@ -28,6 +31,7 @@ export class ToolbarItemsManager {
28
31
  }
29
32
  loadItemsInternal(items, processConditions, sendItemChanged) {
30
33
  if (processConditions && items) {
34
+ // eslint-disable-next-line deprecation/deprecation
31
35
  const eventIds = ToolbarItemsManager.getSyncIdsOfInterest(items);
32
36
  if (0 !== eventIds.length) {
33
37
  const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(items, new Set(eventIds));
@@ -152,7 +156,9 @@ export class ToolbarItemsManager {
152
156
  for (const item of items) {
153
157
  let updatedItem = { ...item };
154
158
  if (isToolbarGroupItem(updatedItem)) {
155
- const { childrenUpdated, childItems } = ToolbarItemsManager.refreshChildItems(updatedItem, eventIds);
159
+ const { childrenUpdated, childItems } =
160
+ // eslint-disable-next-line deprecation/deprecation
161
+ ToolbarItemsManager.refreshChildItems(updatedItem, eventIds);
156
162
  // istanbul ignore else
157
163
  if (childrenUpdated) {
158
164
  updatedItem = {
@@ -210,7 +216,9 @@ export class ToolbarItemsManager {
210
216
  isActiveToolIdRefreshRequired(toolId) {
211
217
  for (const item of this.items) {
212
218
  if (isToolbarGroupItem(item)) {
213
- if (ToolbarItemsManager.isActiveToolIdRefreshRequiredForChildren(item.items, toolId))
219
+ if (
220
+ // eslint-disable-next-line deprecation/deprecation
221
+ ToolbarItemsManager.isActiveToolIdRefreshRequiredForChildren(item.items, toolId))
214
222
  return true;
215
223
  }
216
224
  else {
@@ -229,6 +237,7 @@ export class ToolbarItemsManager {
229
237
  if (isToolbarGroupItem(updatedItem)) {
230
238
  updatedItem = {
231
239
  ...updatedItem,
240
+ // eslint-disable-next-line deprecation/deprecation
232
241
  items: ToolbarItemsManager.refreshActiveToolIdInChildItems(updatedItem, toolId),
233
242
  };
234
243
  }
@@ -247,6 +256,7 @@ export class ToolbarItemsManager {
247
256
  if (isToolbarGroupItem(updatedItem)) {
248
257
  updatedItem = {
249
258
  ...updatedItem,
259
+ // eslint-disable-next-line deprecation/deprecation
250
260
  items: ToolbarItemsManager.refreshActiveToolIdInChildItems(updatedItem, toolId),
251
261
  };
252
262
  }
@@ -1 +1 @@
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,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAM9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,SAAS,UAAU,CAAI,IAA0B;IAC/C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AASD;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAG9B,YAAY,KAAkC;QAFpC,WAAM,GAA+B,EAAE,CAAC;QAMlD;;WAEG;QACa,mBAAc,GAAG,IAAI,OAAO,EAEzC,CAAC;QARF,IAAI,KAAK;YAAE,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IASO,iBAAiB,CACvB,KAAiC,EACjC,iBAA0B,EAC1B,eAAwB;QAExB,IAAI,iBAAiB,IAAI,KAAK,EAAE;YAC9B,MAAM,QAAQ,GAAG,mBAAmB,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACjE,IAAI,CAAC,KAAK,QAAQ,CAAC,MAAM,EAAE;gBACzB,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,GAClC,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AG,IAAI,EAAE,CAAC;YAE9B,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE;gBACnC,WAAW,GAAG;oBACZ,GAAG,WAAW;oBACd,KAAK,EAAE,mBAAmB,CAAC,+BAA+B,CACxD,WAAW,EACX,MAAM,CACP;iBACF,CAAC;aACH;YAED,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC;YACjD,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC/B;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;YAC7B,IAAI,WAAW,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;YAE9B,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE;gBACnC,WAAW,GAAG;oBACZ,GAAG,WAAW;oBACd,KAAK,EAAE,mBAAmB,CAAC,+BAA+B,CACxD,WAAW,EACX,MAAM,CACP;iBACF,CAAC;aACH;YAED,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC;YACjD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC5B;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 { ConditionalIconItem } from \"@itwin/core-react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport type {\n ToolbarActionItem,\n ToolbarGroupItem,\n ToolbarItem,\n} from \"./ToolbarItem\";\nimport { isToolbarGroupItem } from \"./ToolbarItem\";\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 */\nexport class ToolbarItemsManager {\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 const eventIds = ToolbarItemsManager.getSyncIdsOfInterest(items);\n if (0 !== eventIds.length) {\n const { itemsUpdated, updatedItems } =\n this.internalRefreshAffectedItems(items, new Set(eventIds));\n\n // istanbul ignore else\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 // istanbul ignore else\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 } /* istanbul ignore else */ else if (\n ConditionalIconItem.isConditionalIconItem(entry)\n ) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n }\n }\n // istanbul ignore else\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 // istanbul ignore else\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 // istanbul ignore else\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\n itemsUpdated = true;\n } /* istanbul ignore else */ else if (\n entry instanceof ConditionalStringValue\n ) {\n // istanbul ignore else\n if (ConditionalStringValue.refreshValue(entry, eventIds))\n itemsUpdated = true;\n } /* istanbul ignore else */ else if (\n ConditionalIconItem.isConditionalIconItem(entry)\n ) {\n // istanbul ignore else\n if (\n ConditionalIconItem.refreshValue(\n entry as ConditionalIconItem,\n eventIds\n )\n )\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 // istanbul ignore next\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 ToolbarItemsManager.refreshChildItems(updatedItem, eventIds);\n // istanbul ignore else\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 // istanbul ignore else\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\n updateRequired = true;\n } else if (entry instanceof ConditionalStringValue) {\n // istanbul ignore else\n if (ConditionalStringValue.refreshValue(entry, eventIds))\n updateRequired = true;\n } /* istanbul ignore else */ else if (\n ConditionalIconItem.isConditionalIconItem(entry)\n ) {\n // istanbul ignore else\n if (\n ConditionalIconItem.refreshValue(\n entry as ConditionalIconItem,\n eventIds\n )\n )\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 // istanbul ignore next\n if (0 === eventIds.size) return;\n\n const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(\n this.items,\n eventIds\n );\n\n // istanbul ignore else\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 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 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 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,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAM9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,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,IAAI,KAAK;YAAE,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IASO,iBAAiB,CACvB,KAAiC,EACjC,iBAA0B,EAC1B,eAAwB;QAExB,IAAI,iBAAiB,IAAI,KAAK,EAAE;YAC9B,mDAAmD;YACnD,MAAM,QAAQ,GAAG,mBAA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O,MAAM,CAAC,+BAA+B,CAC5C,UAA4B,EAC5B,MAAc;QAEd,MAAM,WAAW,GAAgD,EAAE,CAAC;QACpE,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,EAAE;YACnC,IAAI,WAAW,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;YAE9B,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE;gBACnC,WAAW,GAAG;oBACZ,GAAG,WAAW;oBACd,mDAAmD;oBACnD,KAAK,EAAE,mBAAmB,CAAC,+BAA+B,CACxD,WAAW,EACX,MAAM,CACP;iBACF,CAAC;aACH;YAED,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC;YACjD,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC/B;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;YAC7B,IAAI,WAAW,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;YAE9B,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE;gBACnC,WAAW,GAAG;oBACZ,GAAG,WAAW;oBACd,mDAAmD;oBACnD,KAAK,EAAE,mBAAmB,CAAC,+BAA+B,CACxD,WAAW,EACX,MAAM,CACP;iBACF,CAAC;aACH;YAED,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC;YACjD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC5B;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 { ConditionalIconItem } from \"@itwin/core-react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport type {\n ToolbarActionItem,\n ToolbarGroupItem,\n ToolbarItem,\n} from \"./ToolbarItem\";\nimport { isToolbarGroupItem } from \"./ToolbarItem\";\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 deprecation/deprecation\n const eventIds = ToolbarItemsManager.getSyncIdsOfInterest(items);\n if (0 !== eventIds.length) {\n const { itemsUpdated, updatedItems } =\n this.internalRefreshAffectedItems(items, new Set(eventIds));\n\n // istanbul ignore else\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 // istanbul ignore else\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 } /* istanbul ignore else */ else if (\n ConditionalIconItem.isConditionalIconItem(entry)\n ) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n }\n }\n // istanbul ignore else\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 // istanbul ignore else\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 // istanbul ignore else\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\n itemsUpdated = true;\n } /* istanbul ignore else */ else if (\n entry instanceof ConditionalStringValue\n ) {\n // istanbul ignore else\n if (ConditionalStringValue.refreshValue(entry, eventIds))\n itemsUpdated = true;\n } /* istanbul ignore else */ else if (\n ConditionalIconItem.isConditionalIconItem(entry)\n ) {\n // istanbul ignore else\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 // istanbul ignore next\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 deprecation/deprecation\n ToolbarItemsManager.refreshChildItems(updatedItem, eventIds);\n // istanbul ignore else\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 // istanbul ignore else\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\n updateRequired = true;\n } else if (entry instanceof ConditionalStringValue) {\n // istanbul ignore else\n if (ConditionalStringValue.refreshValue(entry, eventIds))\n updateRequired = true;\n } /* istanbul ignore else */ else if (\n ConditionalIconItem.isConditionalIconItem(entry)\n ) {\n // istanbul ignore else\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 // istanbul ignore next\n if (0 === eventIds.size) return;\n\n const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(\n this.items,\n eventIds\n );\n\n // istanbul ignore else\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 deprecation/deprecation\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 deprecation/deprecation\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 deprecation/deprecation\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"]}
@@ -27,7 +27,8 @@ export interface ToolbarWithOverflowProps extends CommonProps, NoChildrenProps {
27
27
  /** Optional function to call on any KeyDown events processed by toolbar */
28
28
  onKeyDown?: (e: React.KeyboardEvent) => void;
29
29
  }
30
- /** Component that displays toolbar items.
30
+ /** Component that displays toolbar items, displaying only the elements that can fit in the available space,
31
+ * and put the other items into a single panel.
31
32
  * @beta
32
33
  */
33
34
  export declare function ToolbarWithOverflow(props: ToolbarWithOverflowProps): JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarWithOverflow.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/ToolbarWithOverflow.tsx"],"names":[],"mappings":"AAIA;;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K,EACV,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,WAAW,EAAE,eAAe;IAC5E,oGAAoG;IACpG,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,4GAA4G;IAC5G,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,uGAAuG;IACvG,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,8FAA8F;IAC9F,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oFAAoF;IACpF,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,sDAAsD;IACtD,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,2EAA2E;IAC3E,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eAGlE"}
@@ -6,17 +6,13 @@
6
6
  * @module Toolbar
7
7
  */
8
8
  import * as React from "react";
9
- import { ToolbarWithOverflow as CR_ToolbarWithOverflow } from "@itwin/components-react";
10
- import { toUIAToolbarItem } from "./toUIAToolbarItem";
11
- /** Component that displays toolbar items.
9
+ import { Toolbar } from "./Toolbar";
10
+ /** Component that displays toolbar items, displaying only the elements that can fit in the available space,
11
+ * and put the other items into a single panel.
12
12
  * @beta
13
13
  */
14
14
  export function ToolbarWithOverflow(props) {
15
- const { items, ...other } = props;
16
- const uiaItems = React.useMemo(() => {
17
- return items.map((item) => toUIAToolbarItem(item));
18
- }, [items]);
19
- return (React.createElement(CR_ToolbarWithOverflow // eslint-disable-line deprecation/deprecation
20
- , { items: uiaItems, ...other }));
15
+ const { overflowExpandsTo, ...toolbarProps } = props;
16
+ return React.createElement(Toolbar, { enableOverflow: { overflowExpandsTo }, ...toolbarProps });
21
17
  }
22
18
  //# sourceMappingURL=ToolbarWithOverflow.js.map