@yandex/ui
Version:
Yandex UI components
19 lines (18 loc) • 978 B
JavaScript
import { __read } from "tslib";
import React, { useState } from 'react';
import { action } from '@storybook/addon-actions';
import { Textarea } from '@yandex-lego/components/Textarea/desktop/bundle';
export var Debounce = function () {
var _a = __read(useState(''), 2), value = _a[0], setValue = _a[1];
var _b = __read(useState(false), 2), typing = _b[0], setTyping = _b[1];
return (React.createElement("div", { style: { maxWidth: 300 } },
React.createElement(Textarea, { debounceTimeout: 500, size: "m", view: "default", value: value, onChange: function (event) {
action('onChange')(event.target.value);
setTyping(false);
setValue(event.target.value);
}, onInput: function (event) {
action('onInput')(event.target.value);
setTyping(true);
} }),
React.createElement("pre", { style: { marginTop: 16 } }, typing ? 'Печатает...' : '')));
};