@itwin/presentation-components
Version:
React components based on iTwin.js Presentation library
54 lines • 2.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuantityPropertyEditor = exports.QuantityPropertyEditorBase = exports.QuantityEditorName = 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 QuantityPropertyEditorInput_js_1 = require("../inputs/QuantityPropertyEditorInput.js");
/**
* Name for `QuantityPropertyEditor`.
* @internal
*/
exports.QuantityEditorName = "presentation-quantity-editor";
/**
* Editor for quantity properties.
* @internal
*/
class QuantityPropertyEditorBase extends components_react_1.PropertyEditorBase {
/* c8 ignore start */
get reactNode() {
return (0, jsx_runtime_1.jsx)(QuantityPropertyEditor, {});
}
}
exports.QuantityPropertyEditorBase = QuantityPropertyEditorBase;
/**
* Component that renders quantity property value input
* @internal
*/
class QuantityPropertyEditor 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)(QuantityPropertyEditorInput_js_1.QuantityPropertyEditorInput, { ref: this._ref, ...this.props, propertyRecord: this.props.propertyRecord }) : null;
}
}
exports.QuantityPropertyEditor = QuantityPropertyEditor;
//# sourceMappingURL=QuantityPropertyEditor.js.map