@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,72 @@
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 = ["onQuery", "cache", "defaultParams"];
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 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; }
5
+ 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; }
6
+ 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; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ 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); }
9
+ 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; }
10
+ 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); } }
11
+ 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); }); }; }
12
+ 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; }
13
+ 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; }
14
+ import { useRequest } from 'ahooks';
15
+ import { Select } from 'antd';
16
+ import _isArray from 'lodash/isArray';
17
+ import React, { useEffect } from 'react';
18
+ /**
19
+ * 基于接口查询的select组件
20
+ * @param CcsSelectProps
21
+ * @returns
22
+ */
23
+ export default function CcsApiSelect(_ref) {
24
+ var onQuery = _ref.onQuery,
25
+ cache = _ref.cache,
26
+ _ref$defaultParams = _ref.defaultParams,
27
+ defaultParams = _ref$defaultParams === void 0 ? {} : _ref$defaultParams,
28
+ restProps = _objectWithoutProperties(_ref, _excluded);
29
+ var _useRequest = useRequest( /*#__PURE__*/function () {
30
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
31
+ var result;
32
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
33
+ while (1) switch (_context.prev = _context.next) {
34
+ case 0:
35
+ _context.next = 2;
36
+ return onQuery(params);
37
+ case 2:
38
+ result = _context.sent;
39
+ if (!(result !== null && result !== void 0 && result.success && result.data && _isArray(result.data))) {
40
+ _context.next = 5;
41
+ break;
42
+ }
43
+ return _context.abrupt("return", result.data);
44
+ case 5:
45
+ return _context.abrupt("return", []);
46
+ case 6:
47
+ case "end":
48
+ return _context.stop();
49
+ }
50
+ }, _callee);
51
+ }));
52
+ return function (_x) {
53
+ return _ref2.apply(this, arguments);
54
+ };
55
+ }(), _objectSpread({
56
+ manual: true
57
+ }, cache || {})),
58
+ loading = _useRequest.loading,
59
+ _useRequest$data = _useRequest.data,
60
+ data = _useRequest$data === void 0 ? [] : _useRequest$data,
61
+ run = _useRequest.run;
62
+ useEffect(function () {
63
+ if (onQuery) run(defaultParams);
64
+ }, []);
65
+ return /*#__PURE__*/React.createElement(Select, _extends({
66
+ options: data,
67
+ loading: loading,
68
+ style: {
69
+ width: '100%'
70
+ }
71
+ }, restProps));
72
+ }
@@ -0,0 +1,173 @@
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 = ["data", "style", "scroll", "event$", "rowKey", "columns", "pagination", "rowSelection", "className"];
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 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; }
5
+ 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; }
6
+ 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; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ 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); }
9
+ 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; }
10
+ 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; }
11
+ import { useDebounceFn, useEventListener, useUpdate } from 'ahooks';
12
+ import { Pagination, Table, Tooltip } from 'antd';
13
+ import classNames from 'classnames';
14
+ import React, { useEffect, useRef } from 'react';
15
+ import "./index.less";
16
+ var DEFAULT_PAGE = {
17
+ totalNum: 0,
18
+ result: [],
19
+ pageSize: 10,
20
+ pageNo: 1
21
+ };
22
+ var CustomTable = function CustomTable(props) {
23
+ var data = props.data,
24
+ style = props.style,
25
+ scroll = props.scroll,
26
+ event$ = props.event$,
27
+ rowKey = props.rowKey,
28
+ columns = props.columns,
29
+ pagination = props.pagination,
30
+ rowSelection = props.rowSelection,
31
+ _props$className = props.className,
32
+ className = _props$className === void 0 ? '' : _props$className,
33
+ restProps = _objectWithoutProperties(props, _excluded);
34
+
35
+ // 固定表头获取table可视高度
36
+ var ref = useRef(null);
37
+ var update = useUpdate();
38
+ var _ref = data || DEFAULT_PAGE,
39
+ totalNum = _ref.totalNum,
40
+ result = _ref.result,
41
+ pageNo = _ref.pageNo,
42
+ pageSize = _ref.pageSize;
43
+
44
+ // table 固定表头,内容滚动
45
+ var _useDebounceFn = useDebounceFn(function () {
46
+ if ((scroll === null || scroll === void 0 ? void 0 : scroll.y) === 'auto') {
47
+ var _ref$current, _ref$current2, _ref$current3, _ref$current4;
48
+ var _ref2 = (ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect()) || {
49
+ top: 0
50
+ },
51
+ top = _ref2.top;
52
+ var bodyHeight = document.body.clientHeight;
53
+ var theadHeight = 0;
54
+ var pageHeight = 0;
55
+ var thead = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.getElementsByClassName('ant-table-thead');
56
+ if (thead && thead.length > 0) {
57
+ theadHeight = thead[0].clientHeight;
58
+ }
59
+ var _pagination = (_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.getElementsByClassName('ant-pagination');
60
+ if (_pagination && _pagination.length > 0) {
61
+ pageHeight = _pagination[0].clientHeight;
62
+ }
63
+ var scrollHeight = bodyHeight - top - 16 - theadHeight - pageHeight;
64
+
65
+ // 固定tbody高度
66
+ var tbody = (_ref$current4 = ref.current) === null || _ref$current4 === void 0 ? void 0 : _ref$current4.getElementsByClassName('ant-table-body');
67
+ if (tbody && tbody.length > 0 && tbody[0].style) {
68
+ tbody[0].style.height = "".concat(scrollHeight, "px");
69
+ }
70
+ }
71
+ }, {
72
+ wait: 500,
73
+ leading: true
74
+ }),
75
+ onFixedThead = _useDebounceFn.run;
76
+ useEffect(function () {
77
+ onFixedThead();
78
+ }, [totalNum]);
79
+
80
+ // 监听窗口变化
81
+ useEventListener('resize', onFixedThead, {
82
+ target: window
83
+ });
84
+
85
+ // 监听列筛选事件
86
+ event$ === null || event$ === void 0 ? void 0 : event$.useSubscription(function (e) {
87
+ if (e.key === 'columnFilter') {
88
+ columns === null || columns === void 0 ? void 0 : columns.forEach(function (c) {
89
+ c.hidden = e.columnHiddenKeys.includes(c.dataIndex);
90
+ });
91
+ update();
92
+ }
93
+ if (e.key === 'fullScreen') {
94
+ onFixedThead();
95
+ }
96
+ });
97
+
98
+ // 列过滤
99
+ var filterColumns = function filterColumns() {
100
+ var cls = columns === null || columns === void 0 ? void 0 : columns.filter(function (t) {
101
+ return !t.hidden;
102
+ });
103
+ cls === null || cls === void 0 ? void 0 : cls.forEach(function (c) {
104
+ if (c.ellipsis && !c.render) {
105
+ var sc = c;
106
+ sc.ellipsis = {
107
+ showTitle: false
108
+ };
109
+ sc.render = function (e) {
110
+ return /*#__PURE__*/React.createElement(Tooltip, {
111
+ zIndex: 2020,
112
+ title: e,
113
+ placement: "bottomLeft",
114
+ destroyTooltipOnHide: true
115
+ }, e);
116
+ };
117
+ }
118
+ });
119
+ return cls;
120
+ };
121
+ return /*#__PURE__*/React.createElement("div", {
122
+ className: "ccs-table-card",
123
+ style: _objectSpread({}, style)
124
+ }, restProps.render ? /*#__PURE__*/React.createElement(React.Fragment, null, restProps.render(result || []), pagination === false ? null : /*#__PURE__*/React.createElement(Pagination, _objectSpread({
125
+ total: totalNum,
126
+ pageSize: pageSize,
127
+ size: restProps.size === 'small' ? 'small' : 'default',
128
+ simple: restProps.size === 'small',
129
+ current: pageNo,
130
+ showSizeChanger: true,
131
+ showQuickJumper: true,
132
+ showTotal: function showTotal() {
133
+ return "\u5171".concat(totalNum, "\u6761\u8BB0\u5F55");
134
+ },
135
+ pageSizeOptions: ['10', '20', '30', '50', '100'],
136
+ onChange: function onChange(page, size) {
137
+ return restProps.onChange && restProps.onChange({
138
+ pageSize: size,
139
+ current: page
140
+ }, {}, {}, {
141
+ currentDataSource: [],
142
+ action: 'paginate'
143
+ });
144
+ }
145
+ }, pagination))) : /*#__PURE__*/React.createElement(Table, _extends({}, _objectSpread(_objectSpread({
146
+ rowKey: rowKey,
147
+ dataSource: result,
148
+ pagination: pagination === false ? false : _objectSpread({
149
+ total: totalNum,
150
+ pageSize: pageSize,
151
+ current: pageNo,
152
+ showSizeChanger: true,
153
+ showQuickJumper: true,
154
+ showTotal: function showTotal() {
155
+ return "\u5171".concat(totalNum, "\u6761\u8BB0\u5F55");
156
+ },
157
+ pageSizeOptions: ['10', '20', '30', '50', '100'],
158
+ size: restProps.size === 'small' ? 'small' : 'default',
159
+ simple: restProps.size === 'small'
160
+ }, pagination),
161
+ rowSelection: rowSelection ? _objectSpread(_objectSpread({}, rowSelection), {}, {
162
+ columnWidth: 60
163
+ }) : undefined,
164
+ columns: filterColumns()
165
+ }, restProps), {}, {
166
+ size: restProps.size || 'middle',
167
+ className: classNames("".concat(!rowSelection ? 'ccs-table-noselection' : ''), !totalNum ? 'ccs-table-nodata' : '', className),
168
+ scroll: scroll
169
+ }), {
170
+ ref: ref
171
+ })));
172
+ };
173
+ export default CustomTable;
@@ -0,0 +1,117 @@
1
+ .ccs-table {
2
+ &-card {
3
+ .ant-table-container {
4
+ padding: 0 1px;
5
+ }
6
+
7
+ .ant-table-middle
8
+ > .ant-table-content
9
+ > .ant-table-body
10
+ > table
11
+ > .ant-table-tbody
12
+ > tr
13
+ > td,
14
+ .ant-table-middle
15
+ > .ant-table-content
16
+ > .ant-table-body
17
+ > table
18
+ > .ant-table-thead
19
+ > tr
20
+ > th,
21
+ .ant-table-middle
22
+ > .ant-table-content
23
+ > .ant-table-scroll
24
+ > .ant-table-body
25
+ > table
26
+ > .ant-table-tbody
27
+ > tr
28
+ > td,
29
+ .ant-table-middle
30
+ > .ant-table-content
31
+ > .ant-table-scroll
32
+ > .ant-table-body
33
+ > table
34
+ > .ant-table-thead
35
+ > tr
36
+ > th,
37
+ .ant-table-content
38
+ > .ant-table-fixed-right
39
+ > .ant-table-body-outer
40
+ > .ant-table-body-inner
41
+ > table
42
+ > .ant-table-tbody
43
+ > tr
44
+ > td,
45
+ .ant-table-middle
46
+ > .ant-table-content
47
+ > .ant-table-scroll
48
+ > .ant-table-header
49
+ > table
50
+ > .ant-table-thead
51
+ > tr
52
+ > th,
53
+ .ant-table-middle
54
+ > .ant-table-content
55
+ > .ant-table-fixed-right
56
+ > .ant-table-header
57
+ > table
58
+ > .ant-table-thead
59
+ > tr
60
+ > th,
61
+ .ant-table-middle
62
+ > .ant-table-content
63
+ > .ant-table-fixed-right
64
+ > .ant-table-body-outer
65
+ > .ant-table-body-inner
66
+ > table
67
+ > .ant-table-thead
68
+ > tr
69
+ > th {
70
+ padding: 8px;
71
+ }
72
+
73
+ .ant-pagination {
74
+ margin: 0;
75
+ padding: 16px;
76
+ text-align: right;
77
+ }
78
+
79
+ .ant-table-cell {
80
+ .ant-btn-link {
81
+ height: auto;
82
+ padding: 0;
83
+ line-height: initial;
84
+ }
85
+ }
86
+
87
+ .ant-table-sticky-holder {
88
+ z-index: 100;
89
+ }
90
+ }
91
+
92
+ &-noselection {
93
+ .ant-table-thead {
94
+ tr th:first-child {
95
+ padding-left: 22px;
96
+ }
97
+ }
98
+
99
+ .ant-table-tbody {
100
+ tr td:first-child {
101
+ padding-left: 22px;
102
+ }
103
+ }
104
+ }
105
+
106
+ &-nodata {
107
+ color: red;
108
+
109
+ .ant-table-content {
110
+ overflow: hidden !important;
111
+ }
112
+
113
+ .ant-table-body {
114
+ overflow: hidden !important;
115
+ }
116
+ }
117
+ }