Skip to content

Commit c736fd7

Browse files
committed
add transpiled dist files so “yarn add https://github.com/perfectcube/react-ladda.git#master“ will work out of the box. this is a stopgap until pr jsdir#62 is finalized and released on npm by jsdir/react-ladda
1 parent e70079b commit c736fd7

3 files changed

Lines changed: 203 additions & 0 deletions

File tree

dist/LaddaButton.js

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
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; };
8+
9+
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; }; }();
10+
11+
var _react = require('react');
12+
13+
var _react2 = _interopRequireDefault(_react);
14+
15+
var _propTypes = require('prop-types');
16+
17+
var _propTypes2 = _interopRequireDefault(_propTypes);
18+
19+
var _ladda = require('ladda');
20+
21+
var _ladda2 = _interopRequireDefault(_ladda);
22+
23+
var _constants = require('./constants');
24+
25+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26+
27+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28+
29+
function _possibleConstructorReturn(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; }
30+
31+
function _inherits(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; }
32+
33+
var isUndefined = function isUndefined(value) {
34+
return typeof value === 'undefined';
35+
};
36+
37+
var OMITTED_PROPS = ['loading', 'progress'];
38+
39+
var omit = function omit(data, keys) {
40+
var result = {};
41+
Object.keys(data).forEach(function (key) {
42+
if (keys.indexOf(key) === -1) {
43+
result[key] = data[key];
44+
}
45+
});
46+
47+
return result;
48+
};
49+
50+
var LaddaButton = function (_Component) {
51+
_inherits(LaddaButton, _Component);
52+
53+
function LaddaButton() {
54+
var _ref;
55+
56+
var _temp, _this, _ret;
57+
58+
_classCallCheck(this, LaddaButton);
59+
60+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
61+
args[_key] = arguments[_key];
62+
}
63+
64+
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = LaddaButton.__proto__ || Object.getPrototypeOf(LaddaButton)).call.apply(_ref, [this].concat(args))), _this), _this.setNode = function (node) {
65+
_this.node = node;
66+
}, _this.updateLaddaInstance = function (props) {
67+
if (props.loading !== _this.props.loading) {
68+
if (props.loading) {
69+
_this.laddaInstance.start();
70+
} else if (props.disabled) {
71+
// .stop removes the attribute "disabled"
72+
// .disable calls .stop then adds the attribute "disabled"
73+
// see https://github.com/hakimel/Ladda/blob/master/js/ladda.js
74+
_this.laddaInstance.disable();
75+
} else {
76+
_this.laddaInstance.stop();
77+
}
78+
}
79+
80+
if (props.progress !== _this.props.progress) {
81+
_this.laddaInstance.setProgress(props.progress);
82+
}
83+
}, _temp), _possibleConstructorReturn(_this, _ret);
84+
}
85+
86+
_createClass(LaddaButton, [{
87+
key: 'componentDidMount',
88+
value: function componentDidMount() {
89+
this.laddaInstance = _ladda2.default.create(this.node);
90+
91+
if (this.props.loading) {
92+
this.laddaInstance.start();
93+
}
94+
95+
if (!isUndefined(this.props.progress)) {
96+
this.laddaInstance.setProgress(this.props.progress);
97+
}
98+
}
99+
}, {
100+
key: 'shouldComponentUpdate',
101+
value: function shouldComponentUpdate(nextProps) {
102+
this.updateLaddaInstance(nextProps);
103+
}
104+
}, {
105+
key: 'componentWillUnmount',
106+
value: function componentWillUnmount() {
107+
this.laddaInstance.remove();
108+
}
109+
}, {
110+
key: 'render',
111+
value: function render() {
112+
return _react2.default.createElement(
113+
'button',
114+
_extends({}, omit(this.props, OMITTED_PROPS), {
115+
className: 'ladda-button ' + (this.props.className || ''),
116+
ref: this.setNode,
117+
disabled: this.props.disabled || this.props.loading
118+
}),
119+
_react2.default.createElement(
120+
'span',
121+
{ className: 'ladda-label' },
122+
this.props.children
123+
)
124+
);
125+
}
126+
}]);
127+
128+
return LaddaButton;
129+
}(_react.Component);
130+
131+
LaddaButton.propTypes = {
132+
children: _propTypes2.default.node,
133+
className: _propTypes2.default.string,
134+
progress: _propTypes2.default.number,
135+
loading: _propTypes2.default.bool,
136+
disabled: _propTypes2.default.bool,
137+
138+
// Ladda props
139+
// eslint-disable-next-line react/no-unused-prop-types
140+
'data-color': _propTypes2.default.oneOf(['green', 'red', 'blue', 'purple', 'mint']),
141+
// eslint-disable-next-line react/no-unused-prop-types
142+
'data-size': _propTypes2.default.oneOf(_constants.SIZES),
143+
// eslint-disable-next-line react/no-unused-prop-types
144+
'data-style': _propTypes2.default.oneOf(_constants.STYLES),
145+
// eslint-disable-next-line react/no-unused-prop-types
146+
'data-spinner-size': _propTypes2.default.number,
147+
// eslint-disable-next-line react/no-unused-prop-types
148+
'data-spinner-color': _propTypes2.default.string,
149+
// eslint-disable-next-line react/no-unused-prop-types
150+
'data-spinner-lines': _propTypes2.default.number
151+
};
152+
exports.default = LaddaButton;

dist/constants.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
var XS = exports.XS = 'xs';
7+
var S = exports.S = 's';
8+
var L = exports.L = 'l';
9+
var XL = exports.XL = 'xl';
10+
11+
var SIZES = exports.SIZES = [XS, S, L, XL];
12+
13+
var CONTRACT = exports.CONTRACT = 'contract';
14+
var CONTRACT_OVERLAY = exports.CONTRACT_OVERLAY = 'contract-overlay';
15+
var EXPAND_LEFT = exports.EXPAND_LEFT = 'expand-left';
16+
var EXPAND_RIGHT = exports.EXPAND_RIGHT = 'expand-right';
17+
var EXPAND_UP = exports.EXPAND_UP = 'expand-up';
18+
var EXPAND_DOWN = exports.EXPAND_DOWN = 'expand-down';
19+
var SLIDE_LEFT = exports.SLIDE_LEFT = 'slide-left';
20+
var SLIDE_RIGHT = exports.SLIDE_RIGHT = 'slide-right';
21+
var SLIDE_UP = exports.SLIDE_UP = 'slide-up';
22+
var SLIDE_DOWN = exports.SLIDE_DOWN = 'slide-down';
23+
var ZOOM_IN = exports.ZOOM_IN = 'zoom-in';
24+
var ZOOM_OUT = exports.ZOOM_OUT = 'zoom-out';
25+
26+
var STYLES = exports.STYLES = [CONTRACT, CONTRACT_OVERLAY, EXPAND_LEFT, EXPAND_RIGHT, EXPAND_UP, EXPAND_DOWN, SLIDE_LEFT, SLIDE_RIGHT, SLIDE_UP, SLIDE_DOWN, ZOOM_IN, ZOOM_OUT];

dist/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _constants = require('./constants');
8+
9+
Object.keys(_constants).forEach(function (key) {
10+
if (key === "default" || key === "__esModule") return;
11+
Object.defineProperty(exports, key, {
12+
enumerable: true,
13+
get: function get() {
14+
return _constants[key];
15+
}
16+
});
17+
});
18+
19+
var _LaddaButton = require('./LaddaButton');
20+
21+
var _LaddaButton2 = _interopRequireDefault(_LaddaButton);
22+
23+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24+
25+
exports.default = _LaddaButton2.default;

0 commit comments

Comments
 (0)