@itwin/appui-react 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/lib/cjs/appui-react/UiFramework.d.ts.map +1 -1
  3. package/lib/cjs/appui-react/UiFramework.js +11 -10
  4. package/lib/cjs/appui-react/UiFramework.js.map +1 -1
  5. package/lib/cjs/appui-react/cursor/cursormenu/CursorMenu.d.ts +1 -1
  6. package/lib/cjs/appui-react/cursor/cursormenu/CursorMenu.d.ts.map +1 -1
  7. package/lib/cjs/appui-react/cursor/cursormenu/CursorMenu.js +4 -3
  8. package/lib/cjs/appui-react/cursor/cursormenu/CursorMenu.js.map +1 -1
  9. package/lib/cjs/appui-react/selection/HideIsolateEmphasizeManager.d.ts.map +1 -1
  10. package/lib/cjs/appui-react/selection/HideIsolateEmphasizeManager.js +3 -0
  11. package/lib/cjs/appui-react/selection/HideIsolateEmphasizeManager.js.map +1 -1
  12. package/lib/cjs/appui-react/selection/SelectionContextItemDef.d.ts.map +1 -1
  13. package/lib/cjs/appui-react/selection/SelectionContextItemDef.js +12 -8
  14. package/lib/cjs/appui-react/selection/SelectionContextItemDef.js.map +1 -1
  15. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.d.ts +6 -4
  16. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.d.ts.map +1 -1
  17. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.js +49 -78
  18. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.js.map +1 -1
  19. package/lib/cjs/appui-react/toolbar/Toolbar.d.ts +10 -0
  20. package/lib/cjs/appui-react/toolbar/Toolbar.d.ts.map +1 -1
  21. package/lib/cjs/appui-react/toolbar/Toolbar.js +3 -2
  22. package/lib/cjs/appui-react/toolbar/Toolbar.js.map +1 -1
  23. package/lib/cjs/appui-react/toolbar/ToolbarComposer.d.ts +2 -1
  24. package/lib/cjs/appui-react/toolbar/ToolbarComposer.d.ts.map +1 -1
  25. package/lib/cjs/appui-react/toolbar/ToolbarComposer.js +45 -129
  26. package/lib/cjs/appui-react/toolbar/ToolbarComposer.js.map +1 -1
  27. package/lib/cjs/appui-react/toolbar/ToolbarItem.d.ts +2 -2
  28. package/lib/cjs/appui-react/toolbar/ToolbarItem.d.ts.map +1 -1
  29. package/lib/cjs/appui-react/toolbar/ToolbarItem.js +2 -2
  30. package/lib/cjs/appui-react/toolbar/ToolbarItem.js.map +1 -1
  31. package/lib/cjs/appui-react/toolbar/ToolbarItemsManager.d.ts +1 -0
  32. package/lib/cjs/appui-react/toolbar/ToolbarItemsManager.d.ts.map +1 -1
  33. package/lib/cjs/appui-react/toolbar/ToolbarItemsManager.js +12 -2
  34. package/lib/cjs/appui-react/toolbar/ToolbarItemsManager.js.map +1 -1
  35. package/lib/cjs/appui-react/toolbar/ToolbarWithOverflow.d.ts +2 -1
  36. package/lib/cjs/appui-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
  37. package/lib/cjs/appui-react/toolbar/ToolbarWithOverflow.js +5 -9
  38. package/lib/cjs/appui-react/toolbar/ToolbarWithOverflow.js.map +1 -1
  39. package/lib/cjs/appui-react/toolbar/useActiveStageProvidedToolbarItems.d.ts +11 -0
  40. package/lib/cjs/appui-react/toolbar/useActiveStageProvidedToolbarItems.d.ts.map +1 -0
  41. package/lib/cjs/appui-react/toolbar/useActiveStageProvidedToolbarItems.js +46 -0
  42. package/lib/cjs/appui-react/toolbar/useActiveStageProvidedToolbarItems.js.map +1 -0
  43. package/lib/cjs/appui-react/toolbar/useActiveToolIdSynchedItems.d.ts +25 -0
  44. package/lib/cjs/appui-react/toolbar/useActiveToolIdSynchedItems.d.ts.map +1 -0
  45. package/lib/cjs/appui-react/toolbar/useActiveToolIdSynchedItems.js +63 -0
  46. package/lib/cjs/appui-react/toolbar/useActiveToolIdSynchedItems.js.map +1 -0
  47. package/lib/cjs/appui-react/toolbar/useDefaultToolbarItems.d.ts +1 -0
  48. package/lib/cjs/appui-react/toolbar/useDefaultToolbarItems.d.ts.map +1 -1
  49. package/lib/cjs/appui-react/toolbar/useDefaultToolbarItems.js +4 -1
  50. package/lib/cjs/appui-react/toolbar/useDefaultToolbarItems.js.map +1 -1
  51. package/lib/cjs/appui-react/toolbar/useUiItemsProviderToolbarItems.d.ts +2 -1
  52. package/lib/cjs/appui-react/toolbar/useUiItemsProviderToolbarItems.d.ts.map +1 -1
  53. package/lib/cjs/appui-react/toolbar/useUiItemsProviderToolbarItems.js +13 -30
  54. package/lib/cjs/appui-react/toolbar/useUiItemsProviderToolbarItems.js.map +1 -1
  55. package/lib/esm/appui-react/UiFramework.d.ts.map +1 -1
  56. package/lib/esm/appui-react/UiFramework.js +11 -10
  57. package/lib/esm/appui-react/UiFramework.js.map +1 -1
  58. package/lib/esm/appui-react/cursor/cursormenu/CursorMenu.d.ts +1 -1
  59. package/lib/esm/appui-react/cursor/cursormenu/CursorMenu.d.ts.map +1 -1
  60. package/lib/esm/appui-react/cursor/cursormenu/CursorMenu.js +4 -3
  61. package/lib/esm/appui-react/cursor/cursormenu/CursorMenu.js.map +1 -1
  62. package/lib/esm/appui-react/selection/HideIsolateEmphasizeManager.d.ts.map +1 -1
  63. package/lib/esm/appui-react/selection/HideIsolateEmphasizeManager.js +3 -0
  64. package/lib/esm/appui-react/selection/HideIsolateEmphasizeManager.js.map +1 -1
  65. package/lib/esm/appui-react/selection/SelectionContextItemDef.d.ts.map +1 -1
  66. package/lib/esm/appui-react/selection/SelectionContextItemDef.js +12 -8
  67. package/lib/esm/appui-react/selection/SelectionContextItemDef.js.map +1 -1
  68. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.d.ts +6 -4
  69. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.d.ts.map +1 -1
  70. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.js +49 -78
  71. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.js.map +1 -1
  72. package/lib/esm/appui-react/toolbar/Toolbar.d.ts +10 -0
  73. package/lib/esm/appui-react/toolbar/Toolbar.d.ts.map +1 -1
  74. package/lib/esm/appui-react/toolbar/Toolbar.js +3 -2
  75. package/lib/esm/appui-react/toolbar/Toolbar.js.map +1 -1
  76. package/lib/esm/appui-react/toolbar/ToolbarComposer.d.ts +2 -1
  77. package/lib/esm/appui-react/toolbar/ToolbarComposer.d.ts.map +1 -1
  78. package/lib/esm/appui-react/toolbar/ToolbarComposer.js +45 -129
  79. package/lib/esm/appui-react/toolbar/ToolbarComposer.js.map +1 -1
  80. package/lib/esm/appui-react/toolbar/ToolbarItem.d.ts +2 -2
  81. package/lib/esm/appui-react/toolbar/ToolbarItem.d.ts.map +1 -1
  82. package/lib/esm/appui-react/toolbar/ToolbarItem.js +2 -2
  83. package/lib/esm/appui-react/toolbar/ToolbarItem.js.map +1 -1
  84. package/lib/esm/appui-react/toolbar/ToolbarItemsManager.d.ts +1 -0
  85. package/lib/esm/appui-react/toolbar/ToolbarItemsManager.d.ts.map +1 -1
  86. package/lib/esm/appui-react/toolbar/ToolbarItemsManager.js +12 -2
  87. package/lib/esm/appui-react/toolbar/ToolbarItemsManager.js.map +1 -1
  88. package/lib/esm/appui-react/toolbar/ToolbarWithOverflow.d.ts +2 -1
  89. package/lib/esm/appui-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
  90. package/lib/esm/appui-react/toolbar/ToolbarWithOverflow.js +5 -9
  91. package/lib/esm/appui-react/toolbar/ToolbarWithOverflow.js.map +1 -1
  92. package/lib/esm/appui-react/toolbar/useActiveStageProvidedToolbarItems.d.ts +11 -0
  93. package/lib/esm/appui-react/toolbar/useActiveStageProvidedToolbarItems.d.ts.map +1 -0
  94. package/lib/esm/appui-react/toolbar/useActiveStageProvidedToolbarItems.js +42 -0
  95. package/lib/esm/appui-react/toolbar/useActiveStageProvidedToolbarItems.js.map +1 -0
  96. package/lib/esm/appui-react/toolbar/useActiveToolIdSynchedItems.d.ts +25 -0
  97. package/lib/esm/appui-react/toolbar/useActiveToolIdSynchedItems.d.ts.map +1 -0
  98. package/lib/esm/appui-react/toolbar/useActiveToolIdSynchedItems.js +59 -0
  99. package/lib/esm/appui-react/toolbar/useActiveToolIdSynchedItems.js.map +1 -0
  100. package/lib/esm/appui-react/toolbar/useDefaultToolbarItems.d.ts +1 -0
  101. package/lib/esm/appui-react/toolbar/useDefaultToolbarItems.d.ts.map +1 -1
  102. package/lib/esm/appui-react/toolbar/useDefaultToolbarItems.js +4 -1
  103. package/lib/esm/appui-react/toolbar/useDefaultToolbarItems.js.map +1 -1
  104. package/lib/esm/appui-react/toolbar/useUiItemsProviderToolbarItems.d.ts +2 -1
  105. package/lib/esm/appui-react/toolbar/useUiItemsProviderToolbarItems.d.ts.map +1 -1
  106. package/lib/esm/appui-react/toolbar/useUiItemsProviderToolbarItems.js +13 -30
  107. package/lib/esm/appui-react/toolbar/useUiItemsProviderToolbarItems.js.map +1 -1
  108. package/package.json +13 -14
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarWithOverflow.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/ToolbarWithOverflow.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,EAAE,mBAAmB,IAAI,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAExF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAwBtD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;IAClC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,CACL,oBAAC,sBAAsB,CAAC,8CAA8C;QACpE,KAAK,EAAE,QAAQ,KACX,KAAK,GACT,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport type { OnItemExecutedFunc } from \"@itwin/appui-abstract\";\nimport type { CommonProps, NoChildrenProps } from \"@itwin/core-react\";\nimport type {\n Direction,\n ToolbarOpacitySetting,\n ToolbarPanelAlignment,\n} from \"@itwin/components-react\";\nimport { ToolbarWithOverflow as CR_ToolbarWithOverflow } from \"@itwin/components-react\";\nimport type { ToolbarItem } from \"./ToolbarItem\";\nimport { toUIAToolbarItem } from \"./toUIAToolbarItem\";\n\n/** Component that displays toolbar items.\n * @beta\n */\nexport interface ToolbarWithOverflowProps extends CommonProps, NoChildrenProps {\n /** Describes to which direction the popup panels are expanded. Defaults to: [[Direction.Bottom]] */\n expandsTo?: Direction;\n /** Describes to which direction the overflow popup panels are expanded. Defaults to: [[Direction.Right]] */\n overflowExpandsTo?: Direction;\n /** Definitions for items of the toolbar. Items are expected to be already sorted by group and item. */\n items: ToolbarItem[];\n /** Describes how expanded panels are aligned. Defaults to: [[ToolbarPanelAlignment.Start]] */\n panelAlignment?: ToolbarPanelAlignment;\n /** Use Drag Interaction to open popups with nest action buttons */\n useDragInteraction?: boolean;\n /** Determines whether to use mouse proximity to alter the opacity of the toolbar */\n toolbarOpacitySetting?: ToolbarOpacitySetting;\n /** Optional function to call on any item execution */\n onItemExecuted?: OnItemExecutedFunc;\n /** Optional function to call on any KeyDown events processed by toolbar */\n onKeyDown?: (e: React.KeyboardEvent) => void;\n}\n\n/** Component that displays toolbar items.\n * @beta\n */\nexport function ToolbarWithOverflow(props: ToolbarWithOverflowProps) {\n const { items, ...other } = props;\n const uiaItems = React.useMemo(() => {\n return items.map((item) => toUIAToolbarItem(item));\n }, [items]);\n return (\n <CR_ToolbarWithOverflow // eslint-disable-line deprecation/deprecation\n items={uiaItems}\n {...other}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"ToolbarWithOverflow.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/ToolbarWithOverflow.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwBpC;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,iBAAiB,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IACrD,OAAO,oBAAC,OAAO,IAAC,cAAc,EAAE,EAAE,iBAAiB,EAAE,KAAM,YAAY,GAAI,CAAC;AAC9E,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 type { OnItemExecutedFunc } from \"@itwin/appui-abstract\";\nimport type { CommonProps, NoChildrenProps } from \"@itwin/core-react\";\nimport type {\n Direction,\n ToolbarOpacitySetting,\n ToolbarPanelAlignment,\n} from \"@itwin/components-react\";\nimport type { ToolbarItem } from \"./ToolbarItem\";\nimport { Toolbar } from \"./Toolbar\";\n\n/** Component that displays toolbar items.\n * @beta\n */\nexport interface ToolbarWithOverflowProps extends CommonProps, NoChildrenProps {\n /** Describes to which direction the popup panels are expanded. Defaults to: [[Direction.Bottom]] */\n expandsTo?: Direction;\n /** Describes to which direction the overflow popup panels are expanded. Defaults to: [[Direction.Right]] */\n overflowExpandsTo?: Direction;\n /** Definitions for items of the toolbar. Items are expected to be already sorted by group and item. */\n items: ToolbarItem[];\n /** Describes how expanded panels are aligned. Defaults to: [[ToolbarPanelAlignment.Start]] */\n panelAlignment?: ToolbarPanelAlignment;\n /** Use Drag Interaction to open popups with nest action buttons */\n useDragInteraction?: boolean;\n /** Determines whether to use mouse proximity to alter the opacity of the toolbar */\n toolbarOpacitySetting?: ToolbarOpacitySetting;\n /** Optional function to call on any item execution */\n onItemExecuted?: OnItemExecutedFunc;\n /** Optional function to call on any KeyDown events processed by toolbar */\n onKeyDown?: (e: React.KeyboardEvent) => void;\n}\n\n/** Component that displays toolbar items, displaying only the elements that can fit in the available space,\n * and put the other items into a single panel.\n * @beta\n */\nexport function ToolbarWithOverflow(props: ToolbarWithOverflowProps) {\n const { overflowExpandsTo, ...toolbarProps } = props;\n return <Toolbar enableOverflow={{ overflowExpandsTo }} {...toolbarProps} />;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /** @packageDocumentation
2
+ * @module Toolbar
3
+ */
4
+ import type { ToolbarItem, ToolbarOrientation, ToolbarUsage } from "./ToolbarItem";
5
+ /**
6
+ * Collects the currently registered items providers toolbar item
7
+ * for the active stage and provided toolbar usage and orientation.
8
+ * @internal
9
+ */
10
+ export declare const useActiveStageProvidedToolbarItems: (toolbarUsage: ToolbarUsage, toolbarOrientation: ToolbarOrientation) => readonly ToolbarItem[];
11
+ //# sourceMappingURL=useActiveStageProvidedToolbarItems.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useActiveStageProvidedToolbarItems.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useActiveStageProvidedToolbarItems.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,YAAY,EACb,MAAM,eAAe,CAAC;AAGvB;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,iBAC/B,YAAY,sBACN,kBAAkB,KACrC,SAAS,WAAW,EA+BtB,CAAC"}
@@ -0,0 +1,42 @@
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 * as React from "react";
9
+ import { useActiveStageId } from "../hooks/useActiveStageId";
10
+ import { useAvailableUiItemsProviders } from "../hooks/useAvailableUiItemsProviders";
11
+ import { UiFramework } from "../UiFramework";
12
+ import { UiItemsManager } from "../ui-items-provider/UiItemsManager";
13
+ /**
14
+ * Collects the currently registered items providers toolbar item
15
+ * for the active stage and provided toolbar usage and orientation.
16
+ * @internal
17
+ */
18
+ export const useActiveStageProvidedToolbarItems = (toolbarUsage, toolbarOrientation) => {
19
+ const uiItemsProviderIds = useAvailableUiItemsProviders();
20
+ const stageId = useActiveStageId();
21
+ const [items, setItems] = React.useState([]);
22
+ const providersRef = React.useRef("");
23
+ const currentStageRef = React.useRef("");
24
+ // gathers items from registered extensions - dependent on when a uiItemsProvider is register or unregistered and if the
25
+ // current stage's composer allows entries from extensions.
26
+ React.useEffect(() => {
27
+ const uiProviders = uiItemsProviderIds.join("-");
28
+ if (providersRef.current !== uiProviders ||
29
+ currentStageRef.current !== stageId) {
30
+ const frontstageDef = UiFramework.frontstages.activeFrontstageDef;
31
+ if (frontstageDef) {
32
+ const usage = frontstageDef.usage;
33
+ currentStageRef.current = stageId;
34
+ providersRef.current = uiProviders;
35
+ const toolbarItems = UiItemsManager.getToolbarButtonItems(stageId, usage, toolbarUsage, toolbarOrientation);
36
+ setItems(toolbarItems);
37
+ }
38
+ }
39
+ }, [uiItemsProviderIds, stageId, toolbarUsage, toolbarOrientation]);
40
+ return items;
41
+ };
42
+ //# sourceMappingURL=useActiveStageProvidedToolbarItems.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useActiveStageProvidedToolbarItems.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useActiveStageProvidedToolbarItems.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAM7C,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE;;;;GAIG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAChD,YAA0B,EAC1B,kBAAsC,EACd,EAAE;IAC1B,MAAM,kBAAkB,GAAG,4BAA4B,EAAE,CAAC;IAC1D,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IACnC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAyB,EAAE,CAAC,CAAC;IACrE,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzC,wHAAwH;IACxH,2DAA2D;IAC3D,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEjD,IACE,YAAY,CAAC,OAAO,KAAK,WAAW;YACpC,eAAe,CAAC,OAAO,KAAK,OAAO,EACnC;YACA,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,CAAC,mBAAmB,CAAC;YAClE,IAAI,aAAa,EAAE;gBACjB,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;gBAClC,eAAe,CAAC,OAAO,GAAG,OAAO,CAAC;gBAClC,YAAY,CAAC,OAAO,GAAG,WAAW,CAAC;gBACnC,MAAM,YAAY,GAAG,cAAc,CAAC,qBAAqB,CACvD,OAAO,EACP,KAAK,EACL,YAAY,EACZ,kBAAkB,CACnB,CAAC;gBACF,QAAQ,CAAC,YAAY,CAAC,CAAC;aACxB;SACF;IACH,CAAC,EAAE,CAAC,kBAAkB,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,CAAC,CAAC,CAAC;IACpE,OAAO,KAAK,CAAC;AACf,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 * as React from \"react\";\nimport { useActiveStageId } from \"../hooks/useActiveStageId\";\nimport { useAvailableUiItemsProviders } from \"../hooks/useAvailableUiItemsProviders\";\nimport { UiFramework } from \"../UiFramework\";\nimport type {\n ToolbarItem,\n ToolbarOrientation,\n ToolbarUsage,\n} from \"./ToolbarItem\";\nimport { UiItemsManager } from \"../ui-items-provider/UiItemsManager\";\n\n/**\n * Collects the currently registered items providers toolbar item\n * for the active stage and provided toolbar usage and orientation.\n * @internal\n */\nexport const useActiveStageProvidedToolbarItems = (\n toolbarUsage: ToolbarUsage,\n toolbarOrientation: ToolbarOrientation\n): readonly ToolbarItem[] => {\n const uiItemsProviderIds = useAvailableUiItemsProviders();\n const stageId = useActiveStageId();\n const [items, setItems] = React.useState<readonly ToolbarItem[]>([]);\n const providersRef = React.useRef(\"\");\n const currentStageRef = React.useRef(\"\");\n // gathers items from registered extensions - dependent on when a uiItemsProvider is register or unregistered and if the\n // current stage's composer allows entries from extensions.\n React.useEffect(() => {\n const uiProviders = uiItemsProviderIds.join(\"-\");\n\n if (\n providersRef.current !== uiProviders ||\n currentStageRef.current !== stageId\n ) {\n const frontstageDef = UiFramework.frontstages.activeFrontstageDef;\n if (frontstageDef) {\n const usage = frontstageDef.usage;\n currentStageRef.current = stageId;\n providersRef.current = uiProviders;\n const toolbarItems = UiItemsManager.getToolbarButtonItems(\n stageId,\n usage,\n toolbarUsage,\n toolbarOrientation\n );\n setItems(toolbarItems);\n }\n }\n }, [uiItemsProviderIds, stageId, toolbarUsage, toolbarOrientation]);\n return items;\n};\n"]}
@@ -0,0 +1,25 @@
1
+ import type { BeEvent } from "@itwin/core-bentley";
2
+ type ActiveToolIdSynchedItem<T> = {
3
+ id: string;
4
+ isActive?: boolean;
5
+ } | {
6
+ id: string;
7
+ items: T[];
8
+ };
9
+ interface ActiveToolIdSynchedHost {
10
+ activeToolId: string;
11
+ onToolActivatedEvent: BeEvent<(args: {
12
+ toolId: string;
13
+ }) => void>;
14
+ }
15
+ /**
16
+ * Synch the provided items to only show the item with id === activeToolId to be
17
+ * active, as determined by the UiFramework.frontstages.activeToolId.
18
+ * @param itemsToSynch List of items to keep in synch.
19
+ * @param syncHost Source of information to synch to (UiFramework.frontstages)
20
+ * @returns Up to date itemsToSynch.
21
+ * @internal
22
+ */
23
+ export declare function useActiveToolIdSynchedItems<T extends ActiveToolIdSynchedItem<T>>(itemsToSynch: readonly T[], syncHost: ActiveToolIdSynchedHost): T[];
24
+ export {};
25
+ //# sourceMappingURL=useActiveToolIdSynchedItems.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useActiveToolIdSynchedItems.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useActiveToolIdSynchedItems.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,KAAK,uBAAuB,CAAC,CAAC,IAC1B;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAClC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,EAAE,CAAA;CAAE,CAAC;AAE/B,UAAU,uBAAuB;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC,CAAC;CACnE;AAiDD;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,CAAC,SAAS,uBAAuB,CAAC,CAAC,CAAC,EACpC,YAAY,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,uBAAuB,GAAG,CAAC,EAAE,CAWpE"}
@@ -0,0 +1,59 @@
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
+ import * as React from "react";
6
+ /**
7
+ * Recursively checks if the item with the current id of "toolId" is
8
+ * the only active tool.
9
+ * @param items list of items to validate
10
+ * @param toolId toolId to check
11
+ * @returns true if any item "isActive" must change.
12
+ */
13
+ function mustRefresh(items, toolId) {
14
+ return items.some((item) => {
15
+ if ("items" in item) {
16
+ return mustRefresh(item.items, toolId);
17
+ }
18
+ return ((item.isActive && item.id !== toolId) ||
19
+ (!item.isActive && item.id === toolId));
20
+ });
21
+ }
22
+ /**
23
+ * Recursively updates the isActive for the tools and only activate
24
+ * the one with the id equal to toolId.
25
+ * @param items list of items to update
26
+ * @param toolId toolId to check
27
+ * @returns updated list of items
28
+ */
29
+ function refreshItems(items, toolId) {
30
+ return items.map((item) => "items" in item
31
+ ? {
32
+ ...item,
33
+ isActive: item.id === toolId,
34
+ items: refreshItems(item.items, toolId),
35
+ }
36
+ : {
37
+ ...item,
38
+ isActive: item.id === toolId,
39
+ });
40
+ }
41
+ /**
42
+ * Synch the provided items to only show the item with id === activeToolId to be
43
+ * active, as determined by the UiFramework.frontstages.activeToolId.
44
+ * @param itemsToSynch List of items to keep in synch.
45
+ * @param syncHost Source of information to synch to (UiFramework.frontstages)
46
+ * @returns Up to date itemsToSynch.
47
+ * @internal
48
+ */
49
+ export function useActiveToolIdSynchedItems(itemsToSynch, syncHost) {
50
+ const [items, setItems] = React.useState([]);
51
+ React.useEffect(() => {
52
+ setItems(refreshItems(itemsToSynch, syncHost.activeToolId));
53
+ return syncHost.onToolActivatedEvent.addListener(({ toolId }) => {
54
+ setItems((current) => mustRefresh(current, toolId) ? refreshItems(current, toolId) : current);
55
+ });
56
+ }, [itemsToSynch, syncHost.activeToolId, syncHost.onToolActivatedEvent]);
57
+ return items;
58
+ }
59
+ //# sourceMappingURL=useActiveToolIdSynchedItems.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useActiveToolIdSynchedItems.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useActiveToolIdSynchedItems.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B;;;;;;GAMG;AACH,SAAS,WAAW,CAClB,KAAmB,EACnB,MAAc;IAEd,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;SACxC;QACD,OAAO,CACL,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC;YACrC,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,CACvC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,SAAS,YAAY,CACnB,KAAmB,EACnB,MAAc;IAEd,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACxB,OAAO,IAAI,IAAI;QACb,CAAC,CAAC;YACE,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI,CAAC,EAAE,KAAK,MAAM;YAC5B,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC;SACxC;QACH,CAAC,CAAC;YACE,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI,CAAC,EAAE,KAAK,MAAM;SAC7B,CACN,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CAEzC,YAA0B,EAAE,QAAiC;IAC7D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAM,EAAE,CAAC,CAAC;IAClD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,YAAY,CAAC,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;QAC5D,OAAO,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YAC9D,QAAQ,CAAC,CAAC,OAAO,EAAE,EAAE,CACnB,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CACvE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC;IACzE,OAAO,KAAK,CAAC;AACf,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 *--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { BeEvent } from \"@itwin/core-bentley\";\n\ntype ActiveToolIdSynchedItem<T> =\n | { id: string; isActive?: boolean }\n | { id: string; items: T[] };\n\ninterface ActiveToolIdSynchedHost {\n activeToolId: string;\n onToolActivatedEvent: BeEvent<(args: { toolId: string }) => void>;\n}\n\n/**\n * Recursively checks if the item with the current id of \"toolId\" is\n * the only active tool.\n * @param items list of items to validate\n * @param toolId toolId to check\n * @returns true if any item \"isActive\" must change.\n */\nfunction mustRefresh<T extends ActiveToolIdSynchedItem<T>>(\n items: readonly T[],\n toolId: string\n): boolean {\n return items.some((item) => {\n if (\"items\" in item) {\n return mustRefresh(item.items, toolId);\n }\n return (\n (item.isActive && item.id !== toolId) ||\n (!item.isActive && item.id === toolId)\n );\n });\n}\n\n/**\n * Recursively updates the isActive for the tools and only activate\n * the one with the id equal to toolId.\n * @param items list of items to update\n * @param toolId toolId to check\n * @returns updated list of items\n */\nfunction refreshItems<T extends ActiveToolIdSynchedItem<T>>(\n items: readonly T[],\n toolId: string\n): T[] {\n return items.map((item) =>\n \"items\" in item\n ? {\n ...item,\n isActive: item.id === toolId,\n items: refreshItems(item.items, toolId),\n }\n : {\n ...item,\n isActive: item.id === toolId,\n }\n );\n}\n\n/**\n * Synch the provided items to only show the item with id === activeToolId to be\n * active, as determined by the UiFramework.frontstages.activeToolId.\n * @param itemsToSynch List of items to keep in synch.\n * @param syncHost Source of information to synch to (UiFramework.frontstages)\n * @returns Up to date itemsToSynch.\n * @internal\n */\nexport function useActiveToolIdSynchedItems<\n T extends ActiveToolIdSynchedItem<T>\n>(itemsToSynch: readonly T[], syncHost: ActiveToolIdSynchedHost): T[] {\n const [items, setItems] = React.useState<T[]>([]);\n React.useEffect(() => {\n setItems(refreshItems(itemsToSynch, syncHost.activeToolId));\n return syncHost.onToolActivatedEvent.addListener(({ toolId }) => {\n setItems((current) =>\n mustRefresh(current, toolId) ? refreshItems(current, toolId) : current\n );\n });\n }, [itemsToSynch, syncHost.activeToolId, syncHost.onToolActivatedEvent]);\n return items;\n}\n"]}
@@ -5,6 +5,7 @@ import type { ToolbarItem } from "./ToolbarItem";
5
5
  import type { ToolbarItemsManager } from "./ToolbarItemsManager";
6
6
  /** Hook that returns items from [[ToolbarItemsManager]].
7
7
  * @public
8
+ * @deprecated in 4.4.0. Use [[Toolbar]] component instead of this hooks, ToolbarItemsManager is internal and should not be used here.
8
9
  */
9
10
  export declare const useDefaultToolbarItems: (manager: ToolbarItemsManager) => readonly ToolbarItem[];
10
11
  //# sourceMappingURL=useDefaultToolbarItems.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDefaultToolbarItems.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useDefaultToolbarItems.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,sBAAsB,YACxB,mBAAmB,KAC3B,SAAS,WAAW,EAetB,CAAC"}
1
+ {"version":3,"file":"useDefaultToolbarItems.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useDefaultToolbarItems.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,sBAAsB,YAExB,mBAAmB,KAC3B,SAAS,WAAW,EAetB,CAAC"}
@@ -8,8 +8,11 @@
8
8
  import * as React from "react";
9
9
  /** Hook that returns items from [[ToolbarItemsManager]].
10
10
  * @public
11
+ * @deprecated in 4.4.0. Use [[Toolbar]] component instead of this hooks, ToolbarItemsManager is internal and should not be used here.
11
12
  */
12
- export const useDefaultToolbarItems = (manager) => {
13
+ export const useDefaultToolbarItems = (
14
+ // eslint-disable-next-line deprecation/deprecation
15
+ manager) => {
13
16
  const [items, setItems] = React.useState(() => manager.items);
14
17
  const isInitialMount = React.useRef(true);
15
18
  React.useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"useDefaultToolbarItems.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useDefaultToolbarItems.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAA4B,EACJ,EAAE;IAC1B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,cAAc,CAAC,OAAO;YAAE,cAAc,CAAC,OAAO,GAAG,KAAK,CAAC;aACtD;YACH,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SACzB;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7B,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YACjD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACd,OAAO,KAAK,CAAC;AACf,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 * as React from \"react\";\nimport type { ToolbarItem } from \"./ToolbarItem\";\nimport type { ToolbarItemsManager } from \"./ToolbarItemsManager\";\n\n/** Hook that returns items from [[ToolbarItemsManager]].\n * @public\n */\nexport const useDefaultToolbarItems = (\n manager: ToolbarItemsManager\n): readonly ToolbarItem[] => {\n const [items, setItems] = React.useState(() => manager.items);\n const isInitialMount = React.useRef(true);\n React.useEffect(() => {\n if (isInitialMount.current) isInitialMount.current = false;\n else {\n setItems(manager.items);\n }\n }, [manager, manager.items]);\n React.useEffect(() => {\n return manager.onItemsChanged.addListener((args) => {\n setItems(args.items);\n });\n }, [manager]);\n return items;\n};\n"]}
1
+ {"version":3,"file":"useDefaultToolbarItems.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useDefaultToolbarItems.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;AACpC,mDAAmD;AACnD,OAA4B,EACJ,EAAE;IAC1B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,cAAc,CAAC,OAAO;YAAE,cAAc,CAAC,OAAO,GAAG,KAAK,CAAC;aACtD;YACH,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SACzB;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7B,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YACjD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACd,OAAO,KAAK,CAAC;AACf,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 * as React from \"react\";\nimport type { ToolbarItem } from \"./ToolbarItem\";\nimport type { ToolbarItemsManager } from \"./ToolbarItemsManager\";\n\n/** Hook that returns items from [[ToolbarItemsManager]].\n * @public\n * @deprecated in 4.4.0. Use [[Toolbar]] component instead of this hooks, ToolbarItemsManager is internal and should not be used here.\n */\nexport const useDefaultToolbarItems = (\n // eslint-disable-next-line deprecation/deprecation\n manager: ToolbarItemsManager\n): readonly ToolbarItem[] => {\n const [items, setItems] = React.useState(() => manager.items);\n const isInitialMount = React.useRef(true);\n React.useEffect(() => {\n if (isInitialMount.current) isInitialMount.current = false;\n else {\n setItems(manager.items);\n }\n }, [manager, manager.items]);\n React.useEffect(() => {\n return manager.onItemsChanged.addListener((args) => {\n setItems(args.items);\n });\n }, [manager]);\n return items;\n};\n"]}
@@ -3,8 +3,9 @@
3
3
  */
4
4
  import type { ToolbarItem, ToolbarOrientation, ToolbarUsage } from "./ToolbarItem";
5
5
  import type { ToolbarItemsManager } from "./ToolbarItemsManager";
6
- /** Hook that returns items from [[ToolbarItemsManager]].
6
+ /** Hook that retrieves active frontstage toolbar items from UiItemsProviders and manage them through [[ToolbarItemsManager]].
7
7
  * @public
8
+ * @deprecated in 4.4.0. This uses ToolbarItemsManager which is internal, directly use [[ToolbarComposer]] instead.
8
9
  */
9
10
  export declare const useUiItemsProviderToolbarItems: (manager: ToolbarItemsManager, toolbarUsage: ToolbarUsage, toolbarOrientation: ToolbarOrientation) => readonly ToolbarItem[];
10
11
  //# sourceMappingURL=useUiItemsProviderToolbarItems.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useUiItemsProviderToolbarItems.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useUiItemsProviderToolbarItems.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,8BAA8B,YAChC,mBAAmB,gBACd,YAAY,sBACN,kBAAkB,KACrC,SAAS,WAAW,EAqCtB,CAAC"}
1
+ {"version":3,"file":"useUiItemsProviderToolbarItems.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useUiItemsProviderToolbarItems.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGjE;;;GAGG;AACH,eAAO,MAAM,8BAA8B,YAEhC,mBAAmB,gBACd,YAAY,sBACN,kBAAkB,KACrC,SAAS,WAAW,EAetB,CAAC"}
@@ -6,41 +6,24 @@
6
6
  * @module Toolbar
7
7
  */
8
8
  import * as React from "react";
9
- import { useActiveStageId } from "../hooks/useActiveStageId";
10
- import { useAvailableUiItemsProviders } from "../hooks/useAvailableUiItemsProviders";
11
- import { UiFramework } from "../UiFramework";
12
- import { UiItemsManager } from "../ui-items-provider/UiItemsManager";
13
- /** Hook that returns items from [[ToolbarItemsManager]].
9
+ import { useActiveStageProvidedToolbarItems } from "./useActiveStageProvidedToolbarItems";
10
+ /** Hook that retrieves active frontstage toolbar items from UiItemsProviders and manage them through [[ToolbarItemsManager]].
14
11
  * @public
12
+ * @deprecated in 4.4.0. This uses ToolbarItemsManager which is internal, directly use [[ToolbarComposer]] instead.
15
13
  */
16
- export const useUiItemsProviderToolbarItems = (manager, toolbarUsage, toolbarOrientation) => {
17
- const uiItemsProviderIds = useAvailableUiItemsProviders();
18
- const stageId = useActiveStageId();
19
- const [items, setItems] = React.useState(manager.items);
20
- const providersRef = React.useRef("");
21
- const currentStageRef = React.useRef("");
22
- // gathers items from registered extensions - dependent on when a uiItemsProvider is register or unregistered and if the
23
- // current stage's composer allows entries from extensions.
14
+ export const useUiItemsProviderToolbarItems = (
15
+ // eslint-disable-next-line deprecation/deprecation
16
+ manager, toolbarUsage, toolbarOrientation) => {
17
+ const providedItems = useActiveStageProvidedToolbarItems(toolbarUsage, toolbarOrientation);
18
+ const [items, setItems] = React.useState(providedItems);
24
19
  React.useEffect(() => {
25
- const uiProviders = uiItemsProviderIds.join("-");
26
- // istanbul ignore else
27
- if (providersRef.current !== uiProviders ||
28
- currentStageRef.current !== stageId) {
29
- const frontstageDef = UiFramework.frontstages.activeFrontstageDef;
30
- // istanbul ignore else
31
- if (frontstageDef) {
32
- const usage = frontstageDef.usage;
33
- currentStageRef.current = stageId;
34
- providersRef.current = uiProviders;
35
- const toolbarItems = UiItemsManager.getToolbarButtonItems(stageId, usage, toolbarUsage, toolbarOrientation);
36
- manager.loadItems(toolbarItems);
37
- setItems(manager.items);
38
- }
39
- }
40
- return manager.onItemsChanged.addListener((args) => {
20
+ var _a;
21
+ manager === null || manager === void 0 ? void 0 : manager.loadItems(providedItems);
22
+ setItems((_a = manager === null || manager === void 0 ? void 0 : manager.items) !== null && _a !== void 0 ? _a : providedItems);
23
+ return manager === null || manager === void 0 ? void 0 : manager.onItemsChanged.addListener((args) => {
41
24
  setItems(args.items);
42
25
  });
43
- }, [uiItemsProviderIds, stageId, manager, toolbarUsage, toolbarOrientation]);
26
+ }, [manager, providedItems]);
44
27
  return items;
45
28
  };
46
29
  //# sourceMappingURL=useUiItemsProviderToolbarItems.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useUiItemsProviderToolbarItems.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useUiItemsProviderToolbarItems.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAM7C,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAGrE;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,OAA4B,EAC5B,YAA0B,EAC1B,kBAAsC,EACd,EAAE;IAC1B,MAAM,kBAAkB,GAAG,4BAA4B,EAAE,CAAC;IAC1D,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IACnC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACxD,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzC,wHAAwH;IACxH,2DAA2D;IAC3D,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEjD,uBAAuB;QACvB,IACE,YAAY,CAAC,OAAO,KAAK,WAAW;YACpC,eAAe,CAAC,OAAO,KAAK,OAAO,EACnC;YACA,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,CAAC,mBAAmB,CAAC;YAClE,uBAAuB;YACvB,IAAI,aAAa,EAAE;gBACjB,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;gBAClC,eAAe,CAAC,OAAO,GAAG,OAAO,CAAC;gBAClC,YAAY,CAAC,OAAO,GAAG,WAAW,CAAC;gBACnC,MAAM,YAAY,GAAG,cAAc,CAAC,qBAAqB,CACvD,OAAO,EACP,KAAK,EACL,YAAY,EACZ,kBAAkB,CACnB,CAAC;gBACF,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBAChC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aACzB;SACF;QACD,OAAO,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YACjD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAC7E,OAAO,KAAK,CAAC;AACf,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 * as React from \"react\";\nimport { useActiveStageId } from \"../hooks/useActiveStageId\";\nimport { useAvailableUiItemsProviders } from \"../hooks/useAvailableUiItemsProviders\";\nimport { UiFramework } from \"../UiFramework\";\nimport type {\n ToolbarItem,\n ToolbarOrientation,\n ToolbarUsage,\n} from \"./ToolbarItem\";\nimport { UiItemsManager } from \"../ui-items-provider/UiItemsManager\";\nimport type { ToolbarItemsManager } from \"./ToolbarItemsManager\";\n\n/** Hook that returns items from [[ToolbarItemsManager]].\n * @public\n */\nexport const useUiItemsProviderToolbarItems = (\n manager: ToolbarItemsManager,\n toolbarUsage: ToolbarUsage,\n toolbarOrientation: ToolbarOrientation\n): readonly ToolbarItem[] => {\n const uiItemsProviderIds = useAvailableUiItemsProviders();\n const stageId = useActiveStageId();\n const [items, setItems] = React.useState(manager.items);\n const providersRef = React.useRef(\"\");\n const currentStageRef = React.useRef(\"\");\n // gathers items from registered extensions - dependent on when a uiItemsProvider is register or unregistered and if the\n // current stage's composer allows entries from extensions.\n React.useEffect(() => {\n const uiProviders = uiItemsProviderIds.join(\"-\");\n\n // istanbul ignore else\n if (\n providersRef.current !== uiProviders ||\n currentStageRef.current !== stageId\n ) {\n const frontstageDef = UiFramework.frontstages.activeFrontstageDef;\n // istanbul ignore else\n if (frontstageDef) {\n const usage = frontstageDef.usage;\n currentStageRef.current = stageId;\n providersRef.current = uiProviders;\n const toolbarItems = UiItemsManager.getToolbarButtonItems(\n stageId,\n usage,\n toolbarUsage,\n toolbarOrientation\n );\n manager.loadItems(toolbarItems);\n setItems(manager.items);\n }\n }\n return manager.onItemsChanged.addListener((args) => {\n setItems(args.items);\n });\n }, [uiItemsProviderIds, stageId, manager, toolbarUsage, toolbarOrientation]);\n return items;\n};\n"]}
1
+ {"version":3,"file":"useUiItemsProviderToolbarItems.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/useUiItemsProviderToolbarItems.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAE1F;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;AAC5C,mDAAmD;AACnD,OAA4B,EAC5B,YAA0B,EAC1B,kBAAsC,EACd,EAAE;IAC1B,MAAM,aAAa,GAAG,kCAAkC,CACtD,YAAY,EACZ,kBAAkB,CACnB,CAAC;IACF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACxD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;;QACnB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,aAAa,CAAC,CAAC;QAClC,QAAQ,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,mCAAI,aAAa,CAAC,CAAC;QAE1C,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YAClD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC;AACf,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 * as React from \"react\";\nimport type {\n ToolbarItem,\n ToolbarOrientation,\n ToolbarUsage,\n} from \"./ToolbarItem\";\nimport type { ToolbarItemsManager } from \"./ToolbarItemsManager\";\nimport { useActiveStageProvidedToolbarItems } from \"./useActiveStageProvidedToolbarItems\";\n\n/** Hook that retrieves active frontstage toolbar items from UiItemsProviders and manage them through [[ToolbarItemsManager]].\n * @public\n * @deprecated in 4.4.0. This uses ToolbarItemsManager which is internal, directly use [[ToolbarComposer]] instead.\n */\nexport const useUiItemsProviderToolbarItems = (\n // eslint-disable-next-line deprecation/deprecation\n manager: ToolbarItemsManager,\n toolbarUsage: ToolbarUsage,\n toolbarOrientation: ToolbarOrientation\n): readonly ToolbarItem[] => {\n const providedItems = useActiveStageProvidedToolbarItems(\n toolbarUsage,\n toolbarOrientation\n );\n const [items, setItems] = React.useState(providedItems);\n React.useEffect(() => {\n manager?.loadItems(providedItems);\n setItems(manager?.items ?? providedItems);\n\n return manager?.onItemsChanged.addListener((args) => {\n setItems(args.items);\n });\n }, [manager, providedItems]);\n return items;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/appui-react",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "description": "UI framework",
5
5
  "main": "lib/cjs/appui-react.js",
6
6
  "module": "lib/esm/appui-react.js",
@@ -23,16 +23,16 @@
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@itwin/appui-abstract": "^3.7.0 || ^4.0.0",
26
- "@itwin/appui-layout-react": "^4.3.0",
27
- "@itwin/components-react": "^4.3.0",
26
+ "@itwin/appui-layout-react": "^4.4.0",
27
+ "@itwin/components-react": "^4.4.0",
28
28
  "@itwin/core-bentley": "^3.7.0 || ^4.0.0",
29
29
  "@itwin/core-common": "^3.7.0 || ^4.0.0",
30
30
  "@itwin/core-frontend": "^3.7.0 || ^4.0.0",
31
31
  "@itwin/core-geometry": "^3.7.0 || ^4.0.0",
32
32
  "@itwin/core-quantity": "^3.7.0 || ^4.0.0",
33
- "@itwin/core-react": "^4.3.0",
33
+ "@itwin/core-react": "^4.4.0",
34
34
  "@itwin/core-telemetry": "^3.7.0 || ^4.0.0",
35
- "@itwin/imodel-components-react": "^4.3.0",
35
+ "@itwin/imodel-components-react": "^4.4.0",
36
36
  "react": "^17.0.0 || ^18.0.0",
37
37
  "react-dom": "^17.0.0 || ^18.0.0",
38
38
  "react-redux": "^7.2.2",
@@ -44,20 +44,20 @@
44
44
  ],
45
45
  "devDependencies": {
46
46
  "@itwin/appui-abstract": "^3.7.0",
47
- "@itwin/appui-layout-react": "4.3.0",
47
+ "@itwin/appui-layout-react": "4.4.0",
48
48
  "@itwin/build-tools": "^3.7.0",
49
- "@itwin/components-react": "4.3.0",
49
+ "@itwin/components-react": "4.4.0",
50
50
  "@itwin/core-bentley": "^3.7.0",
51
51
  "@itwin/core-common": "^3.7.0",
52
52
  "@itwin/core-frontend": "^3.7.0",
53
53
  "@itwin/core-geometry": "^3.7.0",
54
54
  "@itwin/core-orbitgt": "^3.7.0",
55
55
  "@itwin/core-quantity": "^3.7.0",
56
- "@itwin/core-react": "4.3.0",
56
+ "@itwin/core-react": "4.4.0",
57
57
  "@itwin/core-telemetry": "^3.7.0",
58
58
  "@itwin/ecschema-metadata": "^3.7.0",
59
- "@itwin/eslint-plugin": "^3.7.0",
60
- "@itwin/imodel-components-react": "4.3.0",
59
+ "@itwin/eslint-plugin": "^4.0.0-dev.45",
60
+ "@itwin/imodel-components-react": "4.4.0",
61
61
  "@itwin/webgl-compatibility": "^3.7.0",
62
62
  "@testing-library/dom": "^8.11.2",
63
63
  "@testing-library/react": "^12.0.0",
@@ -80,7 +80,7 @@
80
80
  "chai-as-promised": "^7",
81
81
  "chai-jest-snapshot": "^2.0.0",
82
82
  "cpx2": "^3.0.0",
83
- "eslint": "^7.11.0",
83
+ "eslint": "^8.44.0",
84
84
  "faker": "^4.1.0",
85
85
  "ignore-styles": "^5.0.1",
86
86
  "jsdom": "^19.0.0",
@@ -100,8 +100,7 @@
100
100
  "ts-node": "^10.8.2",
101
101
  "typemoq": "^2.1.0",
102
102
  "typescript": "~5.0.2",
103
- "eslint-config-prettier": "~8.8.0",
104
- "@rushstack/eslint-patch": "^1.3.0"
103
+ "eslint-config-prettier": "~8.8.0"
105
104
  },
106
105
  "//dependencies": [
107
106
  "NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API",
@@ -109,7 +108,7 @@
109
108
  ],
110
109
  "dependencies": {
111
110
  "@bentley/icons-generic": "^1.0.34",
112
- "@itwin/itwinui-react": "^2.11.6",
111
+ "@itwin/itwinui-react": "^2.11.11",
113
112
  "@itwin/itwinui-variables": "^2.0.0",
114
113
  "@itwin/itwinui-icons-react": "^2.1.0",
115
114
  "@itwin/itwinui-icons": "^1.14.0",