@itwin/tree-widget-react 0.2.1 → 0.4.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.
Files changed (83) hide show
  1. package/README.md +30 -1
  2. package/lib/cjs/components/TreeWidgetComponent.d.ts +1 -0
  3. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +9 -17
  4. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +50 -47
  5. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  6. package/lib/cjs/components/header/TreeHeader.d.ts +1 -0
  7. package/lib/cjs/components/rulesets/IModelContent.json +435 -0
  8. package/lib/cjs/components/trees/CategoriesTree.d.ts +3 -7
  9. package/lib/cjs/components/trees/CategoriesTree.js +21 -23
  10. package/lib/cjs/components/trees/CategoriesTree.js.map +1 -1
  11. package/lib/cjs/components/trees/IModelContentTree.d.ts +4 -0
  12. package/lib/cjs/components/trees/{ClassificationsTree.js → IModelContentTree.js} +19 -12
  13. package/lib/cjs/components/trees/IModelContentTree.js.map +1 -0
  14. package/lib/cjs/components/trees/ModelsTree.d.ts +3 -8
  15. package/lib/cjs/components/trees/ModelsTree.js +8 -16
  16. package/lib/cjs/components/trees/ModelsTree.js.map +1 -1
  17. package/lib/cjs/components/trees/SpatialTree.d.ts +3 -2
  18. package/lib/cjs/components/trees/SpatialTree.js +11 -28
  19. package/lib/cjs/components/trees/SpatialTree.js.map +1 -1
  20. package/lib/cjs/components/trees/index.d.ts +1 -2
  21. package/lib/cjs/components/trees/index.js +5 -6
  22. package/lib/cjs/components/trees/index.js.map +1 -1
  23. package/lib/cjs/components/utils/AutoSizer.d.ts +10 -0
  24. package/lib/cjs/components/utils/AutoSizer.js +36 -0
  25. package/lib/cjs/components/utils/AutoSizer.js.map +1 -0
  26. package/lib/cjs/tree-widget-react.d.ts +1 -1
  27. package/lib/cjs/tree-widget-react.js +4 -4
  28. package/lib/cjs/tree-widget-react.js.map +1 -1
  29. package/lib/cjs/types.d.ts +26 -0
  30. package/lib/cjs/types.js +3 -0
  31. package/lib/cjs/types.js.map +1 -0
  32. package/lib/esm/components/TreeWidgetComponent.d.ts +1 -0
  33. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +9 -17
  34. package/lib/esm/components/TreeWidgetUiItemsProvider.js +50 -47
  35. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  36. package/lib/esm/components/header/TreeHeader.d.ts +1 -0
  37. package/lib/esm/components/rulesets/IModelContent.json +435 -0
  38. package/lib/esm/components/trees/CategoriesTree.d.ts +3 -7
  39. package/lib/esm/components/trees/CategoriesTree.js +23 -25
  40. package/lib/esm/components/trees/CategoriesTree.js.map +1 -1
  41. package/lib/esm/components/trees/IModelContentTree.d.ts +4 -0
  42. package/lib/esm/components/trees/IModelContentTree.js +24 -0
  43. package/lib/esm/components/trees/IModelContentTree.js.map +1 -0
  44. package/lib/esm/components/trees/ModelsTree.d.ts +3 -8
  45. package/lib/esm/components/trees/ModelsTree.js +9 -17
  46. package/lib/esm/components/trees/ModelsTree.js.map +1 -1
  47. package/lib/esm/components/trees/SpatialTree.d.ts +3 -2
  48. package/lib/esm/components/trees/SpatialTree.js +10 -11
  49. package/lib/esm/components/trees/SpatialTree.js.map +1 -1
  50. package/lib/esm/components/trees/index.d.ts +1 -2
  51. package/lib/esm/components/trees/index.js +4 -5
  52. package/lib/esm/components/trees/index.js.map +1 -1
  53. package/lib/esm/components/utils/AutoSizer.d.ts +10 -0
  54. package/lib/esm/components/utils/AutoSizer.js +13 -0
  55. package/lib/esm/components/utils/AutoSizer.js.map +1 -0
  56. package/lib/esm/tree-widget-react.d.ts +1 -1
  57. package/lib/esm/tree-widget-react.js +4 -4
  58. package/lib/esm/tree-widget-react.js.map +1 -1
  59. package/lib/esm/types.d.ts +26 -0
  60. package/lib/esm/types.js +2 -0
  61. package/lib/esm/types.js.map +1 -0
  62. package/package.json +6 -3
  63. package/lib/cjs/components/TreeWidgetControl.d.ts +0 -26
  64. package/lib/cjs/components/TreeWidgetControl.js +0 -66
  65. package/lib/cjs/components/TreeWidgetControl.js.map +0 -1
  66. package/lib/cjs/components/rulesets/ClassificationSystems.json +0 -122
  67. package/lib/cjs/components/trees/ClassificationsTree.d.ts +0 -6
  68. package/lib/cjs/components/trees/ClassificationsTree.js.map +0 -1
  69. package/lib/cjs/components/trees/TreeWithRuleset.d.ts +0 -35
  70. package/lib/cjs/components/trees/TreeWithRuleset.js +0 -110
  71. package/lib/cjs/components/trees/TreeWithRuleset.js.map +0 -1
  72. package/lib/cjs/components/trees/TreeWithRulesetTree.scss +0 -17
  73. package/lib/esm/components/TreeWidgetControl.d.ts +0 -26
  74. package/lib/esm/components/TreeWidgetControl.js +0 -59
  75. package/lib/esm/components/TreeWidgetControl.js.map +0 -1
  76. package/lib/esm/components/rulesets/ClassificationSystems.json +0 -122
  77. package/lib/esm/components/trees/ClassificationsTree.d.ts +0 -6
  78. package/lib/esm/components/trees/ClassificationsTree.js +0 -17
  79. package/lib/esm/components/trees/ClassificationsTree.js.map +0 -1
  80. package/lib/esm/components/trees/TreeWithRuleset.d.ts +0 -35
  81. package/lib/esm/components/trees/TreeWithRuleset.js +0 -85
  82. package/lib/esm/components/trees/TreeWithRuleset.js.map +0 -1
  83. package/lib/esm/components/trees/TreeWithRulesetTree.scss +0 -17
@@ -3,13 +3,12 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import React, { useCallback, useEffect, useState } from "react";
6
- import { ClassGroupingOption, ModelsTree, useActiveViewport } from "@itwin/appui-react";
6
+ import { ModelsTree, useActiveIModelConnection, useActiveViewport } from "@itwin/appui-react";
7
7
  import { useTreeFilteringState } from "../TreeFilteringState";
8
8
  import "./ModelsTree.scss";
9
9
  import { TreeHeaderComponent } from "../header/TreeHeader";
10
- import { useResizeObserver } from "@itwin/core-react";
10
+ import { AutoSizer } from "../utils/AutoSizer";
11
11
  export const ModelsTreeComponent = (props) => {
12
- const { iModel } = props;
13
12
  const [is2dToggleActive, setIs2dToggleActive] = useState(false);
14
13
  const [is3dToggleActive, setIs3dToggleActive] = useState(false);
15
14
  const [icon2dToggle, setIcon2dToggle] = useState("icon-visibility");
@@ -17,23 +16,18 @@ export const ModelsTreeComponent = (props) => {
17
16
  const [available2dModels, setAvailable2dModels] = useState([]);
18
17
  const [available3dModels, setAvailable3dModels] = useState([]);
19
18
  const [availableModels, setAvailableModels] = useState([]);
19
+ const iModel = useActiveIModelConnection();
20
20
  const viewport = useActiveViewport();
21
21
  const { searchOptions, filterString, activeMatchIndex, onFilterApplied } = useTreeFilteringState();
22
- const [height, setHeight] = useState(0);
23
- const [width, setWidth] = useState(0);
24
- const handleResize = useCallback((w, h) => {
25
- setHeight(h);
26
- setWidth(w);
27
- }, []);
28
- const ref = useResizeObserver(handleResize);
29
22
  const queryModels = useCallback(async (vp) => {
23
+ var _a;
30
24
  if (vp === undefined)
31
25
  return [];
32
26
  const queryParams = {
33
27
  from: "BisCore.GeometricModel3d",
34
28
  wantPrivate: false,
35
29
  };
36
- const modelProps = await iModel.models.queryProps(queryParams);
30
+ const modelProps = (_a = await (iModel === null || iModel === void 0 ? void 0 : iModel.models.queryProps(queryParams))) !== null && _a !== void 0 ? _a : [];
37
31
  return modelProps
38
32
  .map(({ id, isPlanProjection }) => ({ id, isPlanProjection }))
39
33
  .filter(({ id }) => id);
@@ -102,11 +96,9 @@ export const ModelsTreeComponent = (props) => {
102
96
  }
103
97
  viewport === null || viewport === void 0 ? void 0 : viewport.invalidateScene();
104
98
  }, [is3dToggleActive, viewport, available3dModels]);
105
- return (!(iModel && viewport) ? null : (React.createElement(React.Fragment, null,
106
- React.createElement(TreeHeaderComponent, { searchOptions: searchOptions, showAll: showAll, hideAll: hideAll, invert: invert, toggle2D: viewToggle2D, toggle2DIcon: icon2dToggle, toggle3D: viewToggle3D, toggle3DIcon: icon3dToggle }),
107
- React.createElement("div", { className: "tree-widget-models-tree-container" },
108
- React.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (React.createElement(ModelsTree, { ...props, filterInfo: { filter: filterString, activeMatchIndex }, onFilterApplied: onFilterApplied, activeView: viewport, enableElementsClassGrouping: props.enableElementsClassGrouping
109
- ? ClassGroupingOption.YesWithCounts
110
- : ClassGroupingOption.No, width: width, height: height })))))));
99
+ return (React.createElement(React.Fragment, null, iModel && viewport &&
100
+ React.createElement(React.Fragment, null,
101
+ React.createElement(TreeHeaderComponent, { searchOptions: searchOptions, showAll: showAll, hideAll: hideAll, invert: invert, toggle2D: viewToggle2D, toggle2DIcon: icon2dToggle, toggle3D: viewToggle3D, toggle3DIcon: icon3dToggle }),
102
+ React.createElement(AutoSizer, null, ({ width, height }) => (React.createElement(ModelsTree, { ...props, iModel: iModel, activeView: viewport, width: width, height: height, filterInfo: { filter: filterString, activeMatchIndex }, onFilterApplied: onFilterApplied }))))));
111
103
  };
112
104
  //# sourceMappingURL=ModelsTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../src/components/trees/ModelsTree.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,mBAAmB,CAAC;AAK3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AActD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAqB,EAAE,EAAE;IAC3D,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAEzB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC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;IAC9B,CAAC,EAAE,CAAC,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEpD,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACrC;QACE,oBAAC,mBAAmB,IAClB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,YAAY,EACtB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,YAAY,EACtB,YAAY,EAAE,YAAY,GAC1B;QACF,6BAAK,SAAS,EAAC,mCAAmC;YAChD,6BAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IACpD,KAAK,IAAI,MAAM,IAAI,CAClB,oBAAC,UAAU,OACL,KAAK,EACT,UAAU,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,EACtD,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,QAAQ,EACpB,2BAA2B,EACzB,KAAK,CAAC,2BAA2B;oBAC/B,CAAC,CAAC,mBAAmB,CAAC,aAAa;oBACnC,CAAC,CAAC,mBAAmB,CAAC,EAAE,EAE5B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACd,CACH,CACG,CACF,CACL,CACJ,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport { ClassGroupingOption, ModelsTree, useActiveViewport } from \"@itwin/appui-react\";\nimport { useTreeFilteringState } from \"../TreeFilteringState\";\nimport \"./ModelsTree.scss\";\nimport type {\n GeometricModel3dProps,\n ModelQueryParams,\n} from \"@itwin/core-common\";\nimport { TreeHeaderComponent } from \"../header/TreeHeader\";\nimport { useResizeObserver } from \"@itwin/core-react\";\n\nexport interface ModelTreeProps {\n iModel: IModelConnection;\n allViewports?: boolean;\n activeView?: Viewport;\n enableElementsClassGrouping?: boolean;\n}\n\ninterface TreeViewModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\nexport const ModelsTreeComponent = (props: ModelTreeProps) => {\n const { iModel } = props;\n\n const [is2dToggleActive, setIs2dToggleActive] = useState<boolean>(false);\n const [is3dToggleActive, setIs3dToggleActive] = useState<boolean>(false);\n const [icon2dToggle, setIcon2dToggle] = useState<string>(\"icon-visibility\");\n const [icon3dToggle, setIcon3dToggle] = useState<string>(\"icon-visibility\");\n\n const [available2dModels, setAvailable2dModels] = useState<string[]>([]);\n const [available3dModels, setAvailable3dModels] = useState<string[]>([]);\n const [availableModels, setAvailableModels] = useState<string[]>([]);\n\n const viewport = useActiveViewport();\n\n const { searchOptions, filterString, activeMatchIndex, onFilterApplied } =\n useTreeFilteringState();\n\n const [height, setHeight] = useState(0);\n const [width, setWidth] = useState(0);\n const handleResize = useCallback((w: number, h: number) => {\n setHeight(h);\n setWidth(w);\n }, []);\n const ref = useResizeObserver<HTMLDivElement>(handleResize);\n\n const queryModels = useCallback(async (\n vp: Viewport | undefined\n ): Promise<TreeViewModelInfo[]> => {\n if (vp === undefined) return [];\n\n const queryParams: ModelQueryParams = {\n from: \"BisCore.GeometricModel3d\",\n wantPrivate: false,\n };\n const modelProps = await iModel.models.queryProps(queryParams);\n return modelProps\n .map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection }))\n .filter(({ id }) => id) as TreeViewModelInfo[];\n }, [iModel]);\n\n useEffect(() => {\n queryModels(viewport)\n .then((modelInfos: TreeViewModelInfo[]) => {\n setAvailableModels(modelInfos.map(({ id }) => id));\n\n const { models2d, models3d } = modelInfos.reduce((acc, { id, isPlanProjection }) => {\n isPlanProjection ? acc.models2d.push(id) : acc.models3d.push(id);\n return acc;\n }, { models2d: [] as string[], models3d: [] as string[] });\n\n setAvailable2dModels(models2d);\n setAvailable3dModels(models3d);\n })\n .catch((_e) => {\n setAvailableModels([]);\n });\n }, [queryModels, viewport]);\n\n const invert = useCallback(async () => {\n if (availableModels.length === 0) return;\n const notViewedModels: string[] = [];\n const models: string[] = [];\n availableModels.forEach((id: string) => {\n if (viewport?.viewsModel(id)) models.push(id);\n else notViewedModels.push(id);\n });\n await viewport?.addViewedModels(notViewedModels);\n viewport?.changeModelDisplay(models, false);\n viewport?.invalidateScene();\n }, [viewport, availableModels]);\n\n const hideAll = useCallback(() => {\n viewport?.changeModelDisplay(availableModels, false);\n viewport?.invalidateScene();\n }, [viewport, availableModels]);\n\n const showAll = useCallback(async () => {\n await viewport?.addViewedModels(availableModels);\n viewport?.invalidateScene();\n }, [viewport, availableModels]);\n\n const viewToggle2D = useCallback(async () => {\n if (is2dToggleActive) {\n viewport?.changeModelDisplay(available2dModels, false);\n setIs2dToggleActive(false);\n setIcon2dToggle(\"icon-visibility-hide-2\");\n } else {\n await viewport?.addViewedModels(available2dModels);\n setIs2dToggleActive(true);\n setIcon2dToggle(\"icon-visibility\");\n }\n viewport?.invalidateScene();\n }, [is2dToggleActive, viewport, available2dModels]);\n\n const viewToggle3D = useCallback(async () => {\n if (is3dToggleActive) {\n viewport?.changeModelDisplay(available3dModels, false);\n setIs3dToggleActive(false);\n setIcon3dToggle(\"icon-visibility-hide-2\");\n } else {\n await viewport?.addViewedModels(available3dModels);\n setIs3dToggleActive(true);\n setIcon3dToggle(\"icon-visibility\");\n }\n viewport?.invalidateScene();\n }, [is3dToggleActive, viewport, available3dModels]);\n\n return (!(iModel && viewport) ? null : (\n <>\n <TreeHeaderComponent\n searchOptions={searchOptions}\n showAll={showAll}\n hideAll={hideAll}\n invert={invert}\n toggle2D={viewToggle2D}\n toggle2DIcon={icon2dToggle}\n toggle3D={viewToggle3D}\n toggle3DIcon={icon3dToggle}\n />\n <div className=\"tree-widget-models-tree-container\">\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }}>\n {width && height && (\n <ModelsTree\n {...props}\n filterInfo={{ filter: filterString, activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n activeView={viewport}\n enableElementsClassGrouping={\n props.enableElementsClassGrouping\n ? ClassGroupingOption.YesWithCounts\n : ClassGroupingOption.No\n }\n width={width}\n height={height}\n />\n )}\n </div>\n </div>\n </>\n ));\n};\n"]}
1
+ {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../src/components/trees/ModelsTree.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,mBAAmB,CAAC;AAK3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAO/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAqB,EAAE,EAAE;IAC3D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACzE,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACzE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAS,iBAAiB,CAAC,CAAC;IAC5E,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAS,iBAAiB,CAAC,CAAC;IAE5E,MAAM,CAAC,iBAAiB,EA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AAE,EACtD,eAAe,EAAE,eAAe,GAChC,CACH,CACS,CACX,CAEJ,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport { ModelsTree, useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { useTreeFilteringState } from \"../TreeFilteringState\";\nimport \"./ModelsTree.scss\";\nimport type {\n GeometricModel3dProps,\n ModelQueryParams,\n} from \"@itwin/core-common\";\nimport { TreeHeaderComponent } from \"../header/TreeHeader\";\nimport type { ModelTreeProps } from \"../../types\";\nimport { AutoSizer } from \"../utils/AutoSizer\";\n\ninterface TreeViewModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\nexport const ModelsTreeComponent = (props: ModelTreeProps) => {\n const [is2dToggleActive, setIs2dToggleActive] = useState<boolean>(false);\n const [is3dToggleActive, setIs3dToggleActive] = useState<boolean>(false);\n const [icon2dToggle, setIcon2dToggle] = useState<string>(\"icon-visibility\");\n const [icon3dToggle, setIcon3dToggle] = useState<string>(\"icon-visibility\");\n\n const [available2dModels, setAvailable2dModels] = useState<string[]>([]);\n const [available3dModels, setAvailable3dModels] = useState<string[]>([]);\n const [availableModels, setAvailableModels] = useState<string[]>([]);\n\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n const { searchOptions, filterString, activeMatchIndex, onFilterApplied } =\n useTreeFilteringState();\n\n const queryModels = useCallback(async (\n vp: Viewport | undefined\n ): Promise<TreeViewModelInfo[]> => {\n if (vp === undefined) return [];\n\n const queryParams: ModelQueryParams = {\n from: \"BisCore.GeometricModel3d\",\n wantPrivate: false,\n };\n const modelProps = await iModel?.models.queryProps(queryParams) ?? [];\n return modelProps\n .map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection }))\n .filter(({ id }) => id) as TreeViewModelInfo[];\n }, [iModel]);\n\n useEffect(() => {\n queryModels(viewport)\n .then((modelInfos: TreeViewModelInfo[]) => {\n setAvailableModels(modelInfos.map(({ id }) => id));\n\n const { models2d, models3d } = modelInfos.reduce((acc, { id, isPlanProjection }) => {\n isPlanProjection ? acc.models2d.push(id) : acc.models3d.push(id);\n return acc;\n }, { models2d: [] as string[], models3d: [] as string[] });\n\n setAvailable2dModels(models2d);\n setAvailable3dModels(models3d);\n })\n .catch((_e) => {\n setAvailableModels([]);\n });\n }, [queryModels, viewport]);\n\n const invert = useCallback(async () => {\n if (availableModels.length === 0) return;\n const notViewedModels: string[] = [];\n const models: string[] = [];\n availableModels.forEach((id: string) => {\n if (viewport?.viewsModel(id)) models.push(id);\n else notViewedModels.push(id);\n });\n await viewport?.addViewedModels(notViewedModels);\n viewport?.changeModelDisplay(models, false);\n viewport?.invalidateScene();\n }, [viewport, availableModels]);\n\n const hideAll = useCallback(() => {\n viewport?.changeModelDisplay(availableModels, false);\n viewport?.invalidateScene();\n }, [viewport, availableModels]);\n\n const showAll = useCallback(async () => {\n await viewport?.addViewedModels(availableModels);\n viewport?.invalidateScene();\n }, [viewport, availableModels]);\n\n const viewToggle2D = useCallback(async () => {\n if (is2dToggleActive) {\n viewport?.changeModelDisplay(available2dModels, false);\n setIs2dToggleActive(false);\n setIcon2dToggle(\"icon-visibility-hide-2\");\n } else {\n await viewport?.addViewedModels(available2dModels);\n setIs2dToggleActive(true);\n setIcon2dToggle(\"icon-visibility\");\n }\n viewport?.invalidateScene();\n }, [is2dToggleActive, viewport, available2dModels]);\n\n const viewToggle3D = useCallback(async () => {\n if (is3dToggleActive) {\n viewport?.changeModelDisplay(available3dModels, false);\n setIs3dToggleActive(false);\n setIcon3dToggle(\"icon-visibility-hide-2\");\n } else {\n await viewport?.addViewedModels(available3dModels);\n setIs3dToggleActive(true);\n setIcon3dToggle(\"icon-visibility\");\n }\n viewport?.invalidateScene();\n }, [is3dToggleActive, viewport, available3dModels]);\n\n return (\n <>\n {iModel && viewport &&\n <>\n <TreeHeaderComponent\n searchOptions={searchOptions}\n showAll={showAll}\n hideAll={hideAll}\n invert={invert}\n toggle2D={viewToggle2D}\n toggle2DIcon={icon2dToggle}\n toggle3D={viewToggle3D}\n toggle3DIcon={icon3dToggle}\n />\n <AutoSizer>\n {({ width, height }) => (\n <ModelsTree\n {...props}\n iModel={iModel}\n activeView={viewport}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </>\n }\n </>\n );\n};\n"]}
@@ -1,3 +1,4 @@
1
- import type { SpatialContainmentTreeProps } from "@itwin/appui-react";
2
- export declare const SpatialTreeComponent: (props: Omit<SpatialContainmentTreeProps, "width" | "height">) => JSX.Element;
1
+ /// <reference types="react" />
2
+ import type { SpatialTreeProps } from "../../types";
3
+ export declare const SpatialTreeComponent: (props: SpatialTreeProps) => JSX.Element;
3
4
  //# sourceMappingURL=SpatialTree.d.ts.map
@@ -1,14 +1,13 @@
1
- import { SpatialContainmentTree } from "@itwin/appui-react";
2
- import { useResizeObserver } from "@itwin/core-react";
3
- import React, { useCallback, useState } from "react";
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { SpatialContainmentTree, useActiveIModelConnection } from "@itwin/appui-react";
6
+ import React from "react";
7
+ import { AutoSizer } from "../utils/AutoSizer";
4
8
  export const SpatialTreeComponent = (props) => {
5
- const [height, setHeight] = useState(0);
6
- const [width, setWidth] = useState(0);
7
- const handleResize = useCallback((w, h) => {
8
- setHeight(h);
9
- setWidth(w);
10
- }, []);
11
- const ref = useResizeObserver(handleResize);
12
- return (React.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (React.createElement(SpatialContainmentTree, { ...props, width: width, height: height }))));
9
+ const iModel = useActiveIModelConnection();
10
+ return (React.createElement(React.Fragment, null, iModel &&
11
+ React.createElement(AutoSizer, null, ({ width, height }) => React.createElement(SpatialContainmentTree, { ...props, width: width, height: height, iModel: iModel }))));
13
12
  };
14
13
  //# sourceMappingURL=SpatialTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialTree.js","sourceRoot":"","sources":["../../../../src/components/trees/SpatialTree.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,KAA4D,EAC5D,EAAE;IACF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;QACxD,SAAS,CAAC,CAAC,CAAC,CAAC;QACb,QAAQ,CAAC,CAAC,CAAC,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,MAAM,GAAG,GAAG,iBAAiB,CAAiB,YAAY,CAAC,CAAC;IAE5D,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IACpD,KAAK,IAAI,MAAM,IAAI,CAClB,oBAAC,sBAAsB,OAAK,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,CACpE,CACG,CACP,CAAC;AACJ,CAAC,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*--------------------------------------------------------------------------------------------*/\nimport type { SpatialContainmentTreeProps } from \"@itwin/appui-react\";\nimport { SpatialContainmentTree } from \"@itwin/appui-react\";\nimport { useResizeObserver } from \"@itwin/core-react\";\nimport React, { useCallback, useState } from \"react\";\n\nexport const SpatialTreeComponent = (\n props: Omit<SpatialContainmentTreeProps, \"width\" | \"height\">\n) => {\n const [height, setHeight] = useState(0);\n const [width, setWidth] = useState(0);\n const handleResize = useCallback((w: number, h: number) => {\n setHeight(h);\n setWidth(w);\n }, []);\n const ref = useResizeObserver<HTMLDivElement>(handleResize);\n\n return (\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }}>\n {width && height && (\n <SpatialContainmentTree {...props} width={width} height={height} />\n )}\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"SpatialTree.js","sourceRoot":"","sources":["../../../../src/components/trees/SpatialTree.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,KAAuB,EAAE,EAAE;IAC3B,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,OAAO,CACL,0CACG,MAAM;QACL,oBAAC,SAAS,QACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,oBAAC,sBAAsB,OAAK,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAI,CACjG,CAEb,CACJ,CAAC;AACJ,CAAC,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*--------------------------------------------------------------------------------------------*/\nimport { SpatialContainmentTree, useActiveIModelConnection } from \"@itwin/appui-react\";\nimport React from \"react\";\nimport type { SpatialTreeProps } from \"../../types\";\nimport { AutoSizer } from \"../utils/AutoSizer\";\n\nexport const SpatialTreeComponent = (\n props: SpatialTreeProps) => {\n const iModel = useActiveIModelConnection();\n\n return (\n <>\n {iModel &&\n <AutoSizer>\n {({ width, height }) => <SpatialContainmentTree {...props} width={width} height={height} iModel={iModel} />}\n </AutoSizer>\n }\n </>\n );\n};\n"]}
@@ -1,6 +1,5 @@
1
1
  export * from "./ModelsTree";
2
2
  export * from "./CategoriesTree";
3
3
  export * from "./SpatialTree";
4
- export * from "./ClassificationsTree";
5
- export * from "./TreeWithRuleset";
4
+ export * from "./IModelContentTree";
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,9 @@
1
1
  /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
5
  export * from "./ModelsTree";
6
6
  export * from "./CategoriesTree";
7
7
  export * from "./SpatialTree";
8
- export * from "./ClassificationsTree";
9
- export * from "./TreeWithRuleset";
8
+ export * from "./IModelContentTree";
10
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/trees/index.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,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*--------------------------------------------------------------------------------------------*/\nexport * from \"./ModelsTree\";\nexport * from \"./CategoriesTree\";\nexport * from \"./SpatialTree\";\nexport * from \"./ClassificationsTree\";\nexport * from \"./TreeWithRuleset\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/trees/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport * from \"./ModelsTree\";\nexport * from \"./CategoriesTree\";\nexport * from \"./SpatialTree\";\nexport * from \"./IModelContentTree\";\n"]}
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ export interface Size {
3
+ width: number;
4
+ height: number;
5
+ }
6
+ export interface AutoSizerProps {
7
+ children: (size: Size) => React.ReactElement | null;
8
+ }
9
+ export declare const AutoSizer: (props: AutoSizerProps) => JSX.Element;
10
+ //# sourceMappingURL=AutoSizer.d.ts.map
@@ -0,0 +1,13 @@
1
+ import React, { useCallback, useState } from "react";
2
+ import { useResizeObserver } from "@itwin/core-react";
3
+ export const AutoSizer = (props) => {
4
+ const [height, setHeight] = useState(0);
5
+ const [width, setWidth] = useState(0);
6
+ const handleResize = useCallback((w, h) => {
7
+ setHeight(h);
8
+ setWidth(w);
9
+ }, []);
10
+ const ref = useResizeObserver(handleResize);
11
+ return (React.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (props.children({ width, height }))));
12
+ };
13
+ //# sourceMappingURL=AutoSizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoSizer.js","sourceRoot":"","sources":["../../../../src/components/utils/AutoSizer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAWtD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,EAAE;IACjD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;QACxD,SAAS,CAAC,CAAC,CAAC,CAAC;QACb,QAAQ,CAAC,CAAC,CAAC,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,MAAM,GAAG,GAAG,iBAAiB,CAAiB,YAAY,CAAC,CAAC;IAE5D,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IACpD,KAAK,IAAI,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CACnD,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { useResizeObserver } from \"@itwin/core-react\";\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport interface AutoSizerProps {\n children: (size: Size) => React.ReactElement | null;\n}\n\nexport const AutoSizer = (props: AutoSizerProps) => {\n const [height, setHeight] = useState(0);\n const [width, setWidth] = useState(0);\n const handleResize = useCallback((w: number, h: number) => {\n setHeight(h);\n setWidth(w);\n }, []);\n const ref = useResizeObserver<HTMLDivElement>(handleResize);\n\n return (\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }}>\n {width && height && (props.children({ width, height }))}\n </div>\n );\n};\n"]}
@@ -1,5 +1,5 @@
1
+ export * from "./types";
1
2
  export * from "./TreeWidget";
2
- export * from "./components/TreeWidgetControl";
3
3
  export * from "./components/TreeWidgetComponent";
4
4
  export * from "./components/header/TreeHeader";
5
5
  export * from "./components/trees";
@@ -1,9 +1,9 @@
1
1
  /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ export * from "./types";
5
6
  export * from "./TreeWidget";
6
- export * from "./components/TreeWidgetControl";
7
7
  export * from "./components/TreeWidgetComponent";
8
8
  export * from "./components/header/TreeHeader";
9
9
  export * from "./components/trees";
@@ -1 +1 @@
1
- {"version":3,"file":"tree-widget-react.js","sourceRoot":"","sources":["../../src/tree-widget-react.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wCAAwC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./TreeWidget\";\nexport * from \"./components/TreeWidgetControl\";\nexport * from \"./components/TreeWidgetComponent\";\nexport * from \"./components/header/TreeHeader\";\nexport * from \"./components/trees\";\nexport * from \"./components/TreeWidgetUiItemsProvider\";\n"]}
1
+ {"version":3,"file":"tree-widget-react.js","sourceRoot":"","sources":["../../src/tree-widget-react.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wCAAwC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport * from \"./types\";\nexport * from \"./TreeWidget\";\nexport * from \"./components/TreeWidgetComponent\";\nexport * from \"./components/header/TreeHeader\";\nexport * from \"./components/trees\";\nexport * from \"./components/TreeWidgetUiItemsProvider\";\n"]}
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ import type { StagePanelLocation, StagePanelSection } from "@itwin/appui-abstract";
3
+ import type { CategoryTreeProps, ModelsTreeProps, SpatialContainmentTreeProps } from "@itwin/appui-react";
4
+ import type { SelectableContentDefinition } from "@itwin/components-react";
5
+ import type { IModelConnection } from "@itwin/core-frontend";
6
+ export interface IModelContentTreeProps extends Omit<React.AllHTMLAttributes<HTMLDivElement>, "children"> {
7
+ iModel: IModelConnection;
8
+ }
9
+ export declare type ModelTreeProps = Omit<ModelsTreeProps, "iModel" | "activeView" | "width" | "height" | "filterInfo" | "onFilterApplied">;
10
+ export declare type CategoriesTreeProps = Omit<CategoryTreeProps, "iModel" | "activeView" | "width" | "height" | "filterInfo" | "onFilterApplied">;
11
+ export declare type SpatialTreeProps = Omit<SpatialContainmentTreeProps, "iModel" | "width" | "height">;
12
+ export interface TreeWidgetOptions {
13
+ defaultPanelLocation?: StagePanelLocation;
14
+ defaultPanelSection?: StagePanelSection;
15
+ enableElementsClassGrouping?: boolean;
16
+ additionalTrees?: SelectableContentDefinition[];
17
+ modelsTreeProps?: ModelTreeProps;
18
+ categoriesTreeProps?: CategoriesTreeProps;
19
+ spatialTreeProps?: SpatialTreeProps;
20
+ hideTrees?: {
21
+ modelsTree?: boolean;
22
+ categoriesTree?: boolean;
23
+ spatialTree?: boolean;
24
+ };
25
+ }
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","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*--------------------------------------------------------------------------------------------*/\nimport type { StagePanelLocation, StagePanelSection } from \"@itwin/appui-abstract\";\nimport type {\n CategoryTreeProps,\n ModelsTreeProps,\n SpatialContainmentTreeProps,\n} from \"@itwin/appui-react\";\nimport type { SelectableContentDefinition } from \"@itwin/components-react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\n\nexport interface IModelContentTreeProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"children\"> {\n iModel: IModelConnection;\n}\n\nexport type ModelTreeProps = Omit<\nModelsTreeProps,\n| \"iModel\"\n| \"activeView\"\n| \"width\"\n| \"height\"\n| \"filterInfo\"\n| \"onFilterApplied\"\n>;\n\nexport type CategoriesTreeProps = Omit<\nCategoryTreeProps,\n| \"iModel\"\n| \"activeView\"\n| \"width\"\n| \"height\"\n| \"filterInfo\"\n| \"onFilterApplied\"\n>;\n\nexport type SpatialTreeProps = Omit<\nSpatialContainmentTreeProps,\n\"iModel\" | \"width\" | \"height\"\n>;\n\nexport interface TreeWidgetOptions {\n defaultPanelLocation?: StagePanelLocation;\n defaultPanelSection?: StagePanelSection;\n enableElementsClassGrouping?: boolean;\n additionalTrees?: SelectableContentDefinition[];\n modelsTreeProps?: ModelTreeProps;\n categoriesTreeProps?: CategoriesTreeProps;\n spatialTreeProps?: SpatialTreeProps;\n hideTrees?: {\n modelsTree?: boolean;\n categoriesTree?: boolean;\n spatialTree?: boolean;\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/tree-widget-react",
3
- "version": "0.2.1",
3
+ "version": "0.4.1",
4
4
  "description": "Tree Widget React",
5
5
  "keywords": [
6
6
  "Bentley",
@@ -36,9 +36,12 @@
36
36
  "@itwin/core-frontend": "^3.0.0",
37
37
  "@itwin/core-geometry": "^3.0.0",
38
38
  "@itwin/core-i18n": "^3.0.0",
39
+ "@itwin/core-markup": "^3.0.0",
40
+ "@itwin/core-orbitgt": "^3.0.0",
39
41
  "@itwin/core-quantity": "^3.0.0",
40
42
  "@itwin/core-react": "^3.0.0",
41
43
  "@itwin/eslint-plugin": "^3.0.0",
44
+ "@itwin/imodel-components-react": "^3.0.0",
42
45
  "@itwin/presentation-common": "^3.0.0",
43
46
  "@itwin/presentation-components": "^3.0.0",
44
47
  "@itwin/presentation-frontend": "^3.0.0",
@@ -62,7 +65,6 @@
62
65
  "@itwin/core-frontend": "^3.0.0",
63
66
  "@itwin/core-react": "^3.0.0",
64
67
  "@itwin/presentation-components": "^3.0.0",
65
- "@itwin/presentation-frontend": "^3.0.0",
66
68
  "react": "^17.0.2",
67
69
  "react-dom": "^17.0.2"
68
70
  },
@@ -92,5 +94,6 @@
92
94
  "test": "",
93
95
  "clean": "rimraf lib .rush/temp/package-deps*.json",
94
96
  "rebuild": "npm run clean && npm run build"
95
- }
97
+ },
98
+ "readme": "# @itwin/tree-widget-react\n\nCopyright © Bentley Systems, Incorporated. All rights reserved.\n\nThe tree-widget-react package provides React components to access Models and Categories within an iModel via a UiProvider, `TreeWidgetUiItemsProvider`.\n\nThe package also provides the underlying component, `TreeWidgetComponent`, which you can wrap within your own custom UiProvider and pass in your own custom trees to display.\n\n## Usage\n\n### What to add in your iTwin AppUI based application\n\nWith a few short lines, you can add the tree widget to your app.\n\n#### Call TreeWidget.initialize() **_before_** making use of the provided Tree Widget Provider\n\n```ts\nimport { TreeWidget } from \"@itwin/tree-widget-react\";\n...\nawait TreeWidget.initialize(IModelApp.localization);\n```\n\n#### Register Tree Widget Provider\n\n```ts\nimport { UiItemsManager } from \"@itwin/appui-abstract\";\nimport { TreeWidgetUiItemsProvider } from \"@itwin/tree-widget-react\";\n...\nUiItemsManager.register(\n new TreeWidgetUiItemsProvider({ ...TreeWidgetOptions })\n);\n```\n\n### Additional trees avaialable\n\n#### IModelContentTree\n\nComponent that displays a hierarchy with content of a given `IModelConnection`.\n\n##### Resulting hierarchy\n\n- Root Subject\n - Child Subjects\n - Target Model\n - Spatial Categories of top-assemblies in the Model (if model is a GeometricModel3d)\n - Top-assemblies in the model and category\n - Child elements of the assembly\n - Drawing Categories of top-assemblies in the Model (if model is a GeometricModel2d)\n - Top-assemblies in the model and category\n - Child elements of the assembly\n - Top-assemblies in the Model (if model is neither GeometricModel3d nor GeometricModel2d)\n - Child elements of the assembly\n\nIn addition, for every modeled element we show content of the model as children for the element's node.\n\nMore details about Subjects and Models can be found here:\n\n- <https://www.imodeljs.org/bis/intro/information-hierarchy/>\n- <https://www.imodeljs.org/bis/intro/organizing-models-and-elements/>\n\nMore details about the hierarchy can be found in the [presentation ruleset JSON file](./src/components/rulesets/IModelContent.json).\n"
96
99
  }
@@ -1,26 +0,0 @@
1
- import type { ConfigurableCreateInfo } from "@itwin/appui-react";
2
- import { WidgetControl } from "@itwin/appui-react";
3
- import React from "react";
4
- import type { IModelConnection, Viewport } from "@itwin/core-frontend";
5
- import type { SelectableContentDefinition } from "@itwin/components-react";
6
- export interface TreeWidgetControlOptions {
7
- iModelConnection: IModelConnection;
8
- activeView?: Viewport;
9
- enableElementsClassGrouping?: boolean;
10
- allViewports?: boolean;
11
- additionalTrees?: SelectableContentDefinition[];
12
- additionalProps?: {
13
- modelsTree?: {};
14
- categoriesTree?: {};
15
- spatialTree?: {};
16
- };
17
- treeReplacements?: {
18
- modelsTree?: () => React.ReactNode;
19
- categoriesTree?: () => React.ReactNode;
20
- spatialTree?: () => React.ReactNode;
21
- };
22
- }
23
- export declare class TreeWidgetControl extends WidgetControl {
24
- constructor(info: ConfigurableCreateInfo, options: TreeWidgetControlOptions);
25
- }
26
- //# sourceMappingURL=TreeWidgetControl.d.ts.map
@@ -1,66 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.TreeWidgetControl = void 0;
11
- const appui_react_1 = require("@itwin/appui-react");
12
- const react_1 = __importDefault(require("react"));
13
- const CategoriesTree_1 = require("./trees/CategoriesTree");
14
- const ModelsTree_1 = require("./trees/ModelsTree");
15
- const SpatialTree_1 = require("./trees/SpatialTree");
16
- const TreeWidgetComponent_1 = require("./TreeWidgetComponent");
17
- const TreeWidget_1 = require("../TreeWidget");
18
- class TreeWidgetControl extends appui_react_1.WidgetControl {
19
- constructor(info, options) {
20
- var _a, _b, _c, _d, _e, _f;
21
- super(info, options);
22
- const { iModelConnection: imodel, activeView } = options;
23
- const modelsTreeProps = (_a = options.additionalProps) === null || _a === void 0 ? void 0 : _a.modelsTree;
24
- const categoriesTreeProps = (_b = options.additionalProps) === null || _b === void 0 ? void 0 : _b.categoriesTree;
25
- const spatialTreeProps = (_c = options.additionalProps) === null || _c === void 0 ? void 0 : _c.spatialTree;
26
- const enableElementsClassGrouping = options.enableElementsClassGrouping;
27
- const allViewPorts = options.allViewports;
28
- const additionalTrees = options.additionalTrees;
29
- const modelsTreeReplacement = (_d = options.treeReplacements) === null || _d === void 0 ? void 0 : _d.modelsTree;
30
- const categoriesTreeReplacement = (_e = options.treeReplacements) === null || _e === void 0 ? void 0 : _e.categoriesTree;
31
- const spatialTreeReplacement = (_f = options.treeReplacements) === null || _f === void 0 ? void 0 : _f.spatialTree;
32
- const modelsTreeComponent = (react_1.default.createElement(ModelsTree_1.ModelsTreeComponent, { iModel: imodel, allViewports: allViewPorts, activeView: activeView, enableElementsClassGrouping: enableElementsClassGrouping, ...modelsTreeProps }));
33
- const categoriesTreeComponent = (react_1.default.createElement(CategoriesTree_1.CategoriesTreeComponent, { iModel: imodel, allViewports: allViewPorts, activeView: activeView, ...categoriesTreeProps }));
34
- const spatialContainmentComponent = (react_1.default.createElement(SpatialTree_1.SpatialTreeComponent, { iModel: imodel, enableElementsClassGrouping: enableElementsClassGrouping
35
- ? appui_react_1.ClassGroupingOption.Yes
36
- : appui_react_1.ClassGroupingOption.No, ...spatialTreeProps }));
37
- const trees = [
38
- {
39
- label: TreeWidget_1.TreeWidget.translate("modeltree"),
40
- id: "model-tree",
41
- render: modelsTreeReplacement
42
- ? modelsTreeReplacement
43
- : () => modelsTreeComponent,
44
- },
45
- {
46
- label: TreeWidget_1.TreeWidget.translate("categories"),
47
- id: "categories-tree",
48
- render: categoriesTreeReplacement
49
- ? categoriesTreeReplacement
50
- : () => categoriesTreeComponent,
51
- },
52
- {
53
- label: TreeWidget_1.TreeWidget.translate("containment"),
54
- id: "spatial-containment-tree",
55
- render: spatialTreeReplacement
56
- ? spatialTreeReplacement
57
- : () => spatialContainmentComponent,
58
- },
59
- ];
60
- if (additionalTrees)
61
- trees.push(...additionalTrees);
62
- this.reactNode = react_1.default.createElement(TreeWidgetComponent_1.TreeWidgetComponent, { trees: trees });
63
- }
64
- }
65
- exports.TreeWidgetControl = TreeWidgetControl;
66
- //# sourceMappingURL=TreeWidgetControl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeWidgetControl.js","sourceRoot":"","sources":["../../../src/components/TreeWidgetControl.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;AAG/F,oDAG4B;AAC5B,kDAA0B;AAC1B,2DAAiE;AACjE,mDAAyD;AACzD,qDAA2D;AAE3D,+DAA4D;AAE5D,8CAA2C;A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AC,GAAG;gBACzB,CAAC,CAAC,iCAAmB,CAAC,EAAE,KAExB,gBAAgB,GACpB,CACH,CAAC;QAEF,MAAM,KAAK,GAAkC;YAC3C;gBACE,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,WAAW,CAAC;gBACxC,EAAE,EAAE,YAAY;gBAChB,MAAM,EAAE,qBAAqB;oBAC3B,CAAC,CAAC,qBAAqB;oBACvB,CAAC,CAAC,GAAG,EAAE,CAAC,mBAAmB;aAC9B;YACD;gBACE,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,YAAY,CAAC;gBACzC,EAAE,EAAE,iBAAiB;gBACrB,MAAM,EAAE,yBAAyB;oBAC/B,CAAC,CAAC,yBAAyB;oBAC3B,CAAC,CAAC,GAAG,EAAE,CAAC,uBAAuB;aAClC;YACD;gBACE,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,aAAa,CAAC;gBAC1C,EAAE,EAAE,0BAA0B;gBAC9B,MAAM,EAAE,sBAAsB;oBAC5B,CAAC,CAAC,sBAAsB;oBACxB,CAAC,CAAC,GAAG,EAAE,CAAC,2BAA2B;aACtC;SACF,CAAC;QAEF,IAAI,eAAe;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC;QAEpD,IAAI,CAAC,SAAS,GAAG,8BAAC,yCAAmB,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC;IACzD,CAAC;CACF;AA1ED,8CA0EC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport type { ConfigurableCreateInfo } from \"@itwin/appui-react\";\nimport {\n ClassGroupingOption,\n WidgetControl,\n} from \"@itwin/appui-react\";\nimport React from \"react\";\nimport { CategoriesTreeComponent } from \"./trees/CategoriesTree\";\nimport { ModelsTreeComponent } from \"./trees/ModelsTree\";\nimport { SpatialTreeComponent } from \"./trees/SpatialTree\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport { TreeWidgetComponent } from \"./TreeWidgetComponent\";\nimport type { SelectableContentDefinition } from \"@itwin/components-react\";\nimport { TreeWidget } from \"../TreeWidget\";\n\nexport interface TreeWidgetControlOptions {\n iModelConnection: IModelConnection;\n activeView?: Viewport;\n enableElementsClassGrouping?: boolean;\n allViewports?: boolean;\n additionalTrees?: SelectableContentDefinition[];\n additionalProps?: {\n modelsTree?: {};\n categoriesTree?: {};\n spatialTree?: {};\n };\n treeReplacements?: {\n modelsTree?: () => React.ReactNode;\n categoriesTree?: () => React.ReactNode;\n spatialTree?: () => React.ReactNode;\n };\n}\n\nexport class TreeWidgetControl extends WidgetControl {\n constructor(info: ConfigurableCreateInfo, options: TreeWidgetControlOptions) {\n super(info, options);\n\n const { iModelConnection: imodel, activeView } = options;\n const modelsTreeProps = options.additionalProps?.modelsTree;\n const categoriesTreeProps = options.additionalProps?.categoriesTree;\n const spatialTreeProps = options.additionalProps?.spatialTree;\n const enableElementsClassGrouping = options.enableElementsClassGrouping;\n const allViewPorts = options.allViewports;\n const additionalTrees = options.additionalTrees;\n const modelsTreeReplacement = options.treeReplacements?.modelsTree;\n const categoriesTreeReplacement = options.treeReplacements?.categoriesTree;\n const spatialTreeReplacement = options.treeReplacements?.spatialTree;\n\n const modelsTreeComponent = (\n <ModelsTreeComponent\n iModel={imodel}\n allViewports={allViewPorts}\n activeView={activeView}\n enableElementsClassGrouping={enableElementsClassGrouping}\n {...modelsTreeProps}\n />\n );\n\n const categoriesTreeComponent = (\n <CategoriesTreeComponent\n iModel={imodel}\n allViewports={allViewPorts}\n activeView={activeView}\n {...categoriesTreeProps}\n />\n );\n\n const spatialContainmentComponent = (\n <SpatialTreeComponent\n iModel={imodel}\n enableElementsClassGrouping={\n enableElementsClassGrouping\n ? ClassGroupingOption.Yes\n : ClassGroupingOption.No\n }\n {...spatialTreeProps}\n />\n );\n\n const trees: SelectableContentDefinition[] = [\n {\n label: TreeWidget.translate(\"modeltree\"),\n id: \"model-tree\",\n render: modelsTreeReplacement\n ? modelsTreeReplacement\n : () => modelsTreeComponent,\n },\n {\n label: TreeWidget.translate(\"categories\"),\n id: \"categories-tree\",\n render: categoriesTreeReplacement\n ? categoriesTreeReplacement\n : () => categoriesTreeComponent,\n },\n {\n label: TreeWidget.translate(\"containment\"),\n id: \"spatial-containment-tree\",\n render: spatialTreeReplacement\n ? spatialTreeReplacement\n : () => spatialContainmentComponent,\n },\n ];\n\n if (additionalTrees) trees.push(...additionalTrees);\n\n this.reactNode = <TreeWidgetComponent trees={trees} />;\n }\n}\n"]}
@@ -1,122 +0,0 @@
1
- {
2
- "id": "tree-widget-react/ClassificationSystems",
3
- "rules": [
4
- {
5
- "ruleType": "RootNodes",
6
- "specifications": [
7
- {
8
- "specType": "InstanceNodesOfSpecificClasses",
9
- "classes": [
10
- {
11
- "schemaName": "ClassificationSystems",
12
- "classNames": [
13
- "ClassificationSystem"
14
- ]
15
- }
16
- ],
17
- "arePolymorphic": false,
18
- "groupByClass": false,
19
- "groupByLabel": false
20
- }
21
- ]
22
- },
23
- {
24
- "ruleType": "ChildNodes",
25
- "condition": "ParentNode.IsOfClass(\"ClassificationSystem\", \"ClassificationSystems\")",
26
- "specifications": [
27
- {
28
- "specType": "RelatedInstanceNodes",
29
- "relationships": {
30
- "schemaName": "ClassificationSystems",
31
- "classNames": [
32
- "ClassificationSystemOwnsClassificationTable"
33
- ]
34
- },
35
- "relatedClasses": {
36
- "schemaName": "ClassificationSystems",
37
- "classNames": [
38
- "ClassificationTable"
39
- ]
40
- },
41
- "requiredDirection": "Forward",
42
- "groupByClass": false,
43
- "groupByLabel": false,
44
- "doNotSort": true
45
- }
46
- ]
47
- },
48
- {
49
- "ruleType": "ChildNodes",
50
- "condition": "ParentNode.IsOfClass(\"ClassificationTable\", \"ClassificationSystems\")",
51
- "specifications": [
52
- {
53
- "specType": "RelatedInstanceNodes",
54
- "relationships": {
55
- "schemaName": "BisCore",
56
- "classNames": [
57
- "ModelModelsElement"
58
- ]
59
- },
60
- "relatedClasses": {
61
- "schemaName": "BisCore",
62
- "classNames": [
63
- "Model"
64
- ]
65
- },
66
- "requiredDirection": "Backward",
67
- "groupByClass": false,
68
- "groupByLabel": false,
69
- "hideNodesInHierarchy": true
70
- }
71
- ]
72
- },
73
- {
74
- "ruleType": "ChildNodes",
75
- "condition": "ParentNode.IsOfClass(\"Model\", \"BisCore\")",
76
- "specifications": [
77
- {
78
- "specType": "RelatedInstanceNodes",
79
- "relationships": {
80
- "schemaName": "BisCore",
81
- "classNames": [
82
- "ModelContainsElements"
83
- ]
84
- },
85
- "relatedClasses": {
86
- "schemaName": "ClassificationSystems",
87
- "classNames": [
88
- "Classification"
89
- ]
90
- },
91
- "requiredDirection": "Forward",
92
- "groupByClass": false,
93
- "groupByLabel": false
94
- }
95
- ]
96
- },
97
- {
98
- "ruleType": "ChildNodes",
99
- "condition": "ParentNode.IsOfClass(\"Classification\", \"ClassificationSystems\")",
100
- "specifications": [
101
- {
102
- "specType": "RelatedInstanceNodes",
103
- "relationships": {
104
- "schemaName": "ClassificationSystems",
105
- "classNames": [
106
- "ElementHasClassifications"
107
- ]
108
- },
109
- "relatedClasses": {
110
- "schemaName": "BisCore",
111
- "classNames": [
112
- "Element"
113
- ]
114
- },
115
- "requiredDirection": "Backward",
116
- "groupByClass": false,
117
- "groupByLabel": false
118
- }
119
- ]
120
- }
121
- ]
122
- }
@@ -1,6 +0,0 @@
1
- import type { IModelConnection } from "@itwin/core-frontend";
2
- export interface ClassificationsTreeComponentProps {
3
- iModel: IModelConnection;
4
- }
5
- export declare function ClassificationsTreeComponent(props: ClassificationsTreeComponentProps): JSX.Element;
6
- //# sourceMappingURL=ClassificationsTree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClassificationsTree.js","sourceRoot":"","sources":["../../../../src/components/trees/ClassificationsTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,6CAA+B;AAE/B,uDAA0D;AAE1D,4EAA8E;AAC9E,wGAAyE;AAMzE,SAAgB,4BAA4B,CAC1C,KAAwC;IAExC,MAAM,YAAY,GAAG,IAAI,sDAA4B,CAAC;QACpD,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,oCAAmB,CAAC,EAAE;QAC/B,UAAU,EAAE,EAAE;KACf,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,uCAAqB,IACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,OAAO,EAAE,oCAA8B,EACvC,YAAY,EAAE,YAAY,GAC1B,CACH,CAAC;AACJ,CAAC;AAhBD,oEAgBC","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*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport { SimpleTreeWithRuleset } from \"./TreeWithRuleset\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { PresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport classificationRules from \"../rulesets/ClassificationSystems.json\";\n\nexport interface ClassificationsTreeComponentProps {\n iModel: IModelConnection;\n}\n\nexport function ClassificationsTreeComponent(\n props: ClassificationsTreeComponentProps\n) {\n const dataProvider = new PresentationTreeDataProvider({\n imodel: props.iModel,\n ruleset: classificationRules.id,\n pagingSize: 20,\n });\n\n return (\n <SimpleTreeWithRuleset\n imodel={props.iModel}\n ruleSet={classificationRules as Ruleset}\n dataProvider={dataProvider}\n />\n );\n}\n"]}