@typeolymp/ui-components 1.9.10 → 1.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js
CHANGED
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var styled = require('styled-components');
|
|
8
7
|
var BeatLoader = require('react-spinners/BeatLoader');
|
|
8
|
+
var styled = require('styled-components');
|
|
9
9
|
var parse = require('html-react-parser');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
12
|
|
|
13
13
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
15
14
|
var BeatLoader__default = /*#__PURE__*/_interopDefaultLegacy(BeatLoader);
|
|
15
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
16
16
|
var parse__default = /*#__PURE__*/_interopDefaultLegacy(parse);
|
|
17
17
|
|
|
18
18
|
var theme = {
|
|
@@ -185,6 +185,18 @@ var __assign = function() {
|
|
|
185
185
|
return __assign.apply(this, arguments);
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
+
function __rest(s, e) {
|
|
189
|
+
var t = {};
|
|
190
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
191
|
+
t[p] = s[p];
|
|
192
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
193
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
194
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
195
|
+
t[p[i]] = s[p[i]];
|
|
196
|
+
}
|
|
197
|
+
return t;
|
|
198
|
+
}
|
|
199
|
+
|
|
188
200
|
function __spreadArray(to, from, pack) {
|
|
189
201
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
190
202
|
if (ar || !(i in from)) {
|
|
@@ -270,17 +282,47 @@ var GhostButton = styled__default["default"](StyledButton)(templateObject_3$a ||
|
|
|
270
282
|
? theme.button.medium.marginTopActive
|
|
271
283
|
: theme.button[size].marginTopActive;
|
|
272
284
|
});
|
|
273
|
-
var
|
|
285
|
+
var LoaderWrapper = styled__default["default"].div(templateObject_4$7 || (templateObject_4$7 = __makeTemplateObject(["\n width: ", ";\n margin-top: ", ";\n"], ["\n width: ", ";\n margin-top: ", ";\n"])), function (_a) {
|
|
286
|
+
var width = _a.width;
|
|
287
|
+
return "".concat(width, "px");
|
|
288
|
+
}, function (_a) {
|
|
289
|
+
var size = _a.size;
|
|
290
|
+
return (size === "small" ? "3px" : "");
|
|
291
|
+
});
|
|
292
|
+
var templateObject_1$N, templateObject_2$t, templateObject_3$a, templateObject_4$7;
|
|
274
293
|
|
|
275
294
|
var Button = React.forwardRef(function (_a, ref) {
|
|
276
|
-
var label = _a.label, color = _a.color, size = _a.size, fluid = _a.fluid, disabled = _a.disabled, type = _a.type, tabIndex = _a.tabIndex, href = _a.href, asAnchor = _a.asAnchor,
|
|
295
|
+
var label = _a.label, color = _a.color, size = _a.size, fluid = _a.fluid, disabled = _a.disabled, type = _a.type, tabIndex = _a.tabIndex, href = _a.href, asAnchor = _a.asAnchor, props = __rest(_a, ["label", "color", "size", "fluid", "disabled", "type", "tabIndex", "href", "asAnchor"]);
|
|
296
|
+
var buttonRef = React.useRef(null);
|
|
297
|
+
var _b = React.useState(false), isLoading = _b[0], setIsLoading = _b[1];
|
|
277
298
|
var as = href || asAnchor ? "a" : "button";
|
|
299
|
+
var onClick = function () {
|
|
300
|
+
if (props.onClickAsync) {
|
|
301
|
+
setIsLoading(true);
|
|
302
|
+
new Promise(function (resolve) {
|
|
303
|
+
props.onClickAsync(resolve);
|
|
304
|
+
}).then(function () { return setIsLoading(false); });
|
|
305
|
+
}
|
|
306
|
+
else if (props.onClick) {
|
|
307
|
+
props.onClick();
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
var Loader = function (_a) {
|
|
311
|
+
var _b;
|
|
312
|
+
var dark = _a.dark;
|
|
313
|
+
var width = ((_b = buttonRef.current) === null || _b === void 0 ? void 0 : _b.clientWidth) - 40;
|
|
314
|
+
if (dark)
|
|
315
|
+
width = width + 4;
|
|
316
|
+
return (jsxRuntime.jsx(LoaderWrapper, __assign({ width: width, size: size }, { children: jsxRuntime.jsx(BeatLoader__default["default"], { size: 10, color: dark
|
|
317
|
+
? theme.colors.lightGray.darker
|
|
318
|
+
: theme.colors.lightGray.light, speedMultiplier: 0.5 }) })));
|
|
319
|
+
};
|
|
278
320
|
if (disabled) {
|
|
279
|
-
return (jsxRuntime.jsx(DisabledButton, __assign({ color: color, size: size, fluid: fluid, type: type, tabIndex: tabIndex, as: as, href: href, ref: ref }, { children: jsxRuntime.jsx("span", { children: label }) })));
|
|
321
|
+
return (jsxRuntime.jsx(DisabledButton, __assign({ color: color, size: size, fluid: fluid, type: type, tabIndex: tabIndex, as: as, href: href, ref: ref ? ref : buttonRef }, { children: jsxRuntime.jsx("span", { children: label }) })));
|
|
280
322
|
}
|
|
281
323
|
if (color === "white")
|
|
282
|
-
return (jsxRuntime.jsx(GhostButton, __assign({ color: color, size: size, fluid: fluid, type: type, tabIndex: tabIndex, as: as, href: href, ref: ref, onClick: onClick }, { children: jsxRuntime.jsx("span", { children: label }) })));
|
|
283
|
-
return (jsxRuntime.jsx(StyledButton, __assign({ color: color, size: size, fluid: fluid, type: type, tabIndex: tabIndex, as: as, href: href, ref: ref, onClick: onClick }, { children: jsxRuntime.jsx("span", { children: label }) })));
|
|
324
|
+
return (jsxRuntime.jsx(GhostButton, __assign({ color: color, size: size, fluid: fluid, type: type, tabIndex: tabIndex, as: as, href: href, ref: ref ? ref : buttonRef, onClick: onClick }, { children: isLoading ? jsxRuntime.jsx(Loader, { dark: true }) : jsxRuntime.jsx("span", { children: label }) })));
|
|
325
|
+
return (jsxRuntime.jsx(StyledButton, __assign({ color: color, size: size, fluid: fluid, type: type, tabIndex: tabIndex, as: as, href: href, ref: ref ? ref : buttonRef, onClick: onClick }, { children: isLoading ? jsxRuntime.jsx(Loader, {}) : jsxRuntime.jsx("span", { children: label }) })));
|
|
284
326
|
});
|
|
285
327
|
|
|
286
328
|
var StyledCheckbox = styled__default["default"].div(templateObject_1$M || (templateObject_1$M = __makeTemplateObject(["\n min-height: 25px;\n max-height: 25px;\n min-width: 25px;\n max-width: 25px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n border-width: 1px;\n border-style: solid;\n border-color: ", ";\n cursor: ", ";\n background-color: ", ";\n\n svg {\n margin-left: -1px;\n fill: ", ";\n }\n\n input {\n display: none;\n }\n\n :focus {\n outline: 0;\n border-color: ", ";\n box-shadow: ", ";\n }\n"], ["\n min-height: 25px;\n max-height: 25px;\n min-width: 25px;\n max-width: 25px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n border-width: 1px;\n border-style: solid;\n border-color: ", ";\n cursor: ", ";\n background-color: ", ";\n\n svg {\n margin-left: -1px;\n fill: ", ";\n }\n\n input {\n display: none;\n }\n\n :focus {\n outline: 0;\n border-color: ", ";\n box-shadow: ", ";\n }\n"])), function (_a) {
|