@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.
- package/LICENSE.md +9 -0
- package/README.md +32 -0
- package/lib/cjs/TreeWidget.d.ts +27 -0
- package/lib/cjs/TreeWidget.js +57 -0
- package/lib/cjs/TreeWidget.js.map +1 -0
- package/lib/cjs/components/IconButton.d.ts +14 -0
- package/lib/cjs/components/IconButton.js +42 -0
- package/lib/cjs/components/IconButton.js.map +1 -0
- package/lib/cjs/components/IconButton.scss +73 -0
- package/lib/cjs/components/TreeFilteringState.d.ts +16 -0
- package/lib/cjs/components/TreeFilteringState.js +67 -0
- package/lib/cjs/components/TreeFilteringState.js.map +1 -0
- package/lib/cjs/components/TreeWidgetComponent.d.ts +8 -0
- package/lib/cjs/components/TreeWidgetComponent.js +41 -0
- package/lib/cjs/components/TreeWidgetComponent.js.map +1 -0
- package/lib/cjs/components/TreeWidgetComponent.scss +64 -0
- package/lib/cjs/components/TreeWidgetControl.d.ts +25 -0
- package/lib/cjs/components/TreeWidgetControl.js +64 -0
- package/lib/cjs/components/TreeWidgetControl.js.map +1 -0
- package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +19 -0
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js +81 -0
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -0
- package/lib/cjs/components/header/TreeHeader.d.ts +14 -0
- package/lib/cjs/components/header/TreeHeader.js +43 -0
- package/lib/cjs/components/header/TreeHeader.js.map +1 -0
- package/lib/cjs/components/header/TreeHeader.scss +19 -0
- package/lib/cjs/components/rulesets/ClassificationSystems.json +122 -0
- package/lib/cjs/components/search-bar/Popup.d.ts +50 -0
- package/lib/cjs/components/search-bar/Popup.js +246 -0
- package/lib/cjs/components/search-bar/Popup.js.map +1 -0
- package/lib/cjs/components/search-bar/Popup.scss +316 -0
- package/lib/cjs/components/search-bar/SearchBar.d.ts +53 -0
- package/lib/cjs/components/search-bar/SearchBar.js +97 -0
- package/lib/cjs/components/search-bar/SearchBar.js.map +1 -0
- package/lib/cjs/components/search-bar/SearchBar.scss +110 -0
- package/lib/cjs/components/search-bar/SearchBox.d.ts +76 -0
- package/lib/cjs/components/search-bar/SearchBox.js +184 -0
- package/lib/cjs/components/search-bar/SearchBox.js.map +1 -0
- package/lib/cjs/components/search-bar/SearchBox.scss +91 -0
- package/lib/cjs/components/trees/CategoriesTree.d.ts +9 -0
- package/lib/cjs/components/trees/CategoriesTree.js +76 -0
- package/lib/cjs/components/trees/CategoriesTree.js.map +1 -0
- package/lib/cjs/components/trees/CategoriesTree.scss +13 -0
- package/lib/cjs/components/trees/ClassificationsTree.d.ts +6 -0
- package/lib/cjs/components/trees/ClassificationsTree.js +43 -0
- package/lib/cjs/components/trees/ClassificationsTree.js.map +1 -0
- package/lib/cjs/components/trees/ModelsTree.d.ts +10 -0
- package/lib/cjs/components/trees/ModelsTree.js +135 -0
- package/lib/cjs/components/trees/ModelsTree.js.map +1 -0
- package/lib/cjs/components/trees/ModelsTree.scss +14 -0
- package/lib/cjs/components/trees/SpatialTree.d.ts +3 -0
- package/lib/cjs/components/trees/SpatialTree.js +41 -0
- package/lib/cjs/components/trees/SpatialTree.js.map +1 -0
- package/lib/cjs/components/trees/TreeWithRuleset.d.ts +35 -0
- package/lib/cjs/components/trees/TreeWithRuleset.js +108 -0
- package/lib/cjs/components/trees/TreeWithRuleset.js.map +1 -0
- package/lib/cjs/components/trees/TreeWithRulesetTree.scss +17 -0
- package/lib/cjs/components/trees/index.d.ts +6 -0
- package/lib/cjs/components/trees/index.js +22 -0
- package/lib/cjs/components/trees/index.js.map +1 -0
- package/lib/cjs/tree-widget-react.d.ts +7 -0
- package/lib/cjs/tree-widget-react.js +23 -0
- package/lib/cjs/tree-widget-react.js.map +1 -0
- package/lib/esm/TreeWidget.d.ts +27 -0
- package/lib/esm/TreeWidget.js +53 -0
- package/lib/esm/TreeWidget.js.map +1 -0
- package/lib/esm/components/IconButton.d.ts +14 -0
- package/lib/esm/components/IconButton.js +16 -0
- package/lib/esm/components/IconButton.js.map +1 -0
- package/lib/esm/components/IconButton.scss +73 -0
- package/lib/esm/components/TreeFilteringState.d.ts +16 -0
- package/lib/esm/components/TreeFilteringState.js +44 -0
- package/lib/esm/components/TreeFilteringState.js.map +1 -0
- package/lib/esm/components/TreeWidgetComponent.d.ts +8 -0
- package/lib/esm/components/TreeWidgetComponent.js +18 -0
- package/lib/esm/components/TreeWidgetComponent.js.map +1 -0
- package/lib/esm/components/TreeWidgetComponent.scss +64 -0
- package/lib/esm/components/TreeWidgetControl.d.ts +25 -0
- package/lib/esm/components/TreeWidgetControl.js +57 -0
- package/lib/esm/components/TreeWidgetControl.js.map +1 -0
- package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +19 -0
- package/lib/esm/components/TreeWidgetUiItemsProvider.js +74 -0
- package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -0
- package/lib/esm/components/header/TreeHeader.d.ts +14 -0
- package/lib/esm/components/header/TreeHeader.js +20 -0
- package/lib/esm/components/header/TreeHeader.js.map +1 -0
- package/lib/esm/components/header/TreeHeader.scss +19 -0
- package/lib/esm/components/rulesets/ClassificationSystems.json +122 -0
- package/lib/esm/components/search-bar/Popup.d.ts +50 -0
- package/lib/esm/components/search-bar/Popup.js +220 -0
- package/lib/esm/components/search-bar/Popup.js.map +1 -0
- package/lib/esm/components/search-bar/Popup.scss +316 -0
- package/lib/esm/components/search-bar/SearchBar.d.ts +53 -0
- package/lib/esm/components/search-bar/SearchBar.js +71 -0
- package/lib/esm/components/search-bar/SearchBar.js.map +1 -0
- package/lib/esm/components/search-bar/SearchBar.scss +110 -0
- package/lib/esm/components/search-bar/SearchBox.d.ts +76 -0
- package/lib/esm/components/search-bar/SearchBox.js +158 -0
- package/lib/esm/components/search-bar/SearchBox.js.map +1 -0
- package/lib/esm/components/search-bar/SearchBox.scss +91 -0
- package/lib/esm/components/trees/CategoriesTree.d.ts +9 -0
- package/lib/esm/components/trees/CategoriesTree.js +53 -0
- package/lib/esm/components/trees/CategoriesTree.js.map +1 -0
- package/lib/esm/components/trees/CategoriesTree.scss +13 -0
- package/lib/esm/components/trees/ClassificationsTree.d.ts +6 -0
- package/lib/esm/components/trees/ClassificationsTree.js +17 -0
- package/lib/esm/components/trees/ClassificationsTree.js.map +1 -0
- package/lib/esm/components/trees/ModelsTree.d.ts +10 -0
- package/lib/esm/components/trees/ModelsTree.js +112 -0
- package/lib/esm/components/trees/ModelsTree.js.map +1 -0
- package/lib/esm/components/trees/ModelsTree.scss +14 -0
- package/lib/esm/components/trees/SpatialTree.d.ts +3 -0
- package/lib/esm/components/trees/SpatialTree.js +18 -0
- package/lib/esm/components/trees/SpatialTree.js.map +1 -0
- package/lib/esm/components/trees/TreeWithRuleset.d.ts +35 -0
- package/lib/esm/components/trees/TreeWithRuleset.js +83 -0
- package/lib/esm/components/trees/TreeWithRuleset.js.map +1 -0
- package/lib/esm/components/trees/TreeWithRulesetTree.scss +17 -0
- package/lib/esm/components/trees/index.d.ts +6 -0
- package/lib/esm/components/trees/index.js +10 -0
- package/lib/esm/components/trees/index.js.map +1 -0
- package/lib/esm/tree-widget-react.d.ts +7 -0
- package/lib/esm/tree-widget-react.js +11 -0
- package/lib/esm/tree-widget-react.js.map +1 -0
- package/lib/public/locales/en/TreeWidget.json +16 -0
- package/package.json +97 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** @module SearchBox */
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { CommonProps } from "@itwin/core-react";
|
|
4
|
+
import "./SearchBox.scss";
|
|
5
|
+
export interface SearchBoxProps extends CommonProps {
|
|
6
|
+
/** value to set SearchBox */
|
|
7
|
+
searchText?: string;
|
|
8
|
+
/** placeholder value to show in gray before anything is entered in */
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
/** frequency to poll for changes in value */
|
|
11
|
+
valueChangedDelay?: number;
|
|
12
|
+
/** listens for <Enter> keypress */
|
|
13
|
+
onEnterPressed?: () => void;
|
|
14
|
+
/** listens for <Esc> keypress */
|
|
15
|
+
onEscPressed?: () => void;
|
|
16
|
+
/** listens for onClick event for Clear (x) icon */
|
|
17
|
+
onClear?: () => void;
|
|
18
|
+
/** Search or clear icon click */
|
|
19
|
+
onIconClick?: () => void;
|
|
20
|
+
/** Filtering is cleared after everything's loaded */
|
|
21
|
+
onFilterStart: (newFilter: string) => void;
|
|
22
|
+
/** Filtering is cleared after everything's loaded */
|
|
23
|
+
onFilterClear?: () => void;
|
|
24
|
+
/** Filtering is cleared after everything's loaded */
|
|
25
|
+
onFilterCancel?: () => void;
|
|
26
|
+
/** Tells the component if parent component is still handling the filtering */
|
|
27
|
+
filteringInProgress?: boolean;
|
|
28
|
+
/** Total number of results/entries */
|
|
29
|
+
resultCount: number;
|
|
30
|
+
/** Callback to currently selected result/entry change */
|
|
31
|
+
onSelectedChanged: (index: number) => void;
|
|
32
|
+
/** Specify that the <input> element should automatically get focus */
|
|
33
|
+
autoFocus?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Enumeration of possible component contexts
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare enum InputContext {
|
|
40
|
+
/** Component is ready to filter */
|
|
41
|
+
ReadyToFilter = 0,
|
|
42
|
+
/** Component's parent is currently filtering */
|
|
43
|
+
FilteringInProgress = 1,
|
|
44
|
+
/** Component's parent has finished filtering */
|
|
45
|
+
FilteringFinished = 2,
|
|
46
|
+
/** Component's parent has finished filtering, but ResultSelector(stepping through results) is not enabled */
|
|
47
|
+
FilteringFinishedWithNoStepping = 3
|
|
48
|
+
}
|
|
49
|
+
interface SearchBoxState {
|
|
50
|
+
searchText?: string;
|
|
51
|
+
/** @internal */
|
|
52
|
+
context: InputContext;
|
|
53
|
+
/** Currently selected index */
|
|
54
|
+
selectedIndex: number;
|
|
55
|
+
}
|
|
56
|
+
export declare class SearchBox extends React.PureComponent<SearchBoxProps, SearchBoxState> {
|
|
57
|
+
private _inputElement;
|
|
58
|
+
private _timeoutId;
|
|
59
|
+
constructor(props: SearchBoxProps);
|
|
60
|
+
focus(): void;
|
|
61
|
+
private _trackChange;
|
|
62
|
+
private _handleKeyDown;
|
|
63
|
+
private _handleIconClick;
|
|
64
|
+
private _unsetTimeout;
|
|
65
|
+
componentDidUpdate(prevProps: SearchBoxProps): Promise<void>;
|
|
66
|
+
componentWillUnmount(): void;
|
|
67
|
+
/** @internal */
|
|
68
|
+
static getDerivedStateFromProps(props: SearchBoxProps, state: SearchBoxState): {
|
|
69
|
+
context: InputContext;
|
|
70
|
+
} | null;
|
|
71
|
+
private _onPrevClick;
|
|
72
|
+
private _onNextClick;
|
|
73
|
+
render(): JSX.Element;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=SearchBox.d.ts.map
|
|
@@ -0,0 +1,184 @@
|
|
|
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
|
+
/** @module SearchBox */
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.SearchBox = exports.InputContext = void 0;
|
|
31
|
+
const React = __importStar(require("react"));
|
|
32
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
33
|
+
const IconButton_1 = require("../IconButton");
|
|
34
|
+
require("./SearchBox.scss");
|
|
35
|
+
const TreeWidget_1 = require("../../TreeWidget");
|
|
36
|
+
/**
|
|
37
|
+
* Enumeration of possible component contexts
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
var InputContext;
|
|
41
|
+
(function (InputContext) {
|
|
42
|
+
/** Component is ready to filter */
|
|
43
|
+
InputContext[InputContext["ReadyToFilter"] = 0] = "ReadyToFilter";
|
|
44
|
+
/** Component's parent is currently filtering */
|
|
45
|
+
InputContext[InputContext["FilteringInProgress"] = 1] = "FilteringInProgress";
|
|
46
|
+
/** Component's parent has finished filtering */
|
|
47
|
+
InputContext[InputContext["FilteringFinished"] = 2] = "FilteringFinished";
|
|
48
|
+
/** Component's parent has finished filtering, but ResultSelector(stepping through results) is not enabled */
|
|
49
|
+
InputContext[InputContext["FilteringFinishedWithNoStepping"] = 3] = "FilteringFinishedWithNoStepping";
|
|
50
|
+
})(InputContext = exports.InputContext || (exports.InputContext = {}));
|
|
51
|
+
class SearchBox extends React.PureComponent {
|
|
52
|
+
constructor(props) {
|
|
53
|
+
super(props);
|
|
54
|
+
this._inputElement = null;
|
|
55
|
+
this._timeoutId = 0;
|
|
56
|
+
this._trackChange = (_event) => {
|
|
57
|
+
let searchText = "";
|
|
58
|
+
// istanbul ignore else
|
|
59
|
+
if (this._inputElement)
|
|
60
|
+
searchText = this._inputElement.value;
|
|
61
|
+
this.setState((_prevState) => {
|
|
62
|
+
return { searchText };
|
|
63
|
+
}, () => {
|
|
64
|
+
if (this.props.valueChangedDelay) {
|
|
65
|
+
this._unsetTimeout();
|
|
66
|
+
this._timeoutId = window.setTimeout(() => {
|
|
67
|
+
this.setState({
|
|
68
|
+
context: InputContext.ReadyToFilter,
|
|
69
|
+
selectedIndex: 0,
|
|
70
|
+
});
|
|
71
|
+
this.props.onSelectedChanged(0);
|
|
72
|
+
this.props.onFilterStart(this.state.searchText);
|
|
73
|
+
}, this.props.valueChangedDelay);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.setState({ context: InputContext.ReadyToFilter });
|
|
77
|
+
this.props.onFilterStart(this.state.searchText);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
this._handleKeyDown = (e) => {
|
|
82
|
+
switch (e.key) {
|
|
83
|
+
case "Escape":
|
|
84
|
+
// istanbul ignore else
|
|
85
|
+
if (this.props.onEscPressed)
|
|
86
|
+
this.props.onEscPressed();
|
|
87
|
+
break;
|
|
88
|
+
case "Enter":
|
|
89
|
+
// istanbul ignore else
|
|
90
|
+
if (this.props.onEnterPressed)
|
|
91
|
+
this.props.onEnterPressed();
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
this._handleIconClick = (_event) => {
|
|
96
|
+
// istanbul ignore else
|
|
97
|
+
if (this._inputElement) {
|
|
98
|
+
const clear = this.state.searchText !== "";
|
|
99
|
+
this._inputElement.value = "";
|
|
100
|
+
// istanbul ignore else
|
|
101
|
+
if (clear && this.props.onClear)
|
|
102
|
+
this.props.onClear();
|
|
103
|
+
this._inputElement.focus();
|
|
104
|
+
}
|
|
105
|
+
this._trackChange();
|
|
106
|
+
if (this.props.onIconClick)
|
|
107
|
+
this.props.onIconClick();
|
|
108
|
+
};
|
|
109
|
+
this._unsetTimeout = () => {
|
|
110
|
+
if (this._timeoutId) {
|
|
111
|
+
window.clearTimeout(this._timeoutId);
|
|
112
|
+
this._timeoutId = 0;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
this._onPrevClick = () => {
|
|
116
|
+
if (this.state.selectedIndex > 1) {
|
|
117
|
+
this.props.onSelectedChanged(this.state.selectedIndex - 1);
|
|
118
|
+
this.setState((state) => ({ selectedIndex: state.selectedIndex - 1 }));
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
this._onNextClick = () => {
|
|
122
|
+
if (this.state.selectedIndex < this.props.resultCount) {
|
|
123
|
+
this.props.onSelectedChanged(this.state.selectedIndex + 1);
|
|
124
|
+
this.setState((state) => ({ selectedIndex: state.selectedIndex + 1 }));
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
this.state = {
|
|
128
|
+
searchText: this.props.searchText,
|
|
129
|
+
context: InputContext.ReadyToFilter,
|
|
130
|
+
selectedIndex: 0,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
focus() {
|
|
134
|
+
// istanbul ignore else
|
|
135
|
+
if (this._inputElement) {
|
|
136
|
+
this._inputElement.focus();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async componentDidUpdate(prevProps) {
|
|
140
|
+
if (prevProps.searchText !== this.props.searchText) {
|
|
141
|
+
const searchText = this.props.searchText;
|
|
142
|
+
this.setState({ searchText });
|
|
143
|
+
}
|
|
144
|
+
this.focus();
|
|
145
|
+
}
|
|
146
|
+
componentWillUnmount() {
|
|
147
|
+
this._unsetTimeout();
|
|
148
|
+
}
|
|
149
|
+
/** @internal */
|
|
150
|
+
static getDerivedStateFromProps(props, state) {
|
|
151
|
+
if (state.context === InputContext.FilteringInProgress &&
|
|
152
|
+
!props.filteringInProgress) {
|
|
153
|
+
if (state.searchText)
|
|
154
|
+
return { context: InputContext.FilteringFinished };
|
|
155
|
+
else
|
|
156
|
+
return { context: InputContext.FilteringFinishedWithNoStepping };
|
|
157
|
+
}
|
|
158
|
+
else if (state.context === InputContext.ReadyToFilter &&
|
|
159
|
+
props.filteringInProgress) {
|
|
160
|
+
return { context: InputContext.FilteringInProgress };
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
render() {
|
|
165
|
+
const { autoFocus, className, style, resultCount, placeholder, } = this.props;
|
|
166
|
+
const { searchText, selectedIndex } = this.state;
|
|
167
|
+
const searchClassName = classnames_1.default("tree-widget-searchbox", className);
|
|
168
|
+
const showCount = resultCount > 0;
|
|
169
|
+
const isPrevEnabled = selectedIndex > 1;
|
|
170
|
+
const isNextEnabled = selectedIndex < resultCount;
|
|
171
|
+
return (React.createElement("div", { className: searchClassName, style: style },
|
|
172
|
+
React.createElement("input", { value: searchText, ref: (el) => {
|
|
173
|
+
this._inputElement = el;
|
|
174
|
+
}, autoFocus: autoFocus, onChange: this._trackChange, onKeyDown: this._handleKeyDown, onPaste: this._trackChange, onCut: this._trackChange, placeholder: placeholder ? placeholder : TreeWidget_1.TreeWidget.translate("searchbox.search") }),
|
|
175
|
+
React.createElement("div", { className: "searchbox-stepping-container" },
|
|
176
|
+
showCount && (React.createElement("span", { className: "searchbox-stepping-count" }, `${selectedIndex}/${resultCount}`)),
|
|
177
|
+
React.createElement("div", { className: "searchbox-separator" }),
|
|
178
|
+
React.createElement(IconButton_1.IconButton, { className: "searchbox-step-button", icon: "icon-chevron-up", disabled: !isPrevEnabled, onClick: this._onPrevClick, title: "Previous" }),
|
|
179
|
+
React.createElement(IconButton_1.IconButton, { className: "searchbox-step-button", icon: "icon-chevron-down", disabled: !isNextEnabled, onClick: this._onNextClick, title: "Next" })),
|
|
180
|
+
React.createElement("span", { className: "searchbox-step-button icon icon-close searchbox-close-button", onClick: this._handleIconClick })));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.SearchBox = SearchBox;
|
|
184
|
+
//# sourceMappingURL=SearchBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBox.js","sourceRoot":"","sources":["../../../../src/components/search-bar/SearchBox.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;AAExB,6CAA+B;AAC/B,4DAAoC;AAEpC,8CAA2C;AAC3C,4BAA0B;AAC1B,iDAA8C;AAiC9C;;;GAGG;AACH,IAAY,YASX;AATD,WAAY,YAAY;IACtB,mCAAmC;IACnC,iEAAa,CAAA;IACb,gDAAgD;IAChD,6EAAmB,CAAA;IACnB,gDAAgD;IAChD,yEAAiB,CAAA;IACjB,6GAA6G;IAC7G,qGAA+B,CAAA;AACjC,CAAC,EATW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QASvB;AAUD,MAAa,SAAU,SAAQ,KAAK,CAAC,aAGpC;IAIC,YAAY,KAAqB;QAC/B,KAAK,CAAC,KAAK,CAAC,CAAC;QAJP,kBAAa,GAA4B,IAAI,CAAC;QAC9C,eAAU,GAAW,CAAC,CAAC;QAmBvB,iBAAY,GAAG,CAAC,MAAY,EAAQ,EAAE;YAC5C,IAAI,UAAU,GAAG,EAAE,CAAC;YAEpB,uBAAuB;YACvB,IAAI,IAAI,CAAC,aAAa;gBAAE,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;YAE9D,IAAI,CAAC,QAAQ,CACX,CAAC,UAAU,EAAE,EAAE;gBACb,OAAO,EAAE,UAAU,EAAE,CAAC;YACxB,CAAC,EACD,GAAG,EAAE;gBACH,IAAI,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE;oBAChC,IAAI,CAAC,aAAa,EAAE,CAAC;oBACrB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;wBACvC,IAAI,CAAC,QAAQ,CAAC;4BACZ,OAAO,EAAE,YAAY,CAAC,aAAa;4BACn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,8DAA8D,EACxE,OAAO,EAAE,IAAI,CAAC,gBAAgB,GAC9B,CACE,CACP,CAAC;IACJ,CAAC;CACF;AA9LD,8BA8LC","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/** @module SearchBox */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { CommonProps } from \"@itwin/core-react\";\nimport { IconButton } from \"../IconButton\";\nimport \"./SearchBox.scss\";\nimport { TreeWidget } from \"../../TreeWidget\";\n\nexport interface SearchBoxProps extends CommonProps {\n /** value to set SearchBox */\n searchText?: string;\n /** placeholder value to show in gray before anything is entered in */\n placeholder?: string;\n /** frequency to poll for changes in value */\n valueChangedDelay?: number;\n /** listens for <Enter> keypress */\n onEnterPressed?: () => void;\n /** listens for <Esc> keypress */\n onEscPressed?: () => void;\n /** listens for onClick event for Clear (x) icon */\n onClear?: () => void;\n /** Search or clear icon click */\n onIconClick?: () => void;\n /** Filtering is cleared after everything's loaded */\n onFilterStart: (newFilter: string) => void;\n /** Filtering is cleared after everything's loaded */\n onFilterClear?: () => void;\n /** Filtering is cleared after everything's loaded */\n onFilterCancel?: () => void;\n /** Tells the component if parent component is still handling the filtering */\n filteringInProgress?: boolean;\n /** Total number of results/entries */\n resultCount: number;\n /** Callback to currently selected result/entry change */\n onSelectedChanged: (index: number) => void;\n /** Specify that the <input> element should automatically get focus */\n autoFocus?: boolean;\n}\n\n/**\n * Enumeration of possible component contexts\n * @internal\n */\nexport enum InputContext {\n /** Component is ready to filter */\n ReadyToFilter,\n /** Component's parent is currently filtering */\n FilteringInProgress,\n /** Component's parent has finished filtering */\n FilteringFinished,\n /** Component's parent has finished filtering, but ResultSelector(stepping through results) is not enabled */\n FilteringFinishedWithNoStepping,\n}\n\ninterface SearchBoxState {\n searchText?: string;\n /** @internal */\n context: InputContext;\n /** Currently selected index */\n selectedIndex: number;\n}\n\nexport class SearchBox extends React.PureComponent<\n SearchBoxProps,\n SearchBoxState\n> {\n private _inputElement: HTMLInputElement | null = null;\n private _timeoutId: number = 0;\n\n constructor(props: SearchBoxProps) {\n super(props);\n\n this.state = {\n searchText: this.props.searchText,\n context: InputContext.ReadyToFilter,\n selectedIndex: 0,\n };\n }\n\n public focus() {\n // istanbul ignore else\n if (this._inputElement) {\n this._inputElement.focus();\n }\n }\n\n private _trackChange = (_event?: any): void => {\n let searchText = \"\";\n\n // istanbul ignore else\n if (this._inputElement) searchText = this._inputElement.value;\n\n this.setState(\n (_prevState) => {\n return { searchText };\n },\n () => {\n if (this.props.valueChangedDelay) {\n this._unsetTimeout();\n this._timeoutId = window.setTimeout(() => {\n this.setState({\n context: InputContext.ReadyToFilter,\n selectedIndex: 0,\n });\n this.props.onSelectedChanged(0);\n this.props.onFilterStart(this.state.searchText!);\n }, this.props.valueChangedDelay);\n } else {\n this.setState({ context: InputContext.ReadyToFilter });\n this.props.onFilterStart(this.state.searchText!);\n }\n }\n );\n };\n\n private _handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n switch (e.key) {\n case \"Escape\":\n // istanbul ignore else\n if (this.props.onEscPressed) this.props.onEscPressed();\n break;\n case \"Enter\":\n // istanbul ignore else\n if (this.props.onEnterPressed) this.props.onEnterPressed();\n break;\n }\n };\n\n private _handleIconClick = (_event: React.MouseEvent<HTMLElement>): void => {\n // istanbul ignore else\n if (this._inputElement) {\n const clear = this.state.searchText !== \"\";\n this._inputElement.value = \"\";\n // istanbul ignore else\n if (clear && this.props.onClear) this.props.onClear();\n this._inputElement.focus();\n }\n this._trackChange();\n if (this.props.onIconClick) this.props.onIconClick();\n };\n\n private _unsetTimeout = (): void => {\n if (this._timeoutId) {\n window.clearTimeout(this._timeoutId);\n this._timeoutId = 0;\n }\n };\n\n public async componentDidUpdate(prevProps: SearchBoxProps) {\n if (prevProps.searchText !== this.props.searchText) {\n const searchText = this.props.searchText;\n this.setState({ searchText });\n }\n\n this.focus();\n }\n\n public componentWillUnmount() {\n this._unsetTimeout();\n }\n\n /** @internal */\n public static getDerivedStateFromProps(\n props: SearchBoxProps,\n state: SearchBoxState\n ) {\n if (\n state.context === InputContext.FilteringInProgress &&\n !props.filteringInProgress\n ) {\n if (state.searchText) return { context: InputContext.FilteringFinished };\n else return { context: InputContext.FilteringFinishedWithNoStepping };\n } else if (\n state.context === InputContext.ReadyToFilter &&\n props.filteringInProgress\n ) {\n return { context: InputContext.FilteringInProgress };\n }\n return null;\n }\n\n private _onPrevClick = () => {\n if (this.state.selectedIndex > 1) {\n this.props.onSelectedChanged(this.state.selectedIndex - 1);\n this.setState((state) => ({ selectedIndex: state.selectedIndex - 1 }));\n }\n };\n\n private _onNextClick = () => {\n if (this.state.selectedIndex < this.props.resultCount) {\n this.props.onSelectedChanged(this.state.selectedIndex + 1);\n this.setState((state) => ({ selectedIndex: state.selectedIndex + 1 }));\n }\n };\n\n public render() {\n const {\n autoFocus,\n className,\n style,\n resultCount,\n placeholder,\n } = this.props;\n const { searchText, selectedIndex } = this.state;\n const searchClassName = classnames(\"tree-widget-searchbox\", className);\n const showCount = resultCount > 0;\n const isPrevEnabled = selectedIndex > 1;\n const isNextEnabled = selectedIndex < resultCount;\n\n return (\n <div className={searchClassName} style={style}>\n <input\n value={searchText}\n ref={(el) => {\n this._inputElement = el;\n }}\n autoFocus={autoFocus}\n onChange={this._trackChange}\n onKeyDown={this._handleKeyDown}\n onPaste={this._trackChange}\n onCut={this._trackChange}\n placeholder={\n placeholder ? placeholder : TreeWidget.translate(\"searchbox.search\")\n }\n />\n <div className=\"searchbox-stepping-container\">\n {showCount && (\n <span className=\"searchbox-stepping-count\">{`${selectedIndex}/${resultCount}`}</span>\n )}\n <div className=\"searchbox-separator\" />\n <IconButton\n className=\"searchbox-step-button\"\n icon=\"icon-chevron-up\"\n disabled={!isPrevEnabled}\n onClick={this._onPrevClick}\n title=\"Previous\"\n />\n <IconButton\n className=\"searchbox-step-button\"\n icon=\"icon-chevron-down\"\n disabled={!isNextEnabled}\n onClick={this._onNextClick}\n title=\"Next\"\n />\n </div>\n <span\n className=\"searchbox-step-button icon icon-close searchbox-close-button\"\n onClick={this._handleIconClick}\n />\n </div>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
|
|
7
|
+
.tree-widget-searchbox {
|
|
8
|
+
@include uicore-font-family;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
position: relative;
|
|
12
|
+
//default values (height, width, font-size, color)
|
|
13
|
+
height: 34px;
|
|
14
|
+
width: 12em;
|
|
15
|
+
font-size: $uicore-font-size;
|
|
16
|
+
color: $buic-text-color-reverse;
|
|
17
|
+
background: $buic-background-control;
|
|
18
|
+
border: 1px solid $buic-inputs-border;
|
|
19
|
+
|
|
20
|
+
input {
|
|
21
|
+
padding: 0 $uicore-s;
|
|
22
|
+
height: 100%;
|
|
23
|
+
width: 100%;
|
|
24
|
+
flex: 1;
|
|
25
|
+
background: $buic-background-control;
|
|
26
|
+
margin-right: $uicore-s;
|
|
27
|
+
color: $buic-text-color;
|
|
28
|
+
font-size: inherit;
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
border: 0;
|
|
31
|
+
|
|
32
|
+
&::placeholder {
|
|
33
|
+
color: $buic-foreground-disabled;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:focus-within,
|
|
37
|
+
&:focus,
|
|
38
|
+
&:active,
|
|
39
|
+
&[disabled],
|
|
40
|
+
&[disabled]:hover,
|
|
41
|
+
&[disabled]:active,
|
|
42
|
+
&[disabled]:focus {
|
|
43
|
+
border: 0;
|
|
44
|
+
outline: none;
|
|
45
|
+
outline-width: 0;
|
|
46
|
+
box-shadow: none;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.searchbox-stepping-container {
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
right: 32px;
|
|
54
|
+
height: 100%;
|
|
55
|
+
|
|
56
|
+
.searchbox-stepping-count {
|
|
57
|
+
font-size: 12px;
|
|
58
|
+
color: $buic-text-color;
|
|
59
|
+
margin-right: $uicore-xs;
|
|
60
|
+
position: relative;
|
|
61
|
+
word-wrap: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.searchbox-separator {
|
|
65
|
+
height: 75%;
|
|
66
|
+
width: 1px;
|
|
67
|
+
margin: 0 $uicore-s;
|
|
68
|
+
background: $buic-inputs-border;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.searchbox-step-button {
|
|
73
|
+
height: 100%;
|
|
74
|
+
width: 32px;
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
color: $buic-icon-color;
|
|
80
|
+
font-size: $uicore-font-size-small;
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
|
|
83
|
+
&:hover {
|
|
84
|
+
color: $buic-accessory-primary;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.searchbox-close-button {
|
|
89
|
+
z-index: 1000;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IModelConnection, Viewport } from "@itwin/core-frontend";
|
|
2
|
+
import "./CategoriesTree.scss";
|
|
3
|
+
export interface CategoriesTreeComponentProps {
|
|
4
|
+
iModel: IModelConnection;
|
|
5
|
+
allViewports?: boolean;
|
|
6
|
+
activeView?: Viewport;
|
|
7
|
+
}
|
|
8
|
+
export declare function CategoriesTreeComponent(props: CategoriesTreeComponentProps): JSX.Element;
|
|
9
|
+
//# sourceMappingURL=CategoriesTree.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
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.CategoriesTreeComponent = 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 core_frontend_1 = require("@itwin/core-frontend");
|
|
29
|
+
const appui_react_1 = require("@itwin/appui-react");
|
|
30
|
+
const TreeFilteringState_1 = require("../TreeFilteringState");
|
|
31
|
+
require("./CategoriesTree.scss");
|
|
32
|
+
const TreeHeader_1 = require("../header/TreeHeader");
|
|
33
|
+
const appui_react_2 = require("@itwin/appui-react");
|
|
34
|
+
const core_react_1 = require("@itwin/core-react");
|
|
35
|
+
function CategoriesTreeComponent(props) {
|
|
36
|
+
const { searchOptions, filterString, activeMatchIndex, onFilterApplied, filteredProvider, } = TreeFilteringState_1.useTreeFilteringState();
|
|
37
|
+
const [height, setHeight] = react_1.useState(0);
|
|
38
|
+
const [width, setWidth] = react_1.useState(0);
|
|
39
|
+
const handleResize = react_1.useCallback((w, h) => {
|
|
40
|
+
setHeight(h);
|
|
41
|
+
setWidth(w);
|
|
42
|
+
}, []);
|
|
43
|
+
const ref = core_react_1.useResizeObserver(handleResize);
|
|
44
|
+
const showAll = react_1.useCallback(async () => {
|
|
45
|
+
return appui_react_1.toggleAllCategories(core_frontend_1.IModelApp.viewManager, props.iModel, true, undefined, true, filteredProvider);
|
|
46
|
+
}, [props.iModel, filteredProvider]);
|
|
47
|
+
const hideAll = react_1.useCallback(async () => {
|
|
48
|
+
return appui_react_1.toggleAllCategories(core_frontend_1.IModelApp.viewManager, props.iModel, false, undefined, true, filteredProvider);
|
|
49
|
+
}, [props.iModel, filteredProvider]);
|
|
50
|
+
const invert = react_1.useCallback(async () => {
|
|
51
|
+
const activeView = core_frontend_1.IModelApp.viewManager.getFirstOpenView();
|
|
52
|
+
if (!activeView) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const ids = await appui_react_1.getCategories(props.iModel, activeView, filteredProvider);
|
|
56
|
+
let enabled = [];
|
|
57
|
+
let disabled = [];
|
|
58
|
+
for (const id of ids) {
|
|
59
|
+
if (activeView.view.viewsCategory(id)) {
|
|
60
|
+
enabled.push(id);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
disabled.push(id);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Disable enabled
|
|
67
|
+
appui_react_2.CategoryVisibilityHandler.enableCategory(core_frontend_1.IModelApp.viewManager, props.iModel, enabled, false, true);
|
|
68
|
+
// Enable disabled
|
|
69
|
+
appui_react_2.CategoryVisibilityHandler.enableCategory(core_frontend_1.IModelApp.viewManager, props.iModel, disabled, true, true);
|
|
70
|
+
}, [props.iModel, filteredProvider]);
|
|
71
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
72
|
+
react_1.default.createElement(TreeHeader_1.TreeHeaderComponent, { searchOptions: searchOptions, showAll: showAll, hideAll: hideAll, invert: invert }),
|
|
73
|
+
react_1.default.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (react_1.default.createElement(appui_react_1.CategoryTree, { ...props, filterInfo: { filter: filterString, activeMatchIndex }, onFilterApplied: onFilterApplied, width: width, height: height })))));
|
|
74
|
+
}
|
|
75
|
+
exports.CategoriesTreeComponent = CategoriesTreeComponent;
|
|
76
|
+
//# sourceMappingURL=CategoriesTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../src/components/trees/CategoriesTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+CAAqD;AACrD,wDAI8B;AAC9B,oDAI4B;AAC5B,8DAA8D;AAC9D,iCAA+B;AAC/B,qDAA2D;AAC3D,oDAA+D;AAC/D,kDAAsD;AAQtD,SAAgB,uBAAuB,CAAC,KAAmC;IACzE,MAAM,EACJ,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,GAAG,0CAAqB,EAAE,CAAC;IAE5B,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,CA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QACD,kBAAkB;QAClB,uCAAyB,CAAC,cAAc,CACtC,yBAAS,CAAC,WAAW,EACrB,KAAK,CAAC,MAAM,EACZ,OAAO,EACP,KAAK,EACL,IAAI,CACL,CAAC;QACF,kBAAkB;QAClB,uCAAyB,CAAC,cAAc,CACtC,yBAAS,CAAC,WAAW,EACrB,KAAK,CAAC,MAAM,EACZ,QAAQ,EACR,IAAI,EACJ,IAAI,CACL,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAErC,OAAO,CACL;QACE,8BAAC,gCAAmB,IAClB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACd;QACF,uCAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IACpD,KAAK,IAAI,MAAM,IAAI,CAClB,8BAAC,0BAAY,OACP,KAAK,EACT,UAAU,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,EACtD,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACd,CACH,CACG,CACL,CACJ,CAAC;AACJ,CAAC;AA9FD,0DA8FC","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 {\n IModelApp,\n IModelConnection,\n Viewport,\n} from \"@itwin/core-frontend\";\nimport {\n CategoryTree,\n toggleAllCategories,\n getCategories,\n} from \"@itwin/appui-react\";\nimport { useTreeFilteringState } from \"../TreeFilteringState\";\nimport \"./CategoriesTree.scss\";\nimport { TreeHeaderComponent } from \"../header/TreeHeader\";\nimport { CategoryVisibilityHandler } from \"@itwin/appui-react\";\nimport { useResizeObserver } from \"@itwin/core-react\";\n\nexport interface CategoriesTreeComponentProps {\n iModel: IModelConnection;\n allViewports?: boolean;\n activeView?: Viewport;\n}\n\nexport function CategoriesTreeComponent(props: CategoriesTreeComponentProps) {\n const {\n searchOptions,\n filterString,\n activeMatchIndex,\n onFilterApplied,\n filteredProvider,\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 showAll = useCallback(async () => {\n return toggleAllCategories(\n IModelApp.viewManager,\n props.iModel,\n true,\n undefined,\n true,\n filteredProvider\n );\n }, [props.iModel, filteredProvider]);\n\n const hideAll = useCallback(async () => {\n return toggleAllCategories(\n IModelApp.viewManager,\n props.iModel,\n false,\n undefined,\n true,\n filteredProvider\n );\n }, [props.iModel, filteredProvider]);\n\n const invert = useCallback(async () => {\n const activeView = IModelApp.viewManager.getFirstOpenView();\n if (!activeView) {\n return;\n }\n\n const ids = await getCategories(props.iModel, activeView, filteredProvider);\n let enabled: string[] = [];\n let disabled: string[] = [];\n for (const id of ids) {\n if (activeView.view.viewsCategory(id)) {\n enabled.push(id);\n } else {\n disabled.push(id);\n }\n }\n // Disable enabled\n CategoryVisibilityHandler.enableCategory(\n IModelApp.viewManager,\n props.iModel,\n enabled,\n false,\n true\n );\n // Enable disabled\n CategoryVisibilityHandler.enableCategory(\n IModelApp.viewManager,\n props.iModel,\n disabled,\n true,\n true\n );\n }, [props.iModel, filteredProvider]);\n\n return (\n <>\n <TreeHeaderComponent\n searchOptions={searchOptions}\n showAll={showAll}\n hideAll={hideAll}\n invert={invert}\n />\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }}>\n {width && height && (\n <CategoryTree\n {...props}\n filterInfo={{ filter: filterString, activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n width={width}\n height={height}\n />\n )}\n </div>\n </>\n );\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
|
|
7
|
+
.tree-widget-category-tree-search-bar {
|
|
8
|
+
margin-bottom: $uicore-s;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.tree-widget-category-tree-toolbar-icon {
|
|
12
|
+
color: $buic-icon-color;
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IModelConnection } from "@itwin/core-frontend";
|
|
2
|
+
export interface ClassificationsTreeComponentProps {
|
|
3
|
+
iModel: IModelConnection;
|
|
4
|
+
}
|
|
5
|
+
export declare function ClassificationsTreeComponent(props: ClassificationsTreeComponentProps): JSX.Element;
|
|
6
|
+
//# sourceMappingURL=ClassificationsTree.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ClassificationsTreeComponent = void 0;
|
|
26
|
+
/*---------------------------------------------------------------------------------------------
|
|
27
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
28
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
29
|
+
*--------------------------------------------------------------------------------------------*/
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const TreeWithRuleset_1 = require("./TreeWithRuleset");
|
|
32
|
+
const presentation_components_1 = require("@itwin/presentation-components");
|
|
33
|
+
const ClassificationSystems_json_1 = __importDefault(require("../rulesets/ClassificationSystems.json"));
|
|
34
|
+
function ClassificationsTreeComponent(props) {
|
|
35
|
+
const dataProvider = new presentation_components_1.PresentationTreeDataProvider({
|
|
36
|
+
imodel: props.iModel,
|
|
37
|
+
ruleset: ClassificationSystems_json_1.default.id,
|
|
38
|
+
pagingSize: 20,
|
|
39
|
+
});
|
|
40
|
+
return (React.createElement(TreeWithRuleset_1.SimpleTreeWithRuleset, { imodel: props.iModel, ruleSet: ClassificationSystems_json_1.default, dataProvider: dataProvider }));
|
|
41
|
+
}
|
|
42
|
+
exports.ClassificationsTreeComponent = ClassificationsTreeComponent;
|
|
43
|
+
//# sourceMappingURL=ClassificationsTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassificationsTree.js","sourceRoot":"","sources":["../../../../src/components/trees/ClassificationsTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,6CAA+B;AAE/B,uDAA0D;AAE1D,4EAA8E;AAC9E,wGAAyE;AAMzE,SAAgB,4BAA4B,CAC1C,KAAwC;IAExC,MAAM,YAAY,GAAG,IAAI,sDAA4B,CAAC;QACpD,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,oCAAmB,CAAC,EAAE;QAC/B,UAAU,EAAE,EAAE;KACf,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,uCAAqB,IACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,OAAO,EAAE,oCAA8B,EACvC,YAAY,EAAE,YAAY,GAC1B,CACH,CAAC;AACJ,CAAC;AAhBD,oEAgBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport { Ruleset } from \"@itwin/presentation-common\";\nimport { SimpleTreeWithRuleset } from \"./TreeWithRuleset\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { PresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport classificationRules from \"../rulesets/ClassificationSystems.json\";\n\nexport interface ClassificationsTreeComponentProps {\n iModel: IModelConnection;\n}\n\nexport function ClassificationsTreeComponent(\n props: ClassificationsTreeComponentProps\n) {\n const dataProvider = new PresentationTreeDataProvider({\n imodel: props.iModel,\n ruleset: classificationRules.id,\n pagingSize: 20,\n });\n\n return (\n <SimpleTreeWithRuleset\n imodel={props.iModel}\n ruleSet={classificationRules as Ruleset}\n dataProvider={dataProvider}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IModelConnection, Viewport } from "@itwin/core-frontend";
|
|
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;
|
|
10
|
+
//# sourceMappingURL=ModelsTree.d.ts.map
|