@yandex/ui
Version:
Yandex UI components
38 lines (37 loc) • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Debounce = void 0;
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var addon_actions_1 = require("@storybook/addon-actions");
var bundle_1 = require("@yandex-lego/components/Textinput/desktop/bundle");
var Spacer_1 = require("@yandex-lego/components/Spacer");
var Spin_1 = require("@yandex-lego/components/Spin");
var Debounce = function () {
var _a = tslib_1.__read(react_1.useState(''), 2), value = _a[0], setValue = _a[1];
var _b = tslib_1.__read(react_1.useState(false), 2), typing = _b[0], setTyping = _b[1];
return (react_1.default.createElement(bundle_1.Textinput, { debounceTimeout: 500, size: "m", view: "default", value: value, style: { maxWidth: 300 }, onChange: function (event) {
try {
addon_actions_1.action('onChange')(event.target.value);
}
catch (error) {
if (!error.message.startsWith('Accessing non-existent addons channel')) {
throw error;
}
}
setTyping(false);
setValue(event.target.value);
}, onInput: function (event) {
try {
addon_actions_1.action('onInput')(event.target.value);
}
catch (error) {
if (!error.message.startsWith('Accessing non-existent addons channel')) {
throw error;
}
}
setTyping(true);
}, iconRight: (typing || undefined) && (react_1.default.createElement(Spacer_1.Spacer, { all: "10px" },
react_1.default.createElement(Spin_1.Spin, { progress: true }))) }));
};
exports.Debounce = Debounce;