@itwin/appui-abstract 4.1.0-dev.6 → 4.1.0-dev.7
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/lib/cjs/appui-abstract/BaseUiItemsProvider.d.ts +31 -0
- package/lib/cjs/appui-abstract/BaseUiItemsProvider.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/BaseUiItemsProvider.js +80 -0
- package/lib/cjs/appui-abstract/BaseUiItemsProvider.js.map +1 -0
- package/lib/cjs/appui-abstract/UiItemsManager.d.ts +114 -0
- package/lib/cjs/appui-abstract/UiItemsManager.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/UiItemsManager.js +194 -0
- package/lib/cjs/appui-abstract/UiItemsManager.js.map +1 -0
- package/lib/cjs/appui-abstract/UiItemsProvider.d.ts +30 -0
- package/lib/cjs/appui-abstract/UiItemsProvider.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/UiItemsProvider.js +10 -0
- package/lib/cjs/appui-abstract/UiItemsProvider.js.map +1 -0
- package/lib/cjs/appui-abstract/backstage/BackstageItem.d.ts +92 -0
- package/lib/cjs/appui-abstract/backstage/BackstageItem.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/backstage/BackstageItem.js +71 -0
- package/lib/cjs/appui-abstract/backstage/BackstageItem.js.map +1 -0
- package/lib/cjs/appui-abstract/backstage/BackstageItemsManager.d.ts +39 -0
- package/lib/cjs/appui-abstract/backstage/BackstageItemsManager.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/backstage/BackstageItemsManager.js +134 -0
- package/lib/cjs/appui-abstract/backstage/BackstageItemsManager.js.map +1 -0
- package/lib/cjs/appui-abstract/items/ProvidedItem.d.ts +12 -0
- package/lib/cjs/appui-abstract/items/ProvidedItem.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/items/ProvidedItem.js +10 -0
- package/lib/cjs/appui-abstract/items/ProvidedItem.js.map +1 -0
- package/lib/cjs/appui-abstract/items/StageUsage.d.ts +17 -0
- package/lib/cjs/appui-abstract/items/StageUsage.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/items/StageUsage.js +25 -0
- package/lib/cjs/appui-abstract/items/StageUsage.js.map +1 -0
- package/lib/cjs/appui-abstract/statusbar/StatusBarItem.d.ts +129 -0
- package/lib/cjs/appui-abstract/statusbar/StatusBarItem.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/statusbar/StatusBarItem.js +88 -0
- package/lib/cjs/appui-abstract/statusbar/StatusBarItem.js.map +1 -0
- package/lib/cjs/appui-abstract/statusbar/StatusBarItemsManager.d.ts +40 -0
- package/lib/cjs/appui-abstract/statusbar/StatusBarItemsManager.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/statusbar/StatusBarItemsManager.js +136 -0
- package/lib/cjs/appui-abstract/statusbar/StatusBarItemsManager.js.map +1 -0
- package/lib/cjs/appui-abstract/toolbars/ToolbarItem.d.ts +27 -1
- package/lib/cjs/appui-abstract/toolbars/ToolbarItem.d.ts.map +1 -1
- package/lib/cjs/appui-abstract/toolbars/ToolbarItem.js +23 -1
- package/lib/cjs/appui-abstract/toolbars/ToolbarItem.js.map +1 -1
- package/lib/cjs/appui-abstract/toolbars/ToolbarItemsManager.d.ts +46 -0
- package/lib/cjs/appui-abstract/toolbars/ToolbarItemsManager.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/toolbars/ToolbarItemsManager.js +236 -0
- package/lib/cjs/appui-abstract/toolbars/ToolbarItemsManager.js.map +1 -0
- package/lib/cjs/appui-abstract/utils/isLetter.d.ts +10 -0
- package/lib/cjs/appui-abstract/utils/isLetter.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/utils/isLetter.js +20 -0
- package/lib/cjs/appui-abstract/utils/isLetter.js.map +1 -0
- package/lib/cjs/appui-abstract/widget/AbstractWidgetProps.d.ts +87 -0
- package/lib/cjs/appui-abstract/widget/AbstractWidgetProps.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/widget/AbstractWidgetProps.js +10 -0
- package/lib/cjs/appui-abstract/widget/AbstractWidgetProps.js.map +1 -0
- package/lib/cjs/appui-abstract/widget/StagePanel.d.ts +37 -0
- package/lib/cjs/appui-abstract/widget/StagePanel.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/widget/StagePanel.js +47 -0
- package/lib/cjs/appui-abstract/widget/StagePanel.js.map +1 -0
- package/lib/cjs/appui-abstract/widget/WidgetState.d.ts +20 -0
- package/lib/cjs/appui-abstract/widget/WidgetState.d.ts.map +1 -0
- package/lib/cjs/appui-abstract/widget/WidgetState.js +28 -0
- package/lib/cjs/appui-abstract/widget/WidgetState.js.map +1 -0
- package/lib/cjs/appui-abstract.d.ts +32 -0
- package/lib/cjs/appui-abstract.d.ts.map +1 -1
- package/lib/cjs/appui-abstract.js +32 -0
- package/lib/cjs/appui-abstract.js.map +1 -1
- package/lib/esm/appui-abstract/BaseUiItemsProvider.d.ts +31 -0
- package/lib/esm/appui-abstract/BaseUiItemsProvider.d.ts.map +1 -0
- package/lib/esm/appui-abstract/BaseUiItemsProvider.js +76 -0
- package/lib/esm/appui-abstract/BaseUiItemsProvider.js.map +1 -0
- package/lib/esm/appui-abstract/UiItemsManager.d.ts +114 -0
- package/lib/esm/appui-abstract/UiItemsManager.d.ts.map +1 -0
- package/lib/esm/appui-abstract/UiItemsManager.js +191 -0
- package/lib/esm/appui-abstract/UiItemsManager.js.map +1 -0
- package/lib/esm/appui-abstract/UiItemsProvider.d.ts +30 -0
- package/lib/esm/appui-abstract/UiItemsProvider.d.ts.map +1 -0
- package/lib/esm/appui-abstract/UiItemsProvider.js +9 -0
- package/lib/esm/appui-abstract/UiItemsProvider.js.map +1 -0
- package/lib/esm/appui-abstract/backstage/BackstageItem.d.ts +92 -0
- package/lib/esm/appui-abstract/backstage/BackstageItem.d.ts.map +1 -0
- package/lib/esm/appui-abstract/backstage/BackstageItem.js +66 -0
- package/lib/esm/appui-abstract/backstage/BackstageItem.js.map +1 -0
- package/lib/esm/appui-abstract/backstage/BackstageItemsManager.d.ts +39 -0
- package/lib/esm/appui-abstract/backstage/BackstageItemsManager.d.ts.map +1 -0
- package/lib/esm/appui-abstract/backstage/BackstageItemsManager.js +130 -0
- package/lib/esm/appui-abstract/backstage/BackstageItemsManager.js.map +1 -0
- package/lib/esm/appui-abstract/items/ProvidedItem.d.ts +12 -0
- package/lib/esm/appui-abstract/items/ProvidedItem.d.ts.map +1 -0
- package/lib/esm/appui-abstract/items/ProvidedItem.js +9 -0
- package/lib/esm/appui-abstract/items/ProvidedItem.js.map +1 -0
- package/lib/esm/appui-abstract/items/StageUsage.d.ts +17 -0
- package/lib/esm/appui-abstract/items/StageUsage.d.ts.map +1 -0
- package/lib/esm/appui-abstract/items/StageUsage.js +22 -0
- package/lib/esm/appui-abstract/items/StageUsage.js.map +1 -0
- package/lib/esm/appui-abstract/statusbar/StatusBarItem.d.ts +129 -0
- package/lib/esm/appui-abstract/statusbar/StatusBarItem.d.ts.map +1 -0
- package/lib/esm/appui-abstract/statusbar/StatusBarItem.js +82 -0
- package/lib/esm/appui-abstract/statusbar/StatusBarItem.js.map +1 -0
- package/lib/esm/appui-abstract/statusbar/StatusBarItemsManager.d.ts +40 -0
- package/lib/esm/appui-abstract/statusbar/StatusBarItemsManager.d.ts.map +1 -0
- package/lib/esm/appui-abstract/statusbar/StatusBarItemsManager.js +132 -0
- package/lib/esm/appui-abstract/statusbar/StatusBarItemsManager.js.map +1 -0
- package/lib/esm/appui-abstract/toolbars/ToolbarItem.d.ts +27 -1
- package/lib/esm/appui-abstract/toolbars/ToolbarItem.d.ts.map +1 -1
- package/lib/esm/appui-abstract/toolbars/ToolbarItem.js +22 -0
- package/lib/esm/appui-abstract/toolbars/ToolbarItem.js.map +1 -1
- package/lib/esm/appui-abstract/toolbars/ToolbarItemsManager.d.ts +46 -0
- package/lib/esm/appui-abstract/toolbars/ToolbarItemsManager.d.ts.map +1 -0
- package/lib/esm/appui-abstract/toolbars/ToolbarItemsManager.js +232 -0
- package/lib/esm/appui-abstract/toolbars/ToolbarItemsManager.js.map +1 -0
- package/lib/esm/appui-abstract/utils/isLetter.d.ts +10 -0
- package/lib/esm/appui-abstract/utils/isLetter.d.ts.map +1 -0
- package/lib/esm/appui-abstract/utils/isLetter.js +16 -0
- package/lib/esm/appui-abstract/utils/isLetter.js.map +1 -0
- package/lib/esm/appui-abstract/widget/AbstractWidgetProps.d.ts +87 -0
- package/lib/esm/appui-abstract/widget/AbstractWidgetProps.d.ts.map +1 -0
- package/lib/esm/appui-abstract/widget/AbstractWidgetProps.js +9 -0
- package/lib/esm/appui-abstract/widget/AbstractWidgetProps.js.map +1 -0
- package/lib/esm/appui-abstract/widget/StagePanel.d.ts +37 -0
- package/lib/esm/appui-abstract/widget/StagePanel.d.ts.map +1 -0
- package/lib/esm/appui-abstract/widget/StagePanel.js +44 -0
- package/lib/esm/appui-abstract/widget/StagePanel.js.map +1 -0
- package/lib/esm/appui-abstract/widget/WidgetState.d.ts +20 -0
- package/lib/esm/appui-abstract/widget/WidgetState.d.ts.map +1 -0
- package/lib/esm/appui-abstract/widget/WidgetState.js +25 -0
- package/lib/esm/appui-abstract/widget/WidgetState.js.map +1 -0
- package/lib/esm/appui-abstract.d.ts +32 -0
- package/lib/esm/appui-abstract.d.ts.map +1 -1
- package/lib/esm/appui-abstract.js +32 -0
- package/lib/esm/appui-abstract.js.map +1 -1
- package/package.json +5 -5
@@ -0,0 +1,132 @@
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
5
|
+
/** @packageDocumentation
|
6
|
+
* @module StatusBar
|
7
|
+
*/
|
8
|
+
import { BeEvent } from "@itwin/core-bentley";
|
9
|
+
import { ConditionalBooleanValue } from "../items/ConditionalBooleanValue";
|
10
|
+
import { ConditionalStringValue } from "../items/ConditionalStringValue";
|
11
|
+
const isInstance = (args) => {
|
12
|
+
return !Array.isArray(args);
|
13
|
+
};
|
14
|
+
/**
|
15
|
+
* Controls status bar items.
|
16
|
+
* @internal
|
17
|
+
*/
|
18
|
+
export class StatusBarItemsManager {
|
19
|
+
constructor(items) {
|
20
|
+
this._items = [];
|
21
|
+
/** Event raised when StatusBar items are changed.
|
22
|
+
* @internal
|
23
|
+
*/
|
24
|
+
this.onItemsChanged = new BeEvent();
|
25
|
+
if (items)
|
26
|
+
this.loadItemsInternal(items, true, false);
|
27
|
+
}
|
28
|
+
loadItemsInternal(items, processConditions, sendItemChanged) {
|
29
|
+
if (processConditions && items) {
|
30
|
+
const eventIds = StatusBarItemsManager.getSyncIdsOfInterest(items);
|
31
|
+
if (0 !== eventIds.length) {
|
32
|
+
const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(items, new Set(eventIds));
|
33
|
+
// istanbul ignore else
|
34
|
+
if (itemsUpdated)
|
35
|
+
items = updatedItems;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
this._items = items;
|
39
|
+
if (sendItemChanged)
|
40
|
+
this.onItemsChanged.raiseEvent({ items });
|
41
|
+
}
|
42
|
+
/** load items but do not fire onItemsChanged
|
43
|
+
* @internal
|
44
|
+
*/
|
45
|
+
loadItems(items) {
|
46
|
+
this.loadItemsInternal(items, true, false);
|
47
|
+
}
|
48
|
+
/** Get an array of the StatusBar items */
|
49
|
+
get items() {
|
50
|
+
return this._items;
|
51
|
+
}
|
52
|
+
set items(items) {
|
53
|
+
// istanbul ignore else
|
54
|
+
if (items !== this._items)
|
55
|
+
this.loadItemsInternal(items, true, true);
|
56
|
+
}
|
57
|
+
add(itemOrItems) {
|
58
|
+
let itemsToAdd;
|
59
|
+
if (isInstance(itemOrItems))
|
60
|
+
itemsToAdd = [itemOrItems];
|
61
|
+
else {
|
62
|
+
itemsToAdd = itemOrItems.filter((itemToAdd, index) => itemOrItems.findIndex((item) => item.id === itemToAdd.id) === index);
|
63
|
+
}
|
64
|
+
itemsToAdd = itemsToAdd.filter((itemToAdd) => this._items.find((item) => item.id === itemToAdd.id) === undefined);
|
65
|
+
if (itemsToAdd.length === 0)
|
66
|
+
return;
|
67
|
+
const items = [
|
68
|
+
...this._items,
|
69
|
+
...itemsToAdd,
|
70
|
+
];
|
71
|
+
this.items = items;
|
72
|
+
}
|
73
|
+
/** Remove StatusBar items based on id */
|
74
|
+
remove(itemIdOrItemIds) {
|
75
|
+
const items = this._items.filter((item) => {
|
76
|
+
return isInstance(itemIdOrItemIds) ? item.id !== itemIdOrItemIds : !itemIdOrItemIds.find((itemId) => itemId === item.id);
|
77
|
+
});
|
78
|
+
this.items = items;
|
79
|
+
}
|
80
|
+
/** @internal */
|
81
|
+
removeAll() {
|
82
|
+
this._items = [];
|
83
|
+
}
|
84
|
+
static getSyncIdsOfInterest(items) {
|
85
|
+
const eventIds = new Set();
|
86
|
+
items.forEach((item) => {
|
87
|
+
for (const [, entry] of Object.entries(item)) {
|
88
|
+
if (entry instanceof ConditionalBooleanValue) {
|
89
|
+
entry.syncEventIds.forEach((eventId) => eventIds.add(eventId.toLowerCase()));
|
90
|
+
}
|
91
|
+
else /* istanbul ignore else */ if (entry instanceof ConditionalStringValue) {
|
92
|
+
entry.syncEventIds.forEach((eventId) => eventIds.add(eventId.toLowerCase()));
|
93
|
+
}
|
94
|
+
}
|
95
|
+
});
|
96
|
+
return [...eventIds.values()];
|
97
|
+
}
|
98
|
+
internalRefreshAffectedItems(items, eventIds) {
|
99
|
+
// istanbul ignore next
|
100
|
+
if (0 === eventIds.size)
|
101
|
+
return { itemsUpdated: false, updatedItems: [] };
|
102
|
+
let updateRequired = false;
|
103
|
+
const newItems = [];
|
104
|
+
for (const item of items) {
|
105
|
+
const updatedItem = { ...item };
|
106
|
+
for (const [, entry] of Object.entries(updatedItem)) {
|
107
|
+
if (entry instanceof ConditionalBooleanValue) {
|
108
|
+
// istanbul ignore else
|
109
|
+
if (ConditionalBooleanValue.refreshValue(entry, eventIds))
|
110
|
+
updateRequired = true;
|
111
|
+
}
|
112
|
+
else /* istanbul ignore else */ if (entry instanceof ConditionalStringValue) {
|
113
|
+
// istanbul ignore else
|
114
|
+
if (ConditionalStringValue.refreshValue(entry, eventIds))
|
115
|
+
updateRequired = true;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
newItems.push(updatedItem);
|
119
|
+
}
|
120
|
+
return { itemsUpdated: updateRequired, updatedItems: newItems };
|
121
|
+
}
|
122
|
+
refreshAffectedItems(eventIds) {
|
123
|
+
// istanbul ignore next
|
124
|
+
if (0 === eventIds.size)
|
125
|
+
return;
|
126
|
+
const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(this.items, eventIds);
|
127
|
+
// istanbul ignore else
|
128
|
+
if (itemsUpdated)
|
129
|
+
this.loadItemsInternal(updatedItems, false, true);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
//# sourceMappingURL=StatusBarItemsManager.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"StatusBarItemsManager.js","sourceRoot":"","sources":["../../../../src/appui-abstract/statusbar/StatusBarItemsManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAOzE,MAAM,UAAU,GAAG,CAAI,IAAwB,EAAa,EAAE;IAC5D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC;AASF;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAGhC,YAAY,KAA0C;QAF9C,WAAM,GAAuC,EAAE,CAAC;QAOxD;;WAEG;QACa,mBAAc,GAAG,IAAI,OAAO,EAA6C,CAAC;QAPxF,IAAI,KAAK;YACP,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK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B;aACF;YAED,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC5B;QAED,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;IAClE,CAAC;IAEM,oBAAoB,CAAC,QAAqB;QAC/C,uBAAuB;QACvB,IAAI,CAAC,KAAK,QAAQ,CAAC,IAAI;YACrB,OAAO;QAET,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAE/F,uBAAuB;QACvB,IAAI,YAAY;YACd,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module StatusBar\r\n */\r\n\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { ConditionalBooleanValue } from \"../items/ConditionalBooleanValue\";\r\nimport { ConditionalStringValue } from \"../items/ConditionalStringValue\";\r\nimport { CommonStatusBarItem, StatusBarItemId } from \"./StatusBarItem\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\ntype InstanceOrArray<T> = T | ReadonlyArray<T>;\r\n\r\nconst isInstance = <T>(args: InstanceOrArray<T>): args is T => {\r\n return !Array.isArray(args);\r\n};\r\n\r\n/** Arguments of [[StatusBarItemsManager.onChanged]] event.\r\n * @internal\r\n */\r\nexport interface StatusBarItemsChangedArgs {\r\n readonly items: ReadonlyArray<CommonStatusBarItem>;\r\n}\r\n\r\n/**\r\n * Controls status bar items.\r\n * @internal\r\n */\r\nexport class StatusBarItemsManager {\r\n private _items: ReadonlyArray<CommonStatusBarItem> = [];\r\n\r\n constructor(items?: ReadonlyArray<CommonStatusBarItem>) {\r\n if (items)\r\n this.loadItemsInternal(items, true, false);\r\n }\r\n\r\n /** Event raised when StatusBar items are changed.\r\n * @internal\r\n */\r\n public readonly onItemsChanged = new BeEvent<(args: StatusBarItemsChangedArgs) => void>();\r\n\r\n private loadItemsInternal(items: ReadonlyArray<CommonStatusBarItem>, processConditions: boolean, sendItemChanged: boolean) {\r\n if (processConditions && items) {\r\n const eventIds = StatusBarItemsManager.getSyncIdsOfInterest(items);\r\n if (0 !== eventIds.length) {\r\n const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(items, new Set(eventIds));\r\n\r\n // istanbul ignore else\r\n if (itemsUpdated)\r\n items = updatedItems;\r\n }\r\n }\r\n\r\n this._items = items;\r\n if (sendItemChanged)\r\n this.onItemsChanged.raiseEvent({ items });\r\n }\r\n\r\n /** load items but do not fire onItemsChanged\r\n * @internal\r\n */\r\n public loadItems(items: ReadonlyArray<CommonStatusBarItem>) {\r\n this.loadItemsInternal(items, true, false);\r\n }\r\n\r\n /** Get an array of the StatusBar items */\r\n public get items(): ReadonlyArray<CommonStatusBarItem> {\r\n return this._items;\r\n }\r\n\r\n public set items(items: ReadonlyArray<CommonStatusBarItem>) {\r\n // istanbul ignore else\r\n if (items !== this._items)\r\n this.loadItemsInternal(items, true, true);\r\n }\r\n\r\n public add(itemOrItems: CommonStatusBarItem | ReadonlyArray<CommonStatusBarItem>) {\r\n let itemsToAdd;\r\n if (isInstance(itemOrItems))\r\n itemsToAdd = [itemOrItems];\r\n else {\r\n itemsToAdd = itemOrItems.filter((itemToAdd, index) => itemOrItems.findIndex((item) => item.id === itemToAdd.id) === index);\r\n }\r\n itemsToAdd = itemsToAdd.filter((itemToAdd) => this._items.find((item) => item.id === itemToAdd.id) === undefined);\r\n if (itemsToAdd.length === 0)\r\n return;\r\n const items = [\r\n ...this._items,\r\n ...itemsToAdd,\r\n ];\r\n this.items = items;\r\n }\r\n\r\n /** Remove StatusBar items based on id */\r\n public remove(itemIdOrItemIds: StatusBarItemId | ReadonlyArray<StatusBarItemId\r\n >) {\r\n const items = this._items.filter((item) => {\r\n return isInstance(itemIdOrItemIds) ? item.id !== itemIdOrItemIds : !itemIdOrItemIds.find((itemId) => itemId === item.id);\r\n });\r\n this.items = items;\r\n }\r\n\r\n /** @internal */\r\n public removeAll() {\r\n this._items = [];\r\n }\r\n\r\n public static getSyncIdsOfInterest(items: readonly CommonStatusBarItem[]): string[] {\r\n const eventIds = new Set<string>();\r\n items.forEach((item) => {\r\n for (const [, entry] of Object.entries(item)) {\r\n if (entry instanceof ConditionalBooleanValue) {\r\n entry.syncEventIds.forEach((eventId: string) => eventIds.add(eventId.toLowerCase()));\r\n } else /* istanbul ignore else */ if (entry instanceof ConditionalStringValue) {\r\n entry.syncEventIds.forEach((eventId: string) => eventIds.add(eventId.toLowerCase()));\r\n }\r\n }\r\n });\r\n return [...eventIds.values()];\r\n }\r\n\r\n private internalRefreshAffectedItems(items: readonly CommonStatusBarItem[], eventIds: Set<string>): { itemsUpdated: boolean, updatedItems: CommonStatusBarItem[] } {\r\n // istanbul ignore next\r\n if (0 === eventIds.size)\r\n return { itemsUpdated: false, updatedItems: [] };\r\n\r\n let updateRequired = false;\r\n\r\n const newItems: CommonStatusBarItem[] = [];\r\n for (const item of items) {\r\n const updatedItem = { ...item };\r\n\r\n for (const [, entry] of Object.entries(updatedItem)) {\r\n if (entry instanceof ConditionalBooleanValue) {\r\n // istanbul ignore else\r\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\r\n updateRequired = true;\r\n } else /* istanbul ignore else */ if (entry instanceof ConditionalStringValue) {\r\n // istanbul ignore else\r\n if (ConditionalStringValue.refreshValue(entry, eventIds))\r\n updateRequired = true;\r\n }\r\n }\r\n\r\n newItems.push(updatedItem);\r\n }\r\n\r\n return { itemsUpdated: updateRequired, updatedItems: newItems };\r\n }\r\n\r\n public refreshAffectedItems(eventIds: Set<string>) {\r\n // istanbul ignore next\r\n if (0 === eventIds.size)\r\n return;\r\n\r\n const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(this.items, eventIds);\r\n\r\n // istanbul ignore else\r\n if (itemsUpdated)\r\n this.loadItemsInternal(updatedItems, false, true);\r\n }\r\n}\r\n"]}
|
@@ -4,10 +4,31 @@
|
|
4
4
|
import { BadgeType } from "../items/BadgeType";
|
5
5
|
import { ConditionalBooleanValue } from "../items/ConditionalBooleanValue";
|
6
6
|
import { ConditionalStringValue } from "../items/ConditionalStringValue";
|
7
|
+
import { ProvidedItem } from "../items/ProvidedItem";
|
8
|
+
/** Used to specify the usage of the toolbar which determine the toolbar position.
|
9
|
+
* @deprecated in 3.6. Use [ToolbarUsage]($appui-react) instead.
|
10
|
+
* @public
|
11
|
+
*/
|
12
|
+
export declare enum ToolbarUsage {
|
13
|
+
/** Contains tools to Create Update and Delete content - in ninezone this is in top left of content area. */
|
14
|
+
ContentManipulation = 0,
|
15
|
+
/** Manipulate view/camera - in ninezone this is in top right of content area. */
|
16
|
+
ViewNavigation = 1
|
17
|
+
}
|
18
|
+
/** Used to specify the orientation of the toolbar.
|
19
|
+
* @deprecated in 3.6. Use [ToolbarOrientation]($appui-react) instead.
|
20
|
+
* @public
|
21
|
+
*/
|
22
|
+
export declare enum ToolbarOrientation {
|
23
|
+
/** Horizontal toolbar. */
|
24
|
+
Horizontal = 0,
|
25
|
+
/** Vertical toolbar. */
|
26
|
+
Vertical = 1
|
27
|
+
}
|
7
28
|
/** Describes the data needed to insert a UI items into an existing set of UI items.
|
8
29
|
* @public
|
9
30
|
*/
|
10
|
-
export interface ToolbarItem {
|
31
|
+
export interface ToolbarItem extends ProvidedItem {
|
11
32
|
/** can be used by application to store miscellaneous data. */
|
12
33
|
readonly applicationData?: any;
|
13
34
|
/** Describes badge. Renders no badge if not specified. */
|
@@ -78,6 +99,11 @@ export interface CustomButtonDefinition extends ToolbarItem {
|
|
78
99
|
* @public
|
79
100
|
*/
|
80
101
|
export type CommonToolbarItem = ActionButton | GroupButton | CustomButtonDefinition;
|
102
|
+
/** Type for Toolbar Item Id
|
103
|
+
* @deprecated in 3.6. Please use `ToolbarItem["id"]` from @itwin/appui-react.
|
104
|
+
* @public
|
105
|
+
*/
|
106
|
+
export type ToolbarItemId = CommonToolbarItem["id"];
|
81
107
|
/** Helper class to create Abstract StatusBar Item definitions.
|
82
108
|
* @public
|
83
109
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ToolbarItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-abstract/toolbars/ToolbarItem.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;
|
1
|
+
{"version":3,"file":"ToolbarItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-abstract/toolbars/ToolbarItem.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD;;;GAGG;AACH,oBAAY,YAAY;IACtB,4GAA4G;IAC5G,mBAAmB,IAAI;IACvB,iFAAiF;IACjF,cAAc,IAAI;CACnB;AAED;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B,0BAA0B;IAC1B,UAAU,IAAI;IACd,wBAAwB;IACxB,QAAQ,IAAI;CACb;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,8DAA8D;IAC9D,QAAQ,CAAC,eAAe,CAAC,EAAE,GAAG,CAAC;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC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@@
|
|
5
5
|
/** @packageDocumentation
|
6
6
|
* @module Toolbar
|
7
7
|
*/
|
8
|
+
/** Used to specify the usage of the toolbar which determine the toolbar position.
|
9
|
+
* @deprecated in 3.6. Use [ToolbarUsage]($appui-react) instead.
|
10
|
+
* @public
|
11
|
+
*/
|
12
|
+
export var ToolbarUsage;
|
13
|
+
(function (ToolbarUsage) {
|
14
|
+
/** Contains tools to Create Update and Delete content - in ninezone this is in top left of content area. */
|
15
|
+
ToolbarUsage[ToolbarUsage["ContentManipulation"] = 0] = "ContentManipulation";
|
16
|
+
/** Manipulate view/camera - in ninezone this is in top right of content area. */
|
17
|
+
ToolbarUsage[ToolbarUsage["ViewNavigation"] = 1] = "ViewNavigation";
|
18
|
+
})(ToolbarUsage || (ToolbarUsage = {}));
|
19
|
+
/** Used to specify the orientation of the toolbar.
|
20
|
+
* @deprecated in 3.6. Use [ToolbarOrientation]($appui-react) instead.
|
21
|
+
* @public
|
22
|
+
*/
|
23
|
+
export var ToolbarOrientation;
|
24
|
+
(function (ToolbarOrientation) {
|
25
|
+
/** Horizontal toolbar. */
|
26
|
+
ToolbarOrientation[ToolbarOrientation["Horizontal"] = 0] = "Horizontal";
|
27
|
+
/** Vertical toolbar. */
|
28
|
+
ToolbarOrientation[ToolbarOrientation["Vertical"] = 1] = "Vertical";
|
29
|
+
})(ToolbarOrientation || (ToolbarOrientation = {}));
|
8
30
|
/** Helper class to create Abstract StatusBar Item definitions.
|
9
31
|
* @public
|
10
32
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ToolbarItem.js","sourceRoot":"","sources":["../../../../src/appui-abstract/toolbars/ToolbarItem.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;
|
1
|
+
{"version":3,"file":"ToolbarItem.js","sourceRoot":"","sources":["../../../../src/appui-abstract/toolbars/ToolbarItem.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAOH;;;GAGG;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;;;GAGG;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;AAuFD;;GAEG;AACH,MAAa,oBAAoB;IAiB/B,+BAA+B;IACxB,MAAM,CAAC,cAAc,CAAC,IAAuB;QAClD,OAAQ,IAAqB,CAAC,OAAO,KAAK,SAAS,CAAC;IACtD,CAAC;IAED,8BAA8B;IACvB,MAAM,CAAC,aAAa,CAAC,IAAuB;QACjD,OAAQ,IAAoB,CAAC,KAAK,KAAK,SAAS,CAAC;IACnD,CAAC;IAED,yCAAyC;IAClC,MAAM,CAAC,kBAAkB,CAAC,IAAuB;QACtD,OAAO,CAAC,CAAE,IAA+B,CAAC,QAAQ,CAAC;IACrD,CAAC;;AA7BD,+BAA+B;AACjB,uCAAkB,GAAG,CAAC,EAAU,EAAE,YAAoB,EAAE,IAAqC,EAAE,KAAsC,EAAE,OAAmB,EAAE,SAAiC,EAAgB,EAAE,CAAC,CAAC;IAC7N,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE,KAAK;IACX,OAAO;IACP,GAAG,SAAS;CACb,CAAC,CAAC;AAEH,8BAA8B;AAChB,sCAAiB,GAAG,CAAC,EAAU,EAAE,YAAoB,EAAE,IAAqC,EAAE,KAAsC,EAAE,KAAgD,EAAE,SAAgC,EAAe,EAAE,CAAC,CAAC;IACvP,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE,KAAK;IACX,KAAK;IACL,GAAG,SAAS;CACb,CAAC,CAAC;SAfQ,oBAAoB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Toolbar\r\n */\r\n\r\nimport { BadgeType } from \"../items/BadgeType\";\r\nimport { ConditionalBooleanValue } from \"../items/ConditionalBooleanValue\";\r\nimport { ConditionalStringValue } from \"../items/ConditionalStringValue\";\r\nimport { ProvidedItem } from \"../items/ProvidedItem\";\r\n\r\n/** Used to specify the usage of the toolbar which determine the toolbar position.\r\n * @deprecated in 3.6. Use [ToolbarUsage]($appui-react) instead.\r\n * @public\r\n */\r\nexport enum ToolbarUsage {\r\n /** Contains tools to Create Update and Delete content - in ninezone this is in top left of content area. */\r\n ContentManipulation = 0,\r\n /** Manipulate view/camera - in ninezone this is in top right of content area. */\r\n ViewNavigation = 1,\r\n}\r\n\r\n/** Used to specify the orientation of the toolbar.\r\n * @deprecated in 3.6. Use [ToolbarOrientation]($appui-react) instead.\r\n * @public\r\n */\r\nexport enum ToolbarOrientation {\r\n /** Horizontal toolbar. */\r\n Horizontal = 0,\r\n /** Vertical toolbar. */\r\n Vertical = 1,\r\n}\r\n\r\n/** Describes the data needed to insert a UI items into an existing set of UI items.\r\n * @public\r\n */\r\nexport interface ToolbarItem extends ProvidedItem { // eslint-disable-line deprecation/deprecation\r\n /** can be used by application to store miscellaneous data. */\r\n readonly applicationData?: any;\r\n /** Describes badge. Renders no badge if not specified. */\r\n readonly badgeType?: BadgeType;\r\n /** Optional description */\r\n readonly description?: string | ConditionalStringValue;\r\n /** Require uniqueId for the item. To ensure uniqueness it is suggested that a namespace prefix of the extension name be used. */\r\n readonly id: string;\r\n /** optional data to used by item implementor. */\r\n readonly internalData?: Map<string, any>;\r\n /** Defines if the item is active (shown with an active stripe/bar). */\r\n readonly isActive?: boolean;\r\n /** Describes if the item is visible or hidden. The default is for the item to be visible. */\r\n readonly isHidden?: boolean | ConditionalBooleanValue;\r\n /** Describes if the item is enabled or disabled. The default is for the item to be enabled. */\r\n readonly isDisabled?: boolean | ConditionalBooleanValue;\r\n /** Describes if the item should appear pressed (used for displaying toggle state). This property is NOT used by Toolbars\r\n * constructed using the `ToolbarWithOverflow` component, which are used in AppUi 2.0 and later. For these later toolbars\r\n * the icon is usually changed to denote the state of a toggle.\r\n */\r\n readonly isPressed?: boolean;\r\n /** Specifies the item's grouping value. Items are sorted by group and then item priority. When\r\n * group priority changes a separator is inserted. It is recommended using values 10 through 100, incrementing by 10. This\r\n * allows extensions enough gaps to insert their own groups. If the value is not specified a groupPriority of 0 is used.\r\n */\r\n readonly groupPriority?: number;\r\n /** Priority within a toolbar or group. */\r\n readonly itemPriority: number;\r\n /** Optional parent tool group to add tool. */\r\n readonly parentToolGroupId?: string;\r\n}\r\n\r\n/** Describes the data needed to insert an action button into a toolbar.\r\n * @public\r\n */\r\nexport interface ActionButton extends ToolbarItem {\r\n /** Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id. */\r\n readonly icon: string | ConditionalStringValue;\r\n /** label, shown as tool tip on a button or an item label in a group. */\r\n readonly label: string | ConditionalStringValue;\r\n /** function to run when the button is pressed. */\r\n readonly execute: () => void;\r\n}\r\n\r\n/** Describes the data needed to insert a group button into a toolbar.\r\n * @public\r\n */\r\nexport interface GroupButton extends ToolbarItem {\r\n /** Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id. */\r\n readonly icon: string | ConditionalStringValue;\r\n /** label, shown as tool tip on group button or a group button label in a group panel. */\r\n readonly label: string | ConditionalStringValue;\r\n /** label shown as the title in at top of group panel. */\r\n readonly panelLabel?: string | ConditionalStringValue;\r\n /** children of the group */\r\n readonly items: ReadonlyArray<ActionButton | GroupButton>; // eslint-disable-line deprecation/deprecation\r\n}\r\n\r\n/** Describes the data needed to insert a custom button into a toolbar.\r\n * @public\r\n */\r\nexport interface CustomButtonDefinition extends ToolbarItem {\r\n /** Name of icon WebFont entry or if specifying an imported SVG symbol use \"webSvg:\" prefix to imported symbol Id. */\r\n readonly icon?: string | ConditionalStringValue;\r\n /** label, shown as tool tip on group button or a group button label in a group panel. */\r\n readonly label?: string | ConditionalStringValue;\r\n /** parameter that marks data as being a custom definition. */\r\n readonly isCustom: true;\r\n}\r\n\r\n/** Any Button Type that can be inserted into a toolbar.\r\n * @public\r\n */\r\nexport type CommonToolbarItem = ActionButton | GroupButton | CustomButtonDefinition;\r\n\r\n/** Type for Toolbar Item Id\r\n * @deprecated in 3.6. Please use `ToolbarItem[\"id\"]` from @itwin/appui-react.\r\n * @public\r\n */\r\nexport type ToolbarItemId = CommonToolbarItem[\"id\"]; // eslint-disable-line deprecation/deprecation\r\n\r\n/** Helper class to create Abstract StatusBar Item definitions.\r\n * @public\r\n */\r\nexport class ToolbarItemUtilities {\r\n /** Creates an Action Button */\r\n public static createActionButton = (id: string, itemPriority: number, icon: string | ConditionalStringValue, label: string | ConditionalStringValue, execute: () => void, overrides?: Partial<ActionButton>): ActionButton => ({\r\n id, itemPriority,\r\n icon, label,\r\n execute,\r\n ...overrides,\r\n });\r\n\r\n /** Creates a Group button. */\r\n public static createGroupButton = (id: string, itemPriority: number, icon: string | ConditionalStringValue, label: string | ConditionalStringValue, items: ReadonlyArray<ActionButton | GroupButton>, overrides?: Partial<GroupButton>): GroupButton => ({\r\n id, itemPriority,\r\n icon, label,\r\n items,\r\n ...overrides,\r\n });\r\n\r\n /** ActionButton type guard. */\r\n public static isActionButton(item: CommonToolbarItem): item is ActionButton {\r\n return (item as ActionButton).execute !== undefined;\r\n }\r\n\r\n /** GroupButton type guard. */\r\n public static isGroupButton(item: CommonToolbarItem): item is GroupButton {\r\n return (item as GroupButton).items !== undefined;\r\n }\r\n\r\n /** CustomButtonDefinition type guard. */\r\n public static isCustomDefinition(item: CommonToolbarItem): item is CustomButtonDefinition {\r\n return !!(item as CustomButtonDefinition).isCustom;\r\n }\r\n}\r\n"]}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/** @packageDocumentation
|
2
|
+
* @module Toolbar
|
3
|
+
*/
|
4
|
+
import { BeEvent } from "@itwin/core-bentley";
|
5
|
+
import { CommonToolbarItem, ToolbarItemId } from "./ToolbarItem";
|
6
|
+
/** Arguments of [[ToolbarItemsManager.onChanged]] event.
|
7
|
+
* @internal
|
8
|
+
*/
|
9
|
+
export interface ToolbarItemsChangedArgs {
|
10
|
+
readonly items: ReadonlyArray<CommonToolbarItem>;
|
11
|
+
}
|
12
|
+
/**
|
13
|
+
* Controls status bar items.
|
14
|
+
* @internal
|
15
|
+
*/
|
16
|
+
export declare class ToolbarItemsManager {
|
17
|
+
protected _items: ReadonlyArray<CommonToolbarItem>;
|
18
|
+
constructor(items?: ReadonlyArray<CommonToolbarItem>);
|
19
|
+
/** Event raised when Toolbar items are changed.
|
20
|
+
* @internal
|
21
|
+
*/
|
22
|
+
readonly onItemsChanged: BeEvent<(args: ToolbarItemsChangedArgs) => void>;
|
23
|
+
private loadItemsInternal;
|
24
|
+
/** load items but do not fire onItemsChanged
|
25
|
+
* @internal
|
26
|
+
*/
|
27
|
+
loadItems(items: ReadonlyArray<CommonToolbarItem>): void;
|
28
|
+
/** Get an array of the Toolbar items */
|
29
|
+
get items(): ReadonlyArray<CommonToolbarItem>;
|
30
|
+
set items(items: ReadonlyArray<CommonToolbarItem>);
|
31
|
+
add(itemOrItems: CommonToolbarItem | ReadonlyArray<CommonToolbarItem>): void;
|
32
|
+
/** Remove Toolbar items based on id */
|
33
|
+
remove(itemIdOrItemIds: ToolbarItemId | ReadonlyArray<ToolbarItemId>): void;
|
34
|
+
/** @internal */
|
35
|
+
removeAll(): void;
|
36
|
+
private static gatherSyncIds;
|
37
|
+
static getSyncIdsOfInterest(items: readonly CommonToolbarItem[]): string[];
|
38
|
+
private static refreshChildItems;
|
39
|
+
private internalRefreshAffectedItems;
|
40
|
+
refreshAffectedItems(eventIds: Set<string>): void;
|
41
|
+
private static isActiveToolIdRefreshRequiredForChildren;
|
42
|
+
private isActiveToolIdRefreshRequired;
|
43
|
+
private static refreshActiveToolIdInChildItems;
|
44
|
+
setActiveToolId(toolId: string): void;
|
45
|
+
}
|
46
|
+
//# sourceMappingURL=ToolbarItemsManager.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ToolbarItemsManager.d.ts","sourceRoot":"","sources":["../../../../src/appui-abstract/toolbars/ToolbarItemsManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAgB,iBAAiB,EAAe,aAAa,EAAwB,MAAM,eAAe,CAAC;AAUlH;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAClD;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAM;gBAE5C,KAAK,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC;IAKpD;;OAEG;IACH,SAAgB,cAAc,iBAAsB,uBAAuB,KAAK,IAAI,EAAI;IAExF,OAAO,CAAC,iBAAiB;IAiBzB;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,iBAAiB,CAAC;IAIxD,yCAAyC;IACzC,IAAW,KAAK,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAEnD;IAED,IAAW,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAIvD;IAEM,GAAG,CAAC,WAAW,EAAE,iBAAiB,GAAG,aAAa,CAAC,iBAAiB,CAAC;IAiB5E,uCAAuC;IAChC,MAAM,CAAC,eAAe,EAAE,aAAa,GAAG,aAAa,CAAC,aAAa,CACzE;IAOD,gBAAgB;IACT,SAAS;IAIhB,OAAO,CAAC,MAAM,CAAC,aAAa;WAiBd,oBAAoB,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,GAAG,MAAM,EAAE;IAMjF,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAiChC,OAAO,CAAC,4BAA4B;IAsC7B,oBAAoB,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC;IAYjD,OAAO,CAAC,MAAM,CAAC,wCAAwC;IAcvD,OAAO,CAAC,6BAA6B;IAerC,OAAO,CAAC,MAAM,CAAC,+BAA+B;IAevC,eAAe,CAAC,MAAM,EAAE,MAAM;CAoBtC"}
|
@@ -0,0 +1,232 @@
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
5
|
+
/** @packageDocumentation
|
6
|
+
* @module Toolbar
|
7
|
+
*/
|
8
|
+
import { BeEvent } from "@itwin/core-bentley";
|
9
|
+
import { ConditionalBooleanValue } from "../items/ConditionalBooleanValue";
|
10
|
+
import { ConditionalStringValue } from "../items/ConditionalStringValue";
|
11
|
+
import { ToolbarItemUtilities } from "./ToolbarItem";
|
12
|
+
const isInstance = (args) => {
|
13
|
+
return !Array.isArray(args);
|
14
|
+
};
|
15
|
+
/**
|
16
|
+
* Controls status bar items.
|
17
|
+
* @internal
|
18
|
+
*/
|
19
|
+
export class ToolbarItemsManager {
|
20
|
+
constructor(items) {
|
21
|
+
this._items = [];
|
22
|
+
/** Event raised when Toolbar items are changed.
|
23
|
+
* @internal
|
24
|
+
*/
|
25
|
+
this.onItemsChanged = new BeEvent();
|
26
|
+
if (items)
|
27
|
+
this.loadItemsInternal(items, true, false);
|
28
|
+
}
|
29
|
+
loadItemsInternal(items, processConditions, sendItemChanged) {
|
30
|
+
if (processConditions && items) {
|
31
|
+
const eventIds = ToolbarItemsManager.getSyncIdsOfInterest(items);
|
32
|
+
if (0 !== eventIds.length) {
|
33
|
+
const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(items, new Set(eventIds));
|
34
|
+
// istanbul ignore else
|
35
|
+
if (itemsUpdated)
|
36
|
+
items = updatedItems;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
this._items = items;
|
40
|
+
if (sendItemChanged)
|
41
|
+
this.onItemsChanged.raiseEvent({ items });
|
42
|
+
}
|
43
|
+
/** load items but do not fire onItemsChanged
|
44
|
+
* @internal
|
45
|
+
*/
|
46
|
+
loadItems(items) {
|
47
|
+
this.loadItemsInternal(items, true, false);
|
48
|
+
}
|
49
|
+
/** Get an array of the Toolbar items */
|
50
|
+
get items() {
|
51
|
+
return this._items;
|
52
|
+
}
|
53
|
+
set items(items) {
|
54
|
+
// istanbul ignore else
|
55
|
+
if (items !== this._items)
|
56
|
+
this.loadItemsInternal(items, true, true);
|
57
|
+
}
|
58
|
+
add(itemOrItems) {
|
59
|
+
let itemsToAdd;
|
60
|
+
if (isInstance(itemOrItems))
|
61
|
+
itemsToAdd = [itemOrItems];
|
62
|
+
else {
|
63
|
+
itemsToAdd = itemOrItems.filter((itemToAdd, index) => itemOrItems.findIndex((item) => item.id === itemToAdd.id) === index);
|
64
|
+
}
|
65
|
+
itemsToAdd = itemsToAdd.filter((itemToAdd) => this._items.find((item) => item.id === itemToAdd.id) === undefined);
|
66
|
+
if (itemsToAdd.length === 0)
|
67
|
+
return;
|
68
|
+
const items = [
|
69
|
+
...this._items,
|
70
|
+
...itemsToAdd,
|
71
|
+
];
|
72
|
+
this.items = items;
|
73
|
+
}
|
74
|
+
/** Remove Toolbar items based on id */
|
75
|
+
remove(itemIdOrItemIds) {
|
76
|
+
const items = this._items.filter((item) => {
|
77
|
+
return isInstance(itemIdOrItemIds) ? item.id !== itemIdOrItemIds : !itemIdOrItemIds.find((itemId) => itemId === item.id);
|
78
|
+
});
|
79
|
+
this.items = items;
|
80
|
+
}
|
81
|
+
/** @internal */
|
82
|
+
removeAll() {
|
83
|
+
this._items = [];
|
84
|
+
}
|
85
|
+
static gatherSyncIds(eventIds, items) {
|
86
|
+
for (const item of items) {
|
87
|
+
for (const [, entry] of Object.entries(item)) {
|
88
|
+
if (entry instanceof ConditionalBooleanValue) {
|
89
|
+
entry.syncEventIds.forEach((eventId) => eventIds.add(eventId.toLowerCase()));
|
90
|
+
}
|
91
|
+
else /* istanbul ignore else */ if (entry instanceof ConditionalStringValue) {
|
92
|
+
entry.syncEventIds.forEach((eventId) => eventIds.add(eventId.toLowerCase()));
|
93
|
+
}
|
94
|
+
}
|
95
|
+
// istanbul ignore else
|
96
|
+
if (ToolbarItemUtilities.isGroupButton(item)) {
|
97
|
+
this.gatherSyncIds(eventIds, item.items);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
static getSyncIdsOfInterest(items) {
|
102
|
+
const eventIds = new Set();
|
103
|
+
this.gatherSyncIds(eventIds, items);
|
104
|
+
return [...eventIds.values()];
|
105
|
+
}
|
106
|
+
static refreshChildItems(parentItem, eventIds) {
|
107
|
+
const updatedItems = [];
|
108
|
+
let itemsUpdated = false;
|
109
|
+
for (const item of parentItem.items) {
|
110
|
+
const updatedItem = { ...item };
|
111
|
+
if (ToolbarItemUtilities.isGroupButton(updatedItem)) {
|
112
|
+
const { childrenUpdated, childItems } = this.refreshChildItems(updatedItem, eventIds);
|
113
|
+
// istanbul ignore else
|
114
|
+
if (childrenUpdated) {
|
115
|
+
updatedItem.items = childItems;
|
116
|
+
itemsUpdated = true;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
for (const [, entry] of Object.entries(updatedItem)) {
|
120
|
+
if (entry instanceof ConditionalBooleanValue) {
|
121
|
+
// istanbul ignore else
|
122
|
+
if (ConditionalBooleanValue.refreshValue(entry, eventIds))
|
123
|
+
itemsUpdated = true;
|
124
|
+
}
|
125
|
+
else /* istanbul ignore else */ if (entry instanceof ConditionalStringValue) {
|
126
|
+
// istanbul ignore else
|
127
|
+
if (ConditionalStringValue.refreshValue(entry, eventIds))
|
128
|
+
itemsUpdated = true;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
updatedItems.push(updatedItem);
|
132
|
+
}
|
133
|
+
return { childrenUpdated: itemsUpdated, childItems: updatedItems };
|
134
|
+
}
|
135
|
+
internalRefreshAffectedItems(items, eventIds) {
|
136
|
+
// istanbul ignore next
|
137
|
+
if (0 === eventIds.size)
|
138
|
+
return { itemsUpdated: false, updatedItems: [] };
|
139
|
+
let updateRequired = false;
|
140
|
+
const newItems = [];
|
141
|
+
for (const item of items) {
|
142
|
+
const updatedItem = { ...item };
|
143
|
+
if (ToolbarItemUtilities.isGroupButton(updatedItem)) {
|
144
|
+
const { childrenUpdated, childItems } = ToolbarItemsManager.refreshChildItems(updatedItem, eventIds);
|
145
|
+
// istanbul ignore else
|
146
|
+
if (childrenUpdated) {
|
147
|
+
updatedItem.items = childItems;
|
148
|
+
updateRequired = true;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
for (const [, entry] of Object.entries(updatedItem)) {
|
152
|
+
if (entry instanceof ConditionalBooleanValue) {
|
153
|
+
// istanbul ignore else
|
154
|
+
if (ConditionalBooleanValue.refreshValue(entry, eventIds))
|
155
|
+
updateRequired = true;
|
156
|
+
}
|
157
|
+
else /* istanbul ignore else */ if (entry instanceof ConditionalStringValue) {
|
158
|
+
// istanbul ignore else
|
159
|
+
if (ConditionalStringValue.refreshValue(entry, eventIds))
|
160
|
+
updateRequired = true;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
newItems.push(updatedItem);
|
164
|
+
}
|
165
|
+
return { itemsUpdated: updateRequired, updatedItems: newItems };
|
166
|
+
}
|
167
|
+
refreshAffectedItems(eventIds) {
|
168
|
+
// istanbul ignore next
|
169
|
+
if (0 === eventIds.size)
|
170
|
+
return;
|
171
|
+
const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(this.items, eventIds);
|
172
|
+
// istanbul ignore else
|
173
|
+
if (itemsUpdated)
|
174
|
+
this.loadItemsInternal(updatedItems, false, true);
|
175
|
+
}
|
176
|
+
static isActiveToolIdRefreshRequiredForChildren(children, toolId) {
|
177
|
+
for (const item of children) {
|
178
|
+
if (ToolbarItemUtilities.isGroupButton(item)) {
|
179
|
+
if (this.isActiveToolIdRefreshRequiredForChildren(item.items, toolId))
|
180
|
+
return true;
|
181
|
+
}
|
182
|
+
else {
|
183
|
+
const isActive = !!item.isActive;
|
184
|
+
if ((isActive && item.id !== toolId) || (!isActive && item.id === toolId))
|
185
|
+
return true;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
return false;
|
189
|
+
}
|
190
|
+
isActiveToolIdRefreshRequired(toolId) {
|
191
|
+
for (const item of this.items) {
|
192
|
+
if (ToolbarItemUtilities.isGroupButton(item)) {
|
193
|
+
if (ToolbarItemsManager.isActiveToolIdRefreshRequiredForChildren(item.items, toolId))
|
194
|
+
return true;
|
195
|
+
}
|
196
|
+
else {
|
197
|
+
const isActive = !!item.isActive;
|
198
|
+
if ((isActive && item.id !== toolId) || (!isActive && item.id === toolId))
|
199
|
+
return true;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
return false;
|
203
|
+
}
|
204
|
+
static refreshActiveToolIdInChildItems(parentItem, toolId) {
|
205
|
+
const newChildren = [];
|
206
|
+
for (const item of parentItem.items) {
|
207
|
+
const updatedItem = { ...item };
|
208
|
+
if (ToolbarItemUtilities.isGroupButton(updatedItem)) {
|
209
|
+
updatedItem.items = ToolbarItemsManager.refreshActiveToolIdInChildItems(updatedItem, toolId);
|
210
|
+
}
|
211
|
+
updatedItem.isActive = (updatedItem.id === toolId);
|
212
|
+
newChildren.push(updatedItem);
|
213
|
+
}
|
214
|
+
return newChildren;
|
215
|
+
}
|
216
|
+
setActiveToolId(toolId) {
|
217
|
+
// first see if any updates are really necessary
|
218
|
+
if (!this.isActiveToolIdRefreshRequired(toolId))
|
219
|
+
return;
|
220
|
+
const newItems = [];
|
221
|
+
for (const item of this.items) {
|
222
|
+
const updatedItem = { ...item };
|
223
|
+
if (ToolbarItemUtilities.isGroupButton(updatedItem)) {
|
224
|
+
updatedItem.items = ToolbarItemsManager.refreshActiveToolIdInChildItems(updatedItem, toolId);
|
225
|
+
}
|
226
|
+
updatedItem.isActive = (updatedItem.id === toolId);
|
227
|
+
newItems.push(updatedItem);
|
228
|
+
}
|
229
|
+
this.items = newItems;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
//# sourceMappingURL=ToolbarItemsManager.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ToolbarItemsManager.js","sourceRoot":"","sources":["../../../../src/appui-abstract/toolbars/ToolbarItemsManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAA+D,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAMlH,MAAM,UAAU,GAAG,CAAI,IAAwB,EAAa,EAAE;IAC5D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC;AASF;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAG9B,YAAY,KAAwC;QAF1C,WAAM,GAAqC,EAAE,CAAC;QAOxD;;WAEG;QACa,mBAAc,GAAG,IAAI,OAAO,EAA2C,CAAC;QAPtF,IAAI,KAAK;YACP,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAOO,iBAAiB,CAAC,KAAuC,EAAE,iBAA0B,EAAE,eAAwB;QACrH,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,GAAG,IAAI,CAAC,4BAA4B,C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nD,WAAW,CAAC,KAAK,GAAG,mBAAmB,CAAC,+BAA+B,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;aAC9F;YAED,WAAW,CAAC,QAAQ,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;YACnD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC5B;QAED,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;IACxB,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Toolbar\r\n */\r\n\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { ConditionalBooleanValue } from \"../items/ConditionalBooleanValue\";\r\nimport { ConditionalStringValue } from \"../items/ConditionalStringValue\";\r\nimport { ActionButton, CommonToolbarItem, GroupButton, ToolbarItemId, ToolbarItemUtilities } from \"./ToolbarItem\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\ntype InstanceOrArray<T> = T | ReadonlyArray<T>;\r\n\r\nconst isInstance = <T>(args: InstanceOrArray<T>): args is T => {\r\n return !Array.isArray(args);\r\n};\r\n\r\n/** Arguments of [[ToolbarItemsManager.onChanged]] event.\r\n * @internal\r\n */\r\nexport interface ToolbarItemsChangedArgs {\r\n readonly items: ReadonlyArray<CommonToolbarItem>;\r\n}\r\n\r\n/**\r\n * Controls status bar items.\r\n * @internal\r\n */\r\nexport class ToolbarItemsManager {\r\n protected _items: ReadonlyArray<CommonToolbarItem> = [];\r\n\r\n constructor(items?: ReadonlyArray<CommonToolbarItem>) {\r\n if (items)\r\n this.loadItemsInternal(items, true, false);\r\n }\r\n\r\n /** Event raised when Toolbar items are changed.\r\n * @internal\r\n */\r\n public readonly onItemsChanged = new BeEvent<(args: ToolbarItemsChangedArgs) => void>();\r\n\r\n private loadItemsInternal(items: ReadonlyArray<CommonToolbarItem>, processConditions: boolean, sendItemChanged: boolean) {\r\n if (processConditions && items) {\r\n const eventIds = ToolbarItemsManager.getSyncIdsOfInterest(items);\r\n if (0 !== eventIds.length) {\r\n const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(items, new Set(eventIds));\r\n\r\n // istanbul ignore else\r\n if (itemsUpdated)\r\n items = updatedItems;\r\n }\r\n }\r\n\r\n this._items = items;\r\n if (sendItemChanged)\r\n this.onItemsChanged.raiseEvent({ items });\r\n }\r\n\r\n /** load items but do not fire onItemsChanged\r\n * @internal\r\n */\r\n public loadItems(items: ReadonlyArray<CommonToolbarItem>) {\r\n this.loadItemsInternal(items, true, false);\r\n }\r\n\r\n /** Get an array of the Toolbar items */\r\n public get items(): ReadonlyArray<CommonToolbarItem> {\r\n return this._items;\r\n }\r\n\r\n public set items(items: ReadonlyArray<CommonToolbarItem>) {\r\n // istanbul ignore else\r\n if (items !== this._items)\r\n this.loadItemsInternal(items, true, true);\r\n }\r\n\r\n public add(itemOrItems: CommonToolbarItem | ReadonlyArray<CommonToolbarItem>) {\r\n let itemsToAdd;\r\n if (isInstance(itemOrItems))\r\n itemsToAdd = [itemOrItems];\r\n else {\r\n itemsToAdd = itemOrItems.filter((itemToAdd, index) => itemOrItems.findIndex((item) => item.id === itemToAdd.id) === index);\r\n }\r\n itemsToAdd = itemsToAdd.filter((itemToAdd) => this._items.find((item) => item.id === itemToAdd.id) === undefined);\r\n if (itemsToAdd.length === 0)\r\n return;\r\n const items = [\r\n ...this._items,\r\n ...itemsToAdd,\r\n ];\r\n this.items = items;\r\n }\r\n\r\n /** Remove Toolbar items based on id */\r\n public remove(itemIdOrItemIds: ToolbarItemId | ReadonlyArray<ToolbarItemId\r\n >) {\r\n const items = this._items.filter((item) => {\r\n return isInstance(itemIdOrItemIds) ? item.id !== itemIdOrItemIds : !itemIdOrItemIds.find((itemId) => itemId === item.id);\r\n });\r\n this.items = items;\r\n }\r\n\r\n /** @internal */\r\n public removeAll() {\r\n this._items = [];\r\n }\r\n\r\n private static gatherSyncIds(eventIds: Set<string>, items: readonly CommonToolbarItem[]) {\r\n for (const item of items) {\r\n for (const [, entry] of Object.entries(item)) {\r\n if (entry instanceof ConditionalBooleanValue) {\r\n entry.syncEventIds.forEach((eventId: string) => eventIds.add(eventId.toLowerCase()));\r\n } else /* istanbul ignore else */ if (entry instanceof ConditionalStringValue) {\r\n entry.syncEventIds.forEach((eventId: string) => eventIds.add(eventId.toLowerCase()));\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isGroupButton(item)) {\r\n this.gatherSyncIds(eventIds, item.items);\r\n }\r\n }\r\n }\r\n\r\n public static getSyncIdsOfInterest(items: readonly CommonToolbarItem[]): string[] {\r\n const eventIds = new Set<string>();\r\n this.gatherSyncIds(eventIds, items);\r\n return [...eventIds.values()];\r\n }\r\n\r\n private static refreshChildItems(parentItem: GroupButton, eventIds: Set<string>): { childrenUpdated: boolean, childItems: ReadonlyArray<ActionButton | GroupButton> } {\r\n const updatedItems: Array<ActionButton | GroupButton> = [];\r\n let itemsUpdated = false;\r\n\r\n for (const item of parentItem.items) {\r\n const updatedItem = { ...item };\r\n\r\n if (ToolbarItemUtilities.isGroupButton(updatedItem)) {\r\n const { childrenUpdated, childItems } = this.refreshChildItems(updatedItem, eventIds);\r\n // istanbul ignore else\r\n if (childrenUpdated) {\r\n updatedItem.items = childItems;\r\n itemsUpdated = true;\r\n }\r\n }\r\n\r\n for (const [, entry] of Object.entries(updatedItem)) {\r\n if (entry instanceof ConditionalBooleanValue) {\r\n // istanbul ignore else\r\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\r\n itemsUpdated = true;\r\n } else /* istanbul ignore else */ if (entry instanceof ConditionalStringValue) {\r\n // istanbul ignore else\r\n if (ConditionalStringValue.refreshValue(entry, eventIds))\r\n itemsUpdated = true;\r\n }\r\n }\r\n\r\n updatedItems.push(updatedItem);\r\n }\r\n return { childrenUpdated: itemsUpdated, childItems: updatedItems };\r\n }\r\n\r\n private internalRefreshAffectedItems(items: readonly CommonToolbarItem[], eventIds: Set<string>): { itemsUpdated: boolean, updatedItems: CommonToolbarItem[] } {\r\n // istanbul ignore next\r\n if (0 === eventIds.size)\r\n return { itemsUpdated: false, updatedItems: [] };\r\n\r\n let updateRequired = false;\r\n\r\n const newItems: CommonToolbarItem[] = [];\r\n for (const item of items) {\r\n const updatedItem = { ...item };\r\n\r\n if (ToolbarItemUtilities.isGroupButton(updatedItem)) {\r\n const { childrenUpdated, childItems } = ToolbarItemsManager.refreshChildItems(updatedItem, eventIds);\r\n // istanbul ignore else\r\n if (childrenUpdated) {\r\n updatedItem.items = childItems;\r\n updateRequired = true;\r\n }\r\n }\r\n\r\n for (const [, entry] of Object.entries(updatedItem)) {\r\n if (entry instanceof ConditionalBooleanValue) {\r\n // istanbul ignore else\r\n if (ConditionalBooleanValue.refreshValue(entry, eventIds))\r\n updateRequired = true;\r\n } else /* istanbul ignore else */ if (entry instanceof ConditionalStringValue) {\r\n // istanbul ignore else\r\n if (ConditionalStringValue.refreshValue(entry, eventIds))\r\n updateRequired = true;\r\n }\r\n }\r\n\r\n newItems.push(updatedItem);\r\n }\r\n\r\n return { itemsUpdated: updateRequired, updatedItems: newItems };\r\n }\r\n\r\n public refreshAffectedItems(eventIds: Set<string>) {\r\n // istanbul ignore next\r\n if (0 === eventIds.size)\r\n return;\r\n\r\n const { itemsUpdated, updatedItems } = this.internalRefreshAffectedItems(this.items, eventIds);\r\n\r\n // istanbul ignore else\r\n if (itemsUpdated)\r\n this.loadItemsInternal(updatedItems, false, true);\r\n }\r\n\r\n private static isActiveToolIdRefreshRequiredForChildren(children: ReadonlyArray<ActionButton | GroupButton>, toolId: string): boolean {\r\n for (const item of children) {\r\n if (ToolbarItemUtilities.isGroupButton(item)) {\r\n if (this.isActiveToolIdRefreshRequiredForChildren(item.items, toolId))\r\n return true;\r\n } else {\r\n const isActive = !!item.isActive;\r\n if ((isActive && item.id !== toolId) || (!isActive && item.id === toolId))\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n private isActiveToolIdRefreshRequired(toolId: string): boolean {\r\n for (const item of this.items) {\r\n if (ToolbarItemUtilities.isGroupButton(item)) {\r\n if (ToolbarItemsManager.isActiveToolIdRefreshRequiredForChildren(item.items, toolId))\r\n return true;\r\n } else {\r\n const isActive = !!item.isActive;\r\n if ((isActive && item.id !== toolId) || (!isActive && item.id === toolId))\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private static refreshActiveToolIdInChildItems(parentItem: GroupButton, toolId: string): Array<ActionButton | GroupButton> {\r\n const newChildren: Array<ActionButton | GroupButton> = [];\r\n for (const item of parentItem.items) {\r\n const updatedItem = { ...item };\r\n\r\n if (ToolbarItemUtilities.isGroupButton(updatedItem)) {\r\n updatedItem.items = ToolbarItemsManager.refreshActiveToolIdInChildItems(updatedItem, toolId);\r\n }\r\n\r\n updatedItem.isActive = (updatedItem.id === toolId);\r\n newChildren.push(updatedItem);\r\n }\r\n return newChildren;\r\n }\r\n\r\n public setActiveToolId(toolId: string) {\r\n // first see if any updates are really necessary\r\n if (!this.isActiveToolIdRefreshRequired(toolId))\r\n return;\r\n\r\n const newItems: CommonToolbarItem[] = [];\r\n for (const item of this.items) {\r\n const updatedItem = { ...item };\r\n\r\n if (ToolbarItemUtilities.isGroupButton(updatedItem)) {\r\n updatedItem.items = ToolbarItemsManager.refreshActiveToolIdInChildItems(updatedItem, toolId);\r\n }\r\n\r\n updatedItem.isActive = (updatedItem.id === toolId);\r\n newItems.push(updatedItem);\r\n }\r\n\r\n this.items = newItems;\r\n }\r\n\r\n}\r\n"]}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/** @packageDocumentation
|
2
|
+
* @module Utilities
|
3
|
+
*/
|
4
|
+
/** Uses ECMAScript case transformation (toLowerCase() and toUpperCase()) to check whether or not a given character is a letter.
|
5
|
+
* Beyond the English alphabet, this solution will also work for most Greek, Armenian, Cyrillic, and Latin characters.
|
6
|
+
* But, it will not work for Chinese or Japanese characters since those languages do not have uppercase and lowercase letters.
|
7
|
+
* @alpha
|
8
|
+
*/
|
9
|
+
export declare function isLetter(char: string): boolean;
|
10
|
+
//# sourceMappingURL=isLetter.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"isLetter.d.ts","sourceRoot":"","sources":["../../../../src/appui-abstract/utils/isLetter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9C"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
5
|
+
/** @packageDocumentation
|
6
|
+
* @module Utilities
|
7
|
+
*/
|
8
|
+
/** Uses ECMAScript case transformation (toLowerCase() and toUpperCase()) to check whether or not a given character is a letter.
|
9
|
+
* Beyond the English alphabet, this solution will also work for most Greek, Armenian, Cyrillic, and Latin characters.
|
10
|
+
* But, it will not work for Chinese or Japanese characters since those languages do not have uppercase and lowercase letters.
|
11
|
+
* @alpha
|
12
|
+
*/
|
13
|
+
export function isLetter(char) {
|
14
|
+
return char.length === 1 && char.toLowerCase() !== char.toUpperCase();
|
15
|
+
}
|
16
|
+
//# sourceMappingURL=isLetter.js.map
|