@cashub/ui 0.1.2 → 0.3.0
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/badge/Badge.js +23 -0
- package/badge/BadgeDot.js +21 -0
- package/badge/BadgeFill.js +36 -0
- package/badge/BadgeWithText.js +28 -0
- package/badge/index.js +39 -0
- package/breadcrumb/Breadcrumb.js +44 -0
- package/breadcrumb/index.js +15 -0
- package/button/Button.js +57 -0
- package/button/ButtonGroup.js +34 -0
- package/button/IconButton.js +45 -0
- package/button/ScrollToTopButton.js +73 -0
- package/button/index.js +39 -0
- package/file/HiddenFileInput.js +24 -0
- package/file/index.js +15 -0
- package/form/Checkbox.js +81 -0
- package/form/FormItem.js +19 -0
- package/form/Input.js +30 -0
- package/form/Label.js +25 -0
- package/form/MutedText.js +22 -0
- package/form/RadioButton.js +61 -0
- package/form/Searchbox.js +109 -0
- package/form/SwitchButton.js +76 -0
- package/form/Textarea.js +23 -0
- package/index.js +39 -0
- package/modal/StateModal.js +177 -0
- package/modal/TitleModal.js +299 -0
- package/package.json +1 -1
- package/styles/breakpoint.style.js +14 -0
- package/styles/mixin/backgroundColor.js +28 -0
- package/styles/mixin/borderColor.js +28 -0
- package/styles/mixin/color.js +28 -0
- package/styles/mixin/colorOnBackground.js +28 -0
- package/styles/mixin/inputPlaceholder.js +19 -0
- package/styles/mixin/media.js +27 -0
- package/styles/mixin/scrollbar.js +19 -0
- package/utils/appendToBody.js +21 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
|
|
12
|
+
var _reactDom = _interopRequireWildcard(require("react-dom"));
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _md = require("react-icons/md");
|
|
17
|
+
|
|
18
|
+
var _media = _interopRequireDefault(require("../../styles/mixin/media"));
|
|
19
|
+
|
|
20
|
+
var _scrollbar = _interopRequireDefault(require("../../styles/mixin/scrollbar"));
|
|
21
|
+
|
|
22
|
+
var _appendToBody = _interopRequireDefault(require("../utils/appendToBody"));
|
|
23
|
+
|
|
24
|
+
var _isReactComponent = _interopRequireDefault(require("../../utils/react/isReactComponent"));
|
|
25
|
+
|
|
26
|
+
var _Heading = _interopRequireDefault(require("../heading/Heading3"));
|
|
27
|
+
|
|
28
|
+
var _ModalBackdrop = _interopRequireDefault(require("../backdrop/ModalBackdrop"));
|
|
29
|
+
|
|
30
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
|
+
|
|
32
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
33
|
+
|
|
34
|
+
var _excluded = ["children"];
|
|
35
|
+
|
|
36
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
+
|
|
38
|
+
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); }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
41
|
+
|
|
42
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
43
|
+
|
|
44
|
+
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; }
|
|
45
|
+
|
|
46
|
+
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; }
|
|
47
|
+
|
|
48
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
49
|
+
|
|
50
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
51
|
+
|
|
52
|
+
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); }
|
|
53
|
+
|
|
54
|
+
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; }
|
|
55
|
+
|
|
56
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
57
|
+
|
|
58
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
59
|
+
|
|
60
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
61
|
+
|
|
62
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
63
|
+
|
|
64
|
+
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; }
|
|
65
|
+
|
|
66
|
+
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
67
|
+
|
|
68
|
+
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); } }
|
|
69
|
+
|
|
70
|
+
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); }); }; }
|
|
71
|
+
|
|
72
|
+
var TitleModal = function TitleModal(props) {
|
|
73
|
+
var rootElement = (0, _appendToBody.default)('TitleModalContainer');
|
|
74
|
+
var Container = document.createElement('div');
|
|
75
|
+
rootElement.appendChild(Container);
|
|
76
|
+
|
|
77
|
+
var handleClose = /*#__PURE__*/function () {
|
|
78
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
79
|
+
var dismiss,
|
|
80
|
+
_args = arguments;
|
|
81
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
82
|
+
while (1) {
|
|
83
|
+
switch (_context.prev = _context.next) {
|
|
84
|
+
case 0:
|
|
85
|
+
dismiss = _args.length > 0 && _args[0] !== undefined ? _args[0] : false;
|
|
86
|
+
|
|
87
|
+
if (!props.onBeforeClose) {
|
|
88
|
+
_context.next = 10;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
_context.prev = 2;
|
|
93
|
+
_context.next = 5;
|
|
94
|
+
return props.onBeforeClose(dismiss);
|
|
95
|
+
|
|
96
|
+
case 5:
|
|
97
|
+
_context.next = 10;
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
case 7:
|
|
101
|
+
_context.prev = 7;
|
|
102
|
+
_context.t0 = _context["catch"](2);
|
|
103
|
+
return _context.abrupt("return");
|
|
104
|
+
|
|
105
|
+
case 10:
|
|
106
|
+
// unmount component and clear event handler and state before remove container
|
|
107
|
+
(0, _reactDom.unmountComponentAtNode)(Container);
|
|
108
|
+
Container.remove();
|
|
109
|
+
|
|
110
|
+
if (props.onClose) {
|
|
111
|
+
props.onClose(dismiss);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
case 13:
|
|
115
|
+
case "end":
|
|
116
|
+
return _context.stop();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}, _callee, null, [[2, 7]]);
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
return function handleClose() {
|
|
123
|
+
return _ref.apply(this, arguments);
|
|
124
|
+
};
|
|
125
|
+
}();
|
|
126
|
+
|
|
127
|
+
var methods = {
|
|
128
|
+
close: handleClose
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
_reactDom.default.render( /*#__PURE__*/(0, _jsxRuntime.jsx)(ModalContent, _objectSpread(_objectSpread({}, props), {}, {
|
|
132
|
+
onClose: handleClose,
|
|
133
|
+
methods: methods
|
|
134
|
+
})), Container);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
var ModalContent = function ModalContent(_ref2) {
|
|
138
|
+
var children = _ref2.children,
|
|
139
|
+
onClose = _ref2.onClose,
|
|
140
|
+
methods = _ref2.methods,
|
|
141
|
+
size = _ref2.size;
|
|
142
|
+
var refWrapper = (0, _react.useRef)(null);
|
|
143
|
+
|
|
144
|
+
var _useState = (0, _react.useState)(null),
|
|
145
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
146
|
+
clickTarget = _useState2[0],
|
|
147
|
+
setClickTarget = _useState2[1];
|
|
148
|
+
|
|
149
|
+
var child = (0, _react.useMemo)(function () {
|
|
150
|
+
return (0, _isReactComponent.default)(children) ? /*#__PURE__*/(0, _react.cloneElement)(children, methods) : children;
|
|
151
|
+
}, [children, methods]);
|
|
152
|
+
|
|
153
|
+
var handleDismiss = function handleDismiss(dismiss) {
|
|
154
|
+
if (clickTarget === refWrapper.current) {
|
|
155
|
+
onClose(dismiss);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapper, {
|
|
160
|
+
ref: refWrapper,
|
|
161
|
+
onClick: function onClick() {
|
|
162
|
+
handleDismiss(true);
|
|
163
|
+
},
|
|
164
|
+
onMouseDown: function onMouseDown(e) {
|
|
165
|
+
setClickTarget(e.target);
|
|
166
|
+
},
|
|
167
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Container, {
|
|
168
|
+
size: size,
|
|
169
|
+
onMouseDown: function onMouseDown(e) {
|
|
170
|
+
setClickTarget(e.target);
|
|
171
|
+
},
|
|
172
|
+
children: child
|
|
173
|
+
})
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
var ModalHeader = function ModalHeader(_ref3) {
|
|
178
|
+
var handleClose = _ref3.handleClose,
|
|
179
|
+
children = _ref3.children;
|
|
180
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Header, {
|
|
181
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_md.MdClose, {
|
|
182
|
+
onClick: handleClose
|
|
183
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Heading.default, {
|
|
184
|
+
children: children
|
|
185
|
+
})]
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
var ModalBody = function ModalBody(_ref4) {
|
|
190
|
+
var children = _ref4.children,
|
|
191
|
+
props = _objectWithoutProperties(_ref4, _excluded);
|
|
192
|
+
|
|
193
|
+
var bodyRef = (0, _react.useRef)(null);
|
|
194
|
+
|
|
195
|
+
var recalculateHeight = function recalculateHeight() {
|
|
196
|
+
// body element not render yet
|
|
197
|
+
if (!bodyRef.current) return;
|
|
198
|
+
var ModalBodyElement = bodyRef.current;
|
|
199
|
+
var ModalHeaderElement = ModalBodyElement.previousSibling;
|
|
200
|
+
var ModalFooterElement = ModalBodyElement.nextSibling;
|
|
201
|
+
var needSubtractHeight = 0;
|
|
202
|
+
|
|
203
|
+
if (ModalHeaderElement) {
|
|
204
|
+
needSubtractHeight += ModalHeaderElement.offsetHeight;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (ModalFooterElement) {
|
|
208
|
+
needSubtractHeight += ModalFooterElement.offsetHeight;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
ModalBodyElement.style.maxHeight = "calc(90vh - ".concat(needSubtractHeight, "px)");
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
(0, _react.useEffect)(function () {
|
|
215
|
+
recalculateHeight();
|
|
216
|
+
window.addEventListener('resize', recalculateHeight);
|
|
217
|
+
return function () {
|
|
218
|
+
return window.removeEventListener('resize', recalculateHeight);
|
|
219
|
+
};
|
|
220
|
+
}, []);
|
|
221
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Body, _objectSpread(_objectSpread({
|
|
222
|
+
ref: bodyRef
|
|
223
|
+
}, props), {}, {
|
|
224
|
+
children: children
|
|
225
|
+
}));
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
var ModalFooter = function ModalFooter(_ref5) {
|
|
229
|
+
var children = _ref5.children;
|
|
230
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Footer, {
|
|
231
|
+
children: children
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
var Wrapper = (0, _styledComponents.default)(_ModalBackdrop.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n z-index: 80;\n"])));
|
|
236
|
+
|
|
237
|
+
var Container = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n border-radius: var(--border-radius);\n background: var(--color-background2);\n box-shadow: var(--box-shadow);\n border: var(--border-width) solid var(--border-color);\n width: 100%;\n\n ", "\n\n ", "\n\n ", "\n"])), function (_ref6) {
|
|
238
|
+
var size = _ref6.size;
|
|
239
|
+
|
|
240
|
+
switch (size) {
|
|
241
|
+
case 'large':
|
|
242
|
+
return 'max-width: 75%;';
|
|
243
|
+
|
|
244
|
+
case 'normal':
|
|
245
|
+
return 'max-width: 50%;';
|
|
246
|
+
|
|
247
|
+
case 'small':
|
|
248
|
+
return 'max-width: 30%;';
|
|
249
|
+
|
|
250
|
+
default:
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}, _media.default.tablet(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", "\n "])), function (_ref7) {
|
|
254
|
+
var size = _ref7.size;
|
|
255
|
+
|
|
256
|
+
switch (size) {
|
|
257
|
+
case 'large':
|
|
258
|
+
return 'max-width: 90%;';
|
|
259
|
+
|
|
260
|
+
case 'normal':
|
|
261
|
+
return 'max-width: 75%;';
|
|
262
|
+
|
|
263
|
+
case 'small':
|
|
264
|
+
return 'max-width: 50%;';
|
|
265
|
+
|
|
266
|
+
default:
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
}), _media.default.mobile(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n "])), function (_ref8) {
|
|
270
|
+
var size = _ref8.size;
|
|
271
|
+
|
|
272
|
+
switch (size) {
|
|
273
|
+
case 'normal':
|
|
274
|
+
return 'max-width: 90%;';
|
|
275
|
+
|
|
276
|
+
case 'small':
|
|
277
|
+
return 'max-width: 70%;';
|
|
278
|
+
|
|
279
|
+
default:
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
}));
|
|
283
|
+
|
|
284
|
+
var Header = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n padding: var(--spacing-s) 56px var(--spacing-s) var(--spacing-s);\n border-bottom: var(--border-width) solid var(--border-color);\n min-height: 64px;\n color: var(--font-on-primary);\n\n > svg {\n position: absolute;\n top: 24px;\n right: calc(12px + var(--spacing));\n color: var(--font-on-mute);\n font-size: var(--font-body1);\n cursor: pointer;\n }\n"])));
|
|
285
|
+
|
|
286
|
+
var Body = _styledComponents.default.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n padding: var(--spacing);\n overflow-y: auto;\n overflow-x: hidden;\n\n ", "\n\n ", "\n"])), _scrollbar.default, function (_ref9) {
|
|
287
|
+
var noPaddingBottom = _ref9.noPaddingBottom;
|
|
288
|
+
return noPaddingBottom && 'padding-bottom: 0;';
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
var Footer = _styledComponents.default.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: flex-end;\n padding: 0 var(--spacing);\n border-top: var(--border-width) solid var(--border-color);\n height: 64px;\n line-height: 64px;\n"])));
|
|
292
|
+
|
|
293
|
+
var _default = Object.assign(TitleModal, {
|
|
294
|
+
Header: ModalHeader,
|
|
295
|
+
Body: ModalBody,
|
|
296
|
+
Footer: ModalFooter
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var breakpoints = {
|
|
8
|
+
desktop: 1920,
|
|
9
|
+
laptop: 1200,
|
|
10
|
+
tablet: 768,
|
|
11
|
+
mobile: 576
|
|
12
|
+
};
|
|
13
|
+
var _default = breakpoints;
|
|
14
|
+
exports.default = _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = require("styled-components");
|
|
9
|
+
|
|
10
|
+
var _templateObject;
|
|
11
|
+
|
|
12
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
13
|
+
|
|
14
|
+
var backgroundColor = (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n\n ", "\n\n ", "\n\n ", "\n"])), function (_ref) {
|
|
15
|
+
var primary = _ref.primary;
|
|
16
|
+
return primary && 'background-color: var(--color-primary);';
|
|
17
|
+
}, function (_ref2) {
|
|
18
|
+
var success = _ref2.success;
|
|
19
|
+
return success && 'background-color: var(--color-success);';
|
|
20
|
+
}, function (_ref3) {
|
|
21
|
+
var warning = _ref3.warning;
|
|
22
|
+
return warning && 'background-color: var(--color-warning);';
|
|
23
|
+
}, function (_ref4) {
|
|
24
|
+
var danger = _ref4.danger;
|
|
25
|
+
return danger && 'background-color: var(--color-danger);';
|
|
26
|
+
});
|
|
27
|
+
var _default = backgroundColor;
|
|
28
|
+
exports.default = _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = require("styled-components");
|
|
9
|
+
|
|
10
|
+
var _templateObject;
|
|
11
|
+
|
|
12
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
13
|
+
|
|
14
|
+
var borderColor = (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n\n ", "\n\n ", "\n\n ", "\n"])), function (_ref) {
|
|
15
|
+
var primary = _ref.primary;
|
|
16
|
+
return primary && 'border-color: var(--color-primary);';
|
|
17
|
+
}, function (_ref2) {
|
|
18
|
+
var success = _ref2.success;
|
|
19
|
+
return success && 'border-color: var(--color-success);';
|
|
20
|
+
}, function (_ref3) {
|
|
21
|
+
var warning = _ref3.warning;
|
|
22
|
+
return warning && 'border-color: var(--color-warning);';
|
|
23
|
+
}, function (_ref4) {
|
|
24
|
+
var danger = _ref4.danger;
|
|
25
|
+
return danger && 'border-color: var(--color-danger);';
|
|
26
|
+
});
|
|
27
|
+
var _default = borderColor;
|
|
28
|
+
exports.default = _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = require("styled-components");
|
|
9
|
+
|
|
10
|
+
var _templateObject;
|
|
11
|
+
|
|
12
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
13
|
+
|
|
14
|
+
var color = (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n\n ", "\n\n ", "\n\n ", "\n"])), function (_ref) {
|
|
15
|
+
var primary = _ref.primary;
|
|
16
|
+
return primary && 'color: var(--color-primary);';
|
|
17
|
+
}, function (_ref2) {
|
|
18
|
+
var success = _ref2.success;
|
|
19
|
+
return success && 'color: var(--color-success);';
|
|
20
|
+
}, function (_ref3) {
|
|
21
|
+
var warning = _ref3.warning;
|
|
22
|
+
return warning && 'color: var(--color-warning);';
|
|
23
|
+
}, function (_ref4) {
|
|
24
|
+
var danger = _ref4.danger;
|
|
25
|
+
return danger && 'color: var(--color-danger);';
|
|
26
|
+
});
|
|
27
|
+
var _default = color;
|
|
28
|
+
exports.default = _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = require("styled-components");
|
|
9
|
+
|
|
10
|
+
var _templateObject;
|
|
11
|
+
|
|
12
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
13
|
+
|
|
14
|
+
var colorOnBackground = (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n\n ", "\n\n ", "\n\n ", "\n"])), function (_ref) {
|
|
15
|
+
var primary = _ref.primary;
|
|
16
|
+
return primary && 'color: var(--font-on-primary);';
|
|
17
|
+
}, function (_ref2) {
|
|
18
|
+
var success = _ref2.success;
|
|
19
|
+
return success && 'color: var(--font-on-success);';
|
|
20
|
+
}, function (_ref3) {
|
|
21
|
+
var warning = _ref3.warning;
|
|
22
|
+
return warning && 'color: var(--font-on-danger);';
|
|
23
|
+
}, function (_ref4) {
|
|
24
|
+
var danger = _ref4.danger;
|
|
25
|
+
return danger && 'color: var(--font-on-warning);';
|
|
26
|
+
});
|
|
27
|
+
var _default = colorOnBackground;
|
|
28
|
+
exports.default = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = require("styled-components");
|
|
9
|
+
|
|
10
|
+
var _templateObject;
|
|
11
|
+
|
|
12
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
13
|
+
|
|
14
|
+
var inputPlaceholder = function inputPlaceholder() {
|
|
15
|
+
return (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ::placeholder {\n ", "\n }\n\n ::-moz-placeholder {\n ", "\n opacity: 1;\n }\n\n // Internet Explorer 10+\n :-ms-input-placeholder {\n ", "\n }\n\n // Safari and Chrome\n ::-webkit-input-placeholder {\n ", "\n }\n "])), _styledComponents.css.apply(void 0, arguments), _styledComponents.css.apply(void 0, arguments), _styledComponents.css.apply(void 0, arguments), _styledComponents.css.apply(void 0, arguments));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
var _default = inputPlaceholder;
|
|
19
|
+
exports.default = _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = require("styled-components");
|
|
9
|
+
|
|
10
|
+
var _breakpoint = _interopRequireDefault(require("../breakpoint.style"));
|
|
11
|
+
|
|
12
|
+
var _templateObject;
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
17
|
+
|
|
18
|
+
// Iterate through the breakpoint and create a media template
|
|
19
|
+
var media = Object.keys(_breakpoint.default).reduce(function (func, label) {
|
|
20
|
+
func[label] = function () {
|
|
21
|
+
return (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n @media (max-width: ", "px) {\n ", "\n }\n "])), _breakpoint.default[label], _styledComponents.css.apply(void 0, arguments));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return func;
|
|
25
|
+
}, {});
|
|
26
|
+
var _default = media;
|
|
27
|
+
exports.default = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = require("styled-components");
|
|
9
|
+
|
|
10
|
+
var _templateObject;
|
|
11
|
+
|
|
12
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
13
|
+
|
|
14
|
+
var scrollbar = function scrollbar() {
|
|
15
|
+
return (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &::-webkit-scrollbar {\n width: 12px;\n }\n\n &::-webkit-scrollbar-thumb {\n background-color: var(--color-scroll-bar);\n background-clip: padding-box;\n border: 4px solid transparent;\n border-radius: var(--border-radius);\n }\n "])));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
var _default = scrollbar;
|
|
19
|
+
exports.default = _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var appendToBody = function appendToBody(id) {
|
|
9
|
+
var result = document.getElementById(id);
|
|
10
|
+
|
|
11
|
+
if (!result) {
|
|
12
|
+
result = document.createElement('div');
|
|
13
|
+
result.setAttribute('id', id);
|
|
14
|
+
document.body.appendChild(result);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var _default = appendToBody;
|
|
21
|
+
exports.default = _default;
|