@itwin/components-react 3.6.0-dev.55 → 3.6.0-dev.60
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/lib/cjs/components-react/breadcrumb/Breadcrumb.d.ts +5 -5
- package/lib/cjs/components-react/breadcrumb/Breadcrumb.js +3 -3
- package/lib/cjs/components-react/breadcrumb/Breadcrumb.js.map +1 -1
- package/lib/cjs/components-react/breadcrumb/BreadcrumbDetails.d.ts +2 -2
- package/lib/cjs/components-react/breadcrumb/BreadcrumbDetails.js +1 -1
- package/lib/cjs/components-react/breadcrumb/BreadcrumbDetails.js.map +1 -1
- package/lib/cjs/components-react/breadcrumb/BreadcrumbPath.d.ts +3 -3
- package/lib/cjs/components-react/breadcrumb/BreadcrumbPath.js +2 -2
- package/lib/cjs/components-react/breadcrumb/BreadcrumbPath.js.map +1 -1
- package/lib/cjs/components-react/breadcrumb/BreadcrumbTreeUtils.d.ts +1 -1
- package/lib/cjs/components-react/breadcrumb/BreadcrumbTreeUtils.js +1 -1
- package/lib/cjs/components-react/breadcrumb/BreadcrumbTreeUtils.js.map +1 -1
- package/lib/cjs/components-react/common/showhide/ShowHideDialog.d.ts +2 -2
- package/lib/cjs/components-react/common/showhide/ShowHideDialog.js +1 -1
- package/lib/cjs/components-react/common/showhide/ShowHideDialog.js.map +1 -1
- package/lib/cjs/components-react/common/showhide/ShowHideItem.d.ts +2 -2
- package/lib/cjs/components-react/common/showhide/ShowHideItem.js.map +1 -1
- package/lib/cjs/components-react/common/showhide/ShowHideMenu.d.ts +2 -2
- package/lib/cjs/components-react/common/showhide/ShowHideMenu.js +1 -1
- package/lib/cjs/components-react/common/showhide/ShowHideMenu.js.map +1 -1
- package/lib/cjs/components-react/editors/ThemedEnumEditor.d.ts +3 -3
- package/lib/cjs/components-react/editors/ThemedEnumEditor.js +2 -2
- package/lib/cjs/components-react/editors/ThemedEnumEditor.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 +16 -10
- 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/iconpicker/IconPickerButton.d.ts +2 -2
- package/lib/cjs/components-react/iconpicker/IconPickerButton.js +2 -2
- package/lib/cjs/components-react/iconpicker/IconPickerButton.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyGrid.d.ts +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyGrid.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/FlatGridItem.d.ts +2 -2
- package/lib/cjs/components-react/propertygrid/internal/flat-items/FlatGridItem.d.ts.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/FlatGridItem.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.d.ts +2 -2
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
- package/lib/cjs/components-react/table/SimpleTableDataProvider.d.ts +1 -1
- package/lib/cjs/components-react/table/SimpleTableDataProvider.js +1 -1
- package/lib/cjs/components-react/table/SimpleTableDataProvider.js.map +1 -1
- package/lib/cjs/components-react/table/TableDataProvider.d.ts +8 -8
- package/lib/cjs/components-react/table/TableDataProvider.js +2 -2
- package/lib/cjs/components-react/table/TableDataProvider.js.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/ColumnFiltering.d.ts +16 -16
- package/lib/cjs/components-react/table/columnfiltering/ColumnFiltering.js +6 -6
- package/lib/cjs/components-react/table/columnfiltering/ColumnFiltering.js.map +1 -1
- package/lib/cjs/components-react/table/component/ColumnDragLayer.d.ts +1 -1
- package/lib/cjs/components-react/table/component/ColumnDragLayer.js +1 -1
- package/lib/cjs/components-react/table/component/ColumnDragLayer.js.map +1 -1
- package/lib/cjs/components-react/table/component/Table.d.ts +9 -9
- package/lib/cjs/components-react/table/component/Table.d.ts.map +1 -1
- package/lib/cjs/components-react/table/component/Table.js +2 -2
- package/lib/cjs/components-react/table/component/Table.js.map +1 -1
- package/lib/cjs/components-react/table/component/TableCell.d.ts +6 -6
- package/lib/cjs/components-react/table/component/TableCell.js +3 -3
- package/lib/cjs/components-react/table/component/TableCell.js.map +1 -1
- package/lib/cjs/components-react/table/component/TableColumn.d.ts +1 -1
- package/lib/cjs/components-react/table/component/TableColumn.js.map +1 -1
- package/lib/cjs/components-react/table/component/dragdrop/BeDragDropContext.d.ts +1 -1
- package/lib/cjs/components-react/table/component/dragdrop/BeDragDropContext.js +1 -1
- package/lib/cjs/components-react/table/component/dragdrop/BeDragDropContext.js.map +1 -1
- package/lib/cjs/components-react/table/component/dragdrop/DragDropDef.d.ts +8 -8
- package/lib/cjs/components-react/table/component/dragdrop/DragDropDef.js +2 -2
- package/lib/cjs/components-react/table/component/dragdrop/DragDropDef.js.map +1 -1
- package/lib/cjs/components-react/table/component/dragdrop/withDragSource.d.ts +2 -2
- package/lib/cjs/components-react/table/component/dragdrop/withDragSource.js +1 -1
- package/lib/cjs/components-react/table/component/dragdrop/withDragSource.js.map +1 -1
- package/lib/cjs/components-react/table/component/dragdrop/withDropTarget.d.ts +2 -2
- package/lib/cjs/components-react/table/component/dragdrop/withDropTarget.js +1 -1
- package/lib/cjs/components-react/table/component/dragdrop/withDropTarget.js.map +1 -1
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.d.ts +1 -1
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
- package/lib/cjs/components-react/tree/TreeDataProvider.d.ts +2 -2
- package/lib/cjs/components-react/tree/TreeDataProvider.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/TreeDataProvider.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/breadcrumb/Breadcrumb.d.ts +5 -5
- package/lib/esm/components-react/breadcrumb/Breadcrumb.js +3 -3
- package/lib/esm/components-react/breadcrumb/Breadcrumb.js.map +1 -1
- package/lib/esm/components-react/breadcrumb/BreadcrumbDetails.d.ts +2 -2
- package/lib/esm/components-react/breadcrumb/BreadcrumbDetails.js +1 -1
- package/lib/esm/components-react/breadcrumb/BreadcrumbDetails.js.map +1 -1
- package/lib/esm/components-react/breadcrumb/BreadcrumbPath.d.ts +3 -3
- package/lib/esm/components-react/breadcrumb/BreadcrumbPath.js +2 -2
- package/lib/esm/components-react/breadcrumb/BreadcrumbPath.js.map +1 -1
- package/lib/esm/components-react/breadcrumb/BreadcrumbTreeUtils.d.ts +1 -1
- package/lib/esm/components-react/breadcrumb/BreadcrumbTreeUtils.js +1 -1
- package/lib/esm/components-react/breadcrumb/BreadcrumbTreeUtils.js.map +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideDialog.d.ts +2 -2
- package/lib/esm/components-react/common/showhide/ShowHideDialog.js +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideDialog.js.map +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideItem.d.ts +2 -2
- package/lib/esm/components-react/common/showhide/ShowHideItem.js.map +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideMenu.d.ts +2 -2
- package/lib/esm/components-react/common/showhide/ShowHideMenu.js +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideMenu.js.map +1 -1
- package/lib/esm/components-react/editors/ThemedEnumEditor.d.ts +3 -3
- package/lib/esm/components-react/editors/ThemedEnumEditor.js +2 -2
- package/lib/esm/components-react/editors/ThemedEnumEditor.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 +11 -5
- 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/iconpicker/IconPickerButton.d.ts +2 -2
- package/lib/esm/components-react/iconpicker/IconPickerButton.js +2 -2
- package/lib/esm/components-react/iconpicker/IconPickerButton.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyGrid.d.ts +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyGrid.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/FlatGridItem.d.ts +2 -2
- package/lib/esm/components-react/propertygrid/internal/flat-items/FlatGridItem.d.ts.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/FlatGridItem.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.d.ts +2 -2
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
- package/lib/esm/components-react/table/SimpleTableDataProvider.d.ts +1 -1
- package/lib/esm/components-react/table/SimpleTableDataProvider.js +1 -1
- package/lib/esm/components-react/table/SimpleTableDataProvider.js.map +1 -1
- package/lib/esm/components-react/table/TableDataProvider.d.ts +8 -8
- package/lib/esm/components-react/table/TableDataProvider.js +2 -2
- package/lib/esm/components-react/table/TableDataProvider.js.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/ColumnFiltering.d.ts +16 -16
- package/lib/esm/components-react/table/columnfiltering/ColumnFiltering.js +6 -6
- package/lib/esm/components-react/table/columnfiltering/ColumnFiltering.js.map +1 -1
- package/lib/esm/components-react/table/component/ColumnDragLayer.d.ts +1 -1
- package/lib/esm/components-react/table/component/ColumnDragLayer.js +1 -1
- package/lib/esm/components-react/table/component/ColumnDragLayer.js.map +1 -1
- package/lib/esm/components-react/table/component/Table.d.ts +9 -9
- package/lib/esm/components-react/table/component/Table.d.ts.map +1 -1
- package/lib/esm/components-react/table/component/Table.js +2 -2
- package/lib/esm/components-react/table/component/Table.js.map +1 -1
- package/lib/esm/components-react/table/component/TableCell.d.ts +6 -6
- package/lib/esm/components-react/table/component/TableCell.js +3 -3
- package/lib/esm/components-react/table/component/TableCell.js.map +1 -1
- package/lib/esm/components-react/table/component/TableColumn.d.ts +1 -1
- package/lib/esm/components-react/table/component/TableColumn.js.map +1 -1
- package/lib/esm/components-react/table/component/dragdrop/BeDragDropContext.d.ts +1 -1
- package/lib/esm/components-react/table/component/dragdrop/BeDragDropContext.js +1 -1
- package/lib/esm/components-react/table/component/dragdrop/BeDragDropContext.js.map +1 -1
- package/lib/esm/components-react/table/component/dragdrop/DragDropDef.d.ts +8 -8
- package/lib/esm/components-react/table/component/dragdrop/DragDropDef.js +2 -2
- package/lib/esm/components-react/table/component/dragdrop/DragDropDef.js.map +1 -1
- package/lib/esm/components-react/table/component/dragdrop/withDragSource.d.ts +2 -2
- package/lib/esm/components-react/table/component/dragdrop/withDragSource.js +1 -1
- package/lib/esm/components-react/table/component/dragdrop/withDragSource.js.map +1 -1
- package/lib/esm/components-react/table/component/dragdrop/withDropTarget.d.ts +2 -2
- package/lib/esm/components-react/table/component/dragdrop/withDropTarget.js +1 -1
- package/lib/esm/components-react/table/component/dragdrop/withDropTarget.js.map +1 -1
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.d.ts +1 -1
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
- package/lib/esm/components-react/tree/TreeDataProvider.d.ts +2 -2
- package/lib/esm/components-react/tree/TreeDataProvider.d.ts.map +1 -1
- package/lib/esm/components-react/tree/TreeDataProvider.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 +11 -11
|
@@ -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":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyFilterBuilder\r\n */\r\n\r\nimport { PropertyDescription, PropertyValue } from \"@itwin/appui-abstract\";\r\nimport { PropertyFilterRuleGroupOperator, PropertyFilterRuleOperator } from \"./Operators\";\r\n\r\n/**\r\n * Type that describes property filter.\r\n * @beta\r\n */\r\nexport type PropertyFilter = PropertyFilterRule | PropertyFilterRuleGroup;\r\n\r\n/**\r\n * Data structure that describes group of filter rules.\r\n * @beta\r\n */\r\nexport interface PropertyFilterRuleGroup {\r\n /** Operator that should join rules in this group. */\r\n operator: PropertyFilterRuleGroupOperator;\r\n /** Rules in this group. */\r\n rules: Array<PropertyFilter>;\r\n}\r\n\r\n/**\r\n * Data structure that describes single filter rule.\r\n * @beta\r\n */\r\nexport interface PropertyFilterRule {\r\n /** Property used in this rule. */\r\n property: PropertyDescription;\r\n /** Operator that should be used to compare property value. */\r\n operator: PropertyFilterRuleOperator;\r\n /** Value that property should be compared to. */\r\n value?: PropertyValue;\r\n}\r\n\r\n/**\r\n * Function that checks if supplied filter is rule group.\r\n * @beta\r\n */\r\nexport function isPropertyFilterRuleGroup(filter: PropertyFilter): filter is PropertyFilterRuleGroup {\r\n return (filter as any).rules !== undefined;\r\n}\r\n"]}
|
|
@@ -5,7 +5,7 @@ import "./IconPickerButton.scss";
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { CommonProps } from "@itwin/core-react";
|
|
7
7
|
/** Properties for the [[IconPicker]] React component
|
|
8
|
-
* @alpha @deprecated
|
|
8
|
+
* @alpha @deprecated in 3.0.
|
|
9
9
|
*/
|
|
10
10
|
export interface IconPickerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {
|
|
11
11
|
/** active string */
|
|
@@ -29,7 +29,7 @@ interface IconPickerState {
|
|
|
29
29
|
icon: string;
|
|
30
30
|
}
|
|
31
31
|
/** IconPickerButton component
|
|
32
|
-
* @alpha @deprecated
|
|
32
|
+
* @alpha @deprecated in 3.0.
|
|
33
33
|
*/
|
|
34
34
|
export declare class IconPickerButton extends React.PureComponent<IconPickerProps, IconPickerState> {
|
|
35
35
|
private _target;
|
|
@@ -37,7 +37,7 @@ const React = __importStar(require("react"));
|
|
|
37
37
|
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
38
38
|
const core_react_1 = require("@itwin/core-react");
|
|
39
39
|
/** IconItem Functional component
|
|
40
|
-
* @alpha @deprecated
|
|
40
|
+
* @alpha @deprecated in 3.0.
|
|
41
41
|
*/
|
|
42
42
|
// istanbul ignore next
|
|
43
43
|
class IconItem extends React.PureComponent {
|
|
@@ -60,7 +60,7 @@ class IconItem extends React.PureComponent {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
/** IconPickerButton component
|
|
63
|
-
* @alpha @deprecated
|
|
63
|
+
* @alpha @deprecated in 3.0.
|
|
64
64
|
*/
|
|
65
65
|
// istanbul ignore next
|
|
66
66
|
class IconPickerButton extends React.PureComponent {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconPickerButton.js","sourceRoot":"","sources":["../../../../src/components-react/iconpicker/IconPickerButton.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mCAAiC;AACjC,4DAAoC;AACpC,6CAA+B;AAC/B,0DAAyD;AACzD,kDAAkE;AAYlE;;GAE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AAQ,IAAI,UAAU,EACjC,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,CAAC;QAEF,OAAO,CACL;YACE,+CAAoB,8BAA8B,EAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO;gBAC9K,oBAAC,sBAAS,IAAC,SAAS,EAAC,0BAA0B,EAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAI;gBACxE,8BAAM,SAAS,EAAC,wBAAwB,GAAG,CACpC;YACT,oBAAC,kBAAK,IACJ,SAAS,EAAC,6BAA6B,EACvC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC5B,QAAQ,EAAE,iCAAgB,CAAC,UAAU,EACrC,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,IAC3B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CACrC,CACP,CACJ,CAAC;IACJ,CAAC;;AAxEH,4CA0EC;AAvEC,gBAAgB;AACF,6BAAY,GAA6B;IACrD,UAAU,EAAE,CAAC;CACd,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/* eslint-disable deprecation/deprecation */\r\n/** @packageDocumentation\r\n * @module IconPicker\r\n */\r\n\r\nimport \"./IconPickerButton.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { RelativePosition } from \"@itwin/appui-abstract\";\r\nimport { CommonProps, Popup, SvgSprite } from \"@itwin/core-react\";\r\n\r\n/** Properties for the [[IconItem]] React component\r\n * @alpha @deprecated
|
|
1
|
+
{"version":3,"file":"IconPickerButton.js","sourceRoot":"","sources":["../../../../src/components-react/iconpicker/IconPickerButton.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mCAAiC;AACjC,4DAAoC;AACpC,6CAA+B;AAC/B,0DAAyD;AACzD,kDAAkE;AAYlE;;GAEG;AACH,uBAAuB;AACvB,MAAM,QAAS,SAAQ,KAAK,CAAC,aAA4B;IACvD,gBAAgB;IAChB,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEe,MAAM;QACpB,MAAM;QACJ,6DAA6D;QAC7D,OAAO,EAAE,IAAI,EAAE,qCAAqC;QACpD,GAAG,UAAU,EACd,GAAG,IAAI,CAAC,KAAK,CAAC;QAEf,MAAM,WAAW,GAAG,CAAC,EAAoB,EAAE,EAAE;YAC3C,IAAI,OAAO;gBACT,OAAO,EAAE,CAAC;QACd,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,wBAAwB,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE3E,OAAO,CACL,mCAAY,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW;YACvF,oBAAC,sBAAS,IAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAI,CAC5B,CACV,CAAC;IACJ,CAAC;CACF;AA6BD;;GAEG;AACH,uBAAuB;AACvB,MAAa,gBAAiB,SAAQ,KAAK,CAAC,aAA+C;IAQzF,gBAAgB;IAChB,YAAY,KAAsB;QAChC,KAAK,CAAC,KAAK,CAAC,CAAC;QATP,YAAO,GAAG,KAAK,CAAC,SAAS,EAAqB,CAAC;QAc/C,iBAAY,GAAG,GAAG,EAAE;YAC1B,IAAI,IAAI,CAAC,K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IAAI,EAAE,IAAI,CAAC,GAAI,CAAC,CAC1I,CACF,CACP,CAAC;IACJ,CAAC;IAED,gBAAgB;IACA,MAAM;QACpB,MAAM,WAAW,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAyB,CAAC;QACnE,MAAM,gBAAgB,GAAG,IAAA,oBAAU,EAAC,8BAA8B,EAChE,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,UAAU,EACjC,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,CAAC;QAEF,OAAO,CACL;YACE,+CAAoB,8BAA8B,EAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO;gBAC9K,oBAAC,sBAAS,IAAC,SAAS,EAAC,0BAA0B,EAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAI;gBACxE,8BAAM,SAAS,EAAC,wBAAwB,GAAG,CACpC;YACT,oBAAC,kBAAK,IACJ,SAAS,EAAC,6BAA6B,EACvC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC5B,QAAQ,EAAE,iCAAgB,CAAC,UAAU,EACrC,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,IAC3B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CACrC,CACP,CACJ,CAAC;IACJ,CAAC;;AAxEH,4CA0EC;AAvEC,gBAAgB;AACF,6BAAY,GAA6B;IACrD,UAAU,EAAE,CAAC;CACd,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/* eslint-disable deprecation/deprecation */\r\n/** @packageDocumentation\r\n * @module IconPicker\r\n */\r\n\r\nimport \"./IconPickerButton.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { RelativePosition } from \"@itwin/appui-abstract\";\r\nimport { CommonProps, Popup, SvgSprite } from \"@itwin/core-react\";\r\n\r\n/** Properties for the [[IconItem]] React component\r\n * @alpha @deprecated in 3.0.\r\n */\r\ninterface IconItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {\r\n /** icon specification */\r\n icon: string;\r\n /** function to run when user selects icon */\r\n onClick?: () => void;\r\n}\r\n\r\n/** IconItem Functional component\r\n * @alpha @deprecated in 3.0.\r\n */\r\n// istanbul ignore next\r\nclass IconItem extends React.PureComponent<IconItemProps> {\r\n /** @internal */\r\n constructor(props: IconItemProps) {\r\n super(props);\r\n }\r\n\r\n public override render() {\r\n const {\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n onClick, icon, // do not pass on item specific props\r\n ...otherProps\r\n } = this.props;\r\n\r\n const handleClick = (_e: React.MouseEvent) => {\r\n if (onClick)\r\n onClick();\r\n };\r\n\r\n const classes = classnames(\"components-icon-swatch\", this.props.className);\r\n\r\n return (\r\n <button {...otherProps} className={classes} style={this.props.style} onClick={handleClick}>\r\n <SvgSprite src={this.props.icon} />\r\n </button>\r\n );\r\n }\r\n}\r\n\r\n/** Properties for the [[IconPicker]] React component\r\n * @alpha @deprecated in 3.0.\r\n */\r\n// istanbul ignore next\r\nexport interface IconPickerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {\r\n /** active string */\r\n icon: string;\r\n /** available icons */\r\n icons: string[];\r\n /** function to run when user selects icon */\r\n onIconChange?: ((icon: string) => void) | undefined;\r\n /** Disabled or not */\r\n disabled?: boolean;\r\n /** Readonly or not */\r\n readonly?: boolean;\r\n /** Title to show at top of DropDown */\r\n dropDownTitle?: string;\r\n /** Number of columns */\r\n numColumns: number;\r\n}\r\n\r\n/** @internal */\r\ninterface IconPickerState {\r\n showPopup: boolean;\r\n icon: string;\r\n}\r\n\r\n/** IconPickerButton component\r\n * @alpha @deprecated in 3.0.\r\n */\r\n// istanbul ignore next\r\nexport class IconPickerButton extends React.PureComponent<IconPickerProps, IconPickerState> {\r\n private _target = React.createRef<HTMLButtonElement>();\r\n\r\n /** @internal */\r\n public static defaultProps: Partial<IconPickerProps> = {\r\n numColumns: 4,\r\n };\r\n\r\n /** @internal */\r\n constructor(props: IconPickerProps) {\r\n super(props);\r\n\r\n this.state = { showPopup: false, icon: this.props.icon };\r\n }\r\n\r\n private _togglePopup = () => {\r\n if (this.props.readonly)\r\n return;\r\n\r\n this.setState((prevState) => ({ showPopup: !prevState.showPopup }));\r\n };\r\n\r\n private _closePopup = () => {\r\n this.setState({ showPopup: false });\r\n };\r\n\r\n private _handleIconPicked = (icon: string) => {\r\n this.setState(\r\n { showPopup: false, icon },\r\n () => {\r\n // istanbul ignore else\r\n if (this.props.onIconChange)\r\n this.props.onIconChange(icon);\r\n });\r\n };\r\n\r\n private renderPopup(title: string | undefined) {\r\n const containerStyle: React.CSSProperties = { gridTemplateColumns: `repeat(${this.props.numColumns}, 1fr)` };\r\n return (\r\n <div className=\"components-iconpicker-popup-container\">\r\n {title && <h4>{title}</h4>}\r\n <div data-testid=\"components-iconpicker-popup-icons\" className=\"components-iconpicker-popup-icons\" style={containerStyle}>\r\n {this.props.icons.map((icon: string, index: number) => <IconItem key={index} icon={icon} onClick={this._handleIconPicked.bind(this, icon)} />)}\r\n </div>\r\n </div>\r\n );\r\n }\r\n\r\n /** @internal */\r\n public override render() {\r\n const buttonStyle = { ...this.props.style } as React.CSSProperties;\r\n const buttonClassNames = classnames(\"components-iconpicker-button\",\r\n this.props.readonly && \"readonly\",\r\n this.props.className,\r\n );\r\n\r\n return (\r\n <>\r\n <button data-testid=\"components-iconpicker-button\" onClick={this._togglePopup} className={buttonClassNames} style={buttonStyle} disabled={this.props.disabled} ref={this._target}>\r\n <SvgSprite className=\"iconpicker-button-sprite\" src={this.state.icon} />\r\n <span className=\"icon icon-chevron-down\" />\r\n </button>\r\n <Popup\r\n className=\"components-iconpicker-popup\"\r\n isOpen={this.state.showPopup}\r\n position={RelativePosition.BottomLeft}\r\n onClose={this._closePopup}\r\n target={this._target.current}>\r\n {this.renderPopup(this.props.dropDownTitle)}\r\n </Popup>\r\n </>\r\n );\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -16,7 +16,7 @@ export interface PropertyGridProps extends CommonPropertyGridProps {
|
|
|
16
16
|
}
|
|
17
17
|
/** Property Category in the [[PropertyGrid]] state
|
|
18
18
|
* @public
|
|
19
|
-
* @deprecated This was part of [[PropertyGrid]] internal state and should've never been public. The component is not using it anymore.
|
|
19
|
+
* @deprecated in 2.x. This was part of [[PropertyGrid]] internal state and should've never been public. The component is not using it anymore.
|
|
20
20
|
*/
|
|
21
21
|
export interface PropertyGridCategory {
|
|
22
22
|
propertyCategory: PropertyCategory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyGrid.js","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/component/PropertyGrid.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;;;;;;;;;AAE/F;;GAEG;AACH,+BAA6B;AAC7B,4DAAoC;AACpC,iCAAgC;AAChC,6CAA+B;AAG/B,kDAA4E;AAC5E,gEAA6D;AAE7D,uGAA0I;AAC1I,mEAAgE;AAChE,+DAAqF;AACrF,qGAAkG;AAClG,iDAAiE;AAwCjE;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK,CAAC,SAA+C;IAMrF,gBAAgB;IAChB,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,CAAC;QANP,eAAU,GAAG,KAAK,CAAC;QACnB,qBAAgB,GAAG,KAAK,CAAC;QACzB,2BAAsB,GAAG,KAAK,CAAC;QAgD/B,2BAAsB,GAAG,GAAG,EAAE;YACpC,mEAAmE;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AK,EAAE,GAAG,EAAE,uBAAuB,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,EAAE,uBAAuB,GAAI,CAC5H,CAAC,CAEA,CACP,CAAC,CAAC,CAAC,SAAS,CACS,CACzB,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module PropertyGrid\r\n */\r\nimport \"./PropertyGrid.scss\";\r\nimport classnames from \"classnames\";\r\nimport { produce } from \"immer\";\r\nimport * as React from \"react\";\r\nimport { DisposeFunc } from \"@itwin/core-bentley\";\r\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\r\nimport { Orientation, ResizableContainerObserver } from \"@itwin/core-react\";\r\nimport { DelayedSpinner } from \"../../common/DelayedSpinner\";\r\nimport { IPropertyDataProvider, PropertyCategory, PropertyData } from \"../PropertyDataProvider\";\r\nimport { ColumnResizeRelatedPropertyListProps, ColumnResizingPropertyListPropsSupplier } from \"./ColumnResizingPropertyListPropsSupplier\";\r\nimport { PropertyCategoryBlock } from \"./PropertyCategoryBlock\";\r\nimport { CommonPropertyGridProps, PropertyGridCommons } from \"./PropertyGridCommons\";\r\nimport { PropertyGridEventsRelatedPropsSupplier } from \"./PropertyGridEventsRelatedPropsSupplier\";\r\nimport { PropertyList, PropertyListProps } from \"./PropertyList\";\r\n\r\n/** Properties for [[PropertyGrid]] React component\r\n * @public\r\n */\r\nexport interface PropertyGridProps extends CommonPropertyGridProps {\r\n /** Property data provider */\r\n dataProvider: IPropertyDataProvider;\r\n}\r\n\r\n/** Property Category in the [[PropertyGrid]] state\r\n * @public\r\n * @deprecated This was part of [[PropertyGrid]] internal state and should've never been public. The component is not using it anymore.\r\n */\r\nexport interface PropertyGridCategory {\r\n propertyCategory: PropertyCategory;\r\n propertyCount: number;\r\n properties: PropertyRecord[];\r\n}\r\n\r\ninterface CategorizedPropertyGridRecords {\r\n category: PropertyCategory;\r\n records: PropertyRecord[];\r\n children: CategorizedPropertyGridRecords[];\r\n}\r\n\r\n/** State of [[PropertyGrid]] React component\r\n * @internal\r\n */\r\ninterface PropertyGridState {\r\n /** List of PropertyGrid categories */\r\n categories: CategorizedPropertyGridRecords[];\r\n /** Actual orientation used by the property grid */\r\n orientation: Orientation;\r\n /** If property grid currently loading data, the loading start time */\r\n loadStart?: Date;\r\n /** Width of PropertyGrid */\r\n width: number;\r\n}\r\n\r\n/** PropertyGrid React component.\r\n * @public\r\n */\r\nexport class PropertyGrid extends React.Component<PropertyGridProps, PropertyGridState> {\r\n private _dataChangesListenerDisposeFunc?: DisposeFunc;\r\n private _isMounted = false;\r\n private _isInDataRequest = false;\r\n private _hasPendingDataRequest = false;\r\n\r\n /** @internal */\r\n constructor(props: PropertyGridProps) {\r\n super(props);\r\n this.state = {\r\n categories: [],\r\n orientation: this.getPreferredOrientation(),\r\n width: 0,\r\n };\r\n }\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this._isMounted = true;\r\n this._dataChangesListenerDisposeFunc = this.props.dataProvider.onDataChanged.addListener(this._onPropertyDataChanged);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.gatherData();\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n // istanbul ignore else\r\n if (this._dataChangesListenerDisposeFunc) {\r\n this._dataChangesListenerDisposeFunc();\r\n this._dataChangesListenerDisposeFunc = undefined;\r\n }\r\n this._isMounted = false;\r\n }\r\n\r\n public override componentDidUpdate(prevProps: PropertyGridProps) {\r\n if (this.props.dataProvider !== prevProps.dataProvider) {\r\n // istanbul ignore else\r\n if (this._dataChangesListenerDisposeFunc)\r\n this._dataChangesListenerDisposeFunc();\r\n this._dataChangesListenerDisposeFunc = this.props.dataProvider.onDataChanged.addListener(this._onPropertyDataChanged);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.gatherData();\r\n }\r\n\r\n if (this.props.orientation !== prevProps.orientation\r\n || this.props.isOrientationFixed !== prevProps.isOrientationFixed\r\n || this.props.horizontalOrientationMinWidth !== prevProps.horizontalOrientationMinWidth)\r\n this.updateOrientation(this.state.width);\r\n }\r\n\r\n private _onPropertyDataChanged = () => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.gatherData();\r\n };\r\n\r\n private async gatherData(): Promise<void> {\r\n if (this._isInDataRequest) {\r\n this._hasPendingDataRequest = true;\r\n return;\r\n }\r\n\r\n this.setState((prev) => prev.loadStart ? null : { loadStart: new Date() });\r\n\r\n this._isInDataRequest = true;\r\n let propertyData: PropertyData;\r\n try {\r\n propertyData = await this.props.dataProvider.getData();\r\n } finally {\r\n this._isInDataRequest = false;\r\n }\r\n\r\n if (!this._isMounted)\r\n return;\r\n\r\n if (this._hasPendingDataRequest) {\r\n this._hasPendingDataRequest = false;\r\n return this.gatherData();\r\n }\r\n\r\n this.setState((prevState) => {\r\n const buildCategoriesHierarchy = (newCategories: PropertyCategory[], stateCategories: CategorizedPropertyGridRecords[] | undefined) =>\r\n newCategories.map((category): CategorizedPropertyGridRecords => {\r\n const matchingStateCategory = findCategory(stateCategories ?? [], category.name, false);\r\n return {\r\n category: { ...category, expand: matchingStateCategory?.category?.expand ?? category.expand },\r\n records: propertyData.records[category.name] ?? [],\r\n children: buildCategoriesHierarchy(category.childCategories ?? [], matchingStateCategory?.children),\r\n };\r\n });\r\n return {\r\n categories: buildCategoriesHierarchy(propertyData.categories, prevState.categories),\r\n loadStart: undefined,\r\n };\r\n });\r\n }\r\n\r\n private getPreferredOrientation(): Orientation {\r\n return (this.props.orientation !== undefined) ? this.props.orientation : Orientation.Horizontal;\r\n }\r\n\r\n private _onResize = (width: number) => {\r\n this.updateOrientation(width);\r\n };\r\n\r\n private _onCategoryExpansionToggled = (categoryName: string) => {\r\n this.setState((state) => {\r\n return produce(state, (draft) => {\r\n const records = findCategory(draft.categories, categoryName, true);\r\n // istanbul ignore else\r\n if (records) {\r\n const category = records.category;\r\n category.expand = !category.expand;\r\n }\r\n });\r\n });\r\n };\r\n\r\n private updateOrientation(width: number): void {\r\n const { orientation, isOrientationFixed, horizontalOrientationMinWidth } = { ...this.props };\r\n const currentOrientation = PropertyGridCommons.getCurrentOrientation(width, orientation, isOrientationFixed, horizontalOrientationMinWidth);\r\n\r\n if (currentOrientation !== this.state.orientation || width !== this.state.width)\r\n this.setState({ orientation: currentOrientation, width });\r\n }\r\n\r\n /** @internal */\r\n public override render() {\r\n if (this.state.loadStart) {\r\n return (\r\n <div className=\"components-property-grid-loader\">\r\n <DelayedSpinner loadStart={this.state.loadStart} size=\"large\" />\r\n </div>\r\n );\r\n }\r\n\r\n return (\r\n <PropertyGridEventsRelatedPropsSupplier\r\n isPropertySelectionEnabled={this.props.isPropertySelectionEnabled ?? false}\r\n isPropertySelectionOnRightClickEnabled={this.props.isPropertySelectionOnRightClickEnabled}\r\n isPropertyEditingEnabled={this.props.isPropertyEditingEnabled}\r\n isPropertyHoverEnabled={this.props.isPropertyHoverEnabled ?? false}\r\n onPropertyContextMenu={this.props.onPropertyContextMenu}\r\n onPropertyUpdated={this.props.onPropertyUpdated}\r\n onPropertySelectionChanged={this.props.onPropertySelectionChanged}\r\n >\r\n {(selectionContext) => (\r\n <div className={classnames(\"components-property-grid-wrapper\", this.props.className)} style={this.props.style}>\r\n <div className={classnames(\"components-property-grid\", \"components-smallEditor-host\")}>\r\n <div className=\"property-categories\">\r\n {\r\n this.state.categories.map((categorizedRecords: CategorizedPropertyGridRecords) => (\r\n <NestedCategoryBlock\r\n {...selectionContext}\r\n key={categorizedRecords.category.name}\r\n categorizedRecords={categorizedRecords}\r\n onCategoryExpansionToggled={this._onCategoryExpansionToggled}\r\n orientation={this.state.orientation}\r\n propertyValueRendererManager={this.props.propertyValueRendererManager}\r\n actionButtonRenderers={this.props.actionButtonRenderers}\r\n />\r\n ))\r\n }\r\n </div>\r\n </div>\r\n <ResizableContainerObserver onResize={this._onResize} />\r\n </div>\r\n )}\r\n </PropertyGridEventsRelatedPropsSupplier>\r\n );\r\n }\r\n}\r\n\r\nfunction findCategory(categories: CategorizedPropertyGridRecords[], lookupName: string, recurseIntoChildren: boolean): CategorizedPropertyGridRecords | undefined {\r\n for (const category of categories) {\r\n if (category.category.name === lookupName)\r\n return category;\r\n if (recurseIntoChildren) {\r\n const matchingChild = findCategory(category.children, lookupName, recurseIntoChildren);\r\n if (matchingChild)\r\n return matchingChild;\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\ninterface NestedCategoryBlockProps extends Omit<PropertyListProps, (keyof ColumnResizeRelatedPropertyListProps) | \"properties\"> {\r\n categorizedRecords: CategorizedPropertyGridRecords;\r\n onCategoryExpansionToggled: (categoryName: string) => void;\r\n orientation: Orientation;\r\n}\r\nfunction NestedCategoryBlock(props: NestedCategoryBlockProps) {\r\n return (\r\n <PropertyCategoryBlock\r\n category={props.categorizedRecords.category}\r\n onExpansionToggled={props.onCategoryExpansionToggled}\r\n >\r\n {props.categorizedRecords.records.length ? (\r\n <ColumnResizingPropertyListPropsSupplier orientation={props.orientation}>\r\n {(partialListProps: ColumnResizeRelatedPropertyListProps) => (\r\n <PropertyList\r\n {...partialListProps}\r\n orientation={props.orientation}\r\n category={props.categorizedRecords.category}\r\n properties={props.categorizedRecords.records}\r\n selectedPropertyKey={props.selectedPropertyKey}\r\n onPropertyClicked={props.onPropertyClicked}\r\n onPropertyRightClicked={props.onPropertyRightClicked}\r\n onPropertyContextMenu={props.onPropertyContextMenu}\r\n propertyValueRendererManager={props.propertyValueRendererManager}\r\n editingPropertyKey={props.editingPropertyKey}\r\n onEditCommit={props.onEditCommit}\r\n onEditCancel={props.onEditCancel}\r\n isPropertyHoverEnabled={props.isPropertyHoverEnabled}\r\n isPropertySelectionEnabled={props.isPropertySelectionEnabled}\r\n isPropertyRightClickSelectionEnabled={props.isPropertyRightClickSelectionEnabled}\r\n actionButtonRenderers={props.actionButtonRenderers}\r\n />\r\n )}\r\n </ColumnResizingPropertyListPropsSupplier>\r\n ) : undefined}\r\n {props.categorizedRecords.children.length ? (\r\n <div className=\"property-categories\">\r\n {\r\n props.categorizedRecords.children.map((categorizedChildRecords) => (\r\n <NestedCategoryBlock {...props} key={categorizedChildRecords.category.name} categorizedRecords={categorizedChildRecords} />\r\n ))\r\n }\r\n </div>\r\n ) : undefined}\r\n </PropertyCategoryBlock>\r\n );\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"PropertyGrid.js","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/component/PropertyGrid.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;;;;;;;;;AAE/F;;GAEG;AACH,+BAA6B;AAC7B,4DAAoC;AACpC,iCAAgC;AAChC,6CAA+B;AAG/B,kDAA4E;AAC5E,gEAA6D;AAE7D,uGAA0I;AAC1I,mEAAgE;AAChE,+DAAqF;AACrF,qGAAkG;AAClG,iDAAiE;AAwCjE;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK,CAAC,SAA+C;IAMrF,gBAAgB;IAChB,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,CAAC;QANP,eAAU,GAAG,KAAK,CAAC;QACnB,qBAAgB,GAAG,KAAK,CAAC;QACzB,2BAAsB,GAAG,KAAK,CAAC;QAgD/B,2BAAsB,GAAG,GAAG,EAAE;YACpC,mEAAmE;YACnE,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,CAAC,CAAC;QA+CM,cAAS,GAAG,CAAC,KAAa,EAAE,EAAE;YACpC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC,CAAC;QAEM,gCAA2B,GAAG,CAAC,YAAoB,EAAE,EAAE;YAC7D,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtB,OAAO,IAAA,eAAO,EAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE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WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,QAAQ,EAAE,KAAK,CAAC,kBAAkB,CAAC,QAAQ,EAC3C,UAAU,EAAE,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAC5C,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,EAC9C,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAC1C,sBAAsB,EAAE,KAAK,CAAC,sBAAsB,EACpD,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAClD,4BAA4B,EAAE,KAAK,CAAC,4BAA4B,EAChE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,sBAAsB,EAAE,KAAK,CAAC,sBAAsB,EACpD,0BAA0B,EAAE,KAAK,CAAC,0BAA0B,EAC5D,oCAAoC,EAAE,KAAK,CAAC,oCAAoC,EAChF,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,GAClD,CACH,CACuC,CAC3C,CAAC,CAAC,CAAC,SAAS;QACZ,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAC1C,6BAAK,SAAS,EAAC,qBAAqB,IAEhC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,uBAAuB,EAAE,EAAE,CAAC,CACjE,oBAAC,mBAAmB,OAAK,KAAK,EAAE,GAAG,EAAE,uBAAuB,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,EAAE,uBAAuB,GAAI,CAC5H,CAAC,CAEA,CACP,CAAC,CAAC,CAAC,SAAS,CACS,CACzB,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module PropertyGrid\r\n */\r\nimport \"./PropertyGrid.scss\";\r\nimport classnames from \"classnames\";\r\nimport { produce } from \"immer\";\r\nimport * as React from \"react\";\r\nimport { DisposeFunc } from \"@itwin/core-bentley\";\r\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\r\nimport { Orientation, ResizableContainerObserver } from \"@itwin/core-react\";\r\nimport { DelayedSpinner } from \"../../common/DelayedSpinner\";\r\nimport { IPropertyDataProvider, PropertyCategory, PropertyData } from \"../PropertyDataProvider\";\r\nimport { ColumnResizeRelatedPropertyListProps, ColumnResizingPropertyListPropsSupplier } from \"./ColumnResizingPropertyListPropsSupplier\";\r\nimport { PropertyCategoryBlock } from \"./PropertyCategoryBlock\";\r\nimport { CommonPropertyGridProps, PropertyGridCommons } from \"./PropertyGridCommons\";\r\nimport { PropertyGridEventsRelatedPropsSupplier } from \"./PropertyGridEventsRelatedPropsSupplier\";\r\nimport { PropertyList, PropertyListProps } from \"./PropertyList\";\r\n\r\n/** Properties for [[PropertyGrid]] React component\r\n * @public\r\n */\r\nexport interface PropertyGridProps extends CommonPropertyGridProps {\r\n /** Property data provider */\r\n dataProvider: IPropertyDataProvider;\r\n}\r\n\r\n/** Property Category in the [[PropertyGrid]] state\r\n * @public\r\n * @deprecated in 2.x. This was part of [[PropertyGrid]] internal state and should've never been public. The component is not using it anymore.\r\n */\r\nexport interface PropertyGridCategory {\r\n propertyCategory: PropertyCategory;\r\n propertyCount: number;\r\n properties: PropertyRecord[];\r\n}\r\n\r\ninterface CategorizedPropertyGridRecords {\r\n category: PropertyCategory;\r\n records: PropertyRecord[];\r\n children: CategorizedPropertyGridRecords[];\r\n}\r\n\r\n/** State of [[PropertyGrid]] React component\r\n * @internal\r\n */\r\ninterface PropertyGridState {\r\n /** List of PropertyGrid categories */\r\n categories: CategorizedPropertyGridRecords[];\r\n /** Actual orientation used by the property grid */\r\n orientation: Orientation;\r\n /** If property grid currently loading data, the loading start time */\r\n loadStart?: Date;\r\n /** Width of PropertyGrid */\r\n width: number;\r\n}\r\n\r\n/** PropertyGrid React component.\r\n * @public\r\n */\r\nexport class PropertyGrid extends React.Component<PropertyGridProps, PropertyGridState> {\r\n private _dataChangesListenerDisposeFunc?: DisposeFunc;\r\n private _isMounted = false;\r\n private _isInDataRequest = false;\r\n private _hasPendingDataRequest = false;\r\n\r\n /** @internal */\r\n constructor(props: PropertyGridProps) {\r\n super(props);\r\n this.state = {\r\n categories: [],\r\n orientation: this.getPreferredOrientation(),\r\n width: 0,\r\n };\r\n }\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this._isMounted = true;\r\n this._dataChangesListenerDisposeFunc = this.props.dataProvider.onDataChanged.addListener(this._onPropertyDataChanged);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.gatherData();\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n // istanbul ignore else\r\n if (this._dataChangesListenerDisposeFunc) {\r\n this._dataChangesListenerDisposeFunc();\r\n this._dataChangesListenerDisposeFunc = undefined;\r\n }\r\n this._isMounted = false;\r\n }\r\n\r\n public override componentDidUpdate(prevProps: PropertyGridProps) {\r\n if (this.props.dataProvider !== prevProps.dataProvider) {\r\n // istanbul ignore else\r\n if (this._dataChangesListenerDisposeFunc)\r\n this._dataChangesListenerDisposeFunc();\r\n this._dataChangesListenerDisposeFunc = this.props.dataProvider.onDataChanged.addListener(this._onPropertyDataChanged);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.gatherData();\r\n }\r\n\r\n if (this.props.orientation !== prevProps.orientation\r\n || this.props.isOrientationFixed !== prevProps.isOrientationFixed\r\n || this.props.horizontalOrientationMinWidth !== prevProps.horizontalOrientationMinWidth)\r\n this.updateOrientation(this.state.width);\r\n }\r\n\r\n private _onPropertyDataChanged = () => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.gatherData();\r\n };\r\n\r\n private async gatherData(): Promise<void> {\r\n if (this._isInDataRequest) {\r\n this._hasPendingDataRequest = true;\r\n return;\r\n }\r\n\r\n this.setState((prev) => prev.loadStart ? null : { loadStart: new Date() });\r\n\r\n this._isInDataRequest = true;\r\n let propertyData: PropertyData;\r\n try {\r\n propertyData = await this.props.dataProvider.getData();\r\n } finally {\r\n this._isInDataRequest = false;\r\n }\r\n\r\n if (!this._isMounted)\r\n return;\r\n\r\n if (this._hasPendingDataRequest) {\r\n this._hasPendingDataRequest = false;\r\n return this.gatherData();\r\n }\r\n\r\n this.setState((prevState) => {\r\n const buildCategoriesHierarchy = (newCategories: PropertyCategory[], stateCategories: CategorizedPropertyGridRecords[] | undefined) =>\r\n newCategories.map((category): CategorizedPropertyGridRecords => {\r\n const matchingStateCategory = findCategory(stateCategories ?? [], category.name, false);\r\n return {\r\n category: { ...category, expand: matchingStateCategory?.category?.expand ?? category.expand },\r\n records: propertyData.records[category.name] ?? [],\r\n children: buildCategoriesHierarchy(category.childCategories ?? [], matchingStateCategory?.children),\r\n };\r\n });\r\n return {\r\n categories: buildCategoriesHierarchy(propertyData.categories, prevState.categories),\r\n loadStart: undefined,\r\n };\r\n });\r\n }\r\n\r\n private getPreferredOrientation(): Orientation {\r\n return (this.props.orientation !== undefined) ? this.props.orientation : Orientation.Horizontal;\r\n }\r\n\r\n private _onResize = (width: number) => {\r\n this.updateOrientation(width);\r\n };\r\n\r\n private _onCategoryExpansionToggled = (categoryName: string) => {\r\n this.setState((state) => {\r\n return produce(state, (draft) => {\r\n const records = findCategory(draft.categories, categoryName, true);\r\n // istanbul ignore else\r\n if (records) {\r\n const category = records.category;\r\n category.expand = !category.expand;\r\n }\r\n });\r\n });\r\n };\r\n\r\n private updateOrientation(width: number): void {\r\n const { orientation, isOrientationFixed, horizontalOrientationMinWidth } = { ...this.props };\r\n const currentOrientation = PropertyGridCommons.getCurrentOrientation(width, orientation, isOrientationFixed, horizontalOrientationMinWidth);\r\n\r\n if (currentOrientation !== this.state.orientation || width !== this.state.width)\r\n this.setState({ orientation: currentOrientation, width });\r\n }\r\n\r\n /** @internal */\r\n public override render() {\r\n if (this.state.loadStart) {\r\n return (\r\n <div className=\"components-property-grid-loader\">\r\n <DelayedSpinner loadStart={this.state.loadStart} size=\"large\" />\r\n </div>\r\n );\r\n }\r\n\r\n return (\r\n <PropertyGridEventsRelatedPropsSupplier\r\n isPropertySelectionEnabled={this.props.isPropertySelectionEnabled ?? false}\r\n isPropertySelectionOnRightClickEnabled={this.props.isPropertySelectionOnRightClickEnabled}\r\n isPropertyEditingEnabled={this.props.isPropertyEditingEnabled}\r\n isPropertyHoverEnabled={this.props.isPropertyHoverEnabled ?? false}\r\n onPropertyContextMenu={this.props.onPropertyContextMenu}\r\n onPropertyUpdated={this.props.onPropertyUpdated}\r\n onPropertySelectionChanged={this.props.onPropertySelectionChanged}\r\n >\r\n {(selectionContext) => (\r\n <div className={classnames(\"components-property-grid-wrapper\", this.props.className)} style={this.props.style}>\r\n <div className={classnames(\"components-property-grid\", \"components-smallEditor-host\")}>\r\n <div className=\"property-categories\">\r\n {\r\n this.state.categories.map((categorizedRecords: CategorizedPropertyGridRecords) => (\r\n <NestedCategoryBlock\r\n {...selectionContext}\r\n key={categorizedRecords.category.name}\r\n categorizedRecords={categorizedRecords}\r\n onCategoryExpansionToggled={this._onCategoryExpansionToggled}\r\n orientation={this.state.orientation}\r\n propertyValueRendererManager={this.props.propertyValueRendererManager}\r\n actionButtonRenderers={this.props.actionButtonRenderers}\r\n />\r\n ))\r\n }\r\n </div>\r\n </div>\r\n <ResizableContainerObserver onResize={this._onResize} />\r\n </div>\r\n )}\r\n </PropertyGridEventsRelatedPropsSupplier>\r\n );\r\n }\r\n}\r\n\r\nfunction findCategory(categories: CategorizedPropertyGridRecords[], lookupName: string, recurseIntoChildren: boolean): CategorizedPropertyGridRecords | undefined {\r\n for (const category of categories) {\r\n if (category.category.name === lookupName)\r\n return category;\r\n if (recurseIntoChildren) {\r\n const matchingChild = findCategory(category.children, lookupName, recurseIntoChildren);\r\n if (matchingChild)\r\n return matchingChild;\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\ninterface NestedCategoryBlockProps extends Omit<PropertyListProps, (keyof ColumnResizeRelatedPropertyListProps) | \"properties\"> {\r\n categorizedRecords: CategorizedPropertyGridRecords;\r\n onCategoryExpansionToggled: (categoryName: string) => void;\r\n orientation: Orientation;\r\n}\r\nfunction NestedCategoryBlock(props: NestedCategoryBlockProps) {\r\n return (\r\n <PropertyCategoryBlock\r\n category={props.categorizedRecords.category}\r\n onExpansionToggled={props.onCategoryExpansionToggled}\r\n >\r\n {props.categorizedRecords.records.length ? (\r\n <ColumnResizingPropertyListPropsSupplier orientation={props.orientation}>\r\n {(partialListProps: ColumnResizeRelatedPropertyListProps) => (\r\n <PropertyList\r\n {...partialListProps}\r\n orientation={props.orientation}\r\n category={props.categorizedRecords.category}\r\n properties={props.categorizedRecords.records}\r\n selectedPropertyKey={props.selectedPropertyKey}\r\n onPropertyClicked={props.onPropertyClicked}\r\n onPropertyRightClicked={props.onPropertyRightClicked}\r\n onPropertyContextMenu={props.onPropertyContextMenu}\r\n propertyValueRendererManager={props.propertyValueRendererManager}\r\n editingPropertyKey={props.editingPropertyKey}\r\n onEditCommit={props.onEditCommit}\r\n onEditCancel={props.onEditCancel}\r\n isPropertyHoverEnabled={props.isPropertyHoverEnabled}\r\n isPropertySelectionEnabled={props.isPropertySelectionEnabled}\r\n isPropertyRightClickSelectionEnabled={props.isPropertyRightClickSelectionEnabled}\r\n actionButtonRenderers={props.actionButtonRenderers}\r\n />\r\n )}\r\n </ColumnResizingPropertyListPropsSupplier>\r\n ) : undefined}\r\n {props.categorizedRecords.children.length ? (\r\n <div className=\"property-categories\">\r\n {\r\n props.categorizedRecords.children.map((categorizedChildRecords) => (\r\n <NestedCategoryBlock {...props} key={categorizedChildRecords.category.name} categorizedRecords={categorizedChildRecords} />\r\n ))\r\n }\r\n </div>\r\n ) : undefined}\r\n </PropertyCategoryBlock>\r\n );\r\n}\r\n"]}
|
|
@@ -32,9 +32,9 @@ export interface GridCategoryItem extends FlatGridItemBase {
|
|
|
32
32
|
readonly type: FlatGridItemType.Category;
|
|
33
33
|
readonly name: string;
|
|
34
34
|
readonly derivedCategory: PropertyCategory;
|
|
35
|
-
/** @deprecated Use [[getChildren]] and filter categories yourself. */
|
|
35
|
+
/** @deprecated in 3.1. Use [[getChildren]] and filter categories yourself. */
|
|
36
36
|
getChildCategories(): GridCategoryItem[];
|
|
37
|
-
/** @deprecated Use [[getDescendantsAndSelf]] and filter categories yourself. */
|
|
37
|
+
/** @deprecated in 3.1. Use [[getDescendantsAndSelf]] and filter categories yourself. */
|
|
38
38
|
getDescendantCategoriesAndSelf(): GridCategoryItem[];
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlatGridItem.d.ts","sourceRoot":"","sources":["../../../../../../src/components-react/propertygrid/internal/flat-items/FlatGridItem.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,0BAA0B,EAAE,MAAM,GAAG,SAAS,CAAC;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC1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,IAAI,YAAY,EAAE,CAAC;IACxC,4BAA4B,IAAI,YAAY,EAAE,CAAC;IAC/C,WAAW,IAAI,YAAY,EAAE,CAAC;IAC9B,8BAA8B,IAAI,YAAY,CAAC;CAChD;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,QAAQ,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,eAAe,EAAE,gBAAgB,CAAC;IAE3C,8EAA8E;IAC9E,kBAAkB,IAAI,gBAAgB,EAAE,CAAC;IACzC,wFAAwF;IACxF,8BAA8B,IAAI,gBAAgB,EAAE,CAAC;CACtD;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC/D,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAC;IACvC,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC;IAC5C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAEpC,WAAW,IAAI,uBAAuB,EAAE,CAAC;CAC1C;AAED;;;GAGG;AACH,oBAAY,YAAY,GAAG,uBAAuB,GAAG,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlatGridItem.js","sourceRoot":"","sources":["../../../../../../src/components-react/propertygrid/internal/flat-items/FlatGridItem.ts"],"names":[],"mappings":";AAAA;;;+FAG+F","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module PropertyGrid\r\n */\r\nimport { CategorizedPropertyTypes, FlatGridItemType } from \"./MutableFlatGridItem\";\r\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\r\nimport { PropertyCategory } from \"../../PropertyDataProvider\";\r\n\r\n/**\r\n * Base immutable data structure defining common methods and properties for categories and categorized properties\r\n * @beta\r\n */\r\nexport interface FlatGridItemBase {\r\n readonly isExpanded: boolean;\r\n readonly key: string;\r\n readonly selectionKey: string;\r\n readonly parentSelectionKey: string | undefined;\r\n readonly parentCategorySelectionKey: string | undefined;\r\n readonly depth: number;\r\n readonly label: string;\r\n readonly type: FlatGridItemType;\r\n readonly lastInNumberOfCategories: number;\r\n readonly isLastInRootCategory: boolean;\r\n getDescendantsAndSelf(): FlatGridItem[];\r\n getVisibleDescendantsAndSelf(): FlatGridItem[];\r\n getChildren(): FlatGridItem[];\r\n getLastVisibleDescendantOrSelf(): FlatGridItem;\r\n}\r\n\r\n/**\r\n * Data structure which describes methods and properties present on immutable [[GridCategoryItem]]\r\n * @beta\r\n */\r\nexport interface GridCategoryItem extends FlatGridItemBase {\r\n readonly type: FlatGridItemType.Category;\r\n readonly name: string;\r\n readonly derivedCategory: PropertyCategory;\r\n\r\n /** @deprecated Use [[getChildren]] and filter categories yourself. */\r\n getChildCategories(): GridCategoryItem[];\r\n /** @deprecated Use [[getDescendantsAndSelf]] and filter categories yourself. */\r\n getDescendantCategoriesAndSelf(): GridCategoryItem[];\r\n}\r\n\r\n/**\r\n * Data structure which describes methods and properties present on immutable [[CategorizedPropertyItem]] objects\r\n * @beta\r\n */\r\nexport interface CategorizedPropertyItem extends FlatGridItemBase {\r\n readonly type: CategorizedPropertyTypes;\r\n readonly derivedRecord: PropertyRecord;\r\n readonly parentCategorySelectionKey: string;\r\n readonly parentSelectionKey: string;\r\n\r\n getChildren(): CategorizedPropertyItem[];\r\n}\r\n\r\n/**\r\n * Type which describes immutable [[GridCategoryItem]] or [[CategorizedPropertyItem]]\r\n * @beta\r\n */\r\nexport type FlatGridItem = CategorizedPropertyItem | GridCategoryItem;\r\n"]}
|
|
1
|
+
{"version":3,"file":"FlatGridItem.js","sourceRoot":"","sources":["../../../../../../src/components-react/propertygrid/internal/flat-items/FlatGridItem.ts"],"names":[],"mappings":";AAAA;;;+FAG+F","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module PropertyGrid\r\n */\r\nimport { CategorizedPropertyTypes, FlatGridItemType } from \"./MutableFlatGridItem\";\r\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\r\nimport { PropertyCategory } from \"../../PropertyDataProvider\";\r\n\r\n/**\r\n * Base immutable data structure defining common methods and properties for categories and categorized properties\r\n * @beta\r\n */\r\nexport interface FlatGridItemBase {\r\n readonly isExpanded: boolean;\r\n readonly key: string;\r\n readonly selectionKey: string;\r\n readonly parentSelectionKey: string | undefined;\r\n readonly parentCategorySelectionKey: string | undefined;\r\n readonly depth: number;\r\n readonly label: string;\r\n readonly type: FlatGridItemType;\r\n readonly lastInNumberOfCategories: number;\r\n readonly isLastInRootCategory: boolean;\r\n getDescendantsAndSelf(): FlatGridItem[];\r\n getVisibleDescendantsAndSelf(): FlatGridItem[];\r\n getChildren(): FlatGridItem[];\r\n getLastVisibleDescendantOrSelf(): FlatGridItem;\r\n}\r\n\r\n/**\r\n * Data structure which describes methods and properties present on immutable [[GridCategoryItem]]\r\n * @beta\r\n */\r\nexport interface GridCategoryItem extends FlatGridItemBase {\r\n readonly type: FlatGridItemType.Category;\r\n readonly name: string;\r\n readonly derivedCategory: PropertyCategory;\r\n\r\n /** @deprecated in 3.1. Use [[getChildren]] and filter categories yourself. */\r\n getChildCategories(): GridCategoryItem[];\r\n /** @deprecated in 3.1. Use [[getDescendantsAndSelf]] and filter categories yourself. */\r\n getDescendantCategoriesAndSelf(): GridCategoryItem[];\r\n}\r\n\r\n/**\r\n * Data structure which describes methods and properties present on immutable [[CategorizedPropertyItem]] objects\r\n * @beta\r\n */\r\nexport interface CategorizedPropertyItem extends FlatGridItemBase {\r\n readonly type: CategorizedPropertyTypes;\r\n readonly derivedRecord: PropertyRecord;\r\n readonly parentCategorySelectionKey: string;\r\n readonly parentSelectionKey: string;\r\n\r\n getChildren(): CategorizedPropertyItem[];\r\n}\r\n\r\n/**\r\n * Type which describes immutable [[GridCategoryItem]] or [[CategorizedPropertyItem]]\r\n * @beta\r\n */\r\nexport type FlatGridItem = CategorizedPropertyItem | GridCategoryItem;\r\n"]}
|
|
@@ -105,11 +105,11 @@ export interface IMutableGridCategoryItem extends IMutableFlatPropertyGridItem {
|
|
|
105
105
|
derivedCategory: PropertyCategory;
|
|
106
106
|
isRootCategory: boolean;
|
|
107
107
|
/**
|
|
108
|
-
* @deprecated Use [[getChildren]] and filter categories yourself. Do not use this method to mutate the grid model, as this may lead to unexpected outcomes.
|
|
108
|
+
* @deprecated in 3.1. Use [[getChildren]] and filter categories yourself. Do not use this method to mutate the grid model, as this may lead to unexpected outcomes.
|
|
109
109
|
*/
|
|
110
110
|
getChildCategories(): IMutableGridCategoryItem[];
|
|
111
111
|
/**
|
|
112
|
-
* @deprecated Use [[getDescendantsAndSelf]] and filter categories yourself. Do not use this method to mutate the grid model, as this may lead to unexpected outcomes.
|
|
112
|
+
* @deprecated in 3.1. Use [[getDescendantsAndSelf]] and filter categories yourself. Do not use this method to mutate the grid model, as this may lead to unexpected outcomes.
|
|
113
113
|
*/
|
|
114
114
|
getDescendantCategoriesAndSelf(): IMutableGridCategoryItem[];
|
|
115
115
|
}
|
package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutableFlatGridItem.js","sourceRoot":"","sources":["../../../../../../src/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.ts"],"names":[],"mappings":";;;;;;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,iCAAkC;AAClC,sDAA8B;AAC9B,0DAAiG;AAGjG;;;;;GAKG;AACH,IAA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B,CAAC,MAAsB,EAAE,4BAAiD;QACjG,6DAA6D;QAC7D,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;QAC9C,MAAM,SAAS,GAAG,IAAI,+BAAc,CAAC,KAAK,EAAE,4BAA4B,CAAC,CAAC;QAE1E,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAoB,0BAA0B;QAC5C,OAAO,KAAK,CAAC,0BAA2B,CAAC;IAC3C,CAAC;IAED,IAAoB,kBAAkB;QACpC,OAAO,KAAK,CAAC,kBAAmB,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;CACF;AA1GD,gEA0GC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyGrid\r\n */\r\nimport { immerable } from \"immer\";\r\nimport shortid from \"shortid\";\r\nimport { PropertyDescription, PropertyRecord, PropertyValueFormat } from \"@itwin/appui-abstract\";\r\nimport { PropertyCategory } from \"../../PropertyDataProvider\";\r\n\r\n/**\r\n * Types of FlatGridItems for differentiating what property FlatGridItem is wrapping.\r\n * Category for PropertyCategory\r\n * (Primitive, Array, Struct) for PropertyRecord with valueFormats: (Primitive, Array, Struct)\r\n * @beta\r\n */\r\nexport enum FlatGridItemType {\r\n Category,\r\n Primitive,\r\n Array,\r\n Struct,\r\n}\r\n\r\n/**\r\n * Type which extracts FlatGridItemTypes relevant for working with CategorizedProperties\r\n * @beta\r\n */\r\nexport type CategorizedPropertyTypes = FlatGridItemType.Array | FlatGridItemType.Primitive | FlatGridItemType.Struct;\r\n\r\n/**\r\n * Base mutable data structure defining common methods and properties for both CategorizedProperties and GridCategoryItems\r\n * @beta\r\n */\r\nexport interface IMutableFlatPropertyGridItem {\r\n readonly type: FlatGridItemType;\r\n readonly key: string;\r\n readonly selectionKey: string;\r\n readonly parentSelectionKey: string | undefined;\r\n readonly parentCategorySelectionKey: string | undefined;\r\n readonly depth: number;\r\n readonly label: string;\r\n lastInNumberOfCategories: number;\r\n isLastInRootCategory: boolean;\r\n isExpanded: boolean;\r\n getDescendantsAndSelf(): IMutableFlatGridItem[];\r\n getVisibleDescendantsAndSelf(): IMutableFlatGridItem[];\r\n getChildren(): IMutableFlatGridItem[];\r\n getLastVisibleDescendantOrSelf(): IMutableFlatGridItem;\r\n}\r\n\r\n/**\r\n * Base class for all FlatPropertyGrid items\r\n * @beta\r\n */\r\nexport abstract class MutableFlatPropertyGridItem implements IMutableFlatPropertyGridItem {\r\n public [immerable] = true;\r\n\r\n public readonly key: string = shortid.generate();\r\n protected _isExpanded: boolean = false;\r\n protected _lastInNumberOfCategories: number = 0;\r\n protected _isLastInRootCategory: boolean = false;\r\n\r\n public constructor(private _depth: number, private _parentSelectionKey: string | undefined, private _parentCategorySelectionKey: string | undefined) {\r\n if (this._depth < 0)\r\n throw new Error(\"Depth cannot be negative\");\r\n }\r\n\r\n public abstract type: FlatGridItemType;\r\n public abstract label: string;\r\n public abstract selectionKey: string;\r\n\r\n public get depth() {\r\n return this._depth;\r\n }\r\n\r\n public get parentSelectionKey() {\r\n return this._parentSelectionKey;\r\n }\r\n\r\n public get parentCategorySelectionKey() {\r\n return this._parentCategorySelectionKey;\r\n }\r\n\r\n public get isExpanded() {\r\n return this._isExpanded;\r\n }\r\n\r\n public set isExpanded(value: boolean) {\r\n this._isExpanded = value;\r\n }\r\n\r\n public abstract getChildren(): IMutableFlatGridItem[];\r\n public abstract getSelf(): IMutableFlatGridItem;\r\n\r\n protected getDescendants() {\r\n const descendants: IMutableFlatGridItem[] = [];\r\n this.getChildren().forEach((child) => descendants.push(...child.getDescendantsAndSelf()));\r\n\r\n return descendants;\r\n }\r\n\r\n /**\r\n * Gets a flat list of all FlatGridItems beneath this flat grid item including itself in depth first visiting order.\r\n */\r\n public getDescendantsAndSelf(): IMutableFlatGridItem[] {\r\n return [this.getSelf(), ...this.getDescendants()];\r\n }\r\n\r\n /**\r\n * Gets a flat list of visible FlatGridItems beneath this flat grid item.\r\n */\r\n public getVisibleDescendants(): IMutableFlatGridItem[] {\r\n const descendants: IMutableFlatGridItem[] = [];\r\n if (this.isExpanded)\r\n this.getChildren().forEach((child) => descendants.push(...child.getVisibleDescendantsAndSelf()));\r\n return descendants;\r\n }\r\n\r\n /**\r\n * Gets a flat list of visible FlatGridItems beneath this flat grid item and itself in depth first visiting order.\r\n */\r\n public getVisibleDescendantsAndSelf(): IMutableFlatGridItem[] {\r\n return [this.getSelf(), ...this.getVisibleDescendants()];\r\n }\r\n\r\n /**\r\n * @returns self if item is not expanded, last visible descendant of this item otherwise.\r\n */\r\n public getLastVisibleDescendantOrSelf(): IMutableFlatGridItem {\r\n if (!this.isExpanded)\r\n return this.getSelf();\r\n\r\n const children = this.getChildren();\r\n if (children.length < 1)\r\n return this.getSelf();\r\n\r\n return children[children.length - 1].getLastVisibleDescendantOrSelf();\r\n }\r\n\r\n /**\r\n * Sets lastInNumberOfCategories value and sends it down to this items last child\r\n * @internal\r\n */\r\n public get lastInNumberOfCategories(): number {\r\n if (this.isExpanded && this.getChildren().length > 0)\r\n return 0;\r\n\r\n return this._lastInNumberOfCategories;\r\n }\r\n\r\n public set lastInNumberOfCategories(value: number) {\r\n this._lastInNumberOfCategories = value;\r\n const children = this.getChildren();\r\n if (children.length < 1)\r\n return;\r\n\r\n children[children.length - 1].lastInNumberOfCategories = value;\r\n }\r\n\r\n /**\r\n * Gets and sets isLastInRootCategory value and sends it down to this items last child\r\n * @internal\r\n */\r\n public get isLastInRootCategory(): boolean {\r\n if (this.isExpanded && this.getChildren().length > 0)\r\n return false;\r\n\r\n return this._isLastInRootCategory;\r\n }\r\n\r\n public set isLastInRootCategory(value: boolean) {\r\n this._isLastInRootCategory = value;\r\n const children = this.getChildren();\r\n if (children.length < 1)\r\n return;\r\n\r\n children[children.length - 1].isLastInRootCategory = value;\r\n }\r\n}\r\n\r\n/**\r\n * Data structure which describes methods and properties to be held by Mutable GridCategoryItems\r\n * @beta\r\n */\r\nexport interface IMutableGridCategoryItem extends IMutableFlatPropertyGridItem {\r\n type: FlatGridItemType.Category;\r\n name: string;\r\n derivedCategory: PropertyCategory;\r\n isRootCategory: boolean;\r\n\r\n /**\r\n * @deprecated Use [[getChildren]] and filter categories yourself. Do not use this method to mutate the grid model, as this may lead to unexpected outcomes.\r\n */\r\n getChildCategories(): IMutableGridCategoryItem[];\r\n /**\r\n * @deprecated Use [[getDescendantsAndSelf]] and filter categories yourself. Do not use this method to mutate the grid model, as this may lead to unexpected outcomes.\r\n */\r\n getDescendantCategoriesAndSelf(): IMutableGridCategoryItem[];\r\n}\r\n\r\n/**\r\n * Data structure which describes methods and properties to be held by Mutable CategorizedPropertyItems\r\n * @beta\r\n */\r\nexport interface IMutableCategorizedPropertyItem extends IMutableFlatPropertyGridItem {\r\n readonly type: CategorizedPropertyTypes;\r\n readonly derivedRecord: PropertyRecord;\r\n readonly parentCategorySelectionKey: string;\r\n readonly parentSelectionKey: string;\r\n\r\n getChildren(): IMutableCategorizedPropertyItem[];\r\n}\r\n\r\n/**\r\n * Type which describes mutable GridCategoryItem or CategorizedProperty\r\n * @beta\r\n */\r\nexport type IMutableFlatGridItem = IMutableCategorizedPropertyItem | IMutableGridCategoryItem;\r\n\r\n/**\r\n * Base class for all Mutable CategorizedProperties\r\n * @beta\r\n */\r\nexport abstract class MutableCategorizedProperty extends MutableFlatPropertyGridItem implements Partial<IMutableCategorizedPropertyItem> {\r\n private _derivedRecord: PropertyRecord;\r\n private _selectionKey: string;\r\n\r\n public constructor(\r\n type: CategorizedPropertyTypes,\r\n record: PropertyRecord,\r\n parentSelectionKey: string,\r\n parentCategorySelectionKey: string,\r\n depth: number,\r\n overrideName?: string,\r\n overrideDisplayLabel?: string,\r\n ) {\r\n super(depth, parentSelectionKey, parentCategorySelectionKey);\r\n\r\n const recordType = this.valueTypeToFlatGridType(record.value.valueFormat);\r\n if (recordType !== type) {\r\n const expectedTypeStr = FlatGridItemType[type];\r\n const actualTypeStr = FlatGridItemType[recordType];\r\n throw Error(`Record with incorrect value format passed to property: expected ${expectedTypeStr}, got ${actualTypeStr}`);\r\n }\r\n\r\n const overridenProperty = this.makeOverridenProperty(record.property, overrideName, overrideDisplayLabel);\r\n this._derivedRecord = this.makeDerivedRecord(record, overridenProperty);\r\n\r\n this._selectionKey = `${this.parentSelectionKey}_${this.derivedRecord.property.name}`;\r\n this._isExpanded = !!record.autoExpand;\r\n }\r\n\r\n public abstract override type: CategorizedPropertyTypes;\r\n public abstract override getChildren(): IMutableCategorizedPropertyItem[];\r\n\r\n /**\r\n * Maps PropertyRecord valueFormat to FlatGridItemType\r\n * @param valueType valueFormat to map\r\n * @returns mapped FlatGridItemType\r\n */\r\n private valueTypeToFlatGridType(valueType: PropertyValueFormat) {\r\n switch (valueType) {\r\n case PropertyValueFormat.Primitive:\r\n return FlatGridItemType.Primitive;\r\n case PropertyValueFormat.Array:\r\n return FlatGridItemType.Array;\r\n case PropertyValueFormat.Struct:\r\n return FlatGridItemType.Struct;\r\n /* istanbul ignore next */\r\n default:\r\n const unhandledType: never = valueType;\r\n throw Error(`Property Value Format not handled: ${unhandledType}`);\r\n }\r\n }\r\n\r\n /**\r\n * Make new property description with overriden fields.\r\n * @param propertyDescription property description to override.\r\n * @param overrideName property description name to override.\r\n * @param overrideDisplay property description display name to override.\r\n */\r\n private makeOverridenProperty(propertyDescription: PropertyDescription, overrideName?: string, overrideDisplay?: string): PropertyDescription {\r\n const { name, displayLabel, ...property } = { ...propertyDescription };\r\n const newName = overrideName ?? name;\r\n const newDisplayLabel = overrideDisplay ?? displayLabel;\r\n\r\n return { ...property, name: newName, displayLabel: newDisplayLabel };\r\n }\r\n\r\n /**\r\n * Gets derived property record that has it's property description field overriden\r\n */\r\n private makeDerivedRecord(record: PropertyRecord, overridenPropertyDescription: PropertyDescription) {\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n const { value, property, ...others } = record;\r\n const newRecord = new PropertyRecord(value, overridenPropertyDescription);\r\n\r\n return Object.assign(newRecord, others);\r\n }\r\n\r\n public getSelf(): IMutableCategorizedPropertyItem {\r\n return this;\r\n }\r\n\r\n public override get parentCategorySelectionKey() {\r\n return super.parentCategorySelectionKey!;\r\n }\r\n\r\n public override get parentSelectionKey() {\r\n return super.parentSelectionKey!;\r\n }\r\n\r\n /**\r\n * Unique selection key made of parent selectionKey and this property name.\r\n */\r\n public get selectionKey() {\r\n return this._selectionKey;\r\n }\r\n\r\n public get label() {\r\n return this._derivedRecord.property.displayLabel;\r\n }\r\n\r\n /**\r\n * Record with overriden property description.\r\n */\r\n public get derivedRecord() {\r\n return this._derivedRecord;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"MutableFlatGridItem.js","sourceRoot":"","sources":["../../../../../../src/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.ts"],"names":[],"mappings":";;;;;;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,iCAAkC;AAClC,sDAA8B;AAC9B,0DAAiG;AAGjG;;;;;GAKG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,+DAAQ,CAAA;IACR,iEAAS,CAAA;IACT,yDAAK,CAAA;IACL,2DAAM,CAAA;AACR,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AA6BD;;;GAGG;AACH,MAAsB,2BAA2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;QAE1E,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAoB,0BAA0B;QAC5C,OAAO,KAAK,CAAC,0BAA2B,CAAC;IAC3C,CAAC;IAED,IAAoB,kBAAkB;QACpC,OAAO,KAAK,CAAC,kBAAmB,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;CACF;AA1GD,gEA0GC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyGrid\r\n */\r\nimport { immerable } from \"immer\";\r\nimport shortid from \"shortid\";\r\nimport { PropertyDescription, PropertyRecord, PropertyValueFormat } from \"@itwin/appui-abstract\";\r\nimport { PropertyCategory } from \"../../PropertyDataProvider\";\r\n\r\n/**\r\n * Types of FlatGridItems for differentiating what property FlatGridItem is wrapping.\r\n * Category for PropertyCategory\r\n * (Primitive, Array, Struct) for PropertyRecord with valueFormats: (Primitive, Array, Struct)\r\n * @beta\r\n */\r\nexport enum FlatGridItemType {\r\n Category,\r\n Primitive,\r\n Array,\r\n Struct,\r\n}\r\n\r\n/**\r\n * Type which extracts FlatGridItemTypes relevant for working with CategorizedProperties\r\n * @beta\r\n */\r\nexport type CategorizedPropertyTypes = FlatGridItemType.Array | FlatGridItemType.Primitive | FlatGridItemType.Struct;\r\n\r\n/**\r\n * Base mutable data structure defining common methods and properties for both CategorizedProperties and GridCategoryItems\r\n * @beta\r\n */\r\nexport interface IMutableFlatPropertyGridItem {\r\n readonly type: FlatGridItemType;\r\n readonly key: string;\r\n readonly selectionKey: string;\r\n readonly parentSelectionKey: string | undefined;\r\n readonly parentCategorySelectionKey: string | undefined;\r\n readonly depth: number;\r\n readonly label: string;\r\n lastInNumberOfCategories: number;\r\n isLastInRootCategory: boolean;\r\n isExpanded: boolean;\r\n getDescendantsAndSelf(): IMutableFlatGridItem[];\r\n getVisibleDescendantsAndSelf(): IMutableFlatGridItem[];\r\n getChildren(): IMutableFlatGridItem[];\r\n getLastVisibleDescendantOrSelf(): IMutableFlatGridItem;\r\n}\r\n\r\n/**\r\n * Base class for all FlatPropertyGrid items\r\n * @beta\r\n */\r\nexport abstract class MutableFlatPropertyGridItem implements IMutableFlatPropertyGridItem {\r\n public [immerable] = true;\r\n\r\n public readonly key: string = shortid.generate();\r\n protected _isExpanded: boolean = false;\r\n protected _lastInNumberOfCategories: number = 0;\r\n protected _isLastInRootCategory: boolean = false;\r\n\r\n public constructor(private _depth: number, private _parentSelectionKey: string | undefined, private _parentCategorySelectionKey: string | undefined) {\r\n if (this._depth < 0)\r\n throw new Error(\"Depth cannot be negative\");\r\n }\r\n\r\n public abstract type: FlatGridItemType;\r\n public abstract label: string;\r\n public abstract selectionKey: string;\r\n\r\n public get depth() {\r\n return this._depth;\r\n }\r\n\r\n public get parentSelectionKey() {\r\n return this._parentSelectionKey;\r\n }\r\n\r\n public get parentCategorySelectionKey() {\r\n return this._parentCategorySelectionKey;\r\n }\r\n\r\n public get isExpanded() {\r\n return this._isExpanded;\r\n }\r\n\r\n public set isExpanded(value: boolean) {\r\n this._isExpanded = value;\r\n }\r\n\r\n public abstract getChildren(): IMutableFlatGridItem[];\r\n public abstract getSelf(): IMutableFlatGridItem;\r\n\r\n protected getDescendants() {\r\n const descendants: IMutableFlatGridItem[] = [];\r\n this.getChildren().forEach((child) => descendants.push(...child.getDescendantsAndSelf()));\r\n\r\n return descendants;\r\n }\r\n\r\n /**\r\n * Gets a flat list of all FlatGridItems beneath this flat grid item including itself in depth first visiting order.\r\n */\r\n public getDescendantsAndSelf(): IMutableFlatGridItem[] {\r\n return [this.getSelf(), ...this.getDescendants()];\r\n }\r\n\r\n /**\r\n * Gets a flat list of visible FlatGridItems beneath this flat grid item.\r\n */\r\n public getVisibleDescendants(): IMutableFlatGridItem[] {\r\n const descendants: IMutableFlatGridItem[] = [];\r\n if (this.isExpanded)\r\n this.getChildren().forEach((child) => descendants.push(...child.getVisibleDescendantsAndSelf()));\r\n return descendants;\r\n }\r\n\r\n /**\r\n * Gets a flat list of visible FlatGridItems beneath this flat grid item and itself in depth first visiting order.\r\n */\r\n public getVisibleDescendantsAndSelf(): IMutableFlatGridItem[] {\r\n return [this.getSelf(), ...this.getVisibleDescendants()];\r\n }\r\n\r\n /**\r\n * @returns self if item is not expanded, last visible descendant of this item otherwise.\r\n */\r\n public getLastVisibleDescendantOrSelf(): IMutableFlatGridItem {\r\n if (!this.isExpanded)\r\n return this.getSelf();\r\n\r\n const children = this.getChildren();\r\n if (children.length < 1)\r\n return this.getSelf();\r\n\r\n return children[children.length - 1].getLastVisibleDescendantOrSelf();\r\n }\r\n\r\n /**\r\n * Sets lastInNumberOfCategories value and sends it down to this items last child\r\n * @internal\r\n */\r\n public get lastInNumberOfCategories(): number {\r\n if (this.isExpanded && this.getChildren().length > 0)\r\n return 0;\r\n\r\n return this._lastInNumberOfCategories;\r\n }\r\n\r\n public set lastInNumberOfCategories(value: number) {\r\n this._lastInNumberOfCategories = value;\r\n const children = this.getChildren();\r\n if (children.length < 1)\r\n return;\r\n\r\n children[children.length - 1].lastInNumberOfCategories = value;\r\n }\r\n\r\n /**\r\n * Gets and sets isLastInRootCategory value and sends it down to this items last child\r\n * @internal\r\n */\r\n public get isLastInRootCategory(): boolean {\r\n if (this.isExpanded && this.getChildren().length > 0)\r\n return false;\r\n\r\n return this._isLastInRootCategory;\r\n }\r\n\r\n public set isLastInRootCategory(value: boolean) {\r\n this._isLastInRootCategory = value;\r\n const children = this.getChildren();\r\n if (children.length < 1)\r\n return;\r\n\r\n children[children.length - 1].isLastInRootCategory = value;\r\n }\r\n}\r\n\r\n/**\r\n * Data structure which describes methods and properties to be held by Mutable GridCategoryItems\r\n * @beta\r\n */\r\nexport interface IMutableGridCategoryItem extends IMutableFlatPropertyGridItem {\r\n type: FlatGridItemType.Category;\r\n name: string;\r\n derivedCategory: PropertyCategory;\r\n isRootCategory: boolean;\r\n\r\n /**\r\n * @deprecated in 3.1. Use [[getChildren]] and filter categories yourself. Do not use this method to mutate the grid model, as this may lead to unexpected outcomes.\r\n */\r\n getChildCategories(): IMutableGridCategoryItem[];\r\n /**\r\n * @deprecated in 3.1. Use [[getDescendantsAndSelf]] and filter categories yourself. Do not use this method to mutate the grid model, as this may lead to unexpected outcomes.\r\n */\r\n getDescendantCategoriesAndSelf(): IMutableGridCategoryItem[];\r\n}\r\n\r\n/**\r\n * Data structure which describes methods and properties to be held by Mutable CategorizedPropertyItems\r\n * @beta\r\n */\r\nexport interface IMutableCategorizedPropertyItem extends IMutableFlatPropertyGridItem {\r\n readonly type: CategorizedPropertyTypes;\r\n readonly derivedRecord: PropertyRecord;\r\n readonly parentCategorySelectionKey: string;\r\n readonly parentSelectionKey: string;\r\n\r\n getChildren(): IMutableCategorizedPropertyItem[];\r\n}\r\n\r\n/**\r\n * Type which describes mutable GridCategoryItem or CategorizedProperty\r\n * @beta\r\n */\r\nexport type IMutableFlatGridItem = IMutableCategorizedPropertyItem | IMutableGridCategoryItem;\r\n\r\n/**\r\n * Base class for all Mutable CategorizedProperties\r\n * @beta\r\n */\r\nexport abstract class MutableCategorizedProperty extends MutableFlatPropertyGridItem implements Partial<IMutableCategorizedPropertyItem> {\r\n private _derivedRecord: PropertyRecord;\r\n private _selectionKey: string;\r\n\r\n public constructor(\r\n type: CategorizedPropertyTypes,\r\n record: PropertyRecord,\r\n parentSelectionKey: string,\r\n parentCategorySelectionKey: string,\r\n depth: number,\r\n overrideName?: string,\r\n overrideDisplayLabel?: string,\r\n ) {\r\n super(depth, parentSelectionKey, parentCategorySelectionKey);\r\n\r\n const recordType = this.valueTypeToFlatGridType(record.value.valueFormat);\r\n if (recordType !== type) {\r\n const expectedTypeStr = FlatGridItemType[type];\r\n const actualTypeStr = FlatGridItemType[recordType];\r\n throw Error(`Record with incorrect value format passed to property: expected ${expectedTypeStr}, got ${actualTypeStr}`);\r\n }\r\n\r\n const overridenProperty = this.makeOverridenProperty(record.property, overrideName, overrideDisplayLabel);\r\n this._derivedRecord = this.makeDerivedRecord(record, overridenProperty);\r\n\r\n this._selectionKey = `${this.parentSelectionKey}_${this.derivedRecord.property.name}`;\r\n this._isExpanded = !!record.autoExpand;\r\n }\r\n\r\n public abstract override type: CategorizedPropertyTypes;\r\n public abstract override getChildren(): IMutableCategorizedPropertyItem[];\r\n\r\n /**\r\n * Maps PropertyRecord valueFormat to FlatGridItemType\r\n * @param valueType valueFormat to map\r\n * @returns mapped FlatGridItemType\r\n */\r\n private valueTypeToFlatGridType(valueType: PropertyValueFormat) {\r\n switch (valueType) {\r\n case PropertyValueFormat.Primitive:\r\n return FlatGridItemType.Primitive;\r\n case PropertyValueFormat.Array:\r\n return FlatGridItemType.Array;\r\n case PropertyValueFormat.Struct:\r\n return FlatGridItemType.Struct;\r\n /* istanbul ignore next */\r\n default:\r\n const unhandledType: never = valueType;\r\n throw Error(`Property Value Format not handled: ${unhandledType}`);\r\n }\r\n }\r\n\r\n /**\r\n * Make new property description with overriden fields.\r\n * @param propertyDescription property description to override.\r\n * @param overrideName property description name to override.\r\n * @param overrideDisplay property description display name to override.\r\n */\r\n private makeOverridenProperty(propertyDescription: PropertyDescription, overrideName?: string, overrideDisplay?: string): PropertyDescription {\r\n const { name, displayLabel, ...property } = { ...propertyDescription };\r\n const newName = overrideName ?? name;\r\n const newDisplayLabel = overrideDisplay ?? displayLabel;\r\n\r\n return { ...property, name: newName, displayLabel: newDisplayLabel };\r\n }\r\n\r\n /**\r\n * Gets derived property record that has it's property description field overriden\r\n */\r\n private makeDerivedRecord(record: PropertyRecord, overridenPropertyDescription: PropertyDescription) {\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n const { value, property, ...others } = record;\r\n const newRecord = new PropertyRecord(value, overridenPropertyDescription);\r\n\r\n return Object.assign(newRecord, others);\r\n }\r\n\r\n public getSelf(): IMutableCategorizedPropertyItem {\r\n return this;\r\n }\r\n\r\n public override get parentCategorySelectionKey() {\r\n return super.parentCategorySelectionKey!;\r\n }\r\n\r\n public override get parentSelectionKey() {\r\n return super.parentSelectionKey!;\r\n }\r\n\r\n /**\r\n * Unique selection key made of parent selectionKey and this property name.\r\n */\r\n public get selectionKey() {\r\n return this._selectionKey;\r\n }\r\n\r\n public get label() {\r\n return this._derivedRecord.property.displayLabel;\r\n }\r\n\r\n /**\r\n * Record with overriden property description.\r\n */\r\n public get derivedRecord() {\r\n return this._derivedRecord;\r\n }\r\n}\r\n"]}
|
|
@@ -6,7 +6,7 @@ import { CompositeFilterDescriptorCollection, DistinctValueCollection } from "./
|
|
|
6
6
|
import { ColumnDescription, MutableTableDataProvider, RowItem, TableDataChangeEvent } from "./TableDataProvider";
|
|
7
7
|
/**
|
|
8
8
|
* A Table Data Provider using an array of items.
|
|
9
|
-
* @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this class.
|
|
9
|
+
* @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this class.
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
12
|
export declare class SimpleTableDataProvider implements MutableTableDataProvider {
|
|
@@ -18,7 +18,7 @@ const TableDataProvider_1 = require("./TableDataProvider");
|
|
|
18
18
|
// cSpell:ignore columnfiltering
|
|
19
19
|
/**
|
|
20
20
|
* A Table Data Provider using an array of items.
|
|
21
|
-
* @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this class.
|
|
21
|
+
* @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this class.
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
24
|
class SimpleTableDataProvider {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleTableDataProvider.js","sourceRoot":"","sources":["../../../../src/components-react/table/SimpleTableDataProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0DAAiG;AACjG,kDAAkD;AAClD,6EAA0E;AAC1E,kDAA+C;AAC/C,uEAAqI;AACrI,2DAAiH;AAEjH,4CAA4C;AAC5C,gCAAgC;AAEhC;;;;GAIG;AACH,MAAa,uBAAuB;IAclC,YAAY,OAA4B;QAThC,mBAAc,GAAkB,0BAAa,CAAC,MAAM,CAAC;QACrD,qBAAgB,GAAW,CAAC,CAAC,CAAC;QAGtC,kEAAkE;QAC3D,qBAAgB,GAAG,IAAI,wCAAoB,EAAE,CAAC;QACrD,+DAA+D;QACxD,kBAAa,GAAG,IAAI,wCAAoB,EAAE,CAAC;QAGhD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,yBAAyB,GAAG,EAAE,CAAC;IACtC,CAAC;IAED,2CAA2C;IACpC,QAAQ,CAAC,KAAgB;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAE/B,KAAK,IAAI,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;YAChE,IAAI,CAAC,eA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AoB;IACb,SAAS,CAAC,OAAgB,EAAE,wBAAiC,IAAI;QACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,QAAQ,IAAI,CAAC,EAAE;YACjB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YAEhC,IAAI,CAAC,eAAe,EAAE,CAAC;YAEvB,IAAI,qBAAqB;gBACvB,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;SACnC;IACH,CAAC;IAED,qCAAqC;IAC9B,OAAO,CAAC,OAAgB,EAAE,QAAgB;QAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,QAAQ,IAAI,CAAC,EAAE;YACjB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAE/B,IAAI,QAAQ,GAAG,QAAQ;gBACrB,QAAQ,EAAE,CAAC,CAAK,8CAA8C;YAEhE,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;SAC1C;QAED,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IAEO,YAAY,CAAC,IAAa;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC3C,IAAI,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;gBACzB,OAAO,CAAC,CAAC;SACZ;QACD,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;CACF;AApSD,0DAoSC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Table\r\n */\r\n\r\nimport { Primitives, PropertyRecord, PropertyValueFormat, UiError } from \"@itwin/appui-abstract\";\r\nimport { SortDirection } from \"@itwin/core-react\";\r\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { CompositeFilterDescriptorCollection, DistinctValueCollection, TableDistinctValue } from \"./columnfiltering/ColumnFiltering\";\r\nimport { ColumnDescription, MutableTableDataProvider, RowItem, TableDataChangeEvent } from \"./TableDataProvider\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n// cSpell:ignore columnfiltering\r\n\r\n/**\r\n * A Table Data Provider using an array of items.\r\n * @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this class.\r\n * @public\r\n */\r\nexport class SimpleTableDataProvider implements MutableTableDataProvider {\r\n private _items: RowItem[];\r\n private _rowItemIndices: number[]; // Used for both filtering and sorting\r\n private _columns: ColumnDescription[];\r\n private _secondarySortColumnStack?: number[];\r\n private _sortDirection: SortDirection = SortDirection.NoSort;\r\n private _sortColumnIndex: number = -1;\r\n private _filterDescriptors?: CompositeFilterDescriptorCollection;\r\n\r\n /** Event emitted by the data provider when column data changes */\r\n public onColumnsChanged = new TableDataChangeEvent();\r\n /** Event emitted by the data provider when row data changes */\r\n public onRowsChanged = new TableDataChangeEvent();\r\n\r\n constructor(columns: ColumnDescription[]) {\r\n this._columns = columns;\r\n this._items = [];\r\n this._rowItemIndices = [];\r\n this._secondarySortColumnStack = [];\r\n }\r\n\r\n /** Sets the row items based on an array */\r\n public setItems(items: RowItem[]): void {\r\n this._items = items;\r\n this._rowItemIndices = [];\r\n this.resetRowIndices();\r\n this.onRowsChanged.raiseEvent();\r\n }\r\n\r\n private resetRowIndices(): void {\r\n this._rowItemIndices.splice(0);\r\n\r\n for (let rowIndex = 0; rowIndex < this._items.length; rowIndex++) {\r\n this._rowItemIndices.push(rowIndex);\r\n }\r\n }\r\n\r\n /** Retrieves the column descriptions */\r\n public async getColumns(): Promise<ColumnDescription[]> {\r\n return this._columns;\r\n }\r\n\r\n /** Retrieves the row count */\r\n public async getRowsCount(): Promise<number> {\r\n return this._rowItemIndices.length;\r\n }\r\n\r\n /** Retrieves a specific row by index */\r\n public async getRow(rowIndex: number, unfiltered?: boolean): Promise<RowItem> {\r\n let realRowIndex: number = -1;\r\n\r\n if (unfiltered) {\r\n // istanbul ignore else\r\n if (0 <= rowIndex && rowIndex < this._items.length)\r\n realRowIndex = rowIndex;\r\n } else {\r\n if (0 <= rowIndex && rowIndex < this._rowItemIndices.length)\r\n realRowIndex = this.getRowIndexFromFilteredRowIndex(rowIndex);\r\n }\r\n\r\n if (0 <= realRowIndex && realRowIndex < this._items.length)\r\n return this._items[realRowIndex];\r\n\r\n throw new UiError(UiComponents.loggerCategory(this), `getRow: Invalid row index - ${rowIndex}`);\r\n }\r\n\r\n private getRowIndexFromFilteredRowIndex(filteredRowIndex: number): number {\r\n // istanbul ignore next\r\n if (filteredRowIndex === undefined)\r\n return filteredRowIndex;\r\n\r\n // istanbul ignore next\r\n if (filteredRowIndex < 0 || filteredRowIndex >= this._rowItemIndices.length)\r\n return -1;\r\n\r\n return this._rowItemIndices[filteredRowIndex];\r\n }\r\n\r\n /** Sorts the rows based on the value in a specific column */\r\n public async sort(columnIndex: number, sortDirection: SortDirection): Promise<void> {\r\n // istanbul ignore next\r\n if (columnIndex < 0 || columnIndex >= this._columns.length)\r\n return;\r\n\r\n this._sortColumnIndex = columnIndex;\r\n this._sortDirection = sortDirection;\r\n\r\n if (sortDirection === SortDirection.NoSort) {\r\n if (this._filterDescriptors)\r\n await this.applyFilterDescriptors(this._filterDescriptors);\r\n else\r\n this.resetRowIndices();\r\n return;\r\n }\r\n\r\n this._secondarySortColumnStack = [];\r\n this._secondarySortColumnStack.push(columnIndex);\r\n\r\n // Sort by the column\r\n // eslint-disable-next-line @typescript-eslint/no-this-alias\r\n const dataProvider = this;\r\n this._rowItemIndices.sort((a: number, b: number) => {\r\n return dataProvider.sortDispatcher(dataProvider._items[a], dataProvider._items[b], columnIndex, sortDirection);\r\n });\r\n\r\n delete this._secondarySortColumnStack;\r\n\r\n return;\r\n }\r\n\r\n private sortDispatcher(a: RowItem, b: RowItem, columnIndex: number, sortDirection: SortDirection): number {\r\n let result = this.sortRows(a, b, columnIndex, sortDirection);\r\n\r\n if (result !== 0)\r\n return result;\r\n\r\n // Secondary sort column support\r\n // istanbul ignore else\r\n const column = this._columns[columnIndex];\r\n if (this._secondarySortColumnStack !== undefined &&\r\n column.secondarySortColumn !== undefined &&\r\n column.secondarySortColumn !== columnIndex &&\r\n this._secondarySortColumnStack.indexOf(column.secondarySortColumn) < 0) {\r\n\r\n this._secondarySortColumnStack.push(column.secondarySortColumn);\r\n result = this.sortDispatcher(a, b, column.secondarySortColumn, sortDirection);\r\n this._secondarySortColumnStack.pop();\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private getPrimitiveValue(record: PropertyRecord) {\r\n let primitiveValue: Primitives.Value | undefined;\r\n const recordValue = record.value;\r\n // istanbul ignore else\r\n if (recordValue.valueFormat === PropertyValueFormat.Primitive)\r\n primitiveValue = recordValue.value;\r\n return primitiveValue;\r\n }\r\n\r\n private sortRows(a: RowItem, b: RowItem, columnIndex: number, sortDirection: SortDirection): number {\r\n const aCell = a.cells[columnIndex];\r\n const bCell = b.cells[columnIndex];\r\n\r\n let result: number = 0;\r\n const column = this._columns[columnIndex];\r\n\r\n const propertyDescription = column.propertyDescription;\r\n const valueA = this.getPrimitiveValue(aCell.record as PropertyRecord);\r\n const valueB = this.getPrimitiveValue(bCell.record as PropertyRecord);\r\n // istanbul ignore else\r\n if (valueA !== undefined && valueB !== undefined && propertyDescription)\r\n result = TypeConverterManager.getConverter(propertyDescription.typename, propertyDescription.converter?.name).sortCompare(valueA, valueB, column.sortIgnoreCase);\r\n\r\n if (sortDirection === SortDirection.Descending)\r\n result *= -1;\r\n\r\n return result;\r\n }\r\n\r\n /** Gets distinct values in a column\r\n * @public\r\n */\r\n public async getDistinctValues(columnKey: string, maximumValueCount?: number): Promise<DistinctValueCollection> {\r\n const distinctValues = new DistinctValueCollection();\r\n const columnIndex = this._columns.findIndex((description: ColumnDescription) => description.key === columnKey);\r\n if (columnIndex < 0 || columnIndex >= this._columns.length)\r\n return distinctValues;\r\n\r\n const columnDescription = this._columns[columnIndex];\r\n const propertyDescription = columnDescription.propertyDescription;\r\n const uniqueKeysMap: { [key: string]: TableDistinctValue } = {};\r\n const uniqueValues: any[] = [];\r\n\r\n // istanbul ignore next\r\n if (!propertyDescription)\r\n return distinctValues;\r\n\r\n for (const row of this._items) {\r\n const cell = row.cells[columnIndex];\r\n const record = cell.record;\r\n\r\n // istanbul ignore next\r\n if (record === undefined)\r\n continue;\r\n\r\n const value = this.getPrimitiveValue(record);\r\n const displayValue = await TypeConverterManager\r\n .getConverter(propertyDescription.typename, propertyDescription.converter?.name)\r\n .convertPropertyToString(propertyDescription, value);\r\n\r\n // istanbul ignore next\r\n if (value === undefined || typeof displayValue !== \"string\")\r\n continue;\r\n\r\n const valueKey = value.toString();\r\n if (!uniqueKeysMap.hasOwnProperty(valueKey)) {\r\n const propertyValue: TableDistinctValue = { value, label: displayValue };\r\n\r\n uniqueKeysMap[valueKey] = propertyValue;\r\n uniqueValues.push(propertyValue);\r\n }\r\n }\r\n\r\n distinctValues.values = uniqueValues;\r\n\r\n distinctValues.values.sort((a: TableDistinctValue, b: TableDistinctValue) => {\r\n if (a.value && b.value)\r\n return TypeConverterManager.getConverter(propertyDescription.typename, propertyDescription.converter?.name).sortCompare(a.value, b.value);\r\n return 0;\r\n });\r\n\r\n if (maximumValueCount !== undefined && distinctValues.values.length > maximumValueCount)\r\n distinctValues.values.splice(maximumValueCount);\r\n\r\n return distinctValues;\r\n }\r\n\r\n /** Apply a filter descriptor collection\r\n * @public\r\n */\r\n public async applyFilterDescriptors(filterDescriptors: CompositeFilterDescriptorCollection): Promise<void> {\r\n this._filterDescriptors = filterDescriptors;\r\n\r\n this._rowItemIndices.splice(0);\r\n\r\n this._items.forEach((row: RowItem, i: number) => {\r\n if (filterDescriptors.evaluateRow(row))\r\n this._rowItemIndices.push(i);\r\n });\r\n\r\n if (this._sortDirection !== SortDirection.NoSort) {\r\n await this.sort(this._sortColumnIndex, this._sortDirection);\r\n }\r\n }\r\n\r\n /** Adds a row to the end */\r\n public addRow(rowItem: RowItem): number {\r\n return this.insertRow(rowItem, -1);\r\n }\r\n\r\n /** Inserts a row at a given row index */\r\n public insertRow(rowItem: RowItem, index: number): number {\r\n let newIdx = index;\r\n\r\n if (index < 0 || index >= this._items.length)\r\n newIdx = this._items.push(rowItem) - 1;\r\n else\r\n this._items.splice(newIdx, 0, rowItem);\r\n\r\n this.resetRowIndices();\r\n this.onRowsChanged.raiseEvent();\r\n\r\n return newIdx;\r\n }\r\n\r\n /** Deletes a row */\r\n public deleteRow(rowItem: RowItem, raiseRowsChangedEvent: boolean = true): void {\r\n const rowIndex = this.findRowIndex(rowItem);\r\n if (rowIndex >= 0) {\r\n this._items.splice(rowIndex, 1);\r\n\r\n this.resetRowIndices();\r\n\r\n if (raiseRowsChangedEvent)\r\n this.onRowsChanged.raiseEvent();\r\n }\r\n }\r\n\r\n /** Moves a row to a new row index */\r\n public moveRow(rowItem: RowItem, newIndex: number): number {\r\n const oldIndex = this.findRowIndex(rowItem);\r\n if (oldIndex >= 0) {\r\n this.deleteRow(rowItem, false);\r\n\r\n if (newIndex > oldIndex)\r\n newIndex--; // removing the row will shrink the count by 1\r\n\r\n return this.insertRow(rowItem, newIndex);\r\n }\r\n\r\n return -1;\r\n }\r\n\r\n private findRowIndex(item: RowItem): number {\r\n for (let i = 0; i < this._items.length; i++) {\r\n if (item === this._items[i])\r\n return i;\r\n }\r\n return -1;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SimpleTableDataProvider.js","sourceRoot":"","sources":["../../../../src/components-react/table/SimpleTableDataProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0DAAiG;AACjG,kDAAkD;AAClD,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EvB,IAAI,qBAAqB;gBACvB,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;SACnC;IACH,CAAC;IAED,qCAAqC;IAC9B,OAAO,CAAC,OAAgB,EAAE,QAAgB;QAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,QAAQ,IAAI,CAAC,EAAE;YACjB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAE/B,IAAI,QAAQ,GAAG,QAAQ;gBACrB,QAAQ,EAAE,CAAC,CAAK,8CAA8C;YAEhE,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;SAC1C;QAED,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IAEO,YAAY,CAAC,IAAa;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC3C,IAAI,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;gBACzB,OAAO,CAAC,CAAC;SACZ;QACD,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;CACF;AApSD,0DAoSC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Table\r\n */\r\n\r\nimport { Primitives, PropertyRecord, PropertyValueFormat, UiError } from \"@itwin/appui-abstract\";\r\nimport { SortDirection } from \"@itwin/core-react\";\r\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { CompositeFilterDescriptorCollection, DistinctValueCollection, TableDistinctValue } from \"./columnfiltering/ColumnFiltering\";\r\nimport { ColumnDescription, MutableTableDataProvider, RowItem, TableDataChangeEvent } from \"./TableDataProvider\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n// cSpell:ignore columnfiltering\r\n\r\n/**\r\n * A Table Data Provider using an array of items.\r\n * @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this class.\r\n * @public\r\n */\r\nexport class SimpleTableDataProvider implements MutableTableDataProvider {\r\n private _items: RowItem[];\r\n private _rowItemIndices: number[]; // Used for both filtering and sorting\r\n private _columns: ColumnDescription[];\r\n private _secondarySortColumnStack?: number[];\r\n private _sortDirection: SortDirection = SortDirection.NoSort;\r\n private _sortColumnIndex: number = -1;\r\n private _filterDescriptors?: CompositeFilterDescriptorCollection;\r\n\r\n /** Event emitted by the data provider when column data changes */\r\n public onColumnsChanged = new TableDataChangeEvent();\r\n /** Event emitted by the data provider when row data changes */\r\n public onRowsChanged = new TableDataChangeEvent();\r\n\r\n constructor(columns: ColumnDescription[]) {\r\n this._columns = columns;\r\n this._items = [];\r\n this._rowItemIndices = [];\r\n this._secondarySortColumnStack = [];\r\n }\r\n\r\n /** Sets the row items based on an array */\r\n public setItems(items: RowItem[]): void {\r\n this._items = items;\r\n this._rowItemIndices = [];\r\n this.resetRowIndices();\r\n this.onRowsChanged.raiseEvent();\r\n }\r\n\r\n private resetRowIndices(): void {\r\n this._rowItemIndices.splice(0);\r\n\r\n for (let rowIndex = 0; rowIndex < this._items.length; rowIndex++) {\r\n this._rowItemIndices.push(rowIndex);\r\n }\r\n }\r\n\r\n /** Retrieves the column descriptions */\r\n public async getColumns(): Promise<ColumnDescription[]> {\r\n return this._columns;\r\n }\r\n\r\n /** Retrieves the row count */\r\n public async getRowsCount(): Promise<number> {\r\n return this._rowItemIndices.length;\r\n }\r\n\r\n /** Retrieves a specific row by index */\r\n public async getRow(rowIndex: number, unfiltered?: boolean): Promise<RowItem> {\r\n let realRowIndex: number = -1;\r\n\r\n if (unfiltered) {\r\n // istanbul ignore else\r\n if (0 <= rowIndex && rowIndex < this._items.length)\r\n realRowIndex = rowIndex;\r\n } else {\r\n if (0 <= rowIndex && rowIndex < this._rowItemIndices.length)\r\n realRowIndex = this.getRowIndexFromFilteredRowIndex(rowIndex);\r\n }\r\n\r\n if (0 <= realRowIndex && realRowIndex < this._items.length)\r\n return this._items[realRowIndex];\r\n\r\n throw new UiError(UiComponents.loggerCategory(this), `getRow: Invalid row index - ${rowIndex}`);\r\n }\r\n\r\n private getRowIndexFromFilteredRowIndex(filteredRowIndex: number): number {\r\n // istanbul ignore next\r\n if (filteredRowIndex === undefined)\r\n return filteredRowIndex;\r\n\r\n // istanbul ignore next\r\n if (filteredRowIndex < 0 || filteredRowIndex >= this._rowItemIndices.length)\r\n return -1;\r\n\r\n return this._rowItemIndices[filteredRowIndex];\r\n }\r\n\r\n /** Sorts the rows based on the value in a specific column */\r\n public async sort(columnIndex: number, sortDirection: SortDirection): Promise<void> {\r\n // istanbul ignore next\r\n if (columnIndex < 0 || columnIndex >= this._columns.length)\r\n return;\r\n\r\n this._sortColumnIndex = columnIndex;\r\n this._sortDirection = sortDirection;\r\n\r\n if (sortDirection === SortDirection.NoSort) {\r\n if (this._filterDescriptors)\r\n await this.applyFilterDescriptors(this._filterDescriptors);\r\n else\r\n this.resetRowIndices();\r\n return;\r\n }\r\n\r\n this._secondarySortColumnStack = [];\r\n this._secondarySortColumnStack.push(columnIndex);\r\n\r\n // Sort by the column\r\n // eslint-disable-next-line @typescript-eslint/no-this-alias\r\n const dataProvider = this;\r\n this._rowItemIndices.sort((a: number, b: number) => {\r\n return dataProvider.sortDispatcher(dataProvider._items[a], dataProvider._items[b], columnIndex, sortDirection);\r\n });\r\n\r\n delete this._secondarySortColumnStack;\r\n\r\n return;\r\n }\r\n\r\n private sortDispatcher(a: RowItem, b: RowItem, columnIndex: number, sortDirection: SortDirection): number {\r\n let result = this.sortRows(a, b, columnIndex, sortDirection);\r\n\r\n if (result !== 0)\r\n return result;\r\n\r\n // Secondary sort column support\r\n // istanbul ignore else\r\n const column = this._columns[columnIndex];\r\n if (this._secondarySortColumnStack !== undefined &&\r\n column.secondarySortColumn !== undefined &&\r\n column.secondarySortColumn !== columnIndex &&\r\n this._secondarySortColumnStack.indexOf(column.secondarySortColumn) < 0) {\r\n\r\n this._secondarySortColumnStack.push(column.secondarySortColumn);\r\n result = this.sortDispatcher(a, b, column.secondarySortColumn, sortDirection);\r\n this._secondarySortColumnStack.pop();\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private getPrimitiveValue(record: PropertyRecord) {\r\n let primitiveValue: Primitives.Value | undefined;\r\n const recordValue = record.value;\r\n // istanbul ignore else\r\n if (recordValue.valueFormat === PropertyValueFormat.Primitive)\r\n primitiveValue = recordValue.value;\r\n return primitiveValue;\r\n }\r\n\r\n private sortRows(a: RowItem, b: RowItem, columnIndex: number, sortDirection: SortDirection): number {\r\n const aCell = a.cells[columnIndex];\r\n const bCell = b.cells[columnIndex];\r\n\r\n let result: number = 0;\r\n const column = this._columns[columnIndex];\r\n\r\n const propertyDescription = column.propertyDescription;\r\n const valueA = this.getPrimitiveValue(aCell.record as PropertyRecord);\r\n const valueB = this.getPrimitiveValue(bCell.record as PropertyRecord);\r\n // istanbul ignore else\r\n if (valueA !== undefined && valueB !== undefined && propertyDescription)\r\n result = TypeConverterManager.getConverter(propertyDescription.typename, propertyDescription.converter?.name).sortCompare(valueA, valueB, column.sortIgnoreCase);\r\n\r\n if (sortDirection === SortDirection.Descending)\r\n result *= -1;\r\n\r\n return result;\r\n }\r\n\r\n /** Gets distinct values in a column\r\n * @public\r\n */\r\n public async getDistinctValues(columnKey: string, maximumValueCount?: number): Promise<DistinctValueCollection> {\r\n const distinctValues = new DistinctValueCollection();\r\n const columnIndex = this._columns.findIndex((description: ColumnDescription) => description.key === columnKey);\r\n if (columnIndex < 0 || columnIndex >= this._columns.length)\r\n return distinctValues;\r\n\r\n const columnDescription = this._columns[columnIndex];\r\n const propertyDescription = columnDescription.propertyDescription;\r\n const uniqueKeysMap: { [key: string]: TableDistinctValue } = {};\r\n const uniqueValues: any[] = [];\r\n\r\n // istanbul ignore next\r\n if (!propertyDescription)\r\n return distinctValues;\r\n\r\n for (const row of this._items) {\r\n const cell = row.cells[columnIndex];\r\n const record = cell.record;\r\n\r\n // istanbul ignore next\r\n if (record === undefined)\r\n continue;\r\n\r\n const value = this.getPrimitiveValue(record);\r\n const displayValue = await TypeConverterManager\r\n .getConverter(propertyDescription.typename, propertyDescription.converter?.name)\r\n .convertPropertyToString(propertyDescription, value);\r\n\r\n // istanbul ignore next\r\n if (value === undefined || typeof displayValue !== \"string\")\r\n continue;\r\n\r\n const valueKey = value.toString();\r\n if (!uniqueKeysMap.hasOwnProperty(valueKey)) {\r\n const propertyValue: TableDistinctValue = { value, label: displayValue };\r\n\r\n uniqueKeysMap[valueKey] = propertyValue;\r\n uniqueValues.push(propertyValue);\r\n }\r\n }\r\n\r\n distinctValues.values = uniqueValues;\r\n\r\n distinctValues.values.sort((a: TableDistinctValue, b: TableDistinctValue) => {\r\n if (a.value && b.value)\r\n return TypeConverterManager.getConverter(propertyDescription.typename, propertyDescription.converter?.name).sortCompare(a.value, b.value);\r\n return 0;\r\n });\r\n\r\n if (maximumValueCount !== undefined && distinctValues.values.length > maximumValueCount)\r\n distinctValues.values.splice(maximumValueCount);\r\n\r\n return distinctValues;\r\n }\r\n\r\n /** Apply a filter descriptor collection\r\n * @public\r\n */\r\n public async applyFilterDescriptors(filterDescriptors: CompositeFilterDescriptorCollection): Promise<void> {\r\n this._filterDescriptors = filterDescriptors;\r\n\r\n this._rowItemIndices.splice(0);\r\n\r\n this._items.forEach((row: RowItem, i: number) => {\r\n if (filterDescriptors.evaluateRow(row))\r\n this._rowItemIndices.push(i);\r\n });\r\n\r\n if (this._sortDirection !== SortDirection.NoSort) {\r\n await this.sort(this._sortColumnIndex, this._sortDirection);\r\n }\r\n }\r\n\r\n /** Adds a row to the end */\r\n public addRow(rowItem: RowItem): number {\r\n return this.insertRow(rowItem, -1);\r\n }\r\n\r\n /** Inserts a row at a given row index */\r\n public insertRow(rowItem: RowItem, index: number): number {\r\n let newIdx = index;\r\n\r\n if (index < 0 || index >= this._items.length)\r\n newIdx = this._items.push(rowItem) - 1;\r\n else\r\n this._items.splice(newIdx, 0, rowItem);\r\n\r\n this.resetRowIndices();\r\n this.onRowsChanged.raiseEvent();\r\n\r\n return newIdx;\r\n }\r\n\r\n /** Deletes a row */\r\n public deleteRow(rowItem: RowItem, raiseRowsChangedEvent: boolean = true): void {\r\n const rowIndex = this.findRowIndex(rowItem);\r\n if (rowIndex >= 0) {\r\n this._items.splice(rowIndex, 1);\r\n\r\n this.resetRowIndices();\r\n\r\n if (raiseRowsChangedEvent)\r\n this.onRowsChanged.raiseEvent();\r\n }\r\n }\r\n\r\n /** Moves a row to a new row index */\r\n public moveRow(rowItem: RowItem, newIndex: number): number {\r\n const oldIndex = this.findRowIndex(rowItem);\r\n if (oldIndex >= 0) {\r\n this.deleteRow(rowItem, false);\r\n\r\n if (newIndex > oldIndex)\r\n newIndex--; // removing the row will shrink the count by 1\r\n\r\n return this.insertRow(rowItem, newIndex);\r\n }\r\n\r\n return -1;\r\n }\r\n\r\n private findRowIndex(item: RowItem): number {\r\n for (let i = 0; i < this._items.length; i++) {\r\n if (item === this._items[i])\r\n return i;\r\n }\r\n return -1;\r\n }\r\n}\r\n"]}
|
|
@@ -7,7 +7,7 @@ import { HorizontalAlignment, SortDirection } from "@itwin/core-react";
|
|
|
7
7
|
import { ItemColorOverrides, ItemStyle } from "../properties/ItemStyle";
|
|
8
8
|
import { CompositeFilterDescriptorCollection, DistinctValueCollection } from "./columnfiltering/ColumnFiltering";
|
|
9
9
|
/** Filter Renderer for a Table column
|
|
10
|
-
* @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
10
|
+
* @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
13
13
|
export declare enum FilterRenderer {
|
|
@@ -19,7 +19,7 @@ export declare enum FilterRenderer {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Column definition provided to Table.
|
|
22
|
-
* @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
22
|
+
* @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
export interface ColumnDescription {
|
|
@@ -58,7 +58,7 @@ export interface ColumnDescription {
|
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Cell definition provided to Table.
|
|
61
|
-
* @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
61
|
+
* @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
62
62
|
* @public
|
|
63
63
|
*/
|
|
64
64
|
export interface CellItem {
|
|
@@ -81,7 +81,7 @@ export interface CellItem {
|
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Row definition provided to Table.
|
|
84
|
-
* @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
84
|
+
* @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
85
85
|
* @public
|
|
86
86
|
*/
|
|
87
87
|
export interface RowItem {
|
|
@@ -107,12 +107,12 @@ export interface RowItem {
|
|
|
107
107
|
getValueFromCell?: (columnKey: string) => any;
|
|
108
108
|
}
|
|
109
109
|
/** An interface table data change listeners
|
|
110
|
-
* @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this type.
|
|
110
|
+
* @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this type.
|
|
111
111
|
* @public
|
|
112
112
|
*/
|
|
113
113
|
export declare type TableDataChangesListener = () => void;
|
|
114
114
|
/** An event broadcasted on table data changes
|
|
115
|
-
* @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this class.
|
|
115
|
+
* @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this class.
|
|
116
116
|
* @public
|
|
117
117
|
*/
|
|
118
118
|
export declare class TableDataChangeEvent extends BeEvent<TableDataChangesListener> {
|
|
@@ -120,7 +120,7 @@ export declare class TableDataChangeEvent extends BeEvent<TableDataChangesListen
|
|
|
120
120
|
/**
|
|
121
121
|
* TableDataProvider provides data to the Table.
|
|
122
122
|
* It also provides support for data Sorting & Filtering.
|
|
123
|
-
* @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
123
|
+
* @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
124
124
|
* @public
|
|
125
125
|
*/
|
|
126
126
|
export interface TableDataProvider {
|
|
@@ -150,7 +150,7 @@ export interface TableDataProvider {
|
|
|
150
150
|
/**
|
|
151
151
|
* MutableTableDataProvider provides mutation methods for data in the Table.
|
|
152
152
|
* Useful for Drag & Drop processing.
|
|
153
|
-
* @deprecated Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
153
|
+
* @deprecated in 3.5. Use the Table component in @itwin/itwinui-react instead, which does not use this interface.
|
|
154
154
|
* @public
|
|
155
155
|
*/
|
|
156
156
|
export interface MutableTableDataProvider extends TableDataProvider {
|