@itwin/tree-widget-react 2.3.3 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @itwin/tree-widget-react
2
2
 
3
- This log was last generated on Mon, 29 Jul 2024 14:41:54 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 01 Oct 2024 15:47:35 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.3.4
8
+
9
+ Tue, 01 Oct 2024 15:47:35 GMT
10
+
11
+ ### Patches
12
+
13
+ - Fix visibility eye icon being misaligned when node does not have an expander ([#1058](https://github.com/iTwin/viewer-components-react/pull/1058))
14
+
7
15
  ## 2.3.3
8
16
 
9
- Mon, 29 Jul 2024 14:41:54 GMT
17
+ Mon, 29 Jul 2024 14:42:02 GMT
10
18
 
11
19
  ### Patches
12
20
 
@@ -41,7 +41,7 @@ exports.createVisibilityTreeRenderer = createVisibilityTreeRenderer;
41
41
  function createVisibilityTreeNodeRenderer({ levelOffset = 20, disableRootNodeCollapse = false, descriptionEnabled, iconsEnabled, onVisibilityToggled, }) {
42
42
  return function VisibilityTreeNodeRenderer(treeNodeProps) {
43
43
  const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);
44
- return ((0, jsx_runtime_1.jsx)(components_react_1.TreeNodeRenderer, { ...treeNodeProps, node: { ...treeNodeProps.node, depth: 0, numChildren: 1 }, checkboxRenderer: (checkboxProps) => ((0, jsx_runtime_1.jsx)("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: (0, jsx_runtime_1.jsx)(VisibilityTreeNodeCheckbox, { ...checkboxProps, onVisibilityToggled: onVisibilityToggled }) })), descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: (0, classnames_1.default)("with-checkbox", (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && "disable-expander", treeNodeProps.className) }));
44
+ return ((0, jsx_runtime_1.jsx)(components_react_1.TreeNodeRenderer, { ...treeNodeProps, node: { ...treeNodeProps.node, depth: 0, numChildren: 1 }, checkboxRenderer: (checkboxProps) => ((0, jsx_runtime_1.jsx)("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: (0, jsx_runtime_1.jsx)(VisibilityTreeNodeCheckbox, { ...checkboxProps, onVisibilityToggled: onVisibilityToggled }) })), descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: (0, classnames_1.default)("with-checkbox", (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && "disable-expander") }));
45
45
  };
46
46
  }
47
47
  exports.createVisibilityTreeNodeRenderer = createVisibilityTreeNodeRenderer;
@@ -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;AA6C1C;;;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,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,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"]}
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,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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 )}\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"]}
@@ -34,7 +34,7 @@ export function createVisibilityTreeRenderer({ nodeRendererProps, ...restProps }
34
34
  export function createVisibilityTreeNodeRenderer({ levelOffset = 20, disableRootNodeCollapse = false, descriptionEnabled, iconsEnabled, onVisibilityToggled, }) {
35
35
  return function VisibilityTreeNodeRenderer(treeNodeProps) {
36
36
  const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);
37
- return (_jsx(TreeNodeRenderer, { ...treeNodeProps, node: { ...treeNodeProps.node, depth: 0, numChildren: 1 }, checkboxRenderer: (checkboxProps) => (_jsx("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: _jsx(VisibilityTreeNodeCheckbox, { ...checkboxProps, onVisibilityToggled: onVisibilityToggled }) })), descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: classNames("with-checkbox", (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && "disable-expander", treeNodeProps.className) }));
37
+ return (_jsx(TreeNodeRenderer, { ...treeNodeProps, node: { ...treeNodeProps.node, depth: 0, numChildren: 1 }, checkboxRenderer: (checkboxProps) => (_jsx("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: _jsx(VisibilityTreeNodeCheckbox, { ...checkboxProps, onVisibilityToggled: onVisibilityToggled }) })), descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: classNames("with-checkbox", (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && "disable-expander") }));
38
38
  };
39
39
  }
40
40
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAA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AAM,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;AAWD;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAwC;IACnF,OAAO,CACL,eAAK,SAAS,EAAC,8BAA8B,aAC3C,eAAM,SAAS,EAAC,qBAAqB,YAAE,KAAK,CAAC,KAAK,GAAQ,EAC1D,eAAM,SAAS,EAAC,mBAAmB,YAAE,KAAK,CAAC,OAAO,GAAQ,IACtD,CACP,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 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"]}
1
+ {"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,sCAAsC,EAAE,MAAM,gCAAgC,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAOrD;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAE3C,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;AA6C1C;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,EAAE,iBAAiB,EAAE,GAAG,SAAS,EAA+B;IAC3G,OAAO,SAAS,sBAAsB,CAAC,SAA4B;QACjE,OAAO,KAAC,YAAY,OAAK,SAAS,KAAM,SAAS,EAAE,YAAY,EAAE,gCAAgC,CAAC,iBAAiB,CAAC,GAAI,CAAC;IAC3H,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,EAC/C,WAAW,GAAG,EAAE,EAChB,uBAAuB,GAAG,KAAK,EAC/B,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,GACa;IAChC,OAAO,SAAS,0BAA0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;;;;GAIG;AACH,uBAAuB;AACvB,MAAM,UAAU,0BAA0B,CACxC,UAA6E,EAC7E,UAAqC,EACrC,eAAqG;IAErG,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;IACtG,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,qBAAqB,EAAE,GAAG,sCAAsC,CAAC;QACtH,UAAU;QACV,MAAM;QACN,gBAAgB;KACjB,CAAC,CAAC;IAEH,SAAS,CAAC,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;AAWD;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAwC;IACnF,OAAO,CACL,eAAK,SAAS,EAAC,8BAA8B,aAC3C,eAAM,SAAS,EAAC,qBAAqB,YAAE,KAAK,CAAC,KAAK,GAAQ,EAC1D,eAAM,SAAS,EAAC,mBAAmB,YAAE,KAAK,CAAC,OAAO,GAAQ,IACtD,CACP,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 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 )}\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/tree-widget-react",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "Tree Widget React",
5
5
  "keywords": [
6
6
  "Bentley",