@itwin/presentation-hierarchies-react 1.10.1 → 1.10.3

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 (80) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +50 -10
  3. package/lib/cjs/presentation-hierarchies-react/LocalizationContext.d.ts +1 -1
  4. package/lib/cjs/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -1
  5. package/lib/cjs/presentation-hierarchies-react/LocalizationContext.js +1 -1
  6. package/lib/cjs/presentation-hierarchies-react/LocalizationContext.js.map +1 -1
  7. package/lib/cjs/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
  8. package/lib/cjs/presentation-hierarchies-react/TreeNode.js.map +1 -1
  9. package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +1 -1
  10. package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.js +1 -1
  11. package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.js.map +1 -1
  12. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
  13. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
  14. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
  15. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.js +1 -4
  16. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
  17. package/lib/cjs/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  18. package/lib/cjs/presentation-hierarchies-react/UseTree.js +4 -21
  19. package/lib/cjs/presentation-hierarchies-react/UseTree.js.map +1 -1
  20. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
  21. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js +20 -5
  22. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  23. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
  24. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js +8 -20
  25. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  26. package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.d.ts.map +1 -1
  27. package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
  28. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  29. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js +2 -9
  30. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  31. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
  32. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +7 -2
  33. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
  34. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +1 -1
  35. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +1 -1
  36. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.js +2 -15
  37. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +1 -1
  38. package/lib/cjs/presentation-hierarchies-react-itwinui.d.ts +1 -1
  39. package/lib/cjs/presentation-hierarchies-react-itwinui.d.ts.map +1 -1
  40. package/lib/cjs/presentation-hierarchies-react-itwinui.js.map +1 -1
  41. package/lib/esm/presentation-hierarchies-react/LocalizationContext.d.ts +1 -1
  42. package/lib/esm/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -1
  43. package/lib/esm/presentation-hierarchies-react/LocalizationContext.js +1 -1
  44. package/lib/esm/presentation-hierarchies-react/LocalizationContext.js.map +1 -1
  45. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
  46. package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +1 -1
  47. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +1 -1
  48. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +1 -1
  49. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +1 -1
  50. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
  51. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +1 -1
  52. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
  53. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
  54. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +1 -4
  55. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
  56. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  57. package/lib/esm/presentation-hierarchies-react/UseTree.js +6 -23
  58. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
  59. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
  60. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +22 -7
  61. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  62. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
  63. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +9 -21
  64. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  65. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +1 -1
  66. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
  67. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  68. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +3 -10
  69. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  70. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
  71. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +9 -4
  72. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
  73. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +1 -1
  74. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +2 -15
  75. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +1 -1
  76. package/lib/esm/presentation-hierarchies-react-itwinui.d.ts +1 -1
  77. package/lib/esm/presentation-hierarchies-react-itwinui.d.ts.map +1 -1
  78. package/lib/esm/presentation-hierarchies-react-itwinui.js +1 -1
  79. package/lib/esm/presentation-hierarchies-react-itwinui.js.map +1 -1
  80. package/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,kCAAgC;AAEhC,4DAA4B;AAC5B,iCAA4J;AAC5J,oEAA4F;AAC5F,wDAAqI;AACrI,8EAAgE;AAChE,mDAA0D;AAC1D,sEAAmE;AACnE,gDAAwF;AA0DxF;;;;;;GAMG;AACU,QAAA,gBAAgB,GAA2F,IAAA,kBAAU,EAChI,CACE,EACE,IAAI,EACJ,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,UAAU,EACV,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,UAAU,EACV,IAAI,EACJ,uBAAuB,EACvB,UAAU,EACV,GAAG,aAAa,EACjB,EACD,YAAY,EACZ,EAAE;IACF,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,+CAAsB,GAAE,CAAC;IACtD,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;QAC1D,OAAO,uBAAC,eAAe,OAAK,aAAa,EAAE,G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S,CAAC,CAAC,CAAC,CACX,uBAAC,oBAAI,IAAC,EAAE,EAAC,MAAM,EAAC,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,YAC5C,SAAS,GACL,CACR,CAAC,CAAC,CAAC,IAAI,IACJ,CACP;KACF,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAI,GAAG,IAA6D;IACxF,OAAO,IAAA,mBAAW,EAChB,CAAC,QAAkB,EAAE,EAAE;QACrB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,kCAAkC;YAClC,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 \"./TreeNodeRenderer.css\";\n\nimport cx from \"classnames\";\nimport { ComponentPropsWithoutRef, forwardRef, LegacyRef, MutableRefObject, ReactElement, Ref, RefAttributes, useCallback, useEffect, useRef } from \"react\";\nimport { SvgFilter, SvgFilterHollow, SvgMore, SvgRemove } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, ButtonGroup, DropdownMenu, Flex, IconButton, MenuItem, ProgressRadial, Text, TreeNode } from \"@itwin/itwinui-react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { useLocalizationContext } from \"../LocalizationContext.js\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { HierarchyLevelDetails, UseTreeResult } from \"../UseTree.js\";\nimport { RenderedTreeNode } from \"./TreeRenderer.js\";\n\n/** @public */\ntype TreeNodeProps = ComponentPropsWithoutRef<typeof TreeNode>;\n\n/** @public */\nexport interface TreeNodeActionDefinition {\n label: string;\n icon: ReactElement;\n onClick: () => void;\n}\n\n/** @public */\ninterface TreeNodeRendererOwnProps {\n /** Node that is rendered. */\n node: RenderedTreeNode;\n /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n /** Returns an icon for a given node. */\n getIcon?: (node: PresentationHierarchyNode) => 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 /** CSS class name for the action buttons. */\n actionButtonsClassName?: string;\n /** Tree node size. Should match the size passed to `TreeRenderer` component. */\n size?: \"default\" | \"small\";\n /**\n * Configures filter buttons visibility.\n *\n * Options:\n * - `show-on-hover` - show filter buttons when hovering over node, or the node is in focus.\n * - `hide` - hide filter buttons, but will show them if the filter is applied.\n *\n * Default value: `show-on-hover`\n */\n filterButtonsVisibility?: \"show-on-hover\" | \"hide\";\n /**\n * Additional actions that should be rendered for specific hierarchy node.\n */\n getActions?: (node: PresentationHierarchyNode) => TreeNodeActionDefinition[];\n}\n\n/** @public */\ntype TreeNodeRendererProps = Pick<UseTreeResult, \"expandNode\"> &\n Partial<Pick<UseTreeResult, \"getHierarchyLevelDetails\">> &\n Omit<TreeNodeProps, \"label\" | \"onExpanded\" | \"onSelected\" | \"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 getSublabel,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n isSelected,\n isDisabled,\n actionButtonsClassName,\n getHierarchyLevelDetails,\n reloadTree,\n size,\n filterButtonsVisibility,\n getActions,\n ...treeNodeProps\n },\n forwardedRef,\n ) => {\n const { localizedStrings } = useLocalizationContext();\n if (\"type\" in node && node.type === \"ChildrenPlaceholder\") {\n return <PlaceholderNode {...treeNodeProps} ref={forwardedRef} size={size} />;\n }\n\n if (isPresentationHierarchyNode(node)) {\n return (\n <HierarchyNodeRenderer\n {...treeNodeProps}\n ref={forwardedRef}\n node={node}\n expandNode={expandNode}\n getIcon={getIcon}\n getLabel={getLabel}\n getSublabel={getSublabel}\n onFilterClick={onFilterClick}\n onNodeClick={onNodeClick}\n onNodeKeyDown={onNodeKeyDown}\n isSelected={isSelected}\n isDisabled={isDisabled}\n actionButtonsClassName={actionButtonsClassName}\n getHierarchyLevelDetails={getHierarchyLevelDetails}\n filterButtonsVisibility={filterButtonsVisibility}\n getActions={getActions}\n />\n );\n }\n\n if (node.type === \"ResultSetTooLarge\") {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.parentNodeId);\n const isFilterable =\n hierarchyLevelDetails?.hierarchyNode &&\n !HierarchyNode.isGroupingNode(hierarchyLevelDetails.hierarchyNode) &&\n hierarchyLevelDetails.hierarchyNode.supportsFiltering;\n return (\n <ResultSetTooLargeNode\n {...treeNodeProps}\n ref={forwardedRef}\n limit={node.resultSetSizeLimit}\n onOverrideLimit={hierarchyLevelDetails ? (limit) => hierarchyLevelDetails.setSizeLimit(limit) : undefined}\n onFilterClick={\n onFilterClick && hierarchyLevelDetails && isFilterable\n ? () => {\n onFilterClick(hierarchyLevelDetails);\n }\n : undefined\n }\n />\n );\n }\n\n if (node.type === \"NoFilterMatches\") {\n /* v8 ignore next -- @preserve */\n return (\n <TreeNode\n {...treeNodeProps}\n className=\"stateless-tree-node\"\n ref={forwardedRef}\n label={localizedStrings.noFilteredChildren}\n isDisabled={true}\n onExpanded={() => {}}\n />\n );\n }\n\n const onRetry = reloadTree ? () => reloadTree({ parentNodeId: node.parentNodeId, state: \"reset\" }) : undefined;\n /* v8 ignore next -- @preserve */\n return (\n <TreeNode\n {...treeNodeProps}\n className=\"stateless-tree-node\"\n ref={forwardedRef}\n label={<ErrorNodeLabel message={node.message} onRetry={onRetry} />}\n isDisabled={true}\n onExpanded={() => {}}\n />\n );\n },\n);\nTreeNodeRenderer.displayName = \"TreeNodeRenderer\";\n\ntype HierarchyNodeRendererProps = Omit<TreeNodeRendererProps, \"node\" | \"reloadTree\" | \"size\"> & {\n node: PresentationHierarchyNode;\n};\n\nconst HierarchyNodeRenderer = forwardRef<HTMLDivElement, HierarchyNodeRendererProps>(\n (\n {\n node,\n expandNode,\n getIcon,\n getLabel,\n getSublabel,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n isSelected,\n isDisabled,\n actionButtonsClassName,\n getHierarchyLevelDetails,\n filterButtonsVisibility,\n getActions,\n ...treeNodeProps\n },\n forwardedRef,\n ) => {\n const nodeRef = useRef<HTMLDivElement>(null);\n const ref = useMergedRefs(forwardedRef, nodeRef);\n\n return (\n <TreeNode\n {...treeNodeProps}\n ref={ref}\n isSelected={isSelected}\n isDisabled={isDisabled}\n className={cx(treeNodeProps.className, \"stateless-tree-node\", { filtered: node.isFiltered, selected: isSelected })}\n onClick={(event) => !isDisabled && onNodeClick?.(node, !isSelected, event)}\n onKeyDown={(event) => {\n // Ignore if it is called on the element inside, e.g. checkbox or expander\n if (!isDisabled && event.target === nodeRef.current) {\n onNodeKeyDown?.(node, !isSelected, event);\n }\n }}\n onExpanded={(_, isExpanded) => {\n expandNode(node.id, isExpanded);\n }}\n icon={getIcon ? getIcon(node) : undefined}\n label={getLabel ? getLabel(node) : node.label}\n sublabel={getSublabel ? getSublabel(node) : undefined}\n // TODO: review if this is needed when horizontal scroll is enabled back after fix for issue: https://github.com/iTwin/iTwinUI/issues/2330\n title={node.label}\n contentProps={{ className: \"stateless-tree-node-content\" }}\n >\n <TreeNodeActions\n node={node}\n getHierarchyLevelDetails={getHierarchyLevelDetails}\n onFilterClick={onFilterClick}\n filterButtonsVisibility={filterButtonsVisibility}\n actionButtonsClassName={actionButtonsClassName}\n getActions={getActions}\n />\n </TreeNode>\n );\n },\n);\nHierarchyNodeRenderer.displayName = \"HierarchyNodeRenderer\";\n\nconst PlaceholderNode = forwardRef<\n HTMLDivElement,\n Omit<TreeNodeProps, \"onExpanded\" | \"label\"> & {\n size?: \"default\" | \"small\";\n }\n>(({ size, ...props }, forwardedRef) => {\n const { localizedStrings } = useLocalizationContext();\n /* v8 ignore next -- @preserve */\n return (\n <TreeNode\n {...props}\n ref={forwardedRef}\n className=\"stateless-tree-node\"\n label={localizedStrings.loading}\n icon={\n <ProgressRadial\n size=\"x-small\"\n indeterminate\n title={localizedStrings.loading}\n className={cx(props.className, { \"stateless-tree-node-small-spinner\": size === \"small\" })}\n />\n }\n onExpanded={() => {}}\n />\n );\n});\nPlaceholderNode.displayName = \"PlaceholderNode\";\n\nconst ResultSetTooLargeNode = forwardRef<HTMLDivElement, Omit<TreeNodeProps, \"onExpanded\" | \"label\"> & ResultSetTooLargeNodeLabelProps>(\n ({ onFilterClick, onOverrideLimit, limit, ...props }, forwardedRef) => {\n /* v8 ignore next -- @preserve */\n return (\n <TreeNode\n {...props}\n ref={forwardedRef}\n className=\"stateless-tree-node\"\n label={<ResultSetTooLargeNodeLabel limit={limit} onFilterClick={onFilterClick} onOverrideLimit={onOverrideLimit} />}\n onExpanded={() => {}}\n isDisabled={true}\n />\n );\n },\n);\nResultSetTooLargeNode.displayName = \"ResultSetTooLargeNode\";\n\nfunction ErrorNodeLabel({ message, onRetry }: { message: string; onRetry?: () => void }) {\n const { localizedStrings } = useLocalizationContext();\n return (\n <Flex flexDirection=\"row\" gap=\"xs\" title={message} alignItems=\"start\">\n <Text>{message}</Text>\n {onRetry ? <Anchor onClick={onRetry}>{localizedStrings?.retry}</Anchor> : null}\n </Flex>\n );\n}\n\nfunction TreeNodeActions({\n node,\n getHierarchyLevelDetails,\n onFilterClick,\n filterButtonsVisibility,\n actionButtonsClassName,\n getActions,\n}: Pick<\n HierarchyNodeRendererProps,\n \"node\" | \"actionButtonsClassName\" | \"getHierarchyLevelDetails\" | \"filterButtonsVisibility\" | \"getActions\" | \"onFilterClick\"\n>) {\n const { localizedStrings } = useLocalizationContext();\n const applyFilterButtonRef = useRef<HTMLButtonElement>(null);\n const prevIsFiltered = useRef(node.isFiltered);\n useEffect(() => {\n // If the node is filtered, focus the apply filter button\n if (node.isFiltered && !prevIsFiltered.current) {\n applyFilterButtonRef.current?.focus();\n }\n prevIsFiltered.current = node.isFiltered;\n }, [node.isFiltered]);\n\n const additionalButtons = getActions ? getActions(node) : [];\n const isClearFilterVisible = getHierarchyLevelDetails && node.isFiltered;\n const isFilterVisible = onFilterClick && node.isFilterable && (filterButtonsVisibility !== \"hide\" || node.isFiltered);\n\n const renderAdditionalActions = () => {\n if (additionalButtons.length === 1) {\n const button = additionalButtons[0];\n return (\n <IconButton\n styleType=\"borderless\"\n size=\"small\"\n label={button.label}\n onClick={(e) => {\n e.stopPropagation();\n button.onClick();\n }}\n >\n {button.icon}\n </IconButton>\n );\n }\n\n if (additionalButtons.length > 1) {\n return (\n <DropdownMenu\n menuItems={(close) =>\n additionalButtons.map((button, index) => (\n <MenuItem\n key={index}\n startIcon={button.icon}\n onClick={() => {\n button.onClick();\n close();\n }}\n >\n {button.label}\n </MenuItem>\n ))\n }\n >\n <IconButton styleType=\"borderless\" size=\"small\" label={localizedStrings.more} onClick={(e) => e.stopPropagation()}>\n <SvgMore />\n </IconButton>\n </DropdownMenu>\n );\n }\n\n return null;\n };\n\n return (\n <ButtonGroup className={cx(\"action-buttons\", actionButtonsClassName)}>\n {isClearFilterVisible ? (\n <IconButton\n styleType=\"borderless\"\n size=\"small\"\n label={localizedStrings.clearHierarchyLevelFilter}\n onClick={(e) => {\n e.stopPropagation();\n getHierarchyLevelDetails(node.id)?.setInstanceFilter(undefined);\n applyFilterButtonRef.current?.focus();\n }}\n >\n <SvgRemove />\n </IconButton>\n ) : null}\n {isFilterVisible ? (\n <IconButton\n ref={applyFilterButtonRef}\n styleType=\"borderless\"\n size=\"small\"\n label={localizedStrings.filterHierarchyLevel}\n onClick={(e) => {\n e.stopPropagation();\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);\n }}\n >\n {node.isFiltered ? <SvgFilter /> : <SvgFilterHollow />}\n </IconButton>\n ) : null}\n {renderAdditionalActions()}\n </ButtonGroup>\n );\n}\n\ninterface ResultSetTooLargeNodeLabelProps {\n limit: number;\n onFilterClick?: () => void;\n onOverrideLimit?: (limit: number) => void;\n}\n\nfunction ResultSetTooLargeNodeLabel({ onFilterClick, onOverrideLimit, limit }: ResultSetTooLargeNodeLabelProps) {\n const { localizedStrings } = useLocalizationContext();\n const supportsFiltering = !!onFilterClick;\n const supportsLimitOverride = !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE;\n\n const limitExceededMessage = createLocalizedMessage(\n supportsFiltering ? localizedStrings.resultLimitExceededWithFiltering : localizedStrings.resultLimitExceeded,\n limit,\n onFilterClick,\n );\n const increaseLimitMessage = supportsLimitOverride\n ? createLocalizedMessage(\n supportsFiltering ? localizedStrings.increaseHierarchyLimitWithFiltering : localizedStrings.increaseHierarchyLimit,\n MAX_LIMIT_OVERRIDE,\n () => onOverrideLimit(MAX_LIMIT_OVERRIDE),\n )\n : { title: \"\", element: null };\n\n const title = `${limitExceededMessage.title} ${increaseLimitMessage.title}`;\n\n return (\n <Flex flexDirection=\"column\" gap=\"3xs\" title={title} alignItems=\"start\">\n {limitExceededMessage.element}\n {increaseLimitMessage.element}\n </Flex>\n );\n}\n\nconst LINK_TAG_REGEX = /<link>(.*?)<\\/link>/;\n\nfunction createLocalizedMessage(message: string, limit: number, onClick?: () => void) {\n const limitStr = limit.toLocaleString(undefined, { useGrouping: true });\n const messageWithLimit = message.replace(\"{{limit}}\", limitStr);\n /* v8 ignore next -- @preserve */\n const match = messageWithLimit.length <= 1000 ? messageWithLimit.match(LINK_TAG_REGEX) : undefined;\n\n if (!match) {\n return {\n title: messageWithLimit,\n element: (\n <Text as=\"span\" style={{ whiteSpace: \"normal\" }}>\n {messageWithLimit}\n </Text>\n ),\n };\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = messageWithLimit.split(fullText);\n\n return {\n title: messageWithLimit.replace(fullText, innerText),\n element: (\n <div>\n {textBefore ? (\n <Text as=\"span\" style={{ whiteSpace: \"normal\" }}>\n {textBefore}\n </Text>\n ) : null}\n <Anchor\n style={{ whiteSpace: \"normal\" }}\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? (\n <Text as=\"span\" style={{ whiteSpace: \"normal\" }}>\n {textAfter}\n </Text>\n ) : null}\n </div>\n ),\n };\n}\n\nfunction useMergedRefs<T>(...refs: ReadonlyArray<Ref<T> | LegacyRef<T> | undefined | null>) {\n return useCallback(\n (instance: T | null) => {\n refs.forEach((ref) => {\n /* v8 ignore else -- @preserve */\n if (typeof ref === \"function\") {\n ref(instance);\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = instance;\n }\n });\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n [...refs],\n );\n}\n"]}
1
+ {"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,kCAAgC;AAEhC,4DAA4B;AAC5B,iCAWe;AACf,oEAA4F;AAC5F,wDAU8B;AAC9B,8EAAgE;AAChE,mDAA0D;AAC1D,sEAAmE;AACnE,gDAAwF;AAkExF;;;;;;GAMG;AACU,QAAA,gBAAgB,GAC3B,IAAA,kBAAU,EACR,CACE,EACE,IAAI,EACJ,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,UAAU,EACV,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,UAAU,EACV,IAAI,EACJ,uBAAuB,EACvB,UAAU,EACV,GAAG,aAAa,EACjB,EACD,YAAY,EACZ,EAAE;IACF,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,+CAAsB,GAAE,CAAC;IACtD,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;QAC1D,OAAO,uBAAC,eAAe,OAAK,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,GAAI,CAAC;IAC/E,CAAC;IAED,IAAI,IAAA,yCAA2B,EAAC,IAAI,CAAC,EAAE,CAAC;QACtC,OAAO,CACL,uBAAC,qBAAqB,OAChB,aAAa,EACjB,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,sBAAsB,EAAE,sBAAsB,EAC9C,wBAAwB,EAAE,wBAA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BACd,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 \"./TreeNodeRenderer.css\";\n\nimport cx from \"classnames\";\nimport {\n ComponentPropsWithoutRef,\n forwardRef,\n LegacyRef,\n MutableRefObject,\n ReactElement,\n Ref,\n RefAttributes,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport { SvgFilter, SvgFilterHollow, SvgMore, SvgRemove } from \"@itwin/itwinui-icons-react\";\nimport {\n Anchor,\n ButtonGroup,\n DropdownMenu,\n Flex,\n IconButton,\n MenuItem,\n ProgressRadial,\n Text,\n TreeNode,\n} from \"@itwin/itwinui-react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { useLocalizationContext } from \"../LocalizationContext.js\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { HierarchyLevelDetails, UseTreeResult } from \"../UseTree.js\";\nimport { RenderedTreeNode } from \"./TreeRenderer.js\";\n\n/** @public */\ntype TreeNodeProps = ComponentPropsWithoutRef<typeof TreeNode>;\n\n/** @public */\nexport interface TreeNodeActionDefinition {\n label: string;\n icon: ReactElement;\n onClick: () => void;\n}\n\n/** @public */\ninterface TreeNodeRendererOwnProps {\n /** Node that is rendered. */\n node: RenderedTreeNode;\n /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n /** Returns an icon for a given node. */\n getIcon?: (node: PresentationHierarchyNode) => 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?: (\n node: PresentationHierarchyNode,\n isSelected: boolean,\n event: React.MouseEvent<HTMLElement, MouseEvent>,\n ) => void;\n /** Action to perform when a key is pressed when the node is hovered on. */\n onNodeKeyDown?: (\n node: PresentationHierarchyNode,\n isSelected: boolean,\n event: React.KeyboardEvent<HTMLElement>,\n ) => 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 /** CSS class name for the action buttons. */\n actionButtonsClassName?: string;\n /** Tree node size. Should match the size passed to `TreeRenderer` component. */\n size?: \"default\" | \"small\";\n /**\n * Configures filter buttons visibility.\n *\n * Options:\n * - `show-on-hover` - show filter buttons when hovering over node, or the node is in focus.\n * - `hide` - hide filter buttons, but will show them if the filter is applied.\n *\n * Default value: `show-on-hover`\n */\n filterButtonsVisibility?: \"show-on-hover\" | \"hide\";\n /**\n * Additional actions that should be rendered for specific hierarchy node.\n */\n getActions?: (node: PresentationHierarchyNode) => TreeNodeActionDefinition[];\n}\n\n/** @public */\ntype TreeNodeRendererProps = Pick<UseTreeResult, \"expandNode\"> &\n Partial<Pick<UseTreeResult, \"getHierarchyLevelDetails\">> &\n Omit<TreeNodeProps, \"label\" | \"onExpanded\" | \"onSelected\" | \"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>> =\n forwardRef(\n (\n {\n node,\n expandNode,\n getIcon,\n getLabel,\n getSublabel,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n isSelected,\n isDisabled,\n actionButtonsClassName,\n getHierarchyLevelDetails,\n reloadTree,\n size,\n filterButtonsVisibility,\n getActions,\n ...treeNodeProps\n },\n forwardedRef,\n ) => {\n const { localizedStrings } = useLocalizationContext();\n if (\"type\" in node && node.type === \"ChildrenPlaceholder\") {\n return <PlaceholderNode {...treeNodeProps} ref={forwardedRef} size={size} />;\n }\n\n if (isPresentationHierarchyNode(node)) {\n return (\n <HierarchyNodeRenderer\n {...treeNodeProps}\n ref={forwardedRef}\n node={node}\n expandNode={expandNode}\n getIcon={getIcon}\n getLabel={getLabel}\n getSublabel={getSublabel}\n onFilterClick={onFilterClick}\n onNodeClick={onNodeClick}\n onNodeKeyDown={onNodeKeyDown}\n isSelected={isSelected}\n isDisabled={isDisabled}\n actionButtonsClassName={actionButtonsClassName}\n getHierarchyLevelDetails={getHierarchyLevelDetails}\n filterButtonsVisibility={filterButtonsVisibility}\n getActions={getActions}\n />\n );\n }\n\n if (node.type === \"ResultSetTooLarge\") {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.parentNodeId);\n const isFilterable =\n hierarchyLevelDetails?.hierarchyNode &&\n !HierarchyNode.isGroupingNode(hierarchyLevelDetails.hierarchyNode) &&\n hierarchyLevelDetails.hierarchyNode.supportsFiltering;\n return (\n <ResultSetTooLargeNode\n {...treeNodeProps}\n ref={forwardedRef}\n limit={node.resultSetSizeLimit}\n onOverrideLimit={hierarchyLevelDetails ? (limit) => hierarchyLevelDetails.setSizeLimit(limit) : undefined}\n onFilterClick={\n onFilterClick && hierarchyLevelDetails && isFilterable\n ? () => {\n onFilterClick(hierarchyLevelDetails);\n }\n : undefined\n }\n />\n );\n }\n\n if (node.type === \"NoFilterMatches\") {\n /* v8 ignore next -- @preserve */\n return (\n <TreeNode\n {...treeNodeProps}\n className=\"stateless-tree-node\"\n ref={forwardedRef}\n label={localizedStrings.noFilteredChildren}\n isDisabled={true}\n onExpanded={() => {}}\n />\n );\n }\n\n const onRetry = reloadTree ? () => reloadTree({ parentNodeId: node.parentNodeId, state: \"reset\" }) : undefined;\n /* v8 ignore next -- @preserve */\n return (\n <TreeNode\n {...treeNodeProps}\n className=\"stateless-tree-node\"\n ref={forwardedRef}\n label={<ErrorNodeLabel message={node.message} onRetry={onRetry} />}\n isDisabled={true}\n onExpanded={() => {}}\n />\n );\n },\n );\nTreeNodeRenderer.displayName = \"TreeNodeRenderer\";\n\ntype HierarchyNodeRendererProps = Omit<TreeNodeRendererProps, \"node\" | \"reloadTree\" | \"size\"> & {\n node: PresentationHierarchyNode;\n};\n\nconst HierarchyNodeRenderer = forwardRef<HTMLDivElement, HierarchyNodeRendererProps>(\n (\n {\n node,\n expandNode,\n getIcon,\n getLabel,\n getSublabel,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n isSelected,\n isDisabled,\n actionButtonsClassName,\n getHierarchyLevelDetails,\n filterButtonsVisibility,\n getActions,\n ...treeNodeProps\n },\n forwardedRef,\n ) => {\n const nodeRef = useRef<HTMLDivElement>(null);\n const ref = useMergedRefs(forwardedRef, nodeRef);\n\n return (\n <TreeNode\n {...treeNodeProps}\n ref={ref}\n isSelected={isSelected}\n isDisabled={isDisabled}\n className={cx(treeNodeProps.className, \"stateless-tree-node\", {\n filtered: node.isFiltered,\n selected: isSelected,\n })}\n onClick={(event) => !isDisabled && onNodeClick?.(node, !isSelected, event)}\n onKeyDown={(event) => {\n // Ignore if it is called on the element inside, e.g. checkbox or expander\n if (!isDisabled && event.target === nodeRef.current) {\n onNodeKeyDown?.(node, !isSelected, event);\n }\n }}\n onExpanded={(_, isExpanded) => {\n expandNode(node.id, isExpanded);\n }}\n icon={getIcon ? getIcon(node) : undefined}\n label={getLabel ? getLabel(node) : node.label}\n sublabel={getSublabel ? getSublabel(node) : undefined}\n // TODO: review if this is needed when horizontal scroll is enabled back after fix for issue: https://github.com/iTwin/iTwinUI/issues/2330\n title={node.label}\n contentProps={{ className: \"stateless-tree-node-content\" }}\n >\n <TreeNodeActions\n node={node}\n getHierarchyLevelDetails={getHierarchyLevelDetails}\n onFilterClick={onFilterClick}\n filterButtonsVisibility={filterButtonsVisibility}\n actionButtonsClassName={actionButtonsClassName}\n getActions={getActions}\n />\n </TreeNode>\n );\n },\n);\nHierarchyNodeRenderer.displayName = \"HierarchyNodeRenderer\";\n\nconst PlaceholderNode = forwardRef<\n HTMLDivElement,\n Omit<TreeNodeProps, \"onExpanded\" | \"label\"> & { size?: \"default\" | \"small\" }\n>(({ size, ...props }, forwardedRef) => {\n const { localizedStrings } = useLocalizationContext();\n /* v8 ignore next -- @preserve */\n return (\n <TreeNode\n {...props}\n ref={forwardedRef}\n className=\"stateless-tree-node\"\n label={localizedStrings.loading}\n icon={\n <ProgressRadial\n size=\"x-small\"\n indeterminate\n title={localizedStrings.loading}\n className={cx(props.className, { \"stateless-tree-node-small-spinner\": size === \"small\" })}\n />\n }\n onExpanded={() => {}}\n />\n );\n});\nPlaceholderNode.displayName = \"PlaceholderNode\";\n\nconst ResultSetTooLargeNode = forwardRef<\n HTMLDivElement,\n Omit<TreeNodeProps, \"onExpanded\" | \"label\"> & ResultSetTooLargeNodeLabelProps\n>(({ onFilterClick, onOverrideLimit, limit, ...props }, forwardedRef) => {\n /* v8 ignore next -- @preserve */\n return (\n <TreeNode\n {...props}\n ref={forwardedRef}\n className=\"stateless-tree-node\"\n label={\n <ResultSetTooLargeNodeLabel limit={limit} onFilterClick={onFilterClick} onOverrideLimit={onOverrideLimit} />\n }\n onExpanded={() => {}}\n isDisabled={true}\n />\n );\n});\nResultSetTooLargeNode.displayName = \"ResultSetTooLargeNode\";\n\nfunction ErrorNodeLabel({ message, onRetry }: { message: string; onRetry?: () => void }) {\n const { localizedStrings } = useLocalizationContext();\n return (\n <Flex flexDirection=\"row\" gap=\"xs\" title={message} alignItems=\"start\">\n <Text>{message}</Text>\n {onRetry ? <Anchor onClick={onRetry}>{localizedStrings?.retry}</Anchor> : null}\n </Flex>\n );\n}\n\nfunction TreeNodeActions({\n node,\n getHierarchyLevelDetails,\n onFilterClick,\n filterButtonsVisibility,\n actionButtonsClassName,\n getActions,\n}: Pick<\n HierarchyNodeRendererProps,\n | \"node\"\n | \"actionButtonsClassName\"\n | \"getHierarchyLevelDetails\"\n | \"filterButtonsVisibility\"\n | \"getActions\"\n | \"onFilterClick\"\n>) {\n const { localizedStrings } = useLocalizationContext();\n const applyFilterButtonRef = useRef<HTMLButtonElement>(null);\n const prevIsFiltered = useRef(node.isFiltered);\n useEffect(() => {\n // If the node is filtered, focus the apply filter button\n if (node.isFiltered && !prevIsFiltered.current) {\n applyFilterButtonRef.current?.focus();\n }\n prevIsFiltered.current = node.isFiltered;\n }, [node.isFiltered]);\n\n const additionalButtons = getActions ? getActions(node) : [];\n const isClearFilterVisible = getHierarchyLevelDetails && node.isFiltered;\n const isFilterVisible = onFilterClick && node.isFilterable && (filterButtonsVisibility !== \"hide\" || node.isFiltered);\n\n const renderAdditionalActions = () => {\n if (additionalButtons.length === 1) {\n const button = additionalButtons[0];\n return (\n <IconButton\n styleType=\"borderless\"\n size=\"small\"\n label={button.label}\n onClick={(e) => {\n e.stopPropagation();\n button.onClick();\n }}\n >\n {button.icon}\n </IconButton>\n );\n }\n\n if (additionalButtons.length > 1) {\n return (\n <DropdownMenu\n menuItems={(close) =>\n additionalButtons.map((button, index) => (\n <MenuItem\n key={index}\n startIcon={button.icon}\n onClick={() => {\n button.onClick();\n close();\n }}\n >\n {button.label}\n </MenuItem>\n ))\n }\n >\n <IconButton\n styleType=\"borderless\"\n size=\"small\"\n label={localizedStrings.more}\n onClick={(e) => e.stopPropagation()}\n >\n <SvgMore />\n </IconButton>\n </DropdownMenu>\n );\n }\n\n return null;\n };\n\n return (\n <ButtonGroup className={cx(\"action-buttons\", actionButtonsClassName)}>\n {isClearFilterVisible ? (\n <IconButton\n styleType=\"borderless\"\n size=\"small\"\n label={localizedStrings.clearHierarchyLevelFilter}\n onClick={(e) => {\n e.stopPropagation();\n getHierarchyLevelDetails(node.id)?.setInstanceFilter(undefined);\n applyFilterButtonRef.current?.focus();\n }}\n >\n <SvgRemove />\n </IconButton>\n ) : null}\n {isFilterVisible ? (\n <IconButton\n ref={applyFilterButtonRef}\n styleType=\"borderless\"\n size=\"small\"\n label={localizedStrings.filterHierarchyLevel}\n onClick={(e) => {\n e.stopPropagation();\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);\n }}\n >\n {node.isFiltered ? <SvgFilter /> : <SvgFilterHollow />}\n </IconButton>\n ) : null}\n {renderAdditionalActions()}\n </ButtonGroup>\n );\n}\n\ninterface ResultSetTooLargeNodeLabelProps {\n limit: number;\n onFilterClick?: () => void;\n onOverrideLimit?: (limit: number) => void;\n}\n\nfunction ResultSetTooLargeNodeLabel({ onFilterClick, onOverrideLimit, limit }: ResultSetTooLargeNodeLabelProps) {\n const { localizedStrings } = useLocalizationContext();\n const supportsFiltering = !!onFilterClick;\n const supportsLimitOverride = !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE;\n\n const limitExceededMessage = createLocalizedMessage(\n supportsFiltering ? localizedStrings.resultLimitExceededWithFiltering : localizedStrings.resultLimitExceeded,\n limit,\n onFilterClick,\n );\n const increaseLimitMessage = supportsLimitOverride\n ? createLocalizedMessage(\n supportsFiltering\n ? localizedStrings.increaseHierarchyLimitWithFiltering\n : localizedStrings.increaseHierarchyLimit,\n MAX_LIMIT_OVERRIDE,\n () => onOverrideLimit(MAX_LIMIT_OVERRIDE),\n )\n : { title: \"\", element: null };\n\n const title = `${limitExceededMessage.title} ${increaseLimitMessage.title}`;\n\n return (\n <Flex flexDirection=\"column\" gap=\"3xs\" title={title} alignItems=\"start\">\n {limitExceededMessage.element}\n {increaseLimitMessage.element}\n </Flex>\n );\n}\n\nconst LINK_TAG_REGEX = /<link>(.*?)<\\/link>/;\n\nfunction createLocalizedMessage(message: string, limit: number, onClick?: () => void) {\n const limitStr = limit.toLocaleString(undefined, { useGrouping: true });\n const messageWithLimit = message.replace(\"{{limit}}\", limitStr);\n /* v8 ignore next -- @preserve */\n const match = messageWithLimit.length <= 1000 ? messageWithLimit.match(LINK_TAG_REGEX) : undefined;\n\n if (!match) {\n return {\n title: messageWithLimit,\n element: (\n <Text as=\"span\" style={{ whiteSpace: \"normal\" }}>\n {messageWithLimit}\n </Text>\n ),\n };\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = messageWithLimit.split(fullText);\n\n return {\n title: messageWithLimit.replace(fullText, innerText),\n element: (\n <div>\n {textBefore ? (\n <Text as=\"span\" style={{ whiteSpace: \"normal\" }}>\n {textBefore}\n </Text>\n ) : null}\n <Anchor\n style={{ whiteSpace: \"normal\" }}\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? (\n <Text as=\"span\" style={{ whiteSpace: \"normal\" }}>\n {textAfter}\n </Text>\n ) : null}\n </div>\n ),\n };\n}\n\nfunction useMergedRefs<T>(...refs: ReadonlyArray<Ref<T> | LegacyRef<T> | undefined | null>) {\n return useCallback(\n (instance: T | null) => {\n refs.forEach((ref) => {\n /* v8 ignore else -- @preserve */\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"]}
@@ -25,7 +25,7 @@ type TreeRendererProps = Pick<ReturnType<typeof useTree>, "rootNodes" | "expandN
25
25
  * @see https://itwinui.bentley.com/docs/tree
26
26
  * @public
27
27
  */
28
- export declare function TreeRenderer({ rootNodes, expandNode, selectNodes, isNodeSelected, onFilterClick, getIcon, getLabel, getSublabel, getHierarchyLevelDetails, reloadTree, selectionMode, localizedStrings, size, filterButtonsVisibility, getActions, ...treeProps }: TreeRendererProps): import("react/jsx-runtime.js").JSX.Element;
28
+ export declare function TreeRenderer({ rootNodes, expandNode, selectNodes, isNodeSelected, onFilterClick, getIcon, getLabel, getSublabel, getHierarchyLevelDetails, reloadTree, selectionMode, localizedStrings, size, filterButtonsVisibility, getActions, ...treeProps }: TreeRendererProps): import("react/jsx-runtime").JSX.Element;
29
29
  /**
30
30
  * A data structure for a tree node that is rendered using the `TreeRenderer` component.
31
31
  *
@@ -1 +1 @@
1
- {"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAe,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAuB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,cAAc;AACd,KAAK,SAAS,GAAG,wBAAwB,CAAC,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAEzE,cAAc;AACd,KAAK,qBAAqB,GAAG,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE/E,cAAc;AACd,UAAU,oBAAoB;IAC5B,8BAA8B;IAC9B,SAAS,EAAE,oBAAoB,EAAE,CAAC;IAClC,sEAAsE;IACtE,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,cAAc;AACd,KAAK,iBAAiB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC,GACnF,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,aAAa,GAAG,gBAAgB,GAAG,0BAA0B,GAAG,YAAY,CAAC,CAAC,GACvH,IAAI,CAAC,qBAAqB,EAAE,eAAe,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,GAAG,yBAAyB,GAAG,YAAY,CAAC,GAChI,oBAAoB,GACpB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,GAAG,sBAAsB,CAAC,GAC7E,wBAAwB,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAE/D;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,OAAO,EACP,QAAQ,EACR,WAAW,EACX,wBAAwB,EACxB,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,uBAAuB,EACvB,UAAU,EACV,GAAG,SAAS,EACb,EAAE,iBAAiB,8CAiDnB;AAOD;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GACxB,oBAAoB,GACpB;IACE,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,qBAAqB,CAAC;CAC7B,CAAC;AAEN;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CA6B1I"}
1
+ {"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAe,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAuB,MAAM,2BAA2B,CAAC;AAC/E,O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E,EAAE,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,IAAI,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAElF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,gBAAgB,EACtB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,GAC1C,QAAQ,CAAC,gBAAgB,CAAC,CAgB5B"}
@@ -64,14 +64,7 @@ function noopIsNodeSelected() {
64
64
  */
65
65
  function createRenderedTreeNodeData(node, isNodeSelected) {
66
66
  if ("type" in node) {
67
- return {
68
- nodeId: node.id,
69
- node,
70
- hasSubNodes: false,
71
- isExpanded: false,
72
- isSelected: false,
73
- isDisabled: true,
74
- };
67
+ return { nodeId: node.id, node, hasSubNodes: false, isExpanded: false, isSelected: false, isDisabled: true };
75
68
  }
76
69
  return {
77
70
  nodeId: node.id,
@@ -80,13 +73,7 @@ function createRenderedTreeNodeData(node, isNodeSelected) {
80
73
  subNodes:
81
74
  // returns placeholder node to show as child while children is loading.
82
75
  node.children === true
83
- ? [
84
- {
85
- id: `Loading-${node.id}`,
86
- parentNodeId: node.id,
87
- type: "ChildrenPlaceholder",
88
- },
89
- ]
76
+ ? [{ id: `Loading-${node.id}`, parentNodeId: node.id, type: "ChildrenPlaceholder" }]
90
77
  : node.children,
91
78
  isExpanded: node.isExpanded,
92
79
  isSelected: isNodeSelected(node.id),
@@ -1 +1 @@
1
- {"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":";;AA0CA,oCAkEC;AAuCD,gEA6BC;;AAhLD;;;gGAGgG;AAEhG,iCAA8D;AAC9D,wDAAsD;AACtD,sEAAwE;AAExE,sEAA+E;AAE/E,+DAAyD;AAwBzD;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,UAAU,EACV,WAAW,EACX,cA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E,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,IAAI,GAAI,GACpH,CAC/B,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,KAAI,CAAC;AAC7B,SAAS,kBAAkB;IACzB,OAAO,KAAK,CAAC;AACf,CAAC;AAoBD;;;;;;;;;;;;;GAaG;AACH,SAAgB,0BAA0B,CAAC,IAAsB,EAAE,cAA2C;IAC5G,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,IAAI;YACJ,WAAW,EAAE,KAAK;YAClB,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,IAAI;SACjB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,EAAE;QACf,IAAI;QACJ,WAAW,EAAE,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC/D,QAAQ;QACN,uEAAuE;QACvE,IAAI,CAAC,QAAQ,KAAK,IAAI;YACpB,CAAC,CAAC;gBACE;oBACE,EAAE,EAAE,WAAW,IAAI,CAAC,EAAE,EAAE;oBACxB,YAAY,EAAE,IAAI,CAAC,EAAE;oBACrB,IAAI,EAAE,qBAAqB;iBAC5B;aACF;YACH,CAAC,CAAC,IAAI,CAAC,QAAQ;QACnB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,UAAU,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;KACpC,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, useCallback } from \"react\";\nimport { NodeData, Tree } from \"@itwin/itwinui-react\";\nimport { LocalizationContextProvider } from \"../LocalizationContext.js\";\nimport { PresentationTreeNode } from \"../TreeNode.js\";\nimport { SelectionMode, useSelectionHandler } from \"../UseSelectionHandler.js\";\nimport { useTree } from \"../UseTree.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\n\n/** @public */\ntype TreeProps = ComponentPropsWithoutRef<typeof Tree<RenderedTreeNode>>;\n\n/** @public */\ntype TreeNodeRendererProps = ComponentPropsWithoutRef<typeof TreeNodeRenderer>;\n\n/** @public */\ninterface TreeRendererOwnProps {\n /** Root nodes of the tree. */\n rootNodes: PresentationTreeNode[];\n /** Active selection mode used by the tree. Defaults to `\"single\"`. */\n selectionMode?: SelectionMode;\n}\n\n/** @public */\ntype TreeRendererProps = Pick<ReturnType<typeof useTree>, \"rootNodes\" | \"expandNode\"> &\n Partial<Pick<ReturnType<typeof useTree>, \"selectNodes\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"reloadTree\">> &\n Pick<TreeNodeRendererProps, \"onFilterClick\" | \"getIcon\" | \"getLabel\" | \"getSublabel\" | \"filterButtonsVisibility\" | \"getActions\"> &\n TreeRendererOwnProps &\n Omit<TreeProps, \"data\" | \"nodeRenderer\" | \"getNode\" | \"enableVirtualization\"> &\n ComponentPropsWithoutRef<typeof LocalizationContextProvider>;\n\n/**\n * A component that renders a tree using the `Tree` component from `@itwin/itwinui-react`. The tree nodes\n * are rendered using `TreeNodeRenderer` component from this package.\n *\n * @see https://itwinui.bentley.com/docs/tree\n * @public\n */\nexport function TreeRenderer({\n rootNodes,\n expandNode,\n selectNodes,\n isNodeSelected,\n onFilterClick,\n getIcon,\n getLabel,\n getSublabel,\n getHierarchyLevelDetails,\n reloadTree,\n selectionMode,\n localizedStrings,\n size,\n filterButtonsVisibility,\n getActions,\n ...treeProps\n}: TreeRendererProps) {\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({\n rootNodes,\n selectNodes: selectNodes ?? noopSelectNodes,\n selectionMode: selectionMode ?? \"single\",\n });\n const nodeRenderer = useCallback<TreeProps[\"nodeRenderer\"]>(\n (nodeProps) => {\n return (\n <TreeNodeRenderer\n {...nodeProps}\n filterButtonsVisibility={filterButtonsVisibility}\n expandNode={expandNode}\n getHierarchyLevelDetails={getHierarchyLevelDetails}\n onFilterClick={onFilterClick}\n onNodeClick={onNodeClick}\n onNodeKeyDown={onNodeKeyDown}\n getIcon={getIcon}\n getLabel={getLabel}\n getSublabel={getSublabel}\n reloadTree={reloadTree}\n size={size}\n getActions={getActions}\n />\n );\n },\n [\n filterButtonsVisibility,\n expandNode,\n getHierarchyLevelDetails,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n getIcon,\n getLabel,\n getSublabel,\n reloadTree,\n size,\n getActions,\n ],\n );\n\n const getNode = useCallback<TreeProps[\"getNode\"]>((node) => createRenderedTreeNodeData(node, isNodeSelected ?? noopIsNodeSelected), [isNodeSelected]);\n\n return (\n <LocalizationContextProvider localizedStrings={localizedStrings}>\n <Tree<RenderedTreeNode> {...treeProps} size={size} data={rootNodes} nodeRenderer={nodeRenderer} getNode={getNode} enableVirtualization={true} />\n </LocalizationContextProvider>\n );\n}\n\nfunction noopSelectNodes() {}\nfunction noopIsNodeSelected() {\n return false;\n}\n\n/**\n * A data structure for a tree node that is rendered using the `TreeRenderer` component.\n *\n * In addition to the `PresentationTreeNode` union, this type may have one additional variation - an informational\n * type of node with `ChildrenPlaceholder` type. This type of node is returned as the single child node of a parent\n * while its children are being loaded. This allows the node renderer to show a placeholder under the parent during\n * the process.\n *\n * @public\n */\nexport type RenderedTreeNode =\n | PresentationTreeNode\n | {\n id: string;\n parentNodeId: string | undefined;\n type: \"ChildrenPlaceholder\";\n };\n\n/**\n * An utility function that creates an `@itwin/itwinui-react` `NodeData` object for the `Tree` component from a\n * `RenderedTreeNode` object.\n *\n * Usage example:\n * ```tsx\n * function MyComponent({ rootNodes, nodeRenderer }: MyComponentProps) {\n * const getNode = useCallback<TreeProps[\"getNode\"]>((node) => createRenderedTreeNodeData(node, () => false), []);\n * return <Tree<RenderedTreeNode> data={rootNodes} getNode={getNode} nodeRenderer={nodeRenderer} />;\n * }\n * ```\n *\n * @public\n */\nexport function createRenderedTreeNodeData(node: RenderedTreeNode, isNodeSelected: (nodeId: string) => boolean): NodeData<RenderedTreeNode> {\n if (\"type\" in node) {\n return {\n nodeId: node.id,\n node,\n hasSubNodes: false,\n isExpanded: false,\n isSelected: false,\n isDisabled: true,\n };\n }\n return {\n nodeId: node.id,\n node,\n hasSubNodes: node.children === true || node.children.length > 0,\n subNodes:\n // returns placeholder node to show as child while children is loading.\n node.children === true\n ? [\n {\n id: `Loading-${node.id}`,\n parentNodeId: node.id,\n type: \"ChildrenPlaceholder\",\n },\n ]\n : node.children,\n isExpanded: node.isExpanded,\n isSelected: isNodeSelected(node.id),\n };\n}\n"]}
1
+ {"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":";;AA+CA,oCA4EC;AAmCD,gEAmBC;;AAjLD;;;gGAGgG;AAEhG,iCAA8D;AAC9D,wDAAsD;AACtD,sEAAwE;AAExE,sEAA+E;AAE/E,+DAAyD;AA6BzD;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,OAAO,EACP,QAAQ,EACR,WAAW,EACX,wBAAwB,EACxB,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,uBAAuB,EACvB,UAAU,EACV,GAAG,SAAS,EACM;IAClB,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,IAAA,4CAAmB,EAAC;QACzD,SAAS;QACT,WAAW,EAAE,WAAW,IAAI,eAAe;QAC3C,aAAa,EAAE,aAAa,IAAI,QAAQ;KACzC,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,IAAA,mBAAW,EAC9B,CAAC,SAAS,EAAE,EAAE;QACZ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EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAC/G,CAAC;IACD,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,EAAE;QACf,IAAI;QACJ,WAAW,EAAE,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC/D,QAAQ;QACN,uEAAuE;QACvE,IAAI,CAAC,QAAQ,KAAK,IAAI;YACpB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,WAAW,IAAI,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;YACpF,CAAC,CAAC,IAAI,CAAC,QAAQ;QACnB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,UAAU,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;KACpC,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, useCallback } from \"react\";\nimport { NodeData, Tree } from \"@itwin/itwinui-react\";\nimport { LocalizationContextProvider } from \"../LocalizationContext.js\";\nimport { PresentationTreeNode } from \"../TreeNode.js\";\nimport { SelectionMode, useSelectionHandler } from \"../UseSelectionHandler.js\";\nimport { useTree } from \"../UseTree.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\n\n/** @public */\ntype TreeProps = ComponentPropsWithoutRef<typeof Tree<RenderedTreeNode>>;\n\n/** @public */\ntype TreeNodeRendererProps = ComponentPropsWithoutRef<typeof TreeNodeRenderer>;\n\n/** @public */\ninterface TreeRendererOwnProps {\n /** Root nodes of the tree. */\n rootNodes: PresentationTreeNode[];\n /** Active selection mode used by the tree. Defaults to `\"single\"`. */\n selectionMode?: SelectionMode;\n}\n\n/** @public */\ntype TreeRendererProps = Pick<ReturnType<typeof useTree>, \"rootNodes\" | \"expandNode\"> &\n Partial<\n Pick<ReturnType<typeof useTree>, \"selectNodes\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"reloadTree\">\n > &\n Pick<\n TreeNodeRendererProps,\n \"onFilterClick\" | \"getIcon\" | \"getLabel\" | \"getSublabel\" | \"filterButtonsVisibility\" | \"getActions\"\n > &\n TreeRendererOwnProps &\n Omit<TreeProps, \"data\" | \"nodeRenderer\" | \"getNode\" | \"enableVirtualization\"> &\n ComponentPropsWithoutRef<typeof LocalizationContextProvider>;\n\n/**\n * A component that renders a tree using the `Tree` component from `@itwin/itwinui-react`. The tree nodes\n * are rendered using `TreeNodeRenderer` component from this package.\n *\n * @see https://itwinui.bentley.com/docs/tree\n * @public\n */\nexport function TreeRenderer({\n rootNodes,\n expandNode,\n selectNodes,\n isNodeSelected,\n onFilterClick,\n getIcon,\n getLabel,\n getSublabel,\n getHierarchyLevelDetails,\n reloadTree,\n selectionMode,\n localizedStrings,\n size,\n filterButtonsVisibility,\n getActions,\n ...treeProps\n}: TreeRendererProps) {\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({\n rootNodes,\n selectNodes: selectNodes ?? noopSelectNodes,\n selectionMode: selectionMode ?? \"single\",\n });\n const nodeRenderer = useCallback<TreeProps[\"nodeRenderer\"]>(\n (nodeProps) => {\n return (\n <TreeNodeRenderer\n {...nodeProps}\n filterButtonsVisibility={filterButtonsVisibility}\n expandNode={expandNode}\n getHierarchyLevelDetails={getHierarchyLevelDetails}\n onFilterClick={onFilterClick}\n onNodeClick={onNodeClick}\n onNodeKeyDown={onNodeKeyDown}\n getIcon={getIcon}\n getLabel={getLabel}\n getSublabel={getSublabel}\n reloadTree={reloadTree}\n size={size}\n getActions={getActions}\n />\n );\n },\n [\n filterButtonsVisibility,\n expandNode,\n getHierarchyLevelDetails,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n getIcon,\n getLabel,\n getSublabel,\n reloadTree,\n size,\n getActions,\n ],\n );\n\n const getNode = useCallback<TreeProps[\"getNode\"]>(\n (node) => createRenderedTreeNodeData(node, isNodeSelected ?? noopIsNodeSelected),\n [isNodeSelected],\n );\n\n return (\n <LocalizationContextProvider localizedStrings={localizedStrings}>\n <Tree<RenderedTreeNode>\n {...treeProps}\n size={size}\n data={rootNodes}\n nodeRenderer={nodeRenderer}\n getNode={getNode}\n enableVirtualization={true}\n />\n </LocalizationContextProvider>\n );\n}\n\nfunction noopSelectNodes() {}\nfunction noopIsNodeSelected() {\n return false;\n}\n\n/**\n * A data structure for a tree node that is rendered using the `TreeRenderer` component.\n *\n * In addition to the `PresentationTreeNode` union, this type may have one additional variation - an informational\n * type of node with `ChildrenPlaceholder` type. This type of node is returned as the single child node of a parent\n * while its children are being loaded. This allows the node renderer to show a placeholder under the parent during\n * the process.\n *\n * @public\n */\nexport type RenderedTreeNode =\n | PresentationTreeNode\n | { id: string; parentNodeId: string | undefined; type: \"ChildrenPlaceholder\" };\n\n/**\n * An utility function that creates an `@itwin/itwinui-react` `NodeData` object for the `Tree` component from a\n * `RenderedTreeNode` object.\n *\n * Usage example:\n * ```tsx\n * function MyComponent({ rootNodes, nodeRenderer }: MyComponentProps) {\n * const getNode = useCallback<TreeProps[\"getNode\"]>((node) => createRenderedTreeNodeData(node, () => false), []);\n * return <Tree<RenderedTreeNode> data={rootNodes} getNode={getNode} nodeRenderer={nodeRenderer} />;\n * }\n * ```\n *\n * @public\n */\nexport function createRenderedTreeNodeData(\n node: RenderedTreeNode,\n isNodeSelected: (nodeId: string) => boolean,\n): NodeData<RenderedTreeNode> {\n if (\"type\" in node) {\n return { nodeId: node.id, node, hasSubNodes: false, isExpanded: false, isSelected: false, isDisabled: true };\n }\n return {\n nodeId: node.id,\n node,\n hasSubNodes: node.children === true || node.children.length > 0,\n subNodes:\n // returns placeholder node to show as child while children is loading.\n node.children === true\n ? [{ id: `Loading-${node.id}`, parentNodeId: node.id, type: \"ChildrenPlaceholder\" }]\n : node.children,\n isExpanded: node.isExpanded,\n isSelected: isNodeSelected(node.id),\n };\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  export { TreeNodeRenderer } from "./presentation-hierarchies-react/itwinui/TreeNodeRenderer.js";
2
- export { RenderedTreeNode, TreeRenderer, createRenderedTreeNodeData } from "./presentation-hierarchies-react/itwinui/TreeRenderer.js";
2
+ export { RenderedTreeNode, TreeRenderer, createRenderedTreeNodeData, } from "./presentation-hierarchies-react/itwinui/TreeRenderer.js";
3
3
  //# sourceMappingURL=presentation-hierarchies-react-itwinui.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"presentation-hierarchies-react-itwinui.d.ts","sourceRoot":"","sources":["../../src/presentation-hierarchies-react-itwinui.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC"}
1
+ {"version":3,"file":"presentation-hierarchies-react-itwinui.d.ts","sourceRoot":"","sources":["../../src/presentation-hierarchies-react-itwinui.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAChG,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,0BAA0B,GAC3B,MAAM,0DAA0D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"presentation-hierarchies-react-itwinui.js","sourceRoot":"","sources":["../../src/presentation-hierarchies-react-itwinui.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,oGAAgG;AAAvF,uHAAA,gBAAgB,OAAA;AACzB,4FAAsI;AAA3G,+GAAA,YAAY,OAAA;AAAE,6HAAA,0BAA0B,OAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport { TreeNodeRenderer } from \"./presentation-hierarchies-react/itwinui/TreeNodeRenderer.js\";\nexport { RenderedTreeNode, TreeRenderer, createRenderedTreeNodeData } from \"./presentation-hierarchies-react/itwinui/TreeRenderer.js\";\n"]}
1
+ {"version":3,"file":"presentation-hierarchies-react-itwinui.js","sourceRoot":"","sources":["../../src/presentation-hierarchies-react-itwinui.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,oGAAgG;AAAvF,uHAAA,gBAAgB,OAAA;AACzB,4FAIkE;AAFhE,+GAAA,YAAY,OAAA;AACZ,6HAAA,0BAA0B,OAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport { TreeNodeRenderer } from \"./presentation-hierarchies-react/itwinui/TreeNodeRenderer.js\";\nexport {\n RenderedTreeNode,\n TreeRenderer,\n createRenderedTreeNodeData,\n} from \"./presentation-hierarchies-react/itwinui/TreeRenderer.js\";\n"]}
@@ -71,7 +71,7 @@ interface LocalizationContextProviderProps {
71
71
  * Context provider for localized strings used in the components.
72
72
  * @public
73
73
  */
74
- export declare function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>): import("react/jsx-runtime").JSX.Element;
74
+ export declare function LocalizationContextProvider({ localizedStrings, children, }: PropsWithChildren<LocalizationContextProviderProps>): import("react/jsx-runtime").JSX.Element;
75
75
  /** @internal */
76
76
  export declare function useLocalizationContext(): LocalizationContext;
77
77
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/LocalizationContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,gCAAgC,EAAE,MAAM,CAAC;IACzC;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,mCAAmC,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAiBD;;;GAGG;AACH,UAAU,gCAAgC;IACxC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,2CAQ9H;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,wBAErC"}
1
+ {"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/LocalizationContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,gCAAgC,EAAE,MAAM,CAAC;IACzC;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,mCAAmC,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAkBD;;;GAGG;AACH,UAAU,gCAAgC;IACxC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,gBAAgB,EAChB,QAAQ,GACT,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,2CAQrD;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,wBAErC"}
@@ -21,7 +21,7 @@ const localizationContext = createContext({ localizedStrings: defaultLocalizedSt
21
21
  * Context provider for localized strings used in the components.
22
22
  * @public
23
23
  */
24
- export function LocalizationContextProvider({ localizedStrings, children }) {
24
+ export function LocalizationContextProvider({ localizedStrings, children, }) {
25
25
  const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
26
26
  useEffect(() => {
27
27
  setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAgE1F,MAAM,uBAAuB,GAAqB;IAChD,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,cAAc;IACpC,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,qCAAqC;IACzD,mBAAmB,EAAE,uDAAuD;IAC5E,gCAAgC,EAAE,0GAA0G;IAC5I,sBAAsB,EAAE,oEAAoE;IAC5F,mCAAmC,EAAE,wEAAwE;IAC7G,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,MAAM,mBAAmB,GAAG,aAAa,CAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAW9G;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAuD;IAC7H,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE9G,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAgC,CAAC;AAC/F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB;IACpC,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, PropsWithChildren, useContext, useEffect, useState } from \"react\";\n\n/**\n * Localized strings used in the components.\n * @public\n */\nexport interface LocalizedStrings {\n /**\n * Message displayed when nodes are loading.\n * Default value: `Loading...`.\n */\n loading: string;\n /**\n * Title for apply hierarchy filter button.\n * Default value: `Apply filter`.\n */\n filterHierarchyLevel: string;\n /**\n * Title for clear hierarchy filter button.\n * Default value: `Clear active filter`.\n */\n clearHierarchyLevelFilter: string;\n /**\n * Message displayed when no nodes matching filter are found.\n * Default value: `No child nodes match current filter`.\n */\n noFilteredChildren: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `There are more items than allowed limit of {{limit}}.`.\n */\n resultLimitExceeded: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit and hierarchy filtering is enabled.\n * Default value: `Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.`.\n */\n resultLimitExceededWithFiltering: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `<link>Increase the hierarchy level size limit to {{limit}}.</link>`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Or, <link>increase the hierarchy level size limit to {{limit}}.</link>`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n /**\n * Label for more actions button.\n * Default value: `More`.\n */\n more: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No child nodes match current filter\",\n resultLimitExceeded: \"There are more items than allowed limit of {{limit}}.\",\n resultLimitExceededWithFiltering: \"Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.\",\n increaseHierarchyLimit: \"<link>Increase the hierarchy level size limit to {{limit}}.</link>\",\n increaseHierarchyLimitWithFiltering: \"Or, <link>increase the hierarchy level size limit to {{limit}}.</link>\",\n retry: \"Retry\",\n more: \"More\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>) {\n const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n\n useEffect(() => {\n setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n }, [localizedStrings]);\n\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"]}
1
+ {"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAgE1F,MAAM,uBAAuB,GAAqB;IAChD,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,cAAc;IACpC,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,qCAAqC;IACzD,mBAAmB,EAAE,uDAAuD;IAC5E,gCAAgC,EAC9B,0GAA0G;IAC5G,sBAAsB,EAAE,oEAAoE;IAC5F,mCAAmC,EAAE,wEAAwE;IAC7G,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,MAAM,mBAAmB,GAAG,aAAa,CAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAW9G;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAC1C,gBAAgB,EAChB,QAAQ,GAC4C;IACpD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE9G,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAgC,CAAC;AAC/F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB;IACpC,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, PropsWithChildren, useContext, useEffect, useState } from \"react\";\n\n/**\n * Localized strings used in the components.\n * @public\n */\nexport interface LocalizedStrings {\n /**\n * Message displayed when nodes are loading.\n * Default value: `Loading...`.\n */\n loading: string;\n /**\n * Title for apply hierarchy filter button.\n * Default value: `Apply filter`.\n */\n filterHierarchyLevel: string;\n /**\n * Title for clear hierarchy filter button.\n * Default value: `Clear active filter`.\n */\n clearHierarchyLevelFilter: string;\n /**\n * Message displayed when no nodes matching filter are found.\n * Default value: `No child nodes match current filter`.\n */\n noFilteredChildren: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `There are more items than allowed limit of {{limit}}.`.\n */\n resultLimitExceeded: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit and hierarchy filtering is enabled.\n * Default value: `Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.`.\n */\n resultLimitExceededWithFiltering: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `<link>Increase the hierarchy level size limit to {{limit}}.</link>`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Or, <link>increase the hierarchy level size limit to {{limit}}.</link>`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n /**\n * Label for more actions button.\n * Default value: `More`.\n */\n more: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No child nodes match current filter\",\n resultLimitExceeded: \"There are more items than allowed limit of {{limit}}.\",\n resultLimitExceededWithFiltering:\n \"Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.\",\n increaseHierarchyLimit: \"<link>Increase the hierarchy level size limit to {{limit}}.</link>\",\n increaseHierarchyLimitWithFiltering: \"Or, <link>increase the hierarchy level size limit to {{limit}}.</link>\",\n retry: \"Retry\",\n more: \"More\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({\n localizedStrings,\n children,\n}: PropsWithChildren<LocalizationContextProviderProps>) {\n const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n\n useEffect(() => {\n setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n }, [localizedStrings]);\n\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNode.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/TreeNode.ts"],"names":[],"mappings":"AAKA,OAAO,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,IAAI,yBAAyB,CAEzG"}
1
+ {"version":3,"file":"TreeNode.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/TreeNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,8CAA8C;IAC9C,QAAQ,EAAE,aAAa,CAAC;IACxB,yDAAyD;IACzD,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,mCAAmC;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qCAAqC;IACpD,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAC5B,2BAA2B,GAC3B,qCAAqC,GACrC,mCAAmC,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,GAAG,oBAAoB,CAAC;AAEpF;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,IAAI,yBAAyB,CAEzG"}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNode.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/TreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AA4EhG;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAA0B;IACpE,OAAO,UAAU,IAAI,IAAI,CAAC;AAC5B,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 { HierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/**\n * A type that defines an actual expandable node in a UI tree component, built with `useTree` hook.\n * @public\n */\nexport interface PresentationHierarchyNode {\n id: string;\n label: string;\n children: true | Array<PresentationTreeNode>;\n isExpanded: boolean;\n isLoading: boolean;\n isFilterable: boolean;\n isFiltered: boolean;\n /** UI-agnostic source of this node object. */\n nodeData: HierarchyNode;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A type of `PresentationInfoNode` that is returned as the single child of a filtered parent node,\n * when none of the child nodes match the filter.\n *\n * @public\n */\nexport interface PresentationNoFilterMatchesInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"NoFilterMatches\";\n}\n\n/**\n * A type of `PresentationInfoNode` that is returned as the single child of a parent node, when the\n * number of child nodes exceeds the limit set on the tree nodes loader. The limit is also included\n * on this node as `resultSetSizeLimit` attribute.\n *\n * @public\n */\nexport interface PresentationResultSetTooLargeInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"ResultSetTooLarge\";\n resultSetSizeLimit: number;\n}\n\n/**\n * A type of `PresentationInfoNode` that contains a user-friendly message to be displayed in the UI.\n * Generally, this is the only child of a parent node, created in cases like an error loading children. The\n * renderer may offer users to re-load the children or the whole component in such cases.\n *\n * @public\n */\nexport interface PresentationGenericInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"Unknown\";\n message: string;\n}\n\n/**\n * A type that defines a non-expandable, non-selectable informational node in a UI tree component, built\n * with `useTree` hook.\n *\n * @public\n */\nexport type PresentationInfoNode = PresentationGenericInfoNode | PresentationResultSetTooLargeInfoNode | PresentationNoFilterMatchesInfoNode;\n\n/**\n * A type that defines a node in a UI tree component, built with `useTree` hook.\n * @public\n */\nexport type PresentationTreeNode = PresentationHierarchyNode | PresentationInfoNode;\n\n/**\n * An utility function to check if a node is a `PresentationHierarchyNode`.\n * @public\n */\nexport function isPresentationHierarchyNode(node: PresentationTreeNode): node is PresentationHierarchyNode {\n return \"children\" in node;\n}\n"]}
1
+ {"version":3,"file":"TreeNode.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/TreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AA+EhG;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAA0B;IACpE,OAAO,UAAU,IAAI,IAAI,CAAC;AAC5B,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 { HierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/**\n * A type that defines an actual expandable node in a UI tree component, built with `useTree` hook.\n * @public\n */\nexport interface PresentationHierarchyNode {\n id: string;\n label: string;\n children: true | Array<PresentationTreeNode>;\n isExpanded: boolean;\n isLoading: boolean;\n isFilterable: boolean;\n isFiltered: boolean;\n /** UI-agnostic source of this node object. */\n nodeData: HierarchyNode;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A type of `PresentationInfoNode` that is returned as the single child of a filtered parent node,\n * when none of the child nodes match the filter.\n *\n * @public\n */\nexport interface PresentationNoFilterMatchesInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"NoFilterMatches\";\n}\n\n/**\n * A type of `PresentationInfoNode` that is returned as the single child of a parent node, when the\n * number of child nodes exceeds the limit set on the tree nodes loader. The limit is also included\n * on this node as `resultSetSizeLimit` attribute.\n *\n * @public\n */\nexport interface PresentationResultSetTooLargeInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"ResultSetTooLarge\";\n resultSetSizeLimit: number;\n}\n\n/**\n * A type of `PresentationInfoNode` that contains a user-friendly message to be displayed in the UI.\n * Generally, this is the only child of a parent node, created in cases like an error loading children. The\n * renderer may offer users to re-load the children or the whole component in such cases.\n *\n * @public\n */\nexport interface PresentationGenericInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"Unknown\";\n message: string;\n}\n\n/**\n * A type that defines a non-expandable, non-selectable informational node in a UI tree component, built\n * with `useTree` hook.\n *\n * @public\n */\nexport type PresentationInfoNode =\n | PresentationGenericInfoNode\n | PresentationResultSetTooLargeInfoNode\n | PresentationNoFilterMatchesInfoNode;\n\n/**\n * A type that defines a node in a UI tree component, built with `useTree` hook.\n * @public\n */\nexport type PresentationTreeNode = PresentationHierarchyNode | PresentationInfoNode;\n\n/**\n * An utility function to check if a node is a `PresentationHierarchyNode`.\n * @public\n */\nexport function isPresentationHierarchyNode(node: PresentationTreeNode): node is PresentationHierarchyNode {\n return \"children\" in node;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UnifiedSelectionContext.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UnifiedSelectionContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAI5D;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC;IAAE,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAAC,2CAE/G;AAED,gBAAgB;AAChB,wBAAgB,0BAA0B,iCAEzC"}
1
+ {"version":3,"file":"UnifiedSelectionContext.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UnifiedSelectionContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAI5D;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC;IAAE,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAAC,2CAI/G;AAED,gBAAgB;AAChB,wBAAgB,0BAA0B,iCAEzC"}
@@ -13,7 +13,7 @@ const deprecatedUnifiedSelectionContext = createContext(undefined);
13
13
  * @deprecated in 1.5.0. Use `UnifiedSelectionContextProvider` from `@itwin/unified-selection-react` instead.
14
14
  */
15
15
  export function UnifiedSelectionProvider({ storage, children }) {
16
- return _jsx(deprecatedUnifiedSelectionContext.Provider, { value: storage, children: children });
16
+ return (_jsx(deprecatedUnifiedSelectionContext.Provider, { value: storage, children: children }));
17
17
  }
18
18
  /** @internal */
19
19
  export function useUnifiedSelectionStorage() {
@@ -1 +1 @@
1
- {"version":3,"file":"UnifiedSelectionContext.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UnifiedSelectionContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAGrE,MAAM,iCAAiC,GAAG,aAAa,CAA+B,SAAS,CAAC,CAAC;AAEjG;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAoD;IAC9G,OAAO,KAAC,iCAAiC,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YAAG,QAAQ,GAA8C,CAAC;AAC7H,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,0BAA0B;IACxC,OAAO,UAAU,CAAC,iCAAiC,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, PropsWithChildren, useContext } from \"react\";\nimport { SelectionStorage } from \"@itwin/unified-selection\";\n\nconst deprecatedUnifiedSelectionContext = createContext<SelectionStorage | undefined>(undefined);\n\n/**\n * A React context provider that makes given selection storage available to all child components. This\n * is a requirement for `useUnifiedSelectionTree` to work with unified selection.\n *\n * @public\n * @deprecated in 1.5.0. Use `UnifiedSelectionContextProvider` from `@itwin/unified-selection-react` instead.\n */\nexport function UnifiedSelectionProvider({ storage, children }: PropsWithChildren<{ storage: SelectionStorage }>) {\n return <deprecatedUnifiedSelectionContext.Provider value={storage}>{children}</deprecatedUnifiedSelectionContext.Provider>;\n}\n\n/** @internal */\nexport function useUnifiedSelectionStorage() {\n return useContext(deprecatedUnifiedSelectionContext);\n}\n"]}
1
+ {"version":3,"file":"UnifiedSelectionContext.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UnifiedSelectionContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAGrE,MAAM,iCAAiC,GAAG,aAAa,CAA+B,SAAS,CAAC,CAAC;AAEjG;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAoD;IAC9G,OAAO,CACL,KAAC,iCAAiC,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YAAG,QAAQ,GAA8C,CACpH,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,0BAA0B;IACxC,OAAO,UAAU,CAAC,iCAAiC,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, PropsWithChildren, useContext } from \"react\";\nimport { SelectionStorage } from \"@itwin/unified-selection\";\n\nconst deprecatedUnifiedSelectionContext = createContext<SelectionStorage | undefined>(undefined);\n\n/**\n * A React context provider that makes given selection storage available to all child components. This\n * is a requirement for `useUnifiedSelectionTree` to work with unified selection.\n *\n * @public\n * @deprecated in 1.5.0. Use `UnifiedSelectionContextProvider` from `@itwin/unified-selection-react` instead.\n */\nexport function UnifiedSelectionProvider({ storage, children }: PropsWithChildren<{ storage: SelectionStorage }>) {\n return (\n <deprecatedUnifiedSelectionContext.Provider value={storage}>{children}</deprecatedUnifiedSelectionContext.Provider>\n );\n}\n\n/** @internal */\nexport function useUnifiedSelectionStorage() {\n return useContext(deprecatedUnifiedSelectionContext);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UseIModelTree.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseIModelTree.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC7H,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAW,YAAY,EAAE,aAAa,EAA2B,MAAM,cAAc,CAAC;AAE7F,cAAc;AACd,KAAK,4BAA4B,GAAG,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEhF,cAAc;AACd,KAAK,YAAY,GAAG,4BAA4B,CAAC,cAAc,CAAC,CAAC;AAEjE;;;GAGG;AACH,KAAK,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,sBAA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AAI,CAAC,4BAA4B,EAAE,kBAAkB,GAAG,cAAc,GAAG,eAAe,CAAC,GAAG;IAC1F,sDAAsD;IACtD,sBAAsB,EAAE,CAAC,KAAK,EAAE;QAAE,YAAY,EAAE,YAAY,CAAA;KAAE,KAAK,mBAAmB,CAAC;IAEvF,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE;QACzB,+FAA+F;QAC/F,YAAY,EAAE,YAAY,CAAC;QAC3B,2DAA2D;QAC3D,WAAW,EAAE,WAAW,CAAC;KAC1B,KAAK,OAAO,CAAC,sBAAsB,EAAE,GAAG,SAAS,CAAC,CAAC;CACrD,CAAC;AAEJ;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAMtE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kBAAkB,GAAG,4BAA4B,GAAG,aAAa,CAMrH"}
@@ -3,7 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { useCallback } from "react";
6
- import { createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
6
+ import { createIModelHierarchyProvider, } from "@itwin/presentation-hierarchies";
7
7
  import { useTree, useUnifiedSelectionTree } from "./UseTree.js";
8
8
  /**
9
9
  * A React hook that creates state for a tree component whose displayed hierarchy is based on
@@ -1 +1 @@
1
- {"version":3,"file":"UseIModelTree.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseIModelTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,6BAA6B,EAA+C,MAAM,iCAAiC,CAAC;AAG7H,OAAO,EAAE,OAAO,EAA+B,uBAAuB,EAAE,MAAM,cAAc,CAAC;AA0B7F;;;;;;;;;;;;GAYG;AACH,MAAM,UAA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AAY,EAAE,gBAAgB,CAAC,CACjC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { createIModelHierarchyProvider, HierarchyDefinition, HierarchyFilteringPath } from \"@itwin/presentation-hierarchies\";\nimport { Props } from \"@itwin/presentation-shared\";\nimport { UseUnifiedTreeSelectionProps } from \"./internal/UseUnifiedSelection.js\";\nimport { useTree, UseTreeProps, UseTreeResult, useUnifiedSelectionTree } from \"./UseTree.js\";\n\n/** @public */\ntype IModelHierarchyProviderProps = Props<typeof createIModelHierarchyProvider>;\n\n/** @public */\ntype IModelAccess = IModelHierarchyProviderProps[\"imodelAccess\"];\n\n/**\n * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.\n * @public\n */\ntype UseIModelTreeProps = Omit<UseTreeProps, \"getHierarchyProvider\" | \"getFilteredPaths\"> &\n Pick<IModelHierarchyProviderProps, \"localizedStrings\" | \"imodelAccess\" | \"imodelChanged\"> & {\n /** Provides the hierarchy definition for the tree. */\n getHierarchyDefinition: (props: { imodelAccess: IModelAccess }) => HierarchyDefinition;\n\n /** Provides paths to filtered nodes. */\n getFilteredPaths?: (props: {\n /** Object that provides access to the iModel schema and can run queries against the iModel. */\n imodelAccess: IModelAccess;\n /** Signal indicating that that the request was canceled */\n abortSignal: AbortSignal;\n }) => Promise<HierarchyFilteringPath[] | undefined>;\n };\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data.\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useTree`\n * @see `useIModelUnifiedSelectionTree`\n * @public\n */\nexport function useIModelTree(props: UseIModelTreeProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;\n return useTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),\n });\n}\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data and that is integrated with unified selection through the given selection\n * storage (previously the storage was provided through the, now deprecated, `UnifiedSelectionProvider`).\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useIModelTree`\n * @see `useUnifiedSelectionTree`\n * @see `UnifiedSelectionProvider`\n * @public\n */\nexport function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;\n return useUnifiedSelectionTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),\n });\n}\n\nfunction useIModelTreeProps(\n props: Pick<UseIModelTreeProps, \"imodelAccess\" | \"imodelChanged\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"localizedStrings\">,\n): Pick<UseTreeProps, \"getHierarchyProvider\" | \"getFilteredPaths\"> {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings } = props;\n return {\n getHierarchyProvider: useCallback(\n () =>\n createIModelHierarchyProvider({\n imodelAccess,\n imodelChanged,\n hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),\n localizedStrings,\n }),\n [imodelAccess, imodelChanged, getHierarchyDefinition, localizedStrings],\n ),\n getFilteredPaths: useCallback(\n async ({ abortSignal }: { abortSignal: AbortSignal }) => getFilteredPaths?.({ imodelAccess, abortSignal }),\n [imodelAccess, getFilteredPaths],\n ),\n };\n}\n"]}
1
+ {"version":3,"file":"UseIModelTree.js","sourceRoot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AC,EAAE,YAAY,EAAE,CAAC;YAC7D,gBAAgB;SACjB,CAAC,EACJ,CAAC,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,CAAC,CACxE;QACD,gBAAgB,EAAE,WAAW,CAC3B,KAAK,EAAE,EAAE,WAAW,EAAgC,EAAE,EAAE,CAAC,gBAAgB,EAAE,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,EAC1G,CAAC,YAAY,EAAE,gBAAgB,CAAC,CACjC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport {\n createIModelHierarchyProvider,\n HierarchyDefinition,\n HierarchyFilteringPath,\n} from \"@itwin/presentation-hierarchies\";\nimport { Props } from \"@itwin/presentation-shared\";\nimport { UseUnifiedTreeSelectionProps } from \"./internal/UseUnifiedSelection.js\";\nimport { useTree, UseTreeProps, UseTreeResult, useUnifiedSelectionTree } from \"./UseTree.js\";\n\n/** @public */\ntype IModelHierarchyProviderProps = Props<typeof createIModelHierarchyProvider>;\n\n/** @public */\ntype IModelAccess = IModelHierarchyProviderProps[\"imodelAccess\"];\n\n/**\n * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.\n * @public\n */\ntype UseIModelTreeProps = Omit<UseTreeProps, \"getHierarchyProvider\" | \"getFilteredPaths\"> &\n Pick<IModelHierarchyProviderProps, \"localizedStrings\" | \"imodelAccess\" | \"imodelChanged\"> & {\n /** Provides the hierarchy definition for the tree. */\n getHierarchyDefinition: (props: { imodelAccess: IModelAccess }) => HierarchyDefinition;\n\n /** Provides paths to filtered nodes. */\n getFilteredPaths?: (props: {\n /** Object that provides access to the iModel schema and can run queries against the iModel. */\n imodelAccess: IModelAccess;\n /** Signal indicating that that the request was canceled */\n abortSignal: AbortSignal;\n }) => Promise<HierarchyFilteringPath[] | undefined>;\n };\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data.\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useTree`\n * @see `useIModelUnifiedSelectionTree`\n * @public\n */\nexport function useIModelTree(props: UseIModelTreeProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;\n return useTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),\n });\n}\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data and that is integrated with unified selection through the given selection\n * storage (previously the storage was provided through the, now deprecated, `UnifiedSelectionProvider`).\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useIModelTree`\n * @see `useUnifiedSelectionTree`\n * @see `UnifiedSelectionProvider`\n * @public\n */\nexport function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;\n return useUnifiedSelectionTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),\n });\n}\n\nfunction useIModelTreeProps(\n props: Pick<\n UseIModelTreeProps,\n \"imodelAccess\" | \"imodelChanged\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"localizedStrings\"\n >,\n): Pick<UseTreeProps, \"getHierarchyProvider\" | \"getFilteredPaths\"> {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings } = props;\n return {\n getHierarchyProvider: useCallback(\n () =>\n createIModelHierarchyProvider({\n imodelAccess,\n imodelChanged,\n hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),\n localizedStrings,\n }),\n [imodelAccess, imodelChanged, getHierarchyDefinition, localizedStrings],\n ),\n getFilteredPaths: useCallback(\n async ({ abortSignal }: { abortSignal: AbortSignal }) => getFilteredPaths?.({ imodelAccess, abortSignal }),\n [imodelAccess, getFilteredPaths],\n ),\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UseSelectionHandler.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"names":[],"mappings":"AAMA,OAAO,EAA+B,yBAAyB,EAAwB,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAExE;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/D;;;GAGG;AACH,KAAK,wBAAwB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG;IAC9F,uDAAuD;IACvD,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,UAAU,yBAAyB;IACjC,0EAA0E;IAC1E,WAAW,EAAE,CAAC,IAAI,EAAE,yBAAyB,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;IAC9H,iFAAiF;IACjF,aAAa,EAAE,CAAC,IAAI,EAAE,yBAAyB,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACxH;AAOD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,yBAAyB,CAiE9F"}
1
+ {"version":3,"file":"UseSelectionHandler.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"names":[],"mappings":"AAMA,OAAO,EAA+B,yBAAyB,EAAwB,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAExE;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/D;;;GAGG;AACH,KAAK,wBAAwB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG;IAC9F,uDAAuD;IACvD,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,UAAU,yBAAyB;IACjC,0EAA0E;IAC1E,WAAW,EAAE,CACX,IAAI,EAAE,yBAAyB,EAC/B,UAAU,EAAE,OAAO,EACnB,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,KAC7C,IAAI,CAAC;IACV,iFAAiF;IACjF,aAAa,EAAE,CACb,IAAI,EAAE,yBAAyB,EAC/B,UAAU,EAAE,OAAO,EACnB,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KACpC,IAAI,CAAC;CACX;AAOD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,yBAAyB,CA8D9F"}
@@ -11,10 +11,7 @@ import { isPresentationHierarchyNode } from "./TreeNode.js";
11
11
  export function useSelectionHandler(props) {
12
12
  const { rootNodes, selectionMode, selectNodes } = props;
13
13
  const previousSelectionRef = useRef(undefined);
14
- const state = useRef({
15
- flatNodeList: [],
16
- nodeIdToIndexMap: new Map(),
17
- });
14
+ const state = useRef({ flatNodeList: [], nodeIdToIndexMap: new Map() });
18
15
  useEffect(() => {
19
16
  if (!rootNodes) {
20
17
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"UseSelectionHandler.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAmD,MAAM,eAAe,CAAC;AAiD7G;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACxD,MAAM,oBAAoB,GAAG,MAAM,CAAqB,SAAS,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,MAAM,CAAgB;QAClC,YAAY,EAAE,EAAE;QAChB,gBAAgB,EAAE,IAAI,GAAG,EAAE;KAC5B,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QACD,KAAK,CAAC,OAAO,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACjD,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAE,QAAiB,EAAE,EAAE;QAC3D,MAAM,QAAQ,GAAG,CAAC,MAAe,EAAE,EAAE;YACnC,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC;QACF,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrC,MAAM,WAAW,G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AkB,EAAE,QAAiB;IAC5F,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC9C,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7C,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAsC;IACjE,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,EAAE,CAAC;IAExD,MAAM,sBAAsB,GAAG,CAAC,KAAkC,EAAE,EAAE;QACpE,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvC,OAAO;YACT,CAAC;YACD,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;YACnD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,IAAI,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC1D,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC5C,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 { useCallback, useEffect, useRef } from \"react\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode, PresentationTreeNode } from \"./TreeNode.js\";\nimport { useTree } from \"./UseTree.js\";\n\n/**\n * A union of different supported selection modes in a tree component:\n * - `none` - no selection is allowed,\n * - `single` - only one node can be selected at a time,\n * - `extended` - multiple nodes can be selected using shift and ctrl keys,\n * - `multiple` - multiple nodes can be selected without using shift or ctrl keys.\n *\n * @public\n */\nexport type SelectionMode = \"none\" | \"single\" | \"extended\" | \"multiple\";\n\n/**\n * Type of selection change.\n * - `add` - a node was added to the selection,\n * - `replace` - a selected node was replaced with a different one,\n * - `remove` - a node was removed from the selection.\n *\n * @public\n */\nexport type SelectionChangeType = \"add\" | \"replace\" | \"remove\";\n\n/**\n * Props for `useSelectionHandler` hook.\n * @public\n */\ntype UseSelectionHandlerProps = Pick<ReturnType<typeof useTree>, \"rootNodes\" | \"selectNodes\"> & {\n /** Selection mode that the component is working in. */\n selectionMode: SelectionMode;\n};\n\n/**\n * Result of `useSelectionHandler` hook.\n * @public\n */\ninterface UseSelectionHandlerResult {\n /** Should be called by node renderer when a node component is clicked. */\n onNodeClick: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Should be called by node renderer when a keyboard event happens on a node. */\n onNodeKeyDown: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;\n}\n\ninterface FlatTreeState {\n flatNodeList: Array<string>;\n nodeIdToIndexMap: Map<string, number>;\n}\n\n/**\n * A react hook that helps implement different selection modes in a tree component created using `useTree` hook.\n * @public\n */\nexport function useSelectionHandler(props: UseSelectionHandlerProps): UseSelectionHandlerResult {\n const { rootNodes, selectionMode, selectNodes } = props;\n const previousSelectionRef = useRef<string | undefined>(undefined);\n const state = useRef<FlatTreeState>({\n flatNodeList: [],\n nodeIdToIndexMap: new Map(),\n });\n\n useEffect(() => {\n if (!rootNodes) {\n return;\n }\n state.current = computeFlatNodeList(rootNodes);\n }, [rootNodes]);\n\n const getNodeRange = (firstId?: string, secondId?: string) => {\n const getIndex = (nodeId?: string) => {\n return nodeId ? state.current.nodeIdToIndexMap.get(nodeId) : 0;\n };\n const firstIndex = getIndex(firstId);\n const secondIndex = getIndex(secondId);\n if (firstIndex === undefined || secondIndex === undefined) {\n return [];\n }\n\n const startingIndex = Math.min(firstIndex, secondIndex);\n const endIndex = Math.max(firstIndex, secondIndex);\n return state.current.flatNodeList.slice(startingIndex, endIndex + 1);\n };\n\n const onNodeSelect = useCallback(\n (nodeId: string, isSelected: boolean, shiftDown: boolean, ctrlDown: boolean) => {\n const selection = getSelectionAction(selectionMode, isSelected, shiftDown, ctrlDown);\n if (selection.type === \"disabled\") {\n return;\n }\n\n const nodes = selection.select === \"range\" ? getNodeRange(previousSelectionRef.current, nodeId) : [nodeId];\n if (!nodes.length) {\n return;\n }\n\n selection.select !== \"range\" && (previousSelectionRef.current = nodeId);\n selectNodes(nodes, selection.type);\n },\n [selectionMode, selectNodes],\n );\n\n const onNodeClick = useCallback(\n (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => {\n return onNodeSelect(node.id, isSelected, event.shiftKey, event.ctrlKey);\n },\n [onNodeSelect],\n );\n\n const onNodeKeyDown = useCallback(\n (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => {\n if (event.key === \" \" || event.key === \"Spacebar\" || event.key === \"Enter\") {\n return onNodeSelect(node.id, isSelected, event.shiftKey, event.ctrlKey);\n }\n },\n [onNodeSelect],\n );\n\n return { onNodeClick, onNodeKeyDown };\n}\n\ninterface SelectionAction {\n select: \"node\" | \"range\";\n type: SelectionChangeType | \"disabled\";\n}\n\nfunction getSelectionAction(selectionMode: SelectionMode, isSelected: boolean, shiftDown: boolean, ctrlDown: boolean): SelectionAction {\n switch (selectionMode) {\n case \"none\":\n return { select: \"node\", type: \"disabled\" };\n case \"single\":\n return { select: \"node\", type: isSelected ? \"replace\" : \"remove\" };\n case \"multiple\":\n return { select: \"node\", type: isSelected ? \"add\" : \"remove\" };\n case \"extended\":\n return getExtendedSelectionAction(isSelected, shiftDown, ctrlDown);\n }\n}\n\nfunction getExtendedSelectionAction(isSelected: boolean, shiftDown: boolean, ctrlDown: boolean): SelectionAction {\n if (shiftDown) {\n return { select: \"range\", type: \"replace\" };\n }\n if (ctrlDown) {\n return { select: \"node\", type: isSelected ? \"add\" : \"remove\" };\n }\n return { select: \"node\", type: \"replace\" };\n}\n\nfunction computeFlatNodeList(rootNodes: Array<PresentationTreeNode>): FlatTreeState {\n const flatNodeList: Array<string> = [];\n const nodeIdToIndexMap: Map<string, number> = new Map();\n\n const flattenNodeRecursively = (nodes: Array<PresentationTreeNode>) => {\n nodes.forEach((node) => {\n if (!isPresentationHierarchyNode(node)) {\n return;\n }\n nodeIdToIndexMap.set(node.id, flatNodeList.length);\n flatNodeList.push(node.id);\n if (node.isExpanded && typeof node.children !== \"boolean\") {\n flattenNodeRecursively(node.children);\n }\n });\n };\n\n flattenNodeRecursively(rootNodes);\n return { flatNodeList, nodeIdToIndexMap };\n}\n"]}
1
+ {"version":3,"file":"UseSelectionHandler.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAmD,MAAM,eAAe,CAAC;AAyD7G;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACxD,MAAM,oBAAoB,GAAG,MAAM,CAAqB,SAAS,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,MAAM,CAAgB,EAAE,YAAY,EAAE,EAAE,EAAE,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AAC,EAAE,CAAC;gBACvC,OAAO;YACT,CAAC;YACD,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;YACnD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,IAAI,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC1D,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC5C,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 { useCallback, useEffect, useRef } from \"react\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode, PresentationTreeNode } from \"./TreeNode.js\";\nimport { useTree } from \"./UseTree.js\";\n\n/**\n * A union of different supported selection modes in a tree component:\n * - `none` - no selection is allowed,\n * - `single` - only one node can be selected at a time,\n * - `extended` - multiple nodes can be selected using shift and ctrl keys,\n * - `multiple` - multiple nodes can be selected without using shift or ctrl keys.\n *\n * @public\n */\nexport type SelectionMode = \"none\" | \"single\" | \"extended\" | \"multiple\";\n\n/**\n * Type of selection change.\n * - `add` - a node was added to the selection,\n * - `replace` - a selected node was replaced with a different one,\n * - `remove` - a node was removed from the selection.\n *\n * @public\n */\nexport type SelectionChangeType = \"add\" | \"replace\" | \"remove\";\n\n/**\n * Props for `useSelectionHandler` hook.\n * @public\n */\ntype UseSelectionHandlerProps = Pick<ReturnType<typeof useTree>, \"rootNodes\" | \"selectNodes\"> & {\n /** Selection mode that the component is working in. */\n selectionMode: SelectionMode;\n};\n\n/**\n * Result of `useSelectionHandler` hook.\n * @public\n */\ninterface UseSelectionHandlerResult {\n /** Should be called by node renderer when a node component is clicked. */\n onNodeClick: (\n node: PresentationHierarchyNode,\n isSelected: boolean,\n event: React.MouseEvent<HTMLElement, MouseEvent>,\n ) => void;\n /** Should be called by node renderer when a keyboard event happens on a node. */\n onNodeKeyDown: (\n node: PresentationHierarchyNode,\n isSelected: boolean,\n event: React.KeyboardEvent<HTMLElement>,\n ) => void;\n}\n\ninterface FlatTreeState {\n flatNodeList: Array<string>;\n nodeIdToIndexMap: Map<string, number>;\n}\n\n/**\n * A react hook that helps implement different selection modes in a tree component created using `useTree` hook.\n * @public\n */\nexport function useSelectionHandler(props: UseSelectionHandlerProps): UseSelectionHandlerResult {\n const { rootNodes, selectionMode, selectNodes } = props;\n const previousSelectionRef = useRef<string | undefined>(undefined);\n const state = useRef<FlatTreeState>({ flatNodeList: [], nodeIdToIndexMap: new Map() });\n\n useEffect(() => {\n if (!rootNodes) {\n return;\n }\n state.current = computeFlatNodeList(rootNodes);\n }, [rootNodes]);\n\n const getNodeRange = (firstId?: string, secondId?: string) => {\n const getIndex = (nodeId?: string) => {\n return nodeId ? state.current.nodeIdToIndexMap.get(nodeId) : 0;\n };\n const firstIndex = getIndex(firstId);\n const secondIndex = getIndex(secondId);\n if (firstIndex === undefined || secondIndex === undefined) {\n return [];\n }\n\n const startingIndex = Math.min(firstIndex, secondIndex);\n const endIndex = Math.max(firstIndex, secondIndex);\n return state.current.flatNodeList.slice(startingIndex, endIndex + 1);\n };\n\n const onNodeSelect = useCallback(\n (nodeId: string, isSelected: boolean, shiftDown: boolean, ctrlDown: boolean) => {\n const selection = getSelectionAction(selectionMode, isSelected, shiftDown, ctrlDown);\n if (selection.type === \"disabled\") {\n return;\n }\n\n const nodes = selection.select === \"range\" ? getNodeRange(previousSelectionRef.current, nodeId) : [nodeId];\n if (!nodes.length) {\n return;\n }\n\n selection.select !== \"range\" && (previousSelectionRef.current = nodeId);\n selectNodes(nodes, selection.type);\n },\n [selectionMode, selectNodes],\n );\n\n const onNodeClick = useCallback(\n (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => {\n return onNodeSelect(node.id, isSelected, event.shiftKey, event.ctrlKey);\n },\n [onNodeSelect],\n );\n\n const onNodeKeyDown = useCallback(\n (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => {\n if (event.key === \" \" || event.key === \"Spacebar\" || event.key === \"Enter\") {\n return onNodeSelect(node.id, isSelected, event.shiftKey, event.ctrlKey);\n }\n },\n [onNodeSelect],\n );\n\n return { onNodeClick, onNodeKeyDown };\n}\n\ninterface SelectionAction {\n select: \"node\" | \"range\";\n type: SelectionChangeType | \"disabled\";\n}\n\nfunction getSelectionAction(\n selectionMode: SelectionMode,\n isSelected: boolean,\n shiftDown: boolean,\n ctrlDown: boolean,\n): SelectionAction {\n switch (selectionMode) {\n case \"none\":\n return { select: \"node\", type: \"disabled\" };\n case \"single\":\n return { select: \"node\", type: isSelected ? \"replace\" : \"remove\" };\n case \"multiple\":\n return { select: \"node\", type: isSelected ? \"add\" : \"remove\" };\n case \"extended\":\n return getExtendedSelectionAction(isSelected, shiftDown, ctrlDown);\n }\n}\n\nfunction getExtendedSelectionAction(isSelected: boolean, shiftDown: boolean, ctrlDown: boolean): SelectionAction {\n if (shiftDown) {\n return { select: \"range\", type: \"replace\" };\n }\n if (ctrlDown) {\n return { select: \"node\", type: isSelected ? \"add\" : \"remove\" };\n }\n return { select: \"node\", type: \"replace\" };\n}\n\nfunction computeFlatNodeList(rootNodes: Array<PresentationTreeNode>): FlatTreeState {\n const flatNodeList: Array<string> = [];\n const nodeIdToIndexMap: Map<string, number> = new Map();\n\n const flattenNodeRecursively = (nodes: Array<PresentationTreeNode>) => {\n nodes.forEach((node) => {\n if (!isPresentationHierarchyNode(node)) {\n return;\n }\n nodeIdToIndexMap.set(node.id, flatNodeList.length);\n flatNodeList.push(node.id);\n if (node.isExpanded && typeof node.children !== \"boolean\") {\n flattenNodeRecursively(node.children);\n }\n });\n };\n\n flattenNodeRecursively(rootNodes);\n return { flatNodeList, nodeIdToIndexMap };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UseTree.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseTree.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAClI,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGnF,OAAO,EAA2B,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAE1G,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,8FAA8F;IAC9F,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,8DAA8D;IAC9D,uBAAuB,EAAE,CAAC,KAAK,CAAC,EAAE;QAChC,cAAc,CAAC,EAAE,qBAAqB,CAAC;QACvC,uBAAuB,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;KAChD,KAAK,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAEzC,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACjC,6EAA6E;IAC7E,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,WAAW,KAAK,IAAI,CAAC;IAEhE,sEAAsE;IACtE,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,+DAA+D;IAC/D,iBAAiB,EAAE,CAAC,MAAM,EAAE,qBAAqB,GAAG,SAAS,KAAK,IAAI,CAAC;CACxE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,YA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,CAAC;IAC5F,qFAAqF;IACrF,YAAY,EAAE,CAAC,SAAS,EAAE,wBAAwB,GAAG,SAAS,KAAK,IAAI,CAAC;CACzE"}
@@ -3,9 +3,9 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { useCallback, useEffect, useRef, useState } from "react";
6
- import { HierarchyNode } from "@itwin/presentation-hierarchies";
6
+ import { HierarchyNode, } from "@itwin/presentation-hierarchies";
7
7
  import { TreeActions } from "./internal/TreeActions.js";
8
- import { isTreeModelHierarchyNode, isTreeModelInfoNode, TreeModel } from "./internal/TreeModel.js";
8
+ import { isTreeModelHierarchyNode, isTreeModelInfoNode, TreeModel, } from "./internal/TreeModel.js";
9
9
  import { useUnifiedTreeSelection } from "./internal/UseUnifiedSelection.js";
10
10
  import { safeDispose } from "./internal/Utils.js";
11
11
  /**
@@ -56,10 +56,7 @@ function useTreeInternal({ getHierarchyProvider, getFilteredPaths, onPerformance
56
56
  const onHierarchyLoadErrorRef = useLatest(onHierarchyLoadError);
57
57
  const [actions] = useState(() => new TreeActions((model) => {
58
58
  const rootNodes = model.parentChildMap.get(undefined) !== undefined ? generateTreeStructure(undefined, model) : undefined;
59
- setState({
60
- model,
61
- rootNodes,
62
- });
59
+ setState({ model, rootNodes });
63
60
  }, (actionType, duration) => onPerformanceMeasuredRef.current?.(actionType, duration), (props) => onHierarchyLimitExceededRef.current?.(props), (props) => onHierarchyLoadErrorRef.current?.(props)));
64
61
  const currentFormatter = useRef();
65
62
  const [hierarchyProvider, setHierarchyProvider] = useState();
@@ -188,26 +185,12 @@ function generateTreeStructure(parentNodeId, model) {
188
185
  return createPresentationHierarchyNode(node, model);
189
186
  }
190
187
  if (node.type === "ResultSetTooLarge") {
191
- return {
192
- id: node.id,
193
- parentNodeId,
194
- type: node.type,
195
- resultSetSizeLimit: node.resultSetSizeLimit,
196
- };
188
+ return { id: node.id, parentNodeId, type: node.type, resultSetSizeLimit: node.resultSetSizeLimit };
197
189
  }
198
190
  if (node.type === "NoFilterMatches") {
199
- return {
200
- id: node.id,
201
- parentNodeId,
202
- type: node.type,
203
- };
191
+ return { id: node.id, parentNodeId, type: node.type };
204
192
  }
205
- return {
206
- id: node.id,
207
- parentNodeId,
208
- type: node.type,
209
- message: node.message,
210
- };
193
+ return { id: node.id, parentNodeId, type: node.type, message: node.message };
211
194
  });
212
195
  }
213
196
  function createPresentationHierarchyNode(modelNode, model) {