1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _react = _interopRequireWildcard(require("react"));
|
9 |
|
10 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
11 |
|
12 | var _icons = require("./icons");
|
13 |
|
14 | var _styles = require("./styles");
|
15 |
|
16 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17 |
|
18 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
19 |
|
20 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
21 |
|
22 | function _typeof(obj) { "@babel/helpers - typeof"; 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); }
|
23 |
|
24 | 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); }
|
25 |
|
26 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
27 |
|
28 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
29 |
|
30 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
31 |
|
32 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
33 |
|
34 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
35 |
|
36 | 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); } }
|
37 |
|
38 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
39 |
|
40 | function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
41 |
|
42 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
43 |
|
44 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
45 |
|
46 | function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
47 |
|
48 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
49 |
|
50 | 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); }
|
51 |
|
52 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
53 |
|
54 | 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; }
|
55 |
|
56 | var GoogleButton = function (_PureComponent) {
|
57 | _inherits(GoogleButton, _PureComponent);
|
58 |
|
59 | var _super = _createSuper(GoogleButton);
|
60 |
|
61 | function GoogleButton() {
|
62 | var _this;
|
63 |
|
64 | _classCallCheck(this, GoogleButton);
|
65 |
|
66 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
67 | args[_key] = arguments[_key];
|
68 | }
|
69 |
|
70 | _this = _super.call.apply(_super, [this].concat(args));
|
71 |
|
72 | _defineProperty(_assertThisInitialized(_this), "state", {
|
73 | hovered: false
|
74 | });
|
75 |
|
76 | _defineProperty(_assertThisInitialized(_this), "getStyle", function (propStyles) {
|
77 | var baseStyle = _this.props.type === 'dark' ? _styles.darkStyle : _styles.lightStyle;
|
78 |
|
79 | if (_this.state.hovered) {
|
80 | return _objectSpread({}, baseStyle, {}, _styles.hoverStyle, {}, propStyles);
|
81 | }
|
82 |
|
83 | if (_this.props.disabled) {
|
84 | return _objectSpread({}, baseStyle, {}, _styles.disabledStyle, {}, propStyles);
|
85 | }
|
86 |
|
87 | return _objectSpread({}, baseStyle, {}, propStyles);
|
88 | });
|
89 |
|
90 | _defineProperty(_assertThisInitialized(_this), "mouseOver", function () {
|
91 | if (!_this.props.disabled) {
|
92 | _this.setState({
|
93 | hovered: true
|
94 | });
|
95 | }
|
96 | });
|
97 |
|
98 | _defineProperty(_assertThisInitialized(_this), "mouseOut", function () {
|
99 | if (!_this.props.disabled) {
|
100 | _this.setState({
|
101 | hovered: false
|
102 | });
|
103 | }
|
104 | });
|
105 |
|
106 | _defineProperty(_assertThisInitialized(_this), "click", function (e) {
|
107 | if (!_this.props.disabled) {
|
108 | _this.props.onClick(e);
|
109 | }
|
110 | });
|
111 |
|
112 | return _this;
|
113 | }
|
114 |
|
115 | _createClass(GoogleButton, [{
|
116 | key: "render",
|
117 | value: function render() {
|
118 | var _this$props = this.props,
|
119 | label = _this$props.label,
|
120 | style = _this$props.style,
|
121 | otherProps = _objectWithoutProperties(_this$props, ["label", "style"]);
|
122 |
|
123 | return _react.default.createElement("div", _extends({}, otherProps, {
|
124 | role: "button",
|
125 | onClick: this.click,
|
126 | style: this.getStyle(style),
|
127 | onMouseOver: this.mouseOver,
|
128 | onMouseOut: this.mouseOut
|
129 | }), _react.default.createElement(_icons.GoogleIcon, this.props), _react.default.createElement("span", null, label));
|
130 | }
|
131 | }]);
|
132 |
|
133 | return GoogleButton;
|
134 | }(_react.PureComponent);
|
135 |
|
136 | exports.default = GoogleButton;
|
137 |
|
138 | _defineProperty(GoogleButton, "propTypes", {
|
139 | label: _propTypes.default.string,
|
140 | disabled: _propTypes.default.bool,
|
141 | tabIndex: _propTypes.default.number,
|
142 | onClick: _propTypes.default.func,
|
143 | type: _propTypes.default.oneOf(['light', 'dark']),
|
144 | style: _propTypes.default.object
|
145 | });
|
146 |
|
147 | _defineProperty(GoogleButton, "defaultProps", {
|
148 | label: 'Sign in with Google',
|
149 | disabled: false,
|
150 | type: 'dark',
|
151 | tabIndex: 0,
|
152 | onClick: function onClick() {}
|
153 | }); |
\ | No newline at end of file |