UNPKG

@yandex/ui

Version:

Yandex UI components

36 lines (35 loc) 1.68 kB
import { __read, __spread } from "tslib"; import React, { useState } from 'react'; import { withKnobs, select, boolean, object } from '@storybook/addon-knobs'; import { cnTheme } from '../../Theme'; import { presets, presetsKeys } from '../../Theme/presets'; import { Select } from '../Select.bundle/touch-phone'; import { EXAMPLE_TOUCH_PHONE_TOKEN, createDecorators, parameters } from './examples-config'; export default { title: EXAMPLE_TOUCH_PHONE_TOKEN, decorators: __spread([withKnobs], createDecorators()), parameters: parameters, }; var rawOptions = [ { value: 'a', content: 'Каждый' }, { value: 'b', content: 'Охотник' }, { value: 'c', content: 'Желает' }, { value: 'd', content: 'Знать' }, { value: 'e', content: 'Где', disabled: true }, { value: 'f', content: 'Сидит' }, { value: 'g', content: 'Фазан' }, ]; export var Playground = function () { var _a = __read(useState('a'), 2), value = _a[0], setValue = _a[1]; var preset = select('theme-preset', presetsKeys, 'default'); var size = select('size', ['m', 's'], 'm'); var view = select('view', ['default', ''], 'default'); var theme = view === '' ? select('theme', ['normal'], 'normal') : null; var disabled = boolean('disabled', false); var options = object('options', rawOptions); return (React.createElement("div", { className: cnTheme(presets[preset]) }, React.createElement(Select, { disabled: disabled, theme: theme, size: size, view: view, value: value, onChange: function (event) { return setValue(event.target.value); }, options: options }))); }; Playground.story = { name: 'playground', };