@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.
- package/CHANGELOG.md +20 -0
- package/README.md +50 -10
- package/lib/cjs/presentation-hierarchies-react/LocalizationContext.d.ts +1 -1
- package/lib/cjs/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/LocalizationContext.js +1 -1
- package/lib/cjs/presentation-hierarchies-react/LocalizationContext.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/TreeNode.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.js +1 -1
- package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.js +1 -4
- package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/UseTree.js +4 -21
- package/lib/cjs/presentation-hierarchies-react/UseTree.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js +20 -5
- package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js +8 -20
- package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js +2 -9
- package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +7 -2
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +1 -1
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.js +2 -15
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react-itwinui.d.ts +1 -1
- package/lib/cjs/presentation-hierarchies-react-itwinui.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react-itwinui.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/LocalizationContext.d.ts +1 -1
- package/lib/esm/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/LocalizationContext.js +1 -1
- package/lib/esm/presentation-hierarchies-react/LocalizationContext.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +1 -1
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +1 -4
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +6 -23
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +22 -7
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +9 -21
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +3 -10
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +9 -4
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +2 -15
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react-itwinui.d.ts +1 -1
- package/lib/esm/presentation-hierarchies-react-itwinui.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react-itwinui.js +1 -1
- package/lib/esm/presentation-hierarchies-react-itwinui.js.map +1 -1
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseUnifiedSelection.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAkB,aAAa,EAA8C,MAAM,iCAAiC,CAAC;AAE5H,OAAO,EAAc,WAAW,EAAoB,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,wBAAwB,EAA4D,MAAM,gBAAgB,CAAC;AAyCpH,gBAAgB;AAChB,MAAM,UAAU,uBAAuB,CAAC,EACtC,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,8BAA8B,GACyF;IACvH,iCAAiC;IACjC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAuB,GAAG,EAAE,CAAC,CAAC;QAClE,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK;QAC3B,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;KACtB,CAAC,CAAC,CAAC;IAEJ,MAAM,0BAA0B,GAAG,0BAA0B,EAAE,CAAC;IAChE,gBAAgB,KAAK,0BAA0B,CAAC;IAEhD,8BAA8B,KAAK,qCAAqC,CAAC;IAEzE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,gBAAgB,EAAE,CAA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,CAAC;IAC/C,OAAO;QACL,uDAAuD;QACvD,CAAC,EAAE,CAAC,EAAE,CAAC,8BAA8B,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;KACpE,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,YAA8C;IAC7E,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,iBAAiB,EAAE,GAAG,EAAE,EAAE;QACzB,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;QACtC,IAAI,eAAe,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACnD,iCAAiC;QACjC,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,eAAe,GAAG,EAAE,CAAC;YACrB,iBAAiB,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC;QACjD,CAAC;QACD,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,iBAAiB,CAAC;IAC3B,CAAC,EACD,EAA4C,CAC7C,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 { useEffect, useState } from \"react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { GenericNodeKey, HierarchyNode, InstancesNodeKey, NonGroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { Selectable, Selectables, SelectionStorage } from \"@itwin/unified-selection\";\nimport { useUnifiedSelectionStorage } from \"../UnifiedSelectionContext.js\";\nimport { SelectionChangeType } from \"../UseSelectionHandler.js\";\nimport { isTreeModelHierarchyNode, TreeModelHierarchyNode, TreeModelNode, TreeModelRootNode } from \"./TreeModel.js\";\n\n/** @internal */\nexport interface TreeSelectionOptions {\n isNodeSelected: (nodeId: string) => boolean;\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;\n}\n\n/** @public */\nexport interface UseUnifiedTreeSelectionProps {\n /**\n * Identifier to distinguish this source of changes to the unified selection from another ones in the application.\n */\n sourceName: string;\n\n /**\n * An optional function that allows customizing the `Selectable` object that gets created for generic hierarchy nodes. When\n * not supplied, the `Selectable` is created using the following signature:\n * ```ts\n * {\n * identifier: treeModelNodeId,\n * data: node,\n * async *loadInstanceKeys() {},\n * }\n * ```\n *\n * @param node Hierarchy node to create a selectable for.\n * @param treeModelNodeId ID of the hierarchy node in the internal tree model. This ID uniquely identifies the node in the whole hierarchy, as opposed to `GenericNodeKey.id` contained within the `node`, which may not be unique.\n */\n createSelectableForGenericNode?: (node: NonGroupingHierarchyNode & { key: GenericNodeKey }, treeModelNodeId: string) => Selectable;\n\n /**\n * Unified selection storage to use for listening, getting and changing active selection.\n *\n * When not specified, the deprecated unified selection React context is used to access the\n * selection storage (see `UnifiedSelectionProvider`). This prop will be made required in the\n * next major release, where the deprecated context will also be removed.\n */\n selectionStorage?: SelectionStorage;\n}\n\n/** @internal */\nexport function useUnifiedTreeSelection({\n sourceName,\n selectionStorage,\n getTreeModelNode,\n createSelectableForGenericNode,\n}: UseUnifiedTreeSelectionProps & { getTreeModelNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined }): TreeSelectionOptions {\n /* v8 ignore next -- @preserve */\n const [options, setOptions] = useState<TreeSelectionOptions>(() => ({\n isNodeSelected: () => false,\n selectNodes: () => {},\n }));\n\n const deprecatedSelectionStorage = useUnifiedSelectionStorage();\n selectionStorage ??= deprecatedSelectionStorage;\n\n createSelectableForGenericNode ??= defaultCreateSelectableForGenericNode;\n\n useEffect(() => {\n if (!selectionStorage) {\n // TODO: make selectionStorage prop required\n setOptions({\n isNodeSelected: () => false,\n selectNodes: () => {},\n });\n return;\n }\n\n setOptions(createOptions(sourceName, selectionStorage, createSelectableForGenericNode, getTreeModelNode));\n return selectionStorage.selectionChangeEvent.addListener((args) => {\n if (args.level > 0) {\n return;\n }\n setOptions(createOptions(sourceName, selectionStorage, createSelectableForGenericNode, getTreeModelNode));\n });\n }, [selectionStorage, createSelectableForGenericNode, getTreeModelNode, sourceName]);\n\n return options;\n}\n\nconst defaultCreateSelectableForGenericNode: NonNullable<UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]> = (\n node,\n treeModelNodeId,\n): Selectable => ({\n identifier: treeModelNodeId,\n data: node,\n async *loadInstanceKeys() {},\n});\n\nfunction createOptions(\n source: string,\n storage: SelectionStorage,\n createSelectableForGenericNode: NonNullable<UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]>,\n getNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined,\n): TreeSelectionOptions {\n return {\n isNodeSelected: (nodeId: string) => {\n const node = getNode(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return false;\n }\n return Object.entries(groupNodeSelectablesByIModelKey(node, createSelectableForGenericNode)).some(([imodelKey, nodeSelectables]) => {\n const storageSelectables = storage.getSelection({ imodelKey, level: 0 });\n return Selectables.hasAny(storageSelectables, nodeSelectables);\n });\n },\n\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => {\n const imodelSelectables: { [imodelKey: string]: Selectable[] } = {};\n for (const nodeId of nodeIds) {\n const node = getNode(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return;\n }\n Object.entries(groupNodeSelectablesByIModelKey(node, createSelectableForGenericNode)).forEach(([imodelKey, nodeSelectables]) => {\n let selectablesList = imodelSelectables[imodelKey];\n /* v8 ignore else -- @preserve */\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables[imodelKey] = selectablesList;\n }\n nodeSelectables.forEach((selectable) => selectablesList.push(selectable));\n });\n }\n Object.entries(imodelSelectables).forEach(([imodelKey, selectables]) => {\n const actionProps = { imodelKey, source, selectables, level: 0 };\n switch (changeType) {\n case \"add\":\n storage.addToSelection(actionProps);\n return;\n case \"remove\":\n storage.removeFromSelection(actionProps);\n return;\n case \"replace\":\n storage.replaceSelection(actionProps);\n return;\n }\n });\n },\n };\n}\n\nfunction groupNodeSelectablesByIModelKey(\n modelNode: TreeModelHierarchyNode,\n createSelectableForGenericNode: NonNullable<UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]>,\n): { [imodelKey: string]: Selectable[] } {\n const hierarchyNode = modelNode.nodeData;\n if (HierarchyNode.isInstancesNode(hierarchyNode)) {\n return groupIModelInstanceKeys(hierarchyNode.key.instanceKeys);\n }\n if (HierarchyNode.isGroupingNode(hierarchyNode)) {\n return Object.entries(groupIModelInstanceKeys(hierarchyNode.groupedInstanceKeys)).reduce(\n (imodelSelectables, [imodelKey, instanceKeys]) => ({\n ...imodelSelectables,\n [imodelKey]: [\n {\n identifier: modelNode.id,\n data: hierarchyNode,\n async *loadInstanceKeys() {\n for (const key of instanceKeys) {\n yield key;\n }\n },\n },\n ],\n }),\n {} as { [imodelKey: string]: Selectable[] },\n );\n }\n assert(HierarchyNode.isGeneric(hierarchyNode));\n return {\n // note: generic nodes aren't associated with an imodel\n [\"\"]: [createSelectableForGenericNode(hierarchyNode, modelNode.id)],\n };\n}\n\nfunction groupIModelInstanceKeys(instanceKeys: InstancesNodeKey[\"instanceKeys\"]) {\n return instanceKeys.reduce(\n (imodelSelectables, key) => {\n const imodelKey = key.imodelKey ?? \"\";\n let selectablesList = imodelSelectables[imodelKey];\n /* v8 ignore else -- @preserve */\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables[imodelKey] = selectablesList;\n }\n selectablesList.push(key);\n return imodelSelectables;\n },\n {} as { [imodelKey: string]: InstanceKey[] },\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseUnifiedSelection.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,C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;QACjD,CAAC;QACD,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,iBAAiB,CAAC;IAC3B,CAAC,EACD,EAA4C,CAC7C,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 { useEffect, useState } from \"react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport {\n GenericNodeKey,\n HierarchyNode,\n InstancesNodeKey,\n NonGroupingHierarchyNode,\n} from \"@itwin/presentation-hierarchies\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { Selectable, Selectables, SelectionStorage } from \"@itwin/unified-selection\";\nimport { useUnifiedSelectionStorage } from \"../UnifiedSelectionContext.js\";\nimport { SelectionChangeType } from \"../UseSelectionHandler.js\";\nimport { isTreeModelHierarchyNode, TreeModelHierarchyNode, TreeModelNode, TreeModelRootNode } from \"./TreeModel.js\";\n\n/** @internal */\nexport interface TreeSelectionOptions {\n isNodeSelected: (nodeId: string) => boolean;\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;\n}\n\n/** @public */\nexport interface UseUnifiedTreeSelectionProps {\n /**\n * Identifier to distinguish this source of changes to the unified selection from another ones in the application.\n */\n sourceName: string;\n\n /**\n * An optional function that allows customizing the `Selectable` object that gets created for generic hierarchy nodes. When\n * not supplied, the `Selectable` is created using the following signature:\n * ```ts\n * {\n * identifier: treeModelNodeId,\n * data: node,\n * async *loadInstanceKeys() {},\n * }\n * ```\n *\n * @param node Hierarchy node to create a selectable for.\n * @param treeModelNodeId ID of the hierarchy node in the internal tree model. This ID uniquely identifies the node in the whole hierarchy, as opposed to `GenericNodeKey.id` contained within the `node`, which may not be unique.\n */\n createSelectableForGenericNode?: (\n node: NonGroupingHierarchyNode & { key: GenericNodeKey },\n treeModelNodeId: string,\n ) => Selectable;\n\n /**\n * Unified selection storage to use for listening, getting and changing active selection.\n *\n * When not specified, the deprecated unified selection React context is used to access the\n * selection storage (see `UnifiedSelectionProvider`). This prop will be made required in the\n * next major release, where the deprecated context will also be removed.\n */\n selectionStorage?: SelectionStorage;\n}\n\n/** @internal */\nexport function useUnifiedTreeSelection({\n sourceName,\n selectionStorage,\n getTreeModelNode,\n createSelectableForGenericNode,\n}: UseUnifiedTreeSelectionProps & {\n getTreeModelNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined;\n}): TreeSelectionOptions {\n /* v8 ignore next -- @preserve */\n const [options, setOptions] = useState<TreeSelectionOptions>(() => ({\n isNodeSelected: () => false,\n selectNodes: () => {},\n }));\n\n const deprecatedSelectionStorage = useUnifiedSelectionStorage();\n selectionStorage ??= deprecatedSelectionStorage;\n\n createSelectableForGenericNode ??= defaultCreateSelectableForGenericNode;\n\n useEffect(() => {\n if (!selectionStorage) {\n // TODO: make selectionStorage prop required\n setOptions({ isNodeSelected: () => false, selectNodes: () => {} });\n return;\n }\n\n setOptions(createOptions(sourceName, selectionStorage, createSelectableForGenericNode, getTreeModelNode));\n return selectionStorage.selectionChangeEvent.addListener((args) => {\n if (args.level > 0) {\n return;\n }\n setOptions(createOptions(sourceName, selectionStorage, createSelectableForGenericNode, getTreeModelNode));\n });\n }, [selectionStorage, createSelectableForGenericNode, getTreeModelNode, sourceName]);\n\n return options;\n}\n\nconst defaultCreateSelectableForGenericNode: NonNullable<\n UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]\n> = (node, treeModelNodeId): Selectable => ({ identifier: treeModelNodeId, data: node, async *loadInstanceKeys() {} });\n\nfunction createOptions(\n source: string,\n storage: SelectionStorage,\n createSelectableForGenericNode: NonNullable<UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]>,\n getNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined,\n): TreeSelectionOptions {\n return {\n isNodeSelected: (nodeId: string) => {\n const node = getNode(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return false;\n }\n return Object.entries(groupNodeSelectablesByIModelKey(node, createSelectableForGenericNode)).some(\n ([imodelKey, nodeSelectables]) => {\n const storageSelectables = storage.getSelection({ imodelKey, level: 0 });\n return Selectables.hasAny(storageSelectables, nodeSelectables);\n },\n );\n },\n\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => {\n const imodelSelectables: { [imodelKey: string]: Selectable[] } = {};\n for (const nodeId of nodeIds) {\n const node = getNode(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return;\n }\n Object.entries(groupNodeSelectablesByIModelKey(node, createSelectableForGenericNode)).forEach(\n ([imodelKey, nodeSelectables]) => {\n let selectablesList = imodelSelectables[imodelKey];\n /* v8 ignore else -- @preserve */\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables[imodelKey] = selectablesList;\n }\n nodeSelectables.forEach((selectable) => selectablesList.push(selectable));\n },\n );\n }\n Object.entries(imodelSelectables).forEach(([imodelKey, selectables]) => {\n const actionProps = { imodelKey, source, selectables, level: 0 };\n switch (changeType) {\n case \"add\":\n storage.addToSelection(actionProps);\n return;\n case \"remove\":\n storage.removeFromSelection(actionProps);\n return;\n case \"replace\":\n storage.replaceSelection(actionProps);\n return;\n }\n });\n },\n };\n}\n\nfunction groupNodeSelectablesByIModelKey(\n modelNode: TreeModelHierarchyNode,\n createSelectableForGenericNode: NonNullable<UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]>,\n): { [imodelKey: string]: Selectable[] } {\n const hierarchyNode = modelNode.nodeData;\n if (HierarchyNode.isInstancesNode(hierarchyNode)) {\n return groupIModelInstanceKeys(hierarchyNode.key.instanceKeys);\n }\n if (HierarchyNode.isGroupingNode(hierarchyNode)) {\n return Object.entries(groupIModelInstanceKeys(hierarchyNode.groupedInstanceKeys)).reduce(\n (imodelSelectables, [imodelKey, instanceKeys]) => ({\n ...imodelSelectables,\n [imodelKey]: [\n {\n identifier: modelNode.id,\n data: hierarchyNode,\n async *loadInstanceKeys() {\n for (const key of instanceKeys) {\n yield key;\n }\n },\n },\n ],\n }),\n {} as { [imodelKey: string]: Selectable[] },\n );\n }\n assert(HierarchyNode.isGeneric(hierarchyNode));\n return {\n // note: generic nodes aren't associated with an imodel\n [\"\"]: [createSelectableForGenericNode(hierarchyNode, modelNode.id)],\n };\n}\n\nfunction groupIModelInstanceKeys(instanceKeys: InstancesNodeKey[\"instanceKeys\"]) {\n return instanceKeys.reduce(\n (imodelSelectables, key) => {\n const imodelKey = key.imodelKey ?? \"\";\n let selectablesList = imodelSelectables[imodelKey];\n /* v8 ignore else -- @preserve */\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables[imodelKey] = selectablesList;\n }\n selectablesList.push(key);\n return imodelSelectables;\n },\n {} as { [imodelKey: string]: InstanceKey[] },\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,wBAAwB,CAAC;AAGhC,OAAO,
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,wBAAwB,CAAC;AAGhC,OAAO,EACL,wBAAwB,EAIxB,YAAY,EAEZ,aAAa,EAId,MAAM,OAAO,CAAC;AAEf,OAAO,EASL,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAA+B,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,cAAc;AACd,KAAK,aAAa,GAAG,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE/D,cAAc;AACd,MAA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,MAAM,CAAC;IACnD;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,yBAAyB,KAAK,wBAAwB,EAAE,CAAC;CAC9E;AAED,cAAc;AACd,KAAK,qBAAqB,GAAG,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,GAC5D,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,0BAA0B,CAAC,CAAC,GACxD,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,GAAG,MAAM,CAAC,GACnE,wBAAwB,CAAC;AAE3B;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,yBAAyB,CAAC,qBAAqB,GAAG,aAAa,CAAC,cAAc,CAAC,CAsGjH,CAAC"}
|
|
@@ -5,9 +5,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
import "./TreeNodeRenderer.css";
|
|
7
7
|
import cx from "classnames";
|
|
8
|
-
import { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
8
|
+
import { forwardRef, useCallback, useEffect, useRef, } from "react";
|
|
9
9
|
import { SvgFilter, SvgFilterHollow, SvgMore, SvgRemove } from "@itwin/itwinui-icons-react";
|
|
10
|
-
import { Anchor, ButtonGroup, DropdownMenu, Flex, IconButton, MenuItem, ProgressRadial, Text, TreeNode } from "@itwin/itwinui-react";
|
|
10
|
+
import { Anchor, ButtonGroup, DropdownMenu, Flex, IconButton, MenuItem, ProgressRadial, Text, TreeNode, } from "@itwin/itwinui-react";
|
|
11
11
|
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
12
12
|
import { MAX_LIMIT_OVERRIDE } from "../internal/Utils.js";
|
|
13
13
|
import { useLocalizationContext } from "../LocalizationContext.js";
|
|
@@ -50,7 +50,10 @@ TreeNodeRenderer.displayName = "TreeNodeRenderer";
|
|
|
50
50
|
const HierarchyNodeRenderer = forwardRef(({ node, expandNode, getIcon, getLabel, getSublabel, onFilterClick, onNodeClick, onNodeKeyDown, isSelected, isDisabled, actionButtonsClassName, getHierarchyLevelDetails, filterButtonsVisibility, getActions, ...treeNodeProps }, forwardedRef) => {
|
|
51
51
|
const nodeRef = useRef(null);
|
|
52
52
|
const ref = useMergedRefs(forwardedRef, nodeRef);
|
|
53
|
-
return (_jsx(TreeNode, { ...treeNodeProps, ref: ref, isSelected: isSelected, isDisabled: isDisabled, className: cx(treeNodeProps.className, "stateless-tree-node", {
|
|
53
|
+
return (_jsx(TreeNode, { ...treeNodeProps, ref: ref, isSelected: isSelected, isDisabled: isDisabled, className: cx(treeNodeProps.className, "stateless-tree-node", {
|
|
54
|
+
filtered: node.isFiltered,
|
|
55
|
+
selected: isSelected,
|
|
56
|
+
}), onClick: (event) => !isDisabled && onNodeClick?.(node, !isSelected, event), onKeyDown: (event) => {
|
|
54
57
|
// Ignore if it is called on the element inside, e.g. checkbox or expander
|
|
55
58
|
if (!isDisabled && event.target === nodeRef.current) {
|
|
56
59
|
onNodeKeyDown?.(node, !isSelected, event);
|
|
@@ -123,7 +126,9 @@ function ResultSetTooLargeNodeLabel({ onFilterClick, onOverrideLimit, limit }) {
|
|
|
123
126
|
const supportsLimitOverride = !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE;
|
|
124
127
|
const limitExceededMessage = createLocalizedMessage(supportsFiltering ? localizedStrings.resultLimitExceededWithFiltering : localizedStrings.resultLimitExceeded, limit, onFilterClick);
|
|
125
128
|
const increaseLimitMessage = supportsLimitOverride
|
|
126
|
-
? createLocalizedMessage(supportsFiltering
|
|
129
|
+
? createLocalizedMessage(supportsFiltering
|
|
130
|
+
? localizedStrings.increaseHierarchyLimitWithFiltering
|
|
131
|
+
: localizedStrings.increaseHierarchyLimit, MAX_LIMIT_OVERRIDE, () => onOverrideLimit(MAX_LIMIT_OVERRIDE))
|
|
127
132
|
: { title: "", element: null };
|
|
128
133
|
const title = `${limitExceededMessage.title} ${increaseLimitMessage.title}`;
|
|
129
134
|
return (_jsxs(Flex, { flexDirection: "column", gap: "3xs", title: title, alignItems: "start", children: [limitExceededMessage.element, increaseLimitMessage.element] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAA4B,UAAU,EAAiE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5J,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrI,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAA6B,MAAM,gBAAgB,CAAC;AA0DxF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA2F,UAAU,CAChI,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,sBAAsB,EAAE,CAAC;I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AC,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,WAAW,CAChB,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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,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 {\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB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AM,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"}
|
|
@@ -60,14 +60,7 @@ function noopIsNodeSelected() {
|
|
|
60
60
|
*/
|
|
61
61
|
export function createRenderedTreeNodeData(node, isNodeSelected) {
|
|
62
62
|
if ("type" in node) {
|
|
63
|
-
return {
|
|
64
|
-
nodeId: node.id,
|
|
65
|
-
node,
|
|
66
|
-
hasSubNodes: false,
|
|
67
|
-
isExpanded: false,
|
|
68
|
-
isSelected: false,
|
|
69
|
-
isDisabled: true,
|
|
70
|
-
};
|
|
63
|
+
return { nodeId: node.id, node, hasSubNodes: false, isExpanded: false, isSelected: false, isDisabled: true };
|
|
71
64
|
}
|
|
72
65
|
return {
|
|
73
66
|
nodeId: node.id,
|
|
@@ -76,13 +69,7 @@ export function createRenderedTreeNodeData(node, isNodeSelected) {
|
|
|
76
69
|
subNodes:
|
|
77
70
|
// returns placeholder node to show as child while children is loading.
|
|
78
71
|
node.children === true
|
|
79
|
-
? [
|
|
80
|
-
{
|
|
81
|
-
id: `Loading-${node.id}`,
|
|
82
|
-
parentNodeId: node.id,
|
|
83
|
-
type: "ChildrenPlaceholder",
|
|
84
|
-
},
|
|
85
|
-
]
|
|
72
|
+
? [{ id: `Loading-${node.id}`, parentNodeId: node.id, type: "ChildrenPlaceholder" }]
|
|
86
73
|
: node.children,
|
|
87
74
|
isExpanded: node.isExpanded,
|
|
88
75
|
isSelected: isNodeSelected(node.id),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAA4B,WAAW,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAY,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAExE,OAAO,EAAiB,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAA4B,WAAW,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAY,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAExE,OAAO,EAAiB,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AA6BzD;;;;;;GAMG;AACH,MAAM,UAAU,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,mBAAmB,CAAC;QACzD,SAAS;QACT,WAAW,EAAE,WAAW,IAAI,eAAe;QAC3C,aAAa,EAAE,aAAa,IAAI,QAAQ;KACzC,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,SAAS,EAAE,EAAE;QACZ,OAAO,CACL,KAAC,gBAAgB,OACX,SAAS,EACb,uBAAuB,EAAE,uBAAuB,EAChD,UAAU,EAAE,UAAU,EACtB,wBAA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;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,
|
|
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"}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
export { TreeNodeRenderer } from "./presentation-hierarchies-react/itwinui/TreeNodeRenderer.js";
|
|
6
|
-
export { TreeRenderer, createRenderedTreeNodeData } from "./presentation-hierarchies-react/itwinui/TreeRenderer.js";
|
|
6
|
+
export { TreeRenderer, createRenderedTreeNodeData, } from "./presentation-hierarchies-react/itwinui/TreeRenderer.js";
|
|
7
7
|
//# sourceMappingURL=presentation-hierarchies-react-itwinui.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-hierarchies-react-itwinui.js","sourceRoot":"","sources":["../../src/presentation-hierarchies-react-itwinui.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAChG,OAAO,
|
|
1
|
+
{"version":3,"file":"presentation-hierarchies-react-itwinui.js","sourceRoot":"","sources":["../../src/presentation-hierarchies-react-itwinui.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAChG,OAAO,EAEL,YAAY,EACZ,0BAA0B,GAC3B,MAAM,0DAA0D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport { TreeNodeRenderer } from \"./presentation-hierarchies-react/itwinui/TreeNodeRenderer.js\";\nexport {\n RenderedTreeNode,\n TreeRenderer,\n createRenderedTreeNodeData,\n} from \"./presentation-hierarchies-react/itwinui/TreeRenderer.js\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-hierarchies-react",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.3",
|
|
4
4
|
"description": "React components based on `@itwin/presentation-hierarchies`",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
"./package.json": "./package.json"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@itwin/core-bentley": "^5.
|
|
50
|
+
"@itwin/core-bentley": "^5.9.1",
|
|
51
51
|
"@itwin/itwinui-icons-react": "^2.11.0",
|
|
52
52
|
"@itwin/itwinui-illustrations-react": "^2.1.0",
|
|
53
53
|
"classnames": "^2.5.1",
|
|
54
54
|
"immer": "^10.2.0",
|
|
55
55
|
"react-error-boundary": "^4.1.2",
|
|
56
56
|
"rxjs": "^7.8.2",
|
|
57
|
-
"@itwin/presentation-hierarchies": "^1.7.
|
|
58
|
-
"@itwin/presentation-shared": "^1.2.
|
|
59
|
-
"@itwin/unified-selection": "^1.7.
|
|
57
|
+
"@itwin/presentation-hierarchies": "^1.7.14",
|
|
58
|
+
"@itwin/presentation-shared": "^1.2.13",
|
|
59
|
+
"@itwin/unified-selection": "^1.7.3"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@itwin/itwinui-react": "^3.0.0",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@itwin/build-tools": "^5.
|
|
73
|
-
"@itwin/eslint-plugin": "
|
|
72
|
+
"@itwin/build-tools": "^5.10.0-dev.6",
|
|
73
|
+
"@itwin/eslint-plugin": "^6.1.0",
|
|
74
74
|
"@itwin/itwinui-react": "^3.20.2",
|
|
75
75
|
"@testing-library/dom": "^10.4.1",
|
|
76
76
|
"@testing-library/react": "^16.3.2",
|
|
@@ -78,16 +78,16 @@
|
|
|
78
78
|
"@types/node": "^24.12.2",
|
|
79
79
|
"@types/react": "^18.3.28",
|
|
80
80
|
"@types/react-dom": "^18.3.7",
|
|
81
|
-
"@vitest/coverage-v8": "^4.1.
|
|
81
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
82
82
|
"cpx2": "^7.0.2",
|
|
83
83
|
"eslint": "^9.39.4",
|
|
84
84
|
"eslint-plugin-react": "^7.37.5",
|
|
85
|
-
"happy-dom": "^20.
|
|
85
|
+
"happy-dom": "^20.9.0",
|
|
86
86
|
"react": "^18.3.1",
|
|
87
87
|
"react-dom": "^18.3.1",
|
|
88
88
|
"rimraf": "^6.1.3",
|
|
89
|
-
"typescript": "~
|
|
90
|
-
"vitest": "^4.1.
|
|
89
|
+
"typescript": "~6.0.0",
|
|
90
|
+
"vitest": "^4.1.5",
|
|
91
91
|
"presentation-test-utilities": "^0.0.1"
|
|
92
92
|
},
|
|
93
93
|
"scripts": {
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
100
100
|
"clean": "rimraf lib build",
|
|
101
101
|
"cover": "vitest run --coverage",
|
|
102
|
-
"lint": "eslint ./src/**/*.{ts,tsx}",
|
|
102
|
+
"lint": "eslint \"./src/**/*.{ts,tsx}\"",
|
|
103
103
|
"test": "vitest run",
|
|
104
104
|
"test:watch": "vitest",
|
|
105
105
|
"extract-api": "betools extract-api --entry=lib/esm/presentation-hierarchies-react --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api --includeUnexportedApis",
|