@itwin/tree-widget-react 0.1.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 (126) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +32 -0
  3. package/lib/cjs/TreeWidget.d.ts +27 -0
  4. package/lib/cjs/TreeWidget.js +57 -0
  5. package/lib/cjs/TreeWidget.js.map +1 -0
  6. package/lib/cjs/components/IconButton.d.ts +14 -0
  7. package/lib/cjs/components/IconButton.js +42 -0
  8. package/lib/cjs/components/IconButton.js.map +1 -0
  9. package/lib/cjs/components/IconButton.scss +73 -0
  10. package/lib/cjs/components/TreeFilteringState.d.ts +16 -0
  11. package/lib/cjs/components/TreeFilteringState.js +67 -0
  12. package/lib/cjs/components/TreeFilteringState.js.map +1 -0
  13. package/lib/cjs/components/TreeWidgetComponent.d.ts +8 -0
  14. package/lib/cjs/components/TreeWidgetComponent.js +41 -0
  15. package/lib/cjs/components/TreeWidgetComponent.js.map +1 -0
  16. package/lib/cjs/components/TreeWidgetComponent.scss +64 -0
  17. package/lib/cjs/components/TreeWidgetControl.d.ts +25 -0
  18. package/lib/cjs/components/TreeWidgetControl.js +64 -0
  19. package/lib/cjs/components/TreeWidgetControl.js.map +1 -0
  20. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +19 -0
  21. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +81 -0
  22. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -0
  23. package/lib/cjs/components/header/TreeHeader.d.ts +14 -0
  24. package/lib/cjs/components/header/TreeHeader.js +43 -0
  25. package/lib/cjs/components/header/TreeHeader.js.map +1 -0
  26. package/lib/cjs/components/header/TreeHeader.scss +19 -0
  27. package/lib/cjs/components/rulesets/ClassificationSystems.json +122 -0
  28. package/lib/cjs/components/search-bar/Popup.d.ts +50 -0
  29. package/lib/cjs/components/search-bar/Popup.js +246 -0
  30. package/lib/cjs/components/search-bar/Popup.js.map +1 -0
  31. package/lib/cjs/components/search-bar/Popup.scss +316 -0
  32. package/lib/cjs/components/search-bar/SearchBar.d.ts +53 -0
  33. package/lib/cjs/components/search-bar/SearchBar.js +97 -0
  34. package/lib/cjs/components/search-bar/SearchBar.js.map +1 -0
  35. package/lib/cjs/components/search-bar/SearchBar.scss +110 -0
  36. package/lib/cjs/components/search-bar/SearchBox.d.ts +76 -0
  37. package/lib/cjs/components/search-bar/SearchBox.js +184 -0
  38. package/lib/cjs/components/search-bar/SearchBox.js.map +1 -0
  39. package/lib/cjs/components/search-bar/SearchBox.scss +91 -0
  40. package/lib/cjs/components/trees/CategoriesTree.d.ts +9 -0
  41. package/lib/cjs/components/trees/CategoriesTree.js +76 -0
  42. package/lib/cjs/components/trees/CategoriesTree.js.map +1 -0
  43. package/lib/cjs/components/trees/CategoriesTree.scss +13 -0
  44. package/lib/cjs/components/trees/ClassificationsTree.d.ts +6 -0
  45. package/lib/cjs/components/trees/ClassificationsTree.js +43 -0
  46. package/lib/cjs/components/trees/ClassificationsTree.js.map +1 -0
  47. package/lib/cjs/components/trees/ModelsTree.d.ts +10 -0
  48. package/lib/cjs/components/trees/ModelsTree.js +135 -0
  49. package/lib/cjs/components/trees/ModelsTree.js.map +1 -0
  50. package/lib/cjs/components/trees/ModelsTree.scss +14 -0
  51. package/lib/cjs/components/trees/SpatialTree.d.ts +3 -0
  52. package/lib/cjs/components/trees/SpatialTree.js +41 -0
  53. package/lib/cjs/components/trees/SpatialTree.js.map +1 -0
  54. package/lib/cjs/components/trees/TreeWithRuleset.d.ts +35 -0
  55. package/lib/cjs/components/trees/TreeWithRuleset.js +108 -0
  56. package/lib/cjs/components/trees/TreeWithRuleset.js.map +1 -0
  57. package/lib/cjs/components/trees/TreeWithRulesetTree.scss +17 -0
  58. package/lib/cjs/components/trees/index.d.ts +6 -0
  59. package/lib/cjs/components/trees/index.js +22 -0
  60. package/lib/cjs/components/trees/index.js.map +1 -0
  61. package/lib/cjs/tree-widget-react.d.ts +7 -0
  62. package/lib/cjs/tree-widget-react.js +23 -0
  63. package/lib/cjs/tree-widget-react.js.map +1 -0
  64. package/lib/esm/TreeWidget.d.ts +27 -0
  65. package/lib/esm/TreeWidget.js +53 -0
  66. package/lib/esm/TreeWidget.js.map +1 -0
  67. package/lib/esm/components/IconButton.d.ts +14 -0
  68. package/lib/esm/components/IconButton.js +16 -0
  69. package/lib/esm/components/IconButton.js.map +1 -0
  70. package/lib/esm/components/IconButton.scss +73 -0
  71. package/lib/esm/components/TreeFilteringState.d.ts +16 -0
  72. package/lib/esm/components/TreeFilteringState.js +44 -0
  73. package/lib/esm/components/TreeFilteringState.js.map +1 -0
  74. package/lib/esm/components/TreeWidgetComponent.d.ts +8 -0
  75. package/lib/esm/components/TreeWidgetComponent.js +18 -0
  76. package/lib/esm/components/TreeWidgetComponent.js.map +1 -0
  77. package/lib/esm/components/TreeWidgetComponent.scss +64 -0
  78. package/lib/esm/components/TreeWidgetControl.d.ts +25 -0
  79. package/lib/esm/components/TreeWidgetControl.js +57 -0
  80. package/lib/esm/components/TreeWidgetControl.js.map +1 -0
  81. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +19 -0
  82. package/lib/esm/components/TreeWidgetUiItemsProvider.js +74 -0
  83. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -0
  84. package/lib/esm/components/header/TreeHeader.d.ts +14 -0
  85. package/lib/esm/components/header/TreeHeader.js +20 -0
  86. package/lib/esm/components/header/TreeHeader.js.map +1 -0
  87. package/lib/esm/components/header/TreeHeader.scss +19 -0
  88. package/lib/esm/components/rulesets/ClassificationSystems.json +122 -0
  89. package/lib/esm/components/search-bar/Popup.d.ts +50 -0
  90. package/lib/esm/components/search-bar/Popup.js +220 -0
  91. package/lib/esm/components/search-bar/Popup.js.map +1 -0
  92. package/lib/esm/components/search-bar/Popup.scss +316 -0
  93. package/lib/esm/components/search-bar/SearchBar.d.ts +53 -0
  94. package/lib/esm/components/search-bar/SearchBar.js +71 -0
  95. package/lib/esm/components/search-bar/SearchBar.js.map +1 -0
  96. package/lib/esm/components/search-bar/SearchBar.scss +110 -0
  97. package/lib/esm/components/search-bar/SearchBox.d.ts +76 -0
  98. package/lib/esm/components/search-bar/SearchBox.js +158 -0
  99. package/lib/esm/components/search-bar/SearchBox.js.map +1 -0
  100. package/lib/esm/components/search-bar/SearchBox.scss +91 -0
  101. package/lib/esm/components/trees/CategoriesTree.d.ts +9 -0
  102. package/lib/esm/components/trees/CategoriesTree.js +53 -0
  103. package/lib/esm/components/trees/CategoriesTree.js.map +1 -0
  104. package/lib/esm/components/trees/CategoriesTree.scss +13 -0
  105. package/lib/esm/components/trees/ClassificationsTree.d.ts +6 -0
  106. package/lib/esm/components/trees/ClassificationsTree.js +17 -0
  107. package/lib/esm/components/trees/ClassificationsTree.js.map +1 -0
  108. package/lib/esm/components/trees/ModelsTree.d.ts +10 -0
  109. package/lib/esm/components/trees/ModelsTree.js +112 -0
  110. package/lib/esm/components/trees/ModelsTree.js.map +1 -0
  111. package/lib/esm/components/trees/ModelsTree.scss +14 -0
  112. package/lib/esm/components/trees/SpatialTree.d.ts +3 -0
  113. package/lib/esm/components/trees/SpatialTree.js +18 -0
  114. package/lib/esm/components/trees/SpatialTree.js.map +1 -0
  115. package/lib/esm/components/trees/TreeWithRuleset.d.ts +35 -0
  116. package/lib/esm/components/trees/TreeWithRuleset.js +83 -0
  117. package/lib/esm/components/trees/TreeWithRuleset.js.map +1 -0
  118. package/lib/esm/components/trees/TreeWithRulesetTree.scss +17 -0
  119. package/lib/esm/components/trees/index.d.ts +6 -0
  120. package/lib/esm/components/trees/index.js +10 -0
  121. package/lib/esm/components/trees/index.js.map +1 -0
  122. package/lib/esm/tree-widget-react.d.ts +7 -0
  123. package/lib/esm/tree-widget-react.js +11 -0
  124. package/lib/esm/tree-widget-react.js.map +1 -0
  125. package/lib/public/locales/en/TreeWidget.json +16 -0
  126. package/package.json +97 -0
@@ -0,0 +1,135 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ModelsTreeComponent = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const appui_react_1 = require("@itwin/appui-react");
29
+ const TreeFilteringState_1 = require("../TreeFilteringState");
30
+ require("./ModelsTree.scss");
31
+ const TreeHeader_1 = require("../header/TreeHeader");
32
+ const core_react_1 = require("@itwin/core-react");
33
+ const ModelsTreeComponent = (props) => {
34
+ const { iModel } = props;
35
+ const [is2dToggleActive, setIs2dToggleActive] = react_1.useState(false);
36
+ const [is3dToggleActive, setIs3dToggleActive] = react_1.useState(false);
37
+ const [icon2dToggle, setIcon2dToggle] = react_1.useState("icon-visibility");
38
+ const [icon3dToggle, setIcon3dToggle] = react_1.useState("icon-visibility");
39
+ const [available2dModels, setAvailable2dModels] = react_1.useState([]);
40
+ const [available3dModels, setAvailable3dModels] = react_1.useState([]);
41
+ const [availableModels, setAvailableModels] = react_1.useState([]);
42
+ const viewport = appui_react_1.useActiveViewport();
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
+ const queryModels = react_1.useCallback(async (vp) => {
52
+ if (vp === undefined)
53
+ return [];
54
+ const queryParams = {
55
+ from: "BisCore.GeometricModel3d",
56
+ wantPrivate: false,
57
+ };
58
+ const modelProps = await iModel.models.queryProps(queryParams);
59
+ return modelProps
60
+ .map(({ id, isPlanProjection }) => ({ id, isPlanProjection }))
61
+ .filter(({ id }) => id);
62
+ }, [iModel]);
63
+ react_1.useEffect(() => {
64
+ queryModels(viewport)
65
+ .then((modelInfos) => {
66
+ setAvailableModels(modelInfos.map(({ id }) => id));
67
+ const { models2d, models3d } = modelInfos.reduce((acc, { id, isPlanProjection }) => {
68
+ isPlanProjection ? acc.models2d.push(id) : acc.models3d.push(id);
69
+ return acc;
70
+ }, { models2d: [], models3d: [] });
71
+ setAvailable2dModels(models2d);
72
+ setAvailable3dModels(models3d);
73
+ })
74
+ .catch((_e) => {
75
+ setAvailableModels([]);
76
+ });
77
+ }, [queryModels, viewport]);
78
+ const invert = react_1.useCallback(async () => {
79
+ if (availableModels.length === 0)
80
+ return;
81
+ const notViewedModels = [];
82
+ const models = [];
83
+ availableModels.forEach((id) => {
84
+ if (viewport === null || viewport === void 0 ? void 0 : viewport.viewsModel(id))
85
+ models.push(id);
86
+ else
87
+ notViewedModels.push(id);
88
+ });
89
+ await (viewport === null || viewport === void 0 ? void 0 : viewport.addViewedModels(notViewedModels));
90
+ viewport === null || viewport === void 0 ? void 0 : viewport.changeModelDisplay(models, false);
91
+ viewport === null || viewport === void 0 ? void 0 : viewport.invalidateScene();
92
+ }, [viewport, availableModels]);
93
+ const hideAll = react_1.useCallback(() => {
94
+ viewport === null || viewport === void 0 ? void 0 : viewport.changeModelDisplay(availableModels, false);
95
+ viewport === null || viewport === void 0 ? void 0 : viewport.invalidateScene();
96
+ }, [viewport, availableModels]);
97
+ const showAll = react_1.useCallback(async () => {
98
+ await (viewport === null || viewport === void 0 ? void 0 : viewport.addViewedModels(availableModels));
99
+ viewport === null || viewport === void 0 ? void 0 : viewport.invalidateScene();
100
+ }, [viewport, availableModels]);
101
+ const viewToggle2D = react_1.useCallback(async () => {
102
+ if (is2dToggleActive) {
103
+ viewport === null || viewport === void 0 ? void 0 : viewport.changeModelDisplay(available2dModels, false);
104
+ setIs2dToggleActive(false);
105
+ setIcon2dToggle("icon-visibility-hide-2");
106
+ }
107
+ else {
108
+ await (viewport === null || viewport === void 0 ? void 0 : viewport.addViewedModels(available2dModels));
109
+ setIs2dToggleActive(true);
110
+ setIcon2dToggle("icon-visibility");
111
+ }
112
+ viewport === null || viewport === void 0 ? void 0 : viewport.invalidateScene();
113
+ }, [is2dToggleActive, viewport, available2dModels]);
114
+ const viewToggle3D = react_1.useCallback(async () => {
115
+ if (is3dToggleActive) {
116
+ viewport === null || viewport === void 0 ? void 0 : viewport.changeModelDisplay(available3dModels, false);
117
+ setIs3dToggleActive(false);
118
+ setIcon3dToggle("icon-visibility-hide-2");
119
+ }
120
+ else {
121
+ await (viewport === null || viewport === void 0 ? void 0 : viewport.addViewedModels(available3dModels));
122
+ setIs3dToggleActive(true);
123
+ setIcon3dToggle("icon-visibility");
124
+ }
125
+ viewport === null || viewport === void 0 ? void 0 : viewport.invalidateScene();
126
+ }, [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 })))))));
133
+ };
134
+ exports.ModelsTreeComponent = ModelsTreeComponent;
135
+ //# sourceMappingURL=ModelsTree.js.map
@@ -0,0 +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,MA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K,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IACpD,KAAK,IAAI,MAAM,IAAI,CAClB,8BAAC,wBAAU,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,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 { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport { ModelsTree, ClassGroupingOption, useActiveViewport } from \"@itwin/appui-react\";\nimport { useTreeFilteringState } from \"../TreeFilteringState\";\nimport \"./ModelsTree.scss\";\nimport {\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"]}
@@ -0,0 +1,14 @@
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
+
6
+ @import "~@itwin/core-react/lib/esm/core-react/index";
7
+
8
+ .tree-widget-models-tree-container {
9
+ flex: 1;
10
+ }
11
+
12
+ .tree-widget-models-tree-toolbar-icon {
13
+ color: $buic-icon-color;
14
+ }
@@ -0,0 +1,3 @@
1
+ import { SpatialContainmentTreeProps } from "@itwin/appui-react";
2
+ export declare const SpatialTreeComponent: (props: Omit<SpatialContainmentTreeProps, "width" | "height">) => JSX.Element;
3
+ //# sourceMappingURL=SpatialTree.d.ts.map
@@ -0,0 +1,41 @@
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.SpatialTreeComponent = void 0;
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ const appui_react_1 = require("@itwin/appui-react");
28
+ const core_react_1 = require("@itwin/core-react");
29
+ const react_1 = __importStar(require("react"));
30
+ const SpatialTreeComponent = (props) => {
31
+ const [height, setHeight] = react_1.useState(0);
32
+ const [width, setWidth] = react_1.useState(0);
33
+ const handleResize = react_1.useCallback((w, h) => {
34
+ setHeight(h);
35
+ setWidth(w);
36
+ }, []);
37
+ const ref = core_react_1.useResizeObserver(handleResize);
38
+ 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 }))));
39
+ };
40
+ exports.SpatialTreeComponent = SpatialTreeComponent;
41
+ //# sourceMappingURL=SpatialTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpatialTree.js","sourceRoot":"","sources":["../../../../src/components/trees/SpatialTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,oDAG4B;AAC5B,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 {\n SpatialContainmentTree,\n SpatialContainmentTreeProps,\n} 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"]}
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ import { Ruleset } from "@itwin/presentation-common";
3
+ import { IPresentationTreeDataProvider } from "@itwin/presentation-components";
4
+ import "./TreeWithRulesetTree.scss";
5
+ import { IModelConnection } from "@itwin/core-frontend";
6
+ export interface ControlledTreeProps {
7
+ iModel: IModelConnection;
8
+ dataProvider: IPresentationTreeDataProvider;
9
+ rulesetId: string;
10
+ pageSize?: number;
11
+ }
12
+ export interface TreeProps {
13
+ imodel: IModelConnection;
14
+ ruleSet: Ruleset;
15
+ dataProvider: IPresentationTreeDataProvider;
16
+ }
17
+ export interface TreeState {
18
+ initialized: false;
19
+ dataProvider?: IPresentationTreeDataProvider;
20
+ }
21
+ export declare abstract class TreeWithRuleset<T extends TreeProps, S extends TreeState> extends React.Component<T, S> {
22
+ private _ruleset?;
23
+ /** @internal */
24
+ componentDidMount(): Promise<void>;
25
+ componentDidUpdate(prevProps: any): Promise<void>;
26
+ componentWillUnmount(): void;
27
+ private removeRuleset;
28
+ private _setRuleSet;
29
+ }
30
+ export declare class SimpleTreeWithRuleset extends TreeWithRuleset<TreeProps, TreeState> {
31
+ constructor(props: TreeProps);
32
+ render(): JSX.Element;
33
+ }
34
+ export declare const ControlledTreeWrapper: React.FC<ControlledTreeProps>;
35
+ //# sourceMappingURL=TreeWithRuleset.d.ts.map
@@ -0,0 +1,108 @@
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.ControlledTreeWrapper = exports.SimpleTreeWithRuleset = exports.TreeWithRuleset = void 0;
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ const react_1 = __importStar(require("react"));
28
+ const presentation_components_1 = require("@itwin/presentation-components");
29
+ const components_react_1 = require("@itwin/components-react");
30
+ const presentation_frontend_1 = require("@itwin/presentation-frontend");
31
+ require("./TreeWithRulesetTree.scss");
32
+ const core_react_1 = require("@itwin/core-react");
33
+ class TreeWithRuleset extends react_1.default.Component {
34
+ constructor() {
35
+ super(...arguments);
36
+ this._setRuleSet = async () => {
37
+ return presentation_frontend_1.Presentation.presentation
38
+ .rulesets()
39
+ .add(this.props.ruleSet) // tslint:disable-line:no-floating-promises
40
+ .then((ruleset) => {
41
+ this._ruleset = ruleset;
42
+ const dataProvider = this.props.dataProvider;
43
+ this.setState({ dataProvider });
44
+ });
45
+ };
46
+ }
47
+ /** @internal */
48
+ async componentDidMount() {
49
+ await this._setRuleSet();
50
+ }
51
+ async componentDidUpdate(prevProps) {
52
+ if (this.props.ruleSet !== prevProps.ruleSet) {
53
+ this.removeRuleset();
54
+ await this._setRuleSet();
55
+ }
56
+ }
57
+ componentWillUnmount() {
58
+ this.removeRuleset();
59
+ }
60
+ removeRuleset() {
61
+ if (this._ruleset)
62
+ presentation_frontend_1.Presentation.presentation.rulesets().remove(this._ruleset); // tslint:disable-line:no-floating-promises
63
+ }
64
+ }
65
+ exports.TreeWithRuleset = TreeWithRuleset;
66
+ class SimpleTreeWithRuleset extends TreeWithRuleset {
67
+ constructor(props) {
68
+ super(props);
69
+ this.state = {
70
+ initialized: false,
71
+ };
72
+ }
73
+ render() {
74
+ const dataProvider = this.state
75
+ .dataProvider;
76
+ if (!dataProvider)
77
+ return react_1.default.createElement("div", null);
78
+ else {
79
+ return (react_1.default.createElement("div", { className: "spatial-tree" },
80
+ react_1.default.createElement(exports.ControlledTreeWrapper, { rulesetId: this.props.ruleSet.id, iModel: this.props.imodel, dataProvider: dataProvider, pageSize: dataProvider.pagingSize })));
81
+ }
82
+ }
83
+ }
84
+ exports.SimpleTreeWithRuleset = SimpleTreeWithRuleset;
85
+ // tslint:disable-next-line:variable-name naming-convention
86
+ const ControlledTreeWrapper = (props) => {
87
+ const { nodeLoader } = presentation_components_1.usePresentationTreeNodeLoader({
88
+ imodel: props.iModel,
89
+ ruleset: props.rulesetId,
90
+ pagingSize: props.pageSize || 20,
91
+ });
92
+ const modelSource = nodeLoader.modelSource;
93
+ const unifiedSelectionEventHandler = presentation_components_1.useUnifiedSelectionTreeEventHandler({
94
+ nodeLoader,
95
+ collapsedChildrenDisposalEnabled: true,
96
+ });
97
+ const [height, setHeight] = react_1.useState(0);
98
+ const [width, setWidth] = react_1.useState(0);
99
+ const handleResize = react_1.useCallback((w, h) => {
100
+ setHeight(h);
101
+ setWidth(w);
102
+ }, []);
103
+ const ref = core_react_1.useResizeObserver(handleResize);
104
+ const treeModel = components_react_1.useTreeModel(modelSource);
105
+ return (react_1.default.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (react_1.default.createElement(components_react_1.ControlledTree, { model: treeModel, nodeLoader: nodeLoader, eventsHandler: unifiedSelectionEventHandler, selectionMode: components_react_1.SelectionMode.Extended, width: width, height: height }))));
106
+ };
107
+ exports.ControlledTreeWrapper = ControlledTreeWrapper;
108
+ //# sourceMappingURL=TreeWithRuleset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeWithRuleset.js","sourceRoot":"","sources":["../../../../src/components/trees/TreeWithRuleset.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+CAAqD;AAErD,4EAKwC;AACxC,8DAIiC;AACjC,wEAA4D;AAC5D,sCAAoC;AAEpC,kDAAsD;AAoBtD,MAAsB,eAGlB,SAAQ,eAAK,CAAC,SAAe;IAHjC;;QA0BU,gBAAW,GAAG,KAAK,IAAI,EAAE;YAC/B,OAAO,oCAAY,CAAC,YAAY;iBAC7B,QAAQ,EAAE;iBACV,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,2CAA2C;iBACnE,IAAI,CAAC,CAAC,OAA0B,EAAE,EAAE;gBACnC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;gBACxB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;gBAC7C,IAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;YAClC,CAAC,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------------------------------------------------\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, { useCallback, useState } from \"react\";\nimport { RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\nimport {\n IPresentationTreeDataProvider,\n usePresentationTreeNodeLoader,\n useUnifiedSelectionTreeEventHandler,\n PresentationTreeDataProvider,\n} from \"@itwin/presentation-components\";\nimport {\n SelectionMode,\n ControlledTree,\n useTreeModel,\n} from \"@itwin/components-react\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport \"./TreeWithRulesetTree.scss\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { useResizeObserver } from \"@itwin/core-react\";\n\nexport interface ControlledTreeProps {\n iModel: IModelConnection;\n dataProvider: IPresentationTreeDataProvider;\n rulesetId: string;\n pageSize?: number;\n}\n\nexport interface TreeProps {\n imodel: IModelConnection;\n ruleSet: Ruleset;\n dataProvider: IPresentationTreeDataProvider;\n}\n\nexport interface TreeState {\n initialized: false;\n dataProvider?: IPresentationTreeDataProvider;\n}\n\nexport abstract class TreeWithRuleset<\n T extends TreeProps,\n S extends TreeState\n > extends React.Component<T, S> {\n private _ruleset?: RegisteredRuleset;\n /** @internal */\n public async componentDidMount() {\n await this._setRuleSet();\n }\n\n public async componentDidUpdate(prevProps: any) {\n if (this.props.ruleSet !== prevProps.ruleSet) {\n this.removeRuleset();\n await this._setRuleSet();\n }\n }\n\n public componentWillUnmount() {\n this.removeRuleset();\n }\n\n private removeRuleset() {\n if (this._ruleset)\n Presentation.presentation.rulesets().remove(this._ruleset); // tslint:disable-line:no-floating-promises\n }\n\n private _setRuleSet = async () => {\n return Presentation.presentation\n .rulesets()\n .add(this.props.ruleSet) // tslint:disable-line:no-floating-promises\n .then((ruleset: RegisteredRuleset) => {\n this._ruleset = ruleset;\n const dataProvider = this.props.dataProvider;\n this.setState({ dataProvider });\n });\n };\n}\n\nexport class SimpleTreeWithRuleset extends TreeWithRuleset<\n TreeProps,\n TreeState\n> {\n constructor(props: TreeProps) {\n super(props);\n this.state = {\n initialized: false,\n };\n }\n\n public render() {\n const dataProvider = this.state\n .dataProvider as PresentationTreeDataProvider;\n if (!dataProvider) return <div />;\n else {\n return (\n <div className=\"spatial-tree\">\n <ControlledTreeWrapper\n rulesetId={this.props.ruleSet.id}\n iModel={this.props.imodel}\n dataProvider={dataProvider}\n pageSize={(dataProvider as PresentationTreeDataProvider).pagingSize}\n />\n </div>\n );\n }\n }\n}\n\n// tslint:disable-next-line:variable-name naming-convention\nexport const ControlledTreeWrapper: React.FC<ControlledTreeProps> = (\n props: ControlledTreeProps\n) => {\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: props.rulesetId,\n pagingSize: props.pageSize || 20,\n });\n\n const modelSource = nodeLoader.modelSource;\n const unifiedSelectionEventHandler = useUnifiedSelectionTreeEventHandler({\n nodeLoader,\n collapsedChildrenDisposalEnabled: true,\n });\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 treeModel = useTreeModel(modelSource);\n\n return (\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }}>\n {width && height && (\n <ControlledTree\n model={treeModel}\n nodeLoader={nodeLoader}\n eventsHandler={unifiedSelectionEventHandler}\n selectionMode={SelectionMode.Extended}\n width={width}\n height={height}\n />\n )}\n </div>\n );\n};\n\n"]}
@@ -0,0 +1,17 @@
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 "~@itwin/core-react/lib/esm/core-react/index";
6
+ .spatial-tree {
7
+ display: flex;
8
+ flex-direction: column;
9
+ height: 100%;
10
+ }
11
+ .components-tree-node-content {
12
+ height: $uicore-l;
13
+ line-height: $uicore-font-size-small;
14
+ display: flex;
15
+ flex-direction: column;
16
+ justify-content: center;
17
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./ModelsTree";
2
+ export * from "./CategoriesTree";
3
+ export * from "./SpatialTree";
4
+ export * from "./ClassificationsTree";
5
+ export * from "./TreeWithRuleset";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,22 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ 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
+ __exportStar(require("./ModelsTree"), exports);
18
+ __exportStar(require("./CategoriesTree"), exports);
19
+ __exportStar(require("./SpatialTree"), exports);
20
+ __exportStar(require("./ClassificationsTree"), exports);
21
+ __exportStar(require("./TreeWithRuleset"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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\";"]}
@@ -0,0 +1,7 @@
1
+ export * from "./TreeWidget";
2
+ export * from "./components/TreeWidgetControl";
3
+ export * from "./components/TreeWidgetComponent";
4
+ export * from "./components/header/TreeHeader";
5
+ export * from "./components/trees";
6
+ export * from "./components/TreeWidgetUiItemsProvider";
7
+ //# sourceMappingURL=tree-widget-react.d.ts.map
@@ -0,0 +1,23 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./TreeWidget"), exports);
18
+ __exportStar(require("./components/TreeWidgetControl"), exports);
19
+ __exportStar(require("./components/TreeWidgetComponent"), exports);
20
+ __exportStar(require("./components/header/TreeHeader"), exports);
21
+ __exportStar(require("./components/trees"), exports);
22
+ __exportStar(require("./components/TreeWidgetUiItemsProvider"), exports);
23
+ //# sourceMappingURL=tree-widget-react.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,27 @@
1
+ import { Localization } from "@itwin/core-common";
2
+ import { LocalizationOptions } from "@itwin/core-i18n";
3
+ /**
4
+ * Entry point for static initialization required by various components used in the package.
5
+ * @public
6
+ */
7
+ export declare class TreeWidget {
8
+ private static _i18n?;
9
+ private static _initialized?;
10
+ /**
11
+ * Called by IModelApp to initialize the Tree Widget
12
+ * @param i18n - The internationalization service created by the IModelApp.
13
+ */
14
+ static initialize(i18n?: Localization): Promise<void>;
15
+ /** Unregisters the TreeWidget internationalization service namespace */
16
+ static terminate(): void;
17
+ /** The internationalization service created by the IModelApp. */
18
+ static get i18n(): Localization;
19
+ /** The internationalization service namespace. */
20
+ static get i18nNamespace(): string;
21
+ static get packageName(): string;
22
+ /** Calls i18n.translateWithNamespace with the "TreeWidget" namespace. Do NOT include the namespace in the key.
23
+ */
24
+ static translate(key: string | string[], options?: LocalizationOptions): string;
25
+ static loggerCategory(obj: any): string;
26
+ }
27
+ //# sourceMappingURL=TreeWidget.d.ts.map
@@ -0,0 +1,53 @@
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 { UiError, getClassName } from "@itwin/appui-abstract";
6
+ import { IModelApp } from "@itwin/core-frontend";
7
+ /**
8
+ * Entry point for static initialization required by various components used in the package.
9
+ * @public
10
+ */
11
+ export class TreeWidget {
12
+ /**
13
+ * Called by IModelApp to initialize the Tree Widget
14
+ * @param i18n - The internationalization service created by the IModelApp.
15
+ */
16
+ static async initialize(i18n) {
17
+ if (this._initialized)
18
+ return;
19
+ this._initialized = true;
20
+ TreeWidget._i18n = i18n !== null && i18n !== void 0 ? i18n : IModelApp.localization;
21
+ return TreeWidget._i18n.registerNamespace(TreeWidget.i18nNamespace);
22
+ }
23
+ /** Unregisters the TreeWidget internationalization service namespace */
24
+ static terminate() {
25
+ if (TreeWidget._i18n)
26
+ TreeWidget._i18n.unregisterNamespace(TreeWidget.i18nNamespace);
27
+ TreeWidget._i18n = undefined;
28
+ }
29
+ /** The internationalization service created by the IModelApp. */
30
+ static get i18n() {
31
+ if (!TreeWidget._i18n)
32
+ throw new UiError(TreeWidget.loggerCategory(this), "TreeWidget not initialized");
33
+ return TreeWidget._i18n;
34
+ }
35
+ /** The internationalization service namespace. */
36
+ static get i18nNamespace() {
37
+ return "TreeWidget";
38
+ }
39
+ static get packageName() {
40
+ return "tree-widget-react";
41
+ }
42
+ /** Calls i18n.translateWithNamespace with the "TreeWidget" namespace. Do NOT include the namespace in the key.
43
+ */
44
+ static translate(key, options) {
45
+ return TreeWidget.i18n.getLocalizedStringWithNamespace(TreeWidget.i18nNamespace, key, options);
46
+ }
47
+ static loggerCategory(obj) {
48
+ const className = getClassName(obj);
49
+ const category = TreeWidget.packageName + (className ? `.${className}` : "");
50
+ return category;
51
+ }
52
+ }
53
+ //# sourceMappingURL=TreeWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeWidget.js","sourceRoot":"","sources":["../../src/TreeWidget.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,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CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC9D,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","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 { UiError, getClassName } from \"@itwin/appui-abstract\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { Localization } from \"@itwin/core-common\";\nimport { LocalizationOptions } from \"@itwin/core-i18n\";\n\n/**\n * Entry point for static initialization required by various components used in the package.\n * @public\n */\nexport class TreeWidget {\n private static _i18n?: Localization;\n private static _initialized?: boolean;\n\n /**\n * Called by IModelApp to initialize the Tree Widget\n * @param i18n - The internationalization service created by the IModelApp.\n */\n public static async initialize(i18n?: Localization): Promise<void> {\n if (this._initialized) return;\n\n this._initialized = true;\n TreeWidget._i18n = i18n ?? IModelApp.localization;\n\n return TreeWidget._i18n.registerNamespace(TreeWidget.i18nNamespace);\n }\n\n /** Unregisters the TreeWidget internationalization service namespace */\n public static terminate() {\n if (TreeWidget._i18n)\n TreeWidget._i18n.unregisterNamespace(TreeWidget.i18nNamespace);\n TreeWidget._i18n = undefined;\n }\n\n /** The internationalization service created by the IModelApp. */\n public static get i18n(): Localization {\n if (!TreeWidget._i18n)\n throw new UiError(\n TreeWidget.loggerCategory(this),\n \"TreeWidget not initialized\"\n );\n return TreeWidget._i18n;\n }\n\n /** The internationalization service namespace. */\n public static get i18nNamespace(): string {\n return \"TreeWidget\";\n }\n\n public static get packageName(): string {\n return \"tree-widget-react\";\n }\n\n /** Calls i18n.translateWithNamespace with the \"TreeWidget\" namespace. Do NOT include the namespace in the key.\n */\n public static translate(\n key: string | string[],\n options?: LocalizationOptions\n ): string {\n return TreeWidget.i18n.getLocalizedStringWithNamespace(\n TreeWidget.i18nNamespace,\n key,\n options\n );\n }\n\n public static loggerCategory(obj: any): string {\n const className = getClassName(obj);\n const category =\n TreeWidget.packageName + (className ? `.${className}` : \"\");\n return category;\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import { CommonProps } from "@itwin/core-react";
3
+ import "./IconButton.scss";
4
+ /** Properties for [[IconButton]] component */
5
+ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {
6
+ /** Icon name */
7
+ icon: string;
8
+ /** A function to be run when the element is clicked */
9
+ onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
10
+ label?: string;
11
+ }
12
+ /** Generic icon button component */
13
+ export declare function IconButton({ className, icon, onClick, label, ...otherProps }: IconButtonProps): JSX.Element;
14
+ //# sourceMappingURL=IconButton.d.ts.map
@@ -0,0 +1,16 @@
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 * as React from "react";
6
+ import classnames from "classnames";
7
+ import "./IconButton.scss";
8
+ /** Generic icon button component */
9
+ export function IconButton({ className, icon, onClick, label, ...otherProps }) {
10
+ return (React.createElement(React.Fragment, null,
11
+ label &&
12
+ React.createElement("span", { className: classnames("tree-widget-icon-label", className) }, label),
13
+ React.createElement("button", { ...otherProps, className: classnames("tree-widget-icon-button", className), onClick: onClick },
14
+ React.createElement("span", { className: classnames("icon", icon) }))));
15
+ }
16
+ //# sourceMappingURL=IconButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../../../src/components/IconButton.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,mBAAmB,CAAC;AAc3B,oCAAoC;AACpC,MAAM,UAAU,UAAU,CAAC,EACzB,SAAS,EACT,IAAI,EACJ,OAAO,EACP,KAAK,EACL,GAAG,UAAU,EACG;IAChB,OAAO,CACL;QACG,KAAK;YACJ,8BAAM,SAAS,EAAE,UAAU,CAAC,wBAAwB,EAAE,SAAS,CAAC,IAC7D,KAAK,CACD;QAET,mCACM,UAAU,EACd,SAAS,EAAE,UAAU,CAAC,yBAAyB,EAAE,SAAS,CAAC,EAC3D,OAAO,EAAE,OAAO;YAEhB,8BAAM,SAAS,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,GAAI,CACtC,CACR,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { CommonProps } from \"@itwin/core-react\";\nimport \"./IconButton.scss\";\n\n/** Properties for [[IconButton]] component */\nexport interface IconButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n CommonProps {\n /** Icon name */\n icon: string;\n /** A function to be run when the element is clicked */\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n //** An optional text label to display to the left of the button */\n label?: string;\n}\n\n/** Generic icon button component */\nexport function IconButton({\n className,\n icon,\n onClick,\n label,\n ...otherProps\n}: IconButtonProps) {\n return (\n <>\n {label &&\n <span className={classnames(\"tree-widget-icon-label\", className)}>\n {label}\n </span>\n }\n <button\n {...otherProps}\n className={classnames(\"tree-widget-icon-button\", className)}\n onClick={onClick}\n >\n <span className={classnames(\"icon\", icon)} />\n </button>\n </>\n );\n}\n"]}