@ccs-ui/rc-pro 1.0.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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/es/auth/auth-button.js +59 -0
  4. package/es/auth/auth-dropdown.js +67 -0
  5. package/es/auth/index.js +164 -0
  6. package/es/ccs.js +82 -0
  7. package/es/color-picker/index.js +63 -0
  8. package/es/color-picker/index.less +9 -0
  9. package/es/config.js +11 -0
  10. package/es/context/index.js +11 -0
  11. package/es/date-picker/index.js +59 -0
  12. package/es/drawer/buttons.js +93 -0
  13. package/es/drawer/index.js +8 -0
  14. package/es/drawer/index.less +5 -0
  15. package/es/drawer/open/content.js +43 -0
  16. package/es/drawer/open/destory-fns.js +3 -0
  17. package/es/drawer/open/form.js +32 -0
  18. package/es/drawer/open/index.js +171 -0
  19. package/es/full-screen/index.js +57 -0
  20. package/es/hooks/use-event.js +67 -0
  21. package/es/hooks/use-global.js +10 -0
  22. package/es/hooks/use-once-event.js +16 -0
  23. package/es/hooks/use-page.js +10 -0
  24. package/es/hooks/use-tabs.js +10 -0
  25. package/es/hooks/use-window.js +10 -0
  26. package/es/index.js +27 -0
  27. package/es/interval-button/index.js +118 -0
  28. package/es/keep-alive-tabs/index.js +250 -0
  29. package/es/keep-alive-tabs/index.less +23 -0
  30. package/es/keep-alive-tabs/page.js +37 -0
  31. package/es/loading/index.js +27 -0
  32. package/es/modal/buttons.js +90 -0
  33. package/es/modal/index.js +8 -0
  34. package/es/modal/index.less +25 -0
  35. package/es/modal/open/destory-fns.js +3 -0
  36. package/es/modal/open/drag.js +104 -0
  37. package/es/modal/open/form.js +35 -0
  38. package/es/modal/open/index.js +93 -0
  39. package/es/pro-grid/context.js +4 -0
  40. package/es/pro-grid/index.js +88 -0
  41. package/es/pro-grid/index.less +29 -0
  42. package/es/pro-grid/useProGrid.js +10 -0
  43. package/es/pro-table/index.js +578 -0
  44. package/es/pro-table/index.less +165 -0
  45. package/es/pro-table/search.js +399 -0
  46. package/es/pro-tabs/index.js +77 -0
  47. package/es/pro-tabs/index.less +5 -0
  48. package/es/select/index.js +72 -0
  49. package/es/table/index.js +173 -0
  50. package/es/table/index.less +117 -0
  51. package/es/trigger/index.js +288 -0
  52. package/es/trigger/index.less +42 -0
  53. package/es/types.js +0 -0
  54. package/es/utils.js +205 -0
  55. package/es/virtual-list/index.js +125 -0
  56. package/es/water-mark/index.js +135 -0
  57. package/package.json +102 -0
@@ -0,0 +1,118 @@
1
+ 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); }
2
+ var _excluded = ["num", "cacheKey", "disabledText", "children"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ 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, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $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 defineProperty(generator, "_invoke", { value: makeInvokeMethod(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; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(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); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), 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, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), 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 (val) { var object = Object(val), 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; }
5
+ 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); } }
6
+ 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); }); }; }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ 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."); }
9
+ 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); }
10
+ 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; }
11
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ 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; }
14
+ 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; }
15
+ import { useInterval } from 'ahooks';
16
+ import { Button } from 'antd';
17
+ import React, { forwardRef, useImperativeHandle, useLayoutEffect, useState } from 'react';
18
+ import { CcsUtils } from "../";
19
+ /**
20
+ * 倒计时按钮组件
21
+ * @param PropsType
22
+ * @param IntervalInstance
23
+ * @returns
24
+ */
25
+ var IntervalButton = function IntervalButton(_ref, ref) {
26
+ var num = _ref.num,
27
+ cacheKey = _ref.cacheKey,
28
+ disabledText = _ref.disabledText,
29
+ children = _ref.children,
30
+ restProps = _objectWithoutProperties(_ref, _excluded);
31
+ var _useState = useState(-1),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ count = _useState2[0],
34
+ setCount = _useState2[1];
35
+ var _useState3 = useState(null),
36
+ _useState4 = _slicedToArray(_useState3, 2),
37
+ codeInterval = _useState4[0],
38
+ setCodeInterval = _useState4[1];
39
+
40
+ // 判断是否有未完成的倒计时
41
+ useLayoutEffect(function () {
42
+ var initNum = /*#__PURE__*/function () {
43
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
44
+ var s, currentTime, time;
45
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
46
+ while (1) switch (_context.prev = _context.next) {
47
+ case 0:
48
+ if (!cacheKey) {
49
+ _context.next = 11;
50
+ break;
51
+ }
52
+ _context.next = 3;
53
+ return CcsUtils.getStroage(cacheKey);
54
+ case 3:
55
+ s = _context.sent;
56
+ if (!s) {
57
+ _context.next = 11;
58
+ break;
59
+ }
60
+ currentTime = new Date().getTime();
61
+ time = Math.round((currentTime - s.time) / 1000);
62
+ if (!(time < s.num)) {
63
+ _context.next = 11;
64
+ break;
65
+ }
66
+ setCount(s.num - time);
67
+ setCodeInterval(1000);
68
+ return _context.abrupt("return");
69
+ case 11:
70
+ setCount(num);
71
+ case 12:
72
+ case "end":
73
+ return _context.stop();
74
+ }
75
+ }, _callee);
76
+ }));
77
+ return function initNum() {
78
+ return _ref2.apply(this, arguments);
79
+ };
80
+ }();
81
+ initNum();
82
+ }, []);
83
+
84
+ // ahooks useInterval
85
+ useInterval(function () {
86
+ if (count - 1 === 0) {
87
+ setCodeInterval(null);
88
+ setCount(num);
89
+ if (cacheKey) CcsUtils.removeStroage(cacheKey);
90
+ return;
91
+ }
92
+ setCount(count - 1);
93
+ }, codeInterval, {
94
+ immediate: true
95
+ });
96
+
97
+ // ref start interval
98
+ useImperativeHandle(ref, function () {
99
+ return {
100
+ start: function start() {
101
+ setCodeInterval(1000);
102
+ if (cacheKey) {
103
+ CcsUtils.setStroage(cacheKey, {
104
+ num: num,
105
+ time: new Date().getTime()
106
+ });
107
+ }
108
+ }
109
+ };
110
+ });
111
+ var disabled = count !== 0 && count !== num;
112
+ return count === -1 ? null : /*#__PURE__*/React.createElement(Button, _extends({
113
+ type: "primary"
114
+ }, restProps, {
115
+ disabled: disabled
116
+ }), disabled ? disabledText.replace('num', count) : "".concat(children));
117
+ };
118
+ export default /*#__PURE__*/forwardRef(IntervalButton);
@@ -0,0 +1,250 @@
1
+ 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); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ 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."); }
4
+ 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); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ 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; }
8
+ 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, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $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 defineProperty(generator, "_invoke", { value: makeInvokeMethod(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; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(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); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), 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, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), 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 (val) { var object = Object(val), 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; }
9
+ 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); } }
10
+ 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); }); }; }
11
+ import { MoreOutlined } from '@ant-design/icons';
12
+ import { useUpdate, useUpdateEffect } from 'ahooks';
13
+ import { Button, Dropdown, Empty, Tabs } from 'antd';
14
+ import classnames from 'classnames';
15
+ import _debounce from 'lodash/debounce';
16
+ import ResizeObserver from 'rc-resize-observer';
17
+ import React, { useEffect, useMemo, useRef } from 'react';
18
+ import { useLocation } from 'react-router';
19
+ import { useOutlet } from 'react-router-dom';
20
+ import { CCS, CcsUtils } from "../";
21
+ import "./index.less";
22
+ import Page from "./page";
23
+ var extraItems = [{
24
+ key: '1',
25
+ label: '关闭其他标签'
26
+ }, {
27
+ key: '2',
28
+ label: '关闭所有标签'
29
+ }];
30
+ var RouteHistorys = [];
31
+ export default (function (_ref) {
32
+ var _ref$maxLen = _ref.maxLen,
33
+ maxLen = _ref$maxLen === void 0 ? 10 : _ref$maxLen,
34
+ history = _ref.history,
35
+ _ref$menus = _ref.menus,
36
+ menus = _ref$menus === void 0 ? [] : _ref$menus,
37
+ className = _ref.className;
38
+ var components = useRef([]);
39
+ var location = useLocation();
40
+ var pathname = location.pathname,
41
+ locationKey = location.key;
42
+ var outlet = useOutlet();
43
+ var update = useUpdate();
44
+ var _CCS$GlobalConfig = CCS.GlobalConfig,
45
+ classPrefix = _CCS$GlobalConfig.classPrefix,
46
+ AppName = _CCS$GlobalConfig.AppName;
47
+
48
+ // 超过缓存数量,删除第一个
49
+ if (components.current.length >= maxLen) {
50
+ components.current = components.current.slice(1);
51
+ }
52
+
53
+ // 菜单改变,更新用户权限信息
54
+ useUpdateEffect(function () {
55
+ components.current.forEach(function (component) {
56
+ var _menu$children;
57
+ var menu = menus.find(function (m) {
58
+ return m.nodeData.menuUrl === component.key;
59
+ });
60
+ component.urlAuthList = (menu === null || menu === void 0 ? void 0 : (_menu$children = menu.children) === null || _menu$children === void 0 ? void 0 : _menu$children.map(function (m) {
61
+ return m.nodeData.menuUrl;
62
+ })) || [];
63
+ component.timestamp = new Date().getTime();
64
+ });
65
+ update();
66
+ }, [menus]);
67
+
68
+ // 当前菜单
69
+ var curMenu = useMemo(function () {
70
+ var menu = menus.find(function (m) {
71
+ var menuUrl = m.nodeData.menuUrl;
72
+ if (menuUrl.includes('?')) {
73
+ return menuUrl.split('?')[0] === pathname;
74
+ }
75
+ return menuUrl === pathname;
76
+ });
77
+
78
+ // add document title
79
+ setTimeout(function () {
80
+ document.title = "".concat(AppName, " - ").concat((menu === null || menu === void 0 ? void 0 : menu.nodeName) || (menu === null || menu === void 0 ? void 0 : menu.nodeData.menuUrl));
81
+ }, 10);
82
+
83
+ // save history route
84
+ var saveHistory = /*#__PURE__*/function () {
85
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
86
+ var index;
87
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
88
+ while (1) switch (_context.prev = _context.next) {
89
+ case 0:
90
+ if (RouteHistorys.length) {
91
+ _context.next = 7;
92
+ break;
93
+ }
94
+ _context.next = 3;
95
+ return CcsUtils.getStroage('_ROUTE_HISTORY');
96
+ case 3:
97
+ _context.t0 = _context.sent;
98
+ if (_context.t0) {
99
+ _context.next = 6;
100
+ break;
101
+ }
102
+ _context.t0 = [];
103
+ case 6:
104
+ RouteHistorys = _context.t0;
105
+ case 7:
106
+ index = RouteHistorys.findIndex(function (h) {
107
+ return h.pathName === pathname;
108
+ });
109
+ if (index > -1) {
110
+ RouteHistorys.splice(index, 1);
111
+ }
112
+ RouteHistorys.unshift({
113
+ pathName: pathname,
114
+ menuName: (menu === null || menu === void 0 ? void 0 : menu.nodeData.menuName) || '',
115
+ time: new Date()
116
+ });
117
+ CcsUtils.setStroage('_ROUTE_HISTORY', RouteHistorys);
118
+ case 11:
119
+ case "end":
120
+ return _context.stop();
121
+ }
122
+ }, _callee);
123
+ }));
124
+ return function saveHistory() {
125
+ return _ref2.apply(this, arguments);
126
+ };
127
+ }();
128
+ if (menu) saveHistory();
129
+ return menu;
130
+ }, [pathname]);
131
+ var component = components.current.find(function (c) {
132
+ return c.key === pathname;
133
+ });
134
+ if (!component) {
135
+ var _curMenu$children;
136
+ var urlAuthList = (curMenu === null || curMenu === void 0 ? void 0 : (_curMenu$children = curMenu.children) === null || _curMenu$children === void 0 ? void 0 : _curMenu$children.map(function (m) {
137
+ return m.nodeData.menuUrl;
138
+ })) || [];
139
+ components.current = [].concat(_toConsumableArray(components.current), [{
140
+ locationKey: locationKey,
141
+ key: pathname,
142
+ timestamp: new Date().getTime(),
143
+ label: curMenu ? curMenu.nodeName : '未知',
144
+ outlet: curMenu ? outlet : /*#__PURE__*/React.createElement(Empty, {
145
+ description: "\u672A\u77E5\u9875\u9762"
146
+ }),
147
+ urlAuthList: urlAuthList
148
+ }]);
149
+
150
+ // button auth
151
+ CCS.setAuthList(locationKey, urlAuthList);
152
+ }
153
+
154
+ // 页面主动销毁或关闭tab
155
+ var onDestroy = function onDestroy(path) {
156
+ var index = components.current.findIndex(function (c) {
157
+ return c.key === path;
158
+ });
159
+ if (index >= 0) {
160
+ components.current.splice(index, 1);
161
+ components.current = _toConsumableArray(components.current);
162
+ if (path !== pathname) {
163
+ update();
164
+ return;
165
+ }
166
+
167
+ // 显示首页
168
+ if (components.current.length === 0) {
169
+ history.push('/');
170
+ return;
171
+ }
172
+
173
+ // 显示前一个
174
+ if (index === components.current.length) {
175
+ history.push(components.current[index - 1].key);
176
+ return;
177
+ }
178
+
179
+ // 显示后一个
180
+ history.push(components.current[index].key);
181
+ }
182
+ };
183
+ var onCloseTab = function onCloseTab(key) {
184
+ // 关闭其他标签
185
+ if (key === '1') {
186
+ components.current = components.current.filter(function (c) {
187
+ return c.key === pathname;
188
+ });
189
+ update();
190
+ } else {
191
+ components.current = [];
192
+ history.push('/');
193
+ }
194
+ };
195
+ var tabBarExtraContent = /*#__PURE__*/React.createElement(Dropdown, {
196
+ menu: {
197
+ items: extraItems,
198
+ onClick: function onClick(e) {
199
+ onCloseTab(e.key);
200
+ }
201
+ },
202
+ placement: "bottomRight"
203
+ }, /*#__PURE__*/React.createElement(Button, {
204
+ icon: /*#__PURE__*/React.createElement(MoreOutlined, null),
205
+ type: "text"
206
+ }));
207
+ var tabRef = useRef();
208
+ var resizeFn = _debounce(function (width) {
209
+ if (tabRef.current) tabRef.current.style.maxWidth = "".concat(width, "px");
210
+ }, 200);
211
+ useEffect(function () {
212
+ tabRef.current = document.getElementById('keep-alive-tabs');
213
+ });
214
+ var onResize = function onResize(size) {
215
+ resizeFn(size.width);
216
+ };
217
+ return /*#__PURE__*/React.createElement("div", {
218
+ className: classnames(className, "".concat(classPrefix, "-keep-alive"))
219
+ }, /*#__PURE__*/React.createElement(ResizeObserver, {
220
+ onResize: onResize
221
+ }, /*#__PURE__*/React.createElement("div", null)), /*#__PURE__*/React.createElement(Tabs, {
222
+ id: "keep-alive-tabs",
223
+ hideAdd: true,
224
+ size: "small",
225
+ onChange: function onChange(e) {
226
+ history.push(e);
227
+ },
228
+ className: "".concat(classPrefix, "-keep-alive-tabs"),
229
+ activeKey: pathname,
230
+ type: "editable-card",
231
+ onEdit: function onEdit(e) {
232
+ return onDestroy(e);
233
+ },
234
+ items: components.current,
235
+ tabBarExtraContent: components.current.length > 2 ? tabBarExtraContent : null
236
+ }), components.current.map(function (_ref3) {
237
+ var key = _ref3.key,
238
+ urlAuthList = _ref3.urlAuthList,
239
+ timestamp = _ref3.timestamp,
240
+ outlet = _ref3.outlet;
241
+ return /*#__PURE__*/React.createElement(Page, {
242
+ key: key,
243
+ active: key === pathname,
244
+ location: location,
245
+ onDestroy: onDestroy,
246
+ urlAuthList: urlAuthList,
247
+ timestamp: timestamp
248
+ }, outlet);
249
+ }));
250
+ });
@@ -0,0 +1,23 @@
1
+ .ccs-keep-alive {
2
+ flex: 1 1 auto;
3
+ background: #f0f2f5;
4
+ display: flex;
5
+ flex-direction: column;
6
+
7
+ &-tabs {
8
+ background: rgb(240 242 245);
9
+
10
+ & > .ant-tabs-nav {
11
+ margin: 0;
12
+
13
+ &::before {
14
+ border-bottom: 0;
15
+ }
16
+
17
+ .ant-tabs-tab {
18
+ border: 0;
19
+ border-radius: 0 !important;
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,37 @@
1
+ import React, { memo, useRef } from 'react';
2
+ import Scrollbars from 'react-custom-scrollbars';
3
+ import { PageContext } from "../context";
4
+ export default /*#__PURE__*/memo(function (props) {
5
+ var locationRef = useRef(props.location);
6
+ var children = props.children,
7
+ active = props.active,
8
+ urlAuthList = props.urlAuthList,
9
+ onDestroy = props.onDestroy;
10
+ var id = "_tab_content_".concat(locationRef.current.key);
11
+ return /*#__PURE__*/React.createElement(PageContext.Provider, {
12
+ value: {
13
+ id: id,
14
+ isActive: active,
15
+ location: locationRef.current,
16
+ onDestroy: onDestroy,
17
+ onAuth: function onAuth(e) {
18
+ return urlAuthList.includes(e);
19
+ }
20
+ }
21
+ }, /*#__PURE__*/React.createElement("div", {
22
+ style: {
23
+ flex: '1 1 auto',
24
+ display: active ? 'block' : 'none',
25
+ position: 'relative'
26
+ },
27
+ id: id,
28
+ "data-display": active
29
+ }, /*#__PURE__*/React.createElement(Scrollbars, {
30
+ style: {
31
+ display: active ? 'block' : 'none'
32
+ },
33
+ autoHide: true
34
+ }, children)));
35
+ }, function (l, n) {
36
+ return l.active === n.active && l.timestamp === n.timestamp;
37
+ });
@@ -0,0 +1,27 @@
1
+ import { Spin } from 'antd';
2
+ import React from 'react';
3
+ var LoadingComponent = function LoadingComponent(_ref) {
4
+ var loading = _ref.loading,
5
+ _ref$loadingTip = _ref.loadingTip,
6
+ loadingTip = _ref$loadingTip === void 0 ? '加载中...' : _ref$loadingTip,
7
+ children = _ref.children;
8
+ return loading ? /*#__PURE__*/React.createElement("div", {
9
+ style: {
10
+ position: 'absolute',
11
+ inset: 0,
12
+ background: 'rgba(0, 0, 0, 0.1)',
13
+ zIndex: 1000
14
+ }
15
+ }, /*#__PURE__*/React.createElement("div", {
16
+ style: {
17
+ top: '50%',
18
+ left: ' 50%',
19
+ color: '#fff',
20
+ transform: 'translate(-50%, -50%)',
21
+ position: 'absolute'
22
+ }
23
+ }, children || /*#__PURE__*/React.createElement(Spin, {
24
+ tip: loadingTip
25
+ }))) : null;
26
+ };
27
+ export default LoadingComponent;
@@ -0,0 +1,90 @@
1
+ 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); }
2
+ 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ import { Button, Form, Space } from 'antd';
8
+ import _memoize from 'lodash/memoize';
9
+ import { render as reactRender } from 'rc-util/lib/React/render';
10
+ import React, { useEffect, useRef } from 'react';
11
+ import { CcsAuth } from '..';
12
+ import { useCcsWindow } from "../";
13
+ import { FnContext } from "../drawer/open/content";
14
+ var onGetModalBodyDom = _memoize(function (dom) {
15
+ var _parent$classList;
16
+ var parent = dom === null || dom === void 0 ? void 0 : dom.parentNode;
17
+ if (!parent) return;
18
+ if ((_parent$classList = parent.classList) !== null && _parent$classList !== void 0 && _parent$classList.contains("ant-modal-content")) {
19
+ return parent;
20
+ } else {
21
+ return onGetModalBodyDom(parent);
22
+ }
23
+ });
24
+ export default function ModalButtons(_ref) {
25
+ var children = _ref.children,
26
+ okText = _ref.okText,
27
+ okAuth = _ref.okAuth,
28
+ onOk = _ref.onOk,
29
+ loading = _ref.loading;
30
+ var _useCcsWindow = useCcsWindow(),
31
+ close = _useCcsWindow.close,
32
+ formInitialValues = _useCcsWindow.formInitialValues,
33
+ locationKey = _useCcsWindow.locationKey;
34
+ var form = Form.useFormInstance();
35
+ var ref = useRef(null);
36
+ var onOkClick = function onOkClick() {
37
+ if (!onOk) return;
38
+
39
+ // form返回表单值和所有初始值
40
+ if (form) {
41
+ form.validateFields().then(function (values) {
42
+ onOk(_objectSpread(_objectSpread({}, formInitialValues), values));
43
+ });
44
+ return;
45
+ }
46
+ onOk();
47
+ };
48
+ var renderDefaultButtom = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
49
+ onClick: close
50
+ }, "\u53D6\u6D88"), okAuth ? /*#__PURE__*/React.createElement(CcsAuth.Button, {
51
+ auth: okAuth,
52
+ type: "primary",
53
+ onClick: onOkClick,
54
+ loading: loading
55
+ }, okText || '确定') : /*#__PURE__*/React.createElement(Button, {
56
+ type: "primary",
57
+ onClick: onOkClick,
58
+ loading: loading
59
+ }, okText || '确定'));
60
+ var timeoutId;
61
+ var onRenderButton = function onRenderButton() {
62
+ if (!onOk && !children) return;
63
+ if (!ref.current) return;
64
+
65
+ // get drawer body dom
66
+ var modalBody = onGetModalBodyDom(ref.current);
67
+
68
+ // add footer
69
+ clearTimeout(timeoutId);
70
+ timeoutId = setTimeout(function () {
71
+ if (modalBody !== null && modalBody !== void 0 && modalBody.lastChild) {
72
+ reactRender( /*#__PURE__*/React.createElement(FnContext, {
73
+ locationKey: locationKey
74
+ }, /*#__PURE__*/React.createElement(Space, {
75
+ size: 16
76
+ }, children, renderDefaultButtom)), modalBody.lastChild);
77
+ }
78
+ });
79
+ };
80
+ useEffect(function () {
81
+ onRenderButton();
82
+ }, []);
83
+ onRenderButton();
84
+ return /*#__PURE__*/React.createElement("div", {
85
+ style: {
86
+ display: 'none'
87
+ },
88
+ ref: ref
89
+ });
90
+ }
@@ -0,0 +1,8 @@
1
+ /* eslint-disable @typescript-eslint/no-use-before-define */
2
+ import ModalButtons from "./buttons";
3
+ import "./index.less";
4
+ import ModalOpen from "./open";
5
+ var modal = {};
6
+ modal.open = ModalOpen;
7
+ modal.Buttons = ModalButtons;
8
+ export default modal;
@@ -0,0 +1,25 @@
1
+ .ccs-drag-modal {
2
+ .ant-modal-header {
3
+ .ant-modal-title div {
4
+ padding: 20px 24px 10px;
5
+ box-sizing: border-box;
6
+ }
7
+ margin-bottom: 0;
8
+ }
9
+
10
+ .ant-modal-content {
11
+ padding: 0;
12
+ }
13
+
14
+ .ant-modal-body {
15
+ padding: 0 24px;
16
+ }
17
+
18
+ .ant-modal-footer {
19
+ padding: 0 24px 20px;
20
+ }
21
+ }
22
+
23
+ .ccs-modal-buttons {
24
+ text-align: right;
25
+ }
@@ -0,0 +1,3 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-types
2
+ var destroyModalFns = [];
3
+ export default destroyModalFns;