@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,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,83 @@
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 React, { useCallback, useState } from "react";
6
+ import { usePresentationTreeNodeLoader, useUnifiedSelectionTreeEventHandler, } from "@itwin/presentation-components";
7
+ import { SelectionMode, ControlledTree, useTreeModel, } from "@itwin/components-react";
8
+ import { Presentation } from "@itwin/presentation-frontend";
9
+ import "./TreeWithRulesetTree.scss";
10
+ import { useResizeObserver } from "@itwin/core-react";
11
+ export class TreeWithRuleset extends React.Component {
12
+ constructor() {
13
+ super(...arguments);
14
+ this._setRuleSet = async () => {
15
+ return Presentation.presentation
16
+ .rulesets()
17
+ .add(this.props.ruleSet) // tslint:disable-line:no-floating-promises
18
+ .then((ruleset) => {
19
+ this._ruleset = ruleset;
20
+ const dataProvider = this.props.dataProvider;
21
+ this.setState({ dataProvider });
22
+ });
23
+ };
24
+ }
25
+ /** @internal */
26
+ async componentDidMount() {
27
+ await this._setRuleSet();
28
+ }
29
+ async componentDidUpdate(prevProps) {
30
+ if (this.props.ruleSet !== prevProps.ruleSet) {
31
+ this.removeRuleset();
32
+ await this._setRuleSet();
33
+ }
34
+ }
35
+ componentWillUnmount() {
36
+ this.removeRuleset();
37
+ }
38
+ removeRuleset() {
39
+ if (this._ruleset)
40
+ Presentation.presentation.rulesets().remove(this._ruleset); // tslint:disable-line:no-floating-promises
41
+ }
42
+ }
43
+ export class SimpleTreeWithRuleset extends TreeWithRuleset {
44
+ constructor(props) {
45
+ super(props);
46
+ this.state = {
47
+ initialized: false,
48
+ };
49
+ }
50
+ render() {
51
+ const dataProvider = this.state
52
+ .dataProvider;
53
+ if (!dataProvider)
54
+ return React.createElement("div", null);
55
+ else {
56
+ return (React.createElement("div", { className: "spatial-tree" },
57
+ React.createElement(ControlledTreeWrapper, { rulesetId: this.props.ruleSet.id, iModel: this.props.imodel, dataProvider: dataProvider, pageSize: dataProvider.pagingSize })));
58
+ }
59
+ }
60
+ }
61
+ // tslint:disable-next-line:variable-name naming-convention
62
+ export const ControlledTreeWrapper = (props) => {
63
+ const { nodeLoader } = usePresentationTreeNodeLoader({
64
+ imodel: props.iModel,
65
+ ruleset: props.rulesetId,
66
+ pagingSize: props.pageSize || 20,
67
+ });
68
+ const modelSource = nodeLoader.modelSource;
69
+ const unifiedSelectionEventHandler = useUnifiedSelectionTreeEventHandler({
70
+ nodeLoader,
71
+ collapsedChildrenDisposalEnabled: true,
72
+ });
73
+ const [height, setHeight] = useState(0);
74
+ const [width, setWidth] = useState(0);
75
+ const handleResize = useCallback((w, h) => {
76
+ setHeight(h);
77
+ setWidth(w);
78
+ }, []);
79
+ const ref = useResizeObserver(handleResize);
80
+ const treeModel = useTreeModel(modelSource);
81
+ return (React.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (React.createElement(ControlledTree, { model: treeModel, nodeLoader: nodeLoader, eventsHandler: unifiedSelectionEventHandler, selectionMode: SelectionMode.Extended, width: width, height: height }))));
82
+ };
83
+ //# sourceMappingURL=TreeWithRuleset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeWithRuleset.js","sourceRoot":"","sources":["../../../../src/components/trees/TreeWithRuleset.tsx"],"names":[],"mappings":"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","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, { 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,10 @@
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
+ export * from "./ModelsTree";
6
+ export * from "./CategoriesTree";
7
+ export * from "./SpatialTree";
8
+ export * from "./ClassificationsTree";
9
+ export * from "./TreeWithRuleset";
10
+ //# 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,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nexport * from \"./ModelsTree\";\nexport * from \"./CategoriesTree\";\nexport * from \"./SpatialTree\";\nexport * from \"./ClassificationsTree\";\nexport * from \"./TreeWithRuleset\";"]}
@@ -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,11 @@
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
+ export * from "./TreeWidget";
6
+ export * from "./components/TreeWidgetControl";
7
+ export * from "./components/TreeWidgetComponent";
8
+ export * from "./components/header/TreeHeader";
9
+ export * from "./components/trees";
10
+ export * from "./components/TreeWidgetUiItemsProvider";
11
+ //# 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,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wCAAwC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./TreeWidget\";\nexport * from \"./components/TreeWidgetControl\";\nexport * from \"./components/TreeWidgetComponent\";\nexport * from \"./components/header/TreeHeader\";\nexport * from \"./components/trees\";\nexport * from \"./components/TreeWidgetUiItemsProvider\";\n"]}
@@ -0,0 +1,16 @@
1
+ {
2
+ "searchForSomething": "Search for something",
3
+ "search": "Search...",
4
+ "showAll": "Show All",
5
+ "hideAll": "Hide All",
6
+ "invert": "Invert",
7
+ "toggle2DViews": "Toggle 2D Views",
8
+ "toggle3DViews": "Toggle 3D Views",
9
+ "label2D": "2D",
10
+ "label3D": "3D",
11
+ "learnMore": "Learn more",
12
+ "modeltree": "Model Tree",
13
+ "categories": "Categories",
14
+ "containment": "Spatial Containment",
15
+ "treeview": "Tree View"
16
+ }
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@itwin/tree-widget-react",
3
+ "version": "0.1.1",
4
+ "description": "Tree Widget React",
5
+ "keywords": [
6
+ "Bentley",
7
+ "iModel Tree Widget",
8
+ "iTwin.js"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/itwin/viewer-components-react/tree/master/packages/itwin/tree-widget"
13
+ },
14
+ "license": "MIT",
15
+ "author": {
16
+ "name": "Bentley Systems, Inc.",
17
+ "url": "http://www.bentley.com"
18
+ },
19
+ "main": "lib/cjs/tree-widget-react.js",
20
+ "module": "lib/esm/tree-widget-react.js",
21
+ "typings": "lib/cjs/tree-widget-react",
22
+ "dependencies": {
23
+ "classnames": "^2.3.1",
24
+ "i18next": "^10.2.2",
25
+ "react-redux": "^7.2.0",
26
+ "redux": "^4.0.3"
27
+ },
28
+ "devDependencies": {
29
+ "@bentley/itwin-client": "rc",
30
+ "@itwin/appui-abstract": "rc",
31
+ "@itwin/appui-layout-react": "rc",
32
+ "@itwin/appui-react": "rc",
33
+ "@itwin/build-tools": "rc",
34
+ "@itwin/components-react": "rc",
35
+ "@itwin/core-bentley": "rc",
36
+ "@itwin/core-common": "rc",
37
+ "@itwin/core-frontend": "rc",
38
+ "@itwin/core-geometry": "rc",
39
+ "@itwin/core-i18n": "rc",
40
+ "@itwin/core-markup": "rc",
41
+ "@itwin/core-orbitgt": "rc",
42
+ "@itwin/core-quantity": "rc",
43
+ "@itwin/core-react": "rc",
44
+ "@itwin/presentation-common": "rc",
45
+ "@itwin/presentation-components": "rc",
46
+ "@itwin/presentation-frontend": "rc",
47
+ "@itwin/webgl-compatibility": "rc",
48
+ "@types/i18next": "^8.4.2",
49
+ "@types/react": "^17.0.19",
50
+ "@types/react-dom": "^17.0.9",
51
+ "@types/react-redux": "^7.0.1",
52
+ "cpx": "^1.5.0",
53
+ "react": "^17.0.2",
54
+ "react-dom": "^17.0.2",
55
+ "rimraf": "^3.0.2",
56
+ "tslint": "^5.11.0",
57
+ "typescript": "~4.3.0"
58
+ },
59
+ "peerDependencies": {
60
+ "@bentley/itwin-client": "rc",
61
+ "@itwin/appui-abstract": "rc",
62
+ "@itwin/appui-layout-react": "rc",
63
+ "@itwin/appui-react": "rc",
64
+ "@itwin/components-react": "rc",
65
+ "@itwin/core-bentley": "rc",
66
+ "@itwin/core-common": "rc",
67
+ "@itwin/core-frontend": "rc",
68
+ "@itwin/core-geometry": "rc",
69
+ "@itwin/core-i18n": "rc",
70
+ "@itwin/core-markup": "rc",
71
+ "@itwin/core-orbitgt": "rc",
72
+ "@itwin/core-quantity": "rc",
73
+ "@itwin/core-react": "rc",
74
+ "@itwin/presentation-common": "rc",
75
+ "@itwin/presentation-components": "rc",
76
+ "@itwin/presentation-frontend": "rc",
77
+ "@itwin/webgl-compatibility": "rc",
78
+ "react": "^17.0.2",
79
+ "react-dom": "^17.0.2"
80
+ },
81
+ "scripts": {
82
+ "build": "npm run -s dual-build && npm run -s copy:assets",
83
+ "dual-build": "npm run -s build:cjs && npm run -s build:esm",
84
+ "build:cjs": "tsc 1>&2 --outDir lib/cjs",
85
+ "build:esm": "tsc 1>&2 --module ES2020 --outDir lib/esm",
86
+ "copy:assets": "npm run -s copy:public && npm run -s copy:cjs && npm run -s copy:esm",
87
+ "copy:public": "cpx \"./public/**/*\" ./lib/public",
88
+ "copy:cjs": "cpx \"./src/**/*.scss\" ./lib/cjs",
89
+ "copy:esm": "cpx \"./src/**/*.scss\" ./lib/esm",
90
+ "cover": "",
91
+ "lint": "",
92
+ "pseudolocalize": "betools pseudolocalize --englishDir ./public/locales/en --out ./lib/public/locales/en-PSEUDO",
93
+ "test": "",
94
+ "clean": "rimraf lib .rush/temp/package-deps*.json",
95
+ "rebuild": "npm run clean && npm run build"
96
+ }
97
+ }