flipper-plugin
Version:
Flipper Desktop plugin SDK and components
38 lines • 1.63 kB
JavaScript
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PowerSearchFloatTerm = void 0;
const antd_1 = require("antd");
const react_1 = __importDefault(require("react"));
const PowerSearchFloatTerm = ({ onCancel, onChange, defaultValue, }) => {
const [editing, setEditing] = react_1.default.useState(!defaultValue);
if (editing) {
return (react_1.default.createElement(antd_1.Input, { autoFocus: true, style: { width: 100 }, placeholder: "...", onBlur: (event) => {
const newValue = event.target.value;
setEditing(false);
if (!newValue) {
onCancel();
return;
}
const normalizedValue = parseFloat(newValue);
onChange(normalizedValue);
}, onKeyDown: (event) => {
if (event.key === 'Enter' || event.key === 'Escape') {
event.currentTarget.blur();
}
}, type: "number", step: 0.1, defaultValue: defaultValue }));
}
return react_1.default.createElement(antd_1.Button, { onClick: () => setEditing(true) }, defaultValue);
};
exports.PowerSearchFloatTerm = PowerSearchFloatTerm;
//# sourceMappingURL=PowerSearchFloatTerm.js.map
;