@stokr/components-library 2.0.1 → 2.0.3
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/dist/api/fetchData.js +5 -6
- package/dist/components/2FA/disable-2fa-flow.js +20 -8
- package/dist/components/2FA/enable-2fa-flow.js +24 -12
- package/dist/components/2FA/main-flow.js +41 -10
- package/dist/components/Card/Card.styles.js +69 -0
- package/dist/components/ComponentWrapper/ComponentWrapper.styles.js +3 -1
- package/dist/components/Input/InputWithButton.js +64 -0
- package/dist/components/Input/InputWithButton.stories.js +79 -0
- package/dist/components/Input/InputWithButton.styles.js +37 -0
- package/dist/components/Pagination/Pagination.js +85 -0
- package/dist/components/Pagination/Pagination.stories.js +90 -0
- package/dist/components/Pagination/Pagination.styles.js +27 -0
- package/dist/components/Pagination/usePagination.js +92 -0
- package/dist/index.js +11 -0
- package/package.json +1 -1
package/dist/api/fetchData.js
CHANGED
|
@@ -42,22 +42,21 @@ var fetchData = /*#__PURE__*/function () {
|
|
|
42
42
|
});
|
|
43
43
|
case 8:
|
|
44
44
|
result = _context.sent;
|
|
45
|
-
console.log('🚀 ~ result:', result);
|
|
46
45
|
// console.log(result);
|
|
47
46
|
|
|
48
47
|
resolve(result.data);
|
|
49
|
-
_context.next =
|
|
48
|
+
_context.next = 16;
|
|
50
49
|
break;
|
|
51
|
-
case
|
|
52
|
-
_context.prev =
|
|
50
|
+
case 12:
|
|
51
|
+
_context.prev = 12;
|
|
53
52
|
_context.t0 = _context["catch"](5);
|
|
54
53
|
console.log("Error: ".concat(_context.t0));
|
|
55
54
|
reject(_context.t0);
|
|
56
|
-
case
|
|
55
|
+
case 16:
|
|
57
56
|
case "end":
|
|
58
57
|
return _context.stop();
|
|
59
58
|
}
|
|
60
|
-
}, _callee, null, [[5,
|
|
59
|
+
}, _callee, null, [[5, 12]]);
|
|
61
60
|
}));
|
|
62
61
|
return function (_x3, _x4) {
|
|
63
62
|
return _ref2.apply(this, arguments);
|
|
@@ -14,6 +14,7 @@ var _Text = _interopRequireDefault(require("../Text/Text.styles"));
|
|
|
14
14
|
var _Button = _interopRequireDefault(require("../Button/Button.styles"));
|
|
15
15
|
var _Grid = require("../Grid/Grid.styles");
|
|
16
16
|
var _Sucess2FA = _interopRequireDefault(require("./Sucess2FA"));
|
|
17
|
+
var _fetchData = _interopRequireDefault(require("../../api/fetchData"));
|
|
17
18
|
var _excluded = ["showFlow", "setShowFlow", "onSuccess", "onRequiresRecentLoginError"];
|
|
18
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -68,20 +69,31 @@ var Disable2FA = function Disable2FA(_ref) {
|
|
|
68
69
|
setIsModalOpen(_objectSpread(_objectSpread({}, isModalOpen), {}, {
|
|
69
70
|
sucess: true
|
|
70
71
|
}));
|
|
71
|
-
_context.
|
|
72
|
+
_context.prev = 4;
|
|
73
|
+
_context.next = 7;
|
|
74
|
+
return (0, _fetchData.default)('auth/disable-2fa-email');
|
|
75
|
+
case 7:
|
|
76
|
+
_context.next = 12;
|
|
72
77
|
break;
|
|
73
|
-
case
|
|
74
|
-
_context.prev =
|
|
75
|
-
_context.t0 = _context["catch"](
|
|
76
|
-
console.log('🚀 ~
|
|
77
|
-
|
|
78
|
+
case 9:
|
|
79
|
+
_context.prev = 9;
|
|
80
|
+
_context.t0 = _context["catch"](4);
|
|
81
|
+
console.log('🚀 ~ error while sending email:', _context.t0);
|
|
82
|
+
case 12:
|
|
83
|
+
_context.next = 18;
|
|
84
|
+
break;
|
|
85
|
+
case 14:
|
|
86
|
+
_context.prev = 14;
|
|
87
|
+
_context.t1 = _context["catch"](0);
|
|
88
|
+
console.log('🚀 ~ file: disable-2fa-flow.js ~ error:', _context.t1);
|
|
89
|
+
if (_context.t1.code === 'auth/requires-recent-login') {
|
|
78
90
|
onRequiresRecentLoginError && onRequiresRecentLoginError();
|
|
79
91
|
}
|
|
80
|
-
case
|
|
92
|
+
case 18:
|
|
81
93
|
case "end":
|
|
82
94
|
return _context.stop();
|
|
83
95
|
}
|
|
84
|
-
}, _callee, null, [[0,
|
|
96
|
+
}, _callee, null, [[0, 14], [4, 9]]);
|
|
85
97
|
}));
|
|
86
98
|
return function handleDisableClick() {
|
|
87
99
|
return _ref2.apply(this, arguments);
|
|
@@ -14,6 +14,7 @@ var _Connect2FA = _interopRequireDefault(require("./Connect2FA"));
|
|
|
14
14
|
var _EnterCode = _interopRequireDefault(require("./EnterCode"));
|
|
15
15
|
var _AuthContext = require("../../context/AuthContext");
|
|
16
16
|
var _Sucess2FA = _interopRequireDefault(require("./Sucess2FA"));
|
|
17
|
+
var _fetchData = _interopRequireDefault(require("../../api/fetchData"));
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
@@ -83,14 +84,25 @@ var Enable2FAFlow = function Enable2FAFlow(_ref) {
|
|
|
83
84
|
return enrollUserToTotp(user, totpData.totpSecret, data.otpInput, user.displayName);
|
|
84
85
|
case 5:
|
|
85
86
|
setshowSuccess(true);
|
|
86
|
-
_context.
|
|
87
|
+
_context.prev = 6;
|
|
88
|
+
_context.next = 9;
|
|
89
|
+
return (0, _fetchData.default)('auth/enable-2fa-email');
|
|
90
|
+
case 9:
|
|
91
|
+
_context.next = 14;
|
|
87
92
|
break;
|
|
88
|
-
case
|
|
89
|
-
_context.prev =
|
|
90
|
-
_context.t0 = _context["catch"](
|
|
91
|
-
console.log('🚀 ~
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
case 11:
|
|
94
|
+
_context.prev = 11;
|
|
95
|
+
_context.t0 = _context["catch"](6);
|
|
96
|
+
console.log('🚀 ~ error while sending email:', _context.t0);
|
|
97
|
+
case 14:
|
|
98
|
+
_context.next = 25;
|
|
99
|
+
break;
|
|
100
|
+
case 16:
|
|
101
|
+
_context.prev = 16;
|
|
102
|
+
_context.t1 = _context["catch"](2);
|
|
103
|
+
console.log('🚀 ~ file: enable-2fa-flow.js:60 ~ error:', _context.t1);
|
|
104
|
+
if (!(_context.t1.code === 'auth/invalid-verification-code')) {
|
|
105
|
+
_context.next = 24;
|
|
94
106
|
break;
|
|
95
107
|
}
|
|
96
108
|
setpopupError({
|
|
@@ -100,20 +112,20 @@ var Enable2FAFlow = function Enable2FAFlow(_ref) {
|
|
|
100
112
|
return _context.abrupt("return", {
|
|
101
113
|
otpInput: 'Invalid code'
|
|
102
114
|
});
|
|
103
|
-
case
|
|
104
|
-
if (_context.
|
|
115
|
+
case 24:
|
|
116
|
+
if (_context.t1.code === 'auth/requires-recent-login') {
|
|
105
117
|
onRequiresRecentLoginError && onRequiresRecentLoginError();
|
|
106
118
|
} else {
|
|
107
119
|
setpopupError({
|
|
108
120
|
popup: 'enter2fa',
|
|
109
|
-
message: "".concat(_context.
|
|
121
|
+
message: "".concat(_context.t1 !== null && _context.t1 !== void 0 && _context.t1.message ? _context.t1 === null || _context.t1 === void 0 ? void 0 : _context.t1.message : 'Something went wrong. Try again?')
|
|
110
122
|
});
|
|
111
123
|
}
|
|
112
|
-
case
|
|
124
|
+
case 25:
|
|
113
125
|
case "end":
|
|
114
126
|
return _context.stop();
|
|
115
127
|
}
|
|
116
|
-
}, _callee, null, [[2,
|
|
128
|
+
}, _callee, null, [[2, 16], [6, 11]]);
|
|
117
129
|
}));
|
|
118
130
|
return function onSubmit(_x) {
|
|
119
131
|
return _ref2.apply(this, arguments);
|
|
@@ -21,6 +21,9 @@ var _excluded = ["onRequiresRecentLoginError"];
|
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
24
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
25
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
26
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
24
27
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
28
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
26
29
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -77,6 +80,42 @@ var Main2FAFlow = function Main2FAFlow(_ref) {
|
|
|
77
80
|
var _objectSpread2;
|
|
78
81
|
setIsFlowOpen(_objectSpread(_objectSpread({}, isFlowopen), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, prevFlowId, false), _defineProperty(_objectSpread2, nextFlowId, true), _objectSpread2)));
|
|
79
82
|
};
|
|
83
|
+
var onEnable2FASuccess = /*#__PURE__*/function () {
|
|
84
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
85
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
86
|
+
while (1) switch (_context.prev = _context.next) {
|
|
87
|
+
case 0:
|
|
88
|
+
setis2FAEnabled(true);
|
|
89
|
+
checkMfaEnrollment(user);
|
|
90
|
+
setsuccessMessage('Your log in 2FA authentication is now set');
|
|
91
|
+
case 3:
|
|
92
|
+
case "end":
|
|
93
|
+
return _context.stop();
|
|
94
|
+
}
|
|
95
|
+
}, _callee);
|
|
96
|
+
}));
|
|
97
|
+
return function onEnable2FASuccess() {
|
|
98
|
+
return _ref2.apply(this, arguments);
|
|
99
|
+
};
|
|
100
|
+
}();
|
|
101
|
+
var onDisable2FASuccess = /*#__PURE__*/function () {
|
|
102
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
103
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
104
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
setis2FAEnabled(false);
|
|
107
|
+
checkMfaEnrollment(user);
|
|
108
|
+
setsuccessMessage('Your log in 2FA authentication is removed');
|
|
109
|
+
case 3:
|
|
110
|
+
case "end":
|
|
111
|
+
return _context2.stop();
|
|
112
|
+
}
|
|
113
|
+
}, _callee2);
|
|
114
|
+
}));
|
|
115
|
+
return function onDisable2FASuccess() {
|
|
116
|
+
return _ref3.apply(this, arguments);
|
|
117
|
+
};
|
|
118
|
+
}();
|
|
80
119
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
|
|
81
120
|
alignVertically: true,
|
|
82
121
|
noPaddingHorizontal: true
|
|
@@ -121,11 +160,7 @@ var Main2FAFlow = function Main2FAFlow(_ref) {
|
|
|
121
160
|
}));
|
|
122
161
|
},
|
|
123
162
|
onRequiresRecentLoginError: onRequiresRecentLoginError,
|
|
124
|
-
onSuccess:
|
|
125
|
-
setis2FAEnabled(true);
|
|
126
|
-
checkMfaEnrollment(user);
|
|
127
|
-
setsuccessMessage('Your log in 2FA authentication is now set');
|
|
128
|
-
}
|
|
163
|
+
onSuccess: onEnable2FASuccess
|
|
129
164
|
}), isFlowopen.disable2fa && /*#__PURE__*/_react.default.createElement(_disable2faFlow.default, {
|
|
130
165
|
showFlow: isFlowopen.disable2fa,
|
|
131
166
|
setShowFlow: function setShowFlow(value) {
|
|
@@ -134,11 +169,7 @@ var Main2FAFlow = function Main2FAFlow(_ref) {
|
|
|
134
169
|
}));
|
|
135
170
|
},
|
|
136
171
|
onRequiresRecentLoginError: onRequiresRecentLoginError,
|
|
137
|
-
onSuccess:
|
|
138
|
-
setis2FAEnabled(false);
|
|
139
|
-
checkMfaEnrollment(user);
|
|
140
|
-
setsuccessMessage('Your log in 2FA authentication is removed');
|
|
141
|
-
}
|
|
172
|
+
onSuccess: onDisable2FASuccess
|
|
142
173
|
}), !user && /*#__PURE__*/_react.default.createElement(_loginWithOtpFlow.default, null));
|
|
143
174
|
};
|
|
144
175
|
exports.Main2FAFlow = Main2FAFlow;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.CardTitleContainer = exports.CardTitle = exports.CardRightText = exports.CardLeftText = exports.CardHeaderRegular = exports.CardHeader = exports.Card = void 0;
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
var _rwd = _interopRequireDefault(require("../../styles/rwd"));
|
|
10
|
+
var _Select = require("../Input/Select.styles");
|
|
11
|
+
var _theme = _interopRequireDefault(require("../../styles/theme"));
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
16
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
17
|
+
var Card = _styledComponents.default.div.withConfig({
|
|
18
|
+
displayName: "Cardstyles__Card",
|
|
19
|
+
componentId: "sc-16hwkn5-0"
|
|
20
|
+
})(["padding:28px 22px;background:", ";", " ", " ", " ", ""], _theme.default.cWhite, _rwd.default.Medium(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 40px 50px;\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n "])), function (props) {
|
|
21
|
+
return props.lessPadding && (0, _styledComponents.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: 28px 22px;\n "])));
|
|
22
|
+
}, function (props) {
|
|
23
|
+
return props.lessPaddingHorizontal && (0, _styledComponents.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 40px 22px;\n "])));
|
|
24
|
+
}, function (props) {
|
|
25
|
+
return props.lessPaddingVertical && (0, _styledComponents.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 28px 50px;\n "])));
|
|
26
|
+
}, function (props) {
|
|
27
|
+
return props.chartPadding && (0, _styledComponents.css)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: 20px;\n "])));
|
|
28
|
+
}, function (props) {
|
|
29
|
+
return props.noPadding && (0, _styledComponents.css)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n padding: 0;\n "])));
|
|
30
|
+
}), function (props) {
|
|
31
|
+
return props.chartPadding && (0, _styledComponents.css)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding: 10px;\n "])));
|
|
32
|
+
}, function (props) {
|
|
33
|
+
return props.noPadding && (0, _styledComponents.css)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n padding: 0;\n "])));
|
|
34
|
+
}, function (props) {
|
|
35
|
+
return props.grow && "\n flex-grow: ".concat(props.grow, ";\n ");
|
|
36
|
+
});
|
|
37
|
+
exports.Card = Card;
|
|
38
|
+
var CardTitle = _styledComponents.default.div.withConfig({
|
|
39
|
+
displayName: "Cardstyles__CardTitle",
|
|
40
|
+
componentId: "sc-16hwkn5-1"
|
|
41
|
+
})(["font-size:16px;line-height:22px;font-weight:600;"]);
|
|
42
|
+
exports.CardTitle = CardTitle;
|
|
43
|
+
var CardTitleContainer = _styledComponents.default.div.withConfig({
|
|
44
|
+
displayName: "Cardstyles__CardTitleContainer",
|
|
45
|
+
componentId: "sc-16hwkn5-2"
|
|
46
|
+
})(["display:flex;flex-direction:row;align-items:center;"]);
|
|
47
|
+
exports.CardTitleContainer = CardTitleContainer;
|
|
48
|
+
var CardRightText = _styledComponents.default.div.withConfig({
|
|
49
|
+
displayName: "Cardstyles__CardRightText",
|
|
50
|
+
componentId: "sc-16hwkn5-3"
|
|
51
|
+
})(["margin-left:auto;font-size:16px;"]);
|
|
52
|
+
exports.CardRightText = CardRightText;
|
|
53
|
+
var CardLeftText = _styledComponents.default.div.withConfig({
|
|
54
|
+
displayName: "Cardstyles__CardLeftText",
|
|
55
|
+
componentId: "sc-16hwkn5-4"
|
|
56
|
+
})(["margin-left:18px;font-size:16px;"]);
|
|
57
|
+
exports.CardLeftText = CardLeftText;
|
|
58
|
+
var CardHeader = _styledComponents.default.div.withConfig({
|
|
59
|
+
displayName: "Cardstyles__CardHeader",
|
|
60
|
+
componentId: "sc-16hwkn5-5"
|
|
61
|
+
})(["display:flex;flex-direction:row;justify-content:space-between;align-items:center;flex-wrap:wrap;", " ", "{height:22px;margin-top:-8px;}"], function (props) {
|
|
62
|
+
return props.paddingRight && (0, _styledComponents.css)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n padding-right: ", ";\n "])), props.paddingRight);
|
|
63
|
+
}, _Select.SelectWrapper);
|
|
64
|
+
exports.CardHeader = CardHeader;
|
|
65
|
+
var CardHeaderRegular = _styledComponents.default.div.withConfig({
|
|
66
|
+
displayName: "Cardstyles__CardHeaderRegular",
|
|
67
|
+
componentId: "sc-16hwkn5-6"
|
|
68
|
+
})(["font-weight:400;display:inline-block;"]);
|
|
69
|
+
exports.CardHeaderRegular = CardHeaderRegular;
|
|
@@ -16,7 +16,7 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(
|
|
|
16
16
|
var ComponentWrapper = _styledComponents.default.div.withConfig({
|
|
17
17
|
displayName: "ComponentWrapperstyles__ComponentWrapper",
|
|
18
18
|
componentId: "sc-1w1v084-0"
|
|
19
|
-
})(["position:relative;padding:32px;text-align:left !important;", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " @media screen and (max-width:767px){padding:32px;", "}", " ", " ", ""], _rwd.default.Large(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 32px 64px;\n "]))), function (props) {
|
|
19
|
+
})(["position:relative;padding:32px;text-align:left !important;", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " @media screen and (max-width:767px){padding:32px;", "}", " ", " ", " ", ""], _rwd.default.Large(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 32px 64px;\n "]))), function (props) {
|
|
20
20
|
return props.borderLeft && (0, _styledComponents.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border-left: 1px solid ", ";\n "])), _theme.default.cLightGrey);
|
|
21
21
|
}, function (props) {
|
|
22
22
|
return props.borderRight && (0, _styledComponents.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n border-right: 1px solid ", ";\n "])), _theme.default.cLightGrey);
|
|
@@ -64,6 +64,8 @@ var ComponentWrapper = _styledComponents.default.div.withConfig({
|
|
|
64
64
|
return props.marginTop && (0, _styledComponents.css)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["\n margin-top: ", ";\n "])), props.marginTop);
|
|
65
65
|
}, function (props) {
|
|
66
66
|
return props.isAddMember && (0, _styledComponents.css)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["\n @media screen and (min-width: 768px) {\n padding-left: 10px !important;\n padding-right: 10px !important;\n }\n "])));
|
|
67
|
+
}, function (props) {
|
|
68
|
+
return props.flex && "\n display:flex;\n align-items: center;\n ";
|
|
67
69
|
});
|
|
68
70
|
exports.ComponentWrapper = ComponentWrapper;
|
|
69
71
|
var _default = ComponentWrapper;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.InputWithButton = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _InputWithButton = require("./InputWithButton.styles");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
var InputWithButton = function InputWithButton(_ref) {
|
|
12
|
+
var children = _ref.children,
|
|
13
|
+
type = _ref.type,
|
|
14
|
+
id = _ref.id,
|
|
15
|
+
name = _ref.name,
|
|
16
|
+
placeholder = _ref.placeholder,
|
|
17
|
+
value = _ref.value,
|
|
18
|
+
error = _ref.error,
|
|
19
|
+
touched = _ref.touched,
|
|
20
|
+
onChange = _ref.onChange,
|
|
21
|
+
onBlur = _ref.onBlur,
|
|
22
|
+
onFocus = _ref.onFocus,
|
|
23
|
+
separatorTop = _ref.separatorTop;
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_InputWithButton.Container, {
|
|
25
|
+
separatorTop: separatorTop
|
|
26
|
+
}, /*#__PURE__*/_react.default.createElement(_InputWithButton.InputWrap, null, /*#__PURE__*/_react.default.createElement(_InputWithButton.Input, {
|
|
27
|
+
type: type,
|
|
28
|
+
id: id,
|
|
29
|
+
name: name,
|
|
30
|
+
value: value,
|
|
31
|
+
onChange: onChange,
|
|
32
|
+
onBlur: onBlur,
|
|
33
|
+
onFocus: onFocus,
|
|
34
|
+
placeholder: placeholder
|
|
35
|
+
})), /*#__PURE__*/_react.default.createElement(_InputWithButton.ButtonWrap, null, children));
|
|
36
|
+
};
|
|
37
|
+
exports.InputWithButton = InputWithButton;
|
|
38
|
+
InputWithButton.propTypes = {
|
|
39
|
+
children: _propTypes.default.node.isRequired,
|
|
40
|
+
type: _propTypes.default.string,
|
|
41
|
+
id: _propTypes.default.string.isRequired,
|
|
42
|
+
name: _propTypes.default.string.isRequired,
|
|
43
|
+
placeholder: _propTypes.default.string,
|
|
44
|
+
value: _propTypes.default.string,
|
|
45
|
+
error: _propTypes.default.bool,
|
|
46
|
+
touched: _propTypes.default.bool,
|
|
47
|
+
onChange: _propTypes.default.func,
|
|
48
|
+
onBlur: _propTypes.default.func,
|
|
49
|
+
onFocus: _propTypes.default.func,
|
|
50
|
+
separatorTop: _propTypes.default.bool
|
|
51
|
+
};
|
|
52
|
+
InputWithButton.defaultProps = {
|
|
53
|
+
type: 'search',
|
|
54
|
+
placeholder: '',
|
|
55
|
+
value: '',
|
|
56
|
+
error: false,
|
|
57
|
+
touched: false,
|
|
58
|
+
onChange: function onChange() {},
|
|
59
|
+
onBlur: function onBlur() {},
|
|
60
|
+
onFocus: function onFocus() {},
|
|
61
|
+
separatorTop: false
|
|
62
|
+
};
|
|
63
|
+
var _default = InputWithButton;
|
|
64
|
+
exports.default = _default;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.InputButton = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _InputWithButton = require("./InputWithButton");
|
|
9
|
+
var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
|
|
10
|
+
var _global = _interopRequireDefault(require("../../styles/global"));
|
|
11
|
+
var _Button = require("../Button/Button.styles");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
var _default = {
|
|
14
|
+
title: 'Components Library/Inputs/Input With Button',
|
|
15
|
+
component: _InputWithButton.InputWithButton,
|
|
16
|
+
argTypes: {
|
|
17
|
+
type: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
defaultValue: 'number'
|
|
20
|
+
},
|
|
21
|
+
id: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
name: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
label: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
defaultValue: ''
|
|
32
|
+
},
|
|
33
|
+
value: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
defaultValue: ''
|
|
36
|
+
},
|
|
37
|
+
error: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
defaultValue: false
|
|
40
|
+
},
|
|
41
|
+
touched: {
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
defaultValue: false
|
|
44
|
+
},
|
|
45
|
+
onChange: {
|
|
46
|
+
action: 'change',
|
|
47
|
+
type: 'function'
|
|
48
|
+
},
|
|
49
|
+
onBlur: {
|
|
50
|
+
action: 'blur',
|
|
51
|
+
type: 'function'
|
|
52
|
+
},
|
|
53
|
+
onFocus: {
|
|
54
|
+
action: 'hasFocus',
|
|
55
|
+
type: 'function'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.default = _default;
|
|
60
|
+
var Template = function Template(args) {
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_InputWithButton.InputWithButton, null, /*#__PURE__*/_react.default.createElement(_Button.Button, null, "apply")), /*#__PURE__*/_react.default.createElement(_InputWithButton.InputWithButton, args)));
|
|
62
|
+
};
|
|
63
|
+
var InputButton = Template.bind({});
|
|
64
|
+
exports.InputButton = InputButton;
|
|
65
|
+
InputButton.args = {
|
|
66
|
+
placeholder: 'Page size',
|
|
67
|
+
onChange: function onChange() {
|
|
68
|
+
console.log('changed');
|
|
69
|
+
}
|
|
70
|
+
//label: 'test',
|
|
71
|
+
//value: 'test',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// export const PasswordStrength = Template.bind({})
|
|
75
|
+
// PasswordStrength.args = {
|
|
76
|
+
// label: 'input description (label) - PASSWORD',
|
|
77
|
+
// value: 'your password (value)',
|
|
78
|
+
// showStrength: true,
|
|
79
|
+
// }
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InputWrap = exports.Input = exports.Container = exports.ButtonWrap = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
var _theme = _interopRequireDefault(require("../../styles/theme"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var Container = _styledComponents.default.div.withConfig({
|
|
11
|
+
displayName: "InputWithButtonstyles__Container",
|
|
12
|
+
componentId: "sc-ulpczh-0"
|
|
13
|
+
})(["position:relative;display:flex;flex-direction:row;align-items:center;", ""], function (props) {
|
|
14
|
+
return props.separatorTop && "\n padding-top: 20px;\n margin-top: 20px;\n border-top: 1px solid ".concat(_theme.default.cLightGrey, ";\n ");
|
|
15
|
+
});
|
|
16
|
+
exports.Container = Container;
|
|
17
|
+
var InputWrap = _styledComponents.default.div.withConfig({
|
|
18
|
+
displayName: "InputWithButtonstyles__InputWrap",
|
|
19
|
+
componentId: "sc-ulpczh-1"
|
|
20
|
+
})(["flex-grow:1;z-index:0;position:relative;margin-right:-40px;"]);
|
|
21
|
+
exports.InputWrap = InputWrap;
|
|
22
|
+
var ButtonWrap = _styledComponents.default.div.withConfig({
|
|
23
|
+
displayName: "InputWithButtonstyles__ButtonWrap",
|
|
24
|
+
componentId: "sc-ulpczh-2"
|
|
25
|
+
})(["z-index:1;position:relative;"]);
|
|
26
|
+
exports.ButtonWrap = ButtonWrap;
|
|
27
|
+
var Input = _styledComponents.default.input.withConfig({
|
|
28
|
+
displayName: "InputWithButtonstyles__Input",
|
|
29
|
+
componentId: "sc-ulpczh-3"
|
|
30
|
+
})(["display:block;border:0;height:40px;width:100%;padding:9px 23px;padding-right:63px;font-family:'Open Sans';font-size:14px;line-height:20px;border:1px solid ", ";border-radius:20px;outline:0;transition:border-color 0.2s;&:focus,&:hover{border:1px solid ", ";}&::placeholder{color:", ";opacity:1;}"], function (props) {
|
|
31
|
+
return _theme.default.cLightGrey;
|
|
32
|
+
}, function (props) {
|
|
33
|
+
return _theme.default.cPrimary;
|
|
34
|
+
}, function (props) {
|
|
35
|
+
return _theme.default.cGrey2;
|
|
36
|
+
});
|
|
37
|
+
exports.Input = Input;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.Pagination = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _usePagination = require("./usePagination");
|
|
10
|
+
var _Pagination = require("./Pagination.styles");
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _Icon = _interopRequireWildcard(require("../Icon/Icon.style"));
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
var Pagination = function Pagination(props) {
|
|
17
|
+
var onPageChange = props.onPageChange,
|
|
18
|
+
totalCount = props.totalCount,
|
|
19
|
+
siblingCount = props.siblingCount,
|
|
20
|
+
currentPage = props.currentPage,
|
|
21
|
+
pageSize = props.pageSize;
|
|
22
|
+
var paginationRange = (0, _usePagination.usePagination)({
|
|
23
|
+
currentPage: currentPage,
|
|
24
|
+
totalCount: totalCount,
|
|
25
|
+
siblingCount: siblingCount,
|
|
26
|
+
pageSize: pageSize
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// If there are less than 2 times in pagination range we shall not render the component
|
|
30
|
+
if (currentPage === 0 || paginationRange.length < 2) {
|
|
31
|
+
onPageChange(1);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
var onNext = function onNext() {
|
|
35
|
+
onPageChange(currentPage + 1);
|
|
36
|
+
};
|
|
37
|
+
var onPrevious = function onPrevious() {
|
|
38
|
+
onPageChange(currentPage - 1);
|
|
39
|
+
};
|
|
40
|
+
var lastPage = paginationRange[paginationRange.length - 1];
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement(_Pagination.StyledList, null, /*#__PURE__*/_react.default.createElement(_Pagination.StyledList.Item, {
|
|
42
|
+
disabled: currentPage === 1,
|
|
43
|
+
onClick: onPrevious,
|
|
44
|
+
arrow: true
|
|
45
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
46
|
+
icon: _Icon.iconsMap.arrowLeft
|
|
47
|
+
})), paginationRange.map(function (pageNumber) {
|
|
48
|
+
// If the pageItem is a DOT, render the DOTS unicode character
|
|
49
|
+
if (pageNumber === _usePagination.DOTS) {
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_Pagination.StyledList.Item, {
|
|
51
|
+
dots: true,
|
|
52
|
+
key: pageNumber
|
|
53
|
+
}, "\u2026");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Render our Page Pills
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement(_Pagination.StyledList.Item, {
|
|
58
|
+
key: pageNumber,
|
|
59
|
+
selected: pageNumber === currentPage,
|
|
60
|
+
onClick: function onClick() {
|
|
61
|
+
return onPageChange(pageNumber);
|
|
62
|
+
}
|
|
63
|
+
}, pageNumber);
|
|
64
|
+
}), /*#__PURE__*/_react.default.createElement(_Pagination.StyledList.Item, {
|
|
65
|
+
disabled: currentPage === lastPage,
|
|
66
|
+
onClick: onNext,
|
|
67
|
+
arrow: true
|
|
68
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
69
|
+
icon: _Icon.iconsMap.arrowRight
|
|
70
|
+
})));
|
|
71
|
+
};
|
|
72
|
+
exports.Pagination = Pagination;
|
|
73
|
+
Pagination.propTypes = {
|
|
74
|
+
onPageChange: _propTypes.default.func.isRequired,
|
|
75
|
+
totalCount: _propTypes.default.number.isRequired,
|
|
76
|
+
currentPage: _propTypes.default.number.isRequired,
|
|
77
|
+
siblingCount: _propTypes.default.number,
|
|
78
|
+
pageSize: _propTypes.default.number
|
|
79
|
+
};
|
|
80
|
+
Pagination.defaultProps = {
|
|
81
|
+
siblingCount: 1,
|
|
82
|
+
pageSize: 10
|
|
83
|
+
};
|
|
84
|
+
var _default = Pagination;
|
|
85
|
+
exports.default = _default;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.PaginationWithInput = exports.PaginationExample = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Pagination = require("./Pagination");
|
|
9
|
+
var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
|
|
10
|
+
var _global = _interopRequireDefault(require("../../styles/global"));
|
|
11
|
+
var _InputWithButton = require("../Input/InputWithButton");
|
|
12
|
+
var _Button = require("../Button/Button.styles");
|
|
13
|
+
var _Card = require("../Card/Card.styles");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
var _default = {
|
|
16
|
+
title: 'Components Library/Pagination',
|
|
17
|
+
component: _Pagination.Pagination,
|
|
18
|
+
argTypes: {
|
|
19
|
+
currentPage: {
|
|
20
|
+
type: 'number',
|
|
21
|
+
defaultValue: 0
|
|
22
|
+
},
|
|
23
|
+
totalCount: {
|
|
24
|
+
type: 'number',
|
|
25
|
+
defaultValue: 0
|
|
26
|
+
},
|
|
27
|
+
pageSize: {
|
|
28
|
+
type: 'number',
|
|
29
|
+
defaultValue: 10
|
|
30
|
+
},
|
|
31
|
+
siblingCount: {
|
|
32
|
+
type: 'number',
|
|
33
|
+
defaultValue: 0
|
|
34
|
+
},
|
|
35
|
+
onPageChange: {
|
|
36
|
+
type: 'function',
|
|
37
|
+
required: true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.default = _default;
|
|
42
|
+
var Template = function Template(args) {
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_Pagination.Pagination, args)));
|
|
44
|
+
};
|
|
45
|
+
var TemplateWithInput = function TemplateWithInput(args) {
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, {
|
|
47
|
+
noPaddingHorizontal: true,
|
|
48
|
+
flex: true,
|
|
49
|
+
style: {
|
|
50
|
+
justifyContent: 'space-between',
|
|
51
|
+
flexWrap: 'wrap'
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/_react.default.createElement(_Pagination.Pagination, args), /*#__PURE__*/_react.default.createElement(_Card.Card, {
|
|
54
|
+
noPadding: true
|
|
55
|
+
}, /*#__PURE__*/_react.default.createElement(_Card.CardTitle, {
|
|
56
|
+
style: {
|
|
57
|
+
padding: '2px 20px'
|
|
58
|
+
}
|
|
59
|
+
}, "Page Size:"), /*#__PURE__*/_react.default.createElement(_InputWithButton.InputWithButton, {
|
|
60
|
+
id: "pageSize",
|
|
61
|
+
name: "pageSize",
|
|
62
|
+
type: "number",
|
|
63
|
+
placeholder: 'Page size'
|
|
64
|
+
// onChange={(e) => setinputPageSize(e.target.value)}
|
|
65
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.Button
|
|
66
|
+
// onClick={() => setpageSize(Number(inputPageSize))}
|
|
67
|
+
, null, "apply")))));
|
|
68
|
+
};
|
|
69
|
+
var PaginationExample = Template.bind({});
|
|
70
|
+
exports.PaginationExample = PaginationExample;
|
|
71
|
+
PaginationExample.args = {
|
|
72
|
+
currentPage: 1,
|
|
73
|
+
totalCount: 100,
|
|
74
|
+
pageSize: 10,
|
|
75
|
+
siblingCount: 1,
|
|
76
|
+
onPageChange: function onPageChange(page) {
|
|
77
|
+
console.log('page changed to', page);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var PaginationWithInput = TemplateWithInput.bind({});
|
|
81
|
+
exports.PaginationWithInput = PaginationWithInput;
|
|
82
|
+
PaginationWithInput.args = {
|
|
83
|
+
currentPage: 1,
|
|
84
|
+
totalCount: 100,
|
|
85
|
+
pageSize: 10,
|
|
86
|
+
siblingCount: 1,
|
|
87
|
+
onPageChange: function onPageChange(page) {
|
|
88
|
+
console.log('page changed to', page);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledList = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
var _theme = _interopRequireDefault(require("../../styles/theme"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var StyledList = _styledComponents.default.ul.withConfig({
|
|
11
|
+
displayName: "Paginationstyles__StyledList",
|
|
12
|
+
componentId: "sc-7ltpvr-0"
|
|
13
|
+
})(["display:flex;list-style-type:none;"]);
|
|
14
|
+
exports.StyledList = StyledList;
|
|
15
|
+
var ListItem = _styledComponents.default.li.withConfig({
|
|
16
|
+
displayName: "Paginationstyles__ListItem",
|
|
17
|
+
componentId: "sc-7ltpvr-1"
|
|
18
|
+
})(["padding:0 12px;height:32px;text-align:center;margin:auto 4px;color:", ";display:flex;align-items:center;letter-spacing:0.01071em;border-radius:16px;line-height:1.43;font-size:15px;font-weight:500;min-width:32px;", " &:hover{background-color:", ";color:", ";cursor:pointer;}", " ", " ", ""], _theme.default.cBlack, function (props) {
|
|
19
|
+
return props.arrow && "\n padding:0 9px;\n ";
|
|
20
|
+
}, _theme.default.cPrimary, _theme.default.cWhite, function (props) {
|
|
21
|
+
return props.selected && "\n color: ".concat(_theme.default.cWhite, ";\n background-color: ").concat(_theme.default.cPrimary, ";\n ");
|
|
22
|
+
}, function (props) {
|
|
23
|
+
return props.disabled && "\n pointer-events:none;\n opacity: 0.6;\n ";
|
|
24
|
+
}, function (props) {
|
|
25
|
+
return props.dots && "\n &:hover{\n background-color: transparent;\n cursor: default;\n color:".concat(_theme.default.cBlack, "\n }\n ");
|
|
26
|
+
});
|
|
27
|
+
StyledList.Item = ListItem;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePagination = exports.DOTS = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
var DOTS = '...';
|
|
15
|
+
exports.DOTS = DOTS;
|
|
16
|
+
var range = function range(start, end) {
|
|
17
|
+
var length = end - start + 1;
|
|
18
|
+
/*
|
|
19
|
+
Create an array of certain length and set the elements within it from
|
|
20
|
+
start value to end value.
|
|
21
|
+
*/
|
|
22
|
+
return Array.from({
|
|
23
|
+
length: length
|
|
24
|
+
}, function (_, idx) {
|
|
25
|
+
return idx + start;
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var usePagination = function usePagination(_ref) {
|
|
29
|
+
var totalCount = _ref.totalCount,
|
|
30
|
+
pageSize = _ref.pageSize,
|
|
31
|
+
_ref$siblingCount = _ref.siblingCount,
|
|
32
|
+
siblingCount = _ref$siblingCount === void 0 ? 1 : _ref$siblingCount,
|
|
33
|
+
currentPage = _ref.currentPage;
|
|
34
|
+
var paginationRange = (0, _react.useMemo)(function () {
|
|
35
|
+
//The Math.ceil() function always rounds a number up to the next largest integer.
|
|
36
|
+
var totalPageCount = Math.ceil(totalCount / pageSize);
|
|
37
|
+
|
|
38
|
+
// Pages count is determined as siblingCount + firstPage + lastPage + currentPage + 2*DOTS
|
|
39
|
+
var totalPageNumbers = siblingCount + 5;
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
Case 1:
|
|
43
|
+
If the number of pages is less than the page numbers we want to show in our
|
|
44
|
+
paginationComponent, we return the range [1..totalPageCount]
|
|
45
|
+
*/
|
|
46
|
+
if (totalPageNumbers >= totalPageCount) {
|
|
47
|
+
return range(1, totalPageCount);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
Calculate left and right sibling index and make sure they are within range 1 and totalPageCount
|
|
52
|
+
*/
|
|
53
|
+
var leftSiblingIndex = Math.max(currentPage - siblingCount, 1);
|
|
54
|
+
var rightSiblingIndex = Math.min(currentPage + siblingCount, totalPageCount);
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
We do not show dots just when there is just one page number to be inserted between the extremes of sibling and the page limits i.e 1 and totalPageCount. Hence we are using leftSiblingIndex > 2 and rightSiblingIndex < totalPageCount - 2
|
|
58
|
+
*/
|
|
59
|
+
var shouldShowLeftDots = leftSiblingIndex > 2;
|
|
60
|
+
var shouldShowRightDots = rightSiblingIndex < totalPageCount - 2;
|
|
61
|
+
var firstPageIndex = 1;
|
|
62
|
+
var lastPageIndex = totalPageCount;
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
Case 2: No left dots to show, but rights dots to be shown
|
|
66
|
+
*/
|
|
67
|
+
if (!shouldShowLeftDots && shouldShowRightDots) {
|
|
68
|
+
var leftItemCount = 3 + 2 * siblingCount;
|
|
69
|
+
var leftRange = range(1, leftItemCount);
|
|
70
|
+
return [].concat(_toConsumableArray(leftRange), [DOTS, totalPageCount]);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
Case 3: No right dots to show, but left dots to be shown
|
|
75
|
+
*/
|
|
76
|
+
if (shouldShowLeftDots && !shouldShowRightDots) {
|
|
77
|
+
var rightItemCount = 3 + 2 * siblingCount;
|
|
78
|
+
var rightRange = range(totalPageCount - rightItemCount + 1, totalPageCount);
|
|
79
|
+
return [firstPageIndex, DOTS].concat(_toConsumableArray(rightRange));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
Case 4: Both left and right dots to be shown
|
|
84
|
+
*/
|
|
85
|
+
if (shouldShowLeftDots && shouldShowRightDots) {
|
|
86
|
+
var middleRange = range(leftSiblingIndex, rightSiblingIndex);
|
|
87
|
+
return [firstPageIndex, DOTS].concat(_toConsumableArray(middleRange), [DOTS, lastPageIndex]);
|
|
88
|
+
}
|
|
89
|
+
}, [totalCount, pageSize, siblingCount, currentPage]);
|
|
90
|
+
return paginationRange;
|
|
91
|
+
};
|
|
92
|
+
exports.usePagination = usePagination;
|
package/dist/index.js
CHANGED
|
@@ -1114,6 +1114,17 @@ Object.keys(_headerHo).forEach(function (key) {
|
|
|
1114
1114
|
}
|
|
1115
1115
|
});
|
|
1116
1116
|
});
|
|
1117
|
+
var _Pagination = require("./components/Pagination/Pagination");
|
|
1118
|
+
Object.keys(_Pagination).forEach(function (key) {
|
|
1119
|
+
if (key === "default" || key === "__esModule") return;
|
|
1120
|
+
if (key in exports && exports[key] === _Pagination[key]) return;
|
|
1121
|
+
Object.defineProperty(exports, key, {
|
|
1122
|
+
enumerable: true,
|
|
1123
|
+
get: function get() {
|
|
1124
|
+
return _Pagination[key];
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
});
|
|
1117
1128
|
var _List = require("./components/landing-page/List");
|
|
1118
1129
|
Object.keys(_List).forEach(function (key) {
|
|
1119
1130
|
if (key === "default" || key === "__esModule") return;
|