@itwin/presentation-hierarchies-react 2.0.0-alpha.0 → 2.0.0-alpha.1
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 +14 -0
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.d.ts +0 -2
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.js +3 -11
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +2 -3
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies-react
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#860](https://github.com/iTwin/presentation/pull/860): Changes to tree node action buttons related to filtering:
|
|
8
|
+
- Fix filter button style.
|
|
9
|
+
- Removed "reset filter" button. The filter can be reset through the filter editing dialog.
|
|
10
|
+
- [#862](https://github.com/iTwin/presentation/pull/862): Update `@itwin/itwinui-react` dependency to `5.0.0-alpha.3`.
|
|
11
|
+
|
|
12
|
+
This fixes the following issues:
|
|
13
|
+
|
|
14
|
+
- nodes being selected on expand,
|
|
15
|
+
- node action buttons being rendered incorrectly.
|
|
16
|
+
|
|
3
17
|
## 2.0.0-alpha.0
|
|
4
18
|
|
|
5
19
|
### Major Changes
|
|
@@ -9,6 +9,4 @@ export type ActionButtonProps = {
|
|
|
9
9
|
} & Partial<Pick<ReturnType<typeof useTree>, "getHierarchyLevelDetails">>;
|
|
10
10
|
/** @internal */
|
|
11
11
|
export declare function FilterActionButton({ node, onClick, getHierarchyLevelDetails }: ActionButtonProps): import("react/jsx-runtime").JSX.Element | undefined;
|
|
12
|
-
/** @internal */
|
|
13
|
-
export declare function RemoveFilterActionButton({ node, getHierarchyLevelDetails }: ActionButtonProps): import("react/jsx-runtime").JSX.Element | null;
|
|
14
12
|
//# sourceMappingURL=TreeActionButtons.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeActionButtons.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeActionButtons.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAM/D,gBAAgB;AAChB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,oDAAoD;IACpD,IAAI,EAAE,yBAAyB,CAAC;IAChC,yEAAyE;IACzE,OAAO,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;CAClE,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC;AAE1E,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,wBAAwB,EAAE,EAAE,iBAAiB,uDAgBhG
|
|
1
|
+
{"version":3,"file":"TreeActionButtons.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeActionButtons.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAM/D,gBAAgB;AAChB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,oDAAoD;IACpD,IAAI,EAAE,yBAAyB,CAAC;IAChC,yEAAyE;IACzE,OAAO,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;CAClE,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC;AAE1E,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,wBAAwB,EAAE,EAAE,iBAAiB,uDAgBhG"}
|
|
@@ -6,22 +6,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import { IconButton } from "@itwin/itwinui-react/bricks";
|
|
7
7
|
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
8
8
|
const filterIcon = new URL("@itwin/itwinui-icons/filter.svg", import.meta.url).href;
|
|
9
|
-
const
|
|
9
|
+
const activeFilterIcon = new URL("@itwin/itwinui-icons/placeholder.svg", import.meta.url).href; // Placeholder
|
|
10
10
|
/** @internal */
|
|
11
11
|
export function FilterActionButton({ node, onClick, getHierarchyLevelDetails }) {
|
|
12
12
|
const { localizedStrings } = useLocalizationContext();
|
|
13
|
-
return onClick && node.isFilterable ? (_jsx(IconButton, {
|
|
13
|
+
return onClick && node.isFilterable ? (_jsx(IconButton, { variant: "ghost", className: "filtering-action-button", label: localizedStrings.filterHierarchyLevel, onClick: (e) => {
|
|
14
14
|
e.stopPropagation();
|
|
15
15
|
const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);
|
|
16
16
|
hierarchyLevelDetails && onClick(hierarchyLevelDetails);
|
|
17
|
-
}, icon: node.isFiltered ?
|
|
18
|
-
}
|
|
19
|
-
/** @internal */
|
|
20
|
-
export function RemoveFilterActionButton({ node, getHierarchyLevelDetails }) {
|
|
21
|
-
const { localizedStrings } = useLocalizationContext();
|
|
22
|
-
return getHierarchyLevelDetails && node.isFiltered ? (_jsx(IconButton, { style: { position: "relative" }, className: "filtering-action-button", label: localizedStrings.clearHierarchyLevelFilter, onClick: (e) => {
|
|
23
|
-
e.stopPropagation();
|
|
24
|
-
getHierarchyLevelDetails(node.id)?.setInstanceFilter(undefined);
|
|
25
|
-
}, icon: dismissIcon })) : null;
|
|
17
|
+
}, icon: node.isFiltered ? activeFilterIcon : filterIcon })) : undefined;
|
|
26
18
|
}
|
|
27
19
|
//# sourceMappingURL=TreeActionButtons.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeActionButtons.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeActionButtons.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,iCAAiC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AACpF,MAAM,
|
|
1
|
+
{"version":3,"file":"TreeActionButtons.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeActionButtons.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,iCAAiC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AACpF,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,sCAAsC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc;AAU9G,gBAAgB;AAChB,MAAM,UAAU,kBAAkB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,wBAAwB,EAAqB;IAC/F,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IAEtD,OAAO,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CACpC,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,yBAAyB,EACnC,KAAK,EAAE,gBAAgB,CAAC,oBAAoB,EAC5C,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACb,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,MAAM,qBAAqB,GAAG,wBAAwB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAClE,qBAAqB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAC1D,CAAC,EACD,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,GACrD,CACH,CAAC,CAAC,CAAC,SAAS,CAAC;AAChB,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 { IconButton } from \"@itwin/itwinui-react/bricks\";\nimport { PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { HierarchyLevelDetails, useTree } from \"../UseTree.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\nconst filterIcon = new URL(\"@itwin/itwinui-icons/filter.svg\", import.meta.url).href;\nconst activeFilterIcon = new URL(\"@itwin/itwinui-icons/placeholder.svg\", import.meta.url).href; // Placeholder\n\n/** @internal */\nexport type ActionButtonProps = {\n /** Node on which action is going to be performed */\n node: PresentationHierarchyNode;\n /** Action to perform when the filter button is clicked for this node. */\n onClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n} & Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">>;\n\n/** @internal */\nexport function FilterActionButton({ node, onClick, getHierarchyLevelDetails }: ActionButtonProps) {\n const { localizedStrings } = useLocalizationContext();\n\n return onClick && node.isFilterable ? (\n <IconButton\n variant={\"ghost\"}\n className=\"filtering-action-button\"\n label={localizedStrings.filterHierarchyLevel}\n onClick={(e) => {\n e.stopPropagation();\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onClick(hierarchyLevelDetails);\n }}\n icon={node.isFiltered ? activeFilterIcon : filterIcon}\n />\n ) : undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAA2C,YAAY,EAAO,aAAa,EAAuB,MAAM,OAAO,CAAC;AACjJ,OAAO,EAAW,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAA+B,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC9G,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK/D,aAAa;AACb,KAAK,aAAa,GAAG,IAAI,CAAC,wBAAwB,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;AAEjF,aAAa;AACb,MAAM,WAAW,wBAAwB;IACvC,6BAA6B;IAC7B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,yEAAyE;IACzE,aAAa,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACvE,qDAAqD;IACrD,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,yBAAyB,KAAK,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;IACjF,wCAAwC;IACxC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,yBAAyB,KAAK,YAAY,GAAG,SAAS,CAAC;IACzE,yCAAyC;IACzC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,yBAAyB,KAAK,YAAY,GAAG,SAAS,CAAC;IAC5E,kD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AAyB,KAAK,YAAY,CAAC;CACrE;AAED,aAAa;AACb,KAAK,qBAAqB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,YAAY,CAAC,GACzE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,0BAA0B,CAAC,CAAC,GACrE,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,MAAM,CAAC,GACrC,wBAAwB,CAAC;AAE3B;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,yBAAyB,CAAC,qBAAqB,GAAG,aAAa,CAAC,cAAc,CAAC,CA6DnH,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { forwardRef, useCallback, useRef } from "react";
|
|
|
7
7
|
import { Spinner, Tree } from "@itwin/itwinui-react/bricks";
|
|
8
8
|
import { isPresentationHierarchyNode } from "../TreeNode.js";
|
|
9
9
|
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
10
|
-
import { FilterActionButton
|
|
10
|
+
import { FilterActionButton } from "./TreeActionButtons.js";
|
|
11
11
|
import { TreeErrorRenderer } from "./TreeErrorRenderer.js";
|
|
12
12
|
/**
|
|
13
13
|
* A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.
|
|
@@ -22,11 +22,10 @@ export const TreeNodeRenderer = forwardRef(({ node, expandNode, getIcon, getLabe
|
|
|
22
22
|
if (!isPresentationHierarchyNode(node)) {
|
|
23
23
|
return (_jsx(TreeErrorRenderer, { node: node, getHierarchyLevelDetails: getHierarchyLevelDetails, reloadTree: reloadTree, onFilterClick: onFilterClick, ref: ref }));
|
|
24
24
|
}
|
|
25
|
-
const ActionButtons = () => (_jsxs(_Fragment, { children: [actionsRenderer && actionsRenderer(node), _jsx(
|
|
25
|
+
const ActionButtons = () => (_jsxs(_Fragment, { children: [actionsRenderer && actionsRenderer(node), _jsx(FilterActionButton, { node: node, onClick: onFilterClick, getHierarchyLevelDetails: getHierarchyLevelDetails })] }));
|
|
26
26
|
return (_jsx(Tree.Item, { ...treeItemProps, ref: ref, label: getLabel ? getLabel(node) : node.label, selected: selected, expanded: node.isExpanded || node.children === true || node.children.length > 0 ? node.isExpanded : undefined, onExpandedChange: (isExpanded) => {
|
|
27
27
|
expandNode(node.id, isExpanded);
|
|
28
28
|
}, onClick: (event) => {
|
|
29
|
-
event.stopPropagation();
|
|
30
29
|
!treeItemProps["aria-disabled"] && onNodeClick?.(node, !selected, event);
|
|
31
30
|
}, onKeyDown: (event) => {
|
|
32
31
|
// Ignore if it is called on the element inside, e.g. checkbox or expander
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAA4B,UAAU,EAAiE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjJ,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAmD,MAAM,gBAAgB,CAAC;AAE9G,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAA4B,UAAU,EAAiE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjJ,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAmD,MAAM,gBAAgB,CAAC;AAE9G,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM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CAAC,OAAO,EAAE,IAAI,EAAE,KAAC,OAAO,IAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,GAAI,GAAI,CAAC;AACzJ,CAAC,CAAC,CAAC;AACH,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAEhD,SAAS,aAAa,CAAI,GAAG,IAA6D;IACxF,OAAO,WAAW,CAChB,CAAC,QAAkB,EAAE,EAAE;QACrB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;gBAC9B,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChB,CAAC;iBAAM,IAAI,GAAG,EAAE,CAAC;gBACd,GAAkC,CAAC,OAAO,GAAG,QAAQ,CAAC;YACzD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,uDAAuD;IAC1D,CAAC,GAAG,IAAI,CAAC,CACV,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ComponentPropsWithoutRef, forwardRef, LegacyRef, MutableRefObject, ReactElement, Ref, RefAttributes, useCallback, useRef } from \"react\";\nimport { Spinner, Tree } from \"@itwin/itwinui-react/bricks\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode, PresentationTreeNode } from \"../TreeNode.js\";\nimport { HierarchyLevelDetails, useTree } from \"../UseTree.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { FilterActionButton } from \"./TreeActionButtons.js\";\nimport { TreeErrorRenderer } from \"./TreeErrorRenderer.js\";\n\n/** @alpha */\ntype TreeNodeProps = Omit<ComponentPropsWithoutRef<typeof Tree.Item>, \"actions\">;\n\n/** @alpha */\nexport interface TreeNodeRendererOwnProps {\n /** Node that is rendered. */\n node: PresentationTreeNode;\n /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n /** Returns an icon or icon href for a given node. */\n getIcon?: (node: PresentationHierarchyNode) => string | ReactElement | undefined;\n /** Returns a label for a given node. */\n getLabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Returns sublabel for a given node. */\n getSublabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Action to perform when the node is clicked. */\n onNodeClick?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Action to perform when a key is pressed when the node is hovered on. */\n onNodeKeyDown?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree?: (options: { parentNodeId: string | undefined; state: \"reset\" }) => void;\n /** Renderer for additional tree items actions */\n actionsRenderer?: (node: PresentationHierarchyNode) => ReactElement;\n}\n\n/** @alpha */\ntype TreeNodeRendererProps = Pick<ReturnType<typeof useTree>, \"expandNode\"> &\n Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">> &\n Omit<TreeNodeProps, \"label\" | \"icon\"> &\n TreeNodeRendererOwnProps;\n\n/**\n * A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.\n *\n * @see `TreeRenderer`\n * @see https://itwinui.bentley.com/docs/tree\n * @public\n */\nexport const TreeNodeRenderer: React.ForwardRefExoticComponent<TreeNodeRendererProps & RefAttributes<HTMLDivElement>> = forwardRef(\n (\n {\n node,\n expandNode,\n getIcon,\n getLabel,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n selected,\n getHierarchyLevelDetails,\n reloadTree,\n children,\n actionsRenderer,\n ...treeItemProps\n },\n forwardedRef,\n ) => {\n const nodeRef = useRef<HTMLDivElement>(null);\n const ref = useMergedRefs(forwardedRef, nodeRef);\n\n if (!isPresentationHierarchyNode(node)) {\n return (\n <TreeErrorRenderer node={node} getHierarchyLevelDetails={getHierarchyLevelDetails} reloadTree={reloadTree} onFilterClick={onFilterClick} ref={ref} />\n );\n }\n\n const ActionButtons = () => (\n <>\n {actionsRenderer && actionsRenderer(node)}\n <FilterActionButton node={node} onClick={onFilterClick} getHierarchyLevelDetails={getHierarchyLevelDetails} />\n </>\n );\n\n return (\n <Tree.Item\n {...treeItemProps}\n ref={ref}\n label={getLabel ? getLabel(node) : node.label}\n selected={selected}\n expanded={node.isExpanded || node.children === true || node.children.length > 0 ? node.isExpanded : undefined}\n onExpandedChange={(isExpanded) => {\n expandNode(node.id, isExpanded);\n }}\n onClick={(event) => {\n !treeItemProps[\"aria-disabled\"] && onNodeClick?.(node, !selected, event);\n }}\n onKeyDown={(event) => {\n // Ignore if it is called on the element inside, e.g. checkbox or expander\n if (!treeItemProps[\"aria-disabled\"] && event.target === nodeRef.current) {\n onNodeKeyDown?.(node, !selected, event);\n }\n }}\n icon={getIcon ? getIcon(node) : undefined}\n actions={<ActionButtons />}\n >\n {node.isExpanded && node.children === true ? <PlaceholderNode {...treeItemProps} ref={ref} /> : children}\n </Tree.Item>\n );\n },\n);\nTreeNodeRenderer.displayName = \"TreeNodeRenderer\";\n\nconst PlaceholderNode = forwardRef<HTMLDivElement, Omit<TreeNodeProps, \"onExpanded\" | \"label\">>(({ ...props }, forwardedRef) => {\n const { localizedStrings } = useLocalizationContext();\n return <Tree.Item {...props} ref={forwardedRef} label={localizedStrings.loading} icon={<Spinner size={\"small\"} title={localizedStrings.loading} />} />;\n});\nPlaceholderNode.displayName = \"PlaceholderNode\";\n\nfunction useMergedRefs<T>(...refs: ReadonlyArray<Ref<T> | LegacyRef<T> | undefined | null>) {\n return useCallback(\n (instance: T | null) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(instance);\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = instance;\n }\n });\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n [...refs],\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-hierarchies-react",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "React components based on `@itwin/presentation-hierarchies`",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"react-error-boundary": "^4.0.13",
|
|
46
46
|
"rxjs": "^7.8.1",
|
|
47
47
|
"@itwin/presentation-hierarchies": "^1.4.1",
|
|
48
|
-
"@itwin/
|
|
49
|
-
"@itwin/
|
|
48
|
+
"@itwin/presentation-shared": "^1.2.0",
|
|
49
|
+
"@itwin/unified-selection": "^1.3.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@itwin/itwinui-react": "^5.0.0-alpha.
|
|
52
|
+
"@itwin/itwinui-react": "^5.0.0-alpha.3",
|
|
53
53
|
"react": "^17.0.0 || ^18.0.0",
|
|
54
54
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
55
55
|
},
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@itwin/build-tools": "^4.10.1",
|
|
63
|
-
"@itwin/itwinui-react": "^5.0.0-alpha.
|
|
63
|
+
"@itwin/itwinui-react": "^5.0.0-alpha.3",
|
|
64
64
|
"@testing-library/dom": "^10.3.2",
|
|
65
65
|
"@testing-library/react": "^16.0.0",
|
|
66
66
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"sinon-chai": "^3.7.0",
|
|
93
93
|
"testdouble": "^3.20.2",
|
|
94
94
|
"typescript": "~5.6.3",
|
|
95
|
-
"presentation-
|
|
96
|
-
"presentation-
|
|
95
|
+
"presentation-test-utilities": "^0.0.0",
|
|
96
|
+
"presentation-build-tools": "^0.0.0"
|
|
97
97
|
},
|
|
98
98
|
"scripts": {
|
|
99
99
|
"build": "npm run -s build:esm",
|