@itwin/presentation-hierarchies-react 2.0.0-alpha.6 → 2.0.0-alpha.61

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 (163) hide show
  1. package/CHANGELOG.md +1151 -11
  2. package/README.md +93 -160
  3. package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts +49 -0
  4. package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts.map +1 -0
  5. package/lib/presentation-hierarchies-react/FlatTreeNode.js +96 -0
  6. package/lib/presentation-hierarchies-react/FlatTreeNode.js.map +1 -0
  7. package/lib/presentation-hierarchies-react/LocalizationContext.d.ts +24 -0
  8. package/lib/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -0
  9. package/lib/presentation-hierarchies-react/LocalizationContext.js +40 -0
  10. package/lib/presentation-hierarchies-react/LocalizationContext.js.map +1 -0
  11. package/lib/presentation-hierarchies-react/Renderers.d.ts +92 -0
  12. package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
  13. package/lib/presentation-hierarchies-react/TreeNode.d.ts +80 -0
  14. package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
  15. package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +28 -15
  16. package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
  17. package/lib/presentation-hierarchies-react/UseIModelTree.js +183 -0
  18. package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
  19. package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts +30 -0
  20. package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
  21. package/lib/presentation-hierarchies-react/UseNodeHighlighting.js +57 -0
  22. package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
  23. package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +23 -0
  24. package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
  25. package/lib/presentation-hierarchies-react/UseSelectionHandler.js +124 -0
  26. package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
  27. package/lib/presentation-hierarchies-react/UseTree.d.ts +112 -0
  28. package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
  29. package/lib/presentation-hierarchies-react/UseTree.js +298 -0
  30. package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
  31. package/lib/presentation-hierarchies-react/Utils.js +56 -0
  32. package/lib/presentation-hierarchies-react/Utils.js.map +1 -0
  33. package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js +10 -0
  34. package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -0
  35. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts +9 -0
  36. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts.map +1 -0
  37. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js +12 -0
  38. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js.map +1 -0
  39. package/lib/presentation-hierarchies-react/internal/TreeActions.js +294 -0
  40. package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -0
  41. package/lib/presentation-hierarchies-react/internal/TreeLoader.js +98 -0
  42. package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
  43. package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +1 -0
  44. package/lib/presentation-hierarchies-react/internal/TreeModel.js +115 -0
  45. package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
  46. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +35 -0
  47. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
  48. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +141 -0
  49. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
  50. package/lib/presentation-hierarchies-react/internal/Utils.js +42 -0
  51. package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
  52. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +40 -0
  53. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
  54. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +387 -0
  55. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
  56. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +21 -0
  57. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
  58. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +185 -0
  59. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
  60. package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts +49 -0
  61. package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
  62. package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +88 -0
  63. package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
  64. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +38 -0
  65. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
  66. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +77 -0
  67. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
  68. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +29 -0
  69. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
  70. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +91 -0
  71. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
  72. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +31 -0
  73. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
  74. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +155 -0
  75. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
  76. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.css +25 -0
  77. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +14 -0
  78. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
  79. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +540 -0
  80. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
  81. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +75 -0
  82. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
  83. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +417 -0
  84. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
  85. package/lib/presentation-hierarchies-react-extract.d.ts +17 -0
  86. package/lib/presentation-hierarchies-react-extract.js +16 -0
  87. package/lib/presentation-hierarchies-react-stratakit.d.ts +8 -0
  88. package/lib/presentation-hierarchies-react-stratakit.js +8 -0
  89. package/lib/presentation-hierarchies-react.d.ts +11 -0
  90. package/lib/presentation-hierarchies-react.js +8 -0
  91. package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
  92. package/package.json +78 -56
  93. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +0 -75
  94. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
  95. package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -12
  96. package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
  97. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +0 -15
  98. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +0 -1
  99. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +0 -22
  100. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +0 -1
  101. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
  102. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +0 -62
  103. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
  104. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -46
  105. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
  106. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +0 -98
  107. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
  108. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +0 -132
  109. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
  110. package/lib/esm/presentation-hierarchies-react/UseTree.js +0 -242
  111. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +0 -1
  112. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
  113. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
  114. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +0 -11
  115. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
  116. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
  117. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
  118. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +0 -307
  119. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
  120. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -44
  121. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
  122. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +0 -94
  123. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
  124. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -70
  125. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
  126. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +0 -153
  127. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
  128. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -28
  129. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
  130. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +0 -128
  131. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
  132. package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
  133. package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
  134. package/lib/esm/presentation-hierarchies-react/internal/Utils.js +0 -58
  135. package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
  136. package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts +0 -21
  137. package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts.map +0 -1
  138. package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js +0 -30
  139. package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js.map +0 -1
  140. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts +0 -73
  141. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts.map +0 -1
  142. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js +0 -34
  143. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +0 -1
  144. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts +0 -25
  145. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts.map +0 -1
  146. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js +0 -40
  147. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js.map +0 -1
  148. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts +0 -23
  149. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts.map +0 -1
  150. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js +0 -72
  151. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js.map +0 -1
  152. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +0 -40
  153. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +0 -1
  154. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +0 -80
  155. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +0 -1
  156. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +0 -30
  157. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +0 -1
  158. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +0 -48
  159. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +0 -1
  160. package/lib/esm/presentation-hierarchies-react.d.ts +0 -13
  161. package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
  162. package/lib/esm/presentation-hierarchies-react.js +0 -16
  163. package/lib/esm/presentation-hierarchies-react.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA2D1F,MAAM,uBAAuB,GAAqB;IAChD,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,cAAc;IACpC,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,qCAAqC;IACzD,mBAAmB,EAAE,uDAAuD;IAC5E,gCAAgC,EAAE,0GAA0G;IAC5I,sBAAsB,EAAE,oEAAoE;IAC5F,mCAAmC,EAAE,wEAAwE;IAC7G,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,mBAAmB,GAAG,aAAa,CAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAW9G;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAuD;IAC7H,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE9G,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAgC,CAAC;AAC/F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB;IACpC,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;AACzC,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\nimport { createContext, PropsWithChildren, useContext, useEffect, useState } from \"react\";\n\n/**\n * Localized strings used in the components.\n * @public\n */\nexport interface LocalizedStrings {\n /**\n * Message displayed when nodes are loading.\n * Default value: `Loading...`.\n */\n loading: string;\n /**\n * Title for apply hierarchy filter button.\n * Default value: `Apply filter`.\n */\n filterHierarchyLevel: string;\n /**\n * Title for clear hierarchy filter button.\n * Default value: `Clear active filter`.\n */\n clearHierarchyLevelFilter: string;\n /**\n * Message displayed when no nodes matching filter are found.\n * Default value: `No child nodes match current filter`.\n */\n noFilteredChildren: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `There are more items than allowed limit of {{limit}}.`.\n */\n resultLimitExceeded: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit and hierarchy filtering is enabled.\n * Default value: `Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.`.\n */\n resultLimitExceededWithFiltering: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `<link>Increase the hierarchy level size limit to {{limit}}.</link>`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Or, <link>increase the hierarchy level size limit to {{limit}}.</link>`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No child nodes match current filter\",\n resultLimitExceeded: \"There are more items than allowed limit of {{limit}}.\",\n resultLimitExceededWithFiltering: \"Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.\",\n increaseHierarchyLimit: \"<link>Increase the hierarchy level size limit to {{limit}}.</link>\",\n increaseHierarchyLimitWithFiltering: \"Or, <link>increase the hierarchy level size limit to {{limit}}.</link>\",\n retry: \"Retry\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>) {\n const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n\n useEffect(() => {\n setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n }, [localizedStrings]);\n\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"]}
@@ -1,25 +0,0 @@
1
- import { PresentationHierarchyNode } from "../TreeNode.js";
2
- import { HierarchyLevelDetails, useTree } from "../UseTree.js";
3
- /** @alpha */
4
- export interface TreeItemAction {
5
- label: string;
6
- action: () => void;
7
- /**
8
- * Determines action items visibility:
9
- * - `False` - action item is hidden.
10
- * - `True` - action item is visible at all times.
11
- * - `Undefined` - action item is visible on hover/focus.
12
- */
13
- show?: boolean;
14
- icon?: string;
15
- }
16
- /** @alpha */
17
- export type FilterActionProps = {
18
- /** Action to perform when the filter button is clicked for this node. */
19
- onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
20
- } & Partial<Pick<ReturnType<typeof useTree>, "getHierarchyLevelDetails">>;
21
- /** @internal */
22
- export declare function TreeActionButton({ show, label, action, icon }: TreeItemAction): import("react/jsx-runtime").JSX.Element;
23
- /** @alpha */
24
- export declare function createFilterAction({ onFilter, getHierarchyLevelDetails }: FilterActionProps): (node: PresentationHierarchyNode) => TreeItemAction;
25
- //# sourceMappingURL=TreeActionButton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeActionButton.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeActionButton.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAM/D,aAAa;AACb,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,aAAa;AACb,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACnE,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC;AAE1E,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,cAAc,2CAI7E;AAED,aAAa;AACb,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,wBAAwB,EAAE,EAAE,iBAAiB,GAAG,CAAC,IAAI,EAAE,yBAAyB,KAAK,cAAc,CAuBjJ"}
@@ -1,40 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- import { Tree } from "@itwin/itwinui-react/bricks";
7
- import { useLocalizationContext } from "./LocalizationContext.js";
8
- const filterIcon = new URL("@itwin/itwinui-icons/filter.svg", import.meta.url).href;
9
- const placeholderIcon = new URL("@itwin/itwinui-icons/placeholder.svg", import.meta.url).href; // TODO: active filter icon/placeholder icon if button was not given an icon
10
- /** @internal */
11
- export function TreeActionButton({ show, label, action, icon }) {
12
- const { localizedStrings } = useLocalizationContext();
13
- const localizedLabel = localizedStrings[label];
14
- return _jsx(Tree.ItemAction, { visible: show, onClick: action, label: localizedLabel ?? label, icon: icon ?? placeholderIcon });
15
- }
16
- /** @alpha */
17
- export function createFilterAction({ onFilter, getHierarchyLevelDetails }) {
18
- return (node) => {
19
- const handleVisibility = () => {
20
- if (!onFilter || !node.isFilterable) {
21
- return false;
22
- }
23
- if (node.isFiltered) {
24
- return true;
25
- }
26
- return undefined;
27
- };
28
- return {
29
- label: "filterHierarchyLevel",
30
- action: () => {
31
- const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);
32
- hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);
33
- },
34
- show: handleVisibility(),
35
- isDropdownAction: false,
36
- icon: node.isFiltered ? placeholderIcon : filterIcon,
37
- };
38
- };
39
- }
40
- //# sourceMappingURL=TreeActionButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeActionButton.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeActionButton.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAGnD,OAAO,EAAoB,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEpF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,iCAAiC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AACpF,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,sCAAsC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,4EAA4E;AAsB3K,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAkB;IAC5E,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,cAAc,GAAuB,gBAAgB,CAAC,KAAsC,CAAC,CAAC;IACpG,OAAO,KAAC,IAAI,CAAC,UAAU,IAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,IAAI,KAAK,EAAE,IAAI,EAAE,IAAI,IAAI,eAAe,GAAI,CAAC;AAC5H,CAAC;AAED,aAAa;AACb,MAAM,UAAU,kBAAkB,CAAC,EAAE,QAAQ,EAAE,wBAAwB,EAAqB;IAC1F,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,MAAM,gBAAgB,GAAG,GAAG,EAAE;YAC5B,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;gBACpC,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC;QAEF,OAAO;YACL,KAAK,EAAE,sBAAuD;YAC9D,MAAM,EAAE,GAAG,EAAE;gBACX,MAAM,qBAAqB,GAAG,wBAAwB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAClE,qBAAqB,IAAI,QAAQ,EAAE,CAAC,qBAAqB,CAAC,CAAC;YAC7D,CAAC;YACD,IAAI,EAAE,gBAAgB,EAAE;YACxB,gBAAgB,EAAE,KAAK;YACvB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU;SACrD,CAAC;IACJ,CAAC,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\nimport { Tree } from \"@itwin/itwinui-react/bricks\";\nimport { PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { HierarchyLevelDetails, useTree } from \"../UseTree.js\";\nimport { LocalizedStrings, useLocalizationContext } from \"./LocalizationContext.js\";\n\nconst filterIcon = new URL(\"@itwin/itwinui-icons/filter.svg\", import.meta.url).href;\nconst placeholderIcon = new URL(\"@itwin/itwinui-icons/placeholder.svg\", import.meta.url).href; // TODO: active filter icon/placeholder icon if button was not given an icon\n\n/** @alpha */\nexport interface TreeItemAction {\n label: string;\n action: () => void;\n /**\n * Determines action items visibility:\n * - `False` - action item is hidden.\n * - `True` - action item is visible at all times.\n * - `Undefined` - action item is visible on hover/focus.\n */\n show?: boolean;\n icon?: string;\n}\n\n/** @alpha */\nexport type FilterActionProps = {\n /** Action to perform when the filter button is clicked for this node. */\n onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n} & Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">>;\n\n/** @internal */\nexport function TreeActionButton({ show, label, action, icon }: TreeItemAction) {\n const { localizedStrings } = useLocalizationContext();\n const localizedLabel: string | undefined = localizedStrings[label as keyof typeof localizedStrings];\n return <Tree.ItemAction visible={show} onClick={action} label={localizedLabel ?? label} icon={icon ?? placeholderIcon} />;\n}\n\n/** @alpha */\nexport function createFilterAction({ onFilter, getHierarchyLevelDetails }: FilterActionProps): (node: PresentationHierarchyNode) => TreeItemAction {\n return (node) => {\n const handleVisibility = () => {\n if (!onFilter || !node.isFilterable) {\n return false;\n }\n if (node.isFiltered) {\n return true;\n }\n return undefined;\n };\n\n return {\n label: \"filterHierarchyLevel\" satisfies keyof LocalizedStrings,\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);\n },\n show: handleVisibility(),\n isDropdownAction: false,\n icon: node.isFiltered ? placeholderIcon : filterIcon,\n };\n };\n}\n"]}
@@ -1,23 +0,0 @@
1
- import { CSSProperties, ForwardRefExoticComponent, RefAttributes } from "react";
2
- import { PresentationInfoNode } from "../TreeNode.js";
3
- import { HierarchyLevelDetails, useTree } from "../UseTree.js";
4
- import { FlatNode } from "./FlatTreeNode.js";
5
- /** @alpha */
6
- export interface TreeErrorItemProps {
7
- /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */
8
- reloadTree?: (options: {
9
- parentNodeId: string | undefined;
10
- state: "reset";
11
- }) => void;
12
- /** Action to perform when the filter button is clicked for this node. */
13
- onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
14
- }
15
- interface TreeErrorRendererOwnProps {
16
- node: FlatNode<PresentationInfoNode>;
17
- style?: CSSProperties;
18
- }
19
- type TreeErrorRendererProps = TreeErrorRendererOwnProps & TreeErrorItemProps & Partial<Pick<ReturnType<typeof useTree>, "getHierarchyLevelDetails">>;
20
- /** @internal */
21
- export declare const TreeErrorRenderer: ForwardRefExoticComponent<TreeErrorRendererProps & RefAttributes<HTMLElement>>;
22
- export {};
23
- //# sourceMappingURL=TreeErrorRenderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeErrorRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeErrorRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAA4B,aAAa,EAAc,yBAAyB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,aAAa;AACb,MAAM,WAAW,kBAAkB;IACjC,iGAAiG;IACjG,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACrF,yEAAyE;IACzE,aAAa,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACxE;AAED,UAAU,yBAAyB;IACjC,IAAI,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,KAAK,sBAAsB,GAAG,yBAAyB,GAAG,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC;AAErJ,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,EAAE,yBAAyB,CAAC,sBAAsB,GAAG,aAAa,CAAC,WAAW,CAAC,CAoD5G,CAAC"}
@@ -1,72 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- import { forwardRef } from "react";
7
- import { Anchor, Text, Tree } from "@itwin/itwinui-react/bricks";
8
- import { MAX_LIMIT_OVERRIDE } from "../internal/Utils.js";
9
- import { useLocalizationContext } from "./LocalizationContext.js";
10
- /** @internal */
11
- export const TreeErrorRenderer = forwardRef(({ node, getHierarchyLevelDetails, onFilterClick, reloadTree, ...rest }, forwardedRef) => {
12
- const { localizedStrings } = useLocalizationContext();
13
- if (node.type === "ResultSetTooLarge") {
14
- return (_jsx(ResultSetTooLargeNode, { ...rest, ref: forwardedRef, limit: node.resultSetSizeLimit, onOverrideLimit: getHierarchyLevelDetails ? (limit) => getHierarchyLevelDetails(node.parentNodeId)?.setSizeLimit(limit) : undefined, onFilterClick: onFilterClick
15
- ? () => {
16
- const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.parentNodeId);
17
- hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);
18
- }
19
- : undefined, "aria-level": node.level, "aria-posinset": node.posInLevel, "aria-setsize": node.levelSize }));
20
- }
21
- if (node.type === "NoFilterMatches") {
22
- return (_jsx(Tree.Item, { ...rest, ref: forwardedRef, "aria-level": node.level, "aria-posinset": node.posInLevel, "aria-setsize": node.levelSize, label: localizedStrings.noFilteredChildren, "aria-disabled": true }));
23
- }
24
- const onRetry = reloadTree ? () => reloadTree({ parentNodeId: node.parentNodeId, state: "reset" }) : undefined;
25
- return (_jsx(Tree.Item, { ...rest, ref: forwardedRef, "aria-level": node.level, "aria-posinset": node.posInLevel, "aria-setsize": node.levelSize, label: _jsx(ErrorNodeLabel, { message: node.message, onRetry: onRetry }), "aria-disabled": true }));
26
- });
27
- TreeErrorRenderer.displayName = "TreeErrorRenderer";
28
- const ResultSetTooLargeNode = forwardRef(({ onFilterClick, onOverrideLimit, limit, ...props }, forwardedRef) => {
29
- return (_jsx(Tree.Item, { ...props, ref: forwardedRef, label: _jsx(ResultSetTooLargeNodeLabel, { limit: limit, onFilterClick: onFilterClick, onOverrideLimit: onOverrideLimit }) }));
30
- });
31
- ResultSetTooLargeNode.displayName = "ResultSetTooLargeNode";
32
- function ResultSetTooLargeNodeLabel({ onFilterClick, onOverrideLimit, limit }) {
33
- const { localizedStrings } = useLocalizationContext();
34
- const supportsFiltering = !!onFilterClick;
35
- const supportsLimitOverride = !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE;
36
- const limitExceededMessage = createLocalizedMessage(supportsFiltering ? localizedStrings.resultLimitExceededWithFiltering : localizedStrings.resultLimitExceeded, limit, onFilterClick);
37
- const increaseLimitMessage = supportsLimitOverride
38
- ? createLocalizedMessage(supportsFiltering ? localizedStrings.increaseHierarchyLimitWithFiltering : localizedStrings.increaseHierarchyLimit, MAX_LIMIT_OVERRIDE, () => onOverrideLimit(MAX_LIMIT_OVERRIDE))
39
- : { title: "", element: null };
40
- const title = `${limitExceededMessage.title} ${increaseLimitMessage.title}`;
41
- return (_jsxs("div", { style: { display: "flex", alignItems: "start" }, title: title, children: [limitExceededMessage.element, increaseLimitMessage.element] }));
42
- }
43
- function ErrorNodeLabel({ message, onRetry }) {
44
- const { localizedStrings } = useLocalizationContext();
45
- return (_jsxs("div", { style: { display: "flex" }, children: [_jsx(Text, { children: message }), onRetry ? _jsx(Anchor, { onClick: onRetry, children: localizedStrings?.retry }) : null] }));
46
- }
47
- function createLocalizedMessage(message, limit, onClick) {
48
- const limitStr = limit.toLocaleString(undefined, { useGrouping: true });
49
- const messageWithLimit = message.replace("{{limit}}", limitStr);
50
- const exp = new RegExp("<link>(.*)</link>");
51
- const match = messageWithLimit.match(exp);
52
- if (!match) {
53
- return {
54
- title: messageWithLimit,
55
- element: (_jsx("div", { style: { display: "flex" }, children: _jsx(Text, { children: messageWithLimit }) })),
56
- };
57
- }
58
- const [fullText, innerText] = match;
59
- const [textBefore, textAfter] = messageWithLimit.split(fullText);
60
- return {
61
- title: messageWithLimit.replace(fullText, innerText),
62
- element: (_jsxs("div", { style: { display: "flex" }, children: [textBefore ? _jsx(Text, { children: textBefore }) : null, _jsx(Anchor
63
- // underline props does not exist in v5
64
- , {
65
- // underline props does not exist in v5
66
- onClick: (e) => {
67
- e.stopPropagation();
68
- onClick?.();
69
- }, children: innerText }), textAfter ? _jsx(Text, { children: textAfter }) : null] })),
70
- };
71
- }
72
- //# sourceMappingURL=TreeErrorRenderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeErrorRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeErrorRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAA2C,UAAU,EAA4C,MAAM,OAAO,CAAC;AACtH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAiBlE,gBAAgB;AAChB,MAAM,CAAC,MAAM,iBAAiB,GAAmF,UAAU,CACzH,CAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,EAAE,EAAE;IACvF,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;QACtC,OAAO,CACL,KAAC,qBAAqB,OAChB,IAAI,EACR,GAAG,EAAE,YAAY,EACjB,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Q,GAC3B,CACP;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IACpC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEjE,OAAO;QACL,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC;QACpD,OAAO,EAAE,CACP,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAC5B,UAAU,CAAC,CAAC,CAAC,KAAC,IAAI,cAAE,UAAU,GAAQ,CAAC,CAAC,CAAC,IAAI,EAC9C,KAAC,MAAM;gBACL,uCAAuC;;oBAAvC,uCAAuC;oBACvC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;wBACb,CAAC,CAAC,eAAe,EAAE,CAAC;wBACpB,OAAO,EAAE,EAAE,CAAC;oBACd,CAAC,YAEA,SAAS,GACH,EACR,SAAS,CAAC,CAAC,CAAC,KAAC,IAAI,cAAE,SAAS,GAAQ,CAAC,CAAC,CAAC,IAAI,IACxC,CACP;KACF,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\nimport { ComponentPropsWithoutRef, CSSProperties, forwardRef, ForwardRefExoticComponent, RefAttributes } from \"react\";\nimport { Anchor, Text, Tree } from \"@itwin/itwinui-react/bricks\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { PresentationInfoNode } from \"../TreeNode.js\";\nimport { HierarchyLevelDetails, useTree } from \"../UseTree.js\";\nimport { FlatNode } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/** @alpha */\nexport interface TreeErrorItemProps {\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree?: (options: { parentNodeId: string | undefined; state: \"reset\" }) => void;\n /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n}\n\ninterface TreeErrorRendererOwnProps {\n node: FlatNode<PresentationInfoNode>;\n style?: CSSProperties;\n}\n\ntype TreeErrorRendererProps = TreeErrorRendererOwnProps & TreeErrorItemProps & Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">>;\n\n/** @internal */\nexport const TreeErrorRenderer: ForwardRefExoticComponent<TreeErrorRendererProps & RefAttributes<HTMLElement>> = forwardRef(\n ({ node, getHierarchyLevelDetails, onFilterClick, reloadTree, ...rest }, forwardedRef) => {\n const { localizedStrings } = useLocalizationContext();\n if (node.type === \"ResultSetTooLarge\") {\n return (\n <ResultSetTooLargeNode\n {...rest}\n ref={forwardedRef}\n limit={node.resultSetSizeLimit}\n onOverrideLimit={getHierarchyLevelDetails ? (limit) => getHierarchyLevelDetails(node.parentNodeId)?.setSizeLimit(limit) : undefined}\n onFilterClick={\n onFilterClick\n ? () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.parentNodeId);\n hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);\n }\n : undefined\n }\n aria-level={node.level}\n aria-posinset={node.posInLevel}\n aria-setsize={node.levelSize}\n />\n );\n }\n\n if (node.type === \"NoFilterMatches\") {\n return (\n <Tree.Item\n {...rest}\n ref={forwardedRef}\n aria-level={node.level}\n aria-posinset={node.posInLevel}\n aria-setsize={node.levelSize}\n label={localizedStrings.noFilteredChildren}\n aria-disabled={true}\n />\n );\n }\n\n const onRetry = reloadTree ? () => reloadTree({ parentNodeId: node.parentNodeId, state: \"reset\" }) : undefined;\n return (\n <Tree.Item\n {...rest}\n ref={forwardedRef}\n aria-level={node.level}\n aria-posinset={node.posInLevel}\n aria-setsize={node.levelSize}\n label={<ErrorNodeLabel message={node.message} onRetry={onRetry} />}\n aria-disabled={true}\n />\n );\n },\n);\nTreeErrorRenderer.displayName = \"TreeErrorRenderer\";\n\nconst ResultSetTooLargeNode = forwardRef<\n HTMLElement,\n Omit<ComponentPropsWithoutRef<typeof Tree.Item>, \"onExpanded\" | \"label\"> & ResultSetTooLargeNodeLabelProps\n>(({ onFilterClick, onOverrideLimit, limit, ...props }, forwardedRef) => {\n return (\n <Tree.Item\n {...props}\n ref={forwardedRef}\n label={<ResultSetTooLargeNodeLabel limit={limit} onFilterClick={onFilterClick} onOverrideLimit={onOverrideLimit} />}\n />\n );\n});\nResultSetTooLargeNode.displayName = \"ResultSetTooLargeNode\";\n\ninterface ResultSetTooLargeNodeLabelProps {\n limit: number;\n onFilterClick?: () => void;\n onOverrideLimit?: (limit: number) => void;\n}\n\nfunction ResultSetTooLargeNodeLabel({ onFilterClick, onOverrideLimit, limit }: ResultSetTooLargeNodeLabelProps) {\n const { localizedStrings } = useLocalizationContext();\n const supportsFiltering = !!onFilterClick;\n const supportsLimitOverride = !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE;\n\n const limitExceededMessage = createLocalizedMessage(\n supportsFiltering ? localizedStrings.resultLimitExceededWithFiltering : localizedStrings.resultLimitExceeded,\n limit,\n onFilterClick,\n );\n const increaseLimitMessage = supportsLimitOverride\n ? createLocalizedMessage(\n supportsFiltering ? localizedStrings.increaseHierarchyLimitWithFiltering : localizedStrings.increaseHierarchyLimit,\n MAX_LIMIT_OVERRIDE,\n () => onOverrideLimit(MAX_LIMIT_OVERRIDE),\n )\n : { title: \"\", element: null };\n\n const title = `${limitExceededMessage.title} ${increaseLimitMessage.title}`;\n\n return (\n <div style={{ display: \"flex\", alignItems: \"start\" }} title={title}>\n {limitExceededMessage.element}\n {increaseLimitMessage.element}\n </div>\n );\n}\n\nfunction ErrorNodeLabel({ message, onRetry }: { message: string; onRetry?: () => void }) {\n const { localizedStrings } = useLocalizationContext();\n return (\n <div style={{ display: \"flex\" }}>\n <Text>{message}</Text>\n {onRetry ? <Anchor onClick={onRetry}>{localizedStrings?.retry}</Anchor> : null}\n </div>\n );\n}\n\nfunction createLocalizedMessage(message: string, limit: number, onClick?: () => void) {\n const limitStr = limit.toLocaleString(undefined, { useGrouping: true });\n const messageWithLimit = message.replace(\"{{limit}}\", limitStr);\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = messageWithLimit.match(exp);\n\n if (!match) {\n return {\n title: messageWithLimit,\n element: (\n <div style={{ display: \"flex\" }}>\n <Text>{messageWithLimit}</Text>\n </div>\n ),\n };\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = messageWithLimit.split(fullText);\n\n return {\n title: messageWithLimit.replace(fullText, innerText),\n element: (\n <div style={{ display: \"flex\" }}>\n {textBefore ? <Text>{textBefore}</Text> : null}\n <Anchor\n // underline props does not exist in v5\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? <Text>{textAfter}</Text> : null}\n </div>\n ),\n };\n}\n"]}
@@ -1,40 +0,0 @@
1
- import { ComponentPropsWithoutRef, ForwardRefExoticComponent, ReactElement, RefAttributes } from "react";
2
- import { Tree } from "@itwin/itwinui-react/bricks";
3
- import { PresentationHierarchyNode } from "../TreeNode.js";
4
- import { useTree } from "../UseTree.js";
5
- import { FlatTreeNode } from "./FlatTreeNode.js";
6
- import { TreeItemAction } from "./TreeActionButton.js";
7
- import { TreeErrorItemProps } from "./TreeErrorRenderer.js";
8
- /** @alpha */
9
- type TreeNodeProps = ComponentPropsWithoutRef<typeof Tree.Item>;
10
- /** @alpha */
11
- export interface TreeNodeRendererOwnProps {
12
- /** Node that is rendered. */
13
- node: FlatTreeNode;
14
- /** Returns an icon or icon href for a given node. */
15
- getIcon?: (node: PresentationHierarchyNode) => string | ReactElement | undefined;
16
- /** Returns a label for a given node. */
17
- getLabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;
18
- /** Returns sublabel for a given node. */
19
- getSublabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;
20
- /** Action to perform when the node is clicked. */
21
- onNodeClick?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
22
- /** Action to perform when a key is pressed when the node is hovered on. */
23
- onNodeKeyDown?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;
24
- /**
25
- * Actions for tree item.
26
- */
27
- actions?: Array<(node: PresentationHierarchyNode) => TreeItemAction>;
28
- }
29
- /** @alpha */
30
- type TreeNodeRendererProps = Pick<ReturnType<typeof useTree>, "expandNode" | "isNodeSelected"> & Partial<Pick<ReturnType<typeof useTree>, "getHierarchyLevelDetails">> & Omit<TreeNodeProps, "actions" | "aria-level" | "aria-posinset" | "aria-setsize" | "label" | "icon" | "expanded" | "selected"> & TreeNodeRendererOwnProps & TreeErrorItemProps;
31
- /**
32
- * A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.
33
- *
34
- * @see `TreeRenderer`
35
- * @see https://itwinui.bentley.com/docs/tree
36
- * @public
37
- */
38
- export declare const TreeNodeRenderer: ForwardRefExoticComponent<TreeNodeRendererProps & RefAttributes<HTMLElement>>;
39
- export {};
40
- //# sourceMappingURL=TreeNodeRenderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EACL,wBAAwB,EAExB,yBAAyB,EAGzB,YAAY,EAEZ,aAAa,EAGd,MAAM,OAAO,CAAC;AACf,OAAO,EAAyB,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAA+B,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAqB,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EAAoB,cAAc,EAAE,MAAM,u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eAAe,GAAG,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC,GAC7H,wBAAwB,GACxB,kBAAkB,CAAC;AAErB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,yBAAyB,CAAC,qBAAqB,GAAG,aAAa,CAAC,WAAW,CAAC,CAiG1G,CAAC"}
@@ -1,80 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- import { forwardRef, useCallback, useRef, } from "react";
7
- import { DropdownMenu, Spinner, Tree } from "@itwin/itwinui-react/bricks";
8
- import { isPresentationHierarchyNode } from "../TreeNode.js";
9
- import { isPlaceholderNode } from "./FlatTreeNode.js";
10
- import { useLocalizationContext } from "./LocalizationContext.js";
11
- import { TreeActionButton } from "./TreeActionButton.js";
12
- import { TreeErrorRenderer } from "./TreeErrorRenderer.js";
13
- const dropdownIcon = new URL("@itwin/itwinui-icons/more-horizontal.svg", import.meta.url).href;
14
- /**
15
- * A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.
16
- *
17
- * @see `TreeRenderer`
18
- * @see https://itwinui.bentley.com/docs/tree
19
- * @public
20
- */
21
- export const TreeNodeRenderer = forwardRef(({ node, expandNode, getIcon, getLabel, onFilterClick, onNodeClick, onNodeKeyDown, isNodeSelected, getHierarchyLevelDetails, reloadTree, actions, ...treeItemProps }, forwardedRef) => {
22
- const nodeRef = useRef(null);
23
- const ref = useMergedRefs(forwardedRef, nodeRef);
24
- if (isPlaceholderNode(node)) {
25
- return _jsx(PlaceholderNode, { ...treeItemProps, level: node.level, ref: ref });
26
- }
27
- if (!isPresentationHierarchyNode(node)) {
28
- return (_jsx(TreeErrorRenderer, { style: treeItemProps.style, ref: ref, node: node, getHierarchyLevelDetails: getHierarchyLevelDetails, reloadTree: reloadTree, onFilterClick: onFilterClick }));
29
- }
30
- const getActions = () => {
31
- if (!actions || actions.length === 0) {
32
- return undefined;
33
- }
34
- if (actions.length < 4) {
35
- return actions.map((action, index) => {
36
- const actionInfo = action(node);
37
- return _jsx(TreeActionButton, { ...actionInfo }, index);
38
- });
39
- }
40
- return [
41
- _jsx(TreeActionButton, { ...actions[0](node) }, 0),
42
- _jsx(TreeActionButton, { ...actions[1](node) }, 1),
43
- _jsxs(DropdownMenu.Root, { children: [_jsx(DropdownMenu.Button, { render: _jsx(Tree.ItemAction, { icon: dropdownIcon, label: "Tree actions dropdown" }) }), _jsx(DropdownMenu.Content, { children: actions.slice(2, actions.length).map((action) => {
44
- const info = action(node);
45
- return (_jsx(DropdownMenu.Item, { onClick: () => info.action(), children: info.label }, info.label));
46
- }) })] }, 2),
47
- ];
48
- };
49
- const selected = isNodeSelected(node.id);
50
- return (_jsx(Tree.Item, { ...treeItemProps, ref: ref, "aria-level": node.level, "aria-posinset": node.posInLevel, "aria-setsize": node.levelSize, label: getLabel ? getLabel(node) : node.label, selected: selected, expanded: node.isExpanded || node.children === true || node.children.length > 0 ? node.isExpanded : undefined, onExpandedChange: (isExpanded) => {
51
- expandNode(node.id, isExpanded);
52
- }, onClick: (event) => {
53
- !treeItemProps["aria-disabled"] && onNodeClick?.(node, !selected, event);
54
- }, onKeyDown: (event) => {
55
- // Ignore if it is called on the element inside, e.g. checkbox or expander
56
- if (!treeItemProps["aria-disabled"] && event.target === nodeRef.current) {
57
- onNodeKeyDown?.(node, !selected, event);
58
- }
59
- }, icon: getIcon ? getIcon(node) : undefined, actions: getActions() }));
60
- });
61
- TreeNodeRenderer.displayName = "TreeNodeRenderer";
62
- const PlaceholderNode = forwardRef(({ level, ...props }, forwardedRef) => {
63
- const { localizedStrings } = useLocalizationContext();
64
- return (_jsx(Tree.Item, { ...props, "aria-level": level, "aria-posinset": 1, "aria-setsize": 1, ref: forwardedRef, label: localizedStrings.loading, icon: _jsx(Spinner, { size: "small", title: localizedStrings.loading }) }));
65
- });
66
- PlaceholderNode.displayName = "PlaceholderNode";
67
- function useMergedRefs(...refs) {
68
- return useCallback((instance) => {
69
- refs.forEach((ref) => {
70
- if (typeof ref === "function") {
71
- ref(instance);
72
- }
73
- else if (ref) {
74
- ref.current = instance;
75
- }
76
- });
77
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
78
- [...refs]);
79
- }
80
- //# sourceMappingURL=TreeNodeRenderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAEL,UAAU,EAOV,WAAW,EACX,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAA6B,MAAM,gBAAgB,CAAC;AAExF,OAAO,EAAgB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAkB,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAsB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,0CAA0C,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AAgC/F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAkF,UAAU,CACvH,CACE,EACE,IAAI,EACJ,UAAU,EACV,OAAO,EACP,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,UAAU,EACV,OAAO,EACP,GAAG,aAAa,EACjB,EACD,YAAY,EACZ,EAAE;IAC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AE,EAAE;YACnB,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;gBAC9B,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChB,CAAC;iBAAM,IAAI,GAAG,EAAE,CAAC;gBACd,GAAkC,CAAC,OAAO,GAAG,QAAQ,CAAC;YACzD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,uDAAuD;IAC1D,CAAC,GAAG,IAAI,CAAC,CACV,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\nimport {\n ComponentPropsWithoutRef,\n forwardRef,\n ForwardRefExoticComponent,\n LegacyRef,\n MutableRefObject,\n ReactElement,\n Ref,\n RefAttributes,\n useCallback,\n useRef,\n} from \"react\";\nimport { DropdownMenu, Spinner, Tree } from \"@itwin/itwinui-react/bricks\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { useTree } from \"../UseTree.js\";\nimport { FlatTreeNode, isPlaceholderNode } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionButton, TreeItemAction } from \"./TreeActionButton.js\";\nimport { TreeErrorItemProps, TreeErrorRenderer } from \"./TreeErrorRenderer.js\";\n\nconst dropdownIcon = new URL(\"@itwin/itwinui-icons/more-horizontal.svg\", import.meta.url).href;\n\n/** @alpha */\ntype TreeNodeProps = ComponentPropsWithoutRef<typeof Tree.Item>;\n\n/** @alpha */\nexport interface TreeNodeRendererOwnProps {\n /** Node that is rendered. */\n node: FlatTreeNode;\n /** Returns an icon or icon href for a given node. */\n getIcon?: (node: PresentationHierarchyNode) => string | ReactElement | undefined;\n /** Returns a label for a given node. */\n getLabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Returns sublabel for a given node. */\n getSublabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Action to perform when the node is clicked. */\n onNodeClick?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Action to perform when a key is pressed when the node is hovered on. */\n onNodeKeyDown?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;\n /**\n * Actions for tree item.\n */\n actions?: Array<(node: PresentationHierarchyNode) => TreeItemAction>;\n}\n\n/** @alpha */\ntype TreeNodeRendererProps = Pick<ReturnType<typeof useTree>, \"expandNode\" | \"isNodeSelected\"> &\n Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">> &\n Omit<TreeNodeProps, \"actions\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\" | \"label\" | \"icon\" | \"expanded\" | \"selected\"> &\n TreeNodeRendererOwnProps &\n TreeErrorItemProps;\n\n/**\n * A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.\n *\n * @see `TreeRenderer`\n * @see https://itwinui.bentley.com/docs/tree\n * @public\n */\nexport const TreeNodeRenderer: ForwardRefExoticComponent<TreeNodeRendererProps & RefAttributes<HTMLElement>> = forwardRef(\n (\n {\n node,\n expandNode,\n getIcon,\n getLabel,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n isNodeSelected,\n getHierarchyLevelDetails,\n reloadTree,\n actions,\n ...treeItemProps\n },\n forwardedRef,\n ) => {\n const nodeRef = useRef<HTMLElement>(null);\n const ref = useMergedRefs(forwardedRef, nodeRef);\n\n if (isPlaceholderNode(node)) {\n return <PlaceholderNode {...treeItemProps} level={node.level} ref={ref} />;\n }\n\n if (!isPresentationHierarchyNode(node)) {\n return (\n <TreeErrorRenderer\n style={treeItemProps.style}\n ref={ref}\n node={node}\n getHierarchyLevelDetails={getHierarchyLevelDetails}\n reloadTree={reloadTree}\n onFilterClick={onFilterClick}\n />\n );\n }\n\n const getActions = () => {\n if (!actions || actions.length === 0) {\n return undefined;\n }\n\n if (actions.length < 4) {\n return actions.map((action, index) => {\n const actionInfo = action(node);\n return <TreeActionButton key={index} {...actionInfo} />;\n });\n }\n\n return [\n <TreeActionButton key={0} {...actions[0](node)} />,\n <TreeActionButton key={1} {...actions[1](node)} />,\n <DropdownMenu.Root key={2}>\n <DropdownMenu.Button render={<Tree.ItemAction icon={dropdownIcon} label=\"Tree actions dropdown\" />} />\n <DropdownMenu.Content>\n {actions.slice(2, actions.length).map((action) => {\n const info = action(node);\n return (\n <DropdownMenu.Item key={info.label} onClick={() => info.action()}>\n {info.label}\n </DropdownMenu.Item>\n );\n })}\n </DropdownMenu.Content>\n </DropdownMenu.Root>,\n ];\n };\n\n const selected = isNodeSelected(node.id);\n return (\n <Tree.Item\n {...treeItemProps}\n ref={ref}\n aria-level={node.level}\n aria-posinset={node.posInLevel}\n aria-setsize={node.levelSize}\n label={getLabel ? getLabel(node) : node.label}\n selected={selected}\n expanded={node.isExpanded || node.children === true || node.children.length > 0 ? node.isExpanded : undefined}\n onExpandedChange={(isExpanded) => {\n expandNode(node.id, isExpanded);\n }}\n onClick={(event) => {\n !treeItemProps[\"aria-disabled\"] && onNodeClick?.(node, !selected, event);\n }}\n onKeyDown={(event) => {\n // Ignore if it is called on the element inside, e.g. checkbox or expander\n if (!treeItemProps[\"aria-disabled\"] && event.target === nodeRef.current) {\n onNodeKeyDown?.(node, !selected, event);\n }\n }}\n icon={getIcon ? getIcon(node) : undefined}\n actions={getActions()}\n />\n );\n },\n);\nTreeNodeRenderer.displayName = \"TreeNodeRenderer\";\n\nconst PlaceholderNode = forwardRef<\n HTMLDivElement,\n Omit<TreeNodeProps, \"onExpanded\" | \"label\" | \"actions\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\" | \"icon\"> & { level: number }\n>(({ level, ...props }, forwardedRef) => {\n const { localizedStrings } = useLocalizationContext();\n return (\n <Tree.Item\n {...props}\n aria-level={level}\n aria-posinset={1}\n aria-setsize={1}\n ref={forwardedRef}\n label={localizedStrings.loading}\n icon={<Spinner size={\"small\"} title={localizedStrings.loading} />}\n />\n );\n});\nPlaceholderNode.displayName = \"PlaceholderNode\";\n\nfunction useMergedRefs<T>(...refs: ReadonlyArray<Ref<T> | LegacyRef<T> | undefined | null>) {\n return useCallback(\n (instance: T | null) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(instance);\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = instance;\n }\n });\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n [...refs],\n );\n}\n"]}
@@ -1,30 +0,0 @@
1
- import { ComponentPropsWithoutRef } from "react";
2
- import { Tree } from "@itwin/itwinui-react/bricks";
3
- import { PresentationTreeNode } from "../TreeNode.js";
4
- import { SelectionMode } from "../UseSelectionHandler.js";
5
- import { useTree } from "../UseTree.js";
6
- import { LocalizationContextProvider } from "./LocalizationContext.js";
7
- import { TreeNodeRenderer } from "./TreeNodeRenderer.js";
8
- /** @alpha */
9
- export type TreeProps = ComponentPropsWithoutRef<typeof Tree.Root>;
10
- /** @alpha */
11
- export type TreeNodeRendererProps = ComponentPropsWithoutRef<typeof TreeNodeRenderer>;
12
- /** @alpha */
13
- interface TreeRendererOwnProps {
14
- /** Root nodes of the tree. */
15
- rootNodes: PresentationTreeNode[];
16
- /** Active selection mode used by the tree. Defaults to `"single"`. */
17
- selectionMode?: SelectionMode;
18
- }
19
- /** @alpha */
20
- type TreeRendererProps = Pick<ReturnType<typeof useTree>, "expandNode"> & Partial<Pick<ReturnType<typeof useTree>, "selectNodes" | "isNodeSelected" | "getHierarchyLevelDetails" | "reloadTree">> & Omit<TreeNodeRendererProps, "node" | "reloadTree"> & TreeRendererOwnProps & ComponentPropsWithoutRef<typeof LocalizationContextProvider>;
21
- /**
22
- * A component that renders a tree using the `Tree` component from `@itwin/itwinui-react`. The tree nodes
23
- * are rendered using `TreeNodeRenderer` component from this package.
24
- *
25
- * @see https://itwinui.bentley.com/docs/tree
26
- * @alpha
27
- */
28
- export declare function TreeRenderer({ rootNodes, expandNode, localizedStrings, selectNodes, selectionMode, ...treeProps }: TreeRendererProps): import("react/jsx-runtime").JSX.Element;
29
- export {};
30
- //# sourceMappingURL=TreeRenderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAmB,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAuB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,aAAa;AACb,MAAM,MAAM,SAAS,GAAG,wBAAwB,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;AAEnE,aAAa;AACb,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,CAAC;AACtF,aAAa;AACb,UAAU,oBAAoB;IAC5B,8BAA8B;IAC9B,SAAS,EAAE,oBAAoB,EAAE,CAAC;IAClC,sEAAsE;IACtE,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,aAAa;AACb,KAAK,iBAAiB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,YAAY,CAAC,GACrE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,aAAa,GAAG,gBAAgB,GAAG,0BAA0B,GAAG,YAAY,CAAC,CAAC,GACvH,IAAI,CAAC,qBAAqB,EAAE,MAAM,GAAG,YAAY,CAAC,GAClD,oBAAoB,GACpB,wBAAwB,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAE/D;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,EAAE,iBAAiB,2CAgDpI"}
@@ -1,48 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createElement as _createElement } from "react";
3
- /*---------------------------------------------------------------------------------------------
4
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
- * See LICENSE.md in the project root for license terms and full copyright notice.
6
- *--------------------------------------------------------------------------------------------*/
7
- import { useMemo, useRef } from "react";
8
- import { Tree } from "@itwin/itwinui-react/bricks";
9
- import { useVirtualizer } from "@tanstack/react-virtual";
10
- import { useSelectionHandler } from "../UseSelectionHandler.js";
11
- import { flattenNodes } from "./FlatTreeNode.js";
12
- import { LocalizationContextProvider } from "./LocalizationContext.js";
13
- import { TreeNodeRenderer } from "./TreeNodeRenderer.js";
14
- /**
15
- * A component that renders a tree using the `Tree` component from `@itwin/itwinui-react`. The tree nodes
16
- * are rendered using `TreeNodeRenderer` component from this package.
17
- *
18
- * @see https://itwinui.bentley.com/docs/tree
19
- * @alpha
20
- */
21
- export function TreeRenderer({ rootNodes, expandNode, localizedStrings, selectNodes, selectionMode, ...treeProps }) {
22
- const { onNodeClick, onNodeKeyDown } = useSelectionHandler({
23
- rootNodes,
24
- selectNodes: selectNodes ?? noopSelectNodes,
25
- selectionMode: selectionMode ?? "single",
26
- });
27
- const parentRef = useRef(null);
28
- const flatNodes = useMemo(() => flattenNodes(rootNodes), [rootNodes]);
29
- const virtualizer = useVirtualizer({
30
- count: flatNodes.length,
31
- getScrollElement: () => parentRef.current,
32
- estimateSize: () => 28,
33
- overscan: 5,
34
- });
35
- const items = virtualizer.getVirtualItems();
36
- return (_jsx(LocalizationContextProvider, { localizedStrings: localizedStrings, children: _jsx("div", { style: { height: "100%", width: "100%", overflowY: "auto" }, ref: parentRef, children: _jsx(Tree.Root, { style: { height: virtualizer.getTotalSize(), minHeight: "100%", width: "100%", position: "relative" }, children: items.map((virtualizedItem) => {
37
- return (_createElement(TreeNodeRenderer, { ...treeProps, ref: virtualizer.measureElement, style: {
38
- position: "absolute",
39
- top: 0,
40
- left: 0,
41
- width: "100%",
42
- transform: `translateY(${virtualizedItem.start}px)`,
43
- willChange: "transform",
44
- }, expandNode: expandNode, onNodeClick: onNodeClick, onNodeKeyDown: onNodeKeyDown, node: flatNodes[virtualizedItem.index], key: flatNodes[virtualizedItem.index].id, "data-index": virtualizedItem.index }));
45
- }) }) }) }));
46
- }
47
- function noopSelectNodes() { }
48
- //# sourceMappingURL=TreeRenderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAA4B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAiB,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAsBzD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,SAAS,EAAqB;IACnI,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,mBAAmB,CAAC;QACzD,SAAS;QACT,WAAW,EAAE,WAAW,IAAI,eAAe;QAC3C,aAAa,EAAE,a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,aAAa,EAC5B,IAAI,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,EACtC,GAAG,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,gBAC5B,eAAe,CAAC,KAAK,GACjC,CACH,CAAC;gBACJ,CAAC,CAAC,GACQ,GACR,GACsB,CAC/B,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,KAAI,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\nimport { ComponentPropsWithoutRef, useMemo, useRef } from \"react\";\nimport { Tree } from \"@itwin/itwinui-react/bricks\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport { PresentationTreeNode } from \"../TreeNode.js\";\nimport { SelectionMode, useSelectionHandler } from \"../UseSelectionHandler.js\";\nimport { useTree } from \"../UseTree.js\";\nimport { flattenNodes } from \"./FlatTreeNode.js\";\nimport { LocalizationContextProvider } from \"./LocalizationContext.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\n\n/** @alpha */\nexport type TreeProps = ComponentPropsWithoutRef<typeof Tree.Root>;\n\n/** @alpha */\nexport type TreeNodeRendererProps = ComponentPropsWithoutRef<typeof TreeNodeRenderer>;\n/** @alpha */\ninterface TreeRendererOwnProps {\n /** Root nodes of the tree. */\n rootNodes: PresentationTreeNode[];\n /** Active selection mode used by the tree. Defaults to `\"single\"`. */\n selectionMode?: SelectionMode;\n}\n\n/** @alpha */\ntype TreeRendererProps = Pick<ReturnType<typeof useTree>, \"expandNode\"> &\n Partial<Pick<ReturnType<typeof useTree>, \"selectNodes\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"reloadTree\">> &\n Omit<TreeNodeRendererProps, \"node\" | \"reloadTree\"> &\n TreeRendererOwnProps &\n ComponentPropsWithoutRef<typeof LocalizationContextProvider>;\n\n/**\n * A component that renders a tree using the `Tree` component from `@itwin/itwinui-react`. The tree nodes\n * are rendered using `TreeNodeRenderer` component from this package.\n *\n * @see https://itwinui.bentley.com/docs/tree\n * @alpha\n */\nexport function TreeRenderer({ rootNodes, expandNode, localizedStrings, selectNodes, selectionMode, ...treeProps }: TreeRendererProps) {\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({\n rootNodes,\n selectNodes: selectNodes ?? noopSelectNodes,\n selectionMode: selectionMode ?? \"single\",\n });\n const parentRef = useRef<HTMLDivElement>(null);\n const flatNodes = useMemo(() => flattenNodes(rootNodes), [rootNodes]);\n\n const virtualizer = useVirtualizer({\n count: flatNodes.length,\n getScrollElement: () => parentRef.current,\n estimateSize: () => 28,\n overscan: 5,\n });\n\n const items = virtualizer.getVirtualItems();\n\n return (\n <LocalizationContextProvider localizedStrings={localizedStrings}>\n <div style={{ height: \"100%\", width: \"100%\", overflowY: \"auto\" }} ref={parentRef}>\n <Tree.Root style={{ height: virtualizer.getTotalSize(), minHeight: \"100%\", width: \"100%\", position: \"relative\" }}>\n {items.map((virtualizedItem) => {\n return (\n <TreeNodeRenderer\n {...treeProps}\n ref={virtualizer.measureElement}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n transform: `translateY(${virtualizedItem.start}px)`,\n willChange: \"transform\",\n }}\n expandNode={expandNode}\n onNodeClick={onNodeClick}\n onNodeKeyDown={onNodeKeyDown}\n node={flatNodes[virtualizedItem.index]}\n key={flatNodes[virtualizedItem.index].id}\n data-index={virtualizedItem.index}\n />\n );\n })}\n </Tree.Root>\n </div>\n </LocalizationContextProvider>\n );\n}\n\nfunction noopSelectNodes() {}\n"]}
@@ -1,13 +0,0 @@
1
- export { PresentationGenericInfoNode, PresentationHierarchyNode, PresentationInfoNode, PresentationResultSetTooLargeInfoNode, PresentationTreeNode, isPresentationHierarchyNode, } from "./presentation-hierarchies-react/TreeNode.js";
2
- export { UnifiedSelectionProvider } from "./presentation-hierarchies-react/UnifiedSelectionContext.js";
3
- export { useSelectionHandler } from "./presentation-hierarchies-react/UseSelectionHandler.js";
4
- export { HierarchyLevelDetails, useTree, useUnifiedSelectionTree } from "./presentation-hierarchies-react/UseTree.js";
5
- export { useIModelTree, useIModelUnifiedSelectionTree } from "./presentation-hierarchies-react/UseIModelTree.js";
6
- export { TreeNodeRenderer } from "./presentation-hierarchies-react/itwinui/TreeNodeRenderer.js";
7
- export { TreeItemAction, createFilterAction } from "./presentation-hierarchies-react/itwinui/TreeActionButton.js";
8
- export { TreeRenderer } from "./presentation-hierarchies-react/itwinui/TreeRenderer.js";
9
- export { flattenNodes, FlatTreeNode } from "./presentation-hierarchies-react/itwinui/FlatTreeNode.js";
10
- export { LocalizationContextProvider } from "./presentation-hierarchies-react/itwinui/LocalizationContext.js";
11
- export { GenericInstanceFilter, HierarchyNode, HierarchyProvider } from "@itwin/presentation-hierarchies";
12
- export { SelectionStorage } from "@itwin/unified-selection";
13
- //# sourceMappingURL=presentation-hierarchies-react.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"presentation-hierarchies-react.d.ts","sourceRoot":"","sources":["../../src/presentation-hierarchies-react.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,oBAAoB,EACpB,qCAAqC,EACrC,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,6DAA6D,CAAC;AACvG,OAAO,EAAE,mBAAmB,EAAE,MAAM,yDAAyD,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,MAAM,0DAA0D,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0DAA0D,CAAC;AACtG,OAAO,EAAE,2BAA2B,EAAE,MAAM,iEAAiE,CAAC;AAE9G,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC1G,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,16 +0,0 @@
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
- export { isPresentationHierarchyNode, } from "./presentation-hierarchies-react/TreeNode.js";
6
- export { UnifiedSelectionProvider } from "./presentation-hierarchies-react/UnifiedSelectionContext.js";
7
- export { useSelectionHandler } from "./presentation-hierarchies-react/UseSelectionHandler.js";
8
- export { useTree, useUnifiedSelectionTree } from "./presentation-hierarchies-react/UseTree.js";
9
- export { useIModelTree, useIModelUnifiedSelectionTree } from "./presentation-hierarchies-react/UseIModelTree.js";
10
- export { TreeNodeRenderer } from "./presentation-hierarchies-react/itwinui/TreeNodeRenderer.js";
11
- export { createFilterAction } from "./presentation-hierarchies-react/itwinui/TreeActionButton.js";
12
- export { TreeRenderer } from "./presentation-hierarchies-react/itwinui/TreeRenderer.js";
13
- export { flattenNodes } from "./presentation-hierarchies-react/itwinui/FlatTreeNode.js";
14
- export { LocalizationContextProvider } from "./presentation-hierarchies-react/itwinui/LocalizationContext.js";
15
- export { GenericInstanceFilter, HierarchyNode } from "@itwin/presentation-hierarchies";
16
- //# sourceMappingURL=presentation-hierarchies-react.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"presentation-hierarchies-react.js","sourceRoot":"","sources":["../../src/presentation-hierarchies-react.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAML,2BAA2B,GAC5B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,6DAA6D,CAAC;AACvG,OAAO,EAAE,mBAAmB,EAAE,MAAM,yDAAyD,CAAC;AAC9F,OAAO,EAAyB,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAChG,OAAO,EAAkB,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,MAAM,0DAA0D,CAAC;AACxF,OAAO,EAAE,YAAY,EAAgB,MAAM,0DAA0D,CAAC;AACtG,OAAO,EAAE,2BAA2B,EAAE,MAAM,iEAAiE,CAAC;AAE9G,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAqB,MAAM,iCAAiC,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\nexport {\n PresentationGenericInfoNode,\n PresentationHierarchyNode,\n PresentationInfoNode,\n PresentationResultSetTooLargeInfoNode,\n PresentationTreeNode,\n isPresentationHierarchyNode,\n} from \"./presentation-hierarchies-react/TreeNode.js\";\nexport { UnifiedSelectionProvider } from \"./presentation-hierarchies-react/UnifiedSelectionContext.js\";\nexport { useSelectionHandler } from \"./presentation-hierarchies-react/UseSelectionHandler.js\";\nexport { HierarchyLevelDetails, useTree, useUnifiedSelectionTree } from \"./presentation-hierarchies-react/UseTree.js\";\nexport { useIModelTree, useIModelUnifiedSelectionTree } from \"./presentation-hierarchies-react/UseIModelTree.js\";\nexport { TreeNodeRenderer } from \"./presentation-hierarchies-react/itwinui/TreeNodeRenderer.js\";\nexport { TreeItemAction, createFilterAction } from \"./presentation-hierarchies-react/itwinui/TreeActionButton.js\";\nexport { TreeRenderer } from \"./presentation-hierarchies-react/itwinui/TreeRenderer.js\";\nexport { flattenNodes, FlatTreeNode } from \"./presentation-hierarchies-react/itwinui/FlatTreeNode.js\";\nexport { LocalizationContextProvider } from \"./presentation-hierarchies-react/itwinui/LocalizationContext.js\";\n\nexport { GenericInstanceFilter, HierarchyNode, HierarchyProvider } from \"@itwin/presentation-hierarchies\";\nexport { SelectionStorage } from \"@itwin/unified-selection\";\n"]}