UNPKG

@itwin/presentation-components

Version:

React components based on iTwin.js Presentation library

60 lines 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NumericPropertyEditor = exports.NumericPropertyEditorBase = exports.NumericEditorName = void 0; const jsx_runtime_1 = require("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. *--------------------------------------------------------------------------------------------*/ const react_1 = require("react"); const components_react_1 = require("@itwin/components-react"); const NumericPropertyInput_js_1 = require("../inputs/NumericPropertyInput.js"); /** * Name for `NumericPropertyEditor`. * * @internal */ exports.NumericEditorName = "presentation-numeric-editor"; /** * Editor for numeric properties. * * @internal */ class NumericPropertyEditorBase extends components_react_1.PropertyEditorBase { /* c8 ignore start */ get containerHandlesTab() { return false; } get reactNode() { return (0, jsx_runtime_1.jsx)(NumericPropertyEditor, {}); } } exports.NumericPropertyEditorBase = NumericPropertyEditorBase; /** * Component that renders numeric property target input for numeric value editing. * * @internal */ class NumericPropertyEditor extends react_1.PureComponent { _ref = (0, react_1.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 ? (0, jsx_runtime_1.jsx)(NumericPropertyInput_js_1.NumericPropertyInput, { ref: this._ref, ...this.props, propertyRecord: this.props.propertyRecord }) : null; } } exports.NumericPropertyEditor = NumericPropertyEditor; //# sourceMappingURL=NumericPropertyEditor.js.map