@itwin/appui-react 5.15.0 → 5.15.2
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 +22 -0
- package/lib/appui-react/hooks/useConditionalProp.d.ts.map +1 -1
- package/lib/appui-react/hooks/useConditionalProp.js +8 -2
- package/lib/appui-react/hooks/useConditionalProp.js.map +1 -1
- package/lib/appui-react/toolbar/ToolbarComposer.d.ts.map +1 -1
- package/lib/appui-react/toolbar/ToolbarComposer.js +49 -3
- package/lib/appui-react/toolbar/ToolbarComposer.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/GroupItem.d.ts +5 -0
- package/lib/appui-react/toolbar/new-toolbars/GroupItem.d.ts.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/GroupItem.js +10 -4
- package/lib/appui-react/toolbar/new-toolbars/GroupItem.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/GroupItem.scss +9 -0
- package/lib/appui-react/toolbar/new-toolbars/OverflowButton.js +3 -3
- package/lib/appui-react/toolbar/new-toolbars/OverflowButton.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/useOverflow.js +1 -1
- package/lib/appui-react/toolbar/new-toolbars/useOverflow.js.map +1 -1
- package/lib/cjs/appui-react/toolbar/new-toolbars/GroupItem.scss +9 -0
- package/lib/esm/appui-react/toolbar/new-toolbars/GroupItem.scss +9 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Change Log - @itwin/appui-react
|
|
2
2
|
|
|
3
|
+
## 5.15.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 668df91: Fixed unnecessary overflow in `Toolbar` component.
|
|
8
|
+
- 5ac8e40: Fixed `ToolbarComposer` component to highlight group items that contain toolbar items active via conditional value.
|
|
9
|
+
- 5ac8e40: Fixed `Toolbar` component to correctly refresh conditional values when mounting nested items.
|
|
10
|
+
- @itwin/components-react@5.15.2
|
|
11
|
+
- @itwin/core-react@5.15.2
|
|
12
|
+
- @itwin/imodel-components-react@5.15.2
|
|
13
|
+
|
|
14
|
+
## 5.15.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 655ca63: Removed height limit that caused vertical overflow in menu of `Toolbar` component.
|
|
19
|
+
- Updated dependencies [b930ab8]
|
|
20
|
+
- Updated dependencies [3781110]
|
|
21
|
+
- @itwin/imodel-components-react@5.15.1
|
|
22
|
+
- @itwin/components-react@5.15.1
|
|
23
|
+
- @itwin/core-react@5.15.1
|
|
24
|
+
|
|
3
25
|
## 5.15.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConditionalProp.d.ts","sourceRoot":"","sources":["../../../src/appui-react/hooks/useConditionalProp.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAKH,qJAAqJ;AACrJ,UAAU,sBAAsB,CAAC,CAAC;IAChC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,KAAK,EAAE,CAAC,CAAC;CACV;AAED,uDAAuD;AACvD,KAAK,eAAe,CAAC,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;AAepE,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"useConditionalProp.d.ts","sourceRoot":"","sources":["../../../src/appui-react/hooks/useConditionalProp.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAKH,qJAAqJ;AACrJ,UAAU,sBAAsB,CAAC,CAAC;IAChC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,KAAK,EAAE,CAAC,CAAC;CACV;AAED,uDAAuD;AACvD,KAAK,eAAe,CAAC,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;AAepE,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,iBAoCxE"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Utilities
|
|
7
7
|
*/
|
|
8
|
-
import { useCallback, useSyncExternalStore } from "react";
|
|
8
|
+
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
9
9
|
import { SyncUiEventDispatcher } from "../syncui/SyncUiEventDispatcher.js";
|
|
10
10
|
/** Duck type the conditional. */
|
|
11
11
|
function isConditionalValue(conditionalProp) {
|
|
@@ -17,6 +17,7 @@ function isConditionalValue(conditionalProp) {
|
|
|
17
17
|
}
|
|
18
18
|
/** @internal */
|
|
19
19
|
export function useConditionalProp(conditionalProp) {
|
|
20
|
+
const refreshedRef = useRef(false);
|
|
20
21
|
const subscribe = useCallback((onStoreChange) => {
|
|
21
22
|
if (isConditionalValue(conditionalProp)) {
|
|
22
23
|
return SyncUiEventDispatcher.onSyncUiEvent.addListener(({ eventIds }) => {
|
|
@@ -30,8 +31,13 @@ export function useConditionalProp(conditionalProp) {
|
|
|
30
31
|
return () => { };
|
|
31
32
|
}, [conditionalProp]);
|
|
32
33
|
const getSnapshot = useCallback(() => {
|
|
33
|
-
if (isConditionalValue(conditionalProp))
|
|
34
|
+
if (isConditionalValue(conditionalProp)) {
|
|
35
|
+
if (!refreshedRef.current) {
|
|
36
|
+
conditionalProp.refresh();
|
|
37
|
+
refreshedRef.current = true;
|
|
38
|
+
}
|
|
34
39
|
return conditionalProp.value;
|
|
40
|
+
}
|
|
35
41
|
return conditionalProp;
|
|
36
42
|
}, [conditionalProp]);
|
|
37
43
|
return useSyncExternalStore(subscribe, getSnapshot);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConditionalProp.js","sourceRoot":"","sources":["../../../src/appui-react/hooks/useConditionalProp.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useConditionalProp.js","sourceRoot":"","sources":["../../../src/appui-react/hooks/useConditionalProp.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAY3E,iCAAiC;AACjC,SAAS,kBAAkB,CACzB,eAAmC;IAEnC,OAAO,CACL,OAAO,eAAe,KAAK,QAAQ;QACnC,eAAe;QACf,cAAc,IAAI,eAAe;QACjC,SAAS,IAAI,eAAe;QAC5B,OAAO,IAAI,eAAe,CAC3B,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,kBAAkB,CAAI,eAAmC;IACvE,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,aAAyB,EAAE,EAAE;QAC5B,IAAI,kBAAkB,CAAC,eAAe,CAAC,EAAE,CAAC;YACxC,OAAO,qBAAqB,CAAC,aAAa,CAAC,WAAW,CACpD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACf,IACE,CAAC,qBAAqB,CAAC,kBAAkB,CACvC,QAAQ,EACR,eAAe,CAAC,YAAY,CAC7B;oBAED,OAAO;gBACT,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE;oBAAE,OAAO;gBAEvC,aAAa,EAAE,CAAC;YAClB,CAAC,CACF,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC,EACD,CAAC,eAAe,CAAC,CAClB,CAAC;IACF,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,IAAI,kBAAkB,CAAC,eAAe,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;gBAC1B,eAAe,CAAC,OAAO,EAAE,CAAC;gBAC1B,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;YAC9B,CAAC;YAED,OAAO,eAAe,CAAC,KAAK,CAAC;QAC/B,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IACtB,OAAO,oBAAoB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AACtD,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 Utilities\n */\n\nimport { useCallback, useRef, useSyncExternalStore } from \"react\";\nimport { SyncUiEventDispatcher } from \"../syncui/SyncUiEventDispatcher.js\";\n\n/** Defines a common interface for existing conditional value classes: `ConditionalBooleanValue`, `ConditionalStringValue`, `ConditionalIconItem`. */\ninterface CommonConditionalValue<T> {\n syncEventIds: string[];\n refresh: () => boolean;\n value: T;\n}\n\n/** Type that is usually used in a conditional prop. */\ntype ConditionalProp<T> = CommonConditionalValue<T> | T | undefined;\n\n/** Duck type the conditional. */\nfunction isConditionalValue<T>(\n conditionalProp: ConditionalProp<T>\n): conditionalProp is CommonConditionalValue<T> {\n return (\n typeof conditionalProp === \"object\" &&\n conditionalProp &&\n \"syncEventIds\" in conditionalProp &&\n \"refresh\" in conditionalProp &&\n \"value\" in conditionalProp\n );\n}\n\n/** @internal */\nexport function useConditionalProp<T>(conditionalProp: ConditionalProp<T>) {\n const refreshedRef = useRef(false);\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n if (isConditionalValue(conditionalProp)) {\n return SyncUiEventDispatcher.onSyncUiEvent.addListener(\n ({ eventIds }) => {\n if (\n !SyncUiEventDispatcher.hasEventOfInterest(\n eventIds,\n conditionalProp.syncEventIds\n )\n )\n return;\n if (!conditionalProp.refresh()) return;\n\n onStoreChange();\n }\n );\n }\n return () => {};\n },\n [conditionalProp]\n );\n const getSnapshot = useCallback(() => {\n if (isConditionalValue(conditionalProp)) {\n if (!refreshedRef.current) {\n conditionalProp.refresh();\n refreshedRef.current = true;\n }\n\n return conditionalProp.value;\n }\n return conditionalProp;\n }, [conditionalProp]);\n return useSyncExternalStore(subscribe, getSnapshot);\n}\n"]}
|
|
@@ -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,EAIV,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,kBAAkB,EAClB,YAAY,EACb,MAAM,kBAAkB,CAAC;
|
|
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;AA8J1B;;;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,qBA4C5D;AAqED,gBAAgB;AAChB,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAAE,EACpB,aAAa,EAAE,MAAM,EAAE,iBA4BxB"}
|
|
@@ -15,6 +15,8 @@ import { isToolbarActionItem, isToolbarGroupItem, ToolbarOrientation, ToolbarUsa
|
|
|
15
15
|
import { Toolbar } from "./Toolbar.js";
|
|
16
16
|
import { useActiveStageProvidedToolbarItems } from "./useActiveStageProvidedToolbarItems.js";
|
|
17
17
|
import { useActiveToolId } from "../hooks/useActiveToolId.js";
|
|
18
|
+
import { ConditionalBooleanValue } from "../shared/ConditionalValue.js";
|
|
19
|
+
import { SyncUiEventDispatcher } from "../syncui/SyncUiEventDispatcher.js";
|
|
18
20
|
function addItemToSpecifiedParentGroup(items, groupChildren) {
|
|
19
21
|
const outItems = [];
|
|
20
22
|
for (const toolbarItem of items) {
|
|
@@ -138,9 +140,13 @@ export function ToolbarComposer(props) {
|
|
|
138
140
|
}, [props.items, addonItems]);
|
|
139
141
|
const activeToolId = useActiveToolId();
|
|
140
142
|
const activeItemIds = React.useMemo(() => activeItemIdsProp ?? (activeToolId ? [activeToolId] : []), [activeItemIdsProp, activeToolId]);
|
|
143
|
+
const activeConditionalItemIds = useActiveConditionalItemIds(allItems);
|
|
141
144
|
const items = React.useMemo(() => {
|
|
142
|
-
return updateActiveItems(allItems,
|
|
143
|
-
|
|
145
|
+
return updateActiveItems(allItems, [
|
|
146
|
+
...activeItemIds,
|
|
147
|
+
...activeConditionalItemIds,
|
|
148
|
+
]);
|
|
149
|
+
}, [allItems, activeItemIds, activeConditionalItemIds]);
|
|
144
150
|
const isDragEnabled = React.useContext(ToolbarDragInteractionContext);
|
|
145
151
|
const useProximityOpacity = useProximityOpacitySetting();
|
|
146
152
|
const snapWidgetOpacity = useSnapWidgetOpacitySetting();
|
|
@@ -165,6 +171,46 @@ function toPanelAlignment(orientation, usage) {
|
|
|
165
171
|
return ToolbarPanelAlignment.End;
|
|
166
172
|
return ToolbarPanelAlignment.Start;
|
|
167
173
|
}
|
|
174
|
+
function useActiveConditionalItemIds(items) {
|
|
175
|
+
const [activeItemIds, setActiveItemIds] = React.useState([]);
|
|
176
|
+
const conditionalItems = React.useMemo(() => {
|
|
177
|
+
const conditionals = [];
|
|
178
|
+
const stack = [...items];
|
|
179
|
+
while (stack.length > 0) {
|
|
180
|
+
const current = stack.pop();
|
|
181
|
+
if (current.isActiveCondition)
|
|
182
|
+
conditionals.push(current);
|
|
183
|
+
if (isToolbarGroupItem(current)) {
|
|
184
|
+
for (const child of current.items) {
|
|
185
|
+
stack.push(child);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return conditionals;
|
|
190
|
+
}, [items]);
|
|
191
|
+
React.useEffect(() => {
|
|
192
|
+
return SyncUiEventDispatcher.onSyncUiEvent.addListener((args) => {
|
|
193
|
+
const newActiveIds = [];
|
|
194
|
+
for (const item of conditionalItems) {
|
|
195
|
+
ConditionalBooleanValue.refreshValue(item.isActiveCondition, args.eventIds);
|
|
196
|
+
const isActive = ConditionalBooleanValue.getValue(item.isActiveCondition);
|
|
197
|
+
if (isActive)
|
|
198
|
+
newActiveIds.push(item.id);
|
|
199
|
+
}
|
|
200
|
+
setActiveItemIds(newActiveIds);
|
|
201
|
+
});
|
|
202
|
+
}, [conditionalItems]);
|
|
203
|
+
React.useEffect(() => {
|
|
204
|
+
const newActiveIds = [];
|
|
205
|
+
for (const item of conditionalItems) {
|
|
206
|
+
const isActive = ConditionalBooleanValue.getValue(item.isActiveCondition);
|
|
207
|
+
if (isActive)
|
|
208
|
+
newActiveIds.push(item.id);
|
|
209
|
+
}
|
|
210
|
+
setActiveItemIds(newActiveIds);
|
|
211
|
+
}, [conditionalItems]);
|
|
212
|
+
return activeItemIds;
|
|
213
|
+
}
|
|
168
214
|
/** @internal */
|
|
169
215
|
export function updateActiveItems(items, activeItemIds) {
|
|
170
216
|
return produce(items, (draft) => {
|
|
@@ -175,7 +221,7 @@ export function updateActiveItems(items, activeItemIds) {
|
|
|
175
221
|
const isActive = activeItemIds.includes(current.id);
|
|
176
222
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
177
223
|
current.isActive = isActive;
|
|
178
|
-
if (
|
|
224
|
+
if (isToolbarGroupItem(current)) {
|
|
179
225
|
for (const child of current.items) {
|
|
180
226
|
stack.push([child, [...ancestors, current]]);
|
|
181
227
|
}
|
|
@@ -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,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;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAOrE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,SAAS,6BAA6B,CACpC,KAAmB,EACnB,aAA0D;IAE1D,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,KAAK,MAAM,WAAW,IAAI,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,QA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,CAAC,cAAc;QAErC,OAAO,qBAAqB,CAAC,GAAG,CAAC;IAEnC,OAAO,qBAAqB,CAAC,KAAK,CAAC;AACrC,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,iBAAiB,CAC/B,KAAoB,EACpB,aAAuB;IAEvB,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QAC9B,4CAA4C;QAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAkB,CAAU,CAAC,CAAC;QAEvE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,GAAG,EAAG,CAAC;YAE1C,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpD,4DAA4D;YAC5D,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,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"]}
|
|
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;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAOrE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,SAAS,6BAA6B,CACpC,KAAmB,EACnB,aAA0D;IAE1D,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,KAAK,MAAM,WAAW,IAAI,KAAK,EAAE,CAAC;Q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AG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpD,4DAA4D;YAC5D,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAE5B,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;gBAChC,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,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\";\nimport { ConditionalBooleanValue } from \"../shared/ConditionalValue.js\";\nimport { SyncUiEventDispatcher } from \"../syncui/SyncUiEventDispatcher.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 activeConditionalItemIds = useActiveConditionalItemIds(allItems);\n const items = React.useMemo(() => {\n return updateActiveItems(allItems, [\n ...activeItemIds,\n ...activeConditionalItemIds,\n ]);\n }, [allItems, activeItemIds, activeConditionalItemIds]);\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\nfunction useActiveConditionalItemIds(items: ToolbarItem[]) {\n const [activeItemIds, setActiveItemIds] = React.useState<string[]>([]);\n const conditionalItems = React.useMemo(() => {\n const conditionals: ToolbarItem[] = [];\n const stack = [...items];\n while (stack.length > 0) {\n const current = stack.pop()!;\n if (current.isActiveCondition) conditionals.push(current);\n\n if (isToolbarGroupItem(current)) {\n for (const child of current.items) {\n stack.push(child);\n }\n }\n }\n return conditionals;\n }, [items]);\n React.useEffect(() => {\n return SyncUiEventDispatcher.onSyncUiEvent.addListener((args) => {\n const newActiveIds: string[] = [];\n for (const item of conditionalItems) {\n ConditionalBooleanValue.refreshValue(\n item.isActiveCondition,\n args.eventIds\n );\n\n const isActive = ConditionalBooleanValue.getValue(\n item.isActiveCondition\n );\n if (isActive) newActiveIds.push(item.id);\n }\n setActiveItemIds(newActiveIds);\n });\n }, [conditionalItems]);\n React.useEffect(() => {\n const newActiveIds: string[] = [];\n for (const item of conditionalItems) {\n const isActive = ConditionalBooleanValue.getValue(item.isActiveCondition);\n if (isActive) newActiveIds.push(item.id);\n }\n setActiveItemIds(newActiveIds);\n }, [conditionalItems]);\n return activeItemIds;\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 (isToolbarGroupItem(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"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Toolbar
|
|
3
3
|
*/
|
|
4
|
+
import "./GroupItem.scss";
|
|
4
5
|
import * as React from "react";
|
|
6
|
+
import { DropdownMenu } from "@itwin/itwinui-react";
|
|
5
7
|
import type { ToolbarItem } from "../../toolbar/ToolbarItem.js";
|
|
6
8
|
import { type ToolbarGroupItem } from "../../toolbar/ToolbarItem.js";
|
|
7
9
|
interface GroupItemProps {
|
|
@@ -17,5 +19,8 @@ interface GroupMenuItemProps {
|
|
|
17
19
|
}
|
|
18
20
|
/** @internal */
|
|
19
21
|
export declare function GroupMenuItem({ item, onClose }: GroupMenuItemProps): React.JSX.Element | null;
|
|
22
|
+
type ToolbarMenuProps = React.ComponentProps<typeof DropdownMenu>;
|
|
23
|
+
/** @internal */
|
|
24
|
+
export declare const ToolbarMenu: React.ForwardRefExoticComponent<React.PropsWithoutRef<ToolbarMenuProps> & React.RefAttributes<HTMLDivElement>>;
|
|
20
25
|
export {};
|
|
21
26
|
//# sourceMappingURL=GroupItem.d.ts.map
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"GroupItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/GroupItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAA8B,MAAM,sBAAsB,CAAC;AAChF,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,4BA6ClE;AAkBD,KAAK,gBAAgB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAElE,gBAAgB;AAChB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,yBAAyB,CACvD,KAAK,CAAC,eAAe,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAe7E,CAAC"}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Toolbar
|
|
7
7
|
*/
|
|
8
|
+
import "./GroupItem.scss";
|
|
9
|
+
import classnames from "classnames";
|
|
8
10
|
import * as React from "react";
|
|
9
11
|
import { Icon } from "@itwin/core-react";
|
|
10
12
|
import { DropdownMenu, MenuExtraContent, MenuItem } from "@itwin/itwinui-react";
|
|
@@ -24,7 +26,7 @@ export const GroupItem = React.forwardRef(function GroupItem({ item }, ref) {
|
|
|
24
26
|
if (overflowContext) {
|
|
25
27
|
return React.createElement(GroupMenuItem, { item: item, onClose: overflowContext.onClose });
|
|
26
28
|
}
|
|
27
|
-
return (React.createElement(
|
|
29
|
+
return (React.createElement(ToolbarMenu, { menuItems: (close) => {
|
|
28
30
|
return toMenuItems(item, close);
|
|
29
31
|
}, placement: placement, onVisibleChange: (newVisible) => {
|
|
30
32
|
setPopoverOpen(newVisible);
|
|
@@ -53,13 +55,13 @@ export function GroupMenuItem({ item, onClose }) {
|
|
|
53
55
|
const startIcon = item.iconNode ? (React.createElement(React.Fragment, null, item.iconNode)) : (
|
|
54
56
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
55
57
|
React.createElement(Icon, { iconSpec: iconSpec }));
|
|
56
|
-
return (React.createElement(MenuItem, { startIcon: startIcon, disabled: isDisabled, subMenuItems: subMenuItems, onClick: ()
|
|
57
|
-
|
|
58
|
+
return (React.createElement(MenuItem, { className: "uifw-toolbar-newToolbars-groupItem_menuItem", startIcon: startIcon, disabled: isDisabled, subMenuItems: subMenuItems, onClick: isToolbarActionItem(item)
|
|
59
|
+
? () => {
|
|
58
60
|
item.execute();
|
|
59
61
|
onItemExecuted?.(item);
|
|
60
62
|
onClose?.();
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
: undefined,
|
|
63
65
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
64
66
|
isSelected: isActiveCondition ?? item.isActive, "data-item-id": item.id },
|
|
65
67
|
React.createElement(Badge, { badge: item.badge, badgeKind: item.badgeKind }),
|
|
@@ -78,4 +80,8 @@ function toMenuItems(item, onClose) {
|
|
|
78
80
|
}
|
|
79
81
|
return [];
|
|
80
82
|
}
|
|
83
|
+
/** @internal */
|
|
84
|
+
export const ToolbarMenu = React.forwardRef(function DropdownMenu1(props, ref) {
|
|
85
|
+
return (React.createElement(DropdownMenu, { ...props, className: classnames("uifw-toolbar-newToolbars-groupItem_menu", props.className), ref: ref }));
|
|
86
|
+
});
|
|
81
87
|
//# sourceMappingURL=GroupItem.js.map
|
|
@@ -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,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,IAA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AAoB;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;AAID,gBAAgB;AAChB,MAAM,CAAC,MAAM,WAAW,GAEpB,KAAK,CAAC,UAAU,CAAmC,SAAS,aAAa,CAC3E,KAAK,EACL,GAAG;IAEH,OAAO,CACL,oBAAC,YAAY,OACP,KAAK,EACT,SAAS,EAAE,UAAU,CACnB,yCAAyC,EACzC,KAAK,CAAC,SAAS,CAChB,EACD,GAAG,EAAE,GAAG,GACR,CACH,CAAC;AACJ,CAAC,CAAC,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 \"./GroupItem.scss\";\nimport classnames from \"classnames\";\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 <ToolbarMenu\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 </ToolbarMenu>\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\n return (\n <MenuItem\n className=\"uifw-toolbar-newToolbars-groupItem_menuItem\"\n startIcon={startIcon}\n disabled={isDisabled}\n subMenuItems={subMenuItems}\n onClick={\n isToolbarActionItem(item)\n ? () => {\n item.execute();\n onItemExecuted?.(item);\n onClose?.();\n }\n : undefined\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\ntype ToolbarMenuProps = React.ComponentProps<typeof DropdownMenu>;\n\n/** @internal */\nexport const ToolbarMenu: React.ForwardRefExoticComponent<\n React.PropsWithoutRef<ToolbarMenuProps> & React.RefAttributes<HTMLDivElement>\n> = React.forwardRef<HTMLDivElement, ToolbarMenuProps>(function DropdownMenu1(\n props,\n ref\n) {\n return (\n <DropdownMenu\n {...props}\n className={classnames(\n \"uifw-toolbar-newToolbars-groupItem_menu\",\n props.className\n )}\n ref={ref}\n />\n );\n});\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
.uifw-toolbar-newToolbars-groupItem_menu,
|
|
6
|
+
// Can not customize iTwinUI submenu directly, so we use :has() to workaround it.
|
|
7
|
+
[role="menu"]:has(.uifw-toolbar-newToolbars-groupItem_menuItem) {
|
|
8
|
+
--iui-menu-max-height: 100%;
|
|
9
|
+
}
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* @module Toolbar
|
|
7
7
|
*/
|
|
8
8
|
import * as React from "react";
|
|
9
|
-
import {
|
|
9
|
+
import { IconButton } from "@itwin/itwinui-react";
|
|
10
10
|
import { SvgMore } from "@itwin/itwinui-icons-react";
|
|
11
11
|
import { useLabelProps } from "./Item.js";
|
|
12
|
-
import { usePopoverPlacement } from "./GroupItem.js";
|
|
12
|
+
import { ToolbarMenu, usePopoverPlacement } from "./GroupItem.js";
|
|
13
13
|
import { ToolbarContext } from "./Toolbar.js";
|
|
14
14
|
import { useSafeContext } from "../../hooks/useSafeContext.js";
|
|
15
15
|
/** @internal */
|
|
@@ -19,7 +19,7 @@ export const OverflowButton = React.forwardRef(function OverflowButton(props, re
|
|
|
19
19
|
const placement = usePopoverPlacement();
|
|
20
20
|
const labelProps = useLabelProps();
|
|
21
21
|
const { setPopoverOpen } = useSafeContext(ToolbarContext);
|
|
22
|
-
return (React.createElement(
|
|
22
|
+
return (React.createElement(ToolbarMenu, { menuItems: (close) => {
|
|
23
23
|
return [
|
|
24
24
|
React.createElement(OverflowMenu, { key: 0, onClose: close }, props.children),
|
|
25
25
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverflowButton.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/OverflowButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"OverflowButton.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/OverflowButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,U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CACL,oBAAC,wBAAwB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,OAAO,EAAE,IAClD,QAAQ,CACyB,CACrC,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 { IconButton } from \"@itwin/itwinui-react\";\nimport { SvgMore } from \"@itwin/itwinui-icons-react\";\nimport { useLabelProps } from \"./Item.js\";\nimport { ToolbarMenu, usePopoverPlacement } from \"./GroupItem.js\";\nimport { ToolbarContext } from \"./Toolbar.js\";\nimport { useSafeContext } from \"../../hooks/useSafeContext.js\";\n\ninterface ToolGroupOverflow {\n onClose?: () => void;\n}\n\n/** @internal */\nexport const ToolGroupOverflowContext = React.createContext<\n ToolGroupOverflow | undefined\n>(undefined);\n\ninterface OverflowButtonProps {\n children?: React.ReactNode;\n}\n\n/** @internal */\nexport const OverflowButton = React.forwardRef<\n HTMLButtonElement,\n OverflowButtonProps\n>(function OverflowButton(props, ref) {\n const placement = usePopoverPlacement();\n const labelProps = useLabelProps();\n const { setPopoverOpen } = useSafeContext(ToolbarContext);\n\n return (\n <ToolbarMenu\n menuItems={(close) => {\n return [\n <OverflowMenu key={0} onClose={close}>\n {props.children}\n </OverflowMenu>,\n ];\n }}\n placement={placement}\n onVisibleChange={(newVisible) => {\n setPopoverOpen(newVisible);\n }}\n >\n <IconButton\n ref={ref}\n label=\"More\"\n labelProps={labelProps}\n styleType=\"borderless\"\n >\n <SvgMore />\n </IconButton>\n </ToolbarMenu>\n );\n});\n\ninterface OverflowMenuProps {\n children?: React.ReactNode;\n onClose?: () => void;\n}\n\nfunction OverflowMenu({ children, onClose }: OverflowMenuProps) {\n return (\n <ToolGroupOverflowContext.Provider value={{ onClose }}>\n {children}\n </ToolGroupOverflowContext.Provider>\n );\n}\n"]}
|
|
@@ -19,9 +19,9 @@ export const useOverflow = (allItems, orientation, getItemSize, getOverflowSize)
|
|
|
19
19
|
setCalculate(true);
|
|
20
20
|
}
|
|
21
21
|
React.useLayoutEffect(() => {
|
|
22
|
-
setCalculate(false);
|
|
23
22
|
if (!calculate)
|
|
24
23
|
return;
|
|
24
|
+
setCalculate(false);
|
|
25
25
|
const containerSize = containerSizeRef.current
|
|
26
26
|
? getLength(containerSizeRef.current, orientation)
|
|
27
27
|
: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOverflow.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/useOverflow.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAK/D,gBAAgB;AAChB,MAAM,CAAC,MAAM,WAAW,GAAG,CAIzB,QAA+B,EAC/B,WAAwB,EACxB,WAAwC,EACxC,eAAgC,EAChC,EAAE;IACF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,EAAa,CAAC;IACnD,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,EAAa,CAAC;IAEnD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC1E,IAAI,eAAe,KAAK,WAAW,EAAE,CAAC;QACpC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QAChC,YAAY,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,e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AE,QAAQ,CAAU,CAAC;AAC3E,CAAC,CAAC;AAEF,SAAS,SAAS,CAChB,IAAuC,EACvC,WAAwB;IAExB,OAAO,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,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 * as React from \"react\";\nimport { useResizeObserver } from \"@itwin/core-react/internal\";\nimport type { SizeProps } from \"../../utils/SizeProps.js\";\n\ntype Orientation = \"horizontal\" | \"vertical\";\n\n/** @internal */\nexport const useOverflow = <\n TContainer extends HTMLElement,\n TComponent extends HTMLElement\n>(\n allItems: ReadonlyArray<string>,\n orientation: Orientation,\n getItemSize: (item: string) => SizeProps,\n getOverflowSize: () => SizeProps\n) => {\n const [visible, setVisible] = React.useState(allItems.length);\n const [calculate, setCalculate] = React.useState(false);\n const containerSizeRef = React.useRef<SizeProps>();\n const componentSizeRef = React.useRef<SizeProps>();\n\n const [prevOrientation, setPrevOrientation] = React.useState(orientation);\n if (prevOrientation !== orientation) {\n setPrevOrientation(orientation);\n setCalculate(true);\n }\n\n React.useLayoutEffect(() => {\n if (!calculate) return;\n setCalculate(false);\n\n const containerSize = containerSizeRef.current\n ? getLength(containerSizeRef.current, orientation)\n : undefined;\n if (containerSize === undefined) return;\n\n const componentSize = componentSizeRef.current\n ? getLength(componentSizeRef.current, orientation)\n : undefined;\n if (componentSize === undefined) return;\n\n const itemSizes = allItems.map((item) => {\n const size = getItemSize(item);\n return getLength(size, orientation);\n });\n const overflowSize = getLength(getOverflowSize(), orientation);\n\n const otherSize = itemSizes.reduce((acc, size) => acc + size, 0);\n if (otherSize < containerSize) {\n // No overflow.\n setVisible(itemSizes.length);\n return;\n }\n\n if (overflowSize >= containerSize) {\n // Render only overflow.\n setVisible(0);\n return;\n }\n\n let totalSize = overflowSize;\n let newVisible = 0;\n for (const size of itemSizes) {\n totalSize += size;\n if (totalSize >= containerSize) {\n break;\n }\n newVisible++;\n }\n setVisible(newVisible);\n }, [calculate, allItems, getItemSize, getOverflowSize, orientation]);\n const containerRoRef = useResizeObserver<TContainer>(\n React.useCallback(\n (width: number, height: number) => {\n const length = containerSizeRef.current\n ? getLength(containerSizeRef.current, orientation)\n : undefined;\n containerSizeRef.current = { width, height };\n const newLength = getLength(containerSizeRef.current, orientation);\n\n if (newLength === length) return;\n setCalculate(true);\n },\n [orientation]\n )\n );\n const componentRoRef = useResizeObserver<TComponent>(\n React.useCallback(\n (width: number, height: number) => {\n const length = componentSizeRef.current\n ? getLength(componentSizeRef.current, orientation)\n : undefined;\n componentSizeRef.current = { width, height };\n const newLength = getLength(componentSizeRef.current, orientation);\n\n if (newLength === length) return;\n setCalculate(true);\n },\n [orientation]\n )\n );\n\n const overflow = calculate || visible < allItems.length;\n const visibleItems = calculate ? allItems.length : visible;\n return [containerRoRef, componentRoRef, visibleItems, overflow] as const;\n};\n\nfunction getLength(\n size: { width: number; height: number },\n orientation: Orientation\n) {\n return orientation === \"horizontal\" ? size.width : size.height;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
.uifw-toolbar-newToolbars-groupItem_menu,
|
|
6
|
+
// Can not customize iTwinUI submenu directly, so we use :has() to workaround it.
|
|
7
|
+
[role="menu"]:has(.uifw-toolbar-newToolbars-groupItem_menuItem) {
|
|
8
|
+
--iui-menu-max-height: 100%;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
.uifw-toolbar-newToolbars-groupItem_menu,
|
|
6
|
+
// Can not customize iTwinUI submenu directly, so we use :has() to workaround it.
|
|
7
|
+
[role="menu"]:has(.uifw-toolbar-newToolbars-groupItem_menuItem) {
|
|
8
|
+
--iui-menu-max-height: 100%;
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/appui-react",
|
|
3
|
-
"version": "5.15.
|
|
3
|
+
"version": "5.15.2",
|
|
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.15.
|
|
49
|
-
"@itwin/core-react": "5.15.
|
|
50
|
-
"@itwin/imodel-components-react": "5.15.
|
|
48
|
+
"@itwin/components-react": "5.15.2",
|
|
49
|
+
"@itwin/core-react": "5.15.2",
|
|
50
|
+
"@itwin/imodel-components-react": "5.15.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@itwin/appui-abstract": "^5.1.0",
|
|
@@ -91,9 +91,9 @@
|
|
|
91
91
|
"typescript": "~5.6.2",
|
|
92
92
|
"upath": "^2.0.1",
|
|
93
93
|
"vitest": "^3.0.6",
|
|
94
|
-
"@itwin/components-react": "5.15.
|
|
95
|
-
"@itwin/core-react": "5.15.
|
|
96
|
-
"@itwin/imodel-components-react": "5.15.
|
|
94
|
+
"@itwin/components-react": "5.15.2",
|
|
95
|
+
"@itwin/core-react": "5.15.2",
|
|
96
|
+
"@itwin/imodel-components-react": "5.15.2"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
99
|
"@itwin/itwinui-icons-react": "^2.8.0",
|