@itwin/components-react 4.3.1 → 4.5.0
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/CHANGELOG.md +21 -4
- package/lib/cjs/components-react/common/DelayedSpinner.js +2 -3
- package/lib/cjs/components-react/common/DelayedSpinner.js.map +1 -1
- package/lib/cjs/components-react/common/SubscriptionScheduler.d.ts +1 -1
- package/lib/cjs/components-react/common/SubscriptionScheduler.d.ts.map +1 -1
- package/lib/cjs/components-react/common/SubscriptionScheduler.js +18 -23
- package/lib/cjs/components-react/common/SubscriptionScheduler.js.map +1 -1
- package/lib/cjs/components-react/common/UseAsyncValue.d.ts.map +1 -1
- package/lib/cjs/components-react/common/UseAsyncValue.js +6 -8
- package/lib/cjs/components-react/common/UseAsyncValue.js.map +1 -1
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.d.ts.map +1 -1
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js +8 -7
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
- package/lib/cjs/components-react/converters/NumericTypeConverter.js +2 -4
- package/lib/cjs/components-react/converters/NumericTypeConverter.js.map +1 -1
- package/lib/cjs/components-react/converters/StringTypeConverter.d.ts.map +1 -1
- package/lib/cjs/components-react/converters/StringTypeConverter.js +3 -5
- package/lib/cjs/components-react/converters/StringTypeConverter.js.map +1 -1
- package/lib/cjs/components-react/converters/TypeConverter.js +1 -2
- package/lib/cjs/components-react/converters/TypeConverter.js.map +1 -1
- package/lib/cjs/components-react/converters/TypeConverterManager.d.ts.map +1 -1
- package/lib/cjs/components-react/converters/TypeConverterManager.js +8 -2
- package/lib/cjs/components-react/converters/TypeConverterManager.js.map +1 -1
- package/lib/cjs/components-react/editors/CustomNumberEditor.js +6 -8
- package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/cjs/components-react/editors/DateTimeEditor.js +2 -3
- package/lib/cjs/components-react/editors/DateTimeEditor.js.map +1 -1
- package/lib/cjs/components-react/editors/PopupButton.js +3 -4
- package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
- package/lib/cjs/components-react/editors/TextEditor.js +2 -4
- package/lib/cjs/components-react/editors/TextEditor.js.map +1 -1
- package/lib/cjs/components-react/favorite/FavoritePropertyList.js +3 -3
- package/lib/cjs/components-react/favorite/FavoritePropertyList.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilder.d.ts +23 -9
- package/lib/cjs/components-react/filter-builder/FilterBuilder.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilder.js +19 -8
- package/lib/cjs/components-react/filter-builder/FilterBuilder.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderContext.d.ts +8 -5
- package/lib/cjs/components-react/filter-builder/FilterBuilderContext.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderContext.js +46 -18
- package/lib/cjs/components-react/filter-builder/FilterBuilderContext.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.js +7 -4
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.scss +8 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.js +3 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.d.ts +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js +1 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -3
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.d.ts +11 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js +3 -4
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.d.ts +58 -12
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.js +107 -13
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js +3 -4
- package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
- package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js +2 -3
- package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
- package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -2
- package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +3 -6
- package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -2
- package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +3 -6
- package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js +1 -2
- package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +1 -2
- package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js +1 -2
- package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
- package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js +48 -54
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js +11 -13
- package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
- package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -2
- package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +1 -2
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +2 -3
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +5 -7
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/selectable-content/SelectableContent.js +2 -3
- package/lib/cjs/components-react/selectable-content/SelectableContent.js.map +1 -1
- package/lib/cjs/components-react/toolbar/InternalToolbarComponent.d.ts +144 -0
- package/lib/cjs/components-react/toolbar/InternalToolbarComponent.d.ts.map +1 -0
- package/lib/cjs/components-react/toolbar/InternalToolbarComponent.js +548 -0
- package/lib/cjs/components-react/toolbar/InternalToolbarComponent.js.map +1 -0
- package/lib/cjs/components-react/toolbar/ItemWrapper.js +3 -3
- package/lib/cjs/components-react/toolbar/ItemWrapper.js.map +1 -1
- package/lib/cjs/components-react/toolbar/Items.js +5 -5
- package/lib/cjs/components-react/toolbar/Items.js.map +1 -1
- package/lib/cjs/components-react/toolbar/Overflow.js +3 -3
- package/lib/cjs/components-react/toolbar/Overflow.js.map +1 -1
- package/lib/cjs/components-react/toolbar/OverflowPanel.js +5 -5
- package/lib/cjs/components-react/toolbar/OverflowPanel.js.map +1 -1
- package/lib/cjs/components-react/toolbar/PopupItem.js +4 -4
- package/lib/cjs/components-react/toolbar/PopupItem.js.map +1 -1
- package/lib/cjs/components-react/toolbar/PopupItemWithDrag.d.ts +1 -1
- package/lib/cjs/components-react/toolbar/PopupItemWithDrag.d.ts.map +1 -1
- package/lib/cjs/components-react/toolbar/PopupItemWithDrag.js +4 -4
- package/lib/cjs/components-react/toolbar/PopupItemWithDrag.js.map +1 -1
- package/lib/cjs/components-react/toolbar/PopupItemsPanel.js +2 -2
- package/lib/cjs/components-react/toolbar/PopupItemsPanel.js.map +1 -1
- package/lib/cjs/components-react/toolbar/Toolbar.d.ts +3 -3
- package/lib/cjs/components-react/toolbar/Toolbar.d.ts.map +1 -1
- package/lib/cjs/components-react/toolbar/Toolbar.js +2 -69
- package/lib/cjs/components-react/toolbar/Toolbar.js.map +1 -1
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.d.ts +6 -106
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js +6 -481
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
- package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.d.ts +14 -0
- package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.d.ts.map +1 -0
- package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.js +118 -0
- package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.js.map +1 -0
- package/lib/cjs/components-react/tree/controlled/Observable.d.ts +1 -1
- package/lib/cjs/components-react/tree/controlled/Observable.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/Observable.js +3 -4
- package/lib/cjs/components-react/tree/controlled/Observable.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.d.ts +1 -2
- package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.js +37 -68
- package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEventHandler.js +6 -7
- package/lib/cjs/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeModel.js +7 -8
- package/lib/cjs/components-react/tree/controlled/TreeModel.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.d.ts +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js +28 -35
- package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/ControlledTree.js +6 -14
- package/lib/cjs/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/TreeRenderer.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/TreeRenderer.js +3 -3
- package/lib/cjs/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js +1 -2
- package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/internal/TreeModelMutator.js +2 -2
- package/lib/cjs/components-react/tree/controlled/internal/TreeModelMutator.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.d.ts +2 -3
- package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js +53 -100
- package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
- package/lib/cjs/components-react.d.ts +6 -2
- package/lib/cjs/components-react.d.ts.map +1 -1
- package/lib/cjs/components-react.js +6 -2
- package/lib/cjs/components-react.js.map +1 -1
- package/lib/esm/components-react/common/DelayedSpinner.js +2 -3
- package/lib/esm/components-react/common/DelayedSpinner.js.map +1 -1
- package/lib/esm/components-react/common/SubscriptionScheduler.d.ts +1 -1
- package/lib/esm/components-react/common/SubscriptionScheduler.d.ts.map +1 -1
- package/lib/esm/components-react/common/SubscriptionScheduler.js +12 -17
- package/lib/esm/components-react/common/SubscriptionScheduler.js.map +1 -1
- package/lib/esm/components-react/common/UseAsyncValue.d.ts.map +1 -1
- package/lib/esm/components-react/common/UseAsyncValue.js +1 -3
- package/lib/esm/components-react/common/UseAsyncValue.js.map +1 -1
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.d.ts.map +1 -1
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.js +7 -6
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
- package/lib/esm/components-react/converters/NumericTypeConverter.js +2 -4
- package/lib/esm/components-react/converters/NumericTypeConverter.js.map +1 -1
- package/lib/esm/components-react/converters/StringTypeConverter.d.ts.map +1 -1
- package/lib/esm/components-react/converters/StringTypeConverter.js +3 -5
- package/lib/esm/components-react/converters/StringTypeConverter.js.map +1 -1
- package/lib/esm/components-react/converters/TypeConverter.js +1 -2
- package/lib/esm/components-react/converters/TypeConverter.js.map +1 -1
- package/lib/esm/components-react/converters/TypeConverterManager.d.ts.map +1 -1
- package/lib/esm/components-react/converters/TypeConverterManager.js +7 -1
- package/lib/esm/components-react/converters/TypeConverterManager.js.map +1 -1
- package/lib/esm/components-react/editors/CustomNumberEditor.js +6 -8
- package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/esm/components-react/editors/DateTimeEditor.js +2 -3
- package/lib/esm/components-react/editors/DateTimeEditor.js.map +1 -1
- package/lib/esm/components-react/editors/PopupButton.js +3 -4
- package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
- package/lib/esm/components-react/editors/TextEditor.js +2 -4
- package/lib/esm/components-react/editors/TextEditor.js.map +1 -1
- package/lib/esm/components-react/favorite/FavoritePropertyList.js +3 -3
- package/lib/esm/components-react/favorite/FavoritePropertyList.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilder.d.ts +23 -9
- package/lib/esm/components-react/filter-builder/FilterBuilder.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilder.js +17 -7
- package/lib/esm/components-react/filter-builder/FilterBuilder.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderContext.d.ts +8 -5
- package/lib/esm/components-react/filter-builder/FilterBuilderContext.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderContext.js +46 -18
- package/lib/esm/components-react/filter-builder/FilterBuilderContext.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.js +8 -5
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.scss +8 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.js +3 -2
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.d.ts +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js +1 -2
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -3
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.d.ts +11 -2
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js +3 -4
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderState.d.ts +58 -12
- package/lib/esm/components-react/filter-builder/FilterBuilderState.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderState.js +100 -7
- package/lib/esm/components-react/filter-builder/FilterBuilderState.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js +3 -4
- package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
- package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js +2 -3
- package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
- package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -2
- package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +3 -6
- package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -2
- package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +3 -6
- package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js +1 -2
- package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +1 -2
- package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js +1 -2
- package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
- package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js +48 -54
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js +11 -13
- package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
- package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
- package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
- package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -2
- package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +1 -2
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +2 -3
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +5 -7
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/selectable-content/SelectableContent.js +2 -3
- package/lib/esm/components-react/selectable-content/SelectableContent.js.map +1 -1
- package/lib/esm/components-react/toolbar/InternalToolbarComponent.d.ts +144 -0
- package/lib/esm/components-react/toolbar/InternalToolbarComponent.d.ts.map +1 -0
- package/lib/esm/components-react/toolbar/InternalToolbarComponent.js +512 -0
- package/lib/esm/components-react/toolbar/InternalToolbarComponent.js.map +1 -0
- package/lib/esm/components-react/toolbar/ItemWrapper.js +1 -1
- package/lib/esm/components-react/toolbar/ItemWrapper.js.map +1 -1
- package/lib/esm/components-react/toolbar/Items.js +1 -1
- package/lib/esm/components-react/toolbar/Items.js.map +1 -1
- package/lib/esm/components-react/toolbar/Overflow.js +1 -1
- package/lib/esm/components-react/toolbar/Overflow.js.map +1 -1
- package/lib/esm/components-react/toolbar/OverflowPanel.js +1 -1
- package/lib/esm/components-react/toolbar/OverflowPanel.js.map +1 -1
- package/lib/esm/components-react/toolbar/PopupItem.js +1 -1
- package/lib/esm/components-react/toolbar/PopupItem.js.map +1 -1
- package/lib/esm/components-react/toolbar/PopupItemWithDrag.d.ts +1 -1
- package/lib/esm/components-react/toolbar/PopupItemWithDrag.d.ts.map +1 -1
- package/lib/esm/components-react/toolbar/PopupItemWithDrag.js +1 -1
- package/lib/esm/components-react/toolbar/PopupItemWithDrag.js.map +1 -1
- package/lib/esm/components-react/toolbar/PopupItemsPanel.js +1 -1
- package/lib/esm/components-react/toolbar/PopupItemsPanel.js.map +1 -1
- package/lib/esm/components-react/toolbar/Toolbar.d.ts +3 -3
- package/lib/esm/components-react/toolbar/Toolbar.d.ts.map +1 -1
- package/lib/esm/components-react/toolbar/Toolbar.js +2 -66
- package/lib/esm/components-react/toolbar/Toolbar.js.map +1 -1
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.d.ts +6 -106
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js +5 -471
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
- package/lib/esm/components-react/toolbar/useConditionalSynchedItems.d.ts +14 -0
- package/lib/esm/components-react/toolbar/useConditionalSynchedItems.d.ts.map +1 -0
- package/lib/esm/components-react/toolbar/useConditionalSynchedItems.js +91 -0
- package/lib/esm/components-react/toolbar/useConditionalSynchedItems.js.map +1 -0
- package/lib/esm/components-react/tree/controlled/Observable.d.ts +1 -1
- package/lib/esm/components-react/tree/controlled/Observable.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/Observable.js +1 -2
- package/lib/esm/components-react/tree/controlled/Observable.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.d.ts +1 -2
- package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.js +24 -55
- package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEventHandler.js +1 -2
- package/lib/esm/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeModel.js +7 -8
- package/lib/esm/components-react/tree/controlled/TreeModel.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeNodeLoader.d.ts +1 -1
- package/lib/esm/components-react/tree/controlled/TreeNodeLoader.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js +18 -25
- package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/ControlledTree.js +6 -14
- package/lib/esm/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/TreeRenderer.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/TreeRenderer.js +3 -3
- package/lib/esm/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/internal/SparseTree.js +1 -2
- package/lib/esm/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/internal/TreeModelMutator.js +1 -1
- package/lib/esm/components-react/tree/controlled/internal/TreeModelMutator.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.d.ts +2 -3
- package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js +52 -99
- package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
- package/lib/esm/components-react.d.ts +6 -2
- package/lib/esm/components-react.d.ts.map +1 -1
- package/lib/esm/components-react.js +6 -2
- package/lib/esm/components-react.js.map +1 -1
- package/lib/public/locales/en/UiComponents.json +4 -1
- package/package.json +9 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledTree.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/component/ControlledTree.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAQ7D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AA4CpF;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,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,UAAU,EAAE,aAAa,CAAC,CACxC,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAe,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;IACnD,CAAC,EAAE,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC;IAEvC,OAAO,eAAe,CAAC;AACzB,CAAC;AAUD,SAAS,MAAM,CAAC,KAAkB;IAChC,IAAI,KAAK,CAAC,OAAO,EAAE;QACjB,OAAO,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAC7B,KAAK,CAAC,eAAe,EAAE,CACxB,CAAC,CAAC,CAAC,CACF,6BAAK,SAAS,EAAC,kCAAkC;YAC/C,oBAAC,cAAc,IAAC,IAAI,EAAC,OAAO,GAAG,CAC3B,CACP,CAAC;KACH;IACD,IAAI,KAAK,CAAC,MAAM,EAAE;QAChB,OAAO,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAC5B,KAAK,CAAC,cAAc,EAAE,CACvB,CAAC,CAAC,CAAC,CACF,oBAAC,YAAY;YACX,2BAAG,SAAS,EAAC,wCAAwC,IAClD,YAAY,CAAC,SAAS,CAAC,gBAAgB,CAAC,CACvC,CACS,CAChB,CAAC;KACH;IAED,OAAO,KAAK,CAAC,QAAQ,CAAC;AACxB,CAAC;AAED,SAAS,aAAa,CACpB,mBAA4B;IAE5B,OAAO,KAAK,CAAC,WAAW,CACtB,CAAC,IAA8C,EAAU,EAAE;QACzD,MAAM,aAAa,GACjB,eAAe,CAAC,IAAI,CAAC,IAAI,mBAAmB,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW;YACtE,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,UAAU,GAAG,CAAC,CAAC;QACrB,uFAAuF;QACvF,OAAO,aAAa,GAAG,UAAU,CAAC;IACpC,CAAC,EACD,CAAC,mBAAmB,CAAC,CACtB,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { FillCentered } from \"@itwin/core-react\";\nimport { DelayedSpinner } from \"../../../common/DelayedSpinner\";\nimport type { SelectionMode } from \"../../../common/selection/SelectionModes\";\nimport { UiComponents } from \"../../../UiComponents\";\nimport type { HighlightableTreeProps } from \"../../HighlightingEngine\";\nimport { TreeImageLoader } from \"../../ImageLoader\";\nimport { TreeEventDispatcher } from \"../TreeEventDispatcher\";\nimport type { TreeEvents } from \"../TreeEvents\";\nimport type {\n TreeModel,\n TreeModelNode,\n TreeModelNodePlaceholder,\n VisibleTreeNodes,\n} from \"../TreeModel\";\nimport { computeVisibleNodes, isTreeModelNode } from \"../TreeModel\";\nimport type { ITreeNodeLoader } from \"../TreeNodeLoader\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer\";\nimport type { RenderedItemsRange, TreeRendererProps } from \"./TreeRenderer\";\nimport { TreeRenderer } from \"./TreeRenderer\";\nimport { useElementsScrollStorage } from \"../../../common/UseElementsScrollStorage\";\n\n/**\n * Properties for [[ControlledTree]]\n * @public\n */\nexport interface ControlledTreeProps extends CommonProps {\n /** Model of the tree to display. */\n model: TreeModel;\n /** Node loader used to load root nodes and placeholder nodes. */\n nodeLoader: ITreeNodeLoader;\n /** Tree events handler. */\n eventsHandler: TreeEvents;\n /** Mode of nodes' selection in tree. */\n selectionMode: SelectionMode;\n /**\n * Specifies whether to show node description or not. It is used in default node renderer and to determine node height.\n * If custom node renderer and node height callbacks are used it does nothing.\n */\n descriptionsEnabled?: boolean;\n /**\n * Specifies whether to show node icon or not. It is used in default node renderer.\n * If custom node renderer is used it does nothing.\n */\n iconsEnabled?: boolean;\n /**\n * Used to highlight matches when filtering tree.\n * It is passed to treeRenderer.\n */\n nodeHighlightingProps?: HighlightableTreeProps;\n /** Custom renderer to be used to render a tree. */\n treeRenderer?: (props: TreeRendererProps) => React.ReactElement;\n /** Custom renderer to be used while root nodes is loading. */\n spinnerRenderer?: () => React.ReactElement;\n /** Custom renderer to be used when there is no data to show in tree. */\n noDataRenderer?: () => React.ReactElement;\n /** Callback that is invoked when rendered items range changes. */\n onItemsRendered?: (items: RenderedItemsRange) => void;\n /** Width of the tree renderer. */\n width: number;\n /** Height of the tree renderer. */\n height: number;\n}\n\n/**\n * React tree component which rendering is fully controlled from outside.\n * @public\n */\nexport function ControlledTree(props: ControlledTreeProps) {\n const nodeHeight = useNodeHeight(!!props.descriptionsEnabled);\n const imageLoader = React.useMemo(() => new TreeImageLoader(), []);\n const nodeRenderer = React.useCallback(\n (nodeProps: TreeNodeRendererProps) => (\n <TreeNodeRenderer\n {...nodeProps}\n descriptionEnabled={props.descriptionsEnabled}\n imageLoader={props.iconsEnabled ? imageLoader : undefined}\n />\n ),\n [props.descriptionsEnabled, props.iconsEnabled, imageLoader]\n );\n\n const visibleNodes = React.useMemo(\n () => computeVisibleNodes(props.model),\n [props.model]\n );\n const eventDispatcher = useEventDispatcher(\n props.nodeLoader,\n props.eventsHandler,\n props.selectionMode,\n visibleNodes\n );\n\n const treeProps: TreeRendererProps = {\n nodeRenderer,\n nodeHeight,\n visibleNodes,\n treeActions: eventDispatcher,\n nodeLoader: props.nodeLoader,\n nodeHighlightingProps: props.nodeHighlightingProps,\n onItemsRendered: props.onItemsRendered,\n width: props.width,\n height: props.height,\n };\n\n const loading = useRootNodeLoader(visibleNodes, props.nodeLoader);\n const noData = visibleNodes.getNumRootNodes() === 0;\n return (\n <Loader\n loading={loading}\n noData={noData}\n spinnerRenderer={props.spinnerRenderer}\n noDataRenderer={props.noDataRenderer}\n >\n {props.treeRenderer ? (\n props.treeRenderer(treeProps)\n ) : (\n <TreeRenderer {...treeProps} />\n )}\n </Loader>\n );\n}\n\n/**\n * Returns callbacks for persisting and restoring [[ControlledTree]] layout state.\n * Returned `ref` should be set on container containing ControlledTree.\n * @public\n */\nexport function useControlledTreeLayoutStorage<T extends Element>() {\n return useElementsScrollStorage<T>(\"ReactWindow__VariableSizeList\");\n}\n\nfunction useRootNodeLoader(\n visibleNodes: VisibleTreeNodes,\n nodeLoader: ITreeNodeLoader\n): boolean {\n React.useEffect(() => {\n if (visibleNodes.getNumRootNodes() === undefined) {\n const subscription = nodeLoader\n .loadNode(visibleNodes.getModel().getRootNode(), 0)\n .subscribe();\n return () => subscription.unsubscribe();\n }\n\n return () => {};\n }, [visibleNodes, nodeLoader]);\n\n return visibleNodes.getNumRootNodes() === undefined;\n}\n\nfunction useEventDispatcher(\n nodeLoader: ITreeNodeLoader,\n treeEvents: TreeEvents,\n selectionMode: SelectionMode,\n visibleNodes: VisibleTreeNodes\n) {\n /* istanbul ignore next */\n const getVisibleNodes = React.useCallback(() => visibleNodes, [visibleNodes]);\n const eventDispatcher = React.useMemo(\n () => new TreeEventDispatcher(treeEvents, nodeLoader, selectionMode),\n [treeEvents, nodeLoader, selectionMode]\n );\n\n React.useEffect(() => {\n eventDispatcher.setVisibleNodes(getVisibleNodes);\n }, [eventDispatcher, getVisibleNodes]);\n\n return eventDispatcher;\n}\n\ninterface LoaderProps {\n loading: boolean;\n noData: boolean;\n spinnerRenderer?: () => React.ReactElement;\n noDataRenderer?: () => React.ReactElement;\n children: React.ReactElement;\n}\n\nfunction Loader(props: LoaderProps) {\n if (props.loading) {\n return props.spinnerRenderer ? (\n props.spinnerRenderer()\n ) : (\n <div className=\"components-controlledTree-loader\">\n <DelayedSpinner size=\"large\" />\n </div>\n );\n }\n if (props.noData) {\n return props.noDataRenderer ? (\n props.noDataRenderer()\n ) : (\n <FillCentered>\n <p className=\"components-controlledTree-errorMessage\">\n {UiComponents.translate(\"general.noData\")}\n </p>\n </FillCentered>\n );\n }\n\n return props.children;\n}\n\nfunction useNodeHeight(\n descriptionsEnabled: boolean\n): (node: TreeModelNode | TreeModelNodePlaceholder) => number {\n return React.useCallback(\n (node: TreeModelNode | TreeModelNodePlaceholder): number => {\n const contentHeight =\n isTreeModelNode(node) && descriptionsEnabled && node && node.description\n ? 43\n : 24;\n const borderSize = 1;\n // Not counting node's border size twice because we want neighboring borders to overlap\n return contentHeight + borderSize;\n },\n [descriptionsEnabled]\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ControlledTree.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/component/ControlledTree.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAQ7D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AA4CpF;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;IACnE,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CACpC,CAAC,SAAgC,EAAE,EAAE,CAAC,CACpC,oBAA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AAI,KAAK,CAAC,MAAM,EAAE;QAChB,OAAO,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAC5B,KAAK,CAAC,cAAc,EAAE,CACvB,CAAC,CAAC,CAAC,CACF,oBAAC,YAAY;YACX,2BAAG,SAAS,EAAC,wCAAwC,IAClD,YAAY,CAAC,SAAS,CAAC,gBAAgB,CAAC,CACvC,CACS,CAChB,CAAC;KACH;IAED,OAAO,KAAK,CAAC,QAAQ,CAAC;AACxB,CAAC;AAED,SAAS,aAAa,CACpB,mBAA4B;IAE5B,OAAO,KAAK,CAAC,WAAW,CACtB,CAAC,IAA8C,EAAU,EAAE;QACzD,MAAM,aAAa,GACjB,eAAe,CAAC,IAAI,CAAC,IAAI,mBAAmB,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW;YACtE,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,UAAU,GAAG,CAAC,CAAC;QACrB,uFAAuF;QACvF,OAAO,aAAa,GAAG,UAAU,CAAC;IACpC,CAAC,EACD,CAAC,mBAAmB,CAAC,CACtB,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { FillCentered } from \"@itwin/core-react\";\nimport { DelayedSpinner } from \"../../../common/DelayedSpinner\";\nimport type { SelectionMode } from \"../../../common/selection/SelectionModes\";\nimport { UiComponents } from \"../../../UiComponents\";\nimport type { HighlightableTreeProps } from \"../../HighlightingEngine\";\nimport { TreeImageLoader } from \"../../ImageLoader\";\nimport { TreeEventDispatcher } from \"../TreeEventDispatcher\";\nimport type { TreeEvents } from \"../TreeEvents\";\nimport type {\n TreeModel,\n TreeModelNode,\n TreeModelNodePlaceholder,\n VisibleTreeNodes,\n} from \"../TreeModel\";\nimport { computeVisibleNodes, isTreeModelNode } from \"../TreeModel\";\nimport type { ITreeNodeLoader } from \"../TreeNodeLoader\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer\";\nimport type { RenderedItemsRange, TreeRendererProps } from \"./TreeRenderer\";\nimport { TreeRenderer } from \"./TreeRenderer\";\nimport { useElementsScrollStorage } from \"../../../common/UseElementsScrollStorage\";\n\n/**\n * Properties for [[ControlledTree]]\n * @public\n */\nexport interface ControlledTreeProps extends CommonProps {\n /** Model of the tree to display. */\n model: TreeModel;\n /** Node loader used to load root nodes and placeholder nodes. */\n nodeLoader: ITreeNodeLoader;\n /** Tree events handler. */\n eventsHandler: TreeEvents;\n /** Mode of nodes' selection in tree. */\n selectionMode: SelectionMode;\n /**\n * Specifies whether to show node description or not. It is used in default node renderer and to determine node height.\n * If custom node renderer and node height callbacks are used it does nothing.\n */\n descriptionsEnabled?: boolean;\n /**\n * Specifies whether to show node icon or not. It is used in default node renderer.\n * If custom node renderer is used it does nothing.\n */\n iconsEnabled?: boolean;\n /**\n * Used to highlight matches when filtering tree.\n * It is passed to treeRenderer.\n */\n nodeHighlightingProps?: HighlightableTreeProps;\n /** Custom renderer to be used to render a tree. */\n treeRenderer?: (props: TreeRendererProps) => React.ReactElement;\n /** Custom renderer to be used while root nodes is loading. */\n spinnerRenderer?: () => React.ReactElement;\n /** Custom renderer to be used when there is no data to show in tree. */\n noDataRenderer?: () => React.ReactElement;\n /** Callback that is invoked when rendered items range changes. */\n onItemsRendered?: (items: RenderedItemsRange) => void;\n /** Width of the tree renderer. */\n width: number;\n /** Height of the tree renderer. */\n height: number;\n}\n\n/**\n * React tree component which rendering is fully controlled from outside.\n * @public\n */\nexport function ControlledTree(props: ControlledTreeProps) {\n const nodeHeight = useNodeHeight(!!props.descriptionsEnabled);\n const imageLoader = React.useMemo(() => new TreeImageLoader(), []);\n const nodeRenderer = React.useCallback(\n (nodeProps: TreeNodeRendererProps) => (\n <TreeNodeRenderer\n {...nodeProps}\n descriptionEnabled={props.descriptionsEnabled}\n imageLoader={props.iconsEnabled ? imageLoader : undefined}\n />\n ),\n [props.descriptionsEnabled, props.iconsEnabled, imageLoader]\n );\n\n const visibleNodesRef = React.useRef<VisibleTreeNodes>();\n visibleNodesRef.current = React.useMemo(\n () => computeVisibleNodes(props.model),\n [props.model]\n );\n\n const eventDispatcher = React.useMemo(\n () =>\n new TreeEventDispatcher(\n props.eventsHandler,\n props.nodeLoader,\n props.selectionMode,\n () => visibleNodesRef.current!\n ),\n [props.eventsHandler, props.nodeLoader, props.selectionMode]\n );\n\n const treeProps: TreeRendererProps = {\n nodeRenderer,\n nodeHeight,\n visibleNodes: visibleNodesRef.current,\n treeActions: eventDispatcher,\n nodeLoader: props.nodeLoader,\n nodeHighlightingProps: props.nodeHighlightingProps,\n onItemsRendered: props.onItemsRendered,\n width: props.width,\n height: props.height,\n };\n\n const loading = useRootNodeLoader(visibleNodesRef.current, props.nodeLoader);\n const noData = visibleNodesRef.current.getNumRootNodes() === 0;\n return (\n <Loader\n loading={loading}\n noData={noData}\n spinnerRenderer={props.spinnerRenderer}\n noDataRenderer={props.noDataRenderer}\n >\n {props.treeRenderer ? (\n props.treeRenderer(treeProps)\n ) : (\n <TreeRenderer {...treeProps} />\n )}\n </Loader>\n );\n}\n\n/**\n * Returns callbacks for persisting and restoring [[ControlledTree]] layout state.\n * Returned `ref` should be set on container containing ControlledTree.\n * @public\n */\nexport function useControlledTreeLayoutStorage<T extends Element>() {\n return useElementsScrollStorage<T>(\"ReactWindow__VariableSizeList\");\n}\n\nfunction useRootNodeLoader(\n visibleNodes: VisibleTreeNodes,\n nodeLoader: ITreeNodeLoader\n): boolean {\n React.useEffect(() => {\n if (visibleNodes.getNumRootNodes() === undefined) {\n const subscription = nodeLoader\n .loadNode(visibleNodes.getModel().getRootNode(), 0)\n .subscribe();\n return () => subscription.unsubscribe();\n }\n\n return () => {};\n }, [visibleNodes, nodeLoader]);\n\n return visibleNodes.getNumRootNodes() === undefined;\n}\n\ninterface LoaderProps {\n loading: boolean;\n noData: boolean;\n spinnerRenderer?: () => React.ReactElement;\n noDataRenderer?: () => React.ReactElement;\n children: React.ReactElement;\n}\n\nfunction Loader(props: LoaderProps) {\n if (props.loading) {\n return props.spinnerRenderer ? (\n props.spinnerRenderer()\n ) : (\n <div className=\"components-controlledTree-loader\">\n <DelayedSpinner size=\"large\" />\n </div>\n );\n }\n if (props.noData) {\n return props.noDataRenderer ? (\n props.noDataRenderer()\n ) : (\n <FillCentered>\n <p className=\"components-controlledTree-errorMessage\">\n {UiComponents.translate(\"general.noData\")}\n </p>\n </FillCentered>\n );\n }\n\n return props.children;\n}\n\nfunction useNodeHeight(\n descriptionsEnabled: boolean\n): (node: TreeModelNode | TreeModelNodePlaceholder) => number {\n return React.useCallback(\n (node: TreeModelNode | TreeModelNodePlaceholder): number => {\n const contentHeight =\n isTreeModelNode(node) && descriptionsEnabled && node && node.description\n ? 43\n : 24;\n const borderSize = 1;\n // Not counting node's border size twice because we want neighboring borders to overlap\n return contentHeight + borderSize;\n },\n [descriptionsEnabled]\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,KAAK,EAAE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AG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;AAqC/D;;;GAGG;AACH,qBAAa,YACX,SAAQ,KAAK,CAAC,SAAS,CAAC,iBAAiB,CACzC,YAAW,sBAAsB;IAEjC,OAAO,CAAC,IAAI,CAA6C;IAEzD,kBAAkB;IACX,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS;IAKzC,MAAM;CAGvB"}
|
|
@@ -9,14 +9,14 @@ import "./ControlledTree.scss";
|
|
|
9
9
|
import classnames from "classnames";
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import { areEqual, VariableSizeList } from "react-window";
|
|
12
|
-
import { concat } from "rxjs
|
|
13
|
-
import { timer } from "rxjs/internal/observable/timer";
|
|
12
|
+
import { concat, timer } from "rxjs";
|
|
14
13
|
import { assert } from "@itwin/core-bentley";
|
|
15
14
|
import { Tree as CoreTree, TreeNodePlaceholder } from "@itwin/core-react";
|
|
16
15
|
import { createContextWithMandatoryProvider } from "../../../common/UseContextWithMandatoryProvider";
|
|
17
16
|
import { HighlightingEngine } from "../../HighlightingEngine";
|
|
18
17
|
import { isTreeModelNode, isTreeModelNodePlaceholder, isTreeModelRootNode, } from "../TreeModel";
|
|
19
18
|
import { TreeNodeRenderer } from "./TreeNodeRenderer";
|
|
19
|
+
import { toRxjsObservable } from "../Observable";
|
|
20
20
|
const NODE_LOAD_DELAY = 500;
|
|
21
21
|
/** [[TreeRenderer]] context provider, consumer and custom hook. */
|
|
22
22
|
const [
|
|
@@ -171,7 +171,7 @@ function useNodeLoading(node, visibleNodes, nodeLoader) {
|
|
|
171
171
|
if (!isTreeModelNode(parentNode) && !isTreeModelRootNode(parentNode)) {
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
|
-
const subscription = concat(timer(NODE_LOAD_DELAY), nodeLoader.loadNode(parentNode, node.childIndex)).subscribe();
|
|
174
|
+
const subscription = concat(timer(NODE_LOAD_DELAY), toRxjsObservable(nodeLoader.loadNode(parentNode, node.childIndex))).subscribe();
|
|
175
175
|
return () => subscription.unsubscribe();
|
|
176
176
|
},
|
|
177
177
|
// Mounted node component never changes its node key, thus it's safe to run this effect only once for every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AAErG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAO9D,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,eAAe,GAAG,GAAG,CAAC;AAyF5B,mEAAmE;AACnE,MAAM;AACJ,4CAA4C;AAC5C,2BAA2B;AAE3B,4CAA4C;AAC5C,4BAA4B;AAE5B,mDAAmD;AACnD,sBAAsB,EACvB,GAAG,kCAAkC,CACpC,qBAAqB,CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,YACX,SAAQ,KAAK,CAAC,SAA4B;IAD5C;;QAIU,SAAI,GAAG,KAA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F,uBAAuB;QACvB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,SAAS;YACjE,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;gBACzB,QAAQ,EAAE,MAAM;gBAChB,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;IACP,CAAC,EACD,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAClC,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAkC;IAC5D,0BAA0B;IAC1B,IAAI,OAAO,CAAC,OAAO;QACjB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,6BAA6B,CAAC,CAAC;AACvE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./ControlledTree.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ListChildComponentProps,\n ListOnItemsRenderedProps,\n} from \"react-window\";\nimport { areEqual, VariableSizeList } from \"react-window\";\nimport { concat } from \"rxjs/internal/observable/concat\";\nimport { timer } from \"rxjs/internal/observable/timer\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { Tree as CoreTree, TreeNodePlaceholder } from \"@itwin/core-react\";\nimport { createContextWithMandatoryProvider } from \"../../../common/UseContextWithMandatoryProvider\";\nimport type { HighlightableTreeProps } from \"../../HighlightingEngine\";\nimport { HighlightingEngine } from \"../../HighlightingEngine\";\nimport type { TreeActions } from \"../TreeActions\";\nimport type {\n TreeModelNode,\n TreeModelNodePlaceholder,\n VisibleTreeNodes,\n} from \"../TreeModel\";\nimport {\n isTreeModelNode,\n isTreeModelNodePlaceholder,\n isTreeModelRootNode,\n} from \"../TreeModel\";\nimport type { ITreeNodeLoader } from \"../TreeNodeLoader\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer\";\n\nconst NODE_LOAD_DELAY = 500;\n\n/**\n * Data structure that describes range of rendered items in the tree.\n * @public\n */\nexport interface RenderedItemsRange {\n overscanStartIndex: number;\n overscanStopIndex: number;\n visibleStartIndex: number;\n visibleStopIndex: number;\n}\n\n/**\n * Properties for [[TreeRenderer]] component.\n * @public\n */\nexport interface TreeRendererProps {\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Callback that is used to determine node height. */\n nodeHeight: (\n node: TreeModelNode | TreeModelNodePlaceholder,\n index: number\n ) => number;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Callback to render custom node. */\n nodeRenderer?: (props: TreeNodeRendererProps) => React.ReactNode;\n\n /** Properties used to highlight nodes and scroll to active match while filtering. */\n nodeHighlightingProps?: HighlightableTreeProps;\n\n /** Callback that is called when rendered items range changes. */\n onItemsRendered?: (renderedItems: RenderedItemsRange) => void;\n\n /**\n * Callback used when an editor closes\n * @internal\n */\n onNodeEditorClosed?: () => void;\n\n /** Width of the tree area. */\n width: number;\n\n /** Height of the tree area. */\n height: number;\n}\n\n/**\n * Attributes found on TreeRenderer component\n * @public\n */\nexport interface TreeRendererAttributes {\n /**\n * Scroll to the specified node.\n * @param nodeId Id of the target node to scroll to.\n * @param alignment Controls scrolling behavior. See [react-window](https://github.com/bvaughn/react-window) documentation\n * on `scrollToItem` for details.\n */\n scrollToNode(nodeId: string, alignment?: Alignment): void;\n}\n\ntype Alignment = \"auto\" | \"smart\" | \"center\" | \"end\" | \"start\";\n\n/** [[TreeRenderer]] context that is provided to each rendered node. */\ninterface TreeRendererContext {\n /** Callback to render custom node. */\n nodeRenderer: (props: TreeNodeRendererProps) => React.ReactNode;\n\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Engine used to created node highlighting properties. */\n highlightingEngine?: HighlightingEngine;\n\n /** Callback used detect when label is rendered. It is used by TreeRenderer for scrolling to active match. */\n onLabelRendered?: (node: TreeModelNode) => void;\n\n /** Callback used when an editor closes */\n onNodeEditorClosed?: () => void;\n}\n\n/** [[TreeRenderer]] context provider, consumer and custom hook. */\nconst [\n /** Context of [[TreeRenderer]] provider. */\n TreeRendererContextProvider,\n\n /** Context of [[TreeRenderer]] consumer. */\n _TreeRendererContextConsumer,\n\n /** Custom hook to use [[TreeRenderer]] context. */\n useTreeRendererContext,\n] = createContextWithMandatoryProvider<TreeRendererContext>(\n \"TreeRendererContext\"\n);\n\n/**\n * Default tree rendering component.\n * @public\n */\nexport class TreeRenderer\n extends React.Component<TreeRendererProps>\n implements TreeRendererAttributes\n{\n private _ref = React.createRef<TreeRendererAttributes>();\n\n /** @inheritdoc */\n public scrollToNode(nodeId: string, alignment?: Alignment) {\n // istanbul ignore else\n if (this._ref.current) this._ref.current.scrollToNode(nodeId, alignment);\n }\n\n public override render() {\n return <TreeRendererInner ref={this._ref} {...this.props} />;\n }\n}\n\n// eslint-disable-next-line react/display-name\nconst TreeRendererInner = React.forwardRef<\n TreeRendererAttributes,\n TreeRendererProps\n>((props, ref) => {\n const variableSizeListRef = React.useRef<VariableSizeList>(null);\n useTreeRendererAttributes(ref, variableSizeListRef, props.visibleNodes);\n\n const previousVisibleNodes = usePrevious(props.visibleNodes);\n const previousNodeHeight = usePrevious(props.nodeHeight);\n if (\n (previousVisibleNodes !== undefined &&\n previousVisibleNodes !== props.visibleNodes) ||\n (previousNodeHeight !== undefined &&\n previousNodeHeight !== props.nodeHeight)\n ) {\n /* istanbul ignore else */\n if (variableSizeListRef.current) {\n variableSizeListRef.current.resetAfterIndex(0, false);\n }\n }\n\n const coreTreeRef = React.useRef<CoreTree>(null);\n const onLabelRendered = useScrollToActiveMatch(\n coreTreeRef,\n props.nodeHighlightingProps\n );\n const highlightingEngine = React.useMemo(\n () =>\n props.nodeHighlightingProps &&\n new HighlightingEngine(props.nodeHighlightingProps),\n [props.nodeHighlightingProps]\n );\n\n const rendererContext = React.useMemo<TreeRendererContext>(\n () => ({\n nodeRenderer: props.nodeRenderer\n ? props.nodeRenderer\n : (nodeProps) => <TreeNodeRenderer {...nodeProps} />,\n treeActions: props.treeActions,\n nodeLoader: props.nodeLoader,\n visibleNodes: props.visibleNodes,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed: () => {\n setFocusToSelected(coreTreeRef);\n props.onNodeEditorClosed && props.onNodeEditorClosed();\n },\n }),\n [props, onLabelRendered, highlightingEngine]\n );\n\n const itemKey = React.useCallback(\n (index: number) => getNodeKey(props.visibleNodes.getAtIndex(index)!),\n [props.visibleNodes]\n );\n\n const { nodeHeight, visibleNodes } = props;\n const itemSize = React.useCallback(\n (index: number) => nodeHeight(visibleNodes.getAtIndex(index)!, index),\n [nodeHeight, visibleNodes]\n );\n\n const { nodeHighlightingProps } = props;\n React.useEffect(() => {\n const highlightedNodeId = getHighlightedNodeId(nodeHighlightingProps);\n if (!highlightedNodeId) return;\n\n let index = 0;\n for (const node of visibleNodes) {\n if (isTreeModelNode(node) && node.id === highlightedNodeId) break;\n\n index++;\n }\n\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(index);\n }, [nodeHighlightingProps]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyDown(e);\n },\n [props.treeActions]\n );\n\n const handleKeyUp = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyUp(e);\n },\n [props.treeActions]\n );\n\n const onItemsRendered = props.onItemsRendered;\n const handleRenderedItemsChange = React.useCallback(\n (onItemsRenderedProps: ListOnItemsRenderedProps) => {\n onItemsRendered && onItemsRendered({ ...onItemsRenderedProps });\n },\n [onItemsRendered]\n );\n\n return (\n <TreeRendererContextProvider value={rendererContext}>\n <CoreTree\n ref={coreTreeRef}\n className={classnames(\n \"components-controlledTree\",\n \"components-smallEditor-host\"\n )}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n >\n <VariableSizeList\n ref={variableSizeListRef}\n className={\"ReactWindow__VariableSizeList\"}\n width={props.width}\n height={props.height}\n itemCount={props.visibleNodes.getNumNodes()}\n itemSize={itemSize}\n estimatedItemSize={25}\n overscanCount={10}\n itemKey={itemKey}\n onItemsRendered={handleRenderedItemsChange}\n >\n {Node}\n </VariableSizeList>\n </CoreTree>\n </TreeRendererContextProvider>\n );\n});\n\nfunction getNodeKey(node: TreeModelNode | TreeModelNodePlaceholder): string {\n if (isTreeModelNode(node)) {\n return node.id;\n }\n return `${node.parentId || \"\"}-${node.childIndex}`;\n}\n\nconst Node = React.memo<React.FC<ListChildComponentProps>>(function Node(\n props: ListChildComponentProps\n) {\n const { index, style } = props;\n\n const {\n nodeRenderer,\n visibleNodes,\n treeActions,\n nodeLoader,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed,\n } = useTreeRendererContext(Node);\n const node = visibleNodes.getAtIndex(index)!;\n\n useNodeLoading(node, visibleNodes, nodeLoader);\n\n // Mark selected node's wrapper to make detecting consecutively selected nodes with css selectors possible\n const className = classnames(\"node-wrapper\", {\n \"is-selected\": isTreeModelNode(node) && node.isSelected,\n });\n\n const isEditing = React.useRef(false);\n React.useEffect(() => {\n if (!isTreeModelNode(node)) return;\n\n if (!isEditing.current && node.editingInfo) {\n isEditing.current = true;\n } else if (isEditing.current && node.editingInfo === undefined) {\n isEditing.current = false;\n /* istanbul ignore else */\n if (onNodeEditorClosed) onNodeEditorClosed();\n }\n }, [node, onNodeEditorClosed]);\n\n return (\n <div className={className} style={style}>\n {React.useMemo(() => {\n if (isTreeModelNode(node)) {\n const nodeHighlightProps = highlightingEngine\n ? highlightingEngine.createRenderProps(node)\n : undefined;\n return nodeRenderer({\n node,\n treeActions,\n onLabelRendered,\n nodeHighlightProps,\n });\n }\n\n return <TreeNodePlaceholder level={node.depth} />;\n }, [\n node,\n treeActions,\n nodeRenderer,\n onLabelRendered,\n highlightingEngine,\n ])}\n </div>\n );\n},\nareEqual);\n\nfunction useNodeLoading(\n node: TreeModelNode | TreeModelNodePlaceholder,\n visibleNodes: VisibleTreeNodes,\n nodeLoader: ITreeNodeLoader\n): void {\n React.useEffect(\n () => {\n if (!isTreeModelNodePlaceholder(node)) {\n return;\n }\n\n const treeModel = visibleNodes.getModel();\n const parentNode = node.parentId\n ? treeModel.getNode(node.parentId)\n : treeModel.getRootNode();\n if (!isTreeModelNode(parentNode) && !isTreeModelRootNode(parentNode)) {\n return;\n }\n\n const subscription = concat(\n timer(NODE_LOAD_DELAY),\n nodeLoader.loadNode(parentNode, node.childIndex)\n ).subscribe();\n return () => subscription.unsubscribe();\n },\n // Mounted node component never changes its node key, thus it's safe to run this effect only once for every\n // nodeLoader change.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [nodeLoader]\n );\n}\n\nfunction useTreeRendererAttributes(\n ref: React.Ref<TreeRendererAttributes>,\n variableSizeListRef: React.RefObject<VariableSizeList>,\n visibleNodes: VisibleTreeNodes\n) {\n const visibleNodesRef = React.useRef(visibleNodes);\n visibleNodesRef.current = visibleNodes;\n React.useImperativeHandle(\n ref,\n () => ({\n scrollToNode: (nodeId, alignment) => {\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(\n visibleNodesRef.current.getIndexOfNode(nodeId),\n alignment\n );\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n}\n\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = React.useRef<T>();\n\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n\nfunction getHighlightedNodeId(highlightableTreeProps?: HighlightableTreeProps) {\n return highlightableTreeProps && highlightableTreeProps.activeMatch\n ? highlightableTreeProps.activeMatch.nodeId\n : undefined;\n}\n\nfunction useScrollToActiveMatch(\n treeRef: React.RefObject<CoreTree>,\n highlightableTreeProps?: HighlightableTreeProps\n) {\n const scrollToActive = React.useRef(false);\n React.useEffect(() => {\n scrollToActive.current = true;\n }, [highlightableTreeProps]);\n\n const onLabelRendered = React.useCallback(\n (node: TreeModelNode) => {\n const highlightedNodeId = getHighlightedNodeId(highlightableTreeProps);\n if (\n !treeRef.current ||\n !scrollToActive.current ||\n !highlightedNodeId ||\n highlightedNodeId !== node.id\n )\n return;\n\n scrollToActive.current = false;\n const scrollTo = [\n ...treeRef.current.getElementsByClassName(\n HighlightingEngine.ACTIVE_CLASS_NAME\n ),\n ];\n // istanbul ignore else\n if (scrollTo.length > 0 && scrollTo[0].scrollIntoView !== undefined)\n scrollTo[0].scrollIntoView({\n behavior: \"auto\",\n block: \"nearest\",\n inline: \"end\",\n });\n },\n [highlightableTreeProps, treeRef]\n );\n\n return onLabelRendered;\n}\n\nfunction setFocusToSelected(treeRef: React.RefObject<CoreTree>) {\n /* istanbul ignore else */\n if (treeRef.current)\n treeRef.current.setFocusByClassName(\".core-tree-node.is-selected\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,MAAM,iD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3C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC;IAChC,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAE7B,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CACvC,CAAC,IAAmB,EAAE,EAAE;QACtB,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;QACvE,IACE,CAAC,OAAO,CAAC,OAAO;YAChB,CAAC,cAAc,CAAC,OAAO;YACvB,CAAC,iBAAiB;YAClB,iBAAiB,KAAK,IAAI,CAAC,EAAE;YAE7B,OAAO;QAET,cAAc,CAAC,OAAO,GAAG,KAAK,CAAC;QAC/B,MAAM,QAAQ,GAAG;YACf,GAAG,OAAO,CAAC,OAAO,CAAC,sBAAsB,CACvC,kBAAkB,CAAC,iBAAiB,CACrC;SACF,CAAC;QACF,uBAAuB;QACvB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,SAAS;YACjE,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;gBACzB,QAAQ,EAAE,MAAM;gBAChB,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;IACP,CAAC,EACD,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAClC,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAkC;IAC5D,0BAA0B;IAC1B,IAAI,OAAO,CAAC,OAAO;QACjB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,6BAA6B,CAAC,CAAC;AACvE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./ControlledTree.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ListChildComponentProps,\n ListOnItemsRenderedProps,\n} from \"react-window\";\nimport { areEqual, VariableSizeList } from \"react-window\";\nimport { concat, timer } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { Tree as CoreTree, TreeNodePlaceholder } from \"@itwin/core-react\";\nimport { createContextWithMandatoryProvider } from \"../../../common/UseContextWithMandatoryProvider\";\nimport type { HighlightableTreeProps } from \"../../HighlightingEngine\";\nimport { HighlightingEngine } from \"../../HighlightingEngine\";\nimport type { TreeActions } from \"../TreeActions\";\nimport type {\n TreeModelNode,\n TreeModelNodePlaceholder,\n VisibleTreeNodes,\n} from \"../TreeModel\";\nimport {\n isTreeModelNode,\n isTreeModelNodePlaceholder,\n isTreeModelRootNode,\n} from \"../TreeModel\";\nimport type { ITreeNodeLoader } from \"../TreeNodeLoader\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer\";\nimport { toRxjsObservable } from \"../Observable\";\n\nconst NODE_LOAD_DELAY = 500;\n\n/**\n * Data structure that describes range of rendered items in the tree.\n * @public\n */\nexport interface RenderedItemsRange {\n overscanStartIndex: number;\n overscanStopIndex: number;\n visibleStartIndex: number;\n visibleStopIndex: number;\n}\n\n/**\n * Properties for [[TreeRenderer]] component.\n * @public\n */\nexport interface TreeRendererProps {\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Callback that is used to determine node height. */\n nodeHeight: (\n node: TreeModelNode | TreeModelNodePlaceholder,\n index: number\n ) => number;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Callback to render custom node. */\n nodeRenderer?: (props: TreeNodeRendererProps) => React.ReactNode;\n\n /** Properties used to highlight nodes and scroll to active match while filtering. */\n nodeHighlightingProps?: HighlightableTreeProps;\n\n /** Callback that is called when rendered items range changes. */\n onItemsRendered?: (renderedItems: RenderedItemsRange) => void;\n\n /**\n * Callback used when an editor closes\n * @internal\n */\n onNodeEditorClosed?: () => void;\n\n /** Width of the tree area. */\n width: number;\n\n /** Height of the tree area. */\n height: number;\n}\n\n/**\n * Attributes found on TreeRenderer component\n * @public\n */\nexport interface TreeRendererAttributes {\n /**\n * Scroll to the specified node.\n * @param nodeId Id of the target node to scroll to.\n * @param alignment Controls scrolling behavior. See [react-window](https://github.com/bvaughn/react-window) documentation\n * on `scrollToItem` for details.\n */\n scrollToNode(nodeId: string, alignment?: Alignment): void;\n}\n\ntype Alignment = \"auto\" | \"smart\" | \"center\" | \"end\" | \"start\";\n\n/** [[TreeRenderer]] context that is provided to each rendered node. */\ninterface TreeRendererContext {\n /** Callback to render custom node. */\n nodeRenderer: (props: TreeNodeRendererProps) => React.ReactNode;\n\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Engine used to created node highlighting properties. */\n highlightingEngine?: HighlightingEngine;\n\n /** Callback used detect when label is rendered. It is used by TreeRenderer for scrolling to active match. */\n onLabelRendered?: (node: TreeModelNode) => void;\n\n /** Callback used when an editor closes */\n onNodeEditorClosed?: () => void;\n}\n\n/** [[TreeRenderer]] context provider, consumer and custom hook. */\nconst [\n /** Context of [[TreeRenderer]] provider. */\n TreeRendererContextProvider,\n\n /** Context of [[TreeRenderer]] consumer. */\n _TreeRendererContextConsumer,\n\n /** Custom hook to use [[TreeRenderer]] context. */\n useTreeRendererContext,\n] = createContextWithMandatoryProvider<TreeRendererContext>(\n \"TreeRendererContext\"\n);\n\n/**\n * Default tree rendering component.\n * @public\n */\nexport class TreeRenderer\n extends React.Component<TreeRendererProps>\n implements TreeRendererAttributes\n{\n private _ref = React.createRef<TreeRendererAttributes>();\n\n /** @inheritdoc */\n public scrollToNode(nodeId: string, alignment?: Alignment) {\n // istanbul ignore else\n if (this._ref.current) this._ref.current.scrollToNode(nodeId, alignment);\n }\n\n public override render() {\n return <TreeRendererInner ref={this._ref} {...this.props} />;\n }\n}\n\n// eslint-disable-next-line react/display-name\nconst TreeRendererInner = React.forwardRef<\n TreeRendererAttributes,\n TreeRendererProps\n>((props, ref) => {\n const variableSizeListRef = React.useRef<VariableSizeList>(null);\n useTreeRendererAttributes(ref, variableSizeListRef, props.visibleNodes);\n\n const previousVisibleNodes = usePrevious(props.visibleNodes);\n const previousNodeHeight = usePrevious(props.nodeHeight);\n if (\n (previousVisibleNodes !== undefined &&\n previousVisibleNodes !== props.visibleNodes) ||\n (previousNodeHeight !== undefined &&\n previousNodeHeight !== props.nodeHeight)\n ) {\n /* istanbul ignore else */\n if (variableSizeListRef.current) {\n variableSizeListRef.current.resetAfterIndex(0, false);\n }\n }\n\n const coreTreeRef = React.useRef<CoreTree>(null);\n const onLabelRendered = useScrollToActiveMatch(\n coreTreeRef,\n props.nodeHighlightingProps\n );\n const highlightingEngine = React.useMemo(\n () =>\n props.nodeHighlightingProps &&\n new HighlightingEngine(props.nodeHighlightingProps),\n [props.nodeHighlightingProps]\n );\n\n const rendererContext = React.useMemo<TreeRendererContext>(\n () => ({\n nodeRenderer: props.nodeRenderer\n ? props.nodeRenderer\n : (nodeProps) => <TreeNodeRenderer {...nodeProps} />,\n treeActions: props.treeActions,\n nodeLoader: props.nodeLoader,\n visibleNodes: props.visibleNodes,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed: () => {\n setFocusToSelected(coreTreeRef);\n props.onNodeEditorClosed && props.onNodeEditorClosed();\n },\n }),\n [props, onLabelRendered, highlightingEngine]\n );\n\n const itemKey = React.useCallback(\n (index: number) => getNodeKey(props.visibleNodes.getAtIndex(index)!),\n [props.visibleNodes]\n );\n\n const { nodeHeight, visibleNodes } = props;\n const itemSize = React.useCallback(\n (index: number) => nodeHeight(visibleNodes.getAtIndex(index)!, index),\n [nodeHeight, visibleNodes]\n );\n\n const { nodeHighlightingProps } = props;\n React.useEffect(() => {\n const highlightedNodeId = getHighlightedNodeId(nodeHighlightingProps);\n if (!highlightedNodeId) return;\n\n let index = 0;\n for (const node of visibleNodes) {\n if (isTreeModelNode(node) && node.id === highlightedNodeId) break;\n\n index++;\n }\n\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(index);\n }, [nodeHighlightingProps]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyDown(e);\n },\n [props.treeActions]\n );\n\n const handleKeyUp = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyUp(e);\n },\n [props.treeActions]\n );\n\n const onItemsRendered = props.onItemsRendered;\n const handleRenderedItemsChange = React.useCallback(\n (onItemsRenderedProps: ListOnItemsRenderedProps) => {\n onItemsRendered && onItemsRendered({ ...onItemsRenderedProps });\n },\n [onItemsRendered]\n );\n\n return (\n <TreeRendererContextProvider value={rendererContext}>\n <CoreTree\n ref={coreTreeRef}\n className={classnames(\n \"components-controlledTree\",\n \"components-smallEditor-host\"\n )}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n >\n <VariableSizeList\n ref={variableSizeListRef}\n className={\"ReactWindow__VariableSizeList\"}\n width={props.width}\n height={props.height}\n itemCount={props.visibleNodes.getNumNodes()}\n itemSize={itemSize}\n estimatedItemSize={25}\n overscanCount={10}\n itemKey={itemKey}\n onItemsRendered={handleRenderedItemsChange}\n >\n {Node}\n </VariableSizeList>\n </CoreTree>\n </TreeRendererContextProvider>\n );\n});\n\nfunction getNodeKey(node: TreeModelNode | TreeModelNodePlaceholder): string {\n if (isTreeModelNode(node)) {\n return node.id;\n }\n return `${node.parentId || \"\"}-${node.childIndex}`;\n}\n\nconst Node = React.memo<React.FC<ListChildComponentProps>>(function Node(\n props: ListChildComponentProps\n) {\n const { index, style } = props;\n\n const {\n nodeRenderer,\n visibleNodes,\n treeActions,\n nodeLoader,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed,\n } = useTreeRendererContext(Node);\n const node = visibleNodes.getAtIndex(index)!;\n\n useNodeLoading(node, visibleNodes, nodeLoader);\n\n // Mark selected node's wrapper to make detecting consecutively selected nodes with css selectors possible\n const className = classnames(\"node-wrapper\", {\n \"is-selected\": isTreeModelNode(node) && node.isSelected,\n });\n\n const isEditing = React.useRef(false);\n React.useEffect(() => {\n if (!isTreeModelNode(node)) return;\n\n if (!isEditing.current && node.editingInfo) {\n isEditing.current = true;\n } else if (isEditing.current && node.editingInfo === undefined) {\n isEditing.current = false;\n /* istanbul ignore else */\n if (onNodeEditorClosed) onNodeEditorClosed();\n }\n }, [node, onNodeEditorClosed]);\n\n return (\n <div className={className} style={style}>\n {React.useMemo(() => {\n if (isTreeModelNode(node)) {\n const nodeHighlightProps = highlightingEngine\n ? highlightingEngine.createRenderProps(node)\n : undefined;\n return nodeRenderer({\n node,\n treeActions,\n onLabelRendered,\n nodeHighlightProps,\n });\n }\n\n return <TreeNodePlaceholder level={node.depth} />;\n }, [\n node,\n treeActions,\n nodeRenderer,\n onLabelRendered,\n highlightingEngine,\n ])}\n </div>\n );\n},\nareEqual);\n\nfunction useNodeLoading(\n node: TreeModelNode | TreeModelNodePlaceholder,\n visibleNodes: VisibleTreeNodes,\n nodeLoader: ITreeNodeLoader\n): void {\n React.useEffect(\n () => {\n if (!isTreeModelNodePlaceholder(node)) {\n return;\n }\n\n const treeModel = visibleNodes.getModel();\n const parentNode = node.parentId\n ? treeModel.getNode(node.parentId)\n : treeModel.getRootNode();\n if (!isTreeModelNode(parentNode) && !isTreeModelRootNode(parentNode)) {\n return;\n }\n\n const subscription = concat(\n timer(NODE_LOAD_DELAY),\n toRxjsObservable(nodeLoader.loadNode(parentNode, node.childIndex))\n ).subscribe();\n return () => subscription.unsubscribe();\n },\n // Mounted node component never changes its node key, thus it's safe to run this effect only once for every\n // nodeLoader change.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [nodeLoader]\n );\n}\n\nfunction useTreeRendererAttributes(\n ref: React.Ref<TreeRendererAttributes>,\n variableSizeListRef: React.RefObject<VariableSizeList>,\n visibleNodes: VisibleTreeNodes\n) {\n const visibleNodesRef = React.useRef(visibleNodes);\n visibleNodesRef.current = visibleNodes;\n React.useImperativeHandle(\n ref,\n () => ({\n scrollToNode: (nodeId, alignment) => {\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(\n visibleNodesRef.current.getIndexOfNode(nodeId),\n alignment\n );\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n}\n\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = React.useRef<T>();\n\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n\nfunction getHighlightedNodeId(highlightableTreeProps?: HighlightableTreeProps) {\n return highlightableTreeProps && highlightableTreeProps.activeMatch\n ? highlightableTreeProps.activeMatch.nodeId\n : undefined;\n}\n\nfunction useScrollToActiveMatch(\n treeRef: React.RefObject<CoreTree>,\n highlightableTreeProps?: HighlightableTreeProps\n) {\n const scrollToActive = React.useRef(false);\n React.useEffect(() => {\n scrollToActive.current = true;\n }, [highlightableTreeProps]);\n\n const onLabelRendered = React.useCallback(\n (node: TreeModelNode) => {\n const highlightedNodeId = getHighlightedNodeId(highlightableTreeProps);\n if (\n !treeRef.current ||\n !scrollToActive.current ||\n !highlightedNodeId ||\n highlightedNodeId !== node.id\n )\n return;\n\n scrollToActive.current = false;\n const scrollTo = [\n ...treeRef.current.getElementsByClassName(\n HighlightingEngine.ACTIVE_CLASS_NAME\n ),\n ];\n // istanbul ignore else\n if (scrollTo.length > 0 && scrollTo[0].scrollIntoView !== undefined)\n scrollTo[0].scrollIntoView({\n behavior: \"auto\",\n block: \"nearest\",\n inline: \"end\",\n });\n },\n [highlightableTreeProps, treeRef]\n );\n\n return onLabelRendered;\n}\n\nfunction setFocusToSelected(treeRef: React.RefObject<CoreTree>) {\n /* istanbul ignore else */\n if (treeRef.current)\n treeRef.current.setFocusByClassName(\".core-tree-node.is-selected\");\n}\n"]}
|
|
@@ -55,8 +55,7 @@ export class SparseTree {
|
|
|
55
55
|
this._idToNode[child.id] = child;
|
|
56
56
|
}
|
|
57
57
|
setNodeId(parentId, index, newId) {
|
|
58
|
-
|
|
59
|
-
const previousNodeId = (_a = this.getChildren(parentId)) === null || _a === void 0 ? void 0 : _a.get(index);
|
|
58
|
+
const previousNodeId = this.getChildren(parentId)?.get(index);
|
|
60
59
|
if (previousNodeId === undefined) {
|
|
61
60
|
return false;
|
|
62
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SparseTree.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/internal/SparseTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAOzE;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IAOrB;QAJQ,eAAU,GAAG,IAAI,WAAW,EAAU,CAAC;QACvC,sBAAiB,GAAwC,EAAE,CAAC;QAC5D,cAAS,GAAsB,EAAE,CAAC;QAGxC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IACzB,CAAC;IAEM,OAAO,CAAC,MAAc;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAEM,cAAc,CACnB,QAA4B,EAC5B,OAAe;QAEf,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ;YAAE,OAAO,SAAS,CAAC;QAEhC,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAEM,WAAW,CAChB,QAA4B,EAC5B,mBAA4B,KAAK;QAEjC,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,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AAO,YAAY,GAAG,MAAM,EAAE,EAAE,YAAY,EAAE;gBAC5C,MAAM,SAAS,CAAC;aACjB;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;IAEO,UAAU,CAAC,KAAa;QAI9B,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;IAEO,MAAM,CAAC,OAAO,CAAI,KAAa,EAAE,KAAkB;QACzD,OAAO,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport { immerable } from \"immer\";\nimport { assert, compareNumbers, lowerBound } from \"@itwin/core-bentley\";\n\n/** @internal */\nexport interface Node {\n readonly id: string;\n}\n\n/**\n * Structure for sparse tree storage.\n * It uses SparseArray to store children ids for parent. This allows\n * having tree structure with some nodes missing in the tree branch.\n * @internal\n */\nexport class SparseTree<T extends Node> {\n public [immerable]: boolean;\n\n private _rootNodes = new SparseArray<string>();\n private _parentToChildren: Record<string, SparseArray<string>> = {};\n private _idToNode: Record<string, T> = {};\n\n constructor() {\n this[immerable] = true;\n }\n\n public getNode(nodeId: string): T | undefined {\n return this._idToNode[nodeId];\n }\n\n public getChildOffset(\n parentId: string | undefined,\n childId: string\n ): number | undefined {\n const children = this.getChildren(parentId);\n if (!children) return undefined;\n\n return children.getIndex(childId);\n }\n\n public getChildren(\n parentId: string | undefined,\n createIfNotExist: boolean = false\n ): SparseArray<string> | undefined {\n if (parentId === undefined) {\n return this._rootNodes;\n }\n\n if (this._parentToChildren[parentId] === undefined && createIfNotExist) {\n this._parentToChildren[parentId] = new SparseArray<string>();\n }\n\n return this._parentToChildren[parentId];\n }\n\n public setChildren(\n parentId: string | undefined,\n children: T[],\n offset: number\n ) {\n const existingChildren = this.getChildren(parentId, true)!;\n children.forEach((child, index) => {\n const existingChildId = existingChildren.get(offset + index);\n if (existingChildId !== undefined) {\n this.deleteSubtree(existingChildId);\n }\n\n existingChildren.set(offset + index, child.id);\n this._idToNode[child.id] = child;\n });\n }\n\n public insertChild(parentId: string | undefined, child: T, offset: number) {\n const existingChildren = this.getChildren(parentId, true)!;\n existingChildren.insert(offset, child.id);\n this._idToNode[child.id] = child;\n }\n\n public setNodeId(\n parentId: string | undefined,\n index: number,\n newId: string\n ): boolean {\n const previousNodeId = this.getChildren(parentId)?.get(index);\n if (previousNodeId === undefined) {\n return false;\n }\n\n if (previousNodeId === newId) {\n return true;\n }\n\n if (this.getNode(newId) !== undefined) {\n return false;\n }\n\n this._idToNode[newId] = this._idToNode[previousNodeId];\n delete this._idToNode[previousNodeId];\n\n this._parentToChildren[newId] = this._parentToChildren[previousNodeId];\n delete this._parentToChildren[previousNodeId];\n\n if (parentId === undefined) {\n this._rootNodes.set(index, newId);\n } else {\n this._parentToChildren[parentId].set(index, newId);\n }\n\n return true;\n }\n\n public moveNode(\n sourceParentId: string | undefined,\n sourceNodeId: string,\n targetParentId: string | undefined,\n targetIndex: number\n ): void {\n const sourceNodeSiblings = this.getChildren(sourceParentId);\n assert(sourceNodeSiblings !== undefined);\n\n const sourceIndex = this.getChildOffset(sourceParentId, sourceNodeId);\n assert(sourceIndex !== undefined);\n\n sourceNodeSiblings.remove(sourceIndex);\n if (targetParentId === sourceParentId && targetIndex > sourceIndex) {\n targetIndex -= 1;\n }\n\n const targetNodeSiblings = this.getChildren(targetParentId, true);\n assert(targetNodeSiblings !== undefined);\n targetNodeSiblings.insert(targetIndex, sourceNodeId);\n }\n\n public setNumChildren(parentId: string | undefined, numChildren: number) {\n const children = this.getChildren(parentId, true)!;\n for (const [childId] of children.iterateValues()) {\n this.deleteSubtree(childId);\n }\n\n children.setLength(numChildren);\n }\n\n public removeChild(\n parentId: string | undefined,\n child: string | number\n ): void {\n const children = this.getChildren(parentId);\n if (children === undefined) return;\n\n if (typeof child === \"string\") {\n const childIndex = children.getIndex(child);\n if (childIndex !== undefined) {\n children.remove(childIndex);\n }\n\n this.deleteSubtree(child);\n } else {\n const childId = children.get(child);\n children.remove(child);\n if (childId !== undefined) {\n this.deleteSubtree(childId);\n }\n }\n }\n\n public deleteSubtree(\n parentId: string | undefined,\n deleteParent: boolean = true\n ) {\n const children = this.getChildren(parentId);\n if (children !== undefined) {\n for (const [childId] of children.iterateValues()) {\n this.deleteSubtree(childId);\n }\n }\n\n if (parentId === undefined) {\n this._rootNodes.setLength(0);\n return;\n }\n if (deleteParent) {\n delete this._idToNode[parentId];\n }\n delete this._parentToChildren[parentId];\n }\n}\n\n/**\n * Structure for sparse array value storage.\n * The main advantage of this class over the standard javascript array is that\n * this class does not need to check each index when iterating values that are\n * stored in the array.\n * @public\n */\nexport class SparseArray<T> implements Iterable<T | undefined> {\n public [immerable]: boolean;\n\n private _length = 0;\n private _array: Array<[T, number]> = [];\n\n constructor() {\n this[immerable] = true;\n }\n\n /** Returns length of array including intermediate 'undefined' values */\n public getLength(): number {\n return this._length;\n }\n\n /** Sets length of array. */\n public setLength(length: number) {\n const { index } = this.lowerBound(length);\n this._array.length = index;\n this._length = length;\n }\n\n /** Returns index of supplied value.\n *\n * @returns index of value or undefined if value is not found.\n */\n public getIndex(lookupValue: T): number | undefined {\n for (const [value, index] of this._array) {\n if (value === lookupValue) return index;\n }\n return undefined;\n }\n\n /** Returns value at specific position.\n *\n * @returns stored value or undefined.\n */\n public get(index: number): T | undefined {\n const { index: i, equal } = this.lowerBound(index);\n return equal ? this._array[i][0] : undefined;\n }\n\n /** Sets value at specific position. Overrides any existing value. */\n public set(index: number, value: T) {\n const { index: i, equal } = this.lowerBound(index);\n this._array.splice(i, equal ? 1 : 0, [value, index]);\n this._length = Math.max(this._length, index + 1);\n }\n\n /** Inserts value at specific position. Increases array length by one. */\n public insert(index: number, value: T) {\n const { index: i } = this.lowerBound(index);\n this._array.splice(i, 0, [value, index]);\n\n for (let j = i + 1; j < this._array.length; j++) {\n this._array[j][1]++;\n }\n\n this._length = Math.max(this._length + 1, index + 1);\n }\n\n /** Removes value at specified index and reduces array length by one. */\n public remove(index: number): void {\n if (index >= this._length) {\n return;\n }\n\n const { index: i, equal } = this.lowerBound(index);\n this._array.splice(i, equal ? 1 : 0);\n\n for (let j = i; j < this._array.length; j++) {\n this._array[j][1]--;\n }\n\n this._length = Math.max(0, this._length - 1);\n }\n\n /**\n * Iterates values that are stored in the array\n * @returns `[value, index]` tuples.\n */\n public iterateValues(): IterableIterator<[T, number]> {\n return this._array[Symbol.iterator]();\n }\n\n /** Iterates the array with all intermediate `undefined` values */\n public [Symbol.iterator](): IterableIterator<T | undefined> {\n const array = this._array;\n const length = this._length;\n return (function* () {\n let currentIndex = 0;\n for (const [value, index] of array) {\n for (; currentIndex < index; ++currentIndex) {\n yield undefined;\n }\n\n yield value;\n ++currentIndex;\n }\n\n for (; currentIndex < length; ++currentIndex) {\n yield undefined;\n }\n })();\n }\n\n private lowerBound(index: number): {\n index: number;\n equal: boolean;\n } {\n return lowerBound(index, this._array, SparseArray.compare);\n }\n\n private static compare<T>(index: number, value: [T, number]): number {\n return compareNumbers(index, value[1]);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SparseTree.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/internal/SparseTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAOzE;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IAOrB;QAJQ,eAAU,GAAG,IAAI,WAAW,EAAU,CAAC;QACvC,sBAAiB,GAAwC,EAAE,CAAC;QAC5D,cAAS,GAAsB,EAAE,CA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AQ,CAAC,EAAE,CAAC;IACxC,CAAC;IAED,kEAAkE;IAC3D,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,OAAO,CAAC,QAAQ,CAAC;YACf,IAAI,YAAY,GAAG,CAAC,CAAC;YACrB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE;gBAClC,OAAO,YAAY,GAAG,KAAK,EAAE,EAAE,YAAY,EAAE;oBAC3C,MAAM,SAAS,CAAC;iBACjB;gBAED,MAAM,KAAK,CAAC;gBACZ,EAAE,YAAY,CAAC;aAChB;YAED,OAAO,YAAY,GAAG,MAAM,EAAE,EAAE,YAAY,EAAE;gBAC5C,MAAM,SAAS,CAAC;aACjB;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;IAEO,UAAU,CAAC,KAAa;QAI9B,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;IAEO,MAAM,CAAC,OAAO,CAAI,KAAa,EAAE,KAAkB;QACzD,OAAO,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport { immerable } from \"immer\";\nimport { assert, compareNumbers, lowerBound } from \"@itwin/core-bentley\";\n\n/** @internal */\nexport interface Node {\n readonly id: string;\n}\n\n/**\n * Structure for sparse tree storage.\n * It uses SparseArray to store children ids for parent. This allows\n * having tree structure with some nodes missing in the tree branch.\n * @internal\n */\nexport class SparseTree<T extends Node> {\n public [immerable]: boolean;\n\n private _rootNodes = new SparseArray<string>();\n private _parentToChildren: Record<string, SparseArray<string>> = {};\n private _idToNode: Record<string, T> = {};\n\n constructor() {\n this[immerable] = true;\n }\n\n public getNode(nodeId: string): T | undefined {\n return this._idToNode[nodeId];\n }\n\n public getChildOffset(\n parentId: string | undefined,\n childId: string\n ): number | undefined {\n const children = this.getChildren(parentId);\n if (!children) return undefined;\n\n return children.getIndex(childId);\n }\n\n public getChildren(\n parentId: string | undefined,\n createIfNotExist: boolean = false\n ): SparseArray<string> | undefined {\n if (parentId === undefined) {\n return this._rootNodes;\n }\n\n if (this._parentToChildren[parentId] === undefined && createIfNotExist) {\n this._parentToChildren[parentId] = new SparseArray<string>();\n }\n\n return this._parentToChildren[parentId];\n }\n\n public setChildren(\n parentId: string | undefined,\n children: T[],\n offset: number\n ) {\n const existingChildren = this.getChildren(parentId, true)!;\n children.forEach((child, index) => {\n const existingChildId = existingChildren.get(offset + index);\n if (existingChildId !== undefined) {\n this.deleteSubtree(existingChildId);\n }\n\n existingChildren.set(offset + index, child.id);\n this._idToNode[child.id] = child;\n });\n }\n\n public insertChild(parentId: string | undefined, child: T, offset: number) {\n const existingChildren = this.getChildren(parentId, true)!;\n existingChildren.insert(offset, child.id);\n this._idToNode[child.id] = child;\n }\n\n public setNodeId(\n parentId: string | undefined,\n index: number,\n newId: string\n ): boolean {\n const previousNodeId = this.getChildren(parentId)?.get(index);\n if (previousNodeId === undefined) {\n return false;\n }\n\n if (previousNodeId === newId) {\n return true;\n }\n\n if (this.getNode(newId) !== undefined) {\n return false;\n }\n\n this._idToNode[newId] = this._idToNode[previousNodeId];\n delete this._idToNode[previousNodeId];\n\n this._parentToChildren[newId] = this._parentToChildren[previousNodeId];\n delete this._parentToChildren[previousNodeId];\n\n if (parentId === undefined) {\n this._rootNodes.set(index, newId);\n } else {\n this._parentToChildren[parentId].set(index, newId);\n }\n\n return true;\n }\n\n public moveNode(\n sourceParentId: string | undefined,\n sourceNodeId: string,\n targetParentId: string | undefined,\n targetIndex: number\n ): void {\n const sourceNodeSiblings = this.getChildren(sourceParentId);\n assert(sourceNodeSiblings !== undefined);\n\n const sourceIndex = this.getChildOffset(sourceParentId, sourceNodeId);\n assert(sourceIndex !== undefined);\n\n sourceNodeSiblings.remove(sourceIndex);\n if (targetParentId === sourceParentId && targetIndex > sourceIndex) {\n targetIndex -= 1;\n }\n\n const targetNodeSiblings = this.getChildren(targetParentId, true);\n assert(targetNodeSiblings !== undefined);\n targetNodeSiblings.insert(targetIndex, sourceNodeId);\n }\n\n public setNumChildren(parentId: string | undefined, numChildren: number) {\n const children = this.getChildren(parentId, true)!;\n for (const [childId] of children.iterateValues()) {\n this.deleteSubtree(childId);\n }\n\n children.setLength(numChildren);\n }\n\n public removeChild(\n parentId: string | undefined,\n child: string | number\n ): void {\n const children = this.getChildren(parentId);\n if (children === undefined) return;\n\n if (typeof child === \"string\") {\n const childIndex = children.getIndex(child);\n if (childIndex !== undefined) {\n children.remove(childIndex);\n }\n\n this.deleteSubtree(child);\n } else {\n const childId = children.get(child);\n children.remove(child);\n if (childId !== undefined) {\n this.deleteSubtree(childId);\n }\n }\n }\n\n public deleteSubtree(\n parentId: string | undefined,\n deleteParent: boolean = true\n ) {\n const children = this.getChildren(parentId);\n if (children !== undefined) {\n for (const [childId] of children.iterateValues()) {\n this.deleteSubtree(childId);\n }\n }\n\n if (parentId === undefined) {\n this._rootNodes.setLength(0);\n return;\n }\n if (deleteParent) {\n delete this._idToNode[parentId];\n }\n delete this._parentToChildren[parentId];\n }\n}\n\n/**\n * Structure for sparse array value storage.\n * The main advantage of this class over the standard javascript array is that\n * this class does not need to check each index when iterating values that are\n * stored in the array.\n * @public\n */\nexport class SparseArray<T> implements Iterable<T | undefined> {\n public [immerable]: boolean;\n\n private _length = 0;\n private _array: Array<[T, number]> = [];\n\n constructor() {\n this[immerable] = true;\n }\n\n /** Returns length of array including intermediate 'undefined' values */\n public getLength(): number {\n return this._length;\n }\n\n /** Sets length of array. */\n public setLength(length: number) {\n const { index } = this.lowerBound(length);\n this._array.length = index;\n this._length = length;\n }\n\n /** Returns index of supplied value.\n *\n * @returns index of value or undefined if value is not found.\n */\n public getIndex(lookupValue: T): number | undefined {\n for (const [value, index] of this._array) {\n if (value === lookupValue) return index;\n }\n return undefined;\n }\n\n /** Returns value at specific position.\n *\n * @returns stored value or undefined.\n */\n public get(index: number): T | undefined {\n const { index: i, equal } = this.lowerBound(index);\n return equal ? this._array[i][0] : undefined;\n }\n\n /** Sets value at specific position. Overrides any existing value. */\n public set(index: number, value: T) {\n const { index: i, equal } = this.lowerBound(index);\n this._array.splice(i, equal ? 1 : 0, [value, index]);\n this._length = Math.max(this._length, index + 1);\n }\n\n /** Inserts value at specific position. Increases array length by one. */\n public insert(index: number, value: T) {\n const { index: i } = this.lowerBound(index);\n this._array.splice(i, 0, [value, index]);\n\n for (let j = i + 1; j < this._array.length; j++) {\n this._array[j][1]++;\n }\n\n this._length = Math.max(this._length + 1, index + 1);\n }\n\n /** Removes value at specified index and reduces array length by one. */\n public remove(index: number): void {\n if (index >= this._length) {\n return;\n }\n\n const { index: i, equal } = this.lowerBound(index);\n this._array.splice(i, equal ? 1 : 0);\n\n for (let j = i; j < this._array.length; j++) {\n this._array[j][1]--;\n }\n\n this._length = Math.max(0, this._length - 1);\n }\n\n /**\n * Iterates values that are stored in the array\n * @returns `[value, index]` tuples.\n */\n public iterateValues(): IterableIterator<[T, number]> {\n return this._array[Symbol.iterator]();\n }\n\n /** Iterates the array with all intermediate `undefined` values */\n public [Symbol.iterator](): IterableIterator<T | undefined> {\n const array = this._array;\n const length = this._length;\n return (function* () {\n let currentIndex = 0;\n for (const [value, index] of array) {\n for (; currentIndex < index; ++currentIndex) {\n yield undefined;\n }\n\n yield value;\n ++currentIndex;\n }\n\n for (; currentIndex < length; ++currentIndex) {\n yield undefined;\n }\n })();\n }\n\n private lowerBound(index: number): {\n index: number;\n equal: boolean;\n } {\n return lowerBound(index, this._array, SparseArray.compare);\n }\n\n private static compare<T>(index: number, value: [T, number]): number {\n return compareNumbers(index, value[1]);\n }\n}\n"]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Tree
|
|
7
7
|
*/
|
|
8
|
-
import { EMPTY } from "rxjs
|
|
8
|
+
import { EMPTY } from "rxjs";
|
|
9
9
|
/**
|
|
10
10
|
* Provides basic tree manipulation implementation for various cases like
|
|
11
11
|
* expand/collapse node, modify/replace/clear selection. It is used by default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeModelMutator.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/internal/TreeModelMutator.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"TreeModelMutator.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/internal/TreeModelMutator.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAQ7B;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAK3B,YACE,WAA4B,EAC5B,UAA2B,EAC3B,gCAAyC;QAEzC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,iCAAiC,GAAG,gCAAgC,CAAC;IAC5E,CAAC;IAED,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAEM,UAAU,CAAC,MAAc;QAC9B,IAAI,kBAAkB,GAAG,KAAK,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACnC,IAAI,IAAI,KAAK,SAAS,IAAI,IA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AAC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC;iBAChC;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,eAAe,CACpB,MAAc,EACd,QAAyD;QAEzD,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACnC,IAAI,CAAC,IAAI;gBAAE,OAAO;YAElB,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBACxB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;aACjE;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,qBAAqB,CAC3B,MAAc,EACd,QAAyD;QAEzD,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBACnC,qBAAqB;gBACrB,IAAI,CAAC,IAAI;oBAAE,OAAO;gBAClB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;YAC/B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,eAAe,GAAG,CAAC,IAAmB,EAAE,QAAgB,EAAE,EAAE;YAChE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACzB,YAAY,EAAE,CAAC;QACjB,CAAC,CAAC;QAEF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAC/D,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport { EMPTY } from \"rxjs\";\nimport type { TreeNodeItem } from \"../../TreeDataProvider\";\nimport type { Observable } from \"../Observable\";\nimport type { CheckboxStateChange } from \"../TreeEvents\";\nimport type { TreeModelNode, TreeModelNodeEditingInfo } from \"../TreeModel\";\nimport type { TreeModelSource } from \"../TreeModelSource\";\nimport type { ITreeNodeLoader, TreeNodeLoadResult } from \"../TreeNodeLoader\";\n\n/**\n * Provides basic tree manipulation implementation for various cases like\n * expand/collapse node, modify/replace/clear selection. It is used by default\n * tree event handler to modify model when events occur.\n * @internal\n */\nexport class TreeModelMutator {\n private _modelSource: TreeModelSource;\n private _nodeLoader: ITreeNodeLoader;\n private _collapsedChildrenDisposalEnabled: boolean;\n\n constructor(\n modelSource: TreeModelSource,\n nodeLoader: ITreeNodeLoader,\n collapsedChildrenDisposalEnabled: boolean\n ) {\n this._modelSource = modelSource;\n this._nodeLoader = nodeLoader;\n this._collapsedChildrenDisposalEnabled = collapsedChildrenDisposalEnabled;\n }\n\n public get modelSource() {\n return this._modelSource;\n }\n\n public expandNode(nodeId: string): Observable<TreeNodeLoadResult> {\n let needToLoadChildren = false;\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (node === undefined || node.isExpanded) {\n return;\n }\n\n needToLoadChildren = node.numChildren === undefined;\n\n node.isExpanded = true;\n if (needToLoadChildren) {\n node.isLoading = true;\n }\n });\n\n const expandedNode = this._modelSource.getModel().getNode(nodeId);\n return needToLoadChildren && expandedNode\n ? this._nodeLoader.loadNode(expandedNode, 0)\n : EMPTY;\n }\n\n public collapseNode(nodeId: string) {\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (node === undefined || !node.isExpanded) {\n return;\n }\n\n node.isExpanded = false;\n if (this._collapsedChildrenDisposalEnabled) {\n model.clearChildren(node.id);\n }\n });\n }\n\n public modifySelection(\n nodesToSelect: TreeNodeItem[],\n nodesToDeselect: TreeNodeItem[]\n ) {\n this._modelSource.modifyModel((model) => {\n for (const nodeItem of nodesToSelect) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.isSelected = true;\n }\n }\n\n for (const nodeItem of nodesToDeselect) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.isSelected = false;\n }\n }\n });\n }\n\n public replaceSelection(nodesToSelect: TreeNodeItem[]) {\n this._modelSource.modifyModel((model) => {\n for (const node of model.iterateTreeModelNodes()) {\n node.isSelected = false;\n }\n\n for (const nodeItem of nodesToSelect) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.isSelected = true;\n }\n }\n });\n }\n\n public clearNodeSelection() {\n this._modelSource.modifyModel((model) => {\n for (const node of model.iterateTreeModelNodes()) {\n node.isSelected = false;\n }\n });\n }\n\n public setCheckboxStates(stateChanges: CheckboxStateChange[]) {\n this._modelSource.modifyModel((model) => {\n for (const { nodeItem, newState } of stateChanges) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.checkbox.state = newState;\n }\n }\n });\n }\n\n public activateEditing(\n nodeId: string,\n onCommit: (node: TreeModelNode, newValue: string) => void\n ) {\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (!node) return;\n\n if (node.item.isEditable) {\n node.editingInfo = this.createNodeEditingInfo(nodeId, onCommit);\n }\n });\n }\n\n private createNodeEditingInfo(\n nodeId: string,\n onCommit: (node: TreeModelNode, newValue: string) => void\n ): TreeModelNodeEditingInfo {\n const closeEditing = () => {\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n // istanbul ignore if\n if (!node) return;\n node.editingInfo = undefined;\n });\n };\n\n const onEditCommitted = (node: TreeModelNode, newValue: string) => {\n onCommit(node, newValue);\n closeEditing();\n };\n\n return { onCommit: onEditCommitted, onCancel: closeEditing };\n }\n}\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @module Tree
|
|
3
3
|
*/
|
|
4
4
|
/// <reference types="react" />
|
|
5
|
+
import type { Observable } from "rxjs";
|
|
5
6
|
import { BeUiEvent } from "@itwin/core-bentley";
|
|
6
7
|
import type { SelectionMode } from "../../../common/selection/SelectionModes";
|
|
7
|
-
import type { Observable } from "../Observable";
|
|
8
8
|
import type { TreeActions } from "../TreeActions";
|
|
9
9
|
import type { VisibleTreeNodes } from "../TreeModel";
|
|
10
10
|
/** @internal */
|
|
@@ -38,9 +38,8 @@ export declare class TreeSelectionManager implements Pick<TreeActions, "onNodeCl
|
|
|
38
38
|
onSelectionChanged: BeUiEvent<SelectionModificationEvent>;
|
|
39
39
|
onSelectionReplaced: BeUiEvent<SelectionReplacementEvent>;
|
|
40
40
|
onDragSelection: BeUiEvent<DragSelectionStartEvent>;
|
|
41
|
-
constructor(selectionMode: SelectionMode, getVisibleNodes
|
|
41
|
+
constructor(selectionMode: SelectionMode, getVisibleNodes: () => VisibleTreeNodes);
|
|
42
42
|
private getVisibleNodeAtIndex;
|
|
43
|
-
setVisibleNodes(visibleNodes: (() => VisibleTreeNodes) | undefined): void;
|
|
44
43
|
onNodeClicked(nodeId: string, event: React.MouseEvent): void;
|
|
45
44
|
onNodeMouseDown(nodeId: string): void;
|
|
46
45
|
onNodeMouseMove(nodeId: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeSelectionManager.d.ts","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/internal/TreeSelectionManager.ts"],"names":[],"mappings":"AAIA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"TreeSelectionManager.d.ts","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/internal/TreeSelectionManager.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAMhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,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AAE,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAIrE,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAI1E,OAAO,CAAC,gBAAgB,CA+DtB;CACH"}
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Tree
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import { Subject } from "rxjs/internal/Subject";
|
|
8
|
+
import { Subject } from "rxjs";
|
|
10
9
|
import { BeUiEvent } from "@itwin/core-bentley";
|
|
11
10
|
import { SelectionHandler } from "../../../common/selection/SelectionHandler";
|
|
12
11
|
import { isTreeModelNode } from "../TreeModel";
|
|
@@ -24,87 +23,54 @@ export class TreeSelectionManager {
|
|
|
24
23
|
this.onSelectionReplaced = new BeUiEvent();
|
|
25
24
|
this.onDragSelection = new BeUiEvent();
|
|
26
25
|
this._onKeyboardEvent = (e, actions, isKeyDown) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const processedNodeId = this._selectionHandler.processedItem;
|
|
27
|
+
if (!isNavigationKey(e.key) || !isIndividualSelection(processedNodeId)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const isExpandable = (node) => !node.isLoading && node.numChildren !== 0;
|
|
31
|
+
const isEditing = (node) => node.editingInfo !== undefined;
|
|
32
|
+
const processedNode = this._getVisibleNodes()
|
|
33
|
+
.getModel()
|
|
34
|
+
.getNode(processedNodeId);
|
|
35
|
+
// istanbul ignore if
|
|
36
|
+
if (!processedNode || isEditing(processedNode))
|
|
37
|
+
return;
|
|
38
|
+
const handleKeyboardSelectItem = (index) => {
|
|
39
|
+
const node = this.getVisibleNodeAtIndex(this._getVisibleNodes(), index);
|
|
40
|
+
// istanbul ignore if
|
|
41
|
+
if (!node || isEditing(node))
|
|
30
42
|
return;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (processedNode && isEditing(processedNode))
|
|
41
|
-
return;
|
|
43
|
+
const selectionFunc = this._selectionHandler.createSelectionFunction(...this.createSelectionHandlers(node.id));
|
|
44
|
+
selectionFunc(e.shiftKey, e.ctrlKey);
|
|
45
|
+
};
|
|
46
|
+
const handleKeyboardActivateItem = (_index) => {
|
|
47
|
+
if (isExpandable(processedNode)) {
|
|
48
|
+
if (!processedNode.isExpanded)
|
|
49
|
+
actions.onNodeExpanded(processedNode.id);
|
|
50
|
+
else
|
|
51
|
+
actions.onNodeCollapsed(processedNode.id);
|
|
42
52
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (this._getVisibleNodes) {
|
|
46
|
-
const node = this.getVisibleNodeAtIndex(this._getVisibleNodes(), index);
|
|
47
|
-
// istanbul ignore else
|
|
48
|
-
if (node) {
|
|
49
|
-
// istanbul ignore next
|
|
50
|
-
if (isEditing(node))
|
|
51
|
-
return;
|
|
52
|
-
const selectionFunc = this._selectionHandler.createSelectionFunction(...this.createSelectionHandlers(node.id));
|
|
53
|
-
selectionFunc(e.shiftKey, e.ctrlKey);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const handleKeyboardActivateItem = (_index) => {
|
|
58
|
-
// istanbul ignore else
|
|
59
|
-
if (this._getVisibleNodes && isIndividualSelection(processedNodeId)) {
|
|
60
|
-
const node = this._getVisibleNodes()
|
|
61
|
-
.getModel()
|
|
62
|
-
.getNode(processedNodeId);
|
|
63
|
-
// istanbul ignore else
|
|
64
|
-
if (node) {
|
|
65
|
-
if (isExpandable(node)) {
|
|
66
|
-
if (!node.isExpanded)
|
|
67
|
-
actions.onNodeExpanded(node.id);
|
|
68
|
-
else
|
|
69
|
-
actions.onNodeCollapsed(node.id);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
actions.onNodeEditorActivated(node.id);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const handleCrossAxisArrowKey = (forward) => {
|
|
78
|
-
// istanbul ignore else
|
|
79
|
-
if (this._getVisibleNodes && isIndividualSelection(processedNodeId)) {
|
|
80
|
-
const node = this._getVisibleNodes()
|
|
81
|
-
.getModel()
|
|
82
|
-
.getNode(processedNodeId);
|
|
83
|
-
// istanbul ignore else
|
|
84
|
-
if (node) {
|
|
85
|
-
if (isExpandable(node)) {
|
|
86
|
-
if (forward && !node.isExpanded)
|
|
87
|
-
actions.onNodeExpanded(node.id);
|
|
88
|
-
else if (!forward && node.isExpanded)
|
|
89
|
-
actions.onNodeCollapsed(node.id);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
// istanbul ignore else
|
|
95
|
-
if (isIndividualSelection(processedNodeId)) {
|
|
96
|
-
const itemKeyboardNavigator = new ItemKeyboardNavigator(handleKeyboardSelectItem, handleKeyboardActivateItem);
|
|
97
|
-
itemKeyboardNavigator.orientation = Orientation.Vertical;
|
|
98
|
-
itemKeyboardNavigator.crossAxisArrowKeyHandler =
|
|
99
|
-
handleCrossAxisArrowKey;
|
|
100
|
-
itemKeyboardNavigator.allowWrap = false;
|
|
101
|
-
itemKeyboardNavigator.itemCount = this._getVisibleNodes().getNumNodes();
|
|
102
|
-
const index = this._getVisibleNodes().getIndexOfNode(processedNodeId);
|
|
103
|
-
isKeyDown
|
|
104
|
-
? itemKeyboardNavigator.handleKeyDownEvent(e, index)
|
|
105
|
-
: itemKeyboardNavigator.handleKeyUpEvent(e, index);
|
|
53
|
+
else {
|
|
54
|
+
actions.onNodeEditorActivated(processedNode.id);
|
|
106
55
|
}
|
|
107
|
-
}
|
|
56
|
+
};
|
|
57
|
+
const handleCrossAxisArrowKey = (forward) => {
|
|
58
|
+
if (!isExpandable(processedNode))
|
|
59
|
+
return;
|
|
60
|
+
if (forward && !processedNode.isExpanded)
|
|
61
|
+
actions.onNodeExpanded(processedNode.id);
|
|
62
|
+
else if (!forward && processedNode.isExpanded)
|
|
63
|
+
actions.onNodeCollapsed(processedNode.id);
|
|
64
|
+
};
|
|
65
|
+
const itemKeyboardNavigator = new ItemKeyboardNavigator(handleKeyboardSelectItem, handleKeyboardActivateItem);
|
|
66
|
+
itemKeyboardNavigator.orientation = Orientation.Vertical;
|
|
67
|
+
itemKeyboardNavigator.crossAxisArrowKeyHandler = handleCrossAxisArrowKey;
|
|
68
|
+
itemKeyboardNavigator.allowWrap = false;
|
|
69
|
+
itemKeyboardNavigator.itemCount = this._getVisibleNodes().getNumNodes();
|
|
70
|
+
const processedNodeIndex = this._getVisibleNodes().getIndexOfNode(processedNodeId);
|
|
71
|
+
isKeyDown
|
|
72
|
+
? itemKeyboardNavigator.handleKeyDownEvent(e, processedNodeIndex)
|
|
73
|
+
: itemKeyboardNavigator.handleKeyUpEvent(e, processedNodeIndex);
|
|
108
74
|
};
|
|
109
75
|
this._getVisibleNodes = getVisibleNodes;
|
|
110
76
|
const onItemsSelected = (selections, replacement) => {
|
|
@@ -150,13 +116,8 @@ export class TreeSelectionManager {
|
|
|
150
116
|
const itemHandlers = new Proxy({}, {
|
|
151
117
|
get(_target, prop) {
|
|
152
118
|
if (prop === "length") {
|
|
153
|
-
return _this._getVisibleNodes
|
|
154
|
-
? 0
|
|
155
|
-
: _this._getVisibleNodes().getNumNodes();
|
|
119
|
+
return _this._getVisibleNodes().getNumNodes();
|
|
156
120
|
}
|
|
157
|
-
// istanbul ignore next
|
|
158
|
-
if (_this._getVisibleNodes === undefined)
|
|
159
|
-
return undefined;
|
|
160
121
|
const index = +prop;
|
|
161
122
|
const node = _this.getVisibleNodeAtIndex(_this._getVisibleNodes(), index);
|
|
162
123
|
return new ItemHandler(node);
|
|
@@ -170,9 +131,6 @@ export class TreeSelectionManager {
|
|
|
170
131
|
: /* istanbul ignore next */ undefined;
|
|
171
132
|
return isTreeModelNode(foundNode) ? foundNode : undefined;
|
|
172
133
|
}
|
|
173
|
-
setVisibleNodes(visibleNodes) {
|
|
174
|
-
this._getVisibleNodes = visibleNodes;
|
|
175
|
-
}
|
|
176
134
|
onNodeClicked(nodeId, event) {
|
|
177
135
|
const selectionFunc = this._selectionHandler.createSelectionFunction(...this.createSelectionHandlers(nodeId));
|
|
178
136
|
selectionFunc(event.shiftKey, event.ctrlKey);
|
|
@@ -188,11 +146,8 @@ export class TreeSelectionManager {
|
|
|
188
146
|
}
|
|
189
147
|
}, { once: true });
|
|
190
148
|
this._dragSelectionOperation = new Subject();
|
|
191
|
-
this.
|
|
192
|
-
this.
|
|
193
|
-
selectionChanges: this._dragSelectionOperation,
|
|
194
|
-
});
|
|
195
|
-
this._dragSelectionOperation.next(value);
|
|
149
|
+
this.onDragSelection.emit({
|
|
150
|
+
selectionChanges: this._dragSelectionOperation,
|
|
196
151
|
});
|
|
197
152
|
}
|
|
198
153
|
onNodeMouseMove(nodeId) {
|
|
@@ -223,7 +178,7 @@ export class TreeSelectionManager {
|
|
|
223
178
|
select: () => { },
|
|
224
179
|
deselect: () => { },
|
|
225
180
|
isSelected: () => {
|
|
226
|
-
if (deselectedAll
|
|
181
|
+
if (deselectedAll) {
|
|
227
182
|
return false;
|
|
228
183
|
}
|
|
229
184
|
const node = this._getVisibleNodes().getModel().getNode(nodeId);
|
|
@@ -255,13 +210,11 @@ class ItemHandler {
|
|
|
255
210
|
deselect() { }
|
|
256
211
|
// eslint-disable-next-line @itwin/prefer-get
|
|
257
212
|
isSelected() {
|
|
258
|
-
var _a;
|
|
259
213
|
// istanbul ignore next
|
|
260
|
-
return !!
|
|
214
|
+
return !!this._node?.isSelected;
|
|
261
215
|
}
|
|
262
216
|
item() {
|
|
263
|
-
|
|
264
|
-
return (_b = (_a = this._node) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : "";
|
|
217
|
+
return this._node?.id ?? "";
|
|
265
218
|
}
|
|
266
219
|
}
|
|
267
220
|
//# sourceMappingURL=TreeSelectionManager.js.map
|