@itwin/components-react 4.0.0-dev.2 → 4.0.0-dev.3
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 +1 -1
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.d.ts +4 -1
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.d.ts.map +1 -1
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js +4 -1
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilder.d.ts +22 -25
- package/lib/cjs/components-react/filter-builder/FilterBuilder.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilder.js +19 -81
- package/lib/cjs/components-react/filter-builder/FilterBuilder.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderContext.d.ts +80 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilderContext.d.ts.map +1 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilderContext.js +83 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilderContext.js.map +1 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.d.ts +14 -3
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.js +22 -12
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.scss +4 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.d.ts +25 -16
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.js +22 -14
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.d.ts +14 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js +11 -5
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.d.ts +16 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js +11 -5
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.d.ts +14 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js +11 -5
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.d.ts +50 -7
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.js +60 -8
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/Operators.d.ts +23 -5
- package/lib/cjs/components-react/filter-builder/Operators.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/Operators.js +25 -7
- package/lib/cjs/components-react/filter-builder/Operators.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/Types.d.ts +24 -4
- package/lib/cjs/components-react/filter-builder/Types.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/Types.js +11 -1
- package/lib/cjs/components-react/filter-builder/Types.js.map +1 -1
- package/lib/cjs/components-react/properties/LinkHandler.d.ts +2 -2
- package/lib/cjs/components-react/properties/LinkHandler.js +1 -1
- package/lib/cjs/components-react/properties/LinkHandler.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.d.ts +3 -3
- package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js +1 -1
- package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/PropertyDataProvider.d.ts +2 -2
- package/lib/cjs/components-react/propertygrid/PropertyDataProvider.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyGrid.d.ts +2 -0
- package/lib/cjs/components-react/propertygrid/component/PropertyGrid.d.ts.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyGrid.js +1 -0
- package/lib/cjs/components-react/propertygrid/component/PropertyGrid.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.d.ts +5 -10
- package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.d.ts.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +3 -3
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js +1 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.scss +11 -0
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts +2 -2
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js +1 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridEventHandler.d.ts +2 -2
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridEventHandler.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridEventHandler.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridHooks.d.ts +3 -3
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridHooks.js +3 -3
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridHooks.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridModel.d.ts +3 -3
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridModel.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridModel.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridModelChangeEvent.d.ts +2 -2
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridModelChangeEvent.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridModelChangeEvent.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridModelSource.d.ts +2 -2
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridModelSource.d.ts.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridModelSource.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/PropertyGridModelSource.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/FlatGridItem.d.ts +4 -4
- package/lib/cjs/components-react/propertygrid/internal/flat-items/FlatGridItem.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.d.ts +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCategorizedPrimitiveProperty.d.ts +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCategorizedPrimitiveProperty.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCategorizedPrimitiveProperty.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.d.ts +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.d.ts +8 -8
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +3 -3
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.d.ts +2 -2
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.d.ts +2 -2
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts +3 -6
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/ControlledTree.d.ts +1 -4
- package/lib/cjs/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/TreeRenderer.d.ts +2 -5
- package/lib/cjs/components-react/tree/controlled/component/TreeRenderer.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
- package/lib/cjs/components-react.d.ts +4 -6
- package/lib/cjs/components-react.d.ts.map +1 -1
- package/lib/cjs/components-react.js +4 -6
- package/lib/cjs/components-react.js.map +1 -1
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.d.ts +4 -1
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.d.ts.map +1 -1
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.js +4 -1
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilder.d.ts +22 -25
- package/lib/esm/components-react/filter-builder/FilterBuilder.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilder.js +12 -73
- package/lib/esm/components-react/filter-builder/FilterBuilder.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderContext.d.ts +80 -0
- package/lib/esm/components-react/filter-builder/FilterBuilderContext.d.ts.map +1 -0
- package/lib/esm/components-react/filter-builder/FilterBuilderContext.js +60 -0
- package/lib/esm/components-react/filter-builder/FilterBuilderContext.js.map +1 -0
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.d.ts +14 -3
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.js +17 -7
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.scss +4 -0
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.d.ts +25 -16
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.js +15 -7
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.d.ts +14 -2
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js +7 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.d.ts +16 -2
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js +7 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.d.ts +14 -2
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js +7 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderState.d.ts +50 -7
- package/lib/esm/components-react/filter-builder/FilterBuilderState.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderState.js +54 -3
- package/lib/esm/components-react/filter-builder/FilterBuilderState.js.map +1 -1
- package/lib/esm/components-react/filter-builder/Operators.d.ts +23 -5
- package/lib/esm/components-react/filter-builder/Operators.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/Operators.js +23 -5
- package/lib/esm/components-react/filter-builder/Operators.js.map +1 -1
- package/lib/esm/components-react/filter-builder/Types.d.ts +24 -4
- package/lib/esm/components-react/filter-builder/Types.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/Types.js +11 -1
- package/lib/esm/components-react/filter-builder/Types.js.map +1 -1
- package/lib/esm/components-react/properties/LinkHandler.d.ts +2 -2
- package/lib/esm/components-react/properties/LinkHandler.js +1 -1
- package/lib/esm/components-react/properties/LinkHandler.js.map +1 -1
- package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.d.ts +3 -3
- package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js +1 -1
- package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
- package/lib/esm/components-react/propertygrid/PropertyDataProvider.d.ts +2 -2
- package/lib/esm/components-react/propertygrid/PropertyDataProvider.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyGrid.d.ts +2 -0
- package/lib/esm/components-react/propertygrid/component/PropertyGrid.d.ts.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyGrid.js +1 -0
- package/lib/esm/components-react/propertygrid/component/PropertyGrid.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.d.ts +5 -10
- package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.d.ts.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +3 -3
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js +1 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.scss +11 -0
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts +2 -2
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js +1 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/PropertyGridEventHandler.d.ts +2 -2
- package/lib/esm/components-react/propertygrid/internal/PropertyGridEventHandler.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/PropertyGridEventHandler.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/PropertyGridHooks.d.ts +3 -3
- package/lib/esm/components-react/propertygrid/internal/PropertyGridHooks.js +3 -3
- package/lib/esm/components-react/propertygrid/internal/PropertyGridHooks.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/PropertyGridModel.d.ts +3 -3
- package/lib/esm/components-react/propertygrid/internal/PropertyGridModel.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/PropertyGridModel.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/PropertyGridModelChangeEvent.d.ts +2 -2
- package/lib/esm/components-react/propertygrid/internal/PropertyGridModelChangeEvent.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/PropertyGridModelChangeEvent.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/PropertyGridModelSource.d.ts +2 -2
- package/lib/esm/components-react/propertygrid/internal/PropertyGridModelSource.d.ts.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/PropertyGridModelSource.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/PropertyGridModelSource.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/FlatGridItem.d.ts +4 -4
- package/lib/esm/components-react/propertygrid/internal/flat-items/FlatGridItem.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.d.ts +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCategorizedPrimitiveProperty.d.ts +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCategorizedPrimitiveProperty.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCategorizedPrimitiveProperty.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.d.ts +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.d.ts +8 -8
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +3 -3
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.d.ts +2 -2
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.d.ts +2 -2
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts +3 -6
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/ControlledTree.d.ts +1 -4
- package/lib/esm/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/TreeRenderer.d.ts +2 -5
- package/lib/esm/components-react/tree/controlled/component/TreeRenderer.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
- package/lib/esm/components-react.d.ts +4 -6
- package/lib/esm/components-react.d.ts.map +1 -1
- package/lib/esm/components-react.js +4 -6
- package/lib/esm/components-react.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module PropertyFilterBuilder
|
|
8
|
+
*/
|
|
2
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
10
|
if (k2 === undefined) k2 = k;
|
|
4
11
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -19,17 +26,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
26
|
return result;
|
|
20
27
|
};
|
|
21
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.usePropertyFilterBuilderState = exports.isPropertyFilterBuilderRuleGroup = exports.PropertyFilterBuilderActions = 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
|
-
*--------------------------------------------------------------------------------------------*/
|
|
29
|
+
exports.buildPropertyFilter = exports.usePropertyFilterBuilderState = exports.isPropertyFilterBuilderRuleGroup = exports.PropertyFilterBuilderActions = void 0;
|
|
27
30
|
const immer_1 = require("immer");
|
|
28
31
|
const React = __importStar(require("react"));
|
|
32
|
+
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
29
33
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
30
34
|
const Operators_1 = require("./Operators");
|
|
31
35
|
const Types_1 = require("./Types");
|
|
32
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Actions for controlling [[PropertyFilterBuilder]] component state.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
33
40
|
class PropertyFilterBuilderActions {
|
|
34
41
|
constructor(setState) {
|
|
35
42
|
this.setState = setState;
|
|
@@ -37,6 +44,7 @@ class PropertyFilterBuilderActions {
|
|
|
37
44
|
updateState(updater) {
|
|
38
45
|
this.setState((0, immer_1.produce)(updater));
|
|
39
46
|
}
|
|
47
|
+
/** Adds new rule or group of rules to the group specified by path. */
|
|
40
48
|
addItem(path, itemType) {
|
|
41
49
|
this.updateState((state) => {
|
|
42
50
|
const parentGroup = findRuleGroup(state.rootGroup, path);
|
|
@@ -46,6 +54,7 @@ class PropertyFilterBuilderActions {
|
|
|
46
54
|
parentGroup.items.push(item);
|
|
47
55
|
});
|
|
48
56
|
}
|
|
57
|
+
/** Removes item specified by path. */
|
|
49
58
|
removeItem(path) {
|
|
50
59
|
function removeItemFromGroup(state, pathToItem) {
|
|
51
60
|
const pathToParent = pathToItem.slice(0, -1);
|
|
@@ -64,6 +73,7 @@ class PropertyFilterBuilderActions {
|
|
|
64
73
|
removeItemFromGroup(state, path);
|
|
65
74
|
});
|
|
66
75
|
}
|
|
76
|
+
/** Sets operator of rule group specified by the path. */
|
|
67
77
|
setRuleGroupOperator(path, operator) {
|
|
68
78
|
this.updateState((state) => {
|
|
69
79
|
const group = findRuleGroup(state.rootGroup, path);
|
|
@@ -72,6 +82,7 @@ class PropertyFilterBuilderActions {
|
|
|
72
82
|
group.operator = operator;
|
|
73
83
|
});
|
|
74
84
|
}
|
|
85
|
+
/** Sets property of rule specified by the path. */
|
|
75
86
|
setRuleProperty(path, property) {
|
|
76
87
|
this.updateState((state) => {
|
|
77
88
|
const rule = findRule(state.rootGroup, path);
|
|
@@ -81,6 +92,7 @@ class PropertyFilterBuilderActions {
|
|
|
81
92
|
rule.value = undefined;
|
|
82
93
|
});
|
|
83
94
|
}
|
|
95
|
+
/** Sets operator of rule specified by the path. */
|
|
84
96
|
setRuleOperator(path, operator) {
|
|
85
97
|
this.updateState((state) => {
|
|
86
98
|
const rule = findRule(state.rootGroup, path);
|
|
@@ -91,6 +103,7 @@ class PropertyFilterBuilderActions {
|
|
|
91
103
|
rule.operator = operator;
|
|
92
104
|
});
|
|
93
105
|
}
|
|
106
|
+
/** Sets value of rule specified by the path. */
|
|
94
107
|
setRuleValue(path, value) {
|
|
95
108
|
this.updateState((state) => {
|
|
96
109
|
const rule = findRule(state.rootGroup, path);
|
|
@@ -101,18 +114,57 @@ class PropertyFilterBuilderActions {
|
|
|
101
114
|
}
|
|
102
115
|
}
|
|
103
116
|
exports.PropertyFilterBuilderActions = PropertyFilterBuilderActions;
|
|
104
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Function to check if supplied [[PropertyFilterBuilderRuleGroupItem]] is [[PropertyFilterBuilderRuleGroup]].
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
105
121
|
function isPropertyFilterBuilderRuleGroup(item) {
|
|
106
122
|
return item.items !== undefined;
|
|
107
123
|
}
|
|
108
124
|
exports.isPropertyFilterBuilderRuleGroup = isPropertyFilterBuilderRuleGroup;
|
|
109
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* Custom hook that creates state for [[PropertyFilterBuilder]] component. It creates empty state or initializes
|
|
127
|
+
* state from supplied initial filter.
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
110
130
|
function usePropertyFilterBuilderState(initialFilter) {
|
|
111
131
|
const [state, setState] = React.useState(() => initialFilter ? convertFilterToState(initialFilter) : { rootGroup: createEmptyRuleGroup() });
|
|
112
132
|
const [actions] = React.useState(() => new PropertyFilterBuilderActions(setState));
|
|
113
133
|
return { state, actions };
|
|
114
134
|
}
|
|
115
135
|
exports.usePropertyFilterBuilderState = usePropertyFilterBuilderState;
|
|
136
|
+
/** @internal */
|
|
137
|
+
function buildPropertyFilter(groupItem) {
|
|
138
|
+
if (isPropertyFilterBuilderRuleGroup(groupItem))
|
|
139
|
+
return buildPropertyFilterFromRuleGroup(groupItem);
|
|
140
|
+
return buildPropertyFilterFromRule(groupItem);
|
|
141
|
+
}
|
|
142
|
+
exports.buildPropertyFilter = buildPropertyFilter;
|
|
143
|
+
function buildPropertyFilterFromRuleGroup(rootGroup) {
|
|
144
|
+
if (rootGroup.items.length === 0)
|
|
145
|
+
return undefined;
|
|
146
|
+
const rules = new Array();
|
|
147
|
+
for (const item of rootGroup.items) {
|
|
148
|
+
const rule = buildPropertyFilter(item);
|
|
149
|
+
if (!rule)
|
|
150
|
+
return undefined;
|
|
151
|
+
rules.push(rule);
|
|
152
|
+
}
|
|
153
|
+
if (rules.length === 1)
|
|
154
|
+
return rules[0];
|
|
155
|
+
return {
|
|
156
|
+
operator: rootGroup.operator,
|
|
157
|
+
rules,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function buildPropertyFilterFromRule(rule) {
|
|
161
|
+
const { property, operator, value } = rule;
|
|
162
|
+
if (!property || operator === undefined)
|
|
163
|
+
return undefined;
|
|
164
|
+
if (!(0, Operators_1.isUnaryPropertyFilterOperator)(operator) && (value === undefined || value.valueFormat !== appui_abstract_1.PropertyValueFormat.Primitive || value.value === undefined))
|
|
165
|
+
return undefined;
|
|
166
|
+
return { property, operator, value };
|
|
167
|
+
}
|
|
116
168
|
function createEmptyRule(groupId) {
|
|
117
169
|
return {
|
|
118
170
|
id: core_bentley_1.Guid.createValue(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilderState.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderState.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,iCAAuC;AACvC,6CAA+B;AAE/B,sDAA2C;AAC3C,2CAAyH;AACzH,mCAAwF;AA2BxF,aAAa;AACb,MAAa,4BAA4B;IACvC,YAAoB,QAAiG;QAAjG,aAAQ,GAAR,QAAQ,CAAyF;IAAI,CAAC;IAElH,WAAW,CAAC,OAA2D;QAC7E,IAAI,CAAC,QAAQ,CAAC,IAAA,eAAO,EAAC,OAAO,CAAC,CAAC,CAAC;IAClC,CAAC;IAEM,OAAO,CAAC,IAAc,EAAE,QAA+B;QAC5D,IAAI,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;YACzB,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACzD,IAAI,CAAC,WAAW;gBACd,OAAO;YACT,MAAM,IAAI,GAAG,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAChH,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,UAAU,CAAC,IAAc;QAC9B,SAAS,mBAAmB,CAAC,KAAwC,EAAE,UAAoB;YACzF,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,C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AC,IAAI,EAAE,EAAE,CAAC,CAAC;aAC9D;SACF,CAAC;KACH;IACD,OAAO;QACL,SAAS,EAAE;YACT,EAAE;YACF,QAAQ,EAAE,2CAA+B,CAAC,GAAG;YAC7C,KAAK,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SACjC;KACF,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 { Draft, produce } from \"immer\";\nimport * as React from \"react\";\nimport { PropertyDescription, PropertyValue } from \"@itwin/appui-abstract\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { isUnaryPropertyFilterOperator, PropertyFilterRuleGroupOperator, PropertyFilterRuleOperator } from \"./Operators\";\nimport { isPropertyFilterRuleGroup, PropertyFilter, PropertyFilterRule } from \"./Types\";\n\n/** @alpha */\nexport interface PropertyFilterBuilderState {\n rootGroup: PropertyFilterBuilderRuleGroup;\n}\n\n/** @alpha */\nexport type PropertyFilterBuilderRuleGroupItem = PropertyFilterBuilderRuleGroup | PropertyFilterBuilderRule;\n\n/** @alpha */\nexport interface PropertyFilterBuilderRuleGroup {\n id: string;\n groupId?: string;\n operator: PropertyFilterRuleGroupOperator;\n items: PropertyFilterBuilderRuleGroupItem[];\n}\n\n/** @alpha */\nexport interface PropertyFilterBuilderRule {\n id: string;\n groupId: string;\n property?: PropertyDescription;\n operator?: PropertyFilterRuleOperator;\n value?: PropertyValue;\n}\n\n/** @alpha */\nexport class PropertyFilterBuilderActions {\n constructor(private setState: (setter: (prevState: PropertyFilterBuilderState) => PropertyFilterBuilderState) => void) { }\n\n private updateState(updater: (state: Draft<PropertyFilterBuilderState>) => void) {\n this.setState(produce(updater));\n }\n\n public addItem(path: string[], itemType: \"RULE_GROUP\" | \"RULE\") {\n this.updateState((state) => {\n const parentGroup = findRuleGroup(state.rootGroup, path);\n if (!parentGroup)\n return;\n const item = itemType === \"RULE_GROUP\" ? createEmptyRuleGroup(parentGroup.id) : createEmptyRule(parentGroup.id);\n parentGroup.items.push(item);\n });\n }\n\n public removeItem(path: string[]) {\n function removeItemFromGroup(state: Draft<PropertyFilterBuilderState>, pathToItem: string[]) {\n const pathToParent = pathToItem.slice(0, -1);\n const parentGroup = findRuleGroup(state.rootGroup, pathToParent);\n if (!parentGroup)\n return;\n const itemId = pathToItem[pathToItem.length - 1];\n const itemIndex = parentGroup.items.findIndex((item) => item.id === itemId);\n if (itemIndex === -1)\n return;\n parentGroup.items.splice(itemIndex, 1);\n if (parentGroup.items.length === 0)\n removeItemFromGroup(state, pathToParent);\n }\n\n this.updateState((state) => {\n removeItemFromGroup(state, path);\n });\n }\n\n public setRuleGroupOperator(path: string[], operator: PropertyFilterRuleGroupOperator) {\n this.updateState((state) => {\n const group = findRuleGroup(state.rootGroup, path);\n if (!group)\n return;\n group.operator = operator;\n });\n }\n\n public setRuleProperty(path: string[], property?: PropertyDescription) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule)\n return;\n rule.property = property;\n rule.value = undefined;\n });\n }\n\n public setRuleOperator(path: string[], operator: PropertyFilterRuleOperator) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule)\n return;\n if (isUnaryPropertyFilterOperator(operator))\n rule.value = undefined;\n rule.operator = operator;\n });\n }\n\n public setRuleValue(path: string[], value: PropertyValue) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule)\n return;\n rule.value = value;\n });\n }\n}\n\n/** @alpha */\nexport function isPropertyFilterBuilderRuleGroup(item: PropertyFilterBuilderRuleGroupItem): item is PropertyFilterBuilderRuleGroup {\n return (item as any).items !== undefined;\n}\n\n/** @alpha */\nexport function usePropertyFilterBuilderState(initialFilter?: PropertyFilter) {\n const [state, setState] = React.useState<PropertyFilterBuilderState>(\n () => initialFilter ? convertFilterToState(initialFilter) : { rootGroup: createEmptyRuleGroup() }\n );\n const [actions] = React.useState(() => new PropertyFilterBuilderActions(setState));\n\n return { state, actions };\n}\n\nfunction createEmptyRule(groupId: string): PropertyFilterBuilderRule {\n return {\n id: Guid.createValue(),\n groupId,\n };\n}\n\nfunction createEmptyRuleGroup(groupId?: string): PropertyFilterBuilderRuleGroup {\n const id = Guid.createValue();\n return {\n id,\n groupId,\n operator: PropertyFilterRuleGroupOperator.And,\n items: [createEmptyRule(id)],\n };\n}\n\nfunction findRuleGroup(rootGroup: PropertyFilterBuilderRuleGroup, path: string[]): PropertyFilterBuilderRuleGroup | undefined {\n if (path.length === 0)\n return rootGroup;\n\n const [currentItemId, ...rest] = path;\n const currentItem = rootGroup.items.find((item) => item.id === currentItemId);\n if (!currentItem || !isPropertyFilterBuilderRuleGroup(currentItem))\n return undefined;\n\n return findRuleGroup(currentItem, rest);\n}\n\nfunction findRule(rootGroup: PropertyFilterBuilderRuleGroup, path: string[]): PropertyFilterBuilderRule | undefined {\n if (path.length === 0)\n return undefined;\n\n const [currentItemId, ...rest] = path;\n const currentItem = rootGroup.items.find((item) => item.id === currentItemId);\n if (!currentItem)\n return undefined;\n\n if (isPropertyFilterBuilderRuleGroup(currentItem))\n return findRule(currentItem, rest);\n\n return currentItem;\n}\n\nfunction getRuleGroupItem(filter: PropertyFilter, parentId: string): PropertyFilterBuilderRuleGroupItem {\n const id = Guid.createValue();\n if (isPropertyFilterRuleGroup(filter))\n return {\n id,\n groupId: parentId,\n operator: filter.operator,\n items: filter.rules.map((rule) => getRuleGroupItem(rule, id)),\n };\n return getRuleItem(filter, id);\n}\n\nfunction getRuleItem(filter: PropertyFilterRule, parentId: string) {\n return {\n id: Guid.createValue(),\n groupId: parentId,\n property: filter.property,\n operator: filter.operator,\n value: filter.value,\n };\n}\n\nfunction convertFilterToState(filter: PropertyFilter): PropertyFilterBuilderState {\n const id = Guid.createValue();\n if (isPropertyFilterRuleGroup(filter)) {\n return {\n rootGroup: {\n id,\n operator: filter.operator,\n items: filter.rules.map((rule) => getRuleGroupItem(rule, id)),\n },\n };\n }\n return {\n rootGroup: {\n id,\n operator: PropertyFilterRuleGroupOperator.And,\n items: [getRuleItem(filter, id)],\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FilterBuilderState.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderState.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,iCAAuC;AACvC,6CAA+B;AAC/B,0DAAgG;AAChG,sDAA2C;AAC3C,2CAAyH;AACzH,mCAAwF;AAiDxF;;;GAGG;AACH,MAAa,4BAA4B;IACvC,YAAoB,QAAiG;QAAjG,aAAQ,GAAR,QAAQ,CAAyF;IAAI,CAAC;IAElH,WAAW,CAAC,OAA2D;QAC7E,IAAI,CAAC,QAAQ,CAAC,IAAA,eAAO,EAAC,OAAO,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,sEAAsE;IAC/D,OAAO,CAAC,IAAc,EAAE,QAA+B;QAC5D,IAAI,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;YACzB,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACzD,IAAI,CAAC,WAAW;gBACd,OAAO;YACT,MAAM,IAAI,GAAG,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAChH,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,sCAAsC;IAC/B,UAAU,CAAC,IAAc;QAC9B,SAAS,mBAAmB,CAAC,KAAwC,EAAE,UAAoB;YACzF,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,C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,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;aAC9D;SACF,CAAC;KACH;IACD,OAAO;QACL,SAAS,EAAE;YACT,EAAE;YACF,QAAQ,EAAE,2CAA+B,CAAC,GAAG;YAC7C,KAAK,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SACjC;KACF,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*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyFilterBuilder\n */\n\nimport { Draft, produce } from \"immer\";\nimport * as React from \"react\";\nimport { PropertyDescription, PropertyValue, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { isUnaryPropertyFilterOperator, PropertyFilterRuleGroupOperator, PropertyFilterRuleOperator } from \"./Operators\";\nimport { isPropertyFilterRuleGroup, PropertyFilter, PropertyFilterRule } from \"./Types\";\n\n/**\n * Data structure that describes [[PropertyFilterBuilder]] component state.\n * @internal\n */\nexport interface PropertyFilterBuilderState {\n /** Root group of rules in [[PropertyFilterBuilder]] component. */\n rootGroup: PropertyFilterBuilderRuleGroup;\n}\n\n/**\n * Type that describes [[PropertyFilterBuilder]] component group item.\n * @internal\n */\nexport type PropertyFilterBuilderRuleGroupItem = PropertyFilterBuilderRuleGroup | PropertyFilterBuilderRule;\n\n/**\n * Data structure that describes [[PropertyFilterBuilder]] component rule group.\n * @internal\n */\nexport interface PropertyFilterBuilderRuleGroup {\n /** Id of this rule group. */\n id: string;\n /** Id of rule group that this group is nested in. */\n groupId?: string;\n /** Operator that should join items in this group. */\n operator: PropertyFilterRuleGroupOperator;\n /** Items in this group. */\n items: PropertyFilterBuilderRuleGroupItem[];\n}\n\n/**\n * Data structure that describes [[PropertyFilterBuilder]] component single rule.\n * @internal\n */\nexport interface PropertyFilterBuilderRule {\n /** Id of this rule. */\n id: string;\n /** Id of rule group that this rule is nested in. */\n groupId: string;\n /** Property used in this rule. */\n property?: PropertyDescription;\n /** Operator that should be used to compare property value. */\n operator?: PropertyFilterRuleOperator;\n /** Value that property should be compared to. */\n value?: PropertyValue;\n}\n\n/**\n * Actions for controlling [[PropertyFilterBuilder]] component state.\n * @internal\n */\nexport class PropertyFilterBuilderActions {\n constructor(private setState: (setter: (prevState: PropertyFilterBuilderState) => PropertyFilterBuilderState) => void) { }\n\n private updateState(updater: (state: Draft<PropertyFilterBuilderState>) => void) {\n this.setState(produce(updater));\n }\n\n /** Adds new rule or group of rules to the group specified by path. */\n public addItem(path: string[], itemType: \"RULE_GROUP\" | \"RULE\") {\n this.updateState((state) => {\n const parentGroup = findRuleGroup(state.rootGroup, path);\n if (!parentGroup)\n return;\n const item = itemType === \"RULE_GROUP\" ? createEmptyRuleGroup(parentGroup.id) : createEmptyRule(parentGroup.id);\n parentGroup.items.push(item);\n });\n }\n\n /** Removes item specified by path. */\n public removeItem(path: string[]) {\n function removeItemFromGroup(state: Draft<PropertyFilterBuilderState>, pathToItem: string[]) {\n const pathToParent = pathToItem.slice(0, -1);\n const parentGroup = findRuleGroup(state.rootGroup, pathToParent);\n if (!parentGroup)\n return;\n const itemId = pathToItem[pathToItem.length - 1];\n const itemIndex = parentGroup.items.findIndex((item) => item.id === itemId);\n if (itemIndex === -1)\n return;\n parentGroup.items.splice(itemIndex, 1);\n if (parentGroup.items.length === 0)\n removeItemFromGroup(state, pathToParent);\n }\n\n this.updateState((state) => {\n removeItemFromGroup(state, path);\n });\n }\n\n /** Sets operator of rule group specified by the path. */\n public setRuleGroupOperator(path: string[], operator: PropertyFilterRuleGroupOperator) {\n this.updateState((state) => {\n const group = findRuleGroup(state.rootGroup, path);\n if (!group)\n return;\n group.operator = operator;\n });\n }\n\n /** Sets property of rule specified by the path. */\n public setRuleProperty(path: string[], property?: PropertyDescription) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule)\n return;\n rule.property = property;\n rule.value = undefined;\n });\n }\n\n /** Sets operator of rule specified by the path. */\n public setRuleOperator(path: string[], operator: PropertyFilterRuleOperator) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule)\n return;\n if (isUnaryPropertyFilterOperator(operator))\n rule.value = undefined;\n rule.operator = operator;\n });\n }\n\n /** Sets value of rule specified by the path. */\n public setRuleValue(path: string[], value: PropertyValue) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule)\n return;\n rule.value = value;\n });\n }\n}\n\n/**\n * Function to check if supplied [[PropertyFilterBuilderRuleGroupItem]] is [[PropertyFilterBuilderRuleGroup]].\n * @internal\n */\nexport function isPropertyFilterBuilderRuleGroup(item: PropertyFilterBuilderRuleGroupItem): item is PropertyFilterBuilderRuleGroup {\n return (item as any).items !== undefined;\n}\n\n/**\n * Custom hook that creates state for [[PropertyFilterBuilder]] component. It creates empty state or initializes\n * state from supplied initial filter.\n * @internal\n */\nexport function usePropertyFilterBuilderState(initialFilter?: PropertyFilter) {\n const [state, setState] = React.useState<PropertyFilterBuilderState>(\n () => initialFilter ? convertFilterToState(initialFilter) : { rootGroup: createEmptyRuleGroup() }\n );\n const [actions] = React.useState(() => new PropertyFilterBuilderActions(setState));\n\n return { state, actions };\n}\n\n/** @internal */\nexport function buildPropertyFilter(groupItem: PropertyFilterBuilderRuleGroupItem): PropertyFilter | undefined {\n if (isPropertyFilterBuilderRuleGroup(groupItem))\n return buildPropertyFilterFromRuleGroup(groupItem);\n return buildPropertyFilterFromRule(groupItem);\n}\n\nfunction buildPropertyFilterFromRuleGroup(rootGroup: PropertyFilterBuilderRuleGroup): PropertyFilter | undefined {\n if (rootGroup.items.length === 0)\n return undefined;\n\n const rules = new Array<PropertyFilter>();\n for (const item of rootGroup.items) {\n const rule = buildPropertyFilter(item);\n if (!rule)\n return undefined;\n rules.push(rule);\n }\n\n if (rules.length === 1)\n return rules[0];\n\n return {\n operator: rootGroup.operator,\n rules,\n };\n}\n\nfunction buildPropertyFilterFromRule(rule: PropertyFilterBuilderRule): PropertyFilter | undefined {\n const { property, operator, value } = rule;\n if (!property || operator === undefined)\n return undefined;\n\n if (!isUnaryPropertyFilterOperator(operator) && (value === undefined || value.valueFormat !== PropertyValueFormat.Primitive || value.value === undefined))\n return undefined;\n\n return { property, operator, value };\n}\n\nfunction createEmptyRule(groupId: string): PropertyFilterBuilderRule {\n return {\n id: Guid.createValue(),\n groupId,\n };\n}\n\nfunction createEmptyRuleGroup(groupId?: string): PropertyFilterBuilderRuleGroup {\n const id = Guid.createValue();\n return {\n id,\n groupId,\n operator: PropertyFilterRuleGroupOperator.And,\n items: [createEmptyRule(id)],\n };\n}\n\nfunction findRuleGroup(rootGroup: PropertyFilterBuilderRuleGroup, path: string[]): PropertyFilterBuilderRuleGroup | undefined {\n if (path.length === 0)\n return rootGroup;\n\n const [currentItemId, ...rest] = path;\n const currentItem = rootGroup.items.find((item) => item.id === currentItemId);\n if (!currentItem || !isPropertyFilterBuilderRuleGroup(currentItem))\n return undefined;\n\n return findRuleGroup(currentItem, rest);\n}\n\nfunction findRule(rootGroup: PropertyFilterBuilderRuleGroup, path: string[]): PropertyFilterBuilderRule | undefined {\n if (path.length === 0)\n return undefined;\n\n const [currentItemId, ...rest] = path;\n const currentItem = rootGroup.items.find((item) => item.id === currentItemId);\n if (!currentItem)\n return undefined;\n\n if (isPropertyFilterBuilderRuleGroup(currentItem))\n return findRule(currentItem, rest);\n\n return currentItem;\n}\n\nfunction getRuleGroupItem(filter: PropertyFilter, parentId: string): PropertyFilterBuilderRuleGroupItem {\n const id = Guid.createValue();\n if (isPropertyFilterRuleGroup(filter))\n return {\n id,\n groupId: parentId,\n operator: filter.operator,\n items: filter.rules.map((rule) => getRuleGroupItem(rule, id)),\n };\n return getRuleItem(filter, id);\n}\n\nfunction getRuleItem(filter: PropertyFilterRule, parentId: string) {\n return {\n id: Guid.createValue(),\n groupId: parentId,\n property: filter.property,\n operator: filter.operator,\n value: filter.value,\n };\n}\n\nfunction convertFilterToState(filter: PropertyFilter): PropertyFilterBuilderState {\n const id = Guid.createValue();\n if (isPropertyFilterRuleGroup(filter)) {\n return {\n rootGroup: {\n id,\n operator: filter.operator,\n items: filter.rules.map((rule) => getRuleGroupItem(rule, id)),\n },\n };\n }\n return {\n rootGroup: {\n id,\n operator: PropertyFilterRuleGroupOperator.And,\n items: [getRuleItem(filter, id)],\n },\n };\n}\n"]}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module PropertyFilterBuilder
|
|
3
|
+
*/
|
|
1
4
|
import { PropertyDescription } from "@itwin/appui-abstract";
|
|
2
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Logical operator for joining rules.
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
3
9
|
export declare enum PropertyFilterRuleGroupOperator {
|
|
4
10
|
And = 0,
|
|
5
11
|
Or = 1
|
|
6
12
|
}
|
|
7
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Operators for comparing property value in rule.
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
8
17
|
export declare enum PropertyFilterRuleOperator {
|
|
9
18
|
IsTrue = 0,
|
|
10
19
|
IsFalse = 1,
|
|
@@ -18,10 +27,19 @@ export declare enum PropertyFilterRuleOperator {
|
|
|
18
27
|
IsNull = 9,
|
|
19
28
|
IsNotNull = 10
|
|
20
29
|
}
|
|
21
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Function that returns set of available operator based on property type.
|
|
32
|
+
* @beta
|
|
33
|
+
*/
|
|
22
34
|
export declare function getPropertyFilterOperators(property: PropertyDescription): PropertyFilterRuleOperator[];
|
|
23
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Function that returns display label for rule operator.
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
24
39
|
export declare function getPropertyFilterOperatorLabel(operator: PropertyFilterRuleOperator): string;
|
|
25
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Function that checks if supplied operator is unary.
|
|
42
|
+
* @beta
|
|
43
|
+
*/
|
|
26
44
|
export declare function isUnaryPropertyFilterOperator(operator: PropertyFilterRuleOperator): boolean;
|
|
27
45
|
//# sourceMappingURL=Operators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operators.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/Operators.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAqB,MAAM,uBAAuB,CAAC;AAG/E
|
|
1
|
+
{"version":3,"file":"Operators.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/Operators.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAqB,MAAM,uBAAuB,CAAC;AAG/E;;;GAGG;AACH,oBAAY,+BAA+B;IACzC,GAAG,IAAA;IACH,EAAE,IAAA;CACH;AAED;;;GAGG;AACH,oBAAY,0BAA0B;IACpC,MAAM,IAAA;IACN,OAAO,IAAA;IAEP,OAAO,IAAA;IACP,UAAU,IAAA;IAEV,OAAO,IAAA;IACP,cAAc,IAAA;IACd,IAAI,IAAA;IACJ,WAAW,IAAA;IAEX,IAAI,IAAA;IAEJ,MAAM,IAAA;IACN,SAAS,KAAA;CACV;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,mBAAmB,gCA2CvE;AAGD;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,0BAA0B,UAyBlF;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,0BAA0B,WASjF"}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUnaryPropertyFilterOperator = exports.getPropertyFilterOperatorLabel = exports.getPropertyFilterOperators = exports.PropertyFilterRuleOperator = exports.PropertyFilterRuleGroupOperator = void 0;
|
|
4
2
|
/*---------------------------------------------------------------------------------------------
|
|
5
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module PropertyFilterBuilder
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.isUnaryPropertyFilterOperator = exports.getPropertyFilterOperatorLabel = exports.getPropertyFilterOperators = exports.PropertyFilterRuleOperator = exports.PropertyFilterRuleGroupOperator = void 0;
|
|
8
11
|
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
9
12
|
const UiComponents_1 = require("../UiComponents");
|
|
10
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Logical operator for joining rules.
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
11
17
|
var PropertyFilterRuleGroupOperator;
|
|
12
18
|
(function (PropertyFilterRuleGroupOperator) {
|
|
13
19
|
PropertyFilterRuleGroupOperator[PropertyFilterRuleGroupOperator["And"] = 0] = "And";
|
|
14
20
|
PropertyFilterRuleGroupOperator[PropertyFilterRuleGroupOperator["Or"] = 1] = "Or";
|
|
15
21
|
})(PropertyFilterRuleGroupOperator = exports.PropertyFilterRuleGroupOperator || (exports.PropertyFilterRuleGroupOperator = {}));
|
|
16
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Operators for comparing property value in rule.
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
17
26
|
var PropertyFilterRuleOperator;
|
|
18
27
|
(function (PropertyFilterRuleOperator) {
|
|
19
28
|
PropertyFilterRuleOperator[PropertyFilterRuleOperator["IsTrue"] = 0] = "IsTrue";
|
|
@@ -28,7 +37,10 @@ var PropertyFilterRuleOperator;
|
|
|
28
37
|
PropertyFilterRuleOperator[PropertyFilterRuleOperator["IsNull"] = 9] = "IsNull";
|
|
29
38
|
PropertyFilterRuleOperator[PropertyFilterRuleOperator["IsNotNull"] = 10] = "IsNotNull";
|
|
30
39
|
})(PropertyFilterRuleOperator = exports.PropertyFilterRuleOperator || (exports.PropertyFilterRuleOperator = {}));
|
|
31
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Function that returns set of available operator based on property type.
|
|
42
|
+
* @beta
|
|
43
|
+
*/
|
|
32
44
|
function getPropertyFilterOperators(property) {
|
|
33
45
|
const typename = property.typename;
|
|
34
46
|
if (typename === appui_abstract_1.StandardTypeNames.Bool || typename === appui_abstract_1.StandardTypeNames.Boolean) {
|
|
@@ -70,7 +82,10 @@ function getPropertyFilterOperators(property) {
|
|
|
70
82
|
}
|
|
71
83
|
exports.getPropertyFilterOperators = getPropertyFilterOperators;
|
|
72
84
|
/* istanbul ignore next */
|
|
73
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Function that returns display label for rule operator.
|
|
87
|
+
* @beta
|
|
88
|
+
*/
|
|
74
89
|
function getPropertyFilterOperatorLabel(operator) {
|
|
75
90
|
switch (operator) {
|
|
76
91
|
case PropertyFilterRuleOperator.IsTrue:
|
|
@@ -98,7 +113,10 @@ function getPropertyFilterOperatorLabel(operator) {
|
|
|
98
113
|
}
|
|
99
114
|
}
|
|
100
115
|
exports.getPropertyFilterOperatorLabel = getPropertyFilterOperatorLabel;
|
|
101
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Function that checks if supplied operator is unary.
|
|
118
|
+
* @beta
|
|
119
|
+
*/
|
|
102
120
|
function isUnaryPropertyFilterOperator(operator) {
|
|
103
121
|
switch (operator) {
|
|
104
122
|
case PropertyFilterRuleOperator.IsTrue:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operators.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/Operators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Operators.js","sourceRoot":"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2BAAY,CAAC,SAAS,CAAC,kCAAkC,CAAC,CAAC;QACpE,KAAK,0BAA0B,CAAC,MAAM;YACpC,OAAO,2BAAY,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC;QAClE,KAAK,0BAA0B,CAAC,SAAS;YACvC,OAAO,2BAAY,CAAC,SAAS,CAAC,mCAAmC,CAAC,CAAC;KACtE;AACH,CAAC;AAzBD,wEAyBC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,QAAoC;IAChF,QAAQ,QAAQ,EAAE;QAChB,KAAK,0BAA0B,CAAC,MAAM,CAAC;QACvC,KAAK,0BAA0B,CAAC,OAAO,CAAC;QACxC,KAAK,0BAA0B,CAAC,MAAM,CAAC;QACvC,KAAK,0BAA0B,CAAC,SAAS;YACvC,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AATD,sEASC","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/** @packageDocumentation\n * @module PropertyFilterBuilder\n */\n\nimport { PropertyDescription, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { UiComponents } from \"../UiComponents\";\n\n/**\n * Logical operator for joining rules.\n * @beta\n */\nexport enum PropertyFilterRuleGroupOperator {\n And,\n Or,\n}\n\n/**\n * Operators for comparing property value in rule.\n * @beta\n */\nexport enum PropertyFilterRuleOperator {\n IsTrue,\n IsFalse,\n\n IsEqual,\n IsNotEqual,\n\n Greater,\n GreaterOrEqual,\n Less,\n LessOrEqual,\n\n Like,\n\n IsNull,\n IsNotNull,\n}\n\n/**\n * Function that returns set of available operator based on property type.\n * @beta\n */\nexport function getPropertyFilterOperators(property: PropertyDescription) {\n const typename = property.typename;\n\n if (typename === StandardTypeNames.Bool || typename === StandardTypeNames.Boolean) {\n return [\n PropertyFilterRuleOperator.IsTrue,\n PropertyFilterRuleOperator.IsFalse,\n ];\n }\n\n const operators = [\n PropertyFilterRuleOperator.IsEqual,\n PropertyFilterRuleOperator.IsNotEqual,\n PropertyFilterRuleOperator.IsNull,\n PropertyFilterRuleOperator.IsNotNull,\n ];\n\n if (typename === StandardTypeNames.Number\n || typename === StandardTypeNames.Int\n || typename === StandardTypeNames.Integer\n || typename === StandardTypeNames.Double\n || typename === StandardTypeNames.Float\n || typename === StandardTypeNames.Hex\n || typename === StandardTypeNames.Hexadecimal\n || typename === StandardTypeNames.ShortDate\n || typename === StandardTypeNames.DateTime) {\n return [\n ...operators,\n PropertyFilterRuleOperator.Greater,\n PropertyFilterRuleOperator.GreaterOrEqual,\n PropertyFilterRuleOperator.Less,\n PropertyFilterRuleOperator.LessOrEqual,\n ];\n }\n\n if (typename === StandardTypeNames.String || typename === StandardTypeNames.Text) {\n return [\n ...operators,\n PropertyFilterRuleOperator.Like,\n ];\n }\n\n return operators;\n}\n\n/* istanbul ignore next */\n/**\n * Function that returns display label for rule operator.\n * @beta\n */\nexport function getPropertyFilterOperatorLabel(operator: PropertyFilterRuleOperator) {\n switch (operator) {\n case PropertyFilterRuleOperator.IsTrue:\n return UiComponents.translate(\"filterBuilder.operators.isTrue\");\n case PropertyFilterRuleOperator.IsFalse:\n return UiComponents.translate(\"filterBuilder.operators.isFalse\");\n case PropertyFilterRuleOperator.IsEqual:\n return UiComponents.translate(\"filterBuilder.operators.equal\");\n case PropertyFilterRuleOperator.IsNotEqual:\n return UiComponents.translate(\"filterBuilder.operators.notEqual\");\n case PropertyFilterRuleOperator.Greater:\n return \">\";\n case PropertyFilterRuleOperator.GreaterOrEqual:\n return \">=\";\n case PropertyFilterRuleOperator.Less:\n return \"<\";\n case PropertyFilterRuleOperator.LessOrEqual:\n return \"<=\";\n case PropertyFilterRuleOperator.Like:\n return UiComponents.translate(\"filterBuilder.operators.contains\");\n case PropertyFilterRuleOperator.IsNull:\n return UiComponents.translate(\"filterBuilder.operators.isNull\");\n case PropertyFilterRuleOperator.IsNotNull:\n return UiComponents.translate(\"filterBuilder.operators.isNotNull\");\n }\n}\n\n/**\n * Function that checks if supplied operator is unary.\n * @beta\n */\nexport function isUnaryPropertyFilterOperator(operator: PropertyFilterRuleOperator) {\n switch (operator) {\n case PropertyFilterRuleOperator.IsTrue:\n case PropertyFilterRuleOperator.IsFalse:\n case PropertyFilterRuleOperator.IsNull:\n case PropertyFilterRuleOperator.IsNotNull:\n return true;\n }\n return false;\n}\n"]}
|
|
@@ -1,18 +1,38 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module PropertyFilterBuilder
|
|
3
|
+
*/
|
|
1
4
|
import { PropertyDescription, PropertyValue } from "@itwin/appui-abstract";
|
|
2
5
|
import { PropertyFilterRuleGroupOperator, PropertyFilterRuleOperator } from "./Operators";
|
|
3
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Type that describes property filter.
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
4
10
|
export declare type PropertyFilter = PropertyFilterRule | PropertyFilterRuleGroup;
|
|
5
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Data structure that describes group of filter rules.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
6
15
|
export interface PropertyFilterRuleGroup {
|
|
16
|
+
/** Operator that should join rules in this group. */
|
|
7
17
|
operator: PropertyFilterRuleGroupOperator;
|
|
18
|
+
/** Rules in this group. */
|
|
8
19
|
rules: Array<PropertyFilter>;
|
|
9
20
|
}
|
|
10
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Data structure that describes single filter rule.
|
|
23
|
+
* @beta
|
|
24
|
+
*/
|
|
11
25
|
export interface PropertyFilterRule {
|
|
26
|
+
/** Property used in this rule. */
|
|
12
27
|
property: PropertyDescription;
|
|
28
|
+
/** Operator that should be used to compare property value. */
|
|
13
29
|
operator: PropertyFilterRuleOperator;
|
|
30
|
+
/** Value that property should be compared to. */
|
|
14
31
|
value?: PropertyValue;
|
|
15
32
|
}
|
|
16
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Function that checks if supplied filter is rule group.
|
|
35
|
+
* @beta
|
|
36
|
+
*/
|
|
17
37
|
export declare function isPropertyFilterRuleGroup(filter: PropertyFilter): filter is PropertyFilterRuleGroup;
|
|
18
38
|
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/Types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE1F
|
|
1
|
+
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/Types.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE1F;;;GAGG;AACH,oBAAY,cAAc,GAAG,kBAAkB,GAAG,uBAAuB,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,qDAAqD;IACrD,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,2BAA2B;IAC3B,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,EAAE,0BAA0B,CAAC;IACrC,iDAAiD;IACjD,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,IAAI,uBAAuB,CAEnG"}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module PropertyFilterBuilder
|
|
8
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.isPropertyFilterRuleGroup = void 0;
|
|
4
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Function that checks if supplied filter is rule group.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
5
15
|
function isPropertyFilterRuleGroup(filter) {
|
|
6
16
|
return filter.rules !== undefined;
|
|
7
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/Types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/Types.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAmCH;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,MAAsB;IAC9D,OAAQ,MAAc,CAAC,KAAK,KAAK,SAAS,CAAC;AAC7C,CAAC;AAFD,8DAEC","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/** @packageDocumentation\n * @module PropertyFilterBuilder\n */\n\nimport { PropertyDescription, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyFilterRuleGroupOperator, PropertyFilterRuleOperator } from \"./Operators\";\n\n/**\n * Type that describes property filter.\n * @beta\n */\nexport type PropertyFilter = PropertyFilterRule | PropertyFilterRuleGroup;\n\n/**\n * Data structure that describes group of filter rules.\n * @beta\n */\nexport interface PropertyFilterRuleGroup {\n /** Operator that should join rules in this group. */\n operator: PropertyFilterRuleGroupOperator;\n /** Rules in this group. */\n rules: Array<PropertyFilter>;\n}\n\n/**\n * Data structure that describes single filter rule.\n * @beta\n */\nexport interface PropertyFilterRule {\n /** Property used in this rule. */\n property: PropertyDescription;\n /** Operator that should be used to compare property value. */\n operator: PropertyFilterRuleOperator;\n /** Value that property should be compared to. */\n value?: PropertyValue;\n}\n\n/**\n * Function that checks if supplied filter is rule group.\n * @beta\n */\nexport function isPropertyFilterRuleGroup(filter: PropertyFilter): filter is PropertyFilterRuleGroup {\n return (filter as any).rules !== undefined;\n}\n"]}
|
|
@@ -14,7 +14,7 @@ export declare const renderLinks: (text: string, links: LinkElementsInfo, highli
|
|
|
14
14
|
export declare const withLinks: (stringValue: string, links?: LinkElementsInfo | undefined, highlight?: ((text: string) => React.ReactNode) | undefined) => React.ReactNode;
|
|
15
15
|
/**
|
|
16
16
|
* Properties for [[LinksRenderer]] component.
|
|
17
|
-
* @
|
|
17
|
+
* @public
|
|
18
18
|
*/
|
|
19
19
|
export interface LinksRendererProps {
|
|
20
20
|
value: string;
|
|
@@ -23,7 +23,7 @@ export interface LinksRendererProps {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* React component for rendering string with links.
|
|
26
|
-
* @
|
|
26
|
+
* @public
|
|
27
27
|
*/
|
|
28
28
|
export declare function LinksRenderer(props: LinksRendererProps): JSX.Element;
|
|
29
29
|
//# sourceMappingURL=LinkHandler.d.ts.map
|
|
@@ -96,7 +96,7 @@ const withLinks = (stringValue, links, highlight) => {
|
|
|
96
96
|
exports.withLinks = withLinks;
|
|
97
97
|
/**
|
|
98
98
|
* React component for rendering string with links.
|
|
99
|
-
* @
|
|
99
|
+
* @public
|
|
100
100
|
*/
|
|
101
101
|
function LinksRenderer(props) {
|
|
102
102
|
return React.createElement(React.Fragment, null, (0, exports.withLinks)(props.value, props.links, props.highlighter));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkHandler.js","sourceRoot":"","sources":["../../../../src/components-react/properties/LinkHandler.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,sDAAkE;AAElE,kDAAqD;AAErD,iCAAiC;AACjC,SAAS,SAAS,CAAC,IAAY,EAAE,KAAuB,EAAE,SAA6C;IACrG,OAAO,CACL,oBAAC,6BAAgB,IACf,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACb,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC,IAEA,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAClB,CACpB,CAAC;AACJ,CAAC;AAID,SAAS,eAAe,CAAC,MAAa,EAAE,MAAa;IACnD,IAAI,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK;QAC7B,OAAO,CAAC,CAAC;IACX,IAAI,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK;QAC7B,OAAO,CAAC,CAAC,CAAC;IACZ,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,cAAc,CAAC,IAAY,EAAE,SAA6C;IACjF,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,KAAuB,EAAE,SAA6C;IACtG,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAE1B,IAAI,CAAC,OAAO;QACV,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAE3C,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B,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A6C,EAAmB,EAAE;IACnI,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAC5C,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AAEF;;;GAGG;AACI,MAAM,SAAS,GAAG,CAAC,WAAmB,EAAE,KAAwB,EAAE,SAA6C,EAAmB,EAAE;IACzI,IAAI,KAAK;QACP,OAAO,IAAA,mBAAW,EAAC,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IACpD,IAAI,SAAS;QACX,OAAO,iBAAiB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACnD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AANW,QAAA,SAAS,aAMpB;AAYF;;;GAGG;AACH,SAAgB,aAAa,CAAC,KAAyB;IACrD,OAAO,0CAAG,IAAA,iBAAS,EAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,CAAI,CAAC;AACvE,CAAC;AAFD,sCAEC","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/** @packageDocumentation\n * @module Properties\n */\n\nimport * as React from \"react\";\nimport { BentleyError, BentleyStatus } from \"@itwin/core-bentley\";\nimport { LinkElementsInfo } from \"@itwin/appui-abstract\";\nimport { UnderlinedButton } from \"@itwin/core-react\";\n\n/** Render a single anchor tag */\nfunction renderTag(text: string, links: LinkElementsInfo, highlight?: (text: string) => React.ReactNode) {\n return (\n <UnderlinedButton\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n links.onClick(text);\n }}\n >\n {highlight ? highlight(text) : text}\n </UnderlinedButton>\n );\n}\n\ninterface Match { start: number, end: number }\n\nfunction matchComparison(matchA: Match, matchB: Match) {\n if (matchA.start > matchB.start)\n return 1;\n if (matchB.start > matchA.start)\n return -1;\n return 0;\n}\n\nfunction renderTextPart(text: string, highlight?: (text: string) => React.ReactNode): React.ReactNode {\n return highlight ? highlight(text) : text;\n}\n\nfunction renderText(text: string, links: LinkElementsInfo, highlight?: (text: string) => React.ReactNode): React.ReactNode {\n const { matcher } = links;\n\n if (!matcher)\n return renderTag(text, links, highlight);\n\n const matches = matcher(text);\n\n // Sort just to be sure\n matches.sort(matchComparison);\n\n const parts: React.ReactNode[] = [];\n let lastIndex = 0;\n for (const match of matches) {\n // If matches overlap there must be something wrong with the matcher\n if (lastIndex > match.start)\n throw new BentleyError(BentleyStatus.ERROR, \"renderText: matcher returned overlapping matches\");\n\n if (lastIndex < match.start)\n parts.push(renderTextPart(text.substring(lastIndex, match.start), highlight));\n\n const anchorText = text.substring(match.start, match.end);\n parts.push(renderTag(anchorText, links, highlight));\n\n lastIndex = match.end;\n }\n if (text.length > lastIndex)\n parts.push(renderTextPart(text.substring(lastIndex), highlight));\n\n // Need to map, because React complains about the lack of keys\n return parts.map((part, index) => <React.Fragment key={index}>{part}</React.Fragment>);\n}\n\nfunction renderHighlighted(text: string, highlight: (text: string) => React.ReactNode) {\n return highlight(text);\n}\n\n/** Renders anchor tag by wrapping or splitting provided text\n * @public\n */\nexport const renderLinks = (text: string, links: LinkElementsInfo, highlight?: (text: string) => React.ReactNode): React.ReactNode => {\n return renderText(text, links, highlight);\n};\n\n/** If record has links, wraps stringValue in them, otherwise returns unchanged stringValue\n * Optionally it can highlight text\n * @public\n */\nexport const withLinks = (stringValue: string, links?: LinkElementsInfo, highlight?: (text: string) => React.ReactNode): React.ReactNode => {\n if (links)\n return renderLinks(stringValue, links, highlight);\n if (highlight)\n return renderHighlighted(stringValue, highlight);\n return stringValue;\n};\n\n/**\n * Properties for [[LinksRenderer]] component.\n * @
|
|
1
|
+
{"version":3,"file":"LinkHandler.js","sourceRoot":"","sources":["../../../../src/components-react/properties/LinkHandler.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;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AM,SAAS,GAAG,CAAC,WAAmB,EAAE,KAAwB,EAAE,SAA6C,EAAmB,EAAE;IACzI,IAAI,KAAK;QACP,OAAO,IAAA,mBAAW,EAAC,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IACpD,IAAI,SAAS;QACX,OAAO,iBAAiB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACnD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AANW,QAAA,SAAS,aAMpB;AAYF;;;GAGG;AACH,SAAgB,aAAa,CAAC,KAAyB;IACrD,OAAO,0CAAG,IAAA,iBAAS,EAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,CAAI,CAAC;AACvE,CAAC;AAFD,sCAEC","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/** @packageDocumentation\n * @module Properties\n */\n\nimport * as React from \"react\";\nimport { BentleyError, BentleyStatus } from \"@itwin/core-bentley\";\nimport { LinkElementsInfo } from \"@itwin/appui-abstract\";\nimport { UnderlinedButton } from \"@itwin/core-react\";\n\n/** Render a single anchor tag */\nfunction renderTag(text: string, links: LinkElementsInfo, highlight?: (text: string) => React.ReactNode) {\n return (\n <UnderlinedButton\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n links.onClick(text);\n }}\n >\n {highlight ? highlight(text) : text}\n </UnderlinedButton>\n );\n}\n\ninterface Match { start: number, end: number }\n\nfunction matchComparison(matchA: Match, matchB: Match) {\n if (matchA.start > matchB.start)\n return 1;\n if (matchB.start > matchA.start)\n return -1;\n return 0;\n}\n\nfunction renderTextPart(text: string, highlight?: (text: string) => React.ReactNode): React.ReactNode {\n return highlight ? highlight(text) : text;\n}\n\nfunction renderText(text: string, links: LinkElementsInfo, highlight?: (text: string) => React.ReactNode): React.ReactNode {\n const { matcher } = links;\n\n if (!matcher)\n return renderTag(text, links, highlight);\n\n const matches = matcher(text);\n\n // Sort just to be sure\n matches.sort(matchComparison);\n\n const parts: React.ReactNode[] = [];\n let lastIndex = 0;\n for (const match of matches) {\n // If matches overlap there must be something wrong with the matcher\n if (lastIndex > match.start)\n throw new BentleyError(BentleyStatus.ERROR, \"renderText: matcher returned overlapping matches\");\n\n if (lastIndex < match.start)\n parts.push(renderTextPart(text.substring(lastIndex, match.start), highlight));\n\n const anchorText = text.substring(match.start, match.end);\n parts.push(renderTag(anchorText, links, highlight));\n\n lastIndex = match.end;\n }\n if (text.length > lastIndex)\n parts.push(renderTextPart(text.substring(lastIndex), highlight));\n\n // Need to map, because React complains about the lack of keys\n return parts.map((part, index) => <React.Fragment key={index}>{part}</React.Fragment>);\n}\n\nfunction renderHighlighted(text: string, highlight: (text: string) => React.ReactNode) {\n return highlight(text);\n}\n\n/** Renders anchor tag by wrapping or splitting provided text\n * @public\n */\nexport const renderLinks = (text: string, links: LinkElementsInfo, highlight?: (text: string) => React.ReactNode): React.ReactNode => {\n return renderText(text, links, highlight);\n};\n\n/** If record has links, wraps stringValue in them, otherwise returns unchanged stringValue\n * Optionally it can highlight text\n * @public\n */\nexport const withLinks = (stringValue: string, links?: LinkElementsInfo, highlight?: (text: string) => React.ReactNode): React.ReactNode => {\n if (links)\n return renderLinks(stringValue, links, highlight);\n if (highlight)\n return renderHighlighted(stringValue, highlight);\n return stringValue;\n};\n\n/**\n * Properties for [[LinksRenderer]] component.\n * @public\n */\nexport interface LinksRendererProps {\n value: string;\n links?: LinkElementsInfo;\n highlighter?: (text: string) => React.ReactNode;\n}\n\n/**\n * React component for rendering string with links.\n * @public\n */\nexport function LinksRenderer(props: LinksRendererProps) {\n return <>{withLinks(props.value, props.links, props.highlighter)}</>;\n}\n"]}
|
|
@@ -6,7 +6,7 @@ import { VirtualizedPropertyGridContext } from "./component/VirtualizedPropertyG
|
|
|
6
6
|
import { GridCategoryItem } from "./internal/flat-items/FlatGridItem";
|
|
7
7
|
/**
|
|
8
8
|
* Props that property category renderer receives.
|
|
9
|
-
* @
|
|
9
|
+
* @public
|
|
10
10
|
*/
|
|
11
11
|
export interface PropertyCategoryRendererProps {
|
|
12
12
|
/** The category being rendered. */
|
|
@@ -18,13 +18,13 @@ export interface PropertyCategoryRendererProps {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Factory function that produces custom property category components.
|
|
21
|
-
* @
|
|
21
|
+
* @public
|
|
22
22
|
*/
|
|
23
23
|
export declare type PropertyCategoryRenderer = (categoryItem: GridCategoryItem) => React.ComponentType<PropertyCategoryRendererProps> | undefined;
|
|
24
24
|
/**
|
|
25
25
|
* Keeps a record of currently registered property category renderers and determines which renderers get invoked for
|
|
26
26
|
* each category.
|
|
27
|
-
* @
|
|
27
|
+
* @public
|
|
28
28
|
*/
|
|
29
29
|
export declare class PropertyCategoryRendererManager {
|
|
30
30
|
private _categoryRenderers;
|
|
@@ -11,7 +11,7 @@ exports.PropertyCategoryRendererManager = void 0;
|
|
|
11
11
|
/**
|
|
12
12
|
* Keeps a record of currently registered property category renderers and determines which renderers get invoked for
|
|
13
13
|
* each category.
|
|
14
|
-
* @
|
|
14
|
+
* @public
|
|
15
15
|
*/
|
|
16
16
|
class PropertyCategoryRendererManager {
|
|
17
17
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyCategoryRendererManager.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/PropertyCategoryRendererManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAyBH;;;;GAIG;AACH,MAAa,+BAA+B;IAA5C;QACU,uBAAkB,GAAG,IAAI,GAAG,EAAoC,CAAC;IA4B3E,CAAC;IAxBC,mFAAmF;IAC5E,oBAAoB,CAAC,YAA8B;;QACxD,IAAI,YAAY,CAAC,eAAe,CAAC,QAAQ,KAAK,SAAS,EAAE;YACvD,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,MAAA,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,0CAAG,YAAY,CAAC,CAAC;IACjG,CAAC;IAED,qGAAqG;IAC9F,WAAW,CAAC,YAAoB,EAAE,gBAA0C,EAAE,QAAQ,GAAG,KAAK;QACnG,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE;YAC1D,MAAM,SAAS,GAAG,+BAA+B,CAAC,IAAI,CAAC;YACvD,MAAM,UAAU,GAAG,+BAA+B,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,IAAI,UAAU,qBAAqB,YAAY,wDAAwD,CAAC,CAAC;SACtI;QAED,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAC9D,CAAC;IAED,sDAAsD;IAC/C,cAAc,CAAC,YAAoB;QACxC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;;AA5BH,0EA6BC;AA1Be,8CAAc,GAAG,IAAI,+BAA+B,EAAE,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/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport * as React from \"react\";\nimport { VirtualizedPropertyGridContext } from \"./component/VirtualizedPropertyGrid\";\nimport { GridCategoryItem } from \"./internal/flat-items/FlatGridItem\";\n\n/**\n * Props that property category renderer receives.\n * @
|
|
1
|
+
{"version":3,"file":"PropertyCategoryRendererManager.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/PropertyCategoryRendererManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAyBH;;;;GAIG;AACH,MAAa,+BAA+B;IAA5C;QACU,uBAAkB,GAAG,IAAI,GAAG,EAAoC,CAAC;IA4B3E,CAAC;IAxBC,mFAAmF;IAC5E,oBAAoB,CAAC,YAA8B;;QACxD,IAAI,YAAY,CAAC,eAAe,CAAC,QAAQ,KAAK,SAAS,EAAE;YACvD,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,MAAA,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,0CAAG,YAAY,CAAC,CAAC;IACjG,CAAC;IAED,qGAAqG;IAC9F,WAAW,CAAC,YAAoB,EAAE,gBAA0C,EAAE,QAAQ,GAAG,KAAK;QACnG,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE;YAC1D,MAAM,SAAS,GAAG,+BAA+B,CAAC,IAAI,CAAC;YACvD,MAAM,UAAU,GAAG,+BAA+B,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,IAAI,UAAU,qBAAqB,YAAY,wDAAwD,CAAC,CAAC;SACtI;QAED,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAC9D,CAAC;IAED,sDAAsD;IAC/C,cAAc,CAAC,YAAoB;QACxC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;;AA5BH,0EA6BC;AA1Be,8CAAc,GAAG,IAAI,+BAA+B,EAAE,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/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport * as React from \"react\";\nimport { VirtualizedPropertyGridContext } from \"./component/VirtualizedPropertyGrid\";\nimport { GridCategoryItem } from \"./internal/flat-items/FlatGridItem\";\n\n/**\n * Props that property category renderer receives.\n * @public\n */\nexport interface PropertyCategoryRendererProps {\n /** The category being rendered. */\n categoryItem: GridCategoryItem;\n /** Context of the surrounding property grid. */\n gridContext: VirtualizedPropertyGridContext;\n /** Sets the allocated height for category contents. */\n onHeightChanged: (newHeight: number) => void;\n}\n\n/**\n * Factory function that produces custom property category components.\n * @public\n */\nexport type PropertyCategoryRenderer = (categoryItem: GridCategoryItem) => React.ComponentType<PropertyCategoryRendererProps> | undefined;\n\n/**\n * Keeps a record of currently registered property category renderers and determines which renderers get invoked for\n * each category.\n * @public\n */\nexport class PropertyCategoryRendererManager {\n private _categoryRenderers = new Map<string, PropertyCategoryRenderer>();\n\n public static defaultManager = new PropertyCategoryRendererManager();\n\n /** Retrieves a category rendering component based for the passed category item. */\n public getCategoryComponent(categoryItem: GridCategoryItem): React.ComponentType<PropertyCategoryRendererProps> | undefined {\n if (categoryItem.derivedCategory.renderer === undefined) {\n return undefined;\n }\n\n return this._categoryRenderers.get(categoryItem.derivedCategory.renderer.name)?.(categoryItem);\n }\n\n /** Registers a renderer factory function to be invoked on categories with specific renderer name. */\n public addRenderer(rendererName: string, categoryRenderer: PropertyCategoryRenderer, override = false): void {\n if (this._categoryRenderers.has(rendererName) && !override) {\n const className = PropertyCategoryRendererManager.name;\n const methodName = PropertyCategoryRendererManager.prototype.addRenderer.name;\n throw new Error(`${className}.${methodName} error: renderer '${rendererName}' has already been added. Did you mean to override it?`);\n }\n\n this._categoryRenderers.set(rendererName, categoryRenderer);\n }\n\n /** Removes previous renderer factory registration. */\n public removeRenderer(rendererName: string): void {\n this._categoryRenderers.delete(rendererName);\n }\n}\n"]}
|
|
@@ -28,8 +28,8 @@ export interface PropertyData {
|
|
|
28
28
|
[categoryName: string]: PropertyRecord[];
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
|
-
* Should state of existing property data in the component be
|
|
32
|
-
* @
|
|
31
|
+
* Should state of existing property data in the component be re-used for this property data
|
|
32
|
+
* @beta
|
|
33
33
|
*/
|
|
34
34
|
reusePropertyDataState?: boolean;
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyDataProvider.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/PropertyDataProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAA8C;AAsC9C;;GAEG;AACH,MAAa,uBAAwB,SAAQ,sBAAoC;CAAI;AAArF,0DAAqF","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/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { BeEvent } from \"@itwin/core-bentley\";\n\n/**\n * Contains metadata about a group of Properties.\n * @public\n */\nexport interface PropertyCategory {\n name: string;\n label: string;\n expand: boolean;\n childCategories?: PropertyCategory[];\n renderer?: {\n name: string;\n };\n}\n\n/**\n * Interface for property data provided to the PropertyGrid React component.\n * @public\n */\nexport interface PropertyData {\n label: PropertyRecord;\n description?: string;\n categories: PropertyCategory[];\n records: { [categoryName: string]: PropertyRecord[] };\n\n /**\n * Should state of existing property data in the component be
|
|
1
|
+
{"version":3,"file":"PropertyDataProvider.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/PropertyDataProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAA8C;AAsC9C;;GAEG;AACH,MAAa,uBAAwB,SAAQ,sBAAoC;CAAI;AAArF,0DAAqF","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/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { BeEvent } from \"@itwin/core-bentley\";\n\n/**\n * Contains metadata about a group of Properties.\n * @public\n */\nexport interface PropertyCategory {\n name: string;\n label: string;\n expand: boolean;\n childCategories?: PropertyCategory[];\n renderer?: {\n name: string;\n };\n}\n\n/**\n * Interface for property data provided to the PropertyGrid React component.\n * @public\n */\nexport interface PropertyData {\n label: PropertyRecord;\n description?: string;\n categories: PropertyCategory[];\n records: { [categoryName: string]: PropertyRecord[] };\n\n /**\n * Should state of existing property data in the component be re-used for this property data\n * @beta\n */\n reusePropertyDataState?: boolean;\n}\n\n/** A signature for property data change listeners\n * @public\n */\nexport declare type PropertyDataChangesListener = () => void;\n\n/** An event broadcasted on property data changes\n * @public\n */\nexport class PropertyDataChangeEvent extends BeEvent<PropertyDataChangesListener> { }\n\n/**\n * An interface for property data provider which returns\n * property data and broadcasts an event when the data changes\n * @public\n */\nexport interface IPropertyDataProvider {\n /** Returns property data. */\n getData: (() => Promise<PropertyData>);\n /** Property data change event. */\n onDataChanged: PropertyDataChangeEvent;\n}\n"]}
|
|
@@ -9,6 +9,7 @@ import { IPropertyDataProvider, PropertyCategory } from "../PropertyDataProvider
|
|
|
9
9
|
import { CommonPropertyGridProps } from "./PropertyGridCommons";
|
|
10
10
|
/** Properties for [[PropertyGrid]] React component
|
|
11
11
|
* @public
|
|
12
|
+
* @deprecated in 3.x. Use [[VirtualizedPropertyGrid]] instead.
|
|
12
13
|
*/
|
|
13
14
|
export interface PropertyGridProps extends CommonPropertyGridProps {
|
|
14
15
|
/** Property data provider */
|
|
@@ -34,6 +35,7 @@ interface PropertyGridState {
|
|
|
34
35
|
}
|
|
35
36
|
/** PropertyGrid React component.
|
|
36
37
|
* @public
|
|
38
|
+
* @deprecated in 3.x. Use [[VirtualizedPropertyGrid]] instead.
|
|
37
39
|
*/
|
|
38
40
|
export declare class PropertyGrid extends React.Component<PropertyGridProps, PropertyGridState> {
|
|
39
41
|
private _dataChangesListenerDisposeFunc?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyGrid.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/component/PropertyGrid.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,qBAAqB,CAAC;AAG7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAA8B,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAgB,MAAM,yBAAyB,CAAC;AAGhG,OAAO,EAAE,uBAAuB,EAAuB,MAAM,uBAAuB,CAAC;AAIrF
|
|
1
|
+
{"version":3,"file":"PropertyGrid.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/component/PropertyGrid.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,qBAAqB,CAAC;AAG7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAA8B,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAgB,MAAM,yBAAyB,CAAC;AAGhG,OAAO,EAAE,uBAAuB,EAAuB,MAAM,uBAAuB,CAAC;AAIrF;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,uBAAuB;IAChE,6BAA6B;IAC7B,YAAY,EAAE,qBAAqB,CAAC;CACrC;AAED,UAAU,8BAA8B;IACtC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,QAAQ,EAAE,8BAA8B,EAAE,CAAC;CAC5C;AAED;;GAEG;AACH,UAAU,iBAAiB;IACzB,sCAAsC;IACt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