diff --git a/.eslintignore b/.eslintignore index 5d48351..edabeb2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ -docs/** coverage/** +dist/** +docs/** styleguide/template.js diff --git a/.gitignore b/.gitignore index 91bbd2f..2c9c934 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,6 @@ typings/ # Miscellaneous cache files .DS_Store + +# build +# dist/ diff --git a/dist/index.cjs.js b/dist/index.cjs.js new file mode 100644 index 0000000..1521d01 --- /dev/null +++ b/dist/index.cjs.js @@ -0,0 +1,1446 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var React = _interopDefault(require('react')); +var PropTypes = _interopDefault(require('prop-types')); +var uniqueId = _interopDefault(require('lodash.uniqueid')); + +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +var createClass = 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); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); + +var _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; +}; + +var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; +}; + +var objectWithoutProperties = function (obj, keys) { + var target = {}; + + for (var i in obj) { + if (keys.indexOf(i) >= 0) continue; + if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; + target[i] = obj[i]; + } + + return target; +}; + +var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; +}; + +/** + * Basic button component + */ +var Button = function Button(_ref) { + var className = _ref.className, + href = _ref.href, + text = _ref.text, + secondary = _ref.secondary, + square = _ref.square, + fullwidth = _ref.fullwidth, + children = _ref.children, + rest = objectWithoutProperties(_ref, ['className', 'href', 'text', 'secondary', 'square', 'fullwidth', 'children']); + + var classes = ['wds-button', className, secondary ? 'wds-is-secondary' : '', square ? 'wds-is-square' : '', text ? 'wds-is-text' : '', fullwidth ? 'wds-is-fullwidth' : ''].filter(function (c) { + return c; + }).join(' '); + + if (href) { + return React.createElement( + 'a', + _extends({ href: href, className: classes }, rest), + children + ); + } + + return React.createElement( + 'button', + _extends({ className: classes }, rest), + children + ); +}; + +Button.propTypes = { + /** + * @ignore + */ + children: PropTypes.node, + /** + * href attribute. + * Button uses `` tag if it's present. + */ + href: PropTypes.string, + /** + * Additional class name + */ + className: PropTypes.string, + /** + * Disabled attribute for the `