@itwin/components-react 5.27.1 → 5.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/lib/cjs/components-react/common/HighlightedText.scss +8 -0
- package/lib/components-react/UiComponents.json +0 -1
- package/lib/components-react/abstract-types.d.ts +8 -0
- package/lib/components-react/abstract-types.d.ts.map +1 -0
- package/lib/components-react/abstract-types.js +6 -0
- package/lib/components-react/abstract-types.js.map +1 -0
- package/lib/components-react/common/HighlightedText.d.ts +6 -0
- package/lib/components-react/common/HighlightedText.d.ts.map +1 -1
- package/lib/components-react/common/HighlightedText.js +7 -4
- package/lib/components-react/common/HighlightedText.js.map +1 -1
- package/lib/components-react/common/HighlightedText.scss +8 -0
- package/lib/components-react/common/selection/SelectionHandler.d.ts +3 -0
- package/lib/components-react/common/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/components-react/common/selection/SelectionHandler.js.map +1 -1
- package/lib/components-react/common/selection/SelectionModes.d.ts +3 -0
- package/lib/components-react/common/selection/SelectionModes.d.ts.map +1 -1
- package/lib/components-react/common/selection/SelectionModes.js +4 -0
- package/lib/components-react/common/selection/SelectionModes.js.map +1 -1
- package/lib/components-react/editors/CustomNumberEditor.d.ts +1 -0
- package/lib/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
- package/lib/components-react/editors/CustomNumberEditor.js +9 -2
- package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/components-react/editors/NumericInputEditor.d.ts +1 -0
- package/lib/components-react/editors/NumericInputEditor.d.ts.map +1 -1
- package/lib/components-react/editors/NumericInputEditor.js +7 -0
- package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
- package/lib/components-react/editors/TextEditor.d.ts +3 -0
- package/lib/components-react/editors/TextEditor.d.ts.map +1 -1
- package/lib/components-react/editors/TextEditor.js +21 -3
- package/lib/components-react/editors/TextEditor.js.map +1 -1
- package/lib/components-react/editors/TextareaEditor.d.ts +1 -0
- package/lib/components-react/editors/TextareaEditor.d.ts.map +1 -1
- package/lib/components-react/editors/TextareaEditor.js +7 -0
- package/lib/components-react/editors/TextareaEditor.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js +3 -0
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.js +3 -0
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.js.map +1 -1
- package/lib/components-react/properties/renderers/value/MergedPropertyValueRenderer.d.ts +1 -1
- package/lib/components-react/properties/renderers/value/MergedPropertyValueRenderer.d.ts.map +1 -1
- package/lib/components-react/properties/renderers/value/MergedPropertyValueRenderer.js +4 -7
- package/lib/components-react/properties/renderers/value/MergedPropertyValueRenderer.js.map +1 -1
- package/lib/components-react/tree/HighlightingEngine.d.ts +5 -0
- package/lib/components-react/tree/HighlightingEngine.d.ts.map +1 -1
- package/lib/components-react/tree/HighlightingEngine.js +3 -0
- package/lib/components-react/tree/HighlightingEngine.js.map +1 -1
- package/lib/components-react/tree/ImageLoader.d.ts +2 -0
- package/lib/components-react/tree/ImageLoader.d.ts.map +1 -1
- package/lib/components-react/tree/ImageLoader.js +1 -0
- package/lib/components-react/tree/ImageLoader.js.map +1 -1
- package/lib/components-react/tree/SimpleTreeDataProvider.d.ts +2 -0
- package/lib/components-react/tree/SimpleTreeDataProvider.d.ts.map +1 -1
- package/lib/components-react/tree/SimpleTreeDataProvider.js +1 -0
- package/lib/components-react/tree/SimpleTreeDataProvider.js.map +1 -1
- package/lib/components-react/tree/TreeDataProvider.d.ts +14 -0
- package/lib/components-react/tree/TreeDataProvider.d.ts.map +1 -1
- package/lib/components-react/tree/TreeDataProvider.js +5 -0
- package/lib/components-react/tree/TreeDataProvider.js.map +1 -1
- package/lib/components-react/tree/controlled/Observable.d.ts +9 -0
- package/lib/components-react/tree/controlled/Observable.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/Observable.js +2 -0
- package/lib/components-react/tree/controlled/Observable.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeActions.d.ts +1 -0
- package/lib/components-react/tree/controlled/TreeActions.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/TreeActions.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeEventHandler.d.ts +3 -0
- package/lib/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/TreeEventHandler.js +2 -0
- package/lib/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeEvents.d.ts +7 -0
- package/lib/components-react/tree/controlled/TreeEvents.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/TreeEvents.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeHooks.d.ts +5 -0
- package/lib/components-react/tree/controlled/TreeHooks.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/TreeHooks.js +6 -2
- package/lib/components-react/tree/controlled/TreeHooks.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeModel.d.ts +18 -0
- package/lib/components-react/tree/controlled/TreeModel.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/TreeModel.js +7 -0
- package/lib/components-react/tree/controlled/TreeModel.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeModelSource.d.ts +2 -0
- package/lib/components-react/tree/controlled/TreeModelSource.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/TreeModelSource.js +1 -0
- package/lib/components-react/tree/controlled/TreeModelSource.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeNodeLoader.d.ts +9 -0
- package/lib/components-react/tree/controlled/TreeNodeLoader.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/TreeNodeLoader.js +4 -1
- package/lib/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
- package/lib/components-react/tree/controlled/component/ControlledTree.d.ts +3 -0
- package/lib/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/component/ControlledTree.js +4 -3
- package/lib/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
- package/lib/components-react/tree/controlled/component/NodeContent.d.ts +2 -1
- package/lib/components-react/tree/controlled/component/NodeContent.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/component/NodeContent.js +3 -4
- package/lib/components-react/tree/controlled/component/NodeContent.js.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeNodeEditor.d.ts +3 -0
- package/lib/components-react/tree/controlled/component/TreeNodeEditor.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeNodeEditor.js +2 -0
- package/lib/components-react/tree/controlled/component/TreeNodeEditor.js.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeNodeRenderer.d.ts +3 -0
- package/lib/components-react/tree/controlled/component/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeNodeRenderer.js +5 -7
- package/lib/components-react/tree/controlled/component/TreeNodeRenderer.js.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeRenderer.d.ts +4 -0
- package/lib/components-react/tree/controlled/component/TreeRenderer.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeRenderer.js +3 -6
- package/lib/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
- package/lib/components-react/tree/controlled/internal/SparseTree.d.ts +1 -0
- package/lib/components-react/tree/controlled/internal/SparseTree.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/internal/SparseTree.js +2 -0
- package/lib/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
- package/lib/components-react/tree/controlled/internal/TreeModelMutator.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/internal/TreeModelMutator.js +1 -0
- package/lib/components-react/tree/controlled/internal/TreeModelMutator.js.map +1 -1
- package/lib/components-react/tree/controlled/internal/TreeSelectionManager.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
- package/lib/components-react.d.ts +2 -0
- package/lib/components-react.d.ts.map +1 -1
- package/lib/components-react.js +1 -0
- package/lib/components-react.js.map +1 -1
- package/lib/esm/components-react/common/HighlightedText.scss +8 -0
- package/lib/public/locales/en/UiComponents.json +0 -1
- package/package.json +41 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledTree.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/ControlledTree.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAQhE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AA6CjE;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;IACnE,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CACpC,CAA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,CAAC,CAAC,CACF,6BAAK,SAAS,EAAC,kCAAkC;YAC/C,oBAAC,cAAc,IAAC,IAAI,EAAC,OAAO,GAAG,CAC3B,CACP,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAC5B,KAAK,CAAC,cAAc,EAAE,CACvB,CAAC,CAAC,CAAC;QACF,4DAA4D;QAC5D,oBAAC,YAAY;YACX,2BAAG,SAAS,EAAC,wCAAwC,IAClD,SAAS,CAAC,gBAAgB,CAAC,CAC1B,CACS,CAChB,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC,QAAQ,CAAC;AACxB,CAAC;AAED,SAAS,aAAa,CACpB,mBAA4B;IAE5B,OAAO,KAAK,CAAC,WAAW,CACtB,CAAC,IAA8C,EAAU,EAAE;QACzD,MAAM,aAAa,GACjB,eAAe,CAAC,IAAI,CAAC,IAAI,mBAAmB,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW;YACtE,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,UAAU,GAAG,CAAC,CAAC;QACrB,uFAAuF;QACvF,OAAO,aAAa,GAAG,UAAU,CAAC;IACpC,CAAC,EACD,CAAC,mBAAmB,CAAC,CACtB,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/** @packageDocumentation\n * @module Tree\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { FillCentered } from \"@itwin/core-react\";\nimport { DelayedSpinner } from \"../../../common/DelayedSpinner.js\";\nimport type { SelectionMode } from \"../../../common/selection/SelectionModes.js\";\nimport type { HighlightableTreeProps } from \"../../HighlightingEngine.js\";\nimport { TreeImageLoader } from \"../../ImageLoader.js\";\nimport { TreeEventDispatcher } from \"../TreeEventDispatcher.js\";\nimport type { TreeEvents } from \"../TreeEvents.js\";\nimport type {\n TreeModel,\n TreeModelNode,\n TreeModelNodePlaceholder,\n VisibleTreeNodes,\n} from \"../TreeModel.js\";\nimport { computeVisibleNodes, isTreeModelNode } from \"../TreeModel.js\";\nimport type { ITreeNodeLoader } from \"../TreeNodeLoader.js\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\nimport type { RenderedItemsRange, TreeRendererProps } from \"./TreeRenderer.js\";\nimport { TreeRenderer } from \"./TreeRenderer.js\";\nimport { useElementsScrollStorage } from \"../../../common/UseElementsScrollStorage.js\";\nimport { useTranslation } from \"../../../l10n/useTranslation.js\";\n\n/**\n * Properties for [[ControlledTree]]\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ControlledTreeProps extends CommonProps {\n /** Model of the tree to display. */\n model: TreeModel;\n /** Node loader used to load root nodes and placeholder nodes. */\n nodeLoader: ITreeNodeLoader;\n /** Tree events handler. */\n eventsHandler: TreeEvents;\n /** Mode of nodes' selection in tree. */\n selectionMode: SelectionMode;\n /**\n * Specifies whether to show node description or not. It is used in default node renderer and to determine node height.\n * If custom node renderer and node height callbacks are used it does nothing.\n */\n descriptionsEnabled?: boolean;\n /**\n * Specifies whether to show node icon or not. It is used in default node renderer.\n * If custom node renderer is used it does nothing.\n */\n iconsEnabled?: boolean;\n /**\n * Used to highlight matches when filtering tree.\n * It is passed to treeRenderer.\n */\n nodeHighlightingProps?: HighlightableTreeProps;\n /** Custom renderer to be used to render a tree. */\n treeRenderer?: (props: TreeRendererProps) => React.ReactElement;\n /** Custom renderer to be used while root nodes is loading. */\n spinnerRenderer?: () => React.ReactElement;\n /** Custom renderer to be used when there is no data to show in tree. */\n noDataRenderer?: () => React.ReactElement;\n /** Callback that is invoked when rendered items range changes. */\n onItemsRendered?: (items: RenderedItemsRange) => void;\n /** Width of the tree renderer. */\n width: number;\n /** Height of the tree renderer. */\n height: number;\n}\n\n/**\n * React tree component which rendering is fully controlled from outside.\n * @public\n */\nexport function ControlledTree(props: ControlledTreeProps) {\n const nodeHeight = useNodeHeight(!!props.descriptionsEnabled);\n const imageLoader = React.useMemo(() => new TreeImageLoader(), []);\n const nodeRenderer = React.useCallback(\n (nodeProps: TreeNodeRendererProps) => (\n <TreeNodeRenderer\n {...nodeProps}\n descriptionEnabled={props.descriptionsEnabled}\n imageLoader={props.iconsEnabled ? imageLoader : undefined}\n />\n ),\n [props.descriptionsEnabled, props.iconsEnabled, imageLoader]\n );\n\n const visibleNodesRef = React.useRef<VisibleTreeNodes | undefined>(undefined);\n visibleNodesRef.current = React.useMemo(\n () => computeVisibleNodes(props.model),\n [props.model]\n );\n\n const eventDispatcher = React.useMemo(\n () =>\n new TreeEventDispatcher(\n props.eventsHandler,\n props.nodeLoader,\n props.selectionMode,\n () => visibleNodesRef.current!\n ),\n [props.eventsHandler, props.nodeLoader, props.selectionMode]\n );\n\n const treeProps: TreeRendererProps = {\n nodeRenderer,\n nodeHeight,\n visibleNodes: visibleNodesRef.current,\n treeActions: eventDispatcher,\n nodeLoader: props.nodeLoader,\n nodeHighlightingProps: props.nodeHighlightingProps,\n onItemsRendered: props.onItemsRendered,\n width: props.width,\n height: props.height,\n };\n\n const loading = useRootNodeLoader(visibleNodesRef.current, props.nodeLoader);\n const noData = visibleNodesRef.current.getNumRootNodes() === 0;\n return (\n <Loader\n loading={loading}\n noData={noData}\n spinnerRenderer={props.spinnerRenderer}\n noDataRenderer={props.noDataRenderer}\n >\n {props.treeRenderer ? (\n props.treeRenderer(treeProps)\n ) : (\n <TreeRenderer {...treeProps} />\n )}\n </Loader>\n );\n}\n\n/**\n * Returns callbacks for persisting and restoring [[ControlledTree]] layout state.\n * Returned `ref` should be set on container containing ControlledTree.\n * @public\n */\nexport function useControlledTreeLayoutStorage<T extends Element>() {\n return useElementsScrollStorage<T>(\"ReactWindow__VariableSizeList\");\n}\n\nfunction useRootNodeLoader(\n visibleNodes: VisibleTreeNodes,\n nodeLoader: ITreeNodeLoader\n): boolean {\n React.useEffect(() => {\n if (visibleNodes.getNumRootNodes() === undefined) {\n const subscription = nodeLoader\n .loadNode(visibleNodes.getModel().getRootNode(), 0)\n .subscribe();\n return () => subscription.unsubscribe();\n }\n\n return () => {};\n }, [visibleNodes, nodeLoader]);\n\n return visibleNodes.getNumRootNodes() === undefined;\n}\n\ninterface LoaderProps {\n loading: boolean;\n noData: boolean;\n spinnerRenderer?: () => React.ReactElement;\n noDataRenderer?: () => React.ReactElement;\n children: React.ReactElement;\n}\n\nfunction Loader(props: LoaderProps) {\n const { translate } = useTranslation();\n if (props.loading) {\n return props.spinnerRenderer ? (\n props.spinnerRenderer()\n ) : (\n <div className=\"components-controlledTree-loader\">\n <DelayedSpinner size=\"large\" />\n </div>\n );\n }\n if (props.noData) {\n return props.noDataRenderer ? (\n props.noDataRenderer()\n ) : (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <FillCentered>\n <p className=\"components-controlledTree-errorMessage\">\n {translate(\"general.noData\")}\n </p>\n </FillCentered>\n );\n }\n\n return props.children;\n}\n\nfunction useNodeHeight(\n descriptionsEnabled: boolean\n): (node: TreeModelNode | TreeModelNodePlaceholder) => number {\n return React.useCallback(\n (node: TreeModelNode | TreeModelNodePlaceholder): number => {\n const contentHeight =\n isTreeModelNode(node) && descriptionsEnabled && node && node.description\n ? 43\n : 24;\n const borderSize = 1;\n // Not counting node's border size twice because we want neighboring borders to overlap\n return contentHeight + borderSize;\n },\n [descriptionsEnabled]\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ControlledTree.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/ControlledTree.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,qDAAqD;AAErD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,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AAO,KAAK,CAAC,WAAW,CACtB,CAAC,IAA8C,EAAU,EAAE;QACzD,MAAM,aAAa,GACjB,eAAe,CAAC,IAAI,CAAC,IAAI,mBAAmB,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW;YACtE,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,UAAU,GAAG,CAAC,CAAC;QACrB,uFAAuF;QACvF,OAAO,aAAa,GAAG,UAAU,CAAC;IACpC,CAAC,EACD,CAAC,mBAAmB,CAAC,CACtB,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/** @packageDocumentation\n * @module Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { FillCentered } from \"@itwin/core-react\";\nimport { DelayedSpinner } from \"../../../common/DelayedSpinner.js\";\nimport type { SelectionMode } from \"../../../common/selection/SelectionModes.js\";\nimport type { HighlightableTreeProps } from \"../../HighlightingEngine.js\";\nimport { TreeImageLoader } from \"../../ImageLoader.js\";\nimport { TreeEventDispatcher } from \"../TreeEventDispatcher.js\";\nimport type { TreeEvents } from \"../TreeEvents.js\";\nimport type {\n TreeModel,\n TreeModelNode,\n TreeModelNodePlaceholder,\n VisibleTreeNodes,\n} from \"../TreeModel.js\";\nimport { computeVisibleNodes, isTreeModelNode } from \"../TreeModel.js\";\nimport type { ITreeNodeLoader } from \"../TreeNodeLoader.js\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\nimport type { RenderedItemsRange, TreeRendererProps } from \"./TreeRenderer.js\";\nimport { TreeRenderer } from \"./TreeRenderer.js\";\nimport { useElementsScrollStorage } from \"../../../common/UseElementsScrollStorage.js\";\nimport { useTranslation } from \"../../../l10n/useTranslation.js\";\n\n/**\n * Properties for [[ControlledTree]]\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface ControlledTreeProps extends CommonProps {\n /** Model of the tree to display. */\n model: TreeModel;\n /** Node loader used to load root nodes and placeholder nodes. */\n nodeLoader: ITreeNodeLoader;\n /** Tree events handler. */\n eventsHandler: TreeEvents;\n /** Mode of nodes' selection in tree. */\n selectionMode: SelectionMode;\n /**\n * Specifies whether to show node description or not. It is used in default node renderer and to determine node height.\n * If custom node renderer and node height callbacks are used it does nothing.\n */\n descriptionsEnabled?: boolean;\n /**\n * Specifies whether to show node icon or not. It is used in default node renderer.\n * If custom node renderer is used it does nothing.\n */\n iconsEnabled?: boolean;\n /**\n * Used to highlight matches when filtering tree.\n * It is passed to treeRenderer.\n */\n nodeHighlightingProps?: HighlightableTreeProps;\n /** Custom renderer to be used to render a tree. */\n treeRenderer?: (props: TreeRendererProps) => React.ReactElement;\n /** Custom renderer to be used while root nodes is loading. */\n spinnerRenderer?: () => React.ReactElement;\n /** Custom renderer to be used when there is no data to show in tree. */\n noDataRenderer?: () => React.ReactElement;\n /** Callback that is invoked when rendered items range changes. */\n onItemsRendered?: (items: RenderedItemsRange) => void;\n /** Width of the tree renderer. */\n width: number;\n /** Height of the tree renderer. */\n height: number;\n}\n\n/**\n * React tree component which rendering is fully controlled from outside.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport function ControlledTree(props: ControlledTreeProps) {\n const nodeHeight = useNodeHeight(!!props.descriptionsEnabled);\n const imageLoader = React.useMemo(() => new TreeImageLoader(), []);\n const nodeRenderer = React.useCallback(\n (nodeProps: TreeNodeRendererProps) => (\n <TreeNodeRenderer\n {...nodeProps}\n descriptionEnabled={props.descriptionsEnabled}\n imageLoader={props.iconsEnabled ? imageLoader : undefined}\n />\n ),\n [props.descriptionsEnabled, props.iconsEnabled, imageLoader]\n );\n\n const visibleNodesRef = React.useRef<VisibleTreeNodes | undefined>(undefined);\n visibleNodesRef.current = React.useMemo(\n () => computeVisibleNodes(props.model),\n [props.model]\n );\n\n const eventDispatcher = React.useMemo(\n () =>\n new TreeEventDispatcher(\n props.eventsHandler,\n props.nodeLoader,\n props.selectionMode,\n () => visibleNodesRef.current!\n ),\n [props.eventsHandler, props.nodeLoader, props.selectionMode]\n );\n\n const treeProps: TreeRendererProps = {\n nodeRenderer,\n nodeHeight,\n visibleNodes: visibleNodesRef.current,\n treeActions: eventDispatcher,\n nodeLoader: props.nodeLoader,\n nodeHighlightingProps: props.nodeHighlightingProps,\n onItemsRendered: props.onItemsRendered,\n width: props.width,\n height: props.height,\n };\n\n const loading = useRootNodeLoader(visibleNodesRef.current, props.nodeLoader);\n const noData = visibleNodesRef.current.getNumRootNodes() === 0;\n return (\n <Loader\n loading={loading}\n noData={noData}\n spinnerRenderer={props.spinnerRenderer}\n noDataRenderer={props.noDataRenderer}\n >\n {props.treeRenderer ? (\n props.treeRenderer(treeProps)\n ) : (\n <TreeRenderer {...treeProps} />\n )}\n </Loader>\n );\n}\n\n/**\n * Returns callbacks for persisting and restoring [[ControlledTree]] layout state.\n * Returned `ref` should be set on container containing ControlledTree.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport function useControlledTreeLayoutStorage<T extends Element>() {\n return useElementsScrollStorage<T>(\"ReactWindow__VariableSizeList\");\n}\n\nfunction useRootNodeLoader(\n visibleNodes: VisibleTreeNodes,\n nodeLoader: ITreeNodeLoader\n): boolean {\n React.useEffect(() => {\n if (visibleNodes.getNumRootNodes() === undefined) {\n const subscription = nodeLoader\n .loadNode(visibleNodes.getModel().getRootNode(), 0)\n .subscribe();\n return () => subscription.unsubscribe();\n }\n\n return () => {};\n }, [visibleNodes, nodeLoader]);\n\n return visibleNodes.getNumRootNodes() === undefined;\n}\n\ninterface LoaderProps {\n loading: boolean;\n noData: boolean;\n spinnerRenderer?: () => React.ReactElement;\n noDataRenderer?: () => React.ReactElement;\n children: React.ReactElement;\n}\n\nfunction Loader(props: LoaderProps) {\n const { translate } = useTranslation();\n if (props.loading) {\n return props.spinnerRenderer ? (\n props.spinnerRenderer()\n ) : (\n <div className=\"components-controlledTree-loader\">\n <DelayedSpinner size=\"large\" />\n </div>\n );\n }\n if (props.noData) {\n return props.noDataRenderer ? (\n props.noDataRenderer()\n ) : (\n <FillCentered>\n <p className=\"components-controlledTree-errorMessage\">\n {translate(\"general.noData\")}\n </p>\n </FillCentered>\n );\n }\n\n return props.children;\n}\n\nfunction useNodeHeight(\n descriptionsEnabled: boolean\n): (node: TreeModelNode | TreeModelNodePlaceholder) => number {\n return React.useCallback(\n (node: TreeModelNode | TreeModelNodePlaceholder): number => {\n const contentHeight =\n isTreeModelNode(node) && descriptionsEnabled && node && node.description\n ? 43\n : 24;\n const borderSize = 1;\n // Not counting node's border size twice because we want neighboring borders to overlap\n return contentHeight + borderSize;\n },\n [descriptionsEnabled]\n );\n}\n"]}
|
|
@@ -10,7 +10,7 @@ import type { TreeNodeEditorRenderer } from "./TreeNodeEditor.js";
|
|
|
10
10
|
/**
|
|
11
11
|
* Properties for [[TreeNodeContent]] component
|
|
12
12
|
* @public
|
|
13
|
-
* @deprecated in
|
|
13
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
14
14
|
*/
|
|
15
15
|
export interface TreeNodeContentProps extends CommonProps {
|
|
16
16
|
/** Tree node to render label for. */
|
|
@@ -27,6 +27,7 @@ export interface TreeNodeContentProps extends CommonProps {
|
|
|
27
27
|
/**
|
|
28
28
|
* React component for displaying [[TreeNode]] label
|
|
29
29
|
* @public
|
|
30
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
30
31
|
*/
|
|
31
32
|
export declare function TreeNodeContent(props: TreeNodeContentProps): React.JSX.Element;
|
|
32
33
|
//# sourceMappingURL=NodeContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeContent.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/NodeContent.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"NodeContent.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/NodeContent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOrD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAE9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAGlE;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,qCAAqC;IACrC,IAAI,EAAE,aAAa,CAAC;IACpB,0EAA0E;IAC1E,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oFAAoF;IACpF,cAAc,CAAC,EAAE,0BAA0B,CAAC;IAC5C,sDAAsD;IACtD,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IAChD,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,sBAAsB,CAAC;CAC7C;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,qBAsD1D"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Tree
|
|
7
7
|
*/
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
8
9
|
import "./NodeContent.scss";
|
|
9
10
|
import classnames from "classnames";
|
|
10
11
|
import * as React from "react";
|
|
@@ -17,8 +18,8 @@ import { TreeNodeEditor } from "./TreeNodeEditor.js";
|
|
|
17
18
|
/**
|
|
18
19
|
* React component for displaying [[TreeNode]] label
|
|
19
20
|
* @public
|
|
21
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
20
22
|
*/
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
22
23
|
export function TreeNodeContent(props) {
|
|
23
24
|
const { node, onLabelRendered, highlightProps } = props;
|
|
24
25
|
const label = React.useMemo(() => getLabel(node, highlightProps), [node, highlightProps]);
|
|
@@ -56,9 +57,7 @@ function getLabel(node, highlightProps) {
|
|
|
56
57
|
containerType: PropertyContainerType.Tree,
|
|
57
58
|
style: getStyle(node.item.style, node.isSelected),
|
|
58
59
|
textHighlighter: highlightCallback,
|
|
59
|
-
defaultValue: (
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
61
|
-
React.createElement(TreeNodePlaceholder, { level: 0, "data-testid": "node-label-placeholder" })),
|
|
60
|
+
defaultValue: (React.createElement(TreeNodePlaceholder, { level: 0, "data-testid": "node-label-placeholder" })),
|
|
62
61
|
};
|
|
63
62
|
return PropertyValueRendererManager.defaultManager.render(node.item.label, context);
|
|
64
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeContent.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/NodeContent.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeContent.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/NodeContent.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,qDAAqD;AAErD,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAoBrD;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IACxD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CACzB,GAAoB,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,EACrD,CAAC,IAAI,EAAE,cAAc,CAAC,CACvB,CAAC;IACF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAe,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC;IAEnC,sBAAsB;IACtB,IAAI,MAAuB,CAAC;IAC5B,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC3B,iEAAiE;QACjE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC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MAAM,iBAAiB,GAAG,cAAc;QACtC,CAAC,CAAC,CAAC,IAAY,EAAmB,EAAE,CAChC,kBAAkB,CAAC,eAAe,CAAC,IAAI,EAAE,cAAc,CAAC;QAC5D,CAAC,CAAC,SAAS,CAAC;IAEd,+BAA+B;IAC/B,MAAM,OAAO,GAAiC;QAC5C,aAAa,EAAE,qBAAqB,CAAC,IAAI;QACzC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC;QACjD,eAAe,EAAE,iBAAiB;QAClC,YAAY,EAAE,CACZ,oBAAC,mBAAmB,IAAC,KAAK,EAAE,CAAC,iBAAe,wBAAwB,GAAI,CACzE;KACF,CAAC;IAEF,OAAO,4BAA4B,CAAC,cAAc,CAAC,MAAM,CACvD,IAAI,CAAC,IAAI,CAAC,KAAK,EACf,OAAO,CACR,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CACf,KAAiB,EACjB,UAAoB;IAEpB,OAAO,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;AACvE,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/** @packageDocumentation\n * @module Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport \"./NodeContent.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { TreeNodePlaceholder } from \"@itwin/core-react\";\nimport type { ItemStyle } from \"../../../properties/ItemStyle.js\";\nimport { ItemStyleProvider } from \"../../../properties/ItemStyle.js\";\nimport type { PropertyValueRendererContext } from \"../../../properties/ValueRendererManager.js\";\nimport { PropertyValueRendererManager } from \"../../../properties/ValueRendererManager.js\";\nimport { PropertyContainerType } from \"../../../properties/ValueRendererManager.js\";\nimport type { HighlightableTreeNodeProps } from \"../../HighlightingEngine.js\";\nimport { HighlightingEngine } from \"../../HighlightingEngine.js\";\nimport type { TreeModelNode } from \"../TreeModel.js\";\nimport type { TreeNodeEditorRenderer } from \"./TreeNodeEditor.js\";\nimport { TreeNodeEditor } from \"./TreeNodeEditor.js\";\n\n/**\n * Properties for [[TreeNodeContent]] component\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface TreeNodeContentProps extends CommonProps {\n /** Tree node to render label for. */\n node: TreeModelNode;\n /** Flag that specified whether the description should be shown or not. */\n showDescription?: boolean;\n /** Props for highlighting label parts that matches filter when tree is filtered. */\n highlightProps?: HighlightableTreeNodeProps;\n /** Callback used to detect when label is rendered. */\n onLabelRendered?: (node: TreeModelNode) => void;\n /** Callback to render custom node editor when node is in editing mode. */\n nodeEditorRenderer?: TreeNodeEditorRenderer;\n}\n\n/**\n * React component for displaying [[TreeNode]] label\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport function TreeNodeContent(props: TreeNodeContentProps) {\n const { node, onLabelRendered, highlightProps } = props;\n const label = React.useMemo(\n (): React.ReactNode => getLabel(node, highlightProps),\n [node, highlightProps]\n );\n React.useEffect(() => {\n onLabelRendered && onLabelRendered(node);\n }, [label, node, onLabelRendered]);\n\n // handle cell editing\n let editor: React.ReactNode;\n if (props.node.editingInfo) {\n // if cell editing is enabled, return editor instead of the label\n const style = getStyle(props.node.item.style, props.node.isSelected);\n const editorProps = {\n node: props.node,\n onCancel: props.node.editingInfo.onCancel,\n onCommit: props.node.editingInfo.onCommit,\n style,\n };\n editor = props.nodeEditorRenderer ? (\n props.nodeEditorRenderer(editorProps)\n ) : (\n <TreeNodeEditor {...editorProps} />\n );\n }\n\n const isDescriptionEnabled =\n props.node.item.description && props.showDescription;\n\n const containerClassName = classnames(\n \"components-controlledTree-node-content\",\n isDescriptionEnabled ? \"with-description\" : undefined,\n props.className\n );\n\n const descriptionClassName = classnames(\n \"components-controlledTree-node-description\",\n editor ? \"with-editor\" : undefined\n );\n\n return (\n <div className={containerClassName} style={props.style}>\n <>\n {editor ? editor : label}\n {isDescriptionEnabled ? (\n <div className={descriptionClassName}>\n {props.node.item.description}\n </div>\n ) : undefined}\n </>\n </div>\n );\n}\n\nfunction getLabel(\n node: TreeModelNode,\n highlightProps?: HighlightableTreeNodeProps\n): React.ReactNode {\n // handle filtered matches' highlighting\n const highlightCallback = highlightProps\n ? (text: string): React.ReactNode =>\n HighlightingEngine.renderNodeLabel(text, highlightProps)\n : undefined;\n\n // handle custom cell rendering\n const context: PropertyValueRendererContext = {\n containerType: PropertyContainerType.Tree,\n style: getStyle(node.item.style, node.isSelected),\n textHighlighter: highlightCallback,\n defaultValue: (\n <TreeNodePlaceholder level={0} data-testid={\"node-label-placeholder\"} />\n ),\n };\n\n return PropertyValueRendererManager.defaultManager.render(\n node.item.label,\n context\n );\n}\n\nfunction getStyle(\n style?: ItemStyle,\n isSelected?: boolean\n): React.CSSProperties {\n return ItemStyleProvider.createStyle(style ? style : {}, isSelected);\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import type { TreeModelNode } from "../TreeModel.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* Properties for [[TreeNodeEditor]] component.
|
|
8
8
|
* @public
|
|
9
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
9
10
|
*/
|
|
10
11
|
export interface TreeNodeEditorProps {
|
|
11
12
|
/** Tree node which is in editing mode. */
|
|
@@ -22,11 +23,13 @@ export interface TreeNodeEditorProps {
|
|
|
22
23
|
/**
|
|
23
24
|
* Type for tree node editor renderer.
|
|
24
25
|
* @public
|
|
26
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
25
27
|
*/
|
|
26
28
|
export type TreeNodeEditorRenderer = (props: TreeNodeEditorProps) => React.ReactNode;
|
|
27
29
|
/**
|
|
28
30
|
* React component for displaying tree node editor.
|
|
29
31
|
* @public
|
|
32
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
30
33
|
*/
|
|
31
34
|
export declare function TreeNodeEditor(props: TreeNodeEditorProps): React.JSX.Element;
|
|
32
35
|
//# sourceMappingURL=TreeNodeEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"TreeNodeEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,IAAI,EAAE,aAAa,CAAC;IACpB,0DAA0D;IAC1D,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,wDAAwD;IACxD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE5B,gBAAgB;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACnC,KAAK,EAAE,mBAAmB,KACvB,KAAK,CAAC,SAAS,CAAC;AAErB;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,qBAoBxD"}
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Tree
|
|
7
7
|
*/
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
8
9
|
import * as React from "react";
|
|
9
10
|
import { PropertyRecord } from "@itwin/appui-abstract";
|
|
10
11
|
import { EditorContainer } from "../../../editors/EditorContainer.js";
|
|
11
12
|
/**
|
|
12
13
|
* React component for displaying tree node editor.
|
|
13
14
|
* @public
|
|
15
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
14
16
|
*/
|
|
15
17
|
export function TreeNodeEditor(props) {
|
|
16
18
|
const onCommit = (args) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeEditor.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeNodeEditor.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,qDAAqD;AAErD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AA+BtE;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,QAAQ,GAAG,CAAC,IAAyB,EAAE,EAAE;QAC7C,MAAM,QAAQ,GAAI,IAAI,CAAC,QAA2B,CAAC,KAAe,CAAC;QACnE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEnE,OAAO,CACL,8BAAM,KAAK,EAAE,KAAK,CAAC,KAAK;QACtB,oBAAC,eAAe,IACd,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,cAAc,CAAC,WAAW,EACjC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EACxC,QAAQ,EAAE,IAAI,GACd,CACG,CACR,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAqB;IACjD,MAAM,QAAQ,GAAwB;QACpC,IAAI,EAAE,kBAAkB;QACxB,YAAY,EAAE,kBAAkB;QAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ;KAClC,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACzD,MAAM,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC;IAE1B,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport * as React from \"react\";\nimport type {\n PrimitiveValue,\n PropertyDescription,\n} from \"@itwin/appui-abstract\";\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { PropertyUpdatedArgs } from \"../../../editors/EditorContainer.js\";\nimport { EditorContainer } from \"../../../editors/EditorContainer.js\";\nimport type { TreeModelNode } from \"../TreeModel.js\";\n\n/**\n * Properties for [[TreeNodeEditor]] component.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface TreeNodeEditorProps {\n /** Tree node which is in editing mode. */\n node: TreeModelNode;\n /** Callback that is called when changes are committed. */\n onCommit: (node: TreeModelNode, newValue: string) => void;\n /** Callback that is called when editing is canceled. */\n onCancel: () => void;\n /** Editor style. */\n style?: React.CSSProperties;\n\n /** @internal */\n ignoreEditorBlur?: boolean;\n}\n\n/**\n * Type for tree node editor renderer.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport type TreeNodeEditorRenderer = (\n props: TreeNodeEditorProps\n) => React.ReactNode;\n\n/**\n * React component for displaying tree node editor.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport function TreeNodeEditor(props: TreeNodeEditorProps) {\n const onCommit = (args: PropertyUpdatedArgs) => {\n const newValue = (args.newValue as PrimitiveValue).value as string;\n props.onCommit(props.node, newValue);\n };\n\n const propertyRecord = createPropertyRecord(props.node.item.label);\n\n return (\n <span style={props.style}>\n <EditorContainer\n propertyRecord={propertyRecord}\n title={propertyRecord.description}\n onCommit={onCommit}\n onCancel={props.onCancel}\n ignoreEditorBlur={props.ignoreEditorBlur}\n setFocus={true}\n />\n </span>\n );\n}\n\nfunction createPropertyRecord(label: PropertyRecord) {\n const property: PropertyDescription = {\n name: \"tree-node-editor\",\n displayLabel: \"Tree Node Editor\",\n typename: label.property.typename,\n };\n\n const record = new PropertyRecord(label.value, property);\n record.description = \"\";\n record.isReadonly = false;\n\n return record;\n}\n"]}
|
|
@@ -17,6 +17,7 @@ type CheckboxRendererProps = Omit<CheckboxProps, "onChange" | "onClick"> & {
|
|
|
17
17
|
/**
|
|
18
18
|
* Properties for [[TreeNodeRenderer]].
|
|
19
19
|
* @public
|
|
20
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
20
21
|
*/
|
|
21
22
|
export interface TreeNodeRendererProps extends CommonProps {
|
|
22
23
|
/** Tree node to render. */
|
|
@@ -46,6 +47,7 @@ export interface TreeNodeRendererProps extends CommonProps {
|
|
|
46
47
|
/**
|
|
47
48
|
* Default component for rendering tree node.
|
|
48
49
|
* @public
|
|
50
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
49
51
|
*/
|
|
50
52
|
export declare const TreeNodeRenderer: React.NamedExoticComponent<TreeNodeRendererProps>;
|
|
51
53
|
/**
|
|
@@ -62,6 +64,7 @@ export interface TreeNodeIconProps {
|
|
|
62
64
|
/**
|
|
63
65
|
* React component that renders icon for [[TreeNode]].
|
|
64
66
|
* @public
|
|
67
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
65
68
|
*/
|
|
66
69
|
export declare function TreeNodeIcon(props: TreeNodeIconProps): React.JSX.Element | null;
|
|
67
70
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAExE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;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B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,4BAQpD"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Tree
|
|
7
7
|
*/
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
8
9
|
import * as React from "react";
|
|
9
10
|
import { TreeNode } from "@itwin/core-react";
|
|
10
11
|
import { ImageRenderer } from "../../../common/ImageRenderer.js";
|
|
@@ -13,6 +14,7 @@ import { TreeNodeContent } from "./NodeContent.js";
|
|
|
13
14
|
/**
|
|
14
15
|
* Default component for rendering tree node.
|
|
15
16
|
* @public
|
|
17
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
16
18
|
*/
|
|
17
19
|
export const TreeNodeRenderer = React.memo(function TreeNodeRenderer(props) {
|
|
18
20
|
const label = (React.createElement(TreeNodeContent, { key: props.node.id, node: props.node, showDescription: props.descriptionEnabled, highlightProps: props.nodeHighlightProps, onLabelRendered: props.onLabelRendered, nodeEditorRenderer: props.nodeEditorRenderer }));
|
|
@@ -26,25 +28,21 @@ export const TreeNodeRenderer = React.memo(function TreeNodeRenderer(props) {
|
|
|
26
28
|
e.preventDefault();
|
|
27
29
|
props.onContextMenu && props.onContextMenu(e, props.node);
|
|
28
30
|
}
|
|
29
|
-
const createCheckboxProps = (checkboxInfo
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
31
|
-
) => ({
|
|
31
|
+
const createCheckboxProps = (checkboxInfo) => ({
|
|
32
32
|
state: checkboxInfo.state,
|
|
33
33
|
tooltip: checkboxInfo.tooltip,
|
|
34
34
|
isDisabled: checkboxInfo.isDisabled,
|
|
35
35
|
onClick: (newState) => props.treeActions.onNodeCheckboxClicked(props.node.id, newState),
|
|
36
36
|
});
|
|
37
|
-
return (
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
39
|
-
React.createElement(TreeNode, { "data-testid": TreeComponentTestId.Node, className: props.className, checkboxProps: props.node.checkbox.isVisible
|
|
37
|
+
return (React.createElement(TreeNode, { "data-testid": TreeComponentTestId.Node, className: props.className, checkboxProps: props.node.checkbox.isVisible
|
|
40
38
|
? createCheckboxProps(props.node.checkbox)
|
|
41
39
|
: undefined, style: props.style, isExpanded: props.node.isExpanded, isSelected: props.node.isSelected, isLoading: props.node.isLoading, isLeaf: props.node.numChildren === 0, icon: props.imageLoader ? (React.createElement(TreeNodeIcon, { node: props.node, imageLoader: props.imageLoader })) : undefined, label: label, level: props.node.depth, onClick: (event) => props.treeActions.onNodeClicked(props.node.id, event), onMouseDown: () => props.treeActions.onNodeMouseDown(props.node.id), onMouseMove: () => props.treeActions.onNodeMouseMove(props.node.id), onClickExpansionToggle: onExpansionToggle, onContextMenu: onContextMenu, renderOverrides: { renderCheckbox: props.checkboxRenderer } }, props.children));
|
|
42
40
|
});
|
|
43
41
|
/**
|
|
44
42
|
* React component that renders icon for [[TreeNode]].
|
|
45
43
|
* @public
|
|
44
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
46
45
|
*/
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
48
46
|
export function TreeNodeIcon(props) {
|
|
49
47
|
const { imageLoader, node } = props;
|
|
50
48
|
const image = imageLoader.load(node.item);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAkDnD
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,qDAAqD;AAErD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAkDnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,gBAAgB,CAClE,KAA4B;IAE5B,MAAM,KAAK,GAAG,CACZ,oBAAC,eAAe,IACd,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAClB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,eAAe,EAAE,KAAK,CAAC,kBAAkB,EACzC,cAAc,EAAE,KAAK,CAAC,kBAAkB,EACxC,eAAe,EAAE,KAAK,CAAC,eAAe,EACtC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,GAC5C,CACH,CAAC;IAEF,SAAS,iBAAiB;QACxB,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU;YAAE,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;YACvE,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,SAAS,aAAa,CAAC,CAAmB;QACxC,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,EAAE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EAAE,KAAK,CAAC,EACzE,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EACnE,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EACnE,sBAAsB,EAAE,iBAAiB,EACzC,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,EAAE,cAAc,EAAE,KAAK,CAAC,gBAAgB,EAAE,IAE1D,KAAK,CAAC,QAAQ,CACN,CACZ,CAAC;AACJ,CAAC,CAAC,CAAC;AAcH;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACpC,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE1C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,MAAM,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;IACrC,OAAO,0CAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAI,CAAC;AACvC,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/** @packageDocumentation\n * @module Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport * as React from \"react\";\nimport type { CommonProps, NodeCheckboxProps } from \"@itwin/core-react\";\nimport { TreeNode } from \"@itwin/core-react\";\nimport type { Checkbox } from \"@itwin/itwinui-react\";\nimport { ImageRenderer } from \"../../../common/ImageRenderer.js\";\nimport type { HighlightableTreeNodeProps } from \"../../HighlightingEngine.js\";\nimport type { ITreeImageLoader } from \"../../ImageLoader.js\";\nimport { TreeComponentTestId } from \"../../TreeComponentTestId.js\";\nimport type { TreeActions } from \"../TreeActions.js\";\nimport type { CheckBoxInfo, TreeModelNode } from \"../TreeModel.js\";\nimport { TreeNodeContent } from \"./NodeContent.js\";\nimport type { TreeNodeEditorRenderer } from \"./TreeNodeEditor.js\";\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\n\ntype CheckboxRendererProps = Omit<CheckboxProps, \"onChange\" | \"onClick\"> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\n/**\n * Properties for [[TreeNodeRenderer]].\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface TreeNodeRendererProps extends CommonProps {\n /** Tree node to render. */\n node: TreeModelNode;\n\n /** Action handler. */\n treeActions: TreeActions;\n\n /** Properties used to highlight matches when tree is filtered. */\n nodeHighlightProps?: HighlightableTreeNodeProps;\n\n /** Specifies whether to show descriptions or not. */\n descriptionEnabled?: boolean;\n\n /** Image loader for node icons. */\n imageLoader?: ITreeImageLoader;\n\n /** Callback to render custom checkbox. */\n checkboxRenderer?: (props: CheckboxRendererProps) => React.ReactNode;\n\n /** Callback to render custom node editor when node is in editing mode. */\n nodeEditorRenderer?: TreeNodeEditorRenderer;\n\n /**\n * Callback used to detect when label is rendered. It is used by TreeRenderer for scrolling to active match.\n * @internal\n */\n onLabelRendered?: (node: TreeModelNode) => void;\n\n /** Callback that is invoked when context menu should be opened. */\n onContextMenu?: (e: React.MouseEvent, node: TreeModelNode) => void;\n\n /** Child components to render inside the node.*/\n children?: React.ReactNode;\n}\n\n/**\n * Default component for rendering tree node.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport const TreeNodeRenderer = React.memo(function TreeNodeRenderer(\n props: TreeNodeRendererProps\n) {\n const label = (\n <TreeNodeContent\n key={props.node.id}\n node={props.node}\n showDescription={props.descriptionEnabled}\n highlightProps={props.nodeHighlightProps}\n onLabelRendered={props.onLabelRendered}\n nodeEditorRenderer={props.nodeEditorRenderer}\n />\n );\n\n function onExpansionToggle() {\n if (props.node.isExpanded) props.treeActions.onNodeCollapsed(props.node.id);\n else props.treeActions.onNodeExpanded(props.node.id);\n }\n\n function onContextMenu(e: React.MouseEvent) {\n e.preventDefault();\n props.onContextMenu && props.onContextMenu(e, props.node);\n }\n\n const createCheckboxProps = (\n checkboxInfo: CheckBoxInfo\n ): NodeCheckboxProps => ({\n state: checkboxInfo.state,\n tooltip: checkboxInfo.tooltip,\n isDisabled: checkboxInfo.isDisabled,\n onClick: (newState) =>\n props.treeActions.onNodeCheckboxClicked(props.node.id, newState),\n });\n\n return (\n <TreeNode\n data-testid={TreeComponentTestId.Node}\n className={props.className}\n checkboxProps={\n props.node.checkbox.isVisible\n ? createCheckboxProps(props.node.checkbox)\n : undefined\n }\n style={props.style}\n isExpanded={props.node.isExpanded}\n isSelected={props.node.isSelected}\n isLoading={props.node.isLoading}\n isLeaf={props.node.numChildren === 0}\n icon={\n props.imageLoader ? (\n <TreeNodeIcon node={props.node} imageLoader={props.imageLoader} />\n ) : undefined\n }\n label={label}\n level={props.node.depth}\n onClick={(event) => props.treeActions.onNodeClicked(props.node.id, event)}\n onMouseDown={() => props.treeActions.onNodeMouseDown(props.node.id)}\n onMouseMove={() => props.treeActions.onNodeMouseMove(props.node.id)}\n onClickExpansionToggle={onExpansionToggle}\n onContextMenu={onContextMenu}\n renderOverrides={{ renderCheckbox: props.checkboxRenderer }}\n >\n {props.children}\n </TreeNode>\n );\n});\n\n/**\n * Props for [[TreeNodeIcon]] component.\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof TreeNodeIcon>`\n */\nexport interface TreeNodeIconProps {\n /** Tree node to render icon for. */\n node: TreeModelNode;\n /** Image loader used to load tree node icon. */\n imageLoader: ITreeImageLoader;\n}\n\n/**\n * React component that renders icon for [[TreeNode]].\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport function TreeNodeIcon(props: TreeNodeIconProps) {\n const { imageLoader, node } = props;\n const image = imageLoader.load(node.item);\n\n if (!image) return null;\n\n const renderer = new ImageRenderer();\n return <>{renderer.render(image)}</>;\n}\n"]}
|
|
@@ -11,6 +11,7 @@ import type { TreeNodeRendererProps } from "./TreeNodeRenderer.js";
|
|
|
11
11
|
/**
|
|
12
12
|
* Data structure that describes range of rendered items in the tree.
|
|
13
13
|
* @public
|
|
14
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
14
15
|
*/
|
|
15
16
|
export interface RenderedItemsRange {
|
|
16
17
|
overscanStartIndex: number;
|
|
@@ -21,6 +22,7 @@ export interface RenderedItemsRange {
|
|
|
21
22
|
/**
|
|
22
23
|
* Properties for [[TreeRenderer]] component.
|
|
23
24
|
* @public
|
|
25
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
24
26
|
*/
|
|
25
27
|
export interface TreeRendererProps {
|
|
26
28
|
treeActions: TreeActions;
|
|
@@ -48,6 +50,7 @@ export interface TreeRendererProps {
|
|
|
48
50
|
/**
|
|
49
51
|
* Attributes found on TreeRenderer component
|
|
50
52
|
* @public
|
|
53
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
51
54
|
*/
|
|
52
55
|
export interface TreeRendererAttributes {
|
|
53
56
|
/**
|
|
@@ -62,6 +65,7 @@ type Alignment = "auto" | "smart" | "center" | "end" | "start";
|
|
|
62
65
|
/**
|
|
63
66
|
* Default tree rendering component.
|
|
64
67
|
* @public
|
|
68
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
65
69
|
*/
|
|
66
70
|
export declare class TreeRenderer extends React.Component<TreeRendererProps> implements TreeRendererAttributes {
|
|
67
71
|
private _ref;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAMnE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,eAAe,CAAC;IAE5B,sDAAsD;IACtD,UAAU,EAAE,CACV,IAAI,EAAE,aAAa,GAAG,wBAAwB,EAC9C,KAAK,EAAE,MAAM,KACV,MAAM,CAAC;IAEZ,yCAAyC;IACzC,YAAY,EAAE,gBAAgB,CAAC;IAE/B,uCAAuC;IACvC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,KAAK,CAAC,SAAS,CAAC;IAEjE,qFAAqF;IACrF,qBAAqB,CAAC,EAAE,sBAAsB,CAAC;IAE/C,iEAAiE;IACjE,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAE9D;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAEhC,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IAEd,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CAC3D;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;AAqC/D;;;;GAIG;AACH,qBAAa,YACX,SAAQ,KAAK,CAAC,SAAS,CAAC,iBAAiB,CACzC,YAAW,sBAAsB;IAEjC,OAAO,CAAC,IAAI,CAA6C;IAEzD,kBAAkB;IACX,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS;IAIzC,MAAM;CAGvB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Tree
|
|
7
7
|
*/
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
8
9
|
import "./ControlledTree.scss";
|
|
9
10
|
import classnames from "classnames";
|
|
10
11
|
import * as React from "react";
|
|
@@ -29,6 +30,7 @@ useTreeRendererContext,] = createContextWithMandatoryProvider("TreeRendererConte
|
|
|
29
30
|
/**
|
|
30
31
|
* Default tree rendering component.
|
|
31
32
|
* @public
|
|
33
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
32
34
|
*/
|
|
33
35
|
export class TreeRenderer extends React.Component {
|
|
34
36
|
_ref = React.createRef();
|
|
@@ -55,7 +57,6 @@ const TreeRendererInner = React.forwardRef((props, ref) => {
|
|
|
55
57
|
variableSizeListRef.current.resetAfterIndex(0, false);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
59
60
|
const coreTreeRef = React.useRef(null);
|
|
60
61
|
const onLabelRendered = useScrollToActiveMatch(coreTreeRef, props.nodeHighlightingProps);
|
|
61
62
|
const highlightingEngine = React.useMemo(() => props.nodeHighlightingProps &&
|
|
@@ -145,7 +146,6 @@ const Node = React.memo(function Node(props) {
|
|
|
145
146
|
nodeHighlightProps,
|
|
146
147
|
});
|
|
147
148
|
}
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
149
149
|
return React.createElement(TreeNodePlaceholder, { level: node.depth });
|
|
150
150
|
}, [
|
|
151
151
|
node,
|
|
@@ -199,9 +199,7 @@ function getHighlightedNodeId(highlightableTreeProps) {
|
|
|
199
199
|
? highlightableTreeProps.activeMatch.nodeId
|
|
200
200
|
: undefined;
|
|
201
201
|
}
|
|
202
|
-
function useScrollToActiveMatch(
|
|
203
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
204
|
-
treeRef, highlightableTreeProps) {
|
|
202
|
+
function useScrollToActiveMatch(treeRef, highlightableTreeProps) {
|
|
205
203
|
const scrollToActive = React.useRef(false);
|
|
206
204
|
React.useEffect(() => {
|
|
207
205
|
scrollToActive.current = true;
|
|
@@ -226,7 +224,6 @@ treeRef, highlightableTreeProps) {
|
|
|
226
224
|
}, [highlightableTreeProps, treeRef]);
|
|
227
225
|
return onLabelRendered;
|
|
228
226
|
}
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
230
227
|
function setFocusToSelected(treeRef) {
|
|
231
228
|
if (treeRef.current)
|
|
232
229
|
treeRef.current.setFocusByClassName(".core-tree-node.is-selected");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YA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AM,EAAE,KAAK;aACd,CAAC,CAAC;IACP,CAAC,EACD,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAClC,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,4DAA4D;AAC5D,SAAS,kBAAkB,CAAC,OAAyC;IACnE,IAAI,OAAO,CAAC,OAAO;QACjB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,6BAA6B,CAAC,CAAC;AACvE,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/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./ControlledTree.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ListChildComponentProps,\n ListOnItemsRenderedProps,\n} from \"react-window\";\nimport { areEqual, VariableSizeList } from \"react-window\";\nimport { concat, timer } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { Tree as CoreTree, TreeNodePlaceholder } from \"@itwin/core-react\";\nimport { createContextWithMandatoryProvider } from \"../../../common/UseContextWithMandatoryProvider.js\";\nimport type { HighlightableTreeProps } from \"../../HighlightingEngine.js\";\nimport { HighlightingEngine } from \"../../HighlightingEngine.js\";\nimport type { TreeActions } from \"../TreeActions.js\";\nimport type {\n TreeModelNode,\n TreeModelNodePlaceholder,\n VisibleTreeNodes,\n} from \"../TreeModel.js\";\nimport {\n isTreeModelNode,\n isTreeModelNodePlaceholder,\n isTreeModelRootNode,\n} from \"../TreeModel.js\";\nimport type { ITreeNodeLoader } from \"../TreeNodeLoader.js\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\nimport { toRxjsObservable } from \"../Observable.js\";\n\nconst NODE_LOAD_DELAY = 500;\n\n/**\n * Data structure that describes range of rendered items in the tree.\n * @public\n */\nexport interface RenderedItemsRange {\n overscanStartIndex: number;\n overscanStopIndex: number;\n visibleStartIndex: number;\n visibleStopIndex: number;\n}\n\n/**\n * Properties for [[TreeRenderer]] component.\n * @public\n */\nexport interface TreeRendererProps {\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Callback that is used to determine node height. */\n nodeHeight: (\n node: TreeModelNode | TreeModelNodePlaceholder,\n index: number\n ) => number;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Callback to render custom node. */\n nodeRenderer?: (props: TreeNodeRendererProps) => React.ReactNode;\n\n /** Properties used to highlight nodes and scroll to active match while filtering. */\n nodeHighlightingProps?: HighlightableTreeProps;\n\n /** Callback that is called when rendered items range changes. */\n onItemsRendered?: (renderedItems: RenderedItemsRange) => void;\n\n /**\n * Callback used when an editor closes\n * @internal\n */\n onNodeEditorClosed?: () => void;\n\n /** Width of the tree area. */\n width: number;\n\n /** Height of the tree area. */\n height: number;\n}\n\n/**\n * Attributes found on TreeRenderer component\n * @public\n */\nexport interface TreeRendererAttributes {\n /**\n * Scroll to the specified node.\n * @param nodeId Id of the target node to scroll to.\n * @param alignment Controls scrolling behavior. See [react-window](https://github.com/bvaughn/react-window) documentation\n * on `scrollToItem` for details.\n */\n scrollToNode(nodeId: string, alignment?: Alignment): void;\n}\n\ntype Alignment = \"auto\" | \"smart\" | \"center\" | \"end\" | \"start\";\n\n/** [[TreeRenderer]] context that is provided to each rendered node. */\ninterface TreeRendererContext {\n /** Callback to render custom node. */\n nodeRenderer: (props: TreeNodeRendererProps) => React.ReactNode;\n\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Engine used to created node highlighting properties. */\n highlightingEngine?: HighlightingEngine;\n\n /** Callback used detect when label is rendered. It is used by TreeRenderer for scrolling to active match. */\n onLabelRendered?: (node: TreeModelNode) => void;\n\n /** Callback used when an editor closes */\n onNodeEditorClosed?: () => void;\n}\n\n/** [[TreeRenderer]] context provider, consumer and custom hook. */\nconst [\n /** Context of [[TreeRenderer]] provider. */\n TreeRendererContextProvider,\n\n /** Context of [[TreeRenderer]] consumer. */\n _TreeRendererContextConsumer,\n\n /** Custom hook to use [[TreeRenderer]] context. */\n useTreeRendererContext,\n] = createContextWithMandatoryProvider<TreeRendererContext>(\n \"TreeRendererContext\"\n);\n\n/**\n * Default tree rendering component.\n * @public\n */\nexport class TreeRenderer\n extends React.Component<TreeRendererProps>\n implements TreeRendererAttributes\n{\n private _ref = React.createRef<TreeRendererAttributes>();\n\n /** @inheritdoc */\n public scrollToNode(nodeId: string, alignment?: Alignment) {\n if (this._ref.current) this._ref.current.scrollToNode(nodeId, alignment);\n }\n\n public override render() {\n return <TreeRendererInner ref={this._ref} {...this.props} />;\n }\n}\n\n// eslint-disable-next-line react/display-name\nconst TreeRendererInner = React.forwardRef<\n TreeRendererAttributes,\n TreeRendererProps\n>((props, ref) => {\n const variableSizeListRef = React.useRef<VariableSizeList>(null);\n useTreeRendererAttributes(ref, variableSizeListRef, props.visibleNodes);\n\n const previousVisibleNodes = usePrevious(props.visibleNodes);\n const previousNodeHeight = usePrevious(props.nodeHeight);\n if (\n (previousVisibleNodes !== undefined &&\n previousVisibleNodes !== props.visibleNodes) ||\n (previousNodeHeight !== undefined &&\n previousNodeHeight !== props.nodeHeight)\n ) {\n if (variableSizeListRef.current) {\n variableSizeListRef.current.resetAfterIndex(0, false);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const coreTreeRef = React.useRef<CoreTree>(null);\n const onLabelRendered = useScrollToActiveMatch(\n coreTreeRef,\n props.nodeHighlightingProps\n );\n const highlightingEngine = React.useMemo(\n () =>\n props.nodeHighlightingProps &&\n new HighlightingEngine(props.nodeHighlightingProps),\n [props.nodeHighlightingProps]\n );\n\n const rendererContext = React.useMemo<TreeRendererContext>(\n () => ({\n nodeRenderer: props.nodeRenderer\n ? props.nodeRenderer\n : (nodeProps) => <TreeNodeRenderer {...nodeProps} />,\n treeActions: props.treeActions,\n nodeLoader: props.nodeLoader,\n visibleNodes: props.visibleNodes,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed: () => {\n setFocusToSelected(coreTreeRef);\n props.onNodeEditorClosed && props.onNodeEditorClosed();\n },\n }),\n [props, onLabelRendered, highlightingEngine]\n );\n\n const itemKey = React.useCallback(\n (index: number) => getNodeKey(props.visibleNodes.getAtIndex(index)!),\n [props.visibleNodes]\n );\n\n const { nodeHeight, visibleNodes } = props;\n const itemSize = React.useCallback(\n (index: number) => nodeHeight(visibleNodes.getAtIndex(index)!, index),\n [nodeHeight, visibleNodes]\n );\n\n const { nodeHighlightingProps } = props;\n React.useEffect(() => {\n const highlightedNodeId = getHighlightedNodeId(nodeHighlightingProps);\n if (!highlightedNodeId) return;\n\n let index = 0;\n for (const node of visibleNodes) {\n if (isTreeModelNode(node) && node.id === highlightedNodeId) break;\n\n index++;\n }\n\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(index);\n }, [nodeHighlightingProps]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyDown(e);\n },\n [props.treeActions]\n );\n\n const handleKeyUp = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyUp(e);\n },\n [props.treeActions]\n );\n\n const onItemsRendered = props.onItemsRendered;\n const handleRenderedItemsChange = React.useCallback(\n (onItemsRenderedProps: ListOnItemsRenderedProps) => {\n onItemsRendered && onItemsRendered({ ...onItemsRenderedProps });\n },\n [onItemsRendered]\n );\n\n return (\n <TreeRendererContextProvider value={rendererContext}>\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <CoreTree\n ref={coreTreeRef}\n className={classnames(\n \"components-controlledTree\",\n \"components-smallEditor-host\"\n )}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n >\n <VariableSizeList\n ref={variableSizeListRef}\n className={\"ReactWindow__VariableSizeList\"}\n width={props.width}\n height={props.height}\n itemCount={props.visibleNodes.getNumNodes()}\n itemSize={itemSize}\n estimatedItemSize={25}\n overscanCount={10}\n itemKey={itemKey}\n onItemsRendered={handleRenderedItemsChange}\n >\n {Node}\n </VariableSizeList>\n </CoreTree>\n </TreeRendererContextProvider>\n );\n});\n\nfunction getNodeKey(node: TreeModelNode | TreeModelNodePlaceholder): string {\n if (isTreeModelNode(node)) {\n return node.id;\n }\n return `${node.parentId || \"\"}-${node.childIndex}`;\n}\n\nconst Node = React.memo<React.FC<ListChildComponentProps>>(function Node(\n props: ListChildComponentProps\n) {\n const { index, style } = props;\n\n const {\n nodeRenderer,\n visibleNodes,\n treeActions,\n nodeLoader,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed,\n } = useTreeRendererContext(Node);\n const node = visibleNodes.getAtIndex(index)!;\n\n useNodeLoading(node, visibleNodes, nodeLoader);\n\n // Mark selected node's wrapper to make detecting consecutively selected nodes with css selectors possible\n const className = classnames(\"node-wrapper\", {\n \"is-selected\": isTreeModelNode(node) && node.isSelected,\n });\n\n const isEditing = React.useRef(false);\n React.useEffect(() => {\n if (!isTreeModelNode(node)) return;\n\n if (!isEditing.current && node.editingInfo) {\n isEditing.current = true;\n } else if (isEditing.current && node.editingInfo === undefined) {\n isEditing.current = false;\n\n if (onNodeEditorClosed) onNodeEditorClosed();\n }\n }, [node, onNodeEditorClosed]);\n\n return (\n <div className={className} style={style}>\n {React.useMemo((): React.ReactNode => {\n if (isTreeModelNode(node)) {\n const nodeHighlightProps = highlightingEngine\n ? highlightingEngine.createRenderProps(node)\n : undefined;\n return nodeRenderer({\n node,\n treeActions,\n onLabelRendered,\n nodeHighlightProps,\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return <TreeNodePlaceholder level={node.depth} />;\n }, [\n node,\n treeActions,\n nodeRenderer,\n onLabelRendered,\n highlightingEngine,\n ])}\n </div>\n );\n},\nareEqual);\n\nfunction useNodeLoading(\n node: TreeModelNode | TreeModelNodePlaceholder,\n visibleNodes: VisibleTreeNodes,\n nodeLoader: ITreeNodeLoader\n): void {\n React.useEffect(\n () => {\n if (!isTreeModelNodePlaceholder(node)) {\n return;\n }\n\n const treeModel = visibleNodes.getModel();\n const parentNode = node.parentId\n ? treeModel.getNode(node.parentId)\n : treeModel.getRootNode();\n if (!isTreeModelNode(parentNode) && !isTreeModelRootNode(parentNode)) {\n return;\n }\n\n const subscription = concat(\n timer(NODE_LOAD_DELAY),\n toRxjsObservable(nodeLoader.loadNode(parentNode, node.childIndex))\n ).subscribe();\n return () => subscription.unsubscribe();\n },\n // Mounted node component never changes its node key, thus it's safe to run this effect only once for every\n // nodeLoader change.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [nodeLoader]\n );\n}\n\nfunction useTreeRendererAttributes(\n ref: React.Ref<TreeRendererAttributes>,\n variableSizeListRef: React.RefObject<VariableSizeList | null>,\n visibleNodes: VisibleTreeNodes\n) {\n const visibleNodesRef = React.useRef(visibleNodes);\n visibleNodesRef.current = visibleNodes;\n React.useImperativeHandle(\n ref,\n () => ({\n scrollToNode: (nodeId, alignment) => {\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(\n visibleNodesRef.current.getIndexOfNode(nodeId),\n alignment\n );\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n}\n\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = React.useRef<T | undefined>(undefined);\n\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n\nfunction getHighlightedNodeId(highlightableTreeProps?: HighlightableTreeProps) {\n return highlightableTreeProps && highlightableTreeProps.activeMatch\n ? highlightableTreeProps.activeMatch.nodeId\n : undefined;\n}\n\nfunction useScrollToActiveMatch(\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n treeRef: React.RefObject<CoreTree | null>,\n highlightableTreeProps?: HighlightableTreeProps\n) {\n const scrollToActive = React.useRef(false);\n React.useEffect(() => {\n scrollToActive.current = true;\n }, [highlightableTreeProps]);\n\n const onLabelRendered = React.useCallback(\n (node: TreeModelNode) => {\n const highlightedNodeId = getHighlightedNodeId(highlightableTreeProps);\n if (\n !treeRef.current ||\n !scrollToActive.current ||\n !highlightedNodeId ||\n highlightedNodeId !== node.id\n )\n return;\n\n scrollToActive.current = false;\n const scrollTo = [\n ...treeRef.current.getElementsByClassName(\n HighlightingEngine.ACTIVE_CLASS_NAME\n ),\n ];\n if (scrollTo.length > 0 && scrollTo[0].scrollIntoView !== undefined)\n scrollTo[0].scrollIntoView({\n behavior: \"auto\",\n block: \"nearest\",\n inline: \"end\",\n });\n },\n [highlightableTreeProps, treeRef]\n );\n\n return onLabelRendered;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nfunction setFocusToSelected(treeRef: React.RefObject<CoreTree | null>) {\n if (treeRef.current)\n treeRef.current.setFocusByClassName(\".core-tree-node.is-selected\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,qDAAqD;AAErD,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,MAAM,oDAAoD,CAAC;AAExG,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6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AAC;IAC3C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC;IAChC,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAE7B,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CACvC,CAAC,IAAmB,EAAE,EAAE;QACtB,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;QACvE,IACE,CAAC,OAAO,CAAC,OAAO;YAChB,CAAC,cAAc,CAAC,OAAO;YACvB,CAAC,iBAAiB;YAClB,iBAAiB,KAAK,IAAI,CAAC,EAAE;YAE7B,OAAO;QAET,cAAc,CAAC,OAAO,GAAG,KAAK,CAAC;QAC/B,MAAM,QAAQ,GAAG;YACf,GAAG,OAAO,CAAC,OAAO,CAAC,sBAAsB,CACvC,kBAAkB,CAAC,iBAAiB,CACrC;SACF,CAAC;QACF,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,SAAS;YACjE,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;gBACzB,QAAQ,EAAE,MAAM;gBAChB,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;IACP,CAAC,EACD,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAClC,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAyC;IACnE,IAAI,OAAO,CAAC,OAAO;QACjB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,6BAA6B,CAAC,CAAC;AACvE,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/** @packageDocumentation\n * @module Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport \"./ControlledTree.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ListChildComponentProps,\n ListOnItemsRenderedProps,\n} from \"react-window\";\nimport { areEqual, VariableSizeList } from \"react-window\";\nimport { concat, timer } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { Tree as CoreTree, TreeNodePlaceholder } from \"@itwin/core-react\";\nimport { createContextWithMandatoryProvider } from \"../../../common/UseContextWithMandatoryProvider.js\";\nimport type { HighlightableTreeProps } from \"../../HighlightingEngine.js\";\nimport { HighlightingEngine } from \"../../HighlightingEngine.js\";\nimport type { TreeActions } from \"../TreeActions.js\";\nimport type {\n TreeModelNode,\n TreeModelNodePlaceholder,\n VisibleTreeNodes,\n} from \"../TreeModel.js\";\nimport {\n isTreeModelNode,\n isTreeModelNodePlaceholder,\n isTreeModelRootNode,\n} from \"../TreeModel.js\";\nimport type { ITreeNodeLoader } from \"../TreeNodeLoader.js\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\nimport { toRxjsObservable } from \"../Observable.js\";\n\nconst NODE_LOAD_DELAY = 500;\n\n/**\n * Data structure that describes range of rendered items in the tree.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface RenderedItemsRange {\n overscanStartIndex: number;\n overscanStopIndex: number;\n visibleStartIndex: number;\n visibleStopIndex: number;\n}\n\n/**\n * Properties for [[TreeRenderer]] component.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface TreeRendererProps {\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Callback that is used to determine node height. */\n nodeHeight: (\n node: TreeModelNode | TreeModelNodePlaceholder,\n index: number\n ) => number;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Callback to render custom node. */\n nodeRenderer?: (props: TreeNodeRendererProps) => React.ReactNode;\n\n /** Properties used to highlight nodes and scroll to active match while filtering. */\n nodeHighlightingProps?: HighlightableTreeProps;\n\n /** Callback that is called when rendered items range changes. */\n onItemsRendered?: (renderedItems: RenderedItemsRange) => void;\n\n /**\n * Callback used when an editor closes\n * @internal\n */\n onNodeEditorClosed?: () => void;\n\n /** Width of the tree area. */\n width: number;\n\n /** Height of the tree area. */\n height: number;\n}\n\n/**\n * Attributes found on TreeRenderer component\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface TreeRendererAttributes {\n /**\n * Scroll to the specified node.\n * @param nodeId Id of the target node to scroll to.\n * @param alignment Controls scrolling behavior. See [react-window](https://github.com/bvaughn/react-window) documentation\n * on `scrollToItem` for details.\n */\n scrollToNode(nodeId: string, alignment?: Alignment): void;\n}\n\ntype Alignment = \"auto\" | \"smart\" | \"center\" | \"end\" | \"start\";\n\n/** [[TreeRenderer]] context that is provided to each rendered node. */\ninterface TreeRendererContext {\n /** Callback to render custom node. */\n nodeRenderer: (props: TreeNodeRendererProps) => React.ReactNode;\n\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Engine used to created node highlighting properties. */\n highlightingEngine?: HighlightingEngine;\n\n /** Callback used detect when label is rendered. It is used by TreeRenderer for scrolling to active match. */\n onLabelRendered?: (node: TreeModelNode) => void;\n\n /** Callback used when an editor closes */\n onNodeEditorClosed?: () => void;\n}\n\n/** [[TreeRenderer]] context provider, consumer and custom hook. */\nconst [\n /** Context of [[TreeRenderer]] provider. */\n TreeRendererContextProvider,\n\n /** Context of [[TreeRenderer]] consumer. */\n _TreeRendererContextConsumer,\n\n /** Custom hook to use [[TreeRenderer]] context. */\n useTreeRendererContext,\n] = createContextWithMandatoryProvider<TreeRendererContext>(\n \"TreeRendererContext\"\n);\n\n/**\n * Default tree rendering component.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport class TreeRenderer\n extends React.Component<TreeRendererProps>\n implements TreeRendererAttributes\n{\n private _ref = React.createRef<TreeRendererAttributes>();\n\n /** @inheritdoc */\n public scrollToNode(nodeId: string, alignment?: Alignment) {\n if (this._ref.current) this._ref.current.scrollToNode(nodeId, alignment);\n }\n\n public override render() {\n return <TreeRendererInner ref={this._ref} {...this.props} />;\n }\n}\n\n// eslint-disable-next-line react/display-name\nconst TreeRendererInner = React.forwardRef<\n TreeRendererAttributes,\n TreeRendererProps\n>((props, ref) => {\n const variableSizeListRef = React.useRef<VariableSizeList>(null);\n useTreeRendererAttributes(ref, variableSizeListRef, props.visibleNodes);\n\n const previousVisibleNodes = usePrevious(props.visibleNodes);\n const previousNodeHeight = usePrevious(props.nodeHeight);\n if (\n (previousVisibleNodes !== undefined &&\n previousVisibleNodes !== props.visibleNodes) ||\n (previousNodeHeight !== undefined &&\n previousNodeHeight !== props.nodeHeight)\n ) {\n if (variableSizeListRef.current) {\n variableSizeListRef.current.resetAfterIndex(0, false);\n }\n }\n\n const coreTreeRef = React.useRef<CoreTree>(null);\n const onLabelRendered = useScrollToActiveMatch(\n coreTreeRef,\n props.nodeHighlightingProps\n );\n const highlightingEngine = React.useMemo(\n () =>\n props.nodeHighlightingProps &&\n new HighlightingEngine(props.nodeHighlightingProps),\n [props.nodeHighlightingProps]\n );\n\n const rendererContext = React.useMemo<TreeRendererContext>(\n () => ({\n nodeRenderer: props.nodeRenderer\n ? props.nodeRenderer\n : (nodeProps) => <TreeNodeRenderer {...nodeProps} />,\n treeActions: props.treeActions,\n nodeLoader: props.nodeLoader,\n visibleNodes: props.visibleNodes,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed: () => {\n setFocusToSelected(coreTreeRef);\n props.onNodeEditorClosed && props.onNodeEditorClosed();\n },\n }),\n [props, onLabelRendered, highlightingEngine]\n );\n\n const itemKey = React.useCallback(\n (index: number) => getNodeKey(props.visibleNodes.getAtIndex(index)!),\n [props.visibleNodes]\n );\n\n const { nodeHeight, visibleNodes } = props;\n const itemSize = React.useCallback(\n (index: number) => nodeHeight(visibleNodes.getAtIndex(index)!, index),\n [nodeHeight, visibleNodes]\n );\n\n const { nodeHighlightingProps } = props;\n React.useEffect(() => {\n const highlightedNodeId = getHighlightedNodeId(nodeHighlightingProps);\n if (!highlightedNodeId) return;\n\n let index = 0;\n for (const node of visibleNodes) {\n if (isTreeModelNode(node) && node.id === highlightedNodeId) break;\n\n index++;\n }\n\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(index);\n }, [nodeHighlightingProps]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyDown(e);\n },\n [props.treeActions]\n );\n\n const handleKeyUp = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyUp(e);\n },\n [props.treeActions]\n );\n\n const onItemsRendered = props.onItemsRendered;\n const handleRenderedItemsChange = React.useCallback(\n (onItemsRenderedProps: ListOnItemsRenderedProps) => {\n onItemsRendered && onItemsRendered({ ...onItemsRenderedProps });\n },\n [onItemsRendered]\n );\n\n return (\n <TreeRendererContextProvider value={rendererContext}>\n <CoreTree\n ref={coreTreeRef}\n className={classnames(\n \"components-controlledTree\",\n \"components-smallEditor-host\"\n )}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n >\n <VariableSizeList\n ref={variableSizeListRef}\n className={\"ReactWindow__VariableSizeList\"}\n width={props.width}\n height={props.height}\n itemCount={props.visibleNodes.getNumNodes()}\n itemSize={itemSize}\n estimatedItemSize={25}\n overscanCount={10}\n itemKey={itemKey}\n onItemsRendered={handleRenderedItemsChange}\n >\n {Node}\n </VariableSizeList>\n </CoreTree>\n </TreeRendererContextProvider>\n );\n});\n\nfunction getNodeKey(node: TreeModelNode | TreeModelNodePlaceholder): string {\n if (isTreeModelNode(node)) {\n return node.id;\n }\n return `${node.parentId || \"\"}-${node.childIndex}`;\n}\n\nconst Node = React.memo<React.FC<ListChildComponentProps>>(function Node(\n props: ListChildComponentProps\n) {\n const { index, style } = props;\n\n const {\n nodeRenderer,\n visibleNodes,\n treeActions,\n nodeLoader,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed,\n } = useTreeRendererContext(Node);\n const node = visibleNodes.getAtIndex(index)!;\n\n useNodeLoading(node, visibleNodes, nodeLoader);\n\n // Mark selected node's wrapper to make detecting consecutively selected nodes with css selectors possible\n const className = classnames(\"node-wrapper\", {\n \"is-selected\": isTreeModelNode(node) && node.isSelected,\n });\n\n const isEditing = React.useRef(false);\n React.useEffect(() => {\n if (!isTreeModelNode(node)) return;\n\n if (!isEditing.current && node.editingInfo) {\n isEditing.current = true;\n } else if (isEditing.current && node.editingInfo === undefined) {\n isEditing.current = false;\n\n if (onNodeEditorClosed) onNodeEditorClosed();\n }\n }, [node, onNodeEditorClosed]);\n\n return (\n <div className={className} style={style}>\n {React.useMemo((): React.ReactNode => {\n if (isTreeModelNode(node)) {\n const nodeHighlightProps = highlightingEngine\n ? highlightingEngine.createRenderProps(node)\n : undefined;\n return nodeRenderer({\n node,\n treeActions,\n onLabelRendered,\n nodeHighlightProps,\n });\n }\n\n return <TreeNodePlaceholder level={node.depth} />;\n }, [\n node,\n treeActions,\n nodeRenderer,\n onLabelRendered,\n highlightingEngine,\n ])}\n </div>\n );\n},\nareEqual);\n\nfunction useNodeLoading(\n node: TreeModelNode | TreeModelNodePlaceholder,\n visibleNodes: VisibleTreeNodes,\n nodeLoader: ITreeNodeLoader\n): void {\n React.useEffect(\n () => {\n if (!isTreeModelNodePlaceholder(node)) {\n return;\n }\n\n const treeModel = visibleNodes.getModel();\n const parentNode = node.parentId\n ? treeModel.getNode(node.parentId)\n : treeModel.getRootNode();\n if (!isTreeModelNode(parentNode) && !isTreeModelRootNode(parentNode)) {\n return;\n }\n\n const subscription = concat(\n timer(NODE_LOAD_DELAY),\n toRxjsObservable(nodeLoader.loadNode(parentNode, node.childIndex))\n ).subscribe();\n return () => subscription.unsubscribe();\n },\n // Mounted node component never changes its node key, thus it's safe to run this effect only once for every\n // nodeLoader change.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [nodeLoader]\n );\n}\n\nfunction useTreeRendererAttributes(\n ref: React.Ref<TreeRendererAttributes>,\n variableSizeListRef: React.RefObject<VariableSizeList | null>,\n visibleNodes: VisibleTreeNodes\n) {\n const visibleNodesRef = React.useRef(visibleNodes);\n visibleNodesRef.current = visibleNodes;\n React.useImperativeHandle(\n ref,\n () => ({\n scrollToNode: (nodeId, alignment) => {\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(\n visibleNodesRef.current.getIndexOfNode(nodeId),\n alignment\n );\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n}\n\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = React.useRef<T | undefined>(undefined);\n\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n\nfunction getHighlightedNodeId(highlightableTreeProps?: HighlightableTreeProps) {\n return highlightableTreeProps && highlightableTreeProps.activeMatch\n ? highlightableTreeProps.activeMatch.nodeId\n : undefined;\n}\n\nfunction useScrollToActiveMatch(\n treeRef: React.RefObject<CoreTree | null>,\n highlightableTreeProps?: HighlightableTreeProps\n) {\n const scrollToActive = React.useRef(false);\n React.useEffect(() => {\n scrollToActive.current = true;\n }, [highlightableTreeProps]);\n\n const onLabelRendered = React.useCallback(\n (node: TreeModelNode) => {\n const highlightedNodeId = getHighlightedNodeId(highlightableTreeProps);\n if (\n !treeRef.current ||\n !scrollToActive.current ||\n !highlightedNodeId ||\n highlightedNodeId !== node.id\n )\n return;\n\n scrollToActive.current = false;\n const scrollTo = [\n ...treeRef.current.getElementsByClassName(\n HighlightingEngine.ACTIVE_CLASS_NAME\n ),\n ];\n if (scrollTo.length > 0 && scrollTo[0].scrollIntoView !== undefined)\n scrollTo[0].scrollIntoView({\n behavior: \"auto\",\n block: \"nearest\",\n inline: \"end\",\n });\n },\n [highlightableTreeProps, treeRef]\n );\n\n return onLabelRendered;\n}\n\nfunction setFocusToSelected(treeRef: React.RefObject<CoreTree | null>) {\n if (treeRef.current)\n treeRef.current.setFocusByClassName(\".core-tree-node.is-selected\");\n}\n"]}
|
|
@@ -35,6 +35,7 @@ export declare class SparseTree<T extends Node> {
|
|
|
35
35
|
* this class does not need to check each index when iterating values that are
|
|
36
36
|
* stored in the array.
|
|
37
37
|
* @public
|
|
38
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
38
39
|
*/
|
|
39
40
|
export declare class SparseArray<T> implements Iterable<T | undefined> {
|
|
40
41
|
[immerable]: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SparseTree.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/SparseTree.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"SparseTree.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/SparseTree.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,gBAAgB;AAChB,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,UAAU,CAAC,CAAC,SAAS,IAAI;IAC7B,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE5B,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,iBAAiB,CAA2C;IACpE,OAAO,CAAC,SAAS,CAAyB;;IAMnC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAItC,cAAc,CACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS;IAOd,WAAW,CAChB,QAAQ,EAAE,M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AC,GAAG,SAAS;IAKxC,qEAAqE;IAC9D,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAMlC,yEAAyE;IAClE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAWrC,wEAAwE;IACjE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAelC;;;OAGG;IACI,aAAa,IAAI,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAIrD,kEAAkE;IAC3D,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,GAAG,SAAS,CAAC;IAoB3D,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,MAAM,CAAC,OAAO;CAGvB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Tree
|
|
7
7
|
*/
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
8
9
|
import { immerable } from "immer";
|
|
9
10
|
import { assert, compareNumbers, lowerBound } from "@itwin/core-bentley";
|
|
10
11
|
/**
|
|
@@ -140,6 +141,7 @@ export class SparseTree {
|
|
|
140
141
|
* this class does not need to check each index when iterating values that are
|
|
141
142
|
* stored in the array.
|
|
142
143
|
* @public
|
|
144
|
+
* @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
|
|
143
145
|
*/
|
|
144
146
|
export class SparseArray {
|
|
145
147
|
[immerable];
|