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.

247 lines (199 loc) 8.04 kB
"use strict"; var _react = _interopRequireDefault(require("react")); var _react2 = require("@storybook/react"); var _ = require("./"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } (0, _react2.storiesOf)("Forms/SelectInput", module).add("Default", function () { var Example = /*#__PURE__*/ function (_React$Component) { _inherits(Example, _React$Component); function Example() { var _getPrototypeOf2; var _this; _classCallCheck(this, Example); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); _defineProperty(_assertThisInitialized(_this), "state", { options: [{ value: "bilmodell", label: "Bilmodell" }, { value: "c30", label: "Volvo C30", disabled: true }, { value: "c70", label: "Volvo C70" }, { value: "c90", label: "Volvo C90" }, { value: "c40", label: "Volvo S40" }, { value: "s60", label: "Volvo S60" }, { value: "s80", label: "Volvo S80" }, { value: "s90", label: "Volvo S90" }], value: "bilmodell" }); _defineProperty(_assertThisInitialized(_this), "handleChange", function (e) { _this.setState({ value: e.target.value }); }); return _this; } _createClass(Example, [{ key: "render", value: function render() { return _react.default.createElement(_.SelectInput, { value: this.state.value, options: this.state.options, onChange: this.handleChange }); } }]); return Example; }(_react.default.Component); return _react.default.createElement(Example, null); }).add("Disabled", function () { var Example = /*#__PURE__*/ function (_React$Component2) { _inherits(Example, _React$Component2); function Example() { var _getPrototypeOf3; var _this2; _classCallCheck(this, Example); for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } _this2 = _possibleConstructorReturn(this, (_getPrototypeOf3 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf3, [this].concat(args))); _defineProperty(_assertThisInitialized(_this2), "state", { options: [{ value: "bilmodell", label: "Bilmodell" }, { value: "c70", label: "Volvo C70" }, { value: "c90", label: "Volvo C90" }, { value: "c40", label: "Volvo S40" }, { value: "s60", label: "Volvo S60" }, { value: "s80", label: "Volvo S80" }, { value: "s90", label: "Volvo S90" }], value: "bilmodell" }); _defineProperty(_assertThisInitialized(_this2), "handleChange", function (e) { _this2.setState({ value: e.target.value }); }); return _this2; } _createClass(Example, [{ key: "render", value: function render() { return _react.default.createElement(_.SelectInput, { value: this.state.value, options: this.state.options, onChange: this.handleChange, disabled: true }); } }]); return Example; }(_react.default.Component); return _react.default.createElement(Example, null); }).add("With loading spinner", function () { var Example = /*#__PURE__*/ function (_React$Component3) { _inherits(Example, _React$Component3); function Example() { var _getPrototypeOf4; var _this3; _classCallCheck(this, Example); for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { args[_key3] = arguments[_key3]; } _this3 = _possibleConstructorReturn(this, (_getPrototypeOf4 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf4, [this].concat(args))); _defineProperty(_assertThisInitialized(_this3), "state", { options: [{ value: "bilmodell", label: "Bilmodell" }, { value: "c30", label: "Volvo C30", disabled: true }, { value: "c70", label: "Volvo C70" }, { value: "c90", label: "Volvo C90" }, { value: "c40", label: "Volvo S40" }, { value: "s60", label: "Volvo S60" }, { value: "s80", label: "Volvo S80" }, { value: "s90", label: "Volvo S90" }], value: "bilmodell" }); _defineProperty(_assertThisInitialized(_this3), "onChange", function (e) { _this3.setState({ value: e.target.value }); }); return _this3; } _createClass(Example, [{ key: "render", value: function render() { return _react.default.createElement(_.SelectInput, { onChange: this.onChange.bind(this), options: this.state.options, loading: true }); } }]); return Example; }(_react.default.Component); return _react.default.createElement(Example, null); });