UNPKG

vcc-ui

Version:

VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.

67 lines (56 loc) 2.79 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } import React, { useState } from 'react'; import { storiesOf } from '@storybook/react'; import { TextArea } from './'; var textInputProps = { placeholder: 'Type comment here' }; storiesOf('Forms/TextArea', module).add('Default', function () { function TextInputWithValue() { var _useState = useState(''), _useState2 = _slicedToArray(_useState, 2), value = _useState2[0], setValue = _useState2[1]; return React.createElement(TextArea, _extends({ value: value, onChange: function onChange(e) { return setValue(e.target.value); } }, textInputProps)); } return React.createElement(TextInputWithValue, null); }).add('Disabled', function () { function TextInputWithValue() { var _useState3 = useState('This is some text but field is disabled so I cant edit it'), _useState4 = _slicedToArray(_useState3, 2), value = _useState4[0], setValue = _useState4[1]; return React.createElement(TextArea, _extends({ disabled: true, value: value, onChange: function onChange(e) { return setValue(e.target.value); } }, textInputProps)); } return React.createElement(TextInputWithValue, null); }).add('Validation', function () { function TextInputWithValue() { var _useState5 = useState('This is some text but the field is invalid'), _useState6 = _slicedToArray(_useState5, 2), value = _useState6[0], setValue = _useState6[1]; return React.createElement(TextArea, _extends({ isValid: false, value: value, onChange: function onChange(e) { return setValue(e.target.value); } }, textInputProps)); } return React.createElement(TextInputWithValue, null); });