@ccs-ui/rc-pro 2.3.6-beta-40 → 2.4.0-beta.1

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 (185) hide show
  1. package/docs-dist/154.1dfbf448.async.js +137 -0
  2. package/docs-dist/27.cf0e6aaf.async.js +11 -0
  3. package/docs-dist/272.98b3528d.async.js +15 -0
  4. package/docs-dist/272.e8c51481.chunk.css +5 -0
  5. package/docs-dist/313.ee13d2ba.async.js +5 -0
  6. package/docs-dist/387.c3734c23.async.js +573 -0
  7. package/docs-dist/404.html +15 -0
  8. package/docs-dist/859.2ac4ce6d.async.js +18 -0
  9. package/docs-dist/auth__demos.106c6ce7.async.js +1 -0
  10. package/docs-dist/button__demos.4c22be73.async.js +1 -0
  11. package/docs-dist/cascader__demos.46cb399e.async.js +1 -0
  12. package/docs-dist/date-picker__demos.cb7b5f00.async.js +1 -0
  13. package/docs-dist/dialog__demos.e4f54d6e.async.js +1 -0
  14. package/docs-dist/docs__guide.md.33be0665.chunk.css +1 -0
  15. package/docs-dist/docs__guide.md.fa186b09.async.js +1 -0
  16. package/docs-dist/docs__index.md.22217718.async.js +1 -0
  17. package/docs-dist/docs__index.md.33be0665.chunk.css +1 -0
  18. package/docs-dist/dumi__tmp-production__dumi__theme__ContextWrapper.a5f4a8dc.async.js +1 -0
  19. package/docs-dist/editor__demos.0b8f6819.async.js +6 -0
  20. package/docs-dist/favicon.png +0 -0
  21. package/docs-dist/group-form-item__demos.121f2381.async.js +1 -0
  22. package/docs-dist/guide/index.html +15 -0
  23. package/docs-dist/index.html +15 -0
  24. package/docs-dist/interval-button__demos.a9fa2598.async.js +1 -0
  25. package/docs-dist/loading__demos.0b2a0a1e.async.js +1 -0
  26. package/docs-dist/logo.svg +48 -0
  27. package/docs-dist/meta__docs.58d867fc.async.js +1 -0
  28. package/docs-dist/meta__packages.20ad7ce8.async.js +10079 -0
  29. package/docs-dist/meta__packages.9ed2b563.chunk.css +1 -0
  30. package/docs-dist/nm__dumi__dist__client__pages__404.28f3e467.async.js +1 -0
  31. package/docs-dist/nm__dumi__dist__client__pages__404.8b85f2d9.chunk.css +1 -0
  32. package/docs-dist/nm__dumi__dist__client__pages__Demo__index.1d26abae.async.js +1 -0
  33. package/docs-dist/nm__dumi__dist__client__pages__Demo__index.578aa5c0.chunk.css +1 -0
  34. package/docs-dist/nm__dumi__theme-default__layouts__DocLayout__index.626881d5.async.js +1 -0
  35. package/docs-dist/packages__rc-pro__src__auth__index.md.33be0665.chunk.css +1 -0
  36. package/docs-dist/packages__rc-pro__src__auth__index.md.80345bcc.async.js +1 -0
  37. package/docs-dist/packages__rc-pro__src__button__index.md.05cb5ebc.async.js +1 -0
  38. package/docs-dist/packages__rc-pro__src__button__index.md.33be0665.chunk.css +1 -0
  39. package/docs-dist/packages__rc-pro__src__cascader__index.md.33be0665.chunk.css +1 -0
  40. package/docs-dist/packages__rc-pro__src__cascader__index.md.d8535a05.async.js +1 -0
  41. package/docs-dist/packages__rc-pro__src__date-picker__index.md.33be0665.chunk.css +1 -0
  42. package/docs-dist/packages__rc-pro__src__date-picker__index.md.bab3c69e.async.js +1 -0
  43. package/docs-dist/packages__rc-pro__src__dialog__index.md.33be0665.chunk.css +1 -0
  44. package/docs-dist/packages__rc-pro__src__dialog__index.md.64ec2666.async.js +1 -0
  45. package/docs-dist/packages__rc-pro__src__editor__index.md.33be0665.chunk.css +1 -0
  46. package/docs-dist/packages__rc-pro__src__editor__index.md.a18cb4dc.async.js +1 -0
  47. package/docs-dist/packages__rc-pro__src__group-form-item__index.md.33be0665.chunk.css +1 -0
  48. package/docs-dist/packages__rc-pro__src__group-form-item__index.md.7d1da762.async.js +1 -0
  49. package/docs-dist/packages__rc-pro__src__index.md.33be0665.chunk.css +1 -0
  50. package/docs-dist/packages__rc-pro__src__index.md.d9449737.async.js +1 -0
  51. package/docs-dist/packages__rc-pro__src__interval-button__index.md.33be0665.chunk.css +1 -0
  52. package/docs-dist/packages__rc-pro__src__interval-button__index.md.c725522b.async.js +1 -0
  53. package/docs-dist/packages__rc-pro__src__layout-keep-alive__index.md.33be0665.chunk.css +1 -0
  54. package/docs-dist/packages__rc-pro__src__layout-keep-alive__index.md.d39a1325.async.js +1 -0
  55. package/docs-dist/packages__rc-pro__src__loading__index.md.33be0665.chunk.css +1 -0
  56. package/docs-dist/packages__rc-pro__src__loading__index.md.893eb1e0.async.js +1 -0
  57. package/docs-dist/packages__rc-pro__src__pro-table__index.md.33be0665.chunk.css +1 -0
  58. package/docs-dist/packages__rc-pro__src__pro-table__index.md.352db0a4.async.js +1 -0
  59. package/docs-dist/packages__rc-pro__src__pro-tabs__index.md.33be0665.chunk.css +1 -0
  60. package/docs-dist/packages__rc-pro__src__pro-tabs__index.md.f6578fee.async.js +1 -0
  61. package/docs-dist/packages__rc-pro__src__result__index.md.33be0665.chunk.css +1 -0
  62. package/docs-dist/packages__rc-pro__src__result__index.md.737b704c.async.js +2 -0
  63. package/docs-dist/packages__rc-pro__src__select__index.md.33be0665.chunk.css +1 -0
  64. package/docs-dist/packages__rc-pro__src__select__index.md.35981c54.async.js +2 -0
  65. package/docs-dist/packages__rc-pro__src__time-picker__index.md.33be0665.chunk.css +1 -0
  66. package/docs-dist/packages__rc-pro__src__time-picker__index.md.b525b352.async.js +1 -0
  67. package/docs-dist/packages__rc-pro__src__water-mark__index.md.33be0665.chunk.css +1 -0
  68. package/docs-dist/packages__rc-pro__src__water-mark__index.md.8e548df5.async.js +1 -0
  69. package/docs-dist/preload_helper.5f80f118.js +1 -0
  70. package/docs-dist/pro-table__demos.09e87ab4.async.js +1 -0
  71. package/docs-dist/pro-tabs__demos.eff953d6.async.js +1 -0
  72. package/docs-dist/rc-pros/auth/index.html +15 -0
  73. package/docs-dist/rc-pros/button/index.html +15 -0
  74. package/docs-dist/rc-pros/cascader/index.html +15 -0
  75. package/docs-dist/rc-pros/date-picker/index.html +15 -0
  76. package/docs-dist/rc-pros/dialog/index.html +15 -0
  77. package/docs-dist/rc-pros/editor/index.html +15 -0
  78. package/docs-dist/rc-pros/group-form-item/index.html +15 -0
  79. package/docs-dist/rc-pros/index.html +15 -0
  80. package/docs-dist/rc-pros/interval-button/index.html +15 -0
  81. package/docs-dist/rc-pros/layout-keep-alive/index.html +15 -0
  82. package/docs-dist/rc-pros/loading/index.html +15 -0
  83. package/docs-dist/rc-pros/pro-table/index.html +15 -0
  84. package/docs-dist/rc-pros/pro-tabs/index.html +15 -0
  85. package/docs-dist/rc-pros/result/index.html +15 -0
  86. package/docs-dist/rc-pros/select/index.html +15 -0
  87. package/docs-dist/rc-pros/time-picker/index.html +15 -0
  88. package/docs-dist/rc-pros/water-mark/index.html +15 -0
  89. package/docs-dist/result__demos.4832bcb4.async.js +1 -0
  90. package/docs-dist/select__demos.e57e694a.async.js +1 -0
  91. package/docs-dist/time-picker__demos.518f8acb.async.js +1 -0
  92. package/docs-dist/umi.4e0bcd92.css +1 -0
  93. package/docs-dist/umi.cc941610.js +108 -0
  94. package/docs-dist/water-mark__demos.4e7773cd.async.js +1 -0
  95. package/docs-dist/~demos/:id/index.html +15 -0
  96. package/docs-dist/~demos/auth-demo-basic/index.html +15 -0
  97. package/docs-dist/~demos/button-demo-button/index.html +15 -0
  98. package/docs-dist/~demos/button-demo-group/index.html +15 -0
  99. package/docs-dist/~demos/cascader-demo-basic/index.html +15 -0
  100. package/docs-dist/~demos/cascader-demo-cache/index.html +15 -0
  101. package/docs-dist/~demos/date-picker-demo-basic/index.html +15 -0
  102. package/docs-dist/~demos/date-picker-demo-range/index.html +15 -0
  103. package/docs-dist/~demos/dialog-demo-demos/index.html +15 -0
  104. package/docs-dist/~demos/editor-demo-demos/index.html +15 -0
  105. package/docs-dist/~demos/group-form-item-demo-basic/index.html +15 -0
  106. package/docs-dist/~demos/interval-button-demo-basic/index.html +15 -0
  107. package/docs-dist/~demos/loading-demo-basic/index.html +15 -0
  108. package/docs-dist/~demos/pro-table-demo-basic/index.html +15 -0
  109. package/docs-dist/~demos/pro-table-demo-fixed/index.html +15 -0
  110. package/docs-dist/~demos/pro-table-demo-selection/index.html +15 -0
  111. package/docs-dist/~demos/pro-tabs-demo-basic/index.html +15 -0
  112. package/docs-dist/~demos/pro-tabs-demo-tab/index.html +15 -0
  113. package/docs-dist/~demos/result-demo-basic/index.html +15 -0
  114. package/docs-dist/~demos/select-demo-api/index.html +15 -0
  115. package/docs-dist/~demos/select-demo-basic/index.html +15 -0
  116. package/docs-dist/~demos/select-demo-customize/index.html +15 -0
  117. package/docs-dist/~demos/select-demo-customize-label/index.html +15 -0
  118. package/docs-dist/~demos/time-picker-demo-basic/index.html +15 -0
  119. package/docs-dist/~demos/water-mark-demo-basic/index.html +15 -0
  120. package/es/Foo/d +0 -0
  121. package/es/aj-captcha/index.less +9 -23
  122. package/es/auth/index.d.ts +7 -0
  123. package/es/auth/index.js +14 -0
  124. package/es/cascader/index.js +4 -4
  125. package/es/ccs.d.ts +7 -13
  126. package/es/config.js +33 -11
  127. package/es/context/index.d.ts +2 -2
  128. package/es/date-picker/index.js +20 -0
  129. package/es/dialog/button.d.ts +1 -1
  130. package/es/dialog/button.js +4 -4
  131. package/es/dialog/index.d.ts +0 -1
  132. package/es/dialog/index.js +0 -1
  133. package/es/ellipsis/index.js +4 -2
  134. package/es/ellipsis/useResizeEffect.js +10 -24
  135. package/es/group-form-item/index.d.ts +11 -0
  136. package/es/group-form-item/index.js +124 -0
  137. package/es/hooks/use-page.d.ts +1 -1
  138. package/es/hooks/use-selection.d.ts +12 -23
  139. package/es/hooks/use-selection.js +51 -25
  140. package/es/index.d.ts +1 -3
  141. package/es/index.js +1 -3
  142. package/es/interval-button/index.js +4 -4
  143. package/es/layout-keep-alive/index.d.ts +1 -1
  144. package/es/layout-keep-alive/index.js +26 -20
  145. package/es/layout-keep-alive/index.less +19 -23
  146. package/es/layout-keep-alive/page.d.ts +3 -2
  147. package/es/layout-keep-alive/page.js +4 -3
  148. package/es/layout-single-page/index.d.ts +5 -3
  149. package/es/layout-single-page/index.js +12 -5
  150. package/es/layout-single-page/index.less +2 -8
  151. package/es/layout-single-page/page.d.ts +3 -1
  152. package/es/layout-single-page/page.js +2 -1
  153. package/es/pro-table/_utils.d.ts +1 -1
  154. package/es/pro-table/_utils.js +7 -7
  155. package/es/pro-table/form-item.d.ts +5 -3
  156. package/es/pro-table/form-item.js +28 -11
  157. package/es/pro-table/head.js +88 -63
  158. package/es/pro-table/index.less +20 -175
  159. package/es/pro-table/selection-alert.d.ts +4 -2
  160. package/es/pro-table/selection-alert.js +16 -4
  161. package/es/pro-table/table.d.ts +13 -24
  162. package/es/pro-table/table.js +128 -250
  163. package/es/pro-table/tree.d.ts +3 -3
  164. package/es/pro-table/tree.js +28 -17
  165. package/es/select/ modal.d.ts +3 -9
  166. package/es/select/ modal.js +63 -22
  167. package/es/select/customize.d.ts +7 -15
  168. package/es/select/customize.js +58 -48
  169. package/es/select/index.d.ts +2 -1
  170. package/es/select/index.js +9 -9
  171. package/es/table/index.js +12 -14
  172. package/es/table/index.less +0 -129
  173. package/package.json +13 -32
  174. package/LICENSE +0 -21
  175. package/README.md +0 -37
  176. package/es/breadcrumb.d.ts +0 -8
  177. package/es/breadcrumb.js +0 -40
  178. package/es/dialog/index.less +0 -16
  179. package/es/pro-grid/index.d.ts +0 -15
  180. package/es/pro-grid/index.js +0 -58
  181. package/es/trigger/index.d.ts +0 -43
  182. package/es/trigger/index.js +0 -298
  183. package/es/trigger/index.less +0 -42
  184. package/es/virtual-list/index.d.ts +0 -51
  185. package/es/virtual-list/index.js +0 -132
package/es/config.js CHANGED
@@ -1,9 +1,13 @@
1
1
  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
+ var _excluded = ["theme", "prefixCls"],
3
+ _excluded2 = ["token", "components"];
2
4
  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; }
3
5
  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; }
4
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; }
5
7
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
8
  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); }
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; }
7
11
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
12
  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
13
  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); }
@@ -13,7 +17,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
17
  import { darkTheme, defaultTheme } from '@ant-design/compatible';
14
18
  import { theme as antTheme, App, ConfigProvider, message, Modal, notification } from 'antd';
15
19
  import zhCN from 'antd/locale/zh_CN';
16
- import React, { useState } from 'react';
20
+ import { insertCss } from 'insert-css';
21
+ import React, { useEffect, useState } from 'react';
17
22
  import { AppConfigContext } from "./context";
18
23
  import { DialogElementsHolder } from "./dialog/hook";
19
24
  import ThemeDialog from "./theme-dialog";
@@ -52,11 +57,24 @@ function AppConfig(_ref) {
52
57
  theme = _ref$theme === void 0 ? 'light' : _ref$theme,
53
58
  isCompact = _ref.isCompact,
54
59
  watermark = _ref.watermark,
55
- themeConfig = _ref.themeConfig,
60
+ antConfig = _ref.antConfig,
56
61
  fieldNames = _ref.fieldNames;
57
62
  var dialogHolderRef = React.useRef(null);
58
63
  // 主题
59
64
  var appTheme = theme === 'dark' ? darkTheme : defaultTheme;
65
+ var _ref2 = antConfig || {},
66
+ themeConfig = _ref2.theme,
67
+ _ref2$prefixCls = _ref2.prefixCls,
68
+ prefixCls = _ref2$prefixCls === void 0 ? 'ant' : _ref2$prefixCls,
69
+ otherAntConfig = _objectWithoutProperties(_ref2, _excluded);
70
+
71
+ // 传入的配置参数
72
+ var _ref3 = themeConfig || {},
73
+ token = _ref3.token,
74
+ components = _ref3.components,
75
+ otherThemeConfig = _objectWithoutProperties(_ref3, _excluded2);
76
+
77
+ // 主题算法
60
78
  var algorithm = function algorithm() {
61
79
  var algorithms = theme === 'dark' ? [antTheme.darkAlgorithm] : [antTheme.defaultAlgorithm];
62
80
  if (isCompact) {
@@ -64,23 +82,27 @@ function AppConfig(_ref) {
64
82
  }
65
83
  return algorithms;
66
84
  };
85
+ useEffect(function () {
86
+ var csss = [".".concat(prefixCls, "-drawer .").concat(prefixCls, "-drawer-extra >.").concat(prefixCls, "-btn+.").concat(prefixCls, "-btn {margin-inline-start: 8px;}"), ".ccs-dialog-drawer .".concat(prefixCls, "-drawer-footer{padding:0 !important;}"), ".ccs-tabs-auto-height > .".concat(prefixCls, "-tabs-content-holder,\n .ccs-tabs-auto-height > .").concat(prefixCls, "-tabs-content-holder > .").concat(prefixCls, "-tabs-content,\n .ccs-tabs-auto-height > .").concat(prefixCls, "-tabs-content-holder > .").concat(prefixCls, "-tabs-content > div,\n .ccs-tabs-auto-height> .").concat(prefixCls, "-tabs-content-holder> .").concat(prefixCls, "-tabs-content> div> .ccs-pl { height: 100%;}"), ".ccs-keep-alive-nav .".concat(prefixCls, "-tabs-tab {border: 0 !important;border-radius: 0 !important;}"), ".ccs-keep-alive-nav .".concat(prefixCls, "-tabs-tab-active {background-color: #f0f2f5 !important;}"), ".ccs-keep-alive .dark .ccs-keep-alive-nav .".concat(prefixCls, "-tabs-tab-active {background-color: #2b2c2c !important;} "), ".ccs-pl .".concat(prefixCls, "-table-title {padding: 0 !important;} ")];
87
+ insertCss(csss.join(''));
88
+ }, []);
67
89
 
68
90
  // 合并token
69
- var token = _objectSpread(_objectSpread({}, appTheme.token), themeConfig === null || themeConfig === void 0 ? void 0 : themeConfig.token);
70
-
91
+ var newToken = _objectSpread(_objectSpread({}, appTheme.token), token);
71
92
  // 暗黑模式背景色
72
- if (theme === 'dark') token.colorBgContainer = 'rgb(36, 37, 37)';
73
- return /*#__PURE__*/_jsx(ConfigProvider, {
93
+ if (theme === 'dark') newToken.colorBgContainer = 'rgb(36, 37, 37)';
94
+ return /*#__PURE__*/_jsx(ConfigProvider, _objectSpread(_objectSpread({
74
95
  locale: zhCN,
75
- theme: _objectSpread(_objectSpread({}, appTheme), {}, {
76
- token: token,
77
- components: _objectSpread(_objectSpread({}, appTheme.components), themeConfig === null || themeConfig === void 0 ? void 0 : themeConfig.components),
96
+ prefixCls: prefixCls
97
+ }, otherAntConfig), {}, {
98
+ theme: _objectSpread(_objectSpread(_objectSpread({}, appTheme), otherThemeConfig), {}, {
99
+ token: newToken,
100
+ components: _objectSpread(_objectSpread({}, appTheme.components), components),
78
101
  algorithm: algorithm()
79
102
  }),
80
103
  children: /*#__PURE__*/_jsxs(AppConfigContext.Provider, {
81
104
  value: {
82
105
  theme: theme,
83
- themeConfig: themeConfig,
84
106
  dialogHolderRef: dialogHolderRef,
85
107
  fieldNames: fieldNames
86
108
  },
@@ -92,7 +114,7 @@ function AppConfig(_ref) {
92
114
  zIndex: 105
93
115
  })]
94
116
  })
95
- });
117
+ }));
96
118
  }
97
119
  export default function CssAppConfig(props) {
98
120
  return /*#__PURE__*/_jsx(App, {
@@ -1,4 +1,4 @@
1
- import { TabPaneProps, ThemeConfig } from 'antd';
1
+ import { ConfigProviderProps, TabPaneProps } from 'antd';
2
2
  import { Store } from 'antd/es/form/interface';
3
3
  import React from 'react';
4
4
  import { Location } from 'react-router';
@@ -90,7 +90,7 @@ type CssAppConfigType = {
90
90
  /** 主题 */
91
91
  theme?: 'dark' | 'light' | 'colorful';
92
92
  /** 主题参数配置 */
93
- themeConfig?: ThemeConfig;
93
+ antConfig?: ConfigProviderProps;
94
94
  /** 紧凑模式 */
95
95
  isCompact?: boolean;
96
96
  /** 全局水印 */
@@ -12,6 +12,25 @@ import { DatePicker } from 'antd';
12
12
  import dayjs from 'dayjs';
13
13
  import _isArray from 'lodash.isarray';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
+ var rangePresets = [{
16
+ label: '今天',
17
+ value: [dayjs().startOf('day'), dayjs().endOf('day')]
18
+ }, {
19
+ label: '最近3天',
20
+ value: [dayjs().add(-3, 'd'), dayjs()]
21
+ }, {
22
+ label: '最近7天',
23
+ value: [dayjs().add(-7, 'd'), dayjs()]
24
+ }, {
25
+ label: '最近14天',
26
+ value: [dayjs().add(-14, 'd'), dayjs()]
27
+ }, {
28
+ label: '最近30天',
29
+ value: [dayjs().add(-30, 'd'), dayjs()]
30
+ }, {
31
+ label: '最近90天',
32
+ value: [dayjs().add(-90, 'd'), dayjs()]
33
+ }];
15
34
  function CcsDatePicker(_ref) {
16
35
  var value = _ref.value,
17
36
  onChange = _ref.onChange,
@@ -41,6 +60,7 @@ function RangePicker(_ref2) {
41
60
  if (onChange) onChange(dateString || undefined);
42
61
  };
43
62
  return /*#__PURE__*/_jsx(DatePicker.RangePicker, _objectSpread({
63
+ presets: restProps.picker === 'date' || !restProps.picker ? rangePresets : undefined,
44
64
  value: getDateValue(),
45
65
  onChange: handleOnChange
46
66
  }, restProps));
@@ -16,7 +16,7 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
16
16
  export type DialogButtonRef = {
17
17
  onSetButtons: (e: React.ReactElement) => void;
18
18
  };
19
- export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "onClose" | "auth" | "onOk" | "request" | "extraBtn" | "requestFieldNames" | "preventRequestHandle"> & {
19
+ export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "onOk" | "onClose" | "request" | "auth" | "extraBtn" | "requestFieldNames" | "preventRequestHandle"> & {
20
20
  formRef: React.RefObject<DialogFormRef<TParams>>;
21
21
  formInitialValues: FormProps['initialValues'];
22
22
  buttonRef: RefObject<DialogButtonRef>;
@@ -13,12 +13,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
13
13
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
14
  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; } }
15
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
- import { CcsButton } from "./..";
16
+ import { CcsButton } from '@ccs-ui/rc-pro';
17
17
  import { Button, Form } from 'antd';
18
18
  import React, { useEffect, useImperativeHandle, useState } from 'react';
19
19
  import CcsDialog from '.';
20
20
  import { useDialogFields } from "../hooks/use-app";
21
- import { getDataFromFields } from "../select";
21
+ import { getDataByNamePath } from "../select";
22
22
  import { jsx as _jsx } from "react/jsx-runtime";
23
23
  import { Fragment as _Fragment } from "react/jsx-runtime";
24
24
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -110,9 +110,9 @@ export var DialogButtonHolder = function DialogButtonHolder(_ref) {
110
110
  var fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), requestFieldNames);
111
111
 
112
112
  // 获取成功标识
113
- var success = getDataFromFields(result, fieldNames.success);
113
+ var success = getDataByNamePath(result, fieldNames.success);
114
114
  // 获取异常信息
115
- var msg = getDataFromFields(result, fieldNames.errorMsg);
115
+ var msg = getDataByNamePath(result, fieldNames.errorMsg);
116
116
  if (success === fieldNames.successTag) {
117
117
  // 关闭对话框
118
118
  onHandleClose(values, result);
@@ -3,7 +3,6 @@ import CcsDialogFooter from './button';
3
3
  import { useDialogContext } from './context';
4
4
  import CcsDrawerFooter from './drawer-footer';
5
5
  import useCcsDialog from './hook';
6
- import './index.less';
7
6
  type DialogInterface = {
8
7
  /** 获取openModal,openDrawer方法 */
9
8
  useDialog: typeof useCcsDialog;
@@ -3,7 +3,6 @@ import CcsDialogFooter from "./button";
3
3
  import { useDialogContext } from "./context";
4
4
  import CcsDrawerFooter from "./drawer-footer";
5
5
  import useCcsDialog from "./hook";
6
- import "./index.less";
7
6
  var CcsDialog = ThemeDialog;
8
7
  CcsDialog.Buttons = CcsDialogFooter;
9
8
  CcsDialog.useDialog = useCcsDialog;
@@ -114,8 +114,10 @@ var Ellipsis = function Ellipsis(p) {
114
114
  },
115
115
  placement: "bottomLeft",
116
116
  destroyTooltipOnHide: true,
117
- overlayInnerStyle: {
118
- whiteSpace: 'normal'
117
+ styles: {
118
+ body: {
119
+ whiteSpace: 'normal'
120
+ }
119
121
  },
120
122
  children: renderNode
121
123
  });
@@ -1,28 +1,14 @@
1
- import { useIsomorphicLayoutEffect, useMemoizedFn } from 'ahooks';
1
+ import { useDebounceEffect, useMemoizedFn, useSize } from 'ahooks';
2
2
  import { useRef } from 'react';
3
3
  export function useResizeEffect(effect, targetRef) {
4
- var ref = useRef(0);
5
4
  var fn = useMemoizedFn(effect);
6
- useIsomorphicLayoutEffect(function () {
7
- var target = targetRef.current;
8
- if (!target) return;
9
- if (window.ResizeObserver) {
10
- var animationFrame;
11
- var observer = new ResizeObserver(function () {
12
- // 隐藏了,为0不处理
13
- if (target.clientWidth === 0 || (target === null || target === void 0 ? void 0 : target.clientWidth) === ref.current) return;
14
- animationFrame = window.requestAnimationFrame(function () {
15
- return fn(target);
16
- });
17
- ref.current = target === null || target === void 0 ? void 0 : target.clientWidth;
18
- });
19
- observer.observe(target);
20
- return function () {
21
- window.cancelAnimationFrame(animationFrame);
22
- observer.disconnect();
23
- };
24
- } else {
25
- fn(target);
26
- }
27
- }, [targetRef]);
5
+ var widthRef = useRef();
6
+ var size = useSize(targetRef);
7
+ useDebounceEffect(function () {
8
+ if ((size === null || size === void 0 ? void 0 : size.width) === 0 || (size === null || size === void 0 ? void 0 : size.width) === widthRef.current) return;
9
+ fn(targetRef.current);
10
+ widthRef.current = size === null || size === void 0 ? void 0 : size.width;
11
+ }, [size === null || size === void 0 ? void 0 : size.width], {
12
+ wait: 500
13
+ });
28
14
  }
@@ -0,0 +1,11 @@
1
+ import { FormItemProps } from 'antd';
2
+ import { NamePath } from 'antd/es/form/interface';
3
+ export type GroupFormItemProps = FormItemProps & {
4
+ /** 组表单项名称 */
5
+ groupItemNames: NamePath[];
6
+ };
7
+ declare function GroupFormItem({ groupItemNames, name, ...formItemProps }: GroupFormItemProps): import("react/jsx-runtime").JSX.Element;
8
+ declare namespace GroupFormItem {
9
+ var displayName: string;
10
+ }
11
+ export default GroupFormItem;
@@ -0,0 +1,124 @@
1
+ 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
+ var _excluded = ["groupItemNames", "name"];
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+ 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."); }
10
+ 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; } }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
15
+ 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."); }
16
+ 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
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
18
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
19
+ 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; }
20
+ import { useUpdateEffect } from 'ahooks';
21
+ import { Form } from 'antd';
22
+ import { useEffect, useState } from 'react';
23
+ import { getDataByNamePath } from "../select";
24
+ import { jsx as _jsx } from "react/jsx-runtime";
25
+ import { Fragment as _Fragment } from "react/jsx-runtime";
26
+ import { jsxs as _jsxs } from "react/jsx-runtime";
27
+ var FormUpdateItem = function FormUpdateItem(_ref) {
28
+ var name = _ref.name,
29
+ getFieldsValue = _ref.getFieldsValue,
30
+ setFieldValue = _ref.setFieldValue,
31
+ getFieldValue = _ref.getFieldValue,
32
+ groupItemNames = _ref.groupItemNames;
33
+ var nameValue = getFieldValue(name);
34
+ useEffect(function () {
35
+ // 初始值
36
+ var initialValues = getFieldsValue(true);
37
+ var initNameValue = [];
38
+
39
+ // 根据子项初始值设置name的默认值
40
+ groupItemNames.forEach(function (item) {
41
+ initNameValue.push(getDataByNamePath(initialValues, item));
42
+ });
43
+
44
+ // 如果子项有初始值,则设置name的默认值
45
+ if (initNameValue.filter(function (n) {
46
+ return n !== undefined;
47
+ }).length > 0) {
48
+ setFieldValue(name, initNameValue);
49
+ return;
50
+ }
51
+
52
+ // 如果子项没有初始值,主项有初始值
53
+ var groupNameValue = getDataByNamePath(initialValues, name);
54
+ if (Array.isArray(groupNameValue)) {
55
+ groupItemNames.forEach(function (item, index) {
56
+ setFieldValue(item, groupNameValue[index]);
57
+ });
58
+ }
59
+ }, []);
60
+
61
+ // 依赖主字段变更,更新子项属性值
62
+ useUpdateEffect(function () {
63
+ setTimeout(function () {
64
+ groupItemNames.forEach(function (item, index) {
65
+ setFieldValue(item, Array.isArray(nameValue) ? nameValue[index] : undefined);
66
+ });
67
+ }, 1);
68
+ }, [nameValue]);
69
+ return null;
70
+ };
71
+ function onGetNameValue() {
72
+ var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
73
+ var name = arguments.length > 1 ? arguments[1] : undefined;
74
+ if (!obj) return undefined;
75
+ if (Array.isArray(name)) {
76
+ var names = _toConsumableArray(name);
77
+ var newName = names.shift();
78
+ if (names.length === 0) return obj[newName];
79
+ return onGetNameValue(obj[newName], names);
80
+ }
81
+ return obj[name];
82
+ }
83
+ function GroupFormItem(_ref2) {
84
+ var groupItemNames = _ref2.groupItemNames,
85
+ name = _ref2.name,
86
+ formItemProps = _objectWithoutProperties(_ref2, _excluded);
87
+ var _useState = useState(name || "_".concat(JSON.stringify(groupItemNames).replace(/[^a-zA-Z]/g, ''), "_")),
88
+ _useState2 = _slicedToArray(_useState, 1),
89
+ itemName = _useState2[0];
90
+ return /*#__PURE__*/_jsxs(_Fragment, {
91
+ children: [/*#__PURE__*/_jsx(Form.Item, _objectSpread({
92
+ name: itemName
93
+ }, formItemProps)), groupItemNames && groupItemNames.length > 0 && /*#__PURE__*/_jsxs(_Fragment, {
94
+ children: [/*#__PURE__*/_jsx(Form.Item, {
95
+ noStyle: true,
96
+ shouldUpdate: function shouldUpdate(l, r) {
97
+ return onGetNameValue(l, itemName) !== onGetNameValue(r, itemName);
98
+ },
99
+ children: function children(_ref3) {
100
+ var getFieldsValue = _ref3.getFieldsValue,
101
+ setFieldValue = _ref3.setFieldValue,
102
+ getFieldValue = _ref3.getFieldValue;
103
+ return /*#__PURE__*/_jsx(FormUpdateItem, {
104
+ getFieldsValue: getFieldsValue,
105
+ setFieldValue: setFieldValue,
106
+ getFieldValue: getFieldValue,
107
+ groupItemNames: groupItemNames,
108
+ name: itemName
109
+ });
110
+ }
111
+ }), groupItemNames.map(function (item, index) {
112
+ return /*#__PURE__*/_jsx(Form.Item, {
113
+ noStyle: true,
114
+ name: item,
115
+ hidden: true
116
+ }, index);
117
+ })]
118
+ })]
119
+ });
120
+ }
121
+ if (process.env.NODE_ENV !== 'production') {
122
+ GroupFormItem.displayName = 'CcsGroupFormItem';
123
+ }
124
+ export default GroupFormItem;
@@ -3,7 +3,7 @@ declare const usePage: () => {
3
3
  id: string;
4
4
  location: import("react-router").Location<any>;
5
5
  isActive: boolean;
6
- dialogHolderRef: import("react").RefObject<import("../dialog/hook").ElementsHolderRef>;
6
+ dialogHolderRef: import("react").RefObject<import("@ccs-ui/packages/rc-pro/src/dialog/hook").ElementsHolderRef>;
7
7
  onDestroy: (path: string) => void;
8
8
  onAuth: (code: string) => boolean;
9
9
  };
@@ -1,28 +1,17 @@
1
- import { RowSelectMethod } from 'antd/es/table/interface';
1
+ import { SelectProps } from 'antd';
2
+ import { TableRowSelection } from 'antd/es/table/interface';
2
3
  import React from 'react';
3
- interface PropsType<T> {
4
- /** 表单受控 value */
5
- value?: any[];
4
+ type PropsType<T> = Pick<SelectProps, 'value' | 'onChange'> & Omit<TableRowSelection<T>, 'value' | 'onChange' | 'renderCell'> & {
5
+ /** rowKey 字段,选中key值 */
6
+ keyField: string;
6
7
  /** 默认选择行数据,一般用于回显数据 */
7
8
  defaultRows?: T[];
8
- /** 是否多选 */
9
- multiple?: boolean;
10
- /** 字段配置,默认 { key: 'key'; label: 'label' } */
11
- keyField: string;
12
- /** 表单受控 onChange*/
13
- onChange?: (value: any) => void;
14
- /** 设置选项 */
15
- onChangeOptions?: (options: any[]) => void;
16
- }
17
- export default function useTableSelection<T = any>(props: PropsType<T>): {
18
- onChange: (keys: React.Key[], rows: T[], info: {
19
- type: RowSelectMethod;
20
- }) => void;
21
- onClear: (key?: React.Key) => void;
22
- selectedRowKeys?: React.Key[] | undefined;
23
- selectedRows?: T[] | undefined;
24
- info: {
25
- type: RowSelectMethod;
26
- };
9
+ /** 选中行数据回调 */
10
+ onChangeRows?: (options: any[]) => void;
27
11
  };
12
+ interface ReturnType<T> extends Omit<TableRowSelection<T>, 'renderCell'> {
13
+ selectedRows?: T[];
14
+ onClear: (key?: React.Key) => void;
15
+ }
16
+ export default function useTableSelection<T = any>(props: PropsType<T>): ReturnType<T>;
28
17
  export {};
@@ -1,15 +1,18 @@
1
+ var _excluded = ["value", "type", "defaultRows", "keyField", "onChangeRows", "onChange"];
1
2
  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; }
2
3
  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; }
3
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; }
4
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
6
  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); }
6
- 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); }
7
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
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
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
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
11
  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; } }
12
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
+ 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); }
13
16
  import { useMemoizedFn, useUpdateEffect } from 'ahooks';
14
17
  import { useEffect, useRef, useState } from 'react';
15
18
  // 判断相对
@@ -21,34 +24,53 @@ function isEq(obj1, obj2) {
21
24
  }
22
25
  return JSON.stringify(o1) !== JSON.stringify(o2);
23
26
  }
27
+ function onGetKeys(value, keyField) {
28
+ if (value === undefined) return value;
29
+ if (Array.isArray(value)) {
30
+ return value.map(function (item) {
31
+ return _typeof(item) === 'object' ? item[keyField] : item;
32
+ });
33
+ }
34
+ if (_typeof(value) === 'object') {
35
+ return value[keyField];
36
+ }
37
+ return [value];
38
+ }
24
39
  export default function useTableSelection(props) {
25
40
  var _ref = props || {},
26
41
  value = _ref.value,
42
+ _ref$type = _ref.type,
43
+ type = _ref$type === void 0 ? 'checkbox' : _ref$type,
27
44
  defaultRows = _ref.defaultRows,
28
45
  _ref$keyField = _ref.keyField,
29
46
  keyField = _ref$keyField === void 0 ? 'key' : _ref$keyField,
30
- multiple = _ref.multiple,
47
+ onChangeRows = _ref.onChangeRows,
31
48
  onChangeValue = _ref.onChange,
32
- onChangeOptions = _ref.onChangeOptions;
49
+ rowSelectionProps = _objectWithoutProperties(_ref, _excluded);
33
50
  var _useState = useState({}),
34
51
  _useState2 = _slicedToArray(_useState, 2),
35
52
  setUpdate = _useState2[1];
36
53
  var selectionRef = useRef({
37
- selectedRowKeys: ['number', 'string'].includes(_typeof(value)) ? [value] : value,
54
+ selectedRowKeys: onGetKeys(value, keyField),
38
55
  selectedRows: defaultRows,
39
56
  info: {
40
57
  type: 'none'
41
58
  }
42
59
  });
60
+ var isMultiple = type === 'checkbox';
43
61
  var handleOnChange = useMemoizedFn(function () {
44
- var _selectionRef$current = selectionRef.current.selectedRowKeys,
45
- selectedRowKeys = _selectionRef$current === void 0 ? [] : _selectionRef$current;
46
- if (multiple) {
62
+ var _selectionRef$current = selectionRef.current,
63
+ _selectionRef$current2 = _selectionRef$current.selectedRowKeys,
64
+ selectedRowKeys = _selectionRef$current2 === void 0 ? [] : _selectionRef$current2,
65
+ _selectionRef$current3 = _selectionRef$current.selectedRows,
66
+ selectedRows = _selectionRef$current3 === void 0 ? [] : _selectionRef$current3;
67
+ if (isMultiple) {
47
68
  // 受控调用onChange
48
- onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys);
69
+ onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys, selectedRows);
49
70
  } else {
50
- onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys[0]);
71
+ onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys[0], selectedRows[0]);
51
72
  }
73
+ onChangeRows === null || onChangeRows === void 0 || onChangeRows(selectedRows || []);
52
74
  if (!onChangeValue) setUpdate({});
53
75
  });
54
76
 
@@ -58,22 +80,23 @@ export default function useTableSelection(props) {
58
80
  selectionRef.current.selectedRows = defaultRows;
59
81
 
60
82
  // 生成选项
61
- if (onChangeOptions) onChangeOptions(defaultRows);
83
+ if (onChangeRows) onChangeRows(defaultRows);
62
84
  setUpdate({});
63
85
  }
64
86
  }, [defaultRows]);
65
87
 
66
88
  // value 变更,与当前选中数据不匹配
67
89
  useUpdateEffect(function () {
68
- if (isEq(value, selectionRef.current.selectedRowKeys)) {
69
- var _selectionRef$current2;
70
- var rows = (_selectionRef$current2 = selectionRef.current.selectedRows) === null || _selectionRef$current2 === void 0 ? void 0 : _selectionRef$current2.filter(function () {
90
+ var newValue = onGetKeys(value, keyField);
91
+ if (isEq(newValue, selectionRef.current.selectedRowKeys)) {
92
+ var _selectionRef$current4;
93
+ var rows = (_selectionRef$current4 = selectionRef.current.selectedRows) === null || _selectionRef$current4 === void 0 ? void 0 : _selectionRef$current4.filter(function () {
71
94
  var _ref2;
72
95
  var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
73
- return (_ref2 = value || []) === null || _ref2 === void 0 ? void 0 : _ref2.includes(row[keyField]);
96
+ return (_ref2 = newValue || []) === null || _ref2 === void 0 ? void 0 : _ref2.includes(row[keyField]);
74
97
  });
75
98
  selectionRef.current = {
76
- selectedRowKeys: value,
99
+ selectedRowKeys: newValue === undefined && isMultiple ? [] : newValue,
77
100
  selectedRows: rows,
78
101
  info: {
79
102
  type: 'none'
@@ -101,7 +124,6 @@ export default function useTableSelection(props) {
101
124
  }
102
125
  });
103
126
  }
104
- onChangeOptions === null || onChangeOptions === void 0 || onChangeOptions(rows);
105
127
  handleOnChange();
106
128
  });
107
129
 
@@ -110,18 +132,18 @@ export default function useTableSelection(props) {
110
132
  // 未传入key,删除全部
111
133
  if (!key) {
112
134
  selectionRef.current = {
113
- selectedRowKeys: undefined,
114
- selectedRows: undefined,
135
+ selectedRowKeys: [],
136
+ selectedRows: [],
115
137
  info: {
116
138
  type: 'none'
117
139
  }
118
140
  };
119
141
  } else {
120
- var _selectionRef$current3 = selectionRef.current,
121
- _selectionRef$current4 = _selectionRef$current3.selectedRowKeys,
122
- selectedRowKeys = _selectionRef$current4 === void 0 ? [] : _selectionRef$current4,
123
- _selectionRef$current5 = _selectionRef$current3.selectedRows,
124
- selectedRows = _selectionRef$current5 === void 0 ? [] : _selectionRef$current5;
142
+ var _selectionRef$current5 = selectionRef.current,
143
+ _selectionRef$current6 = _selectionRef$current5.selectedRowKeys,
144
+ selectedRowKeys = _selectionRef$current6 === void 0 ? [] : _selectionRef$current6,
145
+ _selectionRef$current7 = _selectionRef$current5.selectedRows,
146
+ selectedRows = _selectionRef$current7 === void 0 ? [] : _selectionRef$current7;
125
147
  var newRows = selectedRows.filter(function () {
126
148
  var r = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
127
149
  return r[keyField] !== key;
@@ -139,8 +161,12 @@ export default function useTableSelection(props) {
139
161
  }
140
162
  handleOnChange();
141
163
  });
142
- return _objectSpread(_objectSpread({}, selectionRef.current), {}, {
164
+ return _objectSpread(_objectSpread(_objectSpread({}, selectionRef.current), {}, {
143
165
  onChange: onChange,
144
- onClear: onClear
166
+ onClear: onClear,
167
+ type: type
168
+ }, rowSelectionProps), {}, {
169
+ // @ts-ignore
170
+ onClearByProTable: onClear
145
171
  });
146
172
  }
package/es/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { default as CcsDialog } from './dialog';
9
9
  export { default as CcsEditor } from './editor';
10
10
  export { default as CcsEllipsis } from './ellipsis';
11
11
  export { default as CcsFullScreenButton } from './full-screen';
12
+ export { default as CcsGroupFormItem } from './group-form-item';
12
13
  export { default as useAppConfig } from './hooks/use-app';
13
14
  export { default as useCcsOnceEvent } from './hooks/use-once-event';
14
15
  export { default as useCcsPage } from './hooks/use-page';
@@ -19,7 +20,6 @@ export { default as CcsIntervalButton } from './interval-button';
19
20
  export { default as CcsKeepAliveTabs } from './layout-keep-alive';
20
21
  export { default as CcsSinglePage } from './layout-single-page';
21
22
  export { default as CcsLoading } from './loading';
22
- export { default as CcsProGrid } from './pro-grid';
23
23
  export { default as CcsProTable } from './pro-table';
24
24
  export { default as CcsProTabs } from './pro-tabs';
25
25
  export { default as CcsResizeObserver } from './resize-observer';
@@ -28,9 +28,7 @@ export { default as CcsSelect } from './select';
28
28
  export { default as CcsStatusTag } from './status-tag';
29
29
  export { default as CcsTable } from './table';
30
30
  export { default as CcsTimePicker } from './time-picker';
31
- export { default as CcsTrigger } from './trigger';
32
31
  export { default as CcsUpload } from './upload';
33
- export { default as CcsVirtualList } from './virtual-list';
34
32
  export { default as CcsWaterMark } from './water-mark';
35
33
  import * as CCS from './ccs';
36
34
  export default CCS;