@dtjoy/dt-design 1.0.6 → 1.0.8

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 (222) hide show
  1. package/esm/_util/easings.d.ts +1 -0
  2. package/esm/_util/easings.js +9 -0
  3. package/esm/_util/extendsObject.d.ts +4 -0
  4. package/esm/_util/extendsObject.js +17 -0
  5. package/esm/_util/gapSize.d.ts +3 -3
  6. package/esm/_util/getScroll.d.ts +3 -0
  7. package/esm/_util/getScroll.js +32 -0
  8. package/esm/_util/hooks/index.d.ts +4 -1
  9. package/esm/_util/hooks/index.js +4 -1
  10. package/esm/_util/hooks/useForceUpdate.d.ts +2 -0
  11. package/esm/_util/hooks/useForceUpdate.js +6 -0
  12. package/esm/_util/hooks/useOrientation.d.ts +2 -2
  13. package/esm/_util/hooks/useProxyImperativeHandle.d.ts +4 -0
  14. package/esm/_util/hooks/useProxyImperativeHandle.js +31 -0
  15. package/esm/_util/hooks/useSyncState.d.ts +3 -0
  16. package/esm/_util/hooks/useSyncState.js +20 -0
  17. package/esm/_util/index.d.ts +3 -3
  18. package/esm/_util/isNonNullable.d.ts +2 -2
  19. package/esm/_util/scrollTo.d.ts +10 -0
  20. package/esm/_util/scrollTo.js +38 -0
  21. package/esm/_util/type.d.ts +52 -52
  22. package/esm/_util/warning.d.ts +31 -31
  23. package/esm/_util/warning.js +5 -5
  24. package/esm/blockHeader/index.d.ts +50 -48
  25. package/esm/blockHeader/index.js +13 -15
  26. package/esm/blockHeader/style/index.d.ts +2 -2
  27. package/esm/blockHeader/style/index.less +143 -143
  28. package/esm/button/index.d.ts +10 -10
  29. package/esm/button/index.js +2 -2
  30. package/esm/button/style/index.d.ts +2 -2
  31. package/esm/collapsible/index.d.ts +102 -97
  32. package/esm/collapsible/index.js +53 -55
  33. package/esm/collapsible/style/index.d.ts +1 -1
  34. package/esm/collapsibleActionItems/index.d.ts +24 -24
  35. package/esm/collapsibleActionItems/index.js +2 -2
  36. package/esm/collapsibleActionItems/style/index.d.ts +2 -2
  37. package/esm/flex/index.d.ts +7 -7
  38. package/esm/flex/index.js +1 -1
  39. package/esm/flex/interface.d.ts +16 -16
  40. package/esm/flex/style/index.d.ts +2 -2
  41. package/esm/flex/style/index.less +76 -76
  42. package/esm/flex/utils.d.ts +7 -7
  43. package/esm/flex/utils.js +1 -1
  44. package/esm/formList/index.d.ts +78 -77
  45. package/esm/formList/index.js +13 -11
  46. package/esm/formList/style/index.d.ts +2 -2
  47. package/esm/formList/style/index.less +45 -45
  48. package/esm/index.d.ts +17 -14
  49. package/esm/index.js +3 -1
  50. package/esm/overflowList/index.d.ts +40 -39
  51. package/esm/overflowList/index.js +4 -3
  52. package/esm/overflowList/style/index.d.ts +2 -2
  53. package/esm/resize/index.d.ts +9 -8
  54. package/esm/resize/index.js +1 -1
  55. package/esm/resizeObserver/index.d.ts +45 -45
  56. package/esm/resizeObserver/index.js +3 -2
  57. package/esm/splitter/Panel.d.ts +7 -7
  58. package/esm/splitter/Panel.js +3 -3
  59. package/esm/splitter/SplitBar.d.ts +24 -24
  60. package/esm/splitter/SplitBar.js +8 -7
  61. package/esm/splitter/Splitter.d.ts +5 -5
  62. package/esm/splitter/Splitter.js +5 -4
  63. package/esm/splitter/hooks/sizeUtil.d.ts +3 -3
  64. package/esm/splitter/hooks/useItems.d.ts +14 -14
  65. package/esm/splitter/hooks/useItems.js +2 -2
  66. package/esm/splitter/hooks/useResizable.d.ts +10 -10
  67. package/esm/splitter/hooks/useResize.d.ts +6 -6
  68. package/esm/splitter/hooks/useResize.js +5 -5
  69. package/esm/splitter/hooks/useSizes.d.ts +4 -4
  70. package/esm/splitter/index.d.ts +8 -8
  71. package/esm/splitter/interface.d.ts +69 -69
  72. package/esm/splitter/style/index.d.ts +2 -2
  73. package/esm/statusTag/index.d.ts +29 -28
  74. package/esm/statusTag/index.js +8 -8
  75. package/esm/statusTag/style/index.d.ts +2 -2
  76. package/esm/style/index.d.ts +1 -1
  77. package/esm/style/index.less +1 -1
  78. package/esm/style/themes/index.less +2 -2
  79. package/esm/style/themes/variable.less +4 -0
  80. package/esm/table/InternalTable.d.ts +32 -0
  81. package/esm/table/InternalTable.js +429 -0
  82. package/esm/table/RcTable/VirtualTable.d.ts +2 -0
  83. package/esm/table/RcTable/VirtualTable.js +9 -0
  84. package/esm/table/RcTable/index.d.ts +2 -0
  85. package/esm/table/RcTable/index.js +9 -0
  86. package/esm/table/Table.d.ts +17 -0
  87. package/esm/table/Table.js +28 -0
  88. package/esm/table/TableMeasureRowContext.d.ts +3 -0
  89. package/esm/table/TableMeasureRowContext.js +3 -0
  90. package/esm/table/hooks/useContainerWidth.d.ts +1 -0
  91. package/esm/table/hooks/useContainerWidth.js +14 -0
  92. package/esm/table/index.d.ts +7 -0
  93. package/esm/table/index.js +2 -0
  94. package/esm/table/interface.d.ts +196 -0
  95. package/esm/table/interface.js +4 -0
  96. package/esm/table/style/bordered.less +141 -0
  97. package/esm/table/style/fixed.less +88 -0
  98. package/esm/table/style/index.d.ts +2 -0
  99. package/esm/table/style/index.js +2 -0
  100. package/esm/table/style/index.less +150 -0
  101. package/esm/table/style/selection.less +90 -0
  102. package/esm/table/style/sticky.less +55 -0
  103. package/esm/table/style/virtual.less +65 -0
  104. package/esm/table/util.d.ts +14 -0
  105. package/esm/table/util.js +33 -0
  106. package/lib/_util/easings.d.ts +1 -0
  107. package/lib/_util/easings.js +15 -0
  108. package/lib/_util/extendsObject.d.ts +4 -0
  109. package/lib/_util/extendsObject.js +20 -0
  110. package/lib/_util/gapSize.d.ts +3 -3
  111. package/lib/_util/getScroll.d.ts +3 -0
  112. package/lib/_util/getScroll.js +39 -0
  113. package/lib/_util/hooks/index.d.ts +4 -1
  114. package/lib/_util/hooks/index.js +33 -0
  115. package/lib/_util/hooks/useForceUpdate.d.ts +2 -0
  116. package/lib/_util/hooks/useForceUpdate.js +12 -0
  117. package/lib/_util/hooks/useOrientation.d.ts +2 -2
  118. package/lib/_util/hooks/useProxyImperativeHandle.d.ts +4 -0
  119. package/lib/_util/hooks/useProxyImperativeHandle.js +40 -0
  120. package/lib/_util/hooks/useSyncState.d.ts +3 -0
  121. package/lib/_util/hooks/useSyncState.js +19 -0
  122. package/lib/_util/index.d.ts +3 -3
  123. package/lib/_util/isNonNullable.d.ts +2 -2
  124. package/lib/_util/scrollTo.d.ts +10 -0
  125. package/lib/_util/scrollTo.js +44 -0
  126. package/lib/_util/type.d.ts +52 -52
  127. package/lib/_util/warning.d.ts +31 -31
  128. package/lib/_util/warning.js +7 -8
  129. package/lib/blockHeader/index.d.ts +50 -48
  130. package/lib/blockHeader/index.js +13 -12
  131. package/lib/blockHeader/style/index.d.ts +2 -2
  132. package/lib/blockHeader/style/index.less +143 -143
  133. package/lib/button/index.d.ts +10 -10
  134. package/lib/button/index.js +2 -2
  135. package/lib/button/style/index.d.ts +2 -2
  136. package/lib/collapsible/index.d.ts +102 -97
  137. package/lib/collapsible/index.js +49 -49
  138. package/lib/collapsible/style/index.d.ts +1 -1
  139. package/lib/collapsibleActionItems/index.d.ts +24 -24
  140. package/lib/collapsibleActionItems/index.js +2 -2
  141. package/lib/collapsibleActionItems/style/index.d.ts +2 -2
  142. package/lib/flex/index.d.ts +7 -7
  143. package/lib/flex/index.js +2 -2
  144. package/lib/flex/interface.d.ts +16 -16
  145. package/lib/flex/style/index.d.ts +2 -2
  146. package/lib/flex/style/index.less +76 -76
  147. package/lib/flex/utils.d.ts +7 -7
  148. package/lib/flex/utils.js +2 -2
  149. package/lib/formList/index.d.ts +78 -77
  150. package/lib/formList/index.js +10 -10
  151. package/lib/formList/style/index.d.ts +2 -2
  152. package/lib/formList/style/index.less +45 -45
  153. package/lib/index.d.ts +17 -14
  154. package/lib/index.js +21 -2
  155. package/lib/overflowList/index.d.ts +40 -39
  156. package/lib/overflowList/index.js +4 -3
  157. package/lib/overflowList/style/index.d.ts +2 -2
  158. package/lib/resize/index.d.ts +9 -8
  159. package/lib/resize/index.js +1 -1
  160. package/lib/resizeObserver/index.d.ts +45 -45
  161. package/lib/resizeObserver/index.js +3 -2
  162. package/lib/splitter/Panel.d.ts +7 -7
  163. package/lib/splitter/Panel.js +3 -3
  164. package/lib/splitter/SplitBar.d.ts +24 -24
  165. package/lib/splitter/SplitBar.js +8 -7
  166. package/lib/splitter/Splitter.d.ts +5 -5
  167. package/lib/splitter/Splitter.js +5 -4
  168. package/lib/splitter/hooks/sizeUtil.d.ts +3 -3
  169. package/lib/splitter/hooks/useItems.d.ts +14 -14
  170. package/lib/splitter/hooks/useItems.js +2 -2
  171. package/lib/splitter/hooks/useResizable.d.ts +10 -10
  172. package/lib/splitter/hooks/useResize.d.ts +6 -6
  173. package/lib/splitter/hooks/useResize.js +5 -5
  174. package/lib/splitter/hooks/useSizes.d.ts +4 -4
  175. package/lib/splitter/index.d.ts +8 -8
  176. package/lib/splitter/interface.d.ts +69 -69
  177. package/lib/splitter/style/index.d.ts +2 -2
  178. package/lib/statusTag/index.d.ts +29 -28
  179. package/lib/statusTag/index.js +8 -8
  180. package/lib/statusTag/style/index.d.ts +2 -2
  181. package/lib/style/index.d.ts +1 -1
  182. package/lib/style/index.less +1 -1
  183. package/lib/style/themes/index.less +2 -2
  184. package/lib/style/themes/variable.less +4 -0
  185. package/lib/table/InternalTable.d.ts +32 -0
  186. package/lib/table/InternalTable.js +395 -0
  187. package/lib/table/RcTable/VirtualTable.d.ts +2 -0
  188. package/lib/table/RcTable/VirtualTable.js +17 -0
  189. package/lib/table/RcTable/index.d.ts +2 -0
  190. package/lib/table/RcTable/index.js +17 -0
  191. package/lib/table/Table.d.ts +17 -0
  192. package/lib/table/Table.js +37 -0
  193. package/lib/table/TableMeasureRowContext.d.ts +3 -0
  194. package/lib/{_util/zindexContext.js → table/TableMeasureRowContext.js} +2 -5
  195. package/lib/table/hooks/useContainerWidth.d.ts +1 -0
  196. package/lib/table/hooks/useContainerWidth.js +20 -0
  197. package/lib/table/index.d.ts +7 -0
  198. package/lib/table/index.js +9 -0
  199. package/lib/table/interface.d.ts +196 -0
  200. package/lib/table/interface.js +8 -0
  201. package/lib/table/style/bordered.less +141 -0
  202. package/lib/table/style/fixed.less +88 -0
  203. package/lib/table/style/index.d.ts +2 -0
  204. package/lib/table/style/index.js +4 -0
  205. package/lib/table/style/index.less +150 -0
  206. package/lib/table/style/selection.less +90 -0
  207. package/lib/table/style/sticky.less +55 -0
  208. package/lib/table/style/virtual.less +65 -0
  209. package/lib/table/util.d.ts +14 -0
  210. package/lib/table/util.js +44 -0
  211. package/package.json +82 -66
  212. package/esm/_util/convertToTooltipProps.d.ts +0 -4
  213. package/esm/_util/convertToTooltipProps.js +0 -15
  214. package/esm/_util/hooks/useZIndex.d.ts +0 -8
  215. package/esm/_util/hooks/useZIndex.js +0 -51
  216. package/esm/_util/zindexContext.d.ts +0 -3
  217. package/esm/_util/zindexContext.js +0 -6
  218. package/lib/_util/convertToTooltipProps.d.ts +0 -4
  219. package/lib/_util/convertToTooltipProps.js +0 -21
  220. package/lib/_util/hooks/useZIndex.d.ts +0 -8
  221. package/lib/_util/hooks/useZIndex.js +0 -59
  222. package/lib/_util/zindexContext.d.ts +0 -3
@@ -1,2 +1,2 @@
1
- import '../../style';
2
- import './index.less';
1
+ import '../../style';
2
+ import './index.less';
@@ -1,28 +1,29 @@
1
- import React, { CSSProperties, HTMLAttributes, ReactNode } from 'react';
2
- import './style';
3
- export declare const PRESET_COLOR_TYPES: readonly ["blue", "yellow", "green", "gray", "red", "purple", "cyan", "pink"];
4
- export declare const STATUS_TAG_TYPES: readonly ["default", "outline", "fill"];
5
- export declare type PresetColorType = (typeof PRESET_COLOR_TYPES)[number] | (string & {});
6
- export declare type StatusTagType = (typeof STATUS_TAG_TYPES)[number];
7
- export interface IStatusTagProps extends HTMLAttributes<HTMLDivElement> {
8
- /** 状态类型 */
9
- type?: StatusTagType;
10
- /** 是否圆角 */
11
- rounded?: boolean;
12
- /** 状态颜色(支持预设值/自定义十六进制/RGB) */
13
- color?: PresetColorType;
14
- /** 是否加载中 */
15
- loading?: boolean;
16
- /** 自定义图标 */
17
- icon?: ReactNode;
18
- /** 背景颜色(仅fill类型生效),未设置时使用color的0.15透明度 */
19
- background?: string;
20
- /** 类名 */
21
- className?: string;
22
- /** 子节点 */
23
- children?: ReactNode;
24
- /** 自定义样式 */
25
- style?: CSSProperties;
26
- }
27
- declare const StatusTag: React.FC<IStatusTagProps>;
28
- export default StatusTag;
1
+ import type { CSSProperties, HTMLAttributes, ReactNode } from 'react';
2
+ import React from 'react';
3
+ import './style';
4
+ export declare const PRESET_COLOR_TYPES: readonly ["blue", "yellow", "green", "gray", "red", "purple", "cyan", "pink"];
5
+ export declare const STATUS_TAG_TYPES: readonly ["default", "outline", "fill"];
6
+ export type PresetColorType = (typeof PRESET_COLOR_TYPES)[number] | (string & {});
7
+ export type StatusTagType = (typeof STATUS_TAG_TYPES)[number];
8
+ export interface IStatusTagProps extends HTMLAttributes<HTMLDivElement> {
9
+ /** 状态类型 */
10
+ type?: StatusTagType;
11
+ /** 是否圆角 */
12
+ rounded?: boolean;
13
+ /** 状态颜色(支持预设值/自定义十六进制/RGB) */
14
+ color?: PresetColorType;
15
+ /** 是否加载中 */
16
+ loading?: boolean;
17
+ /** 自定义图标 */
18
+ icon?: ReactNode;
19
+ /** 背景颜色(仅fill类型生效),未设置时使用color的0.15透明度 */
20
+ background?: string;
21
+ /** 类名 */
22
+ className?: string;
23
+ /** 子节点 */
24
+ children?: ReactNode;
25
+ /** 自定义样式 */
26
+ style?: CSSProperties;
27
+ }
28
+ declare const StatusTag: React.FC<IStatusTagProps>;
29
+ export default StatusTag;
@@ -8,8 +8,8 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _icons = require("@ant-design/icons");
9
9
  var _antd = require("antd");
10
10
  var _configProvider = require("antd/es/config-provider");
11
- var _classnames = _interopRequireDefault(require("classnames"));
12
11
  require("./style");
12
+ var _clsx = _interopRequireDefault(require("clsx"));
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -41,10 +41,10 @@ function calculateTransparentColor(color, opacity = DEFAULT_OPACITY) {
41
41
  if (hex.length === 3) {
42
42
  hex = hex.split('').map(char => char + char).join('');
43
43
  }
44
- if (!/^[0-9A-Fa-f]{6}$/.test(hex)) return 'rgba(0, 0, 0, 0.15)';
45
- const r = parseInt(hex.substring(0, 2), 16);
46
- const g = parseInt(hex.substring(2, 4), 16);
47
- const b = parseInt(hex.substring(4, 6), 16);
44
+ if (!/^[0-9A-F]{6}$/i.test(hex)) return 'rgba(0, 0, 0, 0.15)';
45
+ const r = Number.parseInt(hex.substring(0, 2), 16);
46
+ const g = Number.parseInt(hex.substring(2, 4), 16);
47
+ const b = Number.parseInt(hex.substring(4, 6), 16);
48
48
  return `rgba(${r}, ${g}, ${b}, ${opacity})`;
49
49
  }
50
50
  const StatusTag = /*#__PURE__*/_react.default.memo(props => {
@@ -62,7 +62,7 @@ const StatusTag = /*#__PURE__*/_react.default.memo(props => {
62
62
  } = props;
63
63
  const prefixCls = (0, _configProvider.globalConfig)().getPrefixCls('status-tag');
64
64
  const showDefaultIcon = (0, _react.useMemo)(() => icon === undefined, [icon]);
65
- const containerClasses = (0, _react.useMemo)(() => (0, _classnames.default)(prefixCls, className, {
65
+ const containerClasses = (0, _react.useMemo)(() => (0, _clsx.default)(prefixCls, className, {
66
66
  [`${prefixCls}--border`]: type === 'outline',
67
67
  [`${prefixCls}--fill`]: type === 'fill',
68
68
  [`${prefixCls}--rounded`]: rounded,
@@ -78,7 +78,7 @@ const StatusTag = /*#__PURE__*/_react.default.memo(props => {
78
78
  const iconStyleConfig = (0, _react.useMemo)(() => {
79
79
  if (isPresetColor(color)) {
80
80
  return {
81
- className: (0, _classnames.default)('anticon', {
81
+ className: (0, _clsx.default)('anticon', {
82
82
  [`${prefixCls}__${color}--icon`]: true,
83
83
  [`${prefixCls}__icon--default`]: !icon,
84
84
  [`${prefixCls}__${color}--iconBg`]: !icon
@@ -87,7 +87,7 @@ const StatusTag = /*#__PURE__*/_react.default.memo(props => {
87
87
  };
88
88
  }
89
89
  return {
90
- className: (0, _classnames.default)('anticon', {
90
+ className: (0, _clsx.default)('anticon', {
91
91
  [`${prefixCls}__icon--default`]: !icon
92
92
  }),
93
93
  style: {
@@ -1,2 +1,2 @@
1
- import '../../style/index.less';
2
- import './index.less';
1
+ import '../../style/index.less';
2
+ import './index.less';
@@ -1 +1 @@
1
- import './index.less';
1
+ import './index.less';
@@ -1 +1 @@
1
- @import "./themes/index.less";
1
+ @import "./themes/index.less";
@@ -1,2 +1,2 @@
1
- @import '~antd/es/style/themes/default.less';
2
- @import './variable.less';
1
+ @import '~antd/es/style/themes/default.less';
2
+ @import './variable.less';
@@ -1 +1,5 @@
1
1
  @primary-color-disabled: #f3f3f3;
2
+
3
+ @motion-duration-fast: 0.1s;
4
+ @motion-duration-mid: 0.2s;
5
+ @motion-duration-slow: 0.3s;
@@ -0,0 +1,32 @@
1
+ import type { TableProps as RcTableProps } from '@rc-component/table';
2
+ import type { SpinProps, TooltipProps } from 'antd';
3
+ import type { SizeType } from 'antd/lib/config-provider/SizeContext';
4
+ import type { FilterValue } from 'antd/lib/table/interface';
5
+ import './style';
6
+ import type { AnyObject } from '../_util/type';
7
+ import type { ColumnsType, GetPopupContainer, RefInternalTable, SorterResult, SortOrder, TableCurrentDataSource, TableLocale, TablePaginationConfig, TableRowSelection } from './interface';
8
+ export type { ColumnsType, TablePaginationConfig };
9
+ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, 'transformColumns' | 'internalHooks' | 'internalRefs' | 'data' | 'columns' | 'scroll' | 'emptyText'> {
10
+ dropdownPrefixCls?: string;
11
+ dataSource?: RcTableProps<RecordType>['data'];
12
+ columns?: ColumnsType<RecordType>;
13
+ pagination?: false | TablePaginationConfig;
14
+ loading?: boolean | SpinProps;
15
+ size?: SizeType;
16
+ bordered?: boolean;
17
+ locale?: TableLocale;
18
+ virtual?: boolean;
19
+ onChange?: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<RecordType> | SorterResult<RecordType>[], extra: TableCurrentDataSource<RecordType>) => void;
20
+ rowSelection?: TableRowSelection<RecordType>;
21
+ getPopupContainer?: GetPopupContainer;
22
+ scroll?: RcTableProps<RecordType>['scroll'] & {
23
+ scrollToFirstRowOnChange?: boolean;
24
+ };
25
+ sortDirections?: SortOrder[];
26
+ showSorterTooltip?: boolean | TooltipProps;
27
+ }
28
+ export interface InternalTableProps<RecordType = AnyObject> extends TableProps<RecordType> {
29
+ _renderTimes: number;
30
+ }
31
+ declare const _default: RefInternalTable;
32
+ export default _default;
@@ -0,0 +1,395 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _table = require("@rc-component/table");
9
+ var _useColumns = require("@rc-component/table/lib/hooks/useColumns");
10
+ var _antd = require("antd");
11
+ var _configProvider = require("antd/lib/config-provider");
12
+ var _defaultRenderEmpty = _interopRequireDefault(require("antd/lib/config-provider/defaultRenderEmpty"));
13
+ var _SizeContext = _interopRequireDefault(require("antd/lib/config-provider/SizeContext"));
14
+ var _useBreakpoint = _interopRequireDefault(require("antd/lib/grid/hooks/useBreakpoint"));
15
+ var _en_US = _interopRequireDefault(require("antd/lib/locale/en_US"));
16
+ var _ExpandIcon = _interopRequireDefault(require("antd/lib/table/ExpandIcon"));
17
+ var _useFilter = _interopRequireWildcard(require("antd/lib/table/hooks/useFilter"));
18
+ var _useLazyKVMap = _interopRequireDefault(require("antd/lib/table/hooks/useLazyKVMap"));
19
+ var _usePagination = _interopRequireWildcard(require("antd/lib/table/hooks/usePagination"));
20
+ var _useSelection = _interopRequireDefault(require("antd/lib/table/hooks/useSelection"));
21
+ var _useSorter = _interopRequireWildcard(require("antd/lib/table/hooks/useSorter"));
22
+ var _useTitleColumns = _interopRequireDefault(require("antd/lib/table/hooks/useTitleColumns"));
23
+ var _clsx = _interopRequireDefault(require("clsx"));
24
+ var _lodashEs = require("lodash-es");
25
+ require("./style");
26
+ var _hooks = require("../_util/hooks");
27
+ var _scrollTo = _interopRequireDefault(require("../_util/scrollTo"));
28
+ var _warning = require("../_util/warning");
29
+ var _useContainerWidth = _interopRequireDefault(require("./hooks/useContainerWidth"));
30
+ var _RcTable = _interopRequireDefault(require("./RcTable"));
31
+ var _VirtualTable = _interopRequireDefault(require("./RcTable/VirtualTable"));
32
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
33
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
34
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
36
+ const EMPTY_LIST = [];
37
+ const InternalTable = (props, ref) => {
38
+ const {
39
+ prefixCls: customizePrefixCls,
40
+ className,
41
+ style,
42
+ size: customizeSize,
43
+ bordered,
44
+ dropdownPrefixCls: customizeDropdownPrefixCls,
45
+ dataSource,
46
+ pagination,
47
+ rowSelection,
48
+ rowKey = 'key',
49
+ rowClassName,
50
+ columns,
51
+ children,
52
+ childrenColumnName: legacyChildrenColumnName,
53
+ onChange,
54
+ getPopupContainer,
55
+ loading,
56
+ expandIcon,
57
+ expandable,
58
+ expandedRowRender,
59
+ expandIconColumnIndex,
60
+ indentSize,
61
+ scroll,
62
+ sortDirections,
63
+ locale,
64
+ showSorterTooltip = true,
65
+ virtual
66
+ } = props;
67
+ const warning = (0, _warning.devUseWarning)('Table');
68
+ warning(!(typeof rowKey === 'function' && rowKey.length > 1), 'usage', '`index` parameter of `rowKey` function is deprecated. There is no guarantee that it will work as expected.');
69
+ [['filterDropdownVisible', 'filterDropdownOpen'], ['onFilterDropdownVisibleChange', 'onFilterDropdownOpenChange']].forEach(([deprecatedName, newName]) => {
70
+ warning(!(deprecatedName in props), 'usage', `\`${deprecatedName}\` is deprecated which will be removed in next major version.Please use \`${newName}\` instead. `);
71
+ });
72
+ const baseColumns = _react.default.useMemo(() => columns || (0, _useColumns.convertChildrenToColumns)(children), [columns, children]);
73
+ const needResponsive = _react.default.useMemo(() => baseColumns.some(col => col.responsive), [baseColumns]);
74
+ const screens = (0, _useBreakpoint.default)(needResponsive);
75
+ const mergedColumns = _react.default.useMemo(() => {
76
+ const matched = new Set(Object.keys(screens).filter(m => screens[m]));
77
+ return baseColumns.filter(c => !c.responsive || c.responsive.some(r => matched.has(r)));
78
+ }, [baseColumns, screens]);
79
+ const tableProps = (0, _lodashEs.omit)(props, ['className', 'style', 'columns']);
80
+ const size = _react.default.useContext(_SizeContext.default);
81
+ const {
82
+ locale: contextLocale = _en_US.default,
83
+ renderEmpty,
84
+ direction
85
+ } = _react.default.useContext(_configProvider.ConfigContext);
86
+ const mergedSize = customizeSize || size;
87
+ const tableLocale = {
88
+ ...contextLocale.Table,
89
+ ...locale
90
+ };
91
+ const rawData = dataSource || EMPTY_LIST;
92
+ const {
93
+ getPrefixCls
94
+ } = _react.default.useContext(_configProvider.ConfigContext);
95
+ const prefixCls = getPrefixCls('table', customizePrefixCls);
96
+ const dropdownPrefixCls = getPrefixCls('dropdown', customizeDropdownPrefixCls);
97
+ const mergedExpandable = {
98
+ childrenColumnName: legacyChildrenColumnName,
99
+ expandIconColumnIndex,
100
+ ...expandable
101
+ };
102
+ const {
103
+ childrenColumnName = 'children'
104
+ } = mergedExpandable;
105
+ const expandType = _react.default.useMemo(() => {
106
+ if (rawData.some(item => item?.[childrenColumnName])) {
107
+ return 'nest';
108
+ }
109
+ if (expandedRowRender || expandable && expandable.expandedRowRender) {
110
+ return 'row';
111
+ }
112
+ return null;
113
+ }, [rawData]);
114
+ const internalRefs = {
115
+ body: _react.default.useRef(null)
116
+ };
117
+
118
+ // ============================ Width =============================
119
+ const getContainerWidth = (0, _useContainerWidth.default)(prefixCls);
120
+
121
+ // ============================= Refs =============================
122
+ const rootRef = _react.default.useRef(null);
123
+ const tblRef = _react.default.useRef(null);
124
+ (0, _hooks.useProxyImperativeHandle)(ref, () => ({
125
+ ...tblRef.current,
126
+ nativeElement: rootRef.current
127
+ }));
128
+
129
+ // ========================== Render ==========================
130
+ const TableComponent = virtual ? _VirtualTable.default : _RcTable.default;
131
+
132
+ // ============================ RowKey ============================
133
+ const getRowKey = _react.default.useMemo(() => {
134
+ if (typeof rowKey === 'function') {
135
+ return rowKey;
136
+ }
137
+ return record => record?.[rowKey];
138
+ }, [rowKey]);
139
+ const [getRecordByKey] = (0, _useLazyKVMap.default)(rawData, childrenColumnName, getRowKey);
140
+
141
+ // ============================ Events =============================
142
+ const changeEventInfo = {};
143
+ const triggerOnChange = (info, action, reset = false) => {
144
+ const changeInfo = {
145
+ ...changeEventInfo,
146
+ ...info
147
+ };
148
+ if (reset) {
149
+ changeEventInfo.resetPagination();
150
+
151
+ // Reset event param
152
+ if (changeInfo.pagination.current) {
153
+ changeInfo.pagination.current = 1;
154
+ }
155
+
156
+ // Trigger pagination events
157
+ if (pagination && pagination.onChange) {
158
+ pagination.onChange(1, changeInfo.pagination.pageSize);
159
+ }
160
+ }
161
+ if (scroll && scroll.scrollToFirstRowOnChange !== false && internalRefs.body.current) {
162
+ (0, _scrollTo.default)(0, {
163
+ getContainer: () => internalRefs.body.current
164
+ });
165
+ }
166
+ onChange?.(changeInfo.pagination, changeInfo.filters, changeInfo.sorter, {
167
+ currentDataSource: (0, _useFilter.getFilterData)((0, _useSorter.getSortData)(rawData, changeInfo.sorterStates, childrenColumnName), changeInfo.filterStates),
168
+ action
169
+ });
170
+ };
171
+
172
+ /**
173
+ * Controlled state in `columns` is not a good idea that makes too many code (1000+ line?) to read
174
+ * state out and then put it back to title render. Move these code into `hooks` but still too
175
+ * complex. We should provides Table props like `sorter` & `filter` to handle control in next big
176
+ * version.
177
+ */
178
+
179
+ // ============================ Sorter =============================
180
+ const onSorterChange = (sorter, sorterStates) => {
181
+ triggerOnChange({
182
+ sorter,
183
+ sorterStates
184
+ }, 'sort', false);
185
+ };
186
+ const [transformSorterColumns, sortStates, sorterTitleProps, getSorters] = (0, _useSorter.default)({
187
+ prefixCls,
188
+ mergedColumns,
189
+ onSorterChange,
190
+ sortDirections: sortDirections || ['ascend', 'descend'],
191
+ tableLocale,
192
+ showSorterTooltip
193
+ });
194
+ const sortedData = _react.default.useMemo(() => (0, _useSorter.getSortData)(rawData, sortStates, childrenColumnName), [rawData, sortStates]);
195
+ changeEventInfo.sorter = getSorters();
196
+ changeEventInfo.sorterStates = sortStates;
197
+
198
+ // ============================ Filter ============================
199
+ const onFilterChange = (filters, filterStates) => {
200
+ triggerOnChange({
201
+ filters,
202
+ filterStates
203
+ }, 'filter', true);
204
+ };
205
+ const [transformFilterColumns, filterStates, filters] = (0, _useFilter.default)({
206
+ prefixCls,
207
+ locale: tableLocale,
208
+ dropdownPrefixCls,
209
+ mergedColumns,
210
+ onFilterChange,
211
+ getPopupContainer
212
+ });
213
+ const mergedData = (0, _useFilter.getFilterData)(sortedData, filterStates);
214
+ changeEventInfo.filters = filters;
215
+ changeEventInfo.filterStates = filterStates;
216
+
217
+ // ============================ Column ============================
218
+ const columnTitleProps = _react.default.useMemo(() => {
219
+ const mergedFilters = {};
220
+ Object.keys(filters).forEach(filterKey => {
221
+ if (filters[filterKey] !== null) {
222
+ mergedFilters[filterKey] = filters[filterKey];
223
+ }
224
+ });
225
+ return {
226
+ ...sorterTitleProps,
227
+ filters: mergedFilters
228
+ };
229
+ }, [sorterTitleProps, filters]);
230
+ const [transformTitleColumns] = (0, _useTitleColumns.default)(columnTitleProps);
231
+
232
+ // ========================== Pagination ==========================
233
+ const onPaginationChange = (current, pageSize) => {
234
+ triggerOnChange({
235
+ pagination: {
236
+ ...changeEventInfo.pagination,
237
+ current,
238
+ pageSize
239
+ }
240
+ }, 'paginate');
241
+ };
242
+ const [mergedPagination, resetPagination] = (0, _usePagination.default)(mergedData.length, pagination, onPaginationChange);
243
+ changeEventInfo.pagination = pagination === false ? {} : (0, _usePagination.getPaginationParam)(pagination, mergedPagination);
244
+ changeEventInfo.resetPagination = resetPagination;
245
+
246
+ // ============================= Data =============================
247
+ const pageData = _react.default.useMemo(() => {
248
+ if (pagination === false || !mergedPagination.pageSize) {
249
+ return mergedData;
250
+ }
251
+ const {
252
+ current = 1,
253
+ total,
254
+ pageSize = _usePagination.DEFAULT_PAGE_SIZE
255
+ } = mergedPagination;
256
+ warning(current > 0, 'usage', '`current` should be positive number.');
257
+
258
+ // Dynamic table data
259
+ if (mergedData.length < total) {
260
+ if (mergedData.length > pageSize) {
261
+ warning(false, 'usage', '`dataSource` length is less than `pagination.total` but large than `pagination.pageSize`. Please make sure your config correct data with async mode.');
262
+ return mergedData.slice((current - 1) * pageSize, current * pageSize);
263
+ }
264
+ return mergedData;
265
+ }
266
+ return mergedData.slice((current - 1) * pageSize, current * pageSize);
267
+ }, [!!pagination, mergedData, mergedPagination && mergedPagination.current, mergedPagination && mergedPagination.pageSize, mergedPagination && mergedPagination.total]);
268
+
269
+ // ========================== Selections ==========================
270
+ const [transformSelectionColumns, selectedKeySet] = (0, _useSelection.default)(rowSelection, {
271
+ prefixCls,
272
+ data: mergedData,
273
+ pageData,
274
+ getRowKey,
275
+ getRecordByKey,
276
+ expandType,
277
+ childrenColumnName,
278
+ locale: tableLocale,
279
+ getPopupContainer
280
+ });
281
+ const internalRowClassName = (record, index, indent) => {
282
+ let mergedRowClassName;
283
+ if (typeof rowClassName === 'function') {
284
+ mergedRowClassName = (0, _clsx.default)(rowClassName(record, index, indent));
285
+ } else {
286
+ mergedRowClassName = (0, _clsx.default)(rowClassName);
287
+ }
288
+ return (0, _clsx.default)({
289
+ [`${prefixCls}-row-selected`]: selectedKeySet.has(getRowKey(record, index))
290
+ }, mergedRowClassName);
291
+ };
292
+
293
+ // ========================== Expandable ==========================
294
+
295
+ // Pass origin render status into `rc-table`, this can be removed when refactor with `rc-table`
296
+ mergedExpandable.__PARENT_RENDER_ICON__ = mergedExpandable.expandIcon;
297
+
298
+ // Customize expandable icon
299
+ mergedExpandable.expandIcon = mergedExpandable.expandIcon || expandIcon || (0, _ExpandIcon.default)(tableLocale);
300
+
301
+ // Adjust expand icon index, no overwrite expandIconColumnIndex if set.
302
+ if (expandType === 'nest' && mergedExpandable.expandIconColumnIndex === undefined) {
303
+ mergedExpandable.expandIconColumnIndex = rowSelection ? 1 : 0;
304
+ } else if (mergedExpandable.expandIconColumnIndex > 0 && rowSelection) {
305
+ mergedExpandable.expandIconColumnIndex -= 1;
306
+ }
307
+
308
+ // Indent size
309
+ if (typeof mergedExpandable.indentSize !== 'number') {
310
+ mergedExpandable.indentSize = typeof indentSize === 'number' ? indentSize : 15;
311
+ }
312
+
313
+ // ============================ Render ============================
314
+ const transformColumns = _react.default.useCallback(innerColumns => transformTitleColumns(transformSelectionColumns(transformFilterColumns(transformSorterColumns(innerColumns)))), [transformSorterColumns, transformFilterColumns, transformSelectionColumns]);
315
+ let topPaginationNode;
316
+ let bottomPaginationNode;
317
+ if (pagination !== false && mergedPagination?.total) {
318
+ let paginationSize;
319
+ if (mergedPagination.size) {
320
+ paginationSize = mergedPagination.size;
321
+ } else {
322
+ paginationSize = mergedSize === 'small' || mergedSize === 'middle' ? 'small' : undefined;
323
+ }
324
+ const renderPagination = position => /*#__PURE__*/_react.default.createElement(_antd.Pagination, _extends({}, mergedPagination, {
325
+ className: (0, _clsx.default)(`${prefixCls}-pagination ${prefixCls}-pagination-${position}`, mergedPagination.className),
326
+ size: paginationSize
327
+ }));
328
+ const defaultPosition = direction === 'rtl' ? 'left' : 'right';
329
+ const {
330
+ position
331
+ } = mergedPagination;
332
+ if (position !== null && Array.isArray(position)) {
333
+ const topPos = position.find(p => p.includes('top'));
334
+ const bottomPos = position.find(p => p.includes('bottom'));
335
+ const isDisable = position.every(p => `${p}` === 'none');
336
+ if (!topPos && !bottomPos && !isDisable) {
337
+ bottomPaginationNode = renderPagination(defaultPosition);
338
+ }
339
+ if (topPos) {
340
+ topPaginationNode = renderPagination(topPos.toLowerCase().replace('top', ''));
341
+ }
342
+ if (bottomPos) {
343
+ bottomPaginationNode = renderPagination(bottomPos.toLowerCase().replace('bottom', ''));
344
+ }
345
+ } else {
346
+ bottomPaginationNode = renderPagination(defaultPosition);
347
+ }
348
+ }
349
+
350
+ // >>>>>>>>> Spinning
351
+ let spinProps;
352
+ if (typeof loading === 'boolean') {
353
+ spinProps = {
354
+ spinning: loading
355
+ };
356
+ } else if (typeof loading === 'object') {
357
+ spinProps = {
358
+ spinning: true,
359
+ ...loading
360
+ };
361
+ }
362
+ const wrapperClassNames = (0, _clsx.default)(`${prefixCls}-wrapper`, {
363
+ [`${prefixCls}-wrapper-rtl`]: direction === 'rtl'
364
+ }, className);
365
+ return /*#__PURE__*/_react.default.createElement("div", {
366
+ ref: rootRef,
367
+ className: wrapperClassNames,
368
+ style: style
369
+ }, /*#__PURE__*/_react.default.createElement(_antd.Spin, _extends({
370
+ spinning: false
371
+ }, spinProps), topPaginationNode, /*#__PURE__*/_react.default.createElement(TableComponent, _extends({}, tableProps, {
372
+ ref: tblRef,
373
+ columns: mergedColumns,
374
+ direction: direction,
375
+ expandable: mergedExpandable,
376
+ prefixCls: prefixCls,
377
+ className: (0, _clsx.default)({
378
+ [`${prefixCls}-middle`]: mergedSize === 'middle',
379
+ [`${prefixCls}-small`]: mergedSize === 'small',
380
+ [`${prefixCls}-bordered`]: bordered,
381
+ [`${prefixCls}-empty`]: rawData.length === 0
382
+ }),
383
+ data: pageData,
384
+ rowKey: getRowKey,
385
+ rowClassName: internalRowClassName,
386
+ emptyText: locale && locale.emptyText || (renderEmpty || _defaultRenderEmpty.default)('Table')
387
+ // Internal
388
+ ,
389
+ internalHooks: _table.INTERNAL_HOOKS,
390
+ internalRefs: internalRefs,
391
+ transformColumns: transformColumns,
392
+ getContainerWidth: getContainerWidth
393
+ })), bottomPaginationNode));
394
+ };
395
+ var _default = exports.default = /*#__PURE__*/_react.default.forwardRef(InternalTable);
@@ -0,0 +1,2 @@
1
+ declare const RcVirtualTable: import("@rc-component/table/lib/VirtualTable").ForwardGenericVirtualTable;
2
+ export default RcVirtualTable;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _table = require("@rc-component/table");
8
+ const RcVirtualTable = (0, _table.genVirtualTable)((prev, next) => {
9
+ const {
10
+ _renderTimes: prevRenderTimes
11
+ } = prev;
12
+ const {
13
+ _renderTimes: nextRenderTimes
14
+ } = next;
15
+ return prevRenderTimes !== nextRenderTimes;
16
+ });
17
+ var _default = exports.default = RcVirtualTable;
@@ -0,0 +1,2 @@
1
+ declare const RcTable: import("@rc-component/table/lib/Table").ForwardGenericTable;
2
+ export default RcTable;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _table = require("@rc-component/table");
8
+ const RcTable = (0, _table.genTable)((prev, next) => {
9
+ const {
10
+ _renderTimes: prevRenderTimes
11
+ } = prev;
12
+ const {
13
+ _renderTimes: nextRenderTimes
14
+ } = next;
15
+ return prevRenderTimes !== nextRenderTimes;
16
+ });
17
+ var _default = exports.default = RcTable;
@@ -0,0 +1,17 @@
1
+ import { EXPAND_COLUMN, Summary } from '@rc-component/table';
2
+ import Column from 'antd/lib/table/Column';
3
+ import ColumnGroup from 'antd/lib/table/ColumnGroup';
4
+ import { SELECTION_ALL, SELECTION_COLUMN, SELECTION_INVERT, SELECTION_NONE } from 'antd/lib/table/hooks/useSelection';
5
+ import type { RefTable } from './interface';
6
+ declare const ForwardTable: RefTable & {
7
+ displayName?: string | undefined;
8
+ SELECTION_COLUMN: typeof SELECTION_COLUMN;
9
+ EXPAND_COLUMN: typeof EXPAND_COLUMN;
10
+ SELECTION_ALL: typeof SELECTION_ALL;
11
+ SELECTION_INVERT: typeof SELECTION_INVERT;
12
+ SELECTION_NONE: typeof SELECTION_NONE;
13
+ Column: typeof Column;
14
+ ColumnGroup: typeof ColumnGroup;
15
+ Summary: typeof Summary;
16
+ };
17
+ export default ForwardTable;