@ccs-ui/rc-pro 2.3.5 → 2.3.6-alpha-2

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 (89) hide show
  1. package/es/aj-captcha/index.d.ts +5 -2
  2. package/es/aj-captcha/index.js +6 -2
  3. package/es/auth/index.d.ts +3 -0
  4. package/es/auth/index.js +3 -0
  5. package/es/button/dropdown.js +5 -17
  6. package/es/button/group.js +47 -65
  7. package/es/button/index.d.ts +4 -11
  8. package/es/button/index.js +10 -13
  9. package/es/cascader/index.d.ts +6 -3
  10. package/es/cascader/index.js +11 -7
  11. package/es/ccs.d.ts +9 -10
  12. package/es/color-picker/index.d.ts +5 -1
  13. package/es/color-picker/index.js +6 -2
  14. package/es/context/index.d.ts +24 -2
  15. package/es/date-picker/index.d.ts +1 -0
  16. package/es/date-picker/index.js +3 -0
  17. package/es/dialog/HookDrawer.js +3 -1
  18. package/es/dialog/HookModal.js +3 -1
  19. package/es/dialog/button.d.ts +1 -1
  20. package/es/dialog/context.d.ts +2 -1
  21. package/es/dialog/hook.d.ts +10 -0
  22. package/es/dialog/index.d.ts +3 -1
  23. package/es/dialog/index.js +3 -0
  24. package/es/editor/index.d.ts +1 -0
  25. package/es/editor/index.js +3 -0
  26. package/es/ellipsis/index.d.ts +21 -5
  27. package/es/ellipsis/index.js +117 -28
  28. package/es/ellipsis/index.less +5 -0
  29. package/es/ellipsis/useMeasure.d.ts +9 -0
  30. package/es/ellipsis/useMeasure.js +142 -0
  31. package/es/ellipsis/useResizeEffect.d.ts +2 -0
  32. package/es/ellipsis/useResizeEffect.js +28 -0
  33. package/es/ellipsis/withStopPropagation.d.ts +4 -0
  34. package/es/ellipsis/withStopPropagation.js +38 -0
  35. package/es/hooks/use-app.d.ts +7 -2
  36. package/es/hooks/use-app.js +8 -3
  37. package/es/hooks/use-selection.d.ts +28 -0
  38. package/es/hooks/use-selection.js +148 -0
  39. package/es/index.d.ts +3 -2
  40. package/es/index.js +3 -2
  41. package/es/interval-button/index.js +3 -0
  42. package/es/layout-keep-alive/index.d.ts +8 -4
  43. package/es/layout-keep-alive/index.js +94 -49
  44. package/es/layout-keep-alive/page.d.ts +2 -2
  45. package/es/layout-keep-alive/page.js +4 -4
  46. package/es/layout-single-page/index.d.ts +5 -2
  47. package/es/layout-single-page/index.js +8 -7
  48. package/es/layout-single-page/page.d.ts +2 -2
  49. package/es/loading/index.d.ts +4 -1
  50. package/es/loading/index.js +4 -1
  51. package/es/pro-table/head.d.ts +8 -7
  52. package/es/pro-table/head.js +54 -100
  53. package/es/pro-table/index.d.ts +8 -8
  54. package/es/pro-table/index.js +8 -3
  55. package/es/pro-table/index.less +8 -3
  56. package/es/pro-table/selection-alert.d.ts +18 -0
  57. package/es/pro-table/selection-alert.js +52 -0
  58. package/es/pro-table/summary.d.ts +8 -0
  59. package/es/pro-table/summary.js +32 -0
  60. package/es/pro-table/table.d.ts +37 -30
  61. package/es/pro-table/table.js +485 -265
  62. package/es/pro-table/tree.d.ts +1 -1
  63. package/es/pro-table/tree.js +9 -15
  64. package/es/pro-tabs/index.d.ts +5 -2
  65. package/es/pro-tabs/index.js +16 -6
  66. package/es/resize-observer.d.ts +2 -2
  67. package/es/resize-observer.js +2 -2
  68. package/es/result/index.d.ts +11 -15
  69. package/es/result/index.js +57 -54
  70. package/es/select/ modal.d.ts +16 -0
  71. package/es/select/ modal.js +100 -0
  72. package/es/select/api.d.ts +25 -0
  73. package/es/select/api.js +67 -0
  74. package/es/select/customize.d.ts +37 -0
  75. package/es/select/customize.js +146 -0
  76. package/es/select/index.d.ts +20 -20
  77. package/es/select/index.js +70 -80
  78. package/es/status-tag/index.d.ts +5 -1
  79. package/es/status-tag/index.js +6 -2
  80. package/es/table/index.d.ts +5 -2
  81. package/es/table/index.js +82 -42
  82. package/es/table/index.less +27 -42
  83. package/es/trigger/index.d.ts +1 -0
  84. package/es/trigger/index.js +1 -0
  85. package/es/upload/index.d.ts +4 -3
  86. package/es/upload/index.js +6 -3
  87. package/es/water-mark/index.d.ts +4 -1
  88. package/es/water-mark/index.js +3 -0
  89. package/package.json +5 -4
@@ -1,15 +1,19 @@
1
- var _excluded = ["type"];
1
+ var _excluded = ["selectedRowKeys", "onChange"];
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
3
  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; }
3
4
  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; }
4
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
5
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
6
- 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); } }
7
- 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); }); }; }
6
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
+ 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."); }
8
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
12
  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; }
11
13
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
14
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ 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); } }
16
+ 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); }); }; }
13
17
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
18
  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."); }
15
19
  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); }
@@ -17,12 +21,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
17
21
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18
22
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
23
  import CcsUtils from '@ccs-ui/utils';
20
- import { useSize, useUpdateEffect } from 'ahooks';
21
- import { theme as antTheme, Empty, Form } from 'antd';
24
+ import { useUpdateEffect } from 'ahooks';
25
+ import { theme as antTheme, Card, Empty } from 'antd';
22
26
  import classNames from 'classnames';
27
+ import _debounce from 'lodash.debounce';
23
28
  import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
24
- import { useAppConfig, useCcsPage } from '..';
25
- import { onDefaultFormat } from "../config";
29
+ import { CcsResizeObserver, useAppConfig, useCcsPage } from '..';
26
30
  import { useProTableFields } from "../hooks/use-app";
27
31
  import { getDataFromFields } from "../select";
28
32
  import CcsTable from "../table";
@@ -32,12 +36,32 @@ import "./index.less";
32
36
  import TableOperation from "./operation";
33
37
  import TableTree from "./tree";
34
38
  import { jsx as _jsx } from "react/jsx-runtime";
35
- import { Fragment as _Fragment } from "react/jsx-runtime";
36
39
  import { jsxs as _jsxs } from "react/jsx-runtime";
40
+ import { Fragment as _Fragment } from "react/jsx-runtime";
41
+ function onSetObj(target, paths, value) {
42
+ while (paths.length > 0) {
43
+ var path = paths.shift();
44
+ if (paths.length > 0) {
45
+ if (!target[path]) target[path] = {};
46
+ onSetObj(target[path], paths, value);
47
+ } else {
48
+ target[path] = value;
49
+ }
50
+ }
51
+ }
52
+ // table 事件
53
+ export var TableEvent = /*#__PURE__*/function (TableEvent) {
54
+ TableEvent["Search"] = "search";
55
+ TableEvent["Reset"] = "reset";
56
+ TableEvent["Reload"] = "reload";
57
+ TableEvent["ChangePage"] = "changePage";
58
+ TableEvent["InitSearch"] = "initSearch";
59
+ TableEvent["FullScreen"] = "fullScreen";
60
+ TableEvent["ColumnFilter"] = "columnFilter";
61
+ TableEvent["SelectedRows"] = "SelectedRows";
62
+ return TableEvent;
63
+ }({});
37
64
  export var classPrefix = 'ccs-pl';
38
- export var TableSelectionContext = /*#__PURE__*/React.createContext({
39
- selectedRows: undefined
40
- });
41
65
 
42
66
  /**
43
67
  * 布局组件 包括form、查询、toolbar、table 自动初始化数据
@@ -46,7 +70,7 @@ export var TableSelectionContext = /*#__PURE__*/React.createContext({
46
70
  * @returns
47
71
  */
48
72
  var InternalProTable = function InternalProTable(props) {
49
- var _props$table, _table$scroll2, _table$scroll3;
73
+ var _table$scroll2, _table$scroll3;
50
74
  var init = props.init,
51
75
  auth = props.auth,
52
76
  table = props.table,
@@ -57,23 +81,24 @@ var InternalProTable = function InternalProTable(props) {
57
81
  children = props.children,
58
82
  className = props.className,
59
83
  expandForm = props.expandForm,
60
- searchEvent = props.searchEvent,
61
- toolbarExtra = props.toolbarExtra,
62
84
  _props$formItems = props.formItems,
63
85
  formItems = _props$formItems === void 0 ? [] : _props$formItems,
64
86
  leafNode = props.leafNode,
87
+ bordered = props.bordered,
65
88
  parentFieldName = props.parentFieldName,
66
89
  _props$formInitValues = props.formInitValues,
67
- formInitValues = _props$formInitValues === void 0 ? {} : _props$formInitValues;
90
+ formInitValues = _props$formInitValues === void 0 ? {} : _props$formInitValues,
91
+ onEvent = props.onEvent;
68
92
  var _useCcsPage = useCcsPage(),
69
93
  onAuth = _useCcsPage.onAuth;
70
94
  var _ref = table || {},
71
95
  pagination = _ref.pagination,
72
- httpRequest = _ref.request,
73
96
  _ref$requestParam = _ref.requestParam,
74
97
  requestParam = _ref$requestParam === void 0 ? {} : _ref$requestParam,
75
98
  columns = _ref.columns,
76
- rowKey = _ref.rowKey;
99
+ rowKey = _ref.rowKey,
100
+ httpRequest = _ref.request,
101
+ rowSelection = _ref.rowSelection;
77
102
  // table sticky
78
103
  var stickyRef = useRef(false);
79
104
 
@@ -101,17 +126,17 @@ var InternalProTable = function InternalProTable(props) {
101
126
  }, []);
102
127
 
103
128
  // column filter
104
- var filtersRef = useRef(defaultColumnValues);
129
+ var filterOrderRef = useRef(defaultColumnValues);
105
130
  // table content
106
131
  var tableContentRef = useRef(null);
132
+ // 接口查询条件
133
+ var searchParamRef = useRef({});
107
134
  // container
108
135
  var containerRef = useRef(null);
109
136
  // table ref
110
137
  var tableRef = useRef();
111
138
  // 查询form
112
- var _Form$useForm = Form.useForm(),
113
- _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
114
- form = _Form$useForm2[0];
139
+ var formRef = useRef(null);
115
140
  // table data
116
141
  var _useState = useState({
117
142
  total: 0,
@@ -123,10 +148,14 @@ var InternalProTable = function InternalProTable(props) {
123
148
  data = _useState2[0],
124
149
  setData = _useState2[1];
125
150
  var treeRef = useRef(null);
126
- var _useState3 = useState([]),
151
+ // const [selectedRowKeys, setSelectedRowKeys] = useState(
152
+ // table?.rowSelection?.defaultSelectedRowKeys || [],
153
+ // );
154
+ var _useState3 = useState({}),
127
155
  _useState4 = _slicedToArray(_useState3, 2),
128
- selectedRows = _useState4[0],
129
- setSelectedRows = _useState4[1];
156
+ update = _useState4[1];
157
+ var rowSelectionRef = useRef({});
158
+ // const selectedRowsRef = useRef<RecordType[]>([]);
130
159
  var _useState5 = useState((table === null || table === void 0 ? void 0 : table.size) || 'middle'),
131
160
  _useState6 = _slicedToArray(_useState5, 2),
132
161
  tableRowSize = _useState6[0],
@@ -136,10 +165,6 @@ var InternalProTable = function InternalProTable(props) {
136
165
  theme = _useAppConfig.theme;
137
166
  // 接口字段指定全局配置
138
167
  var globalFieldNames = useProTableFields();
139
- // 接口字段指定
140
- var fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), (_props$table = props.table) === null || _props$table === void 0 ? void 0 : _props$table.fieldNames);
141
- var onSearchBefore = props.onSearchBefore || onDefaultFormat;
142
- var onSearchAfter = props.onSearchAfter || onDefaultFormat;
143
168
 
144
169
  // 暗黑模式
145
170
  var isDark = theme === 'dark';
@@ -155,143 +180,167 @@ var InternalProTable = function InternalProTable(props) {
155
180
  });
156
181
  }, []);
157
182
 
158
- // 监听容器尺寸变化
159
- var size = useSize(containerRef);
160
- useEffect(function () {
161
- var _table$scroll, _tableContentRef$curr;
162
- if ((table === null || table === void 0 || (_table$scroll = table.scroll) === null || _table$scroll === void 0 ? void 0 : _table$scroll.y) === 'auto' && ((_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 ? void 0 : _tableContentRef$curr.clientHeight) !== 0) {
163
- var _tableRef$current;
164
- (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 || _tableRef$current.onFixedThead();
165
- }
166
- }, [size === null || size === void 0 ? void 0 : size.height]);
167
-
168
183
  // 获取数据
169
184
  var onRequest = /*#__PURE__*/function () {
170
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(eventType) {
185
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(eventType) {
186
+ var _formRef$current, _props$table;
171
187
  var pageNo,
172
188
  pageSize,
173
189
  record,
174
- _args2 = arguments;
175
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
176
- while (1) switch (_context2.prev = _context2.next) {
190
+ formValues,
191
+ fieldNames,
192
+ _fieldNames$requestPa,
193
+ _fieldNames$requestPa2,
194
+ fsFilters,
195
+ _fieldNames$requestPa3,
196
+ fsPageNo,
197
+ _fieldNames$requestPa4,
198
+ fsPageSize,
199
+ _fieldNames$requestPa5,
200
+ fsOrderProps,
201
+ fsQuery,
202
+ params,
203
+ _filterOrderRef$curre,
204
+ filters,
205
+ orderProps,
206
+ _treeRef$current,
207
+ requestResult,
208
+ dataSource,
209
+ total,
210
+ newData,
211
+ _args = arguments;
212
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
213
+ while (1) switch (_context.prev = _context.next) {
177
214
  case 0:
178
- pageNo = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 1;
179
- pageSize = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : (pagination ? pagination.defaultPageSize : 10) || 10;
180
- record = _args2.length > 3 ? _args2[3] : undefined;
215
+ pageNo = _args.length > 1 && _args[1] !== undefined ? _args[1] : 1;
216
+ pageSize = _args.length > 2 && _args[2] !== undefined ? _args[2] : (pagination ? pagination.defaultPageSize : 10) || 10;
217
+ record = _args.length > 3 ? _args[3] : undefined;
181
218
  if (!(!isAuth || !httpRequest)) {
182
- _context2.next = 5;
219
+ _context.next = 5;
183
220
  break;
184
221
  }
185
- return _context2.abrupt("return");
222
+ return _context.abrupt("return");
186
223
  case 5:
187
- // 构建查询条件:表单数据、请求额外参数、分页参数、其他参数
188
- form.validateFields().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
189
- var formValues,
190
- pageValue,
191
- params,
192
- _treeRef$current,
193
- newParams,
194
- requestResult,
195
- newReqResult,
196
- dataSource,
197
- _pageSize,
198
- current,
199
- total,
200
- _args = arguments;
201
- return _regeneratorRuntime().wrap(function _callee$(_context) {
202
- while (1) switch (_context.prev = _context.next) {
203
- case 0:
204
- formValues = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
205
- // 格式化条件
206
- if (formatFormItems.length) {
207
- Object.keys(formValues).forEach(function (k) {
208
- if (formValues[k] !== undefined) {
209
- var s = formatFormItems.find(function (f) {
210
- return f.name === k;
211
- });
212
- if (s) formValues[k] = s.onFormat && s.onFormat(formValues[k]);
213
- }
214
- });
215
- }
216
- pageValue = pagination === false ? {} : {
217
- pageNo: pageNo,
218
- pageSize: pageSize
219
- };
220
- params = _objectSpread(_objectSpread({
221
- query: _objectSpread(_objectSpread({}, formValues), requestParam)
222
- }, pageValue), filtersRef.current); // 异步树
223
- if (!parentFieldName) {
224
- _context.next = 7;
225
- break;
226
- }
227
- (_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 || _treeRef$current.onRequestTree(params.query, record);
228
- return _context.abrupt("return");
229
- case 7:
230
- // onSearchBefore 请求前回传参数,可以在父组件进行修改
231
- newParams = onSearchBefore(params, eventType); // 发起请求
232
- setData(function (d) {
233
- return _objectSpread(_objectSpread({}, d), {}, {
234
- loading: true
235
- });
236
- });
237
- _context.next = 11;
238
- return httpRequest(_objectSpread({}, newParams));
239
- case 11:
240
- requestResult = _context.sent;
241
- if (!requestResult) {
242
- _context.next = 24;
243
- break;
244
- }
245
- // onSearchAfter 处理请求结果
246
- newReqResult = onSearchAfter(requestResult, eventType); // 获取table数据
247
- dataSource = getDataFromFields(newReqResult, fieldNames.dataSource);
248
- _pageSize = getDataFromFields(newReqResult, fieldNames.pageSize);
249
- current = getDataFromFields(newReqResult, fieldNames.current);
250
- total = getDataFromFields(newReqResult, fieldNames.total);
251
- if (!(total === undefined || _pageSize === undefined || current === undefined || dataSource === undefined)) {
252
- _context.next = 21;
253
- break;
254
- }
255
- setData({
256
- dataSource: dataSource,
257
- pageSize: _pageSize,
258
- current: current,
259
- total: total,
260
- loading: false
261
- });
262
- return _context.abrupt("return");
263
- case 21:
264
- // 当前页无数据,返回上一页
265
- if (!dataSource.length && current !== 1 && current !== undefined) {
266
- onRequest('reload', current - 1);
267
- } else {
268
- setData({
269
- current: current,
270
- pageSize: _pageSize,
271
- loading: false,
272
- dataSource: dataSource,
273
- total: total || 0
274
- });
275
- }
276
- _context.next = 25;
277
- break;
278
- case 24:
279
- setData(function (d) {
280
- return _objectSpread(_objectSpread({}, d), {}, {
281
- loading: false
282
- });
283
- });
284
- case 25:
285
- case "end":
286
- return _context.stop();
224
+ _context.next = 7;
225
+ return (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.validateFields();
226
+ case 7:
227
+ formValues = _context.sent;
228
+ // 接口字段指定
229
+ fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), (_props$table = props.table) === null || _props$table === void 0 ? void 0 : _props$table.fieldNames); // 格式化条件
230
+ if (formatFormItems.length) {
231
+ Object.keys(formValues).forEach(function (k) {
232
+ if (formValues[k] !== undefined) {
233
+ var s = formatFormItems.find(function (f) {
234
+ return f.name === k;
235
+ });
236
+ if (s) formValues[k] = s.onFormat && s.onFormat(formValues[k]);
287
237
  }
288
- }, _callee);
289
- }))).catch(function () {});
290
- case 6:
238
+ });
239
+ }
240
+
241
+ // 请求字段
242
+ _fieldNames$requestPa = fieldNames.requestParam, _fieldNames$requestPa2 = _fieldNames$requestPa.filters, fsFilters = _fieldNames$requestPa2 === void 0 ? ['filters'] : _fieldNames$requestPa2, _fieldNames$requestPa3 = _fieldNames$requestPa.pageNo, fsPageNo = _fieldNames$requestPa3 === void 0 ? ['pageNo'] : _fieldNames$requestPa3, _fieldNames$requestPa4 = _fieldNames$requestPa.pageSize, fsPageSize = _fieldNames$requestPa4 === void 0 ? ['pageSize'] : _fieldNames$requestPa4, _fieldNames$requestPa5 = _fieldNames$requestPa.orderProps, fsOrderProps = _fieldNames$requestPa5 === void 0 ? ['orderProps'] : _fieldNames$requestPa5, fsQuery = _fieldNames$requestPa.query; // 构建请求参数
243
+ params = {};
244
+ if (fsQuery && fsQuery.length > 0) {
245
+ onSetObj(params, _toConsumableArray(fsQuery), _objectSpread(_objectSpread(_objectSpread({}, requestParam), formInitValues), formValues));
246
+ } else {
247
+ params = _objectSpread(_objectSpread(_objectSpread({}, requestParam), formInitValues), formValues);
248
+ }
249
+ if (pagination !== false) {
250
+ // 分页
251
+ onSetObj(params, _toConsumableArray(fsPageNo), pageNo);
252
+ onSetObj(params, _toConsumableArray(fsPageSize), pageSize);
253
+ }
254
+
255
+ // 列过滤或排序参数
256
+ _filterOrderRef$curre = filterOrderRef.current, filters = _filterOrderRef$curre.filters, orderProps = _filterOrderRef$curre.orderProps;
257
+ if (Object.keys(filters).length > 0) {
258
+ onSetObj(params, _toConsumableArray(fsFilters), filters);
259
+ }
260
+ if (orderProps.length > 0) {
261
+ onSetObj(params, _toConsumableArray(fsOrderProps), orderProps);
262
+ }
263
+
264
+ // 异步树
265
+ if (!parentFieldName) {
266
+ _context.next = 20;
267
+ break;
268
+ }
269
+ (_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 || _treeRef$current.onRequestTree(params.query, record);
270
+ return _context.abrupt("return");
271
+ case 20:
272
+ // 记录查询条件
273
+ searchParamRef.current = params;
274
+ onEvent === null || onEvent === void 0 || onEvent(eventType, {
275
+ loading: true,
276
+ params: params
277
+ });
278
+
279
+ // 发起请求
280
+ setData(function (d) {
281
+ return _objectSpread(_objectSpread({}, d), {}, {
282
+ loading: true
283
+ });
284
+ });
285
+ _context.next = 25;
286
+ return httpRequest(params);
287
+ case 25:
288
+ requestResult = _context.sent;
289
+ onEvent === null || onEvent === void 0 || onEvent(eventType, {
290
+ loading: false,
291
+ params: params,
292
+ data: requestResult
293
+ });
294
+
295
+ // 请求结果
296
+ if (!requestResult) {
297
+ _context.next = 37;
298
+ break;
299
+ }
300
+ // 获取table数据
301
+ dataSource = getDataFromFields(requestResult, fieldNames.dataSource); // 默认添加一条数据
302
+ if (table !== null && table !== void 0 && table.emptyDefaultOne && dataSource && dataSource.length === 0) {
303
+ dataSource.push(_defineProperty({}, rowKey || 'id', '0'));
304
+ }
305
+ total = getDataFromFields(requestResult, fieldNames.total);
306
+ if (!(total === undefined || dataSource === undefined)) {
307
+ _context.next = 35;
308
+ break;
309
+ }
310
+ newData = {
311
+ dataSource: dataSource,
312
+ pageSize: pageSize,
313
+ current: pageNo,
314
+ total: total,
315
+ loading: false
316
+ };
317
+ setData(newData);
318
+ return _context.abrupt("return");
319
+ case 35:
320
+ // 当前页无数据,返回上一页
321
+ if (!dataSource.length && pageNo !== 1) {
322
+ onRequest(TableEvent.Reload, pageNo - 1);
323
+ } else {
324
+ setData({
325
+ current: pageNo,
326
+ pageSize: pageSize,
327
+ loading: false,
328
+ dataSource: dataSource,
329
+ total: total || 0
330
+ });
331
+ }
332
+ return _context.abrupt("return");
333
+ case 37:
334
+ setData(function (d) {
335
+ return _objectSpread(_objectSpread({}, d), {}, {
336
+ loading: false
337
+ });
338
+ });
339
+ case 38:
291
340
  case "end":
292
- return _context2.stop();
341
+ return _context.stop();
293
342
  }
294
- }, _callee2);
343
+ }, _callee);
295
344
  }));
296
345
  return function onRequest(_x) {
297
346
  return _ref2.apply(this, arguments);
@@ -305,7 +354,7 @@ var InternalProTable = function InternalProTable(props) {
305
354
  var treeNode = getDataById(data.dataSource || [], rowKey, id);
306
355
  // 没有查找到、全部刷新
307
356
  if (!treeNode) {
308
- onRequest('search');
357
+ onRequest(TableEvent.Search);
309
358
  return;
310
359
  }
311
360
  // 获取所有下级ID
@@ -340,20 +389,153 @@ var InternalProTable = function InternalProTable(props) {
340
389
  // 初始查询
341
390
  useEffect(function () {
342
391
  if (init !== false && httpRequest) {
343
- onRequest('initSearch');
392
+ onRequest(TableEvent.InitSearch);
344
393
  }
345
394
  }, [Object.keys(requestParam || {}).toString(), Object.values(requestParam || {}).toString()]);
346
395
 
396
+ // 初始状态,记录选中key和选中记录,用作选中数据回显
397
+ // useEffect(() => {
398
+ // if (!rowSelectionDefaultRows) return;
399
+
400
+ // const { selectedRowKeys } = table?.rowSelection || {};
401
+ // if (
402
+ // selectedRowKeys &&
403
+ // selectedRowKeys.length > 0 &&
404
+ // !rowSelectionRef.current.selectedRowKeys &&
405
+ // rowSelectionDefaultRows.length > 0
406
+ // ) {
407
+ // rowSelectionRef.current = {
408
+ // selectedRowKeys,
409
+ // selectedRows: rowSelectionDefaultRows,
410
+ // };
411
+ // update({});
412
+ // }
413
+ // }, [rowSelectionDefaultRows]);
414
+
347
415
  // 查询按钮
348
- var _onSearch = function onSearch() {
349
- if (searchEvent) searchEvent();
350
- onRequest('search');
416
+ var onSearch = function onSearch() {
417
+ onRequest(TableEvent.Search);
418
+ };
419
+
420
+ // ==================== 封装table行选中逻辑 start====================
421
+ var _ref3 = rowSelection || {},
422
+ selectedRowKeys = _ref3.selectedRowKeys,
423
+ onRowChange = _ref3.onChange,
424
+ rsProps = _objectWithoutProperties(_ref3, _excluded);
425
+ var _rowSelectionRef$curr = rowSelectionRef.current.selectedRowKeys,
426
+ keys = _rowSelectionRef$curr === void 0 ? [] : _rowSelectionRef$curr;
427
+
428
+ // // 传入了选中的key,生成与之匹配的selectedRows数据
429
+ // if (
430
+ // rowSelection &&
431
+ // 'selectedRowKeys' in rowSelection &&
432
+ // !isEqual(selectedRowKeys, keys)
433
+ // ) {
434
+ // // 初始状态,传入了默认值,根据rowSelectionDefaultRows 生成选中rows
435
+ // if (
436
+ // selectedRowKeys.length > 0 &&
437
+ // keys.length === 0 &&
438
+ // (rowSelectionDefaultRows || []).length > 0
439
+ // ) {
440
+ // rowSelectionRef.current = {
441
+ // selectedRowKeys,
442
+ // selectedRows: rowSelectionDefaultRows,
443
+ // };
444
+ // }
445
+
446
+ // // 选中数据清空了,清空当前rowSelectionRef.current 数据
447
+ // if (selectedRowKeys.length === 0 && keys.length !== 0) {
448
+ // rowSelectionRef.current = { selectedRowKeys: [], selectedRows: [] };
449
+ // }
450
+ // }
451
+
452
+ // 行选择配置
453
+ var newRowSelection = rowSelection ? _objectSpread({
454
+ selectedRowKeys: selectedRowKeys || keys,
455
+ onChange: function onChange(keys, rows, info) {
456
+ onRowChange === null || onRowChange === void 0 || onRowChange(keys, rows, info);
457
+ // // row 中存在undefined记录,由于初始渲染造成无法获取选中记录,需从rowSelectionDefaultRows 中获取
458
+ // rows.forEach((row, index) => {
459
+ // if (!row) {
460
+ // const defaultRow = rowSelectionDefaultRows?.find(
461
+ // (rs: any) => rs[rowKey || 'id'] === keys[index],
462
+ // );
463
+ // CcsUtils.showWarning(
464
+ // !!defaultRow,
465
+ // 'CcsProTable:存在未知选中记录,请使用rowSelectionDefaultRows传入初始选中记录',
466
+ // );
467
+ // rows[index] = defaultRow || ({} as RecordType);
468
+ // }
469
+ // });
470
+ // rowSelectionRef.current = {
471
+ // selectedRowKeys: keys,
472
+ // selectedRows: rows,
473
+ // };
474
+ onEvent === null || onEvent === void 0 || onEvent(TableEvent.SelectedRows, {
475
+ keys: keys,
476
+ rows: rows
477
+ });
478
+
479
+ // 未传入onChange则更新状态
480
+ if (!onRowChange) update({});
481
+ },
482
+ preserveSelectedRowKeys: true
483
+ }, rsProps) : undefined;
484
+ // ==================== 当处于受控状态,处理table选中记录 end====================
485
+
486
+ // 清除选择
487
+ var onClearSelected = function onClearSelected(key, noUpdate) {
488
+ var _rowSelection$onChang2;
489
+ // 指定删除
490
+ if (key !== undefined) {
491
+ var _rowSelectionRef$curr2 = rowSelectionRef.current,
492
+ _rowSelectionRef$curr3 = _rowSelectionRef$curr2.selectedRowKeys,
493
+ _selectedRowKeys = _rowSelectionRef$curr3 === void 0 ? [] : _rowSelectionRef$curr3,
494
+ _rowSelectionRef$curr4 = _rowSelectionRef$curr2.selectedRows,
495
+ selectedRows = _rowSelectionRef$curr4 === void 0 ? [] : _rowSelectionRef$curr4;
496
+ rowSelectionRef.current = {
497
+ selectedRowKeys: _selectedRowKeys.filter(function (r) {
498
+ return r !== key;
499
+ }),
500
+ selectedRows: selectedRows.filter(function (r) {
501
+ return r[rowKey || 'id'] !== key;
502
+ })
503
+ };
504
+ } else {
505
+ // 删除全部
506
+ rowSelectionRef.current = {
507
+ selectedRowKeys: undefined,
508
+ selectedRows: undefined
509
+ };
510
+ }
511
+ var _rowSelectionRef$curr5 = rowSelectionRef.current,
512
+ keys = _rowSelectionRef$curr5.selectedRowKeys,
513
+ _rowSelectionRef$curr6 = _rowSelectionRef$curr5.selectedRows,
514
+ rows = _rowSelectionRef$curr6 === void 0 ? [] : _rowSelectionRef$curr6;
515
+ onEvent === null || onEvent === void 0 || onEvent(TableEvent.SelectedRows, {
516
+ keys: keys,
517
+ rows: rows
518
+ });
519
+
520
+ // 受控状态,需要调用onchange
521
+ if (rowSelection !== null && rowSelection !== void 0 && rowSelection.onChange) {
522
+ var _rowSelection$onChang;
523
+ rowSelection === null || rowSelection === void 0 || (_rowSelection$onChang = rowSelection.onChange) === null || _rowSelection$onChang === void 0 || _rowSelection$onChang.call(rowSelection, keys, rows, {});
524
+ return;
525
+ }
526
+ if (!noUpdate)
527
+ // 需要更新状态
528
+ update({});
529
+ rowSelection === null || rowSelection === void 0 || (_rowSelection$onChang2 = rowSelection.onChange) === null || _rowSelection$onChang2 === void 0 || _rowSelection$onChang2.call(rowSelection, selectedRowKeys, rows, {});
351
530
  };
352
531
 
353
532
  // 重置
354
- var _onReset = function onReset() {
355
- if (selectedRows.length > 0) setSelectedRows([]);
356
- form === null || form === void 0 || form.resetFields();
533
+ var onReset = function onReset() {
534
+ var _formRef$current2;
535
+ // 清空选择
536
+ onClearSelected(undefined, true);
537
+ // 重置表单
538
+ (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.resetFields();
357
539
  // 清空columns显示filter和sort值
358
540
  columns === null || columns === void 0 || columns.forEach(function (c) {
359
541
  if (c.filterDropdown || c.filters) {
@@ -364,38 +546,31 @@ var InternalProTable = function InternalProTable(props) {
364
546
  }
365
547
  });
366
548
  // 清空filter请求值
367
- filtersRef.current = defaultColumnValues;
368
- onRequest('reset');
549
+ filterOrderRef.current = defaultColumnValues;
550
+ onRequest(TableEvent.Reset);
369
551
  };
370
552
 
371
553
  // 刷新
372
- var _onReload = function onReload() {
373
- if (selectedRows.length > 0) setSelectedRows([]);
374
- onRequest('reload', data.current, data.pageSize);
554
+ var onReload = function onReload() {
555
+ onClearSelected(undefined, true);
556
+ onRequest(TableEvent.Reload, data.current, data.pageSize);
375
557
  };
376
558
 
377
559
  // form 数据 查询,重载,重置方法
378
560
  useImperativeHandle(proRef, function () {
379
561
  return {
380
562
  data: data,
381
- selectedRows: selectedRows,
382
- formValues: form.getFieldsValue(),
383
- onSearch: function onSearch() {
384
- _onSearch();
385
- },
386
- onReload: function onReload() {
387
- _onReload();
388
- },
563
+ selectedRows: rowSelectionRef.current.selectedRows,
564
+ formValues: searchParamRef.current,
565
+ searchParam: searchParamRef.current,
566
+ onSearch: onSearch,
567
+ onReload: onReload,
389
568
  onPartialReload: function onPartialReload(param) {
390
569
  _onPartialReload(param);
391
570
  },
392
- onReset: function onReset() {
393
- _onReset();
394
- },
571
+ onReset: onReset,
395
572
  onChangeData: setData,
396
- onClearSelected: function onClearSelected() {
397
- return setSelectedRows([]);
398
- }
573
+ onClearSelected: onClearSelected
399
574
  };
400
575
  });
401
576
 
@@ -409,21 +584,28 @@ var InternalProTable = function InternalProTable(props) {
409
584
  c.filteredValue = filters[c.dataIndex];
410
585
  }
411
586
  });
412
- filtersRef.current = _objectSpread(_objectSpread({}, filtersRef.current), {}, {
587
+ filterOrderRef.current = _objectSpread(_objectSpread({}, filterOrderRef.current), {}, {
413
588
  filters: filters
414
589
  });
415
590
  }
416
591
  if (sorter) {
417
592
  columns === null || columns === void 0 || columns.forEach(function (c) {
418
593
  if (c.sorter) {
419
- var curSorter = Array.isArray(sorter) ?
420
- // @ts-ignore
421
- sorter.find(function (sort) {
422
- return sort.field === c.dataIndex;
423
- }) : sorter;
594
+ if (Array.isArray(sorter)) {
595
+ // @ts-ignore
596
+ var curSorter = sorter.find(function (sort) {
597
+ return sort.field === c.dataIndex;
598
+ });
599
+ if (curSorter) c.sortOrder = curSorter === null || curSorter === void 0 ? void 0 : curSorter.order;
600
+ return;
601
+ }
424
602
 
425
603
  // @ts-ignore
426
- c.sortOrder = curSorter === null || curSorter === void 0 ? void 0 : curSorter.order;
604
+ if (sorter.field === c.dataIndex) {
605
+ c.sortOrder = sorter.order;
606
+ return;
607
+ }
608
+ c.sortOrder = undefined;
427
609
  }
428
610
  });
429
611
 
@@ -444,12 +626,18 @@ var InternalProTable = function InternalProTable(props) {
444
626
  });
445
627
  }
446
628
  }
447
- filtersRef.current = _objectSpread(_objectSpread({}, filtersRef.current), {}, {
629
+ filterOrderRef.current = _objectSpread(_objectSpread({}, filterOrderRef.current), {}, {
448
630
  orderProps: orderProps
449
631
  });
450
632
  }
451
- onRequest('changePage', paginationTable.current || 0, paginationTable.pageSize || 10);
633
+ onRequest(TableEvent.ChangePage, paginationTable.current || 0, paginationTable.pageSize || 10);
452
634
  };
635
+
636
+ // 扩展组件传递参数
637
+ var extraProps = _objectSpread(_objectSpread({}, rowSelectionRef.current), {}, {
638
+ data: data.dataSource || [],
639
+ onClear: onClearSelected
640
+ });
453
641
  var renderTable = function renderTable() {
454
642
  if (!table) return null;
455
643
  if (!isAuth) {
@@ -475,38 +663,15 @@ var InternalProTable = function InternalProTable(props) {
475
663
  }
476
664
  }
477
665
 
478
- // 选择,只传入一个type参数或不传,封装选择行为
479
- var _ref4 = table.rowSelection || {},
480
- _ref4$type = _ref4.type,
481
- type = _ref4$type === void 0 ? 'checkbox' : _ref4$type,
482
- restSelection = _objectWithoutProperties(_ref4, _excluded);
483
- var hasSelection = table.rowSelection && CcsUtils.isEmpty(restSelection);
484
- var rowSelection = hasSelection ? {
485
- type: type,
486
- selectedRowKeys: selectedRows.map(function (k) {
487
- return k[rowKey];
488
- }),
489
- onChange: function onChange(_, rows) {
490
- return setSelectedRows(rows);
491
- },
492
- preserveSelectedRowKeys: true
493
- } : table.rowSelection;
494
-
495
666
  // table title
496
- var tableTitle = table.title ? table.title({
497
- selectedRows: selectedRows,
498
- data: data.dataSource || [],
499
- onClear: function onClear() {
500
- return setSelectedRows([]);
501
- }
502
- }) : undefined;
667
+ var tableTitle = CcsUtils.isFunction(table.title) ? table.title(extraProps) : undefined;
503
668
 
504
669
  // 异步树
505
670
  if (parentFieldName) {
506
671
  return /*#__PURE__*/_jsx(TableTree, {
507
672
  data: data,
508
673
  table: _objectSpread(_objectSpread({}, table), {}, {
509
- rowSelection: rowSelection,
674
+ rowSelection: newRowSelection,
510
675
  title: tableTitle ? function () {
511
676
  return tableTitle;
512
677
  } : undefined
@@ -519,8 +684,6 @@ var InternalProTable = function InternalProTable(props) {
519
684
  sticky: stickyRef.current || true,
520
685
  parentFieldName: parentFieldName,
521
686
  setData: setData,
522
- onSearchAfter: onSearchAfter,
523
- onSearchBefore: onSearchBefore,
524
687
  handlePageChange: handlePageChange
525
688
  });
526
689
  }
@@ -534,39 +697,28 @@ var InternalProTable = function InternalProTable(props) {
534
697
  size: tableRowSize,
535
698
  columns: columns,
536
699
  showSorterTooltip: true,
537
- rowSelection: rowSelection,
700
+ rowSelection: newRowSelection,
538
701
  showNumber: props.showNumber,
539
702
  loading: table.loading || data.loading || false,
540
703
  title: tableTitle ? function () {
541
704
  return tableTitle;
542
- } : undefined
705
+ } : undefined,
706
+ onEvent: onEvent
543
707
  }));
544
708
  };
545
- var newToolbar = toolbar && /*#__PURE__*/_jsx(TableSelectionContext.Provider, {
546
- value: {
547
- selectedRows: selectedRows
548
- },
549
- children: toolbar
550
- });
551
- var newToolbarExtra = /*#__PURE__*/_jsx(TableSelectionContext.Provider, {
552
- value: {
553
- selectedRows: selectedRows
554
- },
555
- children: toolbarExtra
556
- });
557
709
  var _antTheme$useToken = antTheme.useToken(),
558
710
  token = _antTheme$useToken.token;
559
711
  var rootStyle = styles.root || {};
560
- if (table !== null && table !== void 0 && table.bordered) {
712
+ if (bordered) {
561
713
  rootStyle = _objectSpread({
562
714
  border: "1px solid ".concat(token.colorBorderSecondary),
563
715
  borderRadius: 4
564
716
  }, rootStyle);
565
717
  }
566
718
  var onFullScreen = function onFullScreen(isFull) {
567
- var _ref5 = containerRef.current || {},
568
- classList = _ref5.classList,
569
- style = _ref5.style;
719
+ var _ref4 = containerRef.current || {},
720
+ classList = _ref4.classList,
721
+ style = _ref4.style;
570
722
  if (isFull) {
571
723
  classList === null || classList === void 0 || classList.add('css-table-full');
572
724
  style.backgroundColor = token.colorBgContainer;
@@ -575,39 +727,107 @@ var InternalProTable = function InternalProTable(props) {
575
727
  style.backgroundColor = 'transparent';
576
728
  }
577
729
  };
578
- return /*#__PURE__*/_jsxs("div", {
579
- className: classNames(classPrefix, className, _defineProperty({}, 'dark-table', isDark)),
580
- style: _objectSpread(_objectSpread({}, rootStyle), {}, {
581
- overflow: (table === null || table === void 0 || (_table$scroll2 = table.scroll) === null || _table$scroll2 === void 0 ? void 0 : _table$scroll2.y) === 'auto' ? 'hidden' : 'unset'
582
- }),
583
- ref: containerRef,
584
- children: [!(!formItems.length && !toolbar) && isAuth && /*#__PURE__*/_jsx(HeadComponent, {
585
- form: form,
586
- toolbar: newToolbar,
587
- formItems: formItems,
588
- expandForm: expandForm,
589
- formInitValues: formInitValues,
590
- formItemLabelWidth: props.formItemLabelWidth,
591
- onSearch: _onSearch,
592
- title: props.title,
593
- tableOperation: (table === null || table === void 0 ? void 0 : table.hideOperation) !== true ? /*#__PURE__*/_jsx(TableOperation, {
594
- onChangeRowSize: function onChangeRowSize(e) {
595
- return setTableRowSize(e);
596
- },
597
- tableRowSize: tableRowSize,
598
- onReset: _onReset,
599
- columns: columns,
600
- tableRef: tableRef,
601
- onFullScreen: onFullScreen
602
- }) : /*#__PURE__*/_jsx(_Fragment, {}),
603
- children: newToolbarExtra
730
+
731
+ // 尺寸变化重设尺寸
732
+ var resizeFn = function resizeFn() {
733
+ var _table$scroll, _tableContentRef$curr;
734
+ if ((table === null || table === void 0 || (_table$scroll = table.scroll) === null || _table$scroll === void 0 ? void 0 : _table$scroll.y) === 'auto' && ((_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 ? void 0 : _tableContentRef$curr.clientHeight) !== 0) {
735
+ var _tableRef$current;
736
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 || _tableRef$current.onFixedThead();
737
+ }
738
+ };
739
+
740
+ // 监听容器尺寸变化
741
+ var onResize = _debounce(resizeFn, 500);
742
+
743
+ // table 操作按钮
744
+ var renderTableOperation = (table === null || table === void 0 ? void 0 : table.hideOperation) !== true ? /*#__PURE__*/_jsx(TableOperation, {
745
+ onChangeRowSize: function onChangeRowSize(e) {
746
+ return setTableRowSize(e);
747
+ },
748
+ tableRowSize: tableRowSize,
749
+ onReset: onReset,
750
+ columns: columns,
751
+ tableRef: tableRef,
752
+ onFullScreen: onFullScreen
753
+ }) : undefined;
754
+
755
+ // 有查询条件
756
+ var hasFormItem = formItems.length > 0;
757
+
758
+ // table 按钮区
759
+ var tableToolbar = CcsUtils.isFunction(toolbar) ? toolbar(extraProps) : toolbar;
760
+ return /*#__PURE__*/_jsxs(_Fragment, {
761
+ children: [/*#__PURE__*/_jsx(CcsResizeObserver.Target, {
762
+ targetRef: tableContentRef,
763
+ onResize: onResize
604
764
  }), /*#__PURE__*/_jsxs("div", {
605
- className: "".concat(classPrefix, "-table-content"),
606
- style: _objectSpread(_objectSpread({}, styles === null || styles === void 0 ? void 0 : styles.table), {}, {
607
- overflow: (table === null || table === void 0 || (_table$scroll3 = table.scroll) === null || _table$scroll3 === void 0 ? void 0 : _table$scroll3.y) === 'auto' ? 'hidden' : 'unset'
765
+ className: classNames(classPrefix, className, _defineProperty({}, 'dark-table', isDark)),
766
+ style: _objectSpread(_objectSpread({}, rootStyle), {}, {
767
+ overflow: (table === null || table === void 0 || (_table$scroll2 = table.scroll) === null || _table$scroll2 === void 0 ? void 0 : _table$scroll2.y) === 'auto' ? 'hidden' : 'unset'
608
768
  }),
609
- ref: tableContentRef,
610
- children: [renderTable(), children]
769
+ ref: containerRef,
770
+ children: [/*#__PURE__*/_jsx(Card, {
771
+ className: "ccs-pl-adaptation",
772
+ style: {
773
+ boxShadow: 'none'
774
+ },
775
+ styles: {
776
+ body: {
777
+ padding: hasFormItem ? 16 : 0
778
+ }
779
+ },
780
+ variant: "borderless",
781
+ title: props.title,
782
+ children: hasFormItem && /*#__PURE__*/_jsx(HeadComponent, {
783
+ formRef: formRef,
784
+ toolbar: tableToolbar,
785
+ formItems: formItems,
786
+ expandForm: expandForm,
787
+ formInitValues: formInitValues,
788
+ formItemLabelWidth: props.formItemLabelWidth,
789
+ onSearch: onSearch,
790
+ tableOperation: renderTableOperation
791
+ })
792
+ }), (toolbar || !hasFormItem && renderTableOperation) && /*#__PURE__*/_jsxs(Card, {
793
+ styles: {
794
+ cover: {
795
+ borderRadius: 0
796
+ },
797
+ body: {
798
+ display: 'flex',
799
+ justifyContent: 'space-between',
800
+ width: '100%',
801
+ padding: '12px 16px',
802
+ alignContent: 'center'
803
+ }
804
+ },
805
+ style: {
806
+ borderRadius: 0,
807
+ borderLeft: 0,
808
+ borderBottom: 0,
809
+ borderRight: 0,
810
+ borderTop: !hasFormItem ? 0 : undefined
811
+ },
812
+ children: [/*#__PURE__*/_jsx("div", {
813
+ style: {
814
+ flex: '1 1 auto'
815
+ },
816
+ children: tableToolbar
817
+ }), /*#__PURE__*/_jsx("div", {
818
+ style: {
819
+ flex: '0 0 auto'
820
+ },
821
+ children: renderTableOperation
822
+ })]
823
+ }), /*#__PURE__*/_jsxs("div", {
824
+ className: "".concat(classPrefix, "-table-content"),
825
+ style: _objectSpread(_objectSpread({}, styles === null || styles === void 0 ? void 0 : styles.table), {}, {
826
+ overflow: (table === null || table === void 0 || (_table$scroll3 = table.scroll) === null || _table$scroll3 === void 0 ? void 0 : _table$scroll3.y) === 'auto' ? 'hidden' : 'unset'
827
+ }),
828
+ ref: tableContentRef,
829
+ children: [renderTable(), children]
830
+ })]
611
831
  })]
612
832
  });
613
833
  };