UNPKG

@yandex/ui

Version:

Yandex UI components

34 lines (33 loc) 1.5 kB
import { __read } from "tslib"; import React, { useState } from 'react'; import { action } from '@storybook/addon-actions'; import { Textinput } from '@yandex-lego/components/Textinput/desktop/bundle'; import { Spacer } from '@yandex-lego/components/Spacer'; import { Spin } from '@yandex-lego/components/Spin'; 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(Textinput, { debounceTimeout: 500, size: "m", view: "default", value: value, style: { maxWidth: 300 }, onChange: function (event) { try { 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 { action('onInput')(event.target.value); } catch (error) { if (!error.message.startsWith('Accessing non-existent addons channel')) { throw error; } } setTyping(true); }, iconRight: (typing || undefined) && (React.createElement(Spacer, { all: "10px" }, React.createElement(Spin, { progress: true }))) })); };