UNPKG

@itwin/presentation-components

Version:

React components based on iTwin.js Presentation library

49 lines 1.8 kB
import { jsx as _jsx } from "react/jsx-runtime"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { createRef, PureComponent } from "react"; import { PropertyEditorBase } from "@itwin/components-react"; import { QuantityPropertyEditorInput } from "../inputs/QuantityPropertyEditorInput.js"; /** * Name for `QuantityPropertyEditor`. * @internal */ export const QuantityEditorName = "presentation-quantity-editor"; /** * Editor for quantity properties. * @internal */ export class QuantityPropertyEditorBase extends PropertyEditorBase { /* c8 ignore start */ get reactNode() { return _jsx(QuantityPropertyEditor, {}); } } /** * Component that renders quantity property value input * @internal */ export class QuantityPropertyEditor extends PureComponent { _ref = createRef(); /* c8 ignore start */ async getPropertyValue() { return this._ref.current?.getValue(); } get htmlElement() { return this._ref.current?.htmlElement ?? null; } get hasFocus() { if (!this._ref.current?.htmlElement || !document.activeElement) { return false; } return this._ref.current.htmlElement.contains(document.activeElement); } /* c8 ignore end */ /** @internal */ render() { return this.props.propertyRecord ? _jsx(QuantityPropertyEditorInput, { ref: this._ref, ...this.props, propertyRecord: this.props.propertyRecord }) : null; } } //# sourceMappingURL=QuantityPropertyEditor.js.map