@itwin/tree-widget-react 0.2.0 → 0.4.0

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 (99) hide show
  1. package/README.md +30 -1
  2. package/lib/cjs/components/IconButton.scss +2 -2
  3. package/lib/cjs/components/TreeWidgetComponent.d.ts +1 -0
  4. package/lib/cjs/components/TreeWidgetComponent.scss +1 -1
  5. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +7 -16
  6. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +45 -47
  7. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  8. package/lib/cjs/components/header/TreeHeader.d.ts +1 -0
  9. package/lib/cjs/components/header/TreeHeader.scss +1 -1
  10. package/lib/cjs/components/rulesets/IModelContent.json +435 -0
  11. package/lib/cjs/components/search-bar/Popup.scss +1 -1
  12. package/lib/cjs/components/search-bar/SearchBar.scss +1 -1
  13. package/lib/cjs/components/search-bar/SearchBox.scss +1 -1
  14. package/lib/cjs/components/trees/CategoriesTree.d.ts +3 -7
  15. package/lib/cjs/components/trees/CategoriesTree.js +21 -23
  16. package/lib/cjs/components/trees/CategoriesTree.js.map +1 -1
  17. package/lib/cjs/components/trees/CategoriesTree.scss +1 -1
  18. package/lib/cjs/components/trees/IModelContentTree.d.ts +4 -0
  19. package/lib/cjs/components/trees/{ClassificationsTree.js → IModelContentTree.js} +19 -12
  20. package/lib/cjs/components/trees/IModelContentTree.js.map +1 -0
  21. package/lib/cjs/components/trees/ModelsTree.d.ts +3 -8
  22. package/lib/cjs/components/trees/ModelsTree.js +8 -16
  23. package/lib/cjs/components/trees/ModelsTree.js.map +1 -1
  24. package/lib/cjs/components/trees/ModelsTree.scss +1 -1
  25. package/lib/cjs/components/trees/SpatialTree.d.ts +3 -2
  26. package/lib/cjs/components/trees/SpatialTree.js +11 -28
  27. package/lib/cjs/components/trees/SpatialTree.js.map +1 -1
  28. package/lib/cjs/components/trees/index.d.ts +1 -2
  29. package/lib/cjs/components/trees/index.js +5 -6
  30. package/lib/cjs/components/trees/index.js.map +1 -1
  31. package/lib/cjs/components/utils/AutoSizer.d.ts +10 -0
  32. package/lib/cjs/components/utils/AutoSizer.js +36 -0
  33. package/lib/cjs/components/utils/AutoSizer.js.map +1 -0
  34. package/lib/cjs/tree-widget-react.d.ts +1 -1
  35. package/lib/cjs/tree-widget-react.js +4 -4
  36. package/lib/cjs/tree-widget-react.js.map +1 -1
  37. package/lib/cjs/types.d.ts +23 -0
  38. package/lib/cjs/types.js +3 -0
  39. package/lib/cjs/types.js.map +1 -0
  40. package/lib/esm/components/IconButton.scss +2 -2
  41. package/lib/esm/components/TreeWidgetComponent.d.ts +1 -0
  42. package/lib/esm/components/TreeWidgetComponent.scss +1 -1
  43. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +7 -16
  44. package/lib/esm/components/TreeWidgetUiItemsProvider.js +45 -47
  45. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  46. package/lib/esm/components/header/TreeHeader.d.ts +1 -0
  47. package/lib/esm/components/header/TreeHeader.scss +1 -1
  48. package/lib/esm/components/rulesets/IModelContent.json +435 -0
  49. package/lib/esm/components/search-bar/Popup.scss +1 -1
  50. package/lib/esm/components/search-bar/SearchBar.scss +1 -1
  51. package/lib/esm/components/search-bar/SearchBox.scss +1 -1
  52. package/lib/esm/components/trees/CategoriesTree.d.ts +3 -7
  53. package/lib/esm/components/trees/CategoriesTree.js +23 -25
  54. package/lib/esm/components/trees/CategoriesTree.js.map +1 -1
  55. package/lib/esm/components/trees/CategoriesTree.scss +1 -1
  56. package/lib/esm/components/trees/IModelContentTree.d.ts +4 -0
  57. package/lib/esm/components/trees/IModelContentTree.js +24 -0
  58. package/lib/esm/components/trees/IModelContentTree.js.map +1 -0
  59. package/lib/esm/components/trees/ModelsTree.d.ts +3 -8
  60. package/lib/esm/components/trees/ModelsTree.js +9 -17
  61. package/lib/esm/components/trees/ModelsTree.js.map +1 -1
  62. package/lib/esm/components/trees/ModelsTree.scss +1 -1
  63. package/lib/esm/components/trees/SpatialTree.d.ts +3 -2
  64. package/lib/esm/components/trees/SpatialTree.js +10 -11
  65. package/lib/esm/components/trees/SpatialTree.js.map +1 -1
  66. package/lib/esm/components/trees/index.d.ts +1 -2
  67. package/lib/esm/components/trees/index.js +4 -5
  68. package/lib/esm/components/trees/index.js.map +1 -1
  69. package/lib/esm/components/utils/AutoSizer.d.ts +10 -0
  70. package/lib/esm/components/utils/AutoSizer.js +13 -0
  71. package/lib/esm/components/utils/AutoSizer.js.map +1 -0
  72. package/lib/esm/tree-widget-react.d.ts +1 -1
  73. package/lib/esm/tree-widget-react.js +4 -4
  74. package/lib/esm/tree-widget-react.js.map +1 -1
  75. package/lib/esm/types.d.ts +23 -0
  76. package/lib/esm/types.js +2 -0
  77. package/lib/esm/types.js.map +1 -0
  78. package/package.json +1 -2
  79. package/lib/cjs/components/TreeWidgetControl.d.ts +0 -26
  80. package/lib/cjs/components/TreeWidgetControl.js +0 -66
  81. package/lib/cjs/components/TreeWidgetControl.js.map +0 -1
  82. package/lib/cjs/components/rulesets/ClassificationSystems.json +0 -122
  83. package/lib/cjs/components/trees/ClassificationsTree.d.ts +0 -6
  84. package/lib/cjs/components/trees/ClassificationsTree.js.map +0 -1
  85. package/lib/cjs/components/trees/TreeWithRuleset.d.ts +0 -35
  86. package/lib/cjs/components/trees/TreeWithRuleset.js +0 -110
  87. package/lib/cjs/components/trees/TreeWithRuleset.js.map +0 -1
  88. package/lib/cjs/components/trees/TreeWithRulesetTree.scss +0 -17
  89. package/lib/esm/components/TreeWidgetControl.d.ts +0 -26
  90. package/lib/esm/components/TreeWidgetControl.js +0 -59
  91. package/lib/esm/components/TreeWidgetControl.js.map +0 -1
  92. package/lib/esm/components/rulesets/ClassificationSystems.json +0 -122
  93. package/lib/esm/components/trees/ClassificationsTree.d.ts +0 -6
  94. package/lib/esm/components/trees/ClassificationsTree.js +0 -17
  95. package/lib/esm/components/trees/ClassificationsTree.js.map +0 -1
  96. package/lib/esm/components/trees/TreeWithRuleset.d.ts +0 -35
  97. package/lib/esm/components/trees/TreeWithRuleset.js +0 -85
  98. package/lib/esm/components/trees/TreeWithRuleset.js.map +0 -1
  99. package/lib/esm/components/trees/TreeWithRulesetTree.scss +0 -17
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../src/components/trees/IModelContentTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+CAAuC;AAEvC,4EAA+E;AAC/E,8DAA4G;AAC5G,wFAAoE;AACpE,kDAA+C;AAC/C,4DAAoC;AAG7B,MAAM,iBAAiB,GAAG,CAAC,KAA6B,EAAE,EAAE;IACjE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC;IAEjD,MAAM,EAAE,UAAU,EAAE,GAAG,uDAA6B,CAAC;QACnD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,4BAAiC;QAC1C,UAAU,EAAE,EAAE;QACd,mCAAmC,EAAE,IAAI;KAC1C,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,uCAAoB,CAAC,eAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,gCAAgC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAEtK,MAAM,SAAS,GAAG,+BAAY,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAEvD,OAAO,CACL,8BAAC,qBAAS,QACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACtB,0CAAS,QAAQ,EAAE,SAAS,EAAE,oBAAU,CAAC,qBAAqB,EAAE,SAAS,CAAC;QACxE,8BAAC,iCAAc,IACb,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,gCAAa,CAAC,IAAI,EACjC,aAAa,EAAE,YAAY,EAC3B,KAAK,EAAE,SAAS,EAChB,YAAY,EAAE,IAAI,GAClB,CACE,CACP,CACS,CACb,CAAC;AACJ,CAAC,CAAC;AA9BW,QAAA,iBAAiB,qBA8B5B","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 React, { useMemo } from \"react\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { ControlledTree, SelectionMode, useTreeEventsHandler, useTreeModel } from \"@itwin/components-react\";\nimport IMODEL_CONTENT_RULESET from \"../rulesets/IModelContent.json\";\nimport { AutoSizer } from \"../utils/AutoSizer\";\nimport classNames from \"classnames\";\nimport type { IModelContentTreeProps } from \"../../types\";\n\nexport const IModelContentTree = (props: IModelContentTreeProps) => {\n const { iModel, className, ...divProps } = props;\n\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: iModel,\n ruleset: IMODEL_CONTENT_RULESET as Ruleset,\n pagingSize: 20,\n appendChildrenCountForGroupingNodes: true,\n });\n const eventHandler = useTreeEventsHandler(useMemo(() => ({ nodeLoader, modelSource: nodeLoader.modelSource, collapsedChildrenDisposalEnabled: true }), [nodeLoader]));\n\n const treeModel = useTreeModel(nodeLoader.modelSource);\n\n return (\n <AutoSizer>\n {({ width, height }) => (\n <div {...divProps} className={classNames(\"imodel-content-tree\", className)}>\n <ControlledTree\n width={width}\n height={height}\n nodeLoader={nodeLoader}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler}\n model={treeModel}\n iconsEnabled={true}\n />\n </div>\n )}\n </AutoSizer>\n );\n};\n"]}
@@ -1,10 +1,5 @@
1
- import type { IModelConnection, Viewport } from "@itwin/core-frontend";
1
+ /// <reference types="react" />
2
2
  import "./ModelsTree.scss";
3
- export interface ModelTreeProps {
4
- iModel: IModelConnection;
5
- allViewports?: boolean;
6
- activeView?: Viewport;
7
- enableElementsClassGrouping?: boolean;
8
- }
9
- export declare const ModelsTreeComponent: (props: ModelTreeProps) => JSX.Element | null;
3
+ import type { ModelTreeProps } from "../../types";
4
+ export declare const ModelsTreeComponent: (props: ModelTreeProps) => JSX.Element;
10
5
  //# sourceMappingURL=ModelsTree.d.ts.map
@@ -29,9 +29,8 @@ const appui_react_1 = require("@itwin/appui-react");
29
29
  const TreeFilteringState_1 = require("../TreeFilteringState");
30
30
  require("./ModelsTree.scss");
31
31
  const TreeHeader_1 = require("../header/TreeHeader");
32
- const core_react_1 = require("@itwin/core-react");
32
+ const AutoSizer_1 = require("../utils/AutoSizer");
33
33
  const ModelsTreeComponent = (props) => {
34
- const { iModel } = props;
35
34
  const [is2dToggleActive, setIs2dToggleActive] = react_1.useState(false);
36
35
  const [is3dToggleActive, setIs3dToggleActive] = react_1.useState(false);
37
36
  const [icon2dToggle, setIcon2dToggle] = react_1.useState("icon-visibility");
@@ -39,23 +38,18 @@ const ModelsTreeComponent = (props) => {
39
38
  const [available2dModels, setAvailable2dModels] = react_1.useState([]);
40
39
  const [available3dModels, setAvailable3dModels] = react_1.useState([]);
41
40
  const [availableModels, setAvailableModels] = react_1.useState([]);
41
+ const iModel = appui_react_1.useActiveIModelConnection();
42
42
  const viewport = appui_react_1.useActiveViewport();
43
43
  const { searchOptions, filterString, activeMatchIndex, onFilterApplied } = TreeFilteringState_1.useTreeFilteringState();
44
- const [height, setHeight] = react_1.useState(0);
45
- const [width, setWidth] = react_1.useState(0);
46
- const handleResize = react_1.useCallback((w, h) => {
47
- setHeight(h);
48
- setWidth(w);
49
- }, []);
50
- const ref = core_react_1.useResizeObserver(handleResize);
51
44
  const queryModels = react_1.useCallback(async (vp) => {
45
+ var _a;
52
46
  if (vp === undefined)
53
47
  return [];
54
48
  const queryParams = {
55
49
  from: "BisCore.GeometricModel3d",
56
50
  wantPrivate: false,
57
51
  };
58
- const modelProps = await iModel.models.queryProps(queryParams);
52
+ const modelProps = (_a = await (iModel === null || iModel === void 0 ? void 0 : iModel.models.queryProps(queryParams))) !== null && _a !== void 0 ? _a : [];
59
53
  return modelProps
60
54
  .map(({ id, isPlanProjection }) => ({ id, isPlanProjection }))
61
55
  .filter(({ id }) => id);
@@ -124,12 +118,10 @@ const ModelsTreeComponent = (props) => {
124
118
  }
125
119
  viewport === null || viewport === void 0 ? void 0 : viewport.invalidateScene();
126
120
  }, [is3dToggleActive, viewport, available3dModels]);
127
- return (!(iModel && viewport) ? null : (react_1.default.createElement(react_1.default.Fragment, null,
128
- react_1.default.createElement(TreeHeader_1.TreeHeaderComponent, { searchOptions: searchOptions, showAll: showAll, hideAll: hideAll, invert: invert, toggle2D: viewToggle2D, toggle2DIcon: icon2dToggle, toggle3D: viewToggle3D, toggle3DIcon: icon3dToggle }),
129
- react_1.default.createElement("div", { className: "tree-widget-models-tree-container" },
130
- react_1.default.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (react_1.default.createElement(appui_react_1.ModelsTree, { ...props, filterInfo: { filter: filterString, activeMatchIndex }, onFilterApplied: onFilterApplied, activeView: viewport, enableElementsClassGrouping: props.enableElementsClassGrouping
131
- ? appui_react_1.ClassGroupingOption.YesWithCounts
132
- : appui_react_1.ClassGroupingOption.No, width: width, height: height })))))));
121
+ return (react_1.default.createElement(react_1.default.Fragment, null, iModel && viewport &&
122
+ react_1.default.createElement(react_1.default.Fragment, null,
123
+ react_1.default.createElement(TreeHeader_1.TreeHeaderComponent, { searchOptions: searchOptions, showAll: showAll, hideAll: hideAll, invert: invert, toggle2D: viewToggle2D, toggle2DIcon: icon2dToggle, toggle3D: viewToggle3D, toggle3DIcon: icon3dToggle }),
124
+ react_1.default.createElement(AutoSizer_1.AutoSizer, null, ({ width, height }) => (react_1.default.createElement(appui_react_1.ModelsTree, { ...props, iModel: iModel, activeView: viewport, width: width, height: height, filterInfo: { filter: filterString, activeMatchIndex }, onFilterApplied: onFilterApplied }))))));
133
125
  };
134
126
  exports.ModelsTreeComponent = ModelsTreeComponent;
135
127
  //# 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,+CAAgE;AAEhE,oDAAwF;AACxF,8DAA8D;AAC9D,6BAA2B;AAK3B,qDAA2D;AAC3D,kDAAsD;AAc/C,MAAM,mBAAmB,GAAG,CAAC,KAAqB,EAAE,EAAE;IAC3D,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAEzB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,gBAAQ,CAAU,KAAK,CAAC,CAAC;IACzE,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,gBAAQ,CAAU,KAAK,CAAC,CAAC;IACzE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,gBAAQ,CAAS,iBAAiB,CAAC,CAAC;IAC5E,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,gBAAQ,CAAS,iBAAiB,CAAC,CAAC;IAE5E,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,gBAAQ,CAAW,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,gBAAQ,CAAW,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,gBAAQ,CAAW,EAAE,CAAC,CAAC;IAErE,MAAM,QAAQ,GAAG,+BAAiB,EAAE,CAAC;IAErC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,GACtE,0CAAqB,EAAE,CAAC;IAE1B,MA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e,EAAE,eAAe,EAChC,UAAU,EAAE,QAAQ,EACpB,2BAA2B,EACzB,KAAK,CAAC,2BAA2B;oBAC/B,CAAC,CAAC,iCAAmB,CAAC,aAAa;oBACnC,CAAC,CAAC,iCAAmB,CAAC,EAAE,EAE5B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACd,CACH,CACG,CACF,CACL,CACJ,CAAC,CAAC;AACL,CAAC,CAAC;AA5IW,QAAA,mBAAmB,uBA4I9B","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,+CAAgE;AAEhE,oDAA8F;AAC9F,8DAA8D;AAC9D,6BAA2B;AAK3B,qDAA2D;AAE3D,kDAA+C;AAOxC,MAAM,mBAAmB,GAAG,CAAC,KAAqB,EAAE,EAAE;IAC3D,MAAM,CAAC,gBAAg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Q,EAAE,YAAY,EACtB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,YAAY,EACtB,YAAY,EAAE,YAAY,GAC1B;YACF,8BAAC,qBAAS,QACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACtB,8BAAC,wBAAU,OACL,KAAK,EACT,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,QAAQ,EACpB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,EACtD,eAAe,EAAE,eAAe,GAChC,CACH,CACS,CACX,CAEJ,CACJ,CAAC;AACJ,CAAC,CAAC;AAjIW,QAAA,mBAAmB,uBAiI9B","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"]}
@@ -3,7 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
 
6
- @import "~@itwin/core-react/lib/esm/core-react/index";
6
+ @import "~@itwin/core-react/lib/cjs/core-react/index";
7
7
 
8
8
  .tree-widget-models-tree-container {
9
9
  flex: 1;
@@ -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,37 +1,20 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
4
  };
21
5
  Object.defineProperty(exports, "__esModule", { value: true });
22
6
  exports.SpatialTreeComponent = void 0;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
23
11
  const appui_react_1 = require("@itwin/appui-react");
24
- const core_react_1 = require("@itwin/core-react");
25
- const react_1 = __importStar(require("react"));
12
+ const react_1 = __importDefault(require("react"));
13
+ const AutoSizer_1 = require("../utils/AutoSizer");
26
14
  const SpatialTreeComponent = (props) => {
27
- const [height, setHeight] = react_1.useState(0);
28
- const [width, setWidth] = react_1.useState(0);
29
- const handleResize = react_1.useCallback((w, h) => {
30
- setHeight(h);
31
- setWidth(w);
32
- }, []);
33
- const ref = core_react_1.useResizeObserver(handleResize);
34
- return (react_1.default.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (react_1.default.createElement(appui_react_1.SpatialContainmentTree, { ...props, width: width, height: height }))));
15
+ const iModel = appui_react_1.useActiveIModelConnection();
16
+ return (react_1.default.createElement(react_1.default.Fragment, null, iModel &&
17
+ react_1.default.createElement(AutoSizer_1.AutoSizer, null, ({ width, height }) => react_1.default.createElement(appui_react_1.SpatialContainmentTree, { ...props, width: width, height: height, iModel: iModel }))));
35
18
  };
36
19
  exports.SpatialTreeComponent = SpatialTreeComponent;
37
20
  //# sourceMappingURL=SpatialTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialTree.js","sourceRoot":"","sources":["../../../../src/components/trees/SpatialTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAKA,oDAA4D;AAC5D,kDAAsD;AACtD,+CAAqD;AAE9C,MAAM,oBAAoB,GAAG,CAClC,KAA4D,EAC5D,EAAE;IACF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,gBAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,gBAAQ,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,mBAAW,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,8BAAiB,CAAiB,YAAY,CAAC,CAAC;IAE5D,OAAO,CACL,uCAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IACpD,KAAK,IAAI,MAAM,IAAI,CAClB,8BAAC,oCAAsB,OAAK,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,CACpE,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,oBAAoB,wBAkB/B","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,oDAAuF;AACvF,kDAA0B;AAE1B,kDAA+C;AAExC,MAAM,oBAAoB,GAAG,CAClC,KAAuB,EAAE,EAAE;IAC3B,MAAM,MAAM,GAAG,uCAAyB,EAAE,CAAC;IAE3C,OAAO,CACL,8DACG,MAAM;QACL,8BAAC,qBAAS,QACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,8BAAC,oCAAsB,OAAK,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAI,CACjG,CAEb,CACJ,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,oBAAoB,wBAa/B","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,4 +1,8 @@
1
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
+ *--------------------------------------------------------------------------------------------*/
2
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
7
  if (k2 === undefined) k2 = k;
4
8
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -10,13 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
- /*---------------------------------------------------------------------------------------------
14
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
15
- * See LICENSE.md in the project root for license terms and full copyright notice.
16
- *--------------------------------------------------------------------------------------------*/
17
17
  __exportStar(require("./ModelsTree"), exports);
18
18
  __exportStar(require("./CategoriesTree"), exports);
19
19
  __exportStar(require("./SpatialTree"), exports);
20
- __exportStar(require("./ClassificationsTree"), exports);
21
- __exportStar(require("./TreeWithRuleset"), exports);
20
+ __exportStar(require("./IModelContentTree"), exports);
22
21
  //# 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,+CAA6B;AAC7B,mDAAiC;AACjC,gDAA8B;AAC9B,wDAAsC;AACtC,oDAAkC","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,+CAA6B;AAC7B,mDAAiC;AACjC,gDAA8B;AAC9B,sDAAoC","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,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.AutoSizer = void 0;
23
+ const react_1 = __importStar(require("react"));
24
+ const core_react_1 = require("@itwin/core-react");
25
+ const AutoSizer = (props) => {
26
+ const [height, setHeight] = react_1.useState(0);
27
+ const [width, setWidth] = react_1.useState(0);
28
+ const handleResize = react_1.useCallback((w, h) => {
29
+ setHeight(h);
30
+ setWidth(w);
31
+ }, []);
32
+ const ref = core_react_1.useResizeObserver(handleResize);
33
+ return (react_1.default.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (props.children({ width, height }))));
34
+ };
35
+ exports.AutoSizer = AutoSizer;
36
+ //# sourceMappingURL=AutoSizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoSizer.js","sourceRoot":"","sources":["../../../../src/components/utils/AutoSizer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AACrD,kDAAsD;AAW/C,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,EAAE;IACjD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,gBAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,gBAAQ,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,mBAAW,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,8BAAiB,CAAiB,YAAY,CAAC,CAAC;IAE5D,OAAO,CACL,uCAAK,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;AAdW,QAAA,SAAS,aAcpB","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,8 +1,8 @@
1
1
  "use strict";
2
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
- *--------------------------------------------------------------------------------------------*/
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
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
7
  if (k2 === undefined) k2 = k;
8
8
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
17
18
  __exportStar(require("./TreeWidget"), exports);
18
- __exportStar(require("./components/TreeWidgetControl"), exports);
19
19
  __exportStar(require("./components/TreeWidgetComponent"), exports);
20
20
  __exportStar(require("./components/header/TreeHeader"), exports);
21
21
  __exportStar(require("./components/trees"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"tree-widget-react.js","sourceRoot":"","sources":["../../src/tree-widget-react.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;AAE/F,+CAA6B;AAC7B,iEAA+C;AAC/C,mEAAiD;AACjD,iEAA+C;AAC/C,qDAAmC;AACnC,yEAAuD","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,0CAAwB;AACxB,+CAA6B;AAC7B,mEAAiD;AACjD,iEAA+C;AAC/C,qDAAmC;AACnC,yEAAuD","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,23 @@
1
+ /// <reference types="react" />
2
+ import type { CategoryTreeProps, ModelsTreeProps, SpatialContainmentTreeProps } from "@itwin/appui-react";
3
+ import type { SelectableContentDefinition } from "@itwin/components-react";
4
+ import type { IModelConnection } from "@itwin/core-frontend";
5
+ export interface IModelContentTreeProps extends Omit<React.AllHTMLAttributes<HTMLDivElement>, "children"> {
6
+ iModel: IModelConnection;
7
+ }
8
+ export declare type ModelTreeProps = Omit<ModelsTreeProps, "iModel" | "activeView" | "width" | "height" | "filterInfo" | "onFilterApplied">;
9
+ export declare type CategoriesTreeProps = Omit<CategoryTreeProps, "iModel" | "activeView" | "width" | "height" | "filterInfo" | "onFilterApplied">;
10
+ export declare type SpatialTreeProps = Omit<SpatialContainmentTreeProps, "iModel" | "width" | "height">;
11
+ export interface TreeWidgetOptions {
12
+ enableElementsClassGrouping?: boolean;
13
+ additionalTrees?: SelectableContentDefinition[];
14
+ modelsTreeProps?: ModelTreeProps;
15
+ categoriesTreeProps?: CategoriesTreeProps;
16
+ spatialTreeProps?: SpatialTreeProps;
17
+ hideTrees?: {
18
+ modelsTree?: boolean;
19
+ categoriesTree?: boolean;
20
+ spatialTree?: boolean;
21
+ };
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# 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 {\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 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"]}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/esm/core-react/index";
6
- @import "~@itwin/appui-layout-react/lib/esm/appui-layout-react/footer/_variables";
5
+ @import "~@itwin/core-react/lib/cjs/core-react/index";
6
+ @import "~@itwin/appui-layout-react/lib/cjs/appui-layout-react/footer/_variables";
7
7
 
8
8
  .tree-widget-icon-button {
9
9
  display: inline-block;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import "./TreeWidgetComponent.scss";
2
3
  import type { SelectableContentDefinition } from "@itwin/components-react";
3
4
  interface TreeWidgetComponentProps {
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/esm/core-react/index";
5
+ @import "~@itwin/core-react/lib/cjs/core-react/index";
6
6
 
7
7
  .tree-widget-visibility-widget {
8
8
  padding: $uicore-s;
@@ -1,20 +1,11 @@
1
1
  import type { AbstractWidgetProps, StagePanelSection, UiItemsProvider } from "@itwin/appui-abstract";
2
- import { StagePanelLocation } from "@itwin/appui-abstract";
3
- import type { TreeWidgetControlOptions } from "./TreeWidgetControl";
2
+ import { AbstractZoneLocation, StagePanelLocation } from "@itwin/appui-abstract";
3
+ import type { TreeWidgetOptions } from "../types";
4
+ export declare const TreeWidgetId = "tree-widget-react:trees";
4
5
  export declare class TreeWidgetUiItemsProvider implements UiItemsProvider {
5
- readonly id = "TreeWidgetUiitemsProvider";
6
- private _imodel?;
7
- private _activeView?;
8
- private _enableElementsClassGrouping?;
9
- private _allViewports?;
10
- private _additionalTrees?;
11
- private _modelsTreeProps?;
12
- private _categoriesTreeProps?;
13
- private _spatialTreeProps?;
14
- private _modelsTreeReplacement?;
15
- private _categoriesTreeReplacement?;
16
- private _spatialTreeReplacement?;
17
- constructor(props?: Partial<TreeWidgetControlOptions>);
18
- provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, _section: StagePanelSection | undefined): ReadonlyArray<AbstractWidgetProps>;
6
+ private _treeWidgetOptions?;
7
+ readonly id = "TreeWidgetUiItemsProvider";
8
+ constructor(_treeWidgetOptions?: TreeWidgetOptions | undefined);
9
+ provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zoneLocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps>;
19
10
  }
20
11
  //# sourceMappingURL=TreeWidgetUiItemsProvider.d.ts.map
@@ -1,4 +1,4 @@
1
- import { StagePanelLocation, StageUsage, } from "@itwin/appui-abstract";
1
+ import { AbstractZoneLocation, StagePanelLocation, StageUsage, } from "@itwin/appui-abstract";
2
2
  import { ClassGroupingOption, UiFramework } from "@itwin/appui-react";
3
3
  import React from "react";
4
4
  import { TreeWidgetComponent } from "./TreeWidgetComponent";
@@ -6,64 +6,62 @@ import { CategoriesTreeComponent } from "./trees/CategoriesTree";
6
6
  import { ModelsTreeComponent } from "./trees/ModelsTree";
7
7
  import { SpatialTreeComponent } from "./trees/SpatialTree";
8
8
  import { TreeWidget } from "../TreeWidget";
9
+ export const TreeWidgetId = "tree-widget-react:trees";
9
10
  export class TreeWidgetUiItemsProvider {
10
- constructor(props) {
11
- var _a, _b, _c, _d, _e, _f;
12
- this.id = "TreeWidgetUiitemsProvider";
13
- this._imodel = props === null || props === void 0 ? void 0 : props.iModelConnection;
14
- this._activeView = props === null || props === void 0 ? void 0 : props.activeView;
15
- this._enableElementsClassGrouping = props === null || props === void 0 ? void 0 : props.enableElementsClassGrouping;
16
- this._allViewports = props === null || props === void 0 ? void 0 : props.allViewports;
17
- this._additionalTrees = props === null || props === void 0 ? void 0 : props.additionalTrees;
18
- this._modelsTreeProps = (_a = props === null || props === void 0 ? void 0 : props.additionalProps) === null || _a === void 0 ? void 0 : _a.modelsTree;
19
- this._categoriesTreeProps = (_b = props === null || props === void 0 ? void 0 : props.additionalProps) === null || _b === void 0 ? void 0 : _b.categoriesTree;
20
- this._spatialTreeProps = (_c = props === null || props === void 0 ? void 0 : props.additionalProps) === null || _c === void 0 ? void 0 : _c.spatialTree;
21
- this._modelsTreeReplacement = (_d = props === null || props === void 0 ? void 0 : props.treeReplacements) === null || _d === void 0 ? void 0 : _d.modelsTree;
22
- this._categoriesTreeReplacement = (_e = props === null || props === void 0 ? void 0 : props.treeReplacements) === null || _e === void 0 ? void 0 : _e.categoriesTree;
23
- this._spatialTreeReplacement = (_f = props === null || props === void 0 ? void 0 : props.treeReplacements) === null || _f === void 0 ? void 0 : _f.spatialTree;
11
+ constructor(_treeWidgetOptions) {
12
+ this._treeWidgetOptions = _treeWidgetOptions;
13
+ this.id = "TreeWidgetUiItemsProvider";
24
14
  }
25
- provideWidgets(_stageId, stageUsage, location, _section) {
26
- var _a, _b, _c;
15
+ provideWidgets(_stageId, stageUsage, location, section,
16
+ // eslint-disable-next-line deprecation/deprecation
17
+ zoneLocation) {
18
+ var _a, _b, _c, _d, _e, _f, _g;
27
19
  const widgets = [];
28
- const imodel = UiFramework.getIModelConnection();
29
- if (stageUsage === StageUsage.General &&
30
- location === StagePanelLocation.Right &&
31
- imodel !== undefined) {
32
- const modelsTreeComponent = (React.createElement(ModelsTreeComponent, { iModel: (_a = this._imodel) !== null && _a !== void 0 ? _a : imodel, allViewports: this._allViewports, activeView: this._activeView, enableElementsClassGrouping: this._enableElementsClassGrouping, ...this._modelsTreeProps }));
33
- const categoriesTreeComponent = (React.createElement(CategoriesTreeComponent, { iModel: (_b = this._imodel) !== null && _b !== void 0 ? _b : imodel, allViewports: this._allViewports, activeView: this._activeView, ...this._categoriesTreeProps }));
34
- const spatialContainmentComponent = (React.createElement(SpatialTreeComponent, { iModel: (_c = this._imodel) !== null && _c !== void 0 ? _c : imodel, enableElementsClassGrouping: this._enableElementsClassGrouping
35
- ? ClassGroupingOption.Yes
36
- : ClassGroupingOption.No, ...this._spatialTreeProps }));
37
- const trees = [
38
- {
20
+ if (
21
+ // eslint-disable-next-line deprecation/deprecation
22
+ (!section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.CenterRight) ||
23
+ (stageUsage === StageUsage.General && location === StagePanelLocation.Right && UiFramework.uiVersion !== "1")) {
24
+ const trees = [];
25
+ if (!((_b = (_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.hideTrees) === null || _b === void 0 ? void 0 : _b.modelsTree)) {
26
+ trees.push({
39
27
  label: TreeWidget.translate("modeltree"),
40
28
  id: "model-tree",
41
- render: this._modelsTreeReplacement
42
- ? this._modelsTreeReplacement
43
- : () => modelsTreeComponent,
44
- },
45
- {
29
+ render: () => {
30
+ var _a, _b;
31
+ return (React.createElement(ModelsTreeComponent, { enableElementsClassGrouping: ((_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.enableElementsClassGrouping)
32
+ ? ClassGroupingOption.YesWithCounts
33
+ : ClassGroupingOption.No, ...(_b = this._treeWidgetOptions) === null || _b === void 0 ? void 0 : _b.modelsTreeProps }));
34
+ },
35
+ });
36
+ }
37
+ if (!((_d = (_c = this._treeWidgetOptions) === null || _c === void 0 ? void 0 : _c.hideTrees) === null || _d === void 0 ? void 0 : _d.categoriesTree)) {
38
+ trees.push({
46
39
  label: TreeWidget.translate("categories"),
47
40
  id: "categories-tree",
48
- render: this._categoriesTreeReplacement
49
- ? this._categoriesTreeReplacement
50
- : () => categoriesTreeComponent,
51
- },
52
- {
41
+ render: () => {
42
+ var _a;
43
+ return (React.createElement(CategoriesTreeComponent, { ...(_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.categoriesTreeProps }));
44
+ },
45
+ });
46
+ }
47
+ if (!((_f = (_e = this._treeWidgetOptions) === null || _e === void 0 ? void 0 : _e.hideTrees) === null || _f === void 0 ? void 0 : _f.spatialTree)) {
48
+ trees.push({
53
49
  label: TreeWidget.translate("containment"),
54
50
  id: "spatial-containment-tree",
55
- render: this._spatialTreeReplacement
56
- ? this._spatialTreeReplacement
57
- : () => spatialContainmentComponent,
58
- },
59
- ];
60
- if (this._additionalTrees) {
61
- trees.push(...this._additionalTrees);
51
+ render: () => {
52
+ var _a, _b;
53
+ return (React.createElement(SpatialTreeComponent, { enableElementsClassGrouping: ((_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.enableElementsClassGrouping)
54
+ ? ClassGroupingOption.YesWithCounts
55
+ : ClassGroupingOption.No, ...(_b = this._treeWidgetOptions) === null || _b === void 0 ? void 0 : _b.spatialTreeProps }));
56
+ },
57
+ });
58
+ }
59
+ if ((_g = this._treeWidgetOptions) === null || _g === void 0 ? void 0 : _g.additionalTrees) {
60
+ trees.push(...this._treeWidgetOptions.additionalTrees);
62
61
  }
63
62
  widgets.push({
64
- id: "tree",
63
+ id: TreeWidgetId,
65
64
  label: TreeWidget.translate("treeview"),
66
- // eslint-disable-next-line react/display-name
67
65
  getWidgetContent: () => React.createElement(TreeWidgetComponent, { trees: trees }),
68
66
  });
69
67
  }