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.

50 lines (41 loc) 2.21 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 { TextInput } from "./"; var textInputProps = { placeholder: "Search for.." }; storiesOf("Forms/TextInput", module).add("Default", function () { function TextInputWithValue() { var _useState = useState(""), _useState2 = _slicedToArray(_useState, 2), value = _useState2[0], setValue = _useState2[1]; return React.createElement(TextInput, _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 input"), _useState4 = _slicedToArray(_useState3, 2), value = _useState4[0], setValue = _useState4[1]; return React.createElement(TextInput, _extends({ disabled: true, value: value, onChange: function onChange(e) { return setValue(e.target.value); } }, textInputProps)); } return React.createElement(TextInputWithValue, null); });