@itwin/tree-widget-react 2.0.2 → 2.2.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 (111) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/README.md +105 -0
  3. package/lib/cjs/components/SelectableTree.d.ts +4 -0
  4. package/lib/cjs/components/SelectableTree.js +1 -1
  5. package/lib/cjs/components/SelectableTree.js.map +1 -1
  6. package/lib/cjs/components/TreeSelector.d.ts +2 -0
  7. package/lib/cjs/components/TreeSelector.js +4 -1
  8. package/lib/cjs/components/TreeSelector.js.map +1 -1
  9. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +4 -0
  10. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +7 -7
  11. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  12. package/lib/cjs/components/tree-header/TreeHeader.d.ts +1 -0
  13. package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
  14. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +6 -4
  15. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -1
  16. package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +11 -3
  17. package/lib/cjs/components/trees/VisibilityTreeRenderer.js +8 -5
  18. package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
  19. package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +13 -0
  20. package/lib/cjs/components/trees/category-tree/CategoriesTree.js +14 -2
  21. package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
  22. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +17 -8
  23. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  24. package/lib/cjs/components/trees/common/ReportingTreeEventHandler.d.ts +27 -0
  25. package/lib/cjs/components/trees/common/ReportingTreeEventHandler.js +51 -0
  26. package/lib/cjs/components/trees/common/ReportingTreeEventHandler.js.map +1 -0
  27. package/lib/cjs/components/trees/common/TreeRenderer.d.ts +17 -2
  28. package/lib/cjs/components/trees/common/TreeRenderer.js +19 -3
  29. package/lib/cjs/components/trees/common/TreeRenderer.js.map +1 -1
  30. package/lib/cjs/components/trees/common/TreeRenderer.scss +1 -1
  31. package/lib/cjs/components/trees/common/UseFeatureReporting.d.ts +23 -0
  32. package/lib/cjs/components/trees/common/UseFeatureReporting.js +30 -0
  33. package/lib/cjs/components/trees/common/UseFeatureReporting.js.map +1 -0
  34. package/lib/cjs/components/trees/common/UsePerformanceReporting.d.ts +18 -0
  35. package/lib/cjs/components/trees/common/UsePerformanceReporting.js +25 -0
  36. package/lib/cjs/components/trees/common/UsePerformanceReporting.js.map +1 -0
  37. package/lib/cjs/components/trees/common/UseVisibilityTreeState.d.ts +8 -1
  38. package/lib/cjs/components/trees/common/UseVisibilityTreeState.js +5 -3
  39. package/lib/cjs/components/trees/common/UseVisibilityTreeState.js.map +1 -1
  40. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +13 -0
  41. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +21 -5
  42. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  43. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +13 -0
  44. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +22 -1
  45. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  46. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +13 -0
  47. package/lib/cjs/components/trees/models-tree/ModelsTree.js +24 -10
  48. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  49. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +27 -12
  50. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  51. package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.d.ts +10 -0
  52. package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js +5 -0
  53. package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -1
  54. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.d.ts +4 -1
  55. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +43 -28
  56. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
  57. package/lib/esm/components/SelectableTree.d.ts +4 -0
  58. package/lib/esm/components/SelectableTree.js +1 -1
  59. package/lib/esm/components/SelectableTree.js.map +1 -1
  60. package/lib/esm/components/TreeSelector.d.ts +2 -0
  61. package/lib/esm/components/TreeSelector.js +4 -1
  62. package/lib/esm/components/TreeSelector.js.map +1 -1
  63. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +4 -0
  64. package/lib/esm/components/TreeWidgetUiItemsProvider.js +7 -7
  65. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  66. package/lib/esm/components/tree-header/TreeHeader.d.ts +1 -0
  67. package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
  68. package/lib/esm/components/trees/VisibilityTreeEventHandler.js +7 -5
  69. package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -1
  70. package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +11 -3
  71. package/lib/esm/components/trees/VisibilityTreeRenderer.js +8 -5
  72. package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
  73. package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +13 -0
  74. package/lib/esm/components/trees/category-tree/CategoriesTree.js +14 -2
  75. package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
  76. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +17 -8
  77. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  78. package/lib/esm/components/trees/common/ReportingTreeEventHandler.d.ts +27 -0
  79. package/lib/esm/components/trees/common/ReportingTreeEventHandler.js +47 -0
  80. package/lib/esm/components/trees/common/ReportingTreeEventHandler.js.map +1 -0
  81. package/lib/esm/components/trees/common/TreeRenderer.d.ts +17 -2
  82. package/lib/esm/components/trees/common/TreeRenderer.js +19 -3
  83. package/lib/esm/components/trees/common/TreeRenderer.js.map +1 -1
  84. package/lib/esm/components/trees/common/TreeRenderer.scss +1 -1
  85. package/lib/esm/components/trees/common/UseFeatureReporting.d.ts +23 -0
  86. package/lib/esm/components/trees/common/UseFeatureReporting.js +26 -0
  87. package/lib/esm/components/trees/common/UseFeatureReporting.js.map +1 -0
  88. package/lib/esm/components/trees/common/UsePerformanceReporting.d.ts +18 -0
  89. package/lib/esm/components/trees/common/UsePerformanceReporting.js +21 -0
  90. package/lib/esm/components/trees/common/UsePerformanceReporting.js.map +1 -0
  91. package/lib/esm/components/trees/common/UseVisibilityTreeState.d.ts +8 -1
  92. package/lib/esm/components/trees/common/UseVisibilityTreeState.js +5 -3
  93. package/lib/esm/components/trees/common/UseVisibilityTreeState.js.map +1 -1
  94. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +13 -0
  95. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +22 -6
  96. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  97. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +13 -0
  98. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +23 -2
  99. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  100. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +13 -0
  101. package/lib/esm/components/trees/models-tree/ModelsTree.js +24 -10
  102. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  103. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +27 -12
  104. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  105. package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.d.ts +10 -0
  106. package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js +5 -0
  107. package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -1
  108. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.d.ts +4 -1
  109. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +43 -28
  110. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
  111. package/package.json +20 -20
@@ -1 +1 @@
1
- {"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,4DAAoC;AACpC,iCAAkC;AAClC,8DAA4E;AAC5E,wDAAgD;AAChD,4EAAsH;AACtH,wDAAqD;AAOrD;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAE3C,MAAM,WAAW,GAAG,IAAI,kCAAe,EAAE,CAAC;AAyC1C;;;GAGG;AACH,SAAgB,4BAA4B,CAAC,EAAE,iBAAiB,EAAE,GAAG,SAAS,EAA+B;IAC3G,OAAO,SAAS,sBAAsB,CAAC,SAA4B;QACjE,OAAO,uBAAC,2BAAY,OAAK,SAAS,KAAM,SAAS,EAAE,YAAY,EAAE,gCAAgC,CAAC,iBAAiB,CAAC,GAAI,CAAC;IAC3H,CAAC,CAAC;AACJ,CAAC;AAJD,oEAIC;AAED;;;GAGG;AACH,SAAgB,gCAAgC,CAAC,EAC/C,WAAW,GAAG,EAAE,EAChB,uBAAuB,GAAG,KAAK,EAC/B,kBAAkB,EAClB,YAAY,GACoB;IAChC,OAAO,SAAS,0BAA0B,CAAC,aAAoC;QAC7E,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,GAAG,WAAW,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChI,OAAO,C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AA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,MAAM,IAAI,YAAY,KAAK,SAAS,IAAI,kBAAkB,KAAK,UAAU,EAAE;YAC7E,eAAe,IAAI,eAAe,CAAC,kBAAkB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;SACnF;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAC,CAAC;IAE5E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;AACpE,CAAC;AAnBD,gEAmBC;AAWD;;;GAGG;AACH,SAAgB,4BAA4B,CAAC,KAAwC;IACnF,OAAO,CACL,iCAAK,SAAS,EAAC,8BAA8B,aAC3C,iCAAM,SAAS,EAAC,qBAAqB,YAAE,KAAK,CAAC,KAAK,GAAQ,EAC1D,iCAAM,SAAS,EAAC,mBAAmB,YAAE,KAAK,CAAC,OAAO,GAAQ,IACtD,CACP,CAAC;AACJ,CAAC;AAPD,oEAOC","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 classNames from \"classnames\";\nimport { useEffect } from \"react\";\nimport { TreeImageLoader, TreeNodeRenderer } from \"@itwin/components-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { PresentationTreeNodeRenderer, useControlledPresentationTreeFiltering } from \"@itwin/presentation-components\";\nimport { TreeRenderer } from \"./common/TreeRenderer\";\n\nimport type { NodeCheckboxRenderProps } from \"@itwin/core-react\";\nimport type { TreeRendererBaseProps, TreeRendererProps } from \"./common/TreeRenderer\";\nimport type { AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps } from \"@itwin/components-react\";\nimport type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"./common/Types\";\n/**\n * These constants are taken from `@itwin/core-react`.\n * Defines the size in pixels of the expansion toggle.\n * It is used to keep same hierarchy nodes with children and nodes without children in the same line.\n * @note This value applies only to the leaf nodes.\n */\nconst EXPANSION_TOGGLE_WIDTH = 24;\nconst EXPANDED_EXPANSION_TOGGLE_WIDTH = 42;\n\nconst imageLoader = new TreeImageLoader();\n\n/**\n * Props for visibility tree renderer.\n * @public\n */\nexport interface VisibilityTreeRendererProps extends TreeRendererBaseProps {\n /** Props for single node renderer. */\n nodeRendererProps: VisibilityTreeNodeRendererProps;\n}\n\n/**\n * Props for visibility tree node renderer.\n * @public\n */\nexport interface VisibilityTreeNodeRendererProps {\n /**\n * Specifies whether the icon at the left of the node label should be rendered.\n */\n iconsEnabled: boolean;\n /**\n * Specifies whether node description should be enabled.\n */\n descriptionEnabled: boolean;\n /**\n * Defines the offset in pixels of how much each hierarchy level should be offset to the right from the checkbox.\n * Defaults to `20`.\n */\n levelOffset?: number;\n /**\n * Specifies whether the root node be expanded at all times.\n * Defaults to `false`.\n */\n disableRootNodeCollapse?: boolean;\n /**\n * Specifies whether the nodes should be enlarged (less dense and larger content).\n * Is `false` by default\n */\n isEnlarged?: boolean;\n}\n\n/**\n * Creates Visibility tree renderer which renders nodes with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeRenderer({ nodeRendererProps, ...restProps }: VisibilityTreeRendererProps) {\n return function VisibilityTreeRenderer(treeProps: TreeRendererProps) {\n return <TreeRenderer {...treeProps} {...restProps} nodeRenderer={createVisibilityTreeNodeRenderer(nodeRendererProps)} />;\n };\n}\n\n/**\n * Creates node renderer which renders node with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse = false,\n descriptionEnabled,\n iconsEnabled,\n}: VisibilityTreeNodeRendererProps) {\n return function VisibilityTreeNodeRenderer(treeNodeProps: TreeNodeRendererProps) {\n const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);\n return (\n <TreeNodeRenderer\n {...treeNodeProps}\n node={{ ...treeNodeProps.node, depth: 0, numChildren: 1 }} // if we want to disable TreeNodeRenderer style calculations for tree nodes, we need to override these values.\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={iconsEnabled ? imageLoader : undefined}\n className={classNames(\n \"with-checkbox\",\n (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && \"disable-expander\",\n treeNodeProps.className,\n )}\n />\n );\n };\n}\n\n/**\n * Checkbox renderer that renders an eye.\n * @public\n */\nexport function VisibilityTreeNodeCheckbox(props: NodeCheckboxRenderProps) {\n return (\n <Checkbox\n className=\"visibility-tree-checkbox\"\n variant=\"eyeball\"\n checked={props.checked}\n onChange={(e) => props.onChange(e.currentTarget.checked)}\n onClick={props.onClick}\n disabled={props.disabled}\n title={props.title}\n />\n );\n}\n\n/**\n * Props for [[FilterableVisibilityTreeNodeRenderer]].\n * @beta\n */\nexport type FilterableVisibilityTreeNodeRendererProps = Omit<PresentationTreeNodeRendererProps, \"descriptionEnabled\"> & VisibilityTreeNodeRendererProps;\n\n/**\n * Creates node renderer which renders node with eye checkbox and hierarchy level filtering actions.\n * @beta\n */\nexport function FilterableVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse,\n descriptionEnabled,\n isEnlarged,\n ...restProps\n}: FilterableVisibilityTreeNodeRendererProps) {\n const expansionToggleWidth = isEnlarged ? EXPANDED_EXPANSION_TOGGLE_WIDTH : EXPANSION_TOGGLE_WIDTH;\n const nodeOffset = restProps.node.depth * levelOffset + (restProps.node.numChildren === 0 ? expansionToggleWidth : 0);\n\n return (\n <PresentationTreeNodeRenderer\n {...restProps}\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={imageLoader}\n className={classNames(\n \"with-checkbox\",\n (restProps.node.numChildren === 0 || (disableRootNodeCollapse && restProps.node.parentId === undefined)) && \"disable-expander\",\n )}\n />\n );\n}\n\n/**\n * Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.\n * @public\n * @deprecated in 2.0.0. Use [[useVisibilityTree]] instead.\n */\n// istanbul ignore next\nexport function useVisibilityTreeFiltering(\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>,\n filterInfo?: VisibilityTreeFilterInfo,\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void,\n) {\n const { filter, activeMatchIndex } = filterInfo ?? { filter: undefined, activeMatchIndex: undefined };\n const { filteredNodeLoader, isFiltering, matchesCount, nodeHighlightingProps } = useControlledPresentationTreeFiltering({\n nodeLoader,\n filter,\n activeMatchIndex,\n });\n\n useEffect(() => {\n if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader) {\n onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);\n }\n }, [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied]);\n\n return { filteredNodeLoader, isFiltering, nodeHighlightingProps };\n}\n\n/**\n * Properties for [[VisibilityTreeNoFilteredData]] component.\n * @public\n */\nexport interface VisibilityTreeNoFilteredDataProps {\n title: string;\n message: string;\n}\n\n/**\n * Renders message that no nodes was found for filter.\n * @public\n */\nexport function VisibilityTreeNoFilteredData(props: VisibilityTreeNoFilteredDataProps) {\n return (\n <div className=\"components-tree-errormessage\">\n <span className=\"errormessage-header\">{props.title}</span>\n <span className=\"errormessage-body\">{props.message}</span>\n </div>\n );\n}\n"]}
1
+ {"version":3,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;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,MAAM,IAAI,YAAY,KAAK,SAAS,IAAI,kBAAkB,KAAK,UAAU,EAAE;YAC7E,eAAe,IAAI,eAAe,CAAC,kBAAkB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;SACnF;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAC,CAAC;IAE5E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;AACpE,CAAC;AAnBD,gEAmBC;AAWD;;;GAGG;AACH,SAAgB,4BAA4B,CAAC,KAAwC;IACnF,OAAO,CACL,iCAAK,SAAS,EAAC,8BAA8B,aAC3C,iCAAM,SAAS,EAAC,qBAAqB,YAAE,KAAK,CAAC,KAAK,GAAQ,EAC1D,iCAAM,SAAS,EAAC,mBAAmB,YAAE,KAAK,CAAC,OAAO,GAAQ,IACtD,CACP,CAAC;AACJ,CAAC;AAPD,oEAOC","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 classNames from \"classnames\";\nimport { useEffect } from \"react\";\nimport { TreeImageLoader, TreeNodeRenderer } from \"@itwin/components-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { PresentationTreeNodeRenderer, useControlledPresentationTreeFiltering } from \"@itwin/presentation-components\";\nimport { TreeRenderer } from \"./common/TreeRenderer\";\n\nimport type { NodeCheckboxRenderProps } from \"@itwin/core-react\";\nimport type { TreeRendererBaseProps, TreeRendererProps } from \"./common/TreeRenderer\";\nimport type { AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps } from \"@itwin/components-react\";\nimport type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"./common/Types\";\n/**\n * These constants are taken from `@itwin/core-react`.\n * Defines the size in pixels of the expansion toggle.\n * It is used to keep same hierarchy nodes with children and nodes without children in the same line.\n * @note This value applies only to the leaf nodes.\n */\nconst EXPANSION_TOGGLE_WIDTH = 24;\nconst EXPANDED_EXPANSION_TOGGLE_WIDTH = 42;\n\nconst imageLoader = new TreeImageLoader();\n\n/**\n * Props for visibility tree renderer.\n * @public\n */\nexport interface VisibilityTreeRendererProps extends TreeRendererBaseProps {\n /** Props for single node renderer. */\n nodeRendererProps: VisibilityTreeNodeRendererProps;\n}\n\n/**\n * Props for visibility tree node renderer.\n * @public\n */\nexport interface VisibilityTreeNodeRendererProps {\n /**\n * Specifies whether the icon at the left of the node label should be rendered.\n */\n iconsEnabled: boolean;\n /**\n * Specifies whether node description should be enabled.\n */\n descriptionEnabled: boolean;\n /**\n * Defines the offset in pixels of how much each hierarchy level should be offset to the right from the checkbox.\n * Defaults to `20`.\n */\n levelOffset?: number;\n /**\n * Specifies whether the root node be expanded at all times.\n * Defaults to `false`.\n */\n disableRootNodeCollapse?: boolean;\n /**\n * Specifies whether the nodes should be enlarged (less dense and larger content).\n * Is `false` by default\n */\n isEnlarged?: boolean;\n /**\n * Callback called when visibility is toggled using a checkbox.\n */\n onVisibilityToggled?: (enabled: boolean) => void;\n}\n\n/**\n * Creates Visibility tree renderer which renders nodes with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeRenderer({ nodeRendererProps, ...restProps }: VisibilityTreeRendererProps) {\n return function VisibilityTreeRenderer(treeProps: TreeRendererProps) {\n return <TreeRenderer {...treeProps} {...restProps} nodeRenderer={createVisibilityTreeNodeRenderer(nodeRendererProps)} />;\n };\n}\n\n/**\n * Creates node renderer which renders node with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse = false,\n descriptionEnabled,\n iconsEnabled,\n onVisibilityToggled,\n}: VisibilityTreeNodeRendererProps) {\n return function VisibilityTreeNodeRenderer(treeNodeProps: TreeNodeRendererProps) {\n const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);\n return (\n <TreeNodeRenderer\n {...treeNodeProps}\n node={{ ...treeNodeProps.node, depth: 0, numChildren: 1 }} // if we want to disable TreeNodeRenderer style calculations for tree nodes, we need to override these values.\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} onVisibilityToggled={onVisibilityToggled} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={iconsEnabled ? imageLoader : undefined}\n className={classNames(\n \"with-checkbox\",\n (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && \"disable-expander\",\n treeNodeProps.className,\n )}\n />\n );\n };\n}\n\ninterface VisibilityTreeNodeCheckboxProps extends NodeCheckboxRenderProps {\n onVisibilityToggled?: (enabled: boolean) => void;\n}\n\n/**\n * Checkbox renderer that renders an eye.\n * @public\n */\nexport function VisibilityTreeNodeCheckbox(props: VisibilityTreeNodeCheckboxProps) {\n return (\n <Checkbox\n className=\"visibility-tree-checkbox\"\n variant=\"eyeball\"\n checked={props.checked}\n onChange={(e) => {\n props.onVisibilityToggled?.(e.currentTarget.checked);\n props.onChange(e.currentTarget.checked);\n }}\n onMouseDown={(e) => e.stopPropagation()}\n onClick={props.onClick}\n disabled={props.disabled}\n title={props.title}\n />\n );\n}\n\n/**\n * Props for [[FilterableVisibilityTreeNodeRenderer]].\n * @beta\n */\nexport type FilterableVisibilityTreeNodeRendererProps = Omit<PresentationTreeNodeRendererProps, \"descriptionEnabled\"> & VisibilityTreeNodeRendererProps;\n\n/**\n * Creates node renderer which renders node with eye checkbox and hierarchy level filtering actions.\n * @beta\n */\nexport function FilterableVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse,\n descriptionEnabled,\n isEnlarged,\n onVisibilityToggled,\n ...restProps\n}: FilterableVisibilityTreeNodeRendererProps) {\n const expansionToggleWidth = isEnlarged ? EXPANDED_EXPANSION_TOGGLE_WIDTH : EXPANSION_TOGGLE_WIDTH;\n const nodeOffset = restProps.node.depth * levelOffset + (restProps.node.numChildren === 0 ? expansionToggleWidth : 0);\n\n return (\n <PresentationTreeNodeRenderer\n {...restProps}\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} onVisibilityToggled={onVisibilityToggled} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={imageLoader}\n className={classNames(\n \"with-checkbox\",\n (restProps.node.numChildren === 0 || (disableRootNodeCollapse && restProps.node.parentId === undefined)) && \"disable-expander\",\n )}\n />\n );\n}\n\n/**\n * Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.\n * @public\n * @deprecated in 2.0.0. Use [[useVisibilityTree]] instead.\n */\n// istanbul ignore next\nexport function useVisibilityTreeFiltering(\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>,\n filterInfo?: VisibilityTreeFilterInfo,\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void,\n) {\n const { filter, activeMatchIndex } = filterInfo ?? { filter: undefined, activeMatchIndex: undefined };\n const { filteredNodeLoader, isFiltering, matchesCount, nodeHighlightingProps } = useControlledPresentationTreeFiltering({\n nodeLoader,\n filter,\n activeMatchIndex,\n });\n\n useEffect(() => {\n if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader) {\n onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);\n }\n }, [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied]);\n\n return { filteredNodeLoader, isFiltering, nodeHighlightingProps };\n}\n\n/**\n * Properties for [[VisibilityTreeNoFilteredData]] component.\n * @public\n */\nexport interface VisibilityTreeNoFilteredDataProps {\n title: string;\n message: string;\n}\n\n/**\n * Renders message that no nodes was found for filter.\n * @public\n */\nexport function VisibilityTreeNoFilteredData(props: VisibilityTreeNoFilteredDataProps) {\n return (\n <div className=\"components-tree-errormessage\">\n <span className=\"errormessage-header\">{props.title}</span>\n <span className=\"errormessage-body\">{props.message}</span>\n </div>\n );\n}\n"]}
@@ -38,6 +38,19 @@ export interface CategoryTreeProps extends BaseFilterableTreeProps {
38
38
  * @beta
39
39
  */
40
40
  hierarchyLevelConfig?: HierarchyLevelConfig;
41
+ /**
42
+ * Callback that is invoked when performance of tracked feature is measured.
43
+ * @param featureId ID of the feature.
44
+ * @param elapsedTime Elapsed time of the feature.
45
+ * @beta
46
+ */
47
+ onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;
48
+ /**
49
+ * Callback that is invoked when a tracked feature is used.
50
+ * @param featureId ID of the feature.
51
+ * @beta
52
+ */
53
+ onFeatureUsed?: (feature: string) => void;
41
54
  }
42
55
  /**
43
56
  * Tree which displays and manages display of categories contained in an iModel.
@@ -18,9 +18,12 @@ const presentation_components_1 = require("@itwin/presentation-components");
18
18
  const presentation_frontend_1 = require("@itwin/presentation-frontend");
19
19
  const TreeWidget_1 = require("../../../TreeWidget");
20
20
  const TreeRenderer_1 = require("../common/TreeRenderer");
21
+ const UseFeatureReporting_1 = require("../common/UseFeatureReporting");
22
+ const UsePerformanceReporting_1 = require("../common/UsePerformanceReporting");
21
23
  const UseVisibilityTreeState_1 = require("../common/UseVisibilityTreeState");
22
24
  const Utils_1 = require("../common/Utils");
23
25
  const VisibilityTreeRenderer_1 = require("../VisibilityTreeRenderer");
26
+ const CategoriesTreeComponent_1 = require("./CategoriesTreeComponent");
24
27
  const CategoryVisibilityHandler_1 = require("./CategoryVisibilityHandler");
25
28
  const PAGING_SIZE = 20;
26
29
  /**
@@ -35,13 +38,18 @@ exports.RULESET_CATEGORIES = require("./Categories.json"); // eslint-disable-lin
35
38
  function CategoryTree(props) {
36
39
  // istanbul ignore next
37
40
  const viewManager = props.viewManager ?? core_frontend_1.IModelApp.viewManager;
38
- const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig } = props;
41
+ const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig, onPerformanceMeasured, onFeatureUsed } = props;
39
42
  const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);
40
43
  const onFilterChange = (0, react_1.useCallback)((dataProvider, matchesCount) => {
41
44
  if (onFilterApplied && dataProvider && matchesCount !== undefined) {
42
45
  onFilterApplied(dataProvider, matchesCount);
43
46
  }
44
47
  }, [onFilterApplied]);
48
+ const { reportUsage } = (0, UseFeatureReporting_1.useFeatureReporting)({ treeIdentifier: CategoriesTreeComponent_1.CategoriesTreeComponent.id, onFeatureUsed });
49
+ const { onNodeLoaded } = (0, UsePerformanceReporting_1.usePerformanceReporting)({
50
+ treeIdentifier: CategoriesTreeComponent_1.CategoriesTreeComponent.id,
51
+ onPerformanceMeasured,
52
+ });
45
53
  const state = (0, UseVisibilityTreeState_1.useVisibilityTreeState)({
46
54
  imodel: props.iModel,
47
55
  ruleset: exports.RULESET_CATEGORIES,
@@ -52,11 +60,14 @@ function CategoryTree(props) {
52
60
  onFilterChange,
53
61
  hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
54
62
  enableHierarchyAutoUpdate: true,
63
+ onNodeLoaded,
64
+ reportUsage,
55
65
  });
56
66
  (0, react_1.useEffect)(() => {
57
67
  setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises
58
68
  }, [activeView]);
59
69
  const baseRendererProps = {
70
+ reportUsage,
60
71
  contextMenuItems: props.contextMenuItems,
61
72
  nodeLabelRenderer: props.nodeLabelRenderer,
62
73
  density: props.density,
@@ -64,6 +75,7 @@ function CategoryTree(props) {
64
75
  iconsEnabled: false,
65
76
  descriptionEnabled: true,
66
77
  levelOffset: 10,
78
+ onVisibilityToggled: () => reportUsage({ featureId: "visibility-change", reportInteraction: true }),
67
79
  },
68
80
  };
69
81
  const noFilteredDataRenderer = (0, react_1.useCallback)(() => {
@@ -80,7 +92,7 @@ function CategoryTree(props) {
80
92
  }
81
93
  exports.CategoryTree = CategoryTree;
82
94
  function CategoriesTreeNodeRenderer(props) {
83
- return ((0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_1.FilterableVisibilityTreeNodeRenderer, { ...props, iconsEnabled: false, descriptionEnabled: true, levelOffset: 10, isEnlarged: props.density === "enlarged" }));
95
+ return ((0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_1.FilterableVisibilityTreeNodeRenderer, { ...props, iconsEnabled: false, descriptionEnabled: true, levelOffset: 10, isEnlarged: props.density === "enlarged", onVisibilityToggled: () => props.reportUsage?.({ featureId: "visibility-change", reportInteraction: true }) }));
84
96
  }
85
97
  function useCategoryVisibilityHandler(viewManager, imodel, categories, activeView, allViewports, visibilityHandler) {
86
98
  const [state, setState] = (0, react_1.useState)();
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,4DAAoC;AACpC,iCAAyD;AACzD,8DAAwD;AACxD,wDAAiD;AACjD,4EAAkE;AAClE,wEAA4D;AAC5D,oDAAiD;AACjD,yDAAgE;AAChE,6EAA0E;AAC1E,2CAAwG;AACxG,sEAA6I;AAC7I,2EAAwE;AAOxE,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;GAGG;AACU,QAAA,kBAAkB,GAAY,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,yDAAyD;AAgClI;;;GAGG;AACH,SAAgB,YAAY,CAAC,KAAwB;IACnD,uBAAuB;IACvB,MAAM,WAAW,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E,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAED,MAAM,qBAAqB,GAAG,IAAA,yCAAiC,EAAC,CAAC,0CAAkC,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { PresentationTree } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES: Ruleset = require(\"./Categories.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps extends BaseFilterableTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig } = props;\n\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n },\n [onFilterApplied],\n );\n const state = useVisibilityTreeState({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n visibilityHandler,\n customizeTreeNodeItem,\n filterInfo: props.filterInfo,\n onFilterChange,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\n },\n };\n\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />\n );\n }, []);\n\n if (!state) {\n return null;\n }\n\n const isFilterApplied = state.filteringResult?.filteredProvider !== undefined;\n const overlay = state.filteringResult?.isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n return (\n <div className={classNames(\"tree-widget-visibility-tree-base\", \"tree-widget-tree-container\")}>\n <PresentationTree\n width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <CategoriesTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n descriptionsEnabled={true}\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n />\n {overlay}\n </div>\n );\n}\n\nfunction CategoriesTreeNodeRenderer(props: PresentationTreeNodeRendererProps & { density?: \"default\" | \"enlarged\" }) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n />\n );\n\n}\n\nfunction useCategoryVisibilityHandler(\n viewManager: ViewManager,\n imodel: IModelConnection,\n categories: CategoryInfo[],\n activeView: Viewport,\n allViewports?: boolean,\n visibilityHandler?: CategoryVisibilityHandler,\n) {\n const [state, setState] = useState<CategoryVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler) {\n return;\n }\n\n const defaultHandler = new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports });\n setState(defaultHandler);\n return () => {\n defaultHandler.dispose();\n };\n }, [viewManager, imodel, categories, activeView, allViewports, visibilityHandler]);\n\n return visibilityHandler ?? state;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n const viewType = view.is3d() ? \"3d\" : \"2d\";\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
1
+ {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,4DAAoC;AACpC,iCAAyD;AACzD,8DAAwD;AACxD,wDAAiD;AACjD,4EAAkE;AAClE,wEAA4D;AAC5D,oDAAiD;AACjD,yDAAgE;AAChE,uEAAoE;AACpE,+EAA4E;AAC5E,6EAA0E;AAC1E,2CAAwG;AACxG,sEAA6I;AAC7I,uEAAoE;AACpE,2EAAwE;AAQxE,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;GAGG;AACU,QAAA,kBAAkB,GAAY,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,yDAAyD;AA6ClI;;;GAGG;AACH,SAAgB,YAAY,CAAC,KAAwB;IACnD,uBAAuB;IACvB,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,yBAAS,CAAC,WAAW,CAAC;IAC/D,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,yBAAyB,EAAE,eAAe,EAAE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAE5J,MAAM,iBAAiB,GAAG,4BAA4B,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,yBAAyB,CAAC,CAAC;IACzJ,MAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,CAAC,YAAoD,EAAE,YAAqB,EAAE,EAAE;QAC9E,IAAI,eAAe,IAAI,YAAY,IAAI,YAAY,KAAK,SAAS,EAAE;YACjE,eAAe,CAAC,YAAY,EA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oCAAY,CAAC,YAAY,CAAC,IAAI,CAAC,0BAAkB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAED,MAAM,qBAAqB,GAAG,IAAA,yCAAiC,EAAC,CAAC,0CAAkC,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { PresentationTree } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoriesTreeComponent } from \"./CategoriesTreeComponent\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { FilterableTreeNodeRendererProps } from \"../common/TreeRenderer\";\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES: Ruleset = require(\"./Categories.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps extends BaseFilterableTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Callback that is invoked when performance of tracked feature is measured.\n * @param featureId ID of the feature.\n * @param elapsedTime Elapsed time of the feature.\n * @beta\n */\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n /**\n * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig, onPerformanceMeasured, onFeatureUsed } = props;\n\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n },\n [onFilterApplied],\n );\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: CategoriesTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: CategoriesTreeComponent.id,\n onPerformanceMeasured,\n });\n\n const state = useVisibilityTreeState({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n visibilityHandler,\n customizeTreeNodeItem,\n filterInfo: props.filterInfo,\n onFilterChange,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n onNodeLoaded,\n reportUsage,\n });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n reportUsage,\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\n onVisibilityToggled: () => reportUsage({ featureId: \"visibility-change\", reportInteraction: true }),\n },\n };\n\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />\n );\n }, []);\n\n if (!state) {\n return null;\n }\n\n const isFilterApplied = state.filteringResult?.filteredProvider !== undefined;\n const overlay = state.filteringResult?.isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n return (\n <div className={classNames(\"tree-widget-visibility-tree-base\", \"tree-widget-tree-container\")}>\n <PresentationTree\n width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <CategoriesTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n descriptionsEnabled={true}\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n />\n {overlay}\n </div>\n );\n}\n\ninterface CategoriesTreeNodeRendererProps extends FilterableTreeNodeRendererProps {\n density?: \"default\" | \"enlarged\";\n}\n\nfunction CategoriesTreeNodeRenderer(props: CategoriesTreeNodeRendererProps) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n onVisibilityToggled={() => props.reportUsage?.({ featureId: \"visibility-change\", reportInteraction: true })}\n />\n );\n}\n\nfunction useCategoryVisibilityHandler(\n viewManager: ViewManager,\n imodel: IModelConnection,\n categories: CategoryInfo[],\n activeView: Viewport,\n allViewports?: boolean,\n visibilityHandler?: CategoryVisibilityHandler,\n) {\n const [state, setState] = useState<CategoryVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler) {\n return;\n }\n\n const defaultHandler = new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports });\n setState(defaultHandler);\n return () => {\n defaultHandler.dispose();\n };\n }, [viewManager, imodel, categories, activeView, allViewports, visibilityHandler]);\n\n return visibilityHandler ?? state;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n const viewType = view.is3d() ? \"3d\" : \"2d\";\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
@@ -10,6 +10,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
10
10
  * See LICENSE.md in the project root for license terms and full copyright notice.
11
11
  *--------------------------------------------------------------------------------------------*/
12
12
  require("../VisibilityTreeBase.scss");
13
+ const classnames_1 = __importDefault(require("classnames"));
13
14
  const react_1 = require("react");
14
15
  const appui_react_1 = require("@itwin/appui-react");
15
16
  const core_frontend_1 = require("@itwin/core-frontend");
@@ -22,7 +23,6 @@ const TreeFilteringState_1 = require("../../TreeFilteringState");
22
23
  const AutoSizer_1 = require("../../utils/AutoSizer");
23
24
  const CategoriesTree_1 = require("./CategoriesTree");
24
25
  const CategoryVisibilityHandler_1 = require("./CategoryVisibilityHandler");
25
- const classnames_1 = __importDefault(require("classnames"));
26
26
  /**
27
27
  * A component that renders [[CategoriesTree]] and a header with filtering capabilities
28
28
  * and header buttons.
@@ -78,11 +78,11 @@ function CategoriesTreeComponentImpl(props) {
78
78
  })();
79
79
  }, [filteredProvider]);
80
80
  return ((0, jsx_runtime_1.jsxs)("div", { className: "tree-widget-tree-with-header", children: [(0, jsx_runtime_1.jsx)(TreeHeader_1.TreeHeader, { onFilterClear: searchOptions.onFilterCancel, onFilterStart: searchOptions.onFilterStart, onSelectedChanged: searchOptions.onResultSelectedChanged, resultCount: searchOptions.matchedResultCount, selectedIndex: searchOptions.activeMatchIndex, density: props.density, children: props.headerButtons
81
- ? props.headerButtons.map((btn, index) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: btn({ viewport: props.viewport, categories, filteredCategories }) }, index))
81
+ ? props.headerButtons.map((btn, index) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: btn({ viewport: props.viewport, categories, filteredCategories, density: props.density, onFeatureUsed: props.onFeatureUsed }) }, index)))
82
82
  : [
83
- (0, jsx_runtime_1.jsx)(ShowAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density }, "show-all-btn"),
84
- (0, jsx_runtime_1.jsx)(HideAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density }, "hide-all-btn"),
85
- (0, jsx_runtime_1.jsx)(InvertAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density }, "invert-all-btn"),
83
+ (0, jsx_runtime_1.jsx)(ShowAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density, onFeatureUsed: props.onFeatureUsed }, "show-all-btn"),
84
+ (0, jsx_runtime_1.jsx)(HideAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density, onFeatureUsed: props.onFeatureUsed }, "hide-all-btn"),
85
+ (0, jsx_runtime_1.jsx)(InvertAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density, onFeatureUsed: props.onFeatureUsed }, "invert-all-btn"),
86
86
  ] }), (0, jsx_runtime_1.jsx)("div", { className: contentClassName, children: (0, jsx_runtime_1.jsx)(AutoSizer_1.AutoSizer, { children: ({ width, height }) => ((0, jsx_runtime_1.jsx)(CategoriesTree_1.CategoryTree, { ...props, categories: categories, width: width, height: height, filterInfo: { filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }, onFilterApplied: onFilterApplied, activeView: props.viewport })) }) })] }));
87
87
  }
88
88
  async function getFilteredCategories(filteredProvider) {
@@ -103,12 +103,21 @@ async function getFilteredCategories(filteredProvider) {
103
103
  return filteredCategories;
104
104
  }
105
105
  function ShowAllButton(props) {
106
- return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("showAll"), onClick: () => void (0, CategoryVisibilityHandler_1.showAllCategories)((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport), children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) }));
106
+ return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("showAll"), onClick: () => {
107
+ props.onFeatureUsed?.(`${exports.CategoriesTreeComponent.id}-showall`);
108
+ void (0, CategoryVisibilityHandler_1.showAllCategories)((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport);
109
+ }, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) }));
107
110
  }
108
111
  function HideAllButton(props) {
109
- return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("hideAll"), onClick: () => void (0, CategoryVisibilityHandler_1.hideAllCategories)((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport), children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}) }));
112
+ return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("hideAll"), onClick: () => {
113
+ props.onFeatureUsed?.(`${exports.CategoriesTreeComponent.id}-hideall`);
114
+ void (0, CategoryVisibilityHandler_1.hideAllCategories)((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport);
115
+ }, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}) }));
110
116
  }
111
117
  function InvertAllButton(props) {
112
- return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { title: TreeWidget_1.TreeWidget.translate("invert"), size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", onClick: () => void (0, CategoryVisibilityHandler_1.invertAllCategories)(props.filteredCategories ?? props.categories, props.viewport), children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHalf, {}) }));
118
+ return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { title: TreeWidget_1.TreeWidget.translate("invert"), size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", onClick: () => {
119
+ props.onFeatureUsed?.(`${exports.CategoriesTreeComponent.id}-invert`);
120
+ void (0, CategoryVisibilityHandler_1.invertAllCategories)(props.filteredCategories ?? props.categories, props.viewport);
121
+ }, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHalf, {}) }));
113
122
  }
114
123
  //# sourceMappingURL=CategoriesTreeComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree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AC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EACrF,KAAK,CAAC,QAAQ,CACf,YAGH,uBAAC,uCAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAsC;IAC7D,OAAO,CACL,uBAAC,0BAAU,IACT,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,EACrC,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAA,+CAAmB,EAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,YAErG,uBAAC,uCAAiB,KAAG,GACV,CACd,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 \"../VisibilityTreeBase.scss\";\nimport { Fragment, useEffect, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { CategoryTree } from \"./CategoriesTree\";\nimport { CategoryVisibilityHandler, hideAllCategories, invertAllCategories, showAllCategories, useCategories } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { CategoryTreeProps } from \"./CategoriesTree\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\nimport classNames from \"classnames\";\n\n/**\n * Props that get passed to [[CategoriesTreeComponent]] header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n /** In case the tree is filtered, a list of filtered categories. */\n filteredCategories?: CategoryInfo[];\n}\n\n/**\n * Props for [[CategoriesTreeComponent]].\n * @public\n */\nexport interface CategoriesTreeComponentProps\n extends Omit<\n CategoryTreeProps,\n \"iModel\" | \"activeView\" | \"width\" | \"height\" | \"filterInfo\" | \"onFilterApplied\" | \"categories\" | \"categoryVisibilityHandler\" | \"viewManager\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * CategoriesTreeComponent.ShowAllButton,\n * CategoriesTreeComponent.HideAllButton,\n * CategoriesTreeComponent.InvertAllButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[CategoriesTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const CategoriesTreeComponent = (props: CategoriesTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all categories and their subcategories.\n * @public\n */\nCategoriesTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all categories.\n * @public\n */\nCategoriesTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all categories.\n * @public\n */\nCategoriesTreeComponent.InvertAllButton = InvertAllButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nCategoriesTreeComponent.id = \"categories-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nCategoriesTreeComponent.getLabel = () => TreeWidget.translate(\"categories\");\n\nfunction CategoriesTreeComponentImpl(props: CategoriesTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const categories = useCategories(IModelApp.viewManager, props.iModel, props.viewport);\n const [filteredCategories, setFilteredCategories] = useState<CategoryInfo[]>();\n const { searchOptions, filterString, onFilterApplied, filteredProvider } = useTreeFilteringState();\n const contentClassName = classNames(\"tree-widget-tree-content\", props.density === \"enlarged\" && \"enlarge\");\n\n useEffect(() => {\n void (async () => {\n if (filteredProvider) {\n setFilteredCategories(await getFilteredCategories(filteredProvider));\n } else {\n setFilteredCategories(undefined);\n }\n })();\n }, [filteredProvider]);\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n density={props.density}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) => <Fragment key={index}>{btn({ viewport: props.viewport, categories, filteredCategories })}</Fragment>)\n : [\n <ShowAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"show-all-btn\"\n density={props.density}\n />,\n <HideAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"hide-all-btn\"\n density={props.density}\n />,\n <InvertAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"invert-all-btn\"\n density={props.density}\n />,\n ]}\n </TreeHeader>\n <div className={contentClassName}>\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n categories={categories}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n activeView={props.viewport}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nasync function getFilteredCategories(filteredProvider: IPresentationTreeDataProvider) {\n const filteredCategories: CategoryInfo[] = [];\n const nodes = await filteredProvider.getNodes();\n for (const node of nodes) {\n if (!isPresentationTreeNodeItem(node)) {\n continue;\n }\n const filteredCategoryId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(node.key);\n const filteredSubCategoriesIds = node.hasChildren\n ? (await filteredProvider.getNodes(node))\n .filter(isPresentationTreeNodeItem)\n .map((child) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(child.key))\n : [];\n filteredCategories.push({ categoryId: filteredCategoryId, subCategoryIds: filteredSubCategoriesIds });\n }\n return filteredCategories;\n}\n\nfunction ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() =>\n void showAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n )\n }\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() =>\n void hideAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n )\n }\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n title={TreeWidget.translate(\"invert\")}\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => void invertAllCategories(props.filteredCategories ?? props.categories, props.viewport)}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n"]}
1
+ {"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,4DAAoC;AACpC,iCAAsD;AACtD,oDAAkF;AAClF,wDAAiD;AACjD,oEAAqG;AACrG,wDAAkD;AAClD,4EAA4E;AAC5E,oDAAiD;AACjD,6DAA0D;AAC1D,iEAAiE;AACjE,qDAAkD;AAClD,qDAAgD;AAChD,2EAAkJ;AAyClJ;;;;GAIG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAAmC,EAAE,EAAE;IAC7E,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAA,+BAAiB,GAAE,CAAC;IAErC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,uBAAC,2BAA2B,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;AACxF,CAAC,CAAC;AATW,QAAA,uBAAuB,2BASlC;AAEF;;;GAGG;AACH,+BAAuB,CAAC,aAAa,GAAG,aAAa,CAAC;AAEtD;;;GAGG;AACH,+BAAuB,CAAC,aAAa,GAAG,aAAa,CAAC;AAEtD;;;GAGG;AACH,+BAAuB,CAAC,eAAe,GAAG,eAAe,CAAC;AAE1D;;;GAGG;AACH,+BAAuB,CAAC,EAAE,GAAG,iBAAiB,CAAC;AAE/C;;;GAGG;AACH,+BAAuB,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,uBAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAE5E,SAAS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CAAC,YAED,uBAAC,uCAAiB,KAAG,GACV,CACd,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 \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { Fragment, useEffect, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { CategoryTree } from \"./CategoriesTree\";\nimport { CategoryVisibilityHandler, hideAllCategories, invertAllCategories, showAllCategories, useCategories } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { CategoryTreeProps } from \"./CategoriesTree\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\n/**\n * Props that get passed to [[CategoriesTreeComponent]] header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n /** In case the tree is filtered, a list of filtered categories. */\n filteredCategories?: CategoryInfo[];\n}\n\n/**\n * Props for [[CategoriesTreeComponent]].\n * @public\n */\nexport interface CategoriesTreeComponentProps\n extends Omit<\n CategoryTreeProps,\n \"iModel\" | \"activeView\" | \"width\" | \"height\" | \"filterInfo\" | \"onFilterApplied\" | \"categories\" | \"categoryVisibilityHandler\" | \"viewManager\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * CategoriesTreeComponent.ShowAllButton,\n * CategoriesTreeComponent.HideAllButton,\n * CategoriesTreeComponent.InvertAllButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[CategoriesTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const CategoriesTreeComponent = (props: CategoriesTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all categories and their subcategories.\n * @public\n */\nCategoriesTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all categories.\n * @public\n */\nCategoriesTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all categories.\n * @public\n */\nCategoriesTreeComponent.InvertAllButton = InvertAllButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nCategoriesTreeComponent.id = \"categories-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nCategoriesTreeComponent.getLabel = () => TreeWidget.translate(\"categories\");\n\nfunction CategoriesTreeComponentImpl(props: CategoriesTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const categories = useCategories(IModelApp.viewManager, props.iModel, props.viewport);\n const [filteredCategories, setFilteredCategories] = useState<CategoryInfo[]>();\n const { searchOptions, filterString, onFilterApplied, filteredProvider } = useTreeFilteringState();\n const contentClassName = classNames(\"tree-widget-tree-content\", props.density === \"enlarged\" && \"enlarge\");\n\n useEffect(() => {\n void (async () => {\n if (filteredProvider) {\n setFilteredCategories(await getFilteredCategories(filteredProvider));\n } else {\n setFilteredCategories(undefined);\n }\n })();\n }, [filteredProvider]);\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n density={props.density}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) => (\n <Fragment key={index}>\n {btn({ viewport: props.viewport, categories, filteredCategories, density: props.density, onFeatureUsed: props.onFeatureUsed })}\n </Fragment>\n ))\n : [\n <ShowAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"show-all-btn\"\n density={props.density}\n onFeatureUsed={props.onFeatureUsed}\n />,\n <HideAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"hide-all-btn\"\n density={props.density}\n onFeatureUsed={props.onFeatureUsed}\n />,\n <InvertAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"invert-all-btn\"\n density={props.density}\n onFeatureUsed={props.onFeatureUsed}\n />,\n ]}\n </TreeHeader>\n <div className={contentClassName}>\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n categories={categories}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n activeView={props.viewport}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nasync function getFilteredCategories(filteredProvider: IPresentationTreeDataProvider) {\n const filteredCategories: CategoryInfo[] = [];\n const nodes = await filteredProvider.getNodes();\n for (const node of nodes) {\n if (!isPresentationTreeNodeItem(node)) {\n continue;\n }\n const filteredCategoryId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(node.key);\n const filteredSubCategoriesIds = node.hasChildren\n ? (await filteredProvider.getNodes(node))\n .filter(isPresentationTreeNodeItem)\n .map((child) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(child.key))\n : [];\n filteredCategories.push({ categoryId: filteredCategoryId, subCategoryIds: filteredSubCategoriesIds });\n }\n return filteredCategories;\n}\n\nfunction ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() => {\n props.onFeatureUsed?.(`${CategoriesTreeComponent.id}-showall`);\n void showAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() => {\n props.onFeatureUsed?.(`${CategoriesTreeComponent.id}-hideall`);\n void hideAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n title={TreeWidget.translate(\"invert\")}\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => {\n props.onFeatureUsed?.(`${CategoriesTreeComponent.id}-invert`);\n void invertAllCategories(props.filteredCategories ?? props.categories, props.viewport);\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import { TreeEventHandler } from "@itwin/components-react";
2
+ import type { AbstractTreeNodeLoaderWithProvider, TreeCheckboxStateChangeEventArgs, TreeNodeEventArgs, TreeSelectionModificationEventArgs, TreeSelectionReplacementEventArgs } from "@itwin/components-react";
3
+ import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
4
+ export interface ReportingTreeEventHandlerProps {
5
+ nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;
6
+ eventHandler: TreeEventHandler;
7
+ reportUsage: (props: {
8
+ reportInteraction: boolean;
9
+ }) => void;
10
+ }
11
+ export declare class ReportingTreeEventHandler extends TreeEventHandler {
12
+ protected _eventHandler: TreeEventHandler;
13
+ protected _reportUsage: (props: {
14
+ reportInteraction: boolean;
15
+ }) => void;
16
+ constructor(props: ReportingTreeEventHandlerProps);
17
+ dispose(): void;
18
+ onNodeExpanded(props: TreeNodeEventArgs): void;
19
+ onNodeCollapsed(props: TreeNodeEventArgs): void;
20
+ onSelectionModified(props: TreeSelectionModificationEventArgs): import("@itwin/components-react").Subscription | undefined;
21
+ onSelectionReplaced(props: TreeSelectionReplacementEventArgs): import("@itwin/components-react").Subscription | undefined;
22
+ onCheckboxStateChanged(props: TreeCheckboxStateChangeEventArgs): import("@itwin/components-react").Subscription | undefined;
23
+ onDelayedNodeClick(props: TreeNodeEventArgs): void;
24
+ onNodeDoubleClick(props: TreeNodeEventArgs): void;
25
+ onNodeEditorActivated(props: TreeNodeEventArgs): void;
26
+ }
27
+ //# sourceMappingURL=ReportingTreeEventHandler.d.ts.map
@@ -0,0 +1,51 @@
1
+ "use strict";
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
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ReportingTreeEventHandler = void 0;
8
+ const components_react_1 = require("@itwin/components-react");
9
+ class ReportingTreeEventHandler extends components_react_1.TreeEventHandler {
10
+ constructor(props) {
11
+ super({ modelSource: props.nodeLoader.modelSource, nodeLoader: props.nodeLoader });
12
+ this._eventHandler = props.eventHandler;
13
+ this._reportUsage = props.reportUsage;
14
+ }
15
+ dispose() {
16
+ this._eventHandler.dispose();
17
+ super.dispose();
18
+ }
19
+ onNodeExpanded(props) {
20
+ this._reportUsage({ reportInteraction: true });
21
+ this._eventHandler.onNodeExpanded(props);
22
+ }
23
+ onNodeCollapsed(props) {
24
+ this._reportUsage({ reportInteraction: true });
25
+ this._eventHandler.onNodeCollapsed(props);
26
+ }
27
+ onSelectionModified(props) {
28
+ this._reportUsage({ reportInteraction: true });
29
+ return this._eventHandler.onSelectionModified(props);
30
+ }
31
+ onSelectionReplaced(props) {
32
+ this._reportUsage({ reportInteraction: true });
33
+ return this._eventHandler.onSelectionReplaced(props);
34
+ }
35
+ onCheckboxStateChanged(props) {
36
+ return this._eventHandler.onCheckboxStateChanged(props);
37
+ }
38
+ onDelayedNodeClick(props) {
39
+ this._eventHandler.onDelayedNodeClick(props);
40
+ }
41
+ onNodeDoubleClick(props) {
42
+ this._reportUsage({ reportInteraction: true });
43
+ this._eventHandler.onNodeDoubleClick(props);
44
+ }
45
+ onNodeEditorActivated(props) {
46
+ this._reportUsage({ reportInteraction: true });
47
+ this._eventHandler.onNodeEditorActivated(props);
48
+ }
49
+ }
50
+ exports.ReportingTreeEventHandler = ReportingTreeEventHandler;
51
+ //# sourceMappingURL=ReportingTreeEventHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReportingTreeEventHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/ReportingTreeEventHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,8DAA2D;AAgB3D,MAAa,yBAA0B,SAAQ,mCAAgB;IAI7D,YAAY,KAAqC;QAC/C,KAAK,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,IAAI,CAA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iB,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAEe,qBAAqB,CAAC,KAAwB;QAC5D,IAAI,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;CACF;AApDD,8DAoDC","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 { TreeEventHandler } from \"@itwin/components-react\";\n\nimport type {\n AbstractTreeNodeLoaderWithProvider,\n TreeCheckboxStateChangeEventArgs,\n TreeNodeEventArgs,\n TreeSelectionModificationEventArgs,\n TreeSelectionReplacementEventArgs,\n} from \"@itwin/components-react\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nexport interface ReportingTreeEventHandlerProps {\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;\n eventHandler: TreeEventHandler;\n reportUsage: (props: { reportInteraction: boolean }) => void;\n}\n\nexport class ReportingTreeEventHandler extends TreeEventHandler {\n protected _eventHandler: TreeEventHandler;\n protected _reportUsage: (props: { reportInteraction: boolean }) => void;\n\n constructor(props: ReportingTreeEventHandlerProps) {\n super({ modelSource: props.nodeLoader.modelSource, nodeLoader: props.nodeLoader });\n this._eventHandler = props.eventHandler;\n this._reportUsage = props.reportUsage;\n }\n\n public dispose() {\n this._eventHandler.dispose();\n super.dispose();\n }\n\n public override onNodeExpanded(props: TreeNodeEventArgs) {\n this._reportUsage({ reportInteraction: true });\n this._eventHandler.onNodeExpanded(props);\n }\n\n public override onNodeCollapsed(props: TreeNodeEventArgs) {\n this._reportUsage({ reportInteraction: true });\n this._eventHandler.onNodeCollapsed(props);\n }\n\n public override onSelectionModified(props: TreeSelectionModificationEventArgs) {\n this._reportUsage({ reportInteraction: true });\n return this._eventHandler.onSelectionModified(props);\n }\n\n public override onSelectionReplaced(props: TreeSelectionReplacementEventArgs) {\n this._reportUsage({ reportInteraction: true });\n return this._eventHandler.onSelectionReplaced(props);\n }\n\n public override onCheckboxStateChanged(props: TreeCheckboxStateChangeEventArgs) {\n return this._eventHandler.onCheckboxStateChanged(props);\n }\n\n public override onDelayedNodeClick(props: TreeNodeEventArgs) {\n this._eventHandler.onDelayedNodeClick(props);\n }\n\n public override onNodeDoubleClick(props: TreeNodeEventArgs) {\n this._reportUsage({ reportInteraction: true });\n this._eventHandler.onNodeDoubleClick(props);\n }\n\n public override onNodeEditorActivated(props: TreeNodeEventArgs) {\n this._reportUsage({ reportInteraction: true });\n this._eventHandler.onNodeEditorActivated(props);\n }\n}\n"]}
@@ -4,6 +4,7 @@ import type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps }
4
4
  import type { AbstractTreeNodeLoaderWithProvider, TreeRendererProps as ComponentsTreeRendererProps } from "@itwin/components-react";
5
5
  import type { TreeNodeRendererProps } from "./TreeNodeRenderer";
6
6
  import type { TreeContextMenuProps } from "./ContextMenu";
7
+ import type { UsageTrackedFeatures } from "./UseFeatureReporting";
7
8
  /**
8
9
  * Base props for [[TreeRenderer]] component.
9
10
  * @public
@@ -24,17 +25,31 @@ export type TreeRendererProps = ComponentsTreeRendererProps & TreeRendererBasePr
24
25
  * @public
25
26
  */
26
27
  export declare function TreeRenderer({ contextMenuItems, nodeRenderer, nodeLabelRenderer, density, ...restProps }: TreeRendererProps): JSX.Element;
28
+ /**
29
+ * Props for [[FilterableTreeRenderer]] node renderer.
30
+ * @beta
31
+ */
32
+ export interface FilterableTreeNodeRendererProps extends PresentationTreeNodeRendererProps {
33
+ reportUsage?: (props: {
34
+ featureId?: UsageTrackedFeatures;
35
+ reportInteraction: boolean;
36
+ }) => void;
37
+ }
27
38
  /**
28
39
  * Props for [[FilterableTreeRenderer]] component.
29
40
  * @beta
30
41
  */
31
42
  export interface FilterableTreeRendererProps extends Omit<TreeRendererProps, "nodeLoader" | "nodeRenderer"> {
32
43
  nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;
33
- nodeRenderer: (props: PresentationTreeNodeRendererProps) => React.ReactNode;
44
+ nodeRenderer: (props: FilterableTreeNodeRendererProps) => React.ReactNode;
45
+ reportUsage?: (props: {
46
+ featureId?: UsageTrackedFeatures;
47
+ reportInteraction: boolean;
48
+ }) => void;
34
49
  }
35
50
  /**
36
51
  * Base tree renderer for trees with enabled hierarchy level filtering.
37
52
  * @beta
38
53
  */
39
- export declare function FilterableTreeRenderer({ nodeRenderer, nodeLoader, ...restProps }: FilterableTreeRendererProps): JSX.Element;
54
+ export declare function FilterableTreeRenderer({ nodeRenderer, nodeLoader, reportUsage, ...restProps }: FilterableTreeRendererProps): JSX.Element;
40
55
  //# sourceMappingURL=TreeRenderer.d.ts.map
@@ -33,10 +33,26 @@ exports.TreeRenderer = TreeRenderer;
33
33
  * Base tree renderer for trees with enabled hierarchy level filtering.
34
34
  * @beta
35
35
  */
36
- function FilterableTreeRenderer({ nodeRenderer, nodeLoader, ...restProps }) {
37
- const { onClearFilterClick, onFilterClick, filterDialog } = (0, presentation_components_1.useFilterablePresentationTree)({ nodeLoader });
36
+ function FilterableTreeRenderer({ nodeRenderer, nodeLoader, reportUsage, ...restProps }) {
37
+ const { onClearFilterClick, onFilterClick, filterDialog } = (0, presentation_components_1.useFilterablePresentationTree)({
38
+ nodeLoader,
39
+ onFilterApplied: () => {
40
+ reportUsage?.({ featureId: "hierarchy-level-filtering", reportInteraction: true });
41
+ },
42
+ });
38
43
  return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(TreeRenderer, { ...restProps, nodeLoader: nodeLoader, nodeRenderer: (props) => {
39
- return nodeRenderer({ ...props, onClearFilterClick, onFilterClick });
44
+ return nodeRenderer({
45
+ ...props,
46
+ reportUsage,
47
+ onFilterClick: (nodeId) => {
48
+ reportUsage?.({ reportInteraction: true });
49
+ onFilterClick(nodeId);
50
+ },
51
+ onClearFilterClick: (nodeId) => {
52
+ reportUsage?.({ reportInteraction: true });
53
+ onClearFilterClick(nodeId);
54
+ },
55
+ });
40
56
  } }), filterDialog] }));
41
57
  }
42
58
  exports.FilterableTreeRenderer = FilterableTreeRenderer;
@@ -1 +1 @@
1
- {"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/TreeRenderer.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,+BAA6B;AAC7B,4DAAoC;AACpC,8DAAmG;AACnG,4EAA+E;AAC/E,+CAA+C;AAC/C,yDAAqE;AAuBrE;;;GAGG;AACH,SAAgB,YAAY,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,SAAS,EAAqB;IAC1H,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,IAAA,4BAAc,EAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAElF,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,IAAA,oBAAU,EAAC,6BAA6B,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,UAAU,EAAE,CAAC,CAAC;IAErG,OAAO,CACL,iCAAK,SAAS,EAAE,SAAS,aACvB,uBAAC,+BAAsB,OACjB,SAAS,EACb,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE;oBAC1B,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;oBACxF,OAAO,CACL,uBAAC,kDAA+B,IAAC,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,iBAAiB,EAAE,iBAAiB,YACxF,YAAY,CAAC,CAAC,CAAC,CACd,YAAY,CAAC,EAAE,GAAG,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CACxE,CAAC,CAAC,CAAC,CACF,uBAAC,mCAAgB,OAAK,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,GAAI,CAC5F,GAC+B,CACnC,CAAC;gBACJ,CAAC,EACD,UAAU,EAAE,UAAU,GACtB,EACD,iBAAiB,EAAE,IAChB,CACP,CAAC;AACJ,CAAC;AA3BD,oCA2BC;AAUD;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,SAAS,EAA+B;IAC5G,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,IAAA,uDAA6B,EAAC,EAAE,UAAU,EAAE,CAAC,CAAC;IAE1G,OAAO,CACL,4CACE,uBAAC,YAAY,OACP,SAAS,EACb,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;oBACtB,OAAO,YAAY,CAAC,EAAE,GAAG,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAC,CAAC;gBACvE,CAAC,GACD,EACD,YAAY,IACT,CACP,CAAC;AACJ,CAAC;AAfD,wDAeC;AAED,SAAS,aAAa,CAAC,OAA+B,EAAE,aAAwD;IAC9G,QAAQ,OAAO,EAAE;QACf,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC;QACvB,KAAK,UAAU;YACb,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC;KACnB;AACH,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 \"./TreeRenderer.scss\";\nimport classNames from \"classnames\";\nimport { TreeRenderer as ComponentsTreeRenderer, TreeNodeRenderer } from \"@itwin/components-react\";\nimport { useFilterablePresentationTree } from \"@itwin/presentation-components\";\nimport { useContextMenu } from \"./ContextMenu\";\nimport { TreeNodeRendererContextProvider } from \"./TreeNodeRenderer\";\n\nimport type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { AbstractTreeNodeLoaderWithProvider, TreeRendererProps as ComponentsTreeRendererProps } from \"@itwin/components-react\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer\";\nimport type { TreeContextMenuProps } from \"./ContextMenu\";\n/**\n * Base props for [[TreeRenderer]] component.\n * @public\n */\nexport interface TreeRendererBaseProps extends TreeContextMenuProps, TreeNodeRendererProps {\n /**\n * Modifies the density of tree nodes. `enlarged` tree nodes have bigger height and bigger button hit boxes.\n */\n density?: \"default\" | \"enlarged\";\n}\n\n/**\n * Props for [[TreeRenderer]] component.\n * @public\n */\nexport type TreeRendererProps = ComponentsTreeRendererProps & TreeRendererBaseProps;\n\n/**\n * Base tree renderer for visibility trees.\n * @public\n */\nexport function TreeRenderer({ contextMenuItems, nodeRenderer, nodeLabelRenderer, density, ...restProps }: TreeRendererProps) {\n const { onContextMenu, renderContextMenu } = useContextMenu({ contextMenuItems });\n\n const nodeHeight = getNodeHeight(density ?? \"default\", restProps.nodeHeight);\n const className = classNames(\"tree-widget-tree-nodes-list\", { [\"enlarge\"]: density === \"enlarged\" });\n\n return (\n <div className={className}>\n <ComponentsTreeRenderer\n {...restProps}\n nodeRenderer={(nodeProps) => {\n const nodeClassName = nodeProps.node.numChildren === 0 ? \"without-expander\" : undefined;\n return (\n <TreeNodeRendererContextProvider node={nodeProps.node} nodeLabelRenderer={nodeLabelRenderer}>\n {nodeRenderer ? (\n nodeRenderer({ ...nodeProps, onContextMenu, className: nodeClassName })\n ) : (\n <TreeNodeRenderer {...nodeProps} onContextMenu={onContextMenu} className={nodeClassName} />\n )}\n </TreeNodeRendererContextProvider>\n );\n }}\n nodeHeight={nodeHeight}\n />\n {renderContextMenu()}\n </div>\n );\n}\n\n/**\n * Props for [[FilterableTreeRenderer]] component.\n * @beta\n */\nexport interface FilterableTreeRendererProps extends Omit<TreeRendererProps, \"nodeLoader\" | \"nodeRenderer\"> {\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;\n nodeRenderer: (props: PresentationTreeNodeRendererProps) => React.ReactNode;\n}\n/**\n * Base tree renderer for trees with enabled hierarchy level filtering.\n * @beta\n */\nexport function FilterableTreeRenderer({ nodeRenderer, nodeLoader, ...restProps }: FilterableTreeRendererProps) {\n const { onClearFilterClick, onFilterClick, filterDialog } = useFilterablePresentationTree({ nodeLoader });\n\n return (\n <div>\n <TreeRenderer\n {...restProps}\n nodeLoader={nodeLoader}\n nodeRenderer={(props) => {\n return nodeRenderer({ ...props, onClearFilterClick, onFilterClick });\n }}\n />\n {filterDialog}\n </div>\n );\n}\n\nfunction getNodeHeight(density: \"default\" | \"enlarged\", defaultHeight: ComponentsTreeRendererProps[\"nodeHeight\"]) {\n switch (density) {\n case \"default\":\n return defaultHeight;\n case \"enlarged\":\n return () => 43;\n }\n}\n"]}
1
+ {"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/TreeRenderer.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,+BAA6B;AAC7B,4DAAoC;AACpC,8DAAmG;AACnG,4EAA+E;AAC/E,+CAA+C;AAC/C,yDAAqE;AAwBrE;;;GAGG;AACH,SAAgB,YAAY,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,SAAS,EAAqB;IAC1H,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,IAAA,4BAAc,EAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAElF,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,IAAA,oBAAU,EAAC,6BAA6B,EAAE,EAA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AO,YAAY,CAAC;wBAClB,GAAG,KAAK;wBACR,WAAW;wBACX,aAAa,EAAE,CAAC,MAAc,EAAE,EAAE;4BAChC,WAAW,EAAE,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;4BAC3C,aAAa,CAAC,MAAM,CAAC,CAAC;wBACxB,CAAC;wBACD,kBAAkB,EAAE,CAAC,MAAc,EAAE,EAAE;4BACrC,WAAW,EAAE,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;4BAC3C,kBAAkB,CAAC,MAAM,CAAC,CAAC;wBAC7B,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC,GACD,EACD,YAAY,IACT,CACP,CAAC;AACJ,CAAC;AA/BD,wDA+BC;AAED,SAAS,aAAa,CAAC,OAA+B,EAAE,aAAwD;IAC9G,QAAQ,OAAO,EAAE;QACf,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC;QACvB,KAAK,UAAU;YACb,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC;KACnB;AACH,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 \"./TreeRenderer.scss\";\nimport classNames from \"classnames\";\nimport { TreeRenderer as ComponentsTreeRenderer, TreeNodeRenderer } from \"@itwin/components-react\";\nimport { useFilterablePresentationTree } from \"@itwin/presentation-components\";\nimport { useContextMenu } from \"./ContextMenu\";\nimport { TreeNodeRendererContextProvider } from \"./TreeNodeRenderer\";\n\nimport type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { AbstractTreeNodeLoaderWithProvider, TreeRendererProps as ComponentsTreeRendererProps } from \"@itwin/components-react\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer\";\nimport type { TreeContextMenuProps } from \"./ContextMenu\";\nimport type { UsageTrackedFeatures } from \"./UseFeatureReporting\";\n/**\n * Base props for [[TreeRenderer]] component.\n * @public\n */\nexport interface TreeRendererBaseProps extends TreeContextMenuProps, TreeNodeRendererProps {\n /**\n * Modifies the density of tree nodes. `enlarged` tree nodes have bigger height and bigger button hit boxes.\n */\n density?: \"default\" | \"enlarged\";\n}\n\n/**\n * Props for [[TreeRenderer]] component.\n * @public\n */\nexport type TreeRendererProps = ComponentsTreeRendererProps & TreeRendererBaseProps;\n\n/**\n * Base tree renderer for visibility trees.\n * @public\n */\nexport function TreeRenderer({ contextMenuItems, nodeRenderer, nodeLabelRenderer, density, ...restProps }: TreeRendererProps) {\n const { onContextMenu, renderContextMenu } = useContextMenu({ contextMenuItems });\n\n const nodeHeight = getNodeHeight(density ?? \"default\", restProps.nodeHeight);\n const className = classNames(\"tree-widget-tree-nodes-list\", { [\"enlarge\"]: density === \"enlarged\" });\n\n return (\n <div className={className}>\n <ComponentsTreeRenderer\n {...restProps}\n nodeRenderer={(nodeProps) => {\n const nodeClassName = nodeProps.node.numChildren === 0 ? \"without-expander\" : undefined;\n return (\n <TreeNodeRendererContextProvider node={nodeProps.node} nodeLabelRenderer={nodeLabelRenderer}>\n {nodeRenderer ? (\n nodeRenderer({ ...nodeProps, onContextMenu, className: nodeClassName })\n ) : (\n <TreeNodeRenderer {...nodeProps} onContextMenu={onContextMenu} className={nodeClassName} />\n )}\n </TreeNodeRendererContextProvider>\n );\n }}\n nodeHeight={nodeHeight}\n />\n {renderContextMenu()}\n </div>\n );\n}\n\n/**\n * Props for [[FilterableTreeRenderer]] node renderer.\n * @beta\n */\nexport interface FilterableTreeNodeRendererProps extends PresentationTreeNodeRendererProps {\n reportUsage?: (props: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => void;\n}\n\n/**\n * Props for [[FilterableTreeRenderer]] component.\n * @beta\n */\nexport interface FilterableTreeRendererProps extends Omit<TreeRendererProps, \"nodeLoader\" | \"nodeRenderer\"> {\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;\n nodeRenderer: (props: FilterableTreeNodeRendererProps) => React.ReactNode;\n reportUsage?: (props: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => void;\n}\n/**\n * Base tree renderer for trees with enabled hierarchy level filtering.\n * @beta\n */\nexport function FilterableTreeRenderer({ nodeRenderer, nodeLoader, reportUsage, ...restProps }: FilterableTreeRendererProps) {\n const { onClearFilterClick, onFilterClick, filterDialog } = useFilterablePresentationTree({\n nodeLoader,\n onFilterApplied: () => {\n reportUsage?.({ featureId: \"hierarchy-level-filtering\", reportInteraction: true });\n },\n });\n\n return (\n <div>\n <TreeRenderer\n {...restProps}\n nodeLoader={nodeLoader}\n nodeRenderer={(props) => {\n return nodeRenderer({\n ...props,\n reportUsage,\n onFilterClick: (nodeId: string) => {\n reportUsage?.({ reportInteraction: true });\n onFilterClick(nodeId);\n },\n onClearFilterClick: (nodeId: string) => {\n reportUsage?.({ reportInteraction: true });\n onClearFilterClick(nodeId);\n },\n });\n }}\n />\n {filterDialog}\n </div>\n );\n}\n\nfunction getNodeHeight(density: \"default\" | \"enlarged\", defaultHeight: ComponentsTreeRendererProps[\"nodeHeight\"]) {\n switch (density) {\n case \"default\":\n return defaultHeight;\n case \"enlarged\":\n return () => 43;\n }\n}\n"]}
@@ -58,7 +58,7 @@
58
58
 
59
59
  .core-tree-node {
60
60
  &.without-expander {
61
- margin-left: var(--enlarged-node-without-expander-margin);
61
+ margin-left: var(--enlarged-node-without-expander-margin);
62
62
  }
63
63
 
64
64
  > .presentation-components-node-action-buttons {
@@ -0,0 +1,23 @@
1
+ /** @internal */
2
+ export interface UseFeatureReportingProps {
3
+ treeIdentifier: string;
4
+ onFeatureUsed?: (featureId: string) => void;
5
+ }
6
+ /** @internal */
7
+ export interface UseFeatureReportingResult {
8
+ reportUsage: (props: {
9
+ featureId?: UsageTrackedFeatures;
10
+ reportInteraction: boolean;
11
+ }) => void;
12
+ }
13
+ /**
14
+ * Features that are tracked for usage.
15
+ * @internal
16
+ */
17
+ export type UsageTrackedFeatures = "visibility-change" | "hierarchy-level-filtering" | "filtering" | "hierarchy-level-size-limit-hit" | "zoom-to-node";
18
+ /**
19
+ * Enables feature reporting for a tree component.
20
+ * @internal
21
+ */
22
+ export declare function useFeatureReporting(props: UseFeatureReportingProps): UseFeatureReportingResult;
23
+ //# sourceMappingURL=UseFeatureReporting.d.ts.map
@@ -0,0 +1,30 @@
1
+ "use strict";
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
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useFeatureReporting = void 0;
8
+ const react_1 = require("react");
9
+ /**
10
+ * Enables feature reporting for a tree component.
11
+ * @internal
12
+ */
13
+ function useFeatureReporting(props) {
14
+ const { treeIdentifier, onFeatureUsed } = props;
15
+ const onFeatureUsedRef = (0, react_1.useRef)(onFeatureUsed);
16
+ (0, react_1.useEffect)(() => {
17
+ onFeatureUsedRef.current = onFeatureUsed;
18
+ }, [onFeatureUsed]);
19
+ const reportUsage = (0, react_1.useCallback)(({ featureId, reportInteraction }) => {
20
+ if (reportInteraction !== false) {
21
+ onFeatureUsedRef.current?.(`use-${treeIdentifier}`);
22
+ }
23
+ if (featureId) {
24
+ onFeatureUsedRef.current?.(`${treeIdentifier}-${featureId}`);
25
+ }
26
+ }, [treeIdentifier]);
27
+ return { reportUsage };
28
+ }
29
+ exports.useFeatureReporting = useFeatureReporting;
30
+ //# sourceMappingURL=UseFeatureReporting.js.map