@hw-component/table 0.0.5-beta-v6 → 0.0.5-beta-v8

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.
@@ -0,0 +1,3 @@
1
+ import type { IPaginationProps } from "../HTablePagination/index";
2
+ declare const _default: ({ affixProps }: IPaginationProps) => JSX.Element;
3
+ export default _default;
@@ -0,0 +1,63 @@
1
+ // welcome to hoo hoo hoo
2
+ import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useClassName } from '../hooks/index.js';
5
+ import { useState, useEffect } from 'react';
6
+
7
+ var GoTop = (function (_ref) {
8
+ var affixProps = _ref.affixProps;
9
+ var className = useClassName("hw-top-btn");
10
+ var _ref2 = affixProps || {},
11
+ target = _ref2.target;
12
+ var _useState = useState({
13
+ display: "none"
14
+ }),
15
+ _useState2 = _slicedToArray(_useState, 2),
16
+ style = _useState2[0],
17
+ setStyle = _useState2[1];
18
+ var dom = target === null || target === void 0 ? void 0 : target();
19
+ var cuDom = dom || document.body;
20
+ var goTopFn = function goTopFn() {
21
+ cuDom.scrollTo({
22
+ top: 0
23
+ });
24
+ };
25
+ useEffect(function () {
26
+ var scroll = function scroll(e) {
27
+ var top = e.target.scrollTop;
28
+ if (top > 10) {
29
+ setStyle({
30
+ display: "block"
31
+ });
32
+ return;
33
+ }
34
+ setStyle({
35
+ display: "none"
36
+ });
37
+ };
38
+ cuDom.addEventListener("scroll", scroll);
39
+ return function () {
40
+ cuDom.removeEventListener("scroll", scroll);
41
+ };
42
+ }, [dom]);
43
+ useEffect(function () {
44
+ var top = cuDom.scrollTop;
45
+ if (top > 10) {
46
+ setStyle({
47
+ display: "block"
48
+ });
49
+ return;
50
+ }
51
+ setStyle({
52
+ display: "none"
53
+ });
54
+ }, []);
55
+ return jsx("div", {
56
+ className: className,
57
+ style: style,
58
+ onClick: goTopFn
59
+ });
60
+ });
61
+
62
+ export { GoTop as default };
63
+ // powered by hdj
@@ -3,7 +3,7 @@ import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
3
3
  import React from "react";
4
4
  import type { HTableInstance } from "../modal";
5
5
  import type { HRowSelection } from "../modal";
6
- import { AffixProps } from "antd/lib/affix";
6
+ import type { AffixProps } from "antd/lib/affix";
7
7
  interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
8
8
  configData?: ConfigDataModal;
9
9
  onPageChange?: (params: ParamsModal) => void;
@@ -14,6 +14,7 @@ interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "
14
14
  actionRender?: ActionRenderFn;
15
15
  rowSelection?: HRowSelection | false;
16
16
  affixProps?: AffixProps | false;
17
+ goTop?: boolean;
17
18
  }
18
- declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, ...props }: HTableBodyProps) => JSX.Element;
19
+ declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, goTop, ...props }: HTableBodyProps) => JSX.Element;
19
20
  export default _default;
@@ -21,7 +21,7 @@ import HTablePagination from '../HTablePagination/index.js';
21
21
  import { useClassName } from '../hooks/index.js';
22
22
  import AlertMsg from './AlertMsg.js';
23
23
 
24
- var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps"];
24
+ var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop"];
25
25
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
26
26
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
27
27
  var defaultRender = function defaultRender() {
@@ -32,7 +32,7 @@ var defaultRender = function defaultRender() {
32
32
  var contentStyle = {
33
33
  paddingLeft: 24,
34
34
  paddingRight: 24,
35
- marginBottom: 16
35
+ paddingBottom: 16
36
36
  };
37
37
  var Body = (function (_ref) {
38
38
  var configData = _ref.configData,
@@ -51,6 +51,8 @@ var Body = (function (_ref) {
51
51
  options = _ref.options,
52
52
  actionRender = _ref.actionRender,
53
53
  affixProps = _ref.affixProps,
54
+ _ref$goTop = _ref.goTop,
55
+ goTop = _ref$goTop === void 0 ? true : _ref$goTop,
54
56
  props = _objectWithoutProperties(_ref, _excluded);
55
57
  var selectedRowKeys = rowSelection.selectedRowKeys;
56
58
  var _useHTableContext = useHTableContext(),
@@ -133,7 +135,8 @@ var Body = (function (_ref) {
133
135
  })), pagination !== false && jsx(HTablePagination, _objectSpread({
134
136
  onPageChange: onPageChange,
135
137
  paginationStyle: paginationStyle,
136
- affixProps: affixProps
138
+ affixProps: affixProps,
139
+ goTop: goTop
137
140
  }, pagination))]
138
141
  })
139
142
  });
@@ -39,7 +39,10 @@ var Header = (function (_ref) {
39
39
  }, [configData]);
40
40
  var className = useClassName("hw-table-header");
41
41
  return jsx(Card, {
42
- style: _objectSpread({}, headerStyle),
42
+ style: _objectSpread({
43
+ borderBottomLeftRadius: 0,
44
+ borderBottomRightRadius: 0
45
+ }, headerStyle),
43
46
  bordered: false,
44
47
  className: "hw_table_header ".concat(className),
45
48
  bodyStyle: {
@@ -2,10 +2,11 @@ import type { PaginationProps } from "antd";
2
2
  import type { ParamsModal } from "@/components/modal";
3
3
  import React from "react";
4
4
  import type { AffixProps } from "antd/lib/affix";
5
- interface IPaginationProps extends PaginationProps {
5
+ export interface IPaginationProps extends PaginationProps {
6
6
  onPageChange?: (params: ParamsModal) => void;
7
7
  paginationStyle?: React.CSSProperties;
8
8
  affixProps?: AffixProps | false;
9
+ goTop?: boolean;
9
10
  }
10
- declare const _default: ({ onPageChange, paginationStyle, affixProps, ...props }: IPaginationProps) => JSX.Element;
11
+ declare const _default: ({ onPageChange, paginationStyle, affixProps, goTop, ...props }: IPaginationProps) => JSX.Element;
11
12
  export default _default;
@@ -12,13 +12,14 @@ import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
12
12
  import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
13
13
  import _Number$parseInt from '@babel/runtime-corejs3/core-js/number/parse-int';
14
14
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js/instance/concat';
15
- import { jsx, Fragment } from 'react/jsx-runtime';
15
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
16
16
  import { Row, Pagination, Affix } from 'antd';
17
17
  import { useHTableContext } from '../context.js';
18
18
  import { useClassName } from '../hooks/index.js';
19
19
  import { useState } from 'react';
20
+ import GoTop from '../GoTop/index.js';
20
21
 
21
- var _excluded = ["onPageChange", "paginationStyle", "affixProps"],
22
+ var _excluded = ["onPageChange", "paginationStyle", "affixProps", "goTop"],
22
23
  _excluded2 = ["offsetBottom"];
23
24
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
25
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -26,6 +27,7 @@ var HTablePagination = (function (_ref) {
26
27
  var onPageChange = _ref.onPageChange,
27
28
  paginationStyle = _ref.paginationStyle,
28
29
  affixProps = _ref.affixProps,
30
+ goTop = _ref.goTop,
29
31
  props = _objectWithoutProperties(_ref, _excluded);
30
32
  var _useHTableContext = useHTableContext(),
31
33
  contextOnPageChange = _useHTableContext.onPageChange,
@@ -89,11 +91,11 @@ var HTablePagination = (function (_ref) {
89
91
  });
90
92
  }
91
93
  }, afProps), {}, {
92
- children: jsx(Row, {
94
+ children: jsxs(Row, {
93
95
  justify: "end",
94
96
  className: className,
95
97
  style: _objectSpread(_objectSpread({}, paginationStyle), style),
96
- children: jsx(Pagination, _objectSpread({
98
+ children: [jsx(Pagination, _objectSpread({
97
99
  size: "small",
98
100
  showQuickJumper: true,
99
101
  pageSize: pageSize,
@@ -112,7 +114,9 @@ var HTablePagination = (function (_ref) {
112
114
  current: pn
113
115
  });
114
116
  }
115
- }, props))
117
+ }, props)), goTop && jsx(GoTop, {
118
+ affixProps: affixProps
119
+ })]
116
120
  })
117
121
  }));
118
122
  });
package/es/index.css CHANGED
@@ -2,7 +2,7 @@
2
2
  border-bottom-left-radius: 4px;
3
3
  border-bottom-right-radius: 4px;
4
4
  background-color: #fff;
5
- overflow: hidden;
5
+ position: relative;
6
6
  }
7
7
  .ant-hw-table-body .ant-hw-table-pagination {
8
8
  padding: 12px 24px;
@@ -19,6 +19,18 @@
19
19
  padding: 24px;
20
20
  border-radius: 4px;
21
21
  background-color: #ffffff;
22
+ position: relative;
23
+ }
24
+ .ant-hw-top-btn {
25
+ position: absolute;
26
+ right: 10px;
27
+ bottom: 54px;
28
+ z-index: 9;
29
+ cursor: pointer;
30
+ width: 48px;
31
+ height: 48px;
32
+ background: url("./GoTop/goTop.png") no-repeat;
33
+ background-size: 100%;
22
34
  }
23
35
  .ant-hw-table-header {
24
36
  border-top-left-radius: 4px;
package/es/modal.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { ColProps } from "antd";
5
5
  import type React from "react";
6
6
  import type { ModalProps } from "antd";
7
7
  import type { TableProps } from "antd/lib/table";
8
- import { AffixProps } from "antd/lib/affix";
8
+ import type { AffixProps } from "antd/lib/affix";
9
9
  export interface RowObj {
10
10
  keys?: React.Key[];
11
11
  rowData?: any[];
@@ -61,6 +61,7 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
61
61
  allPageCheck?: boolean;
62
62
  rowSelection?: HRowSelection | false;
63
63
  affixProps?: AffixProps | false;
64
+ goTop?: boolean;
64
65
  }
65
66
  export interface TableInstance {
66
67
  reload: (params?: ParamsModal) => Promise<any>;
@@ -0,0 +1,3 @@
1
+ import type { IPaginationProps } from "../HTablePagination/index";
2
+ declare const _default: ({ affixProps }: IPaginationProps) => JSX.Element;
3
+ export default _default;
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var index = require('../hooks/index.js');
8
+ var React = require('react');
9
+
10
+ var GoTop = (function (_ref) {
11
+ var affixProps = _ref.affixProps;
12
+ var className = index.useClassName("hw-top-btn");
13
+ var _ref2 = affixProps || {},
14
+ target = _ref2.target;
15
+ var _useState = React.useState({
16
+ display: "none"
17
+ }),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ style = _useState2[0],
20
+ setStyle = _useState2[1];
21
+ var dom = target === null || target === void 0 ? void 0 : target();
22
+ var cuDom = dom || document.body;
23
+ var goTopFn = function goTopFn() {
24
+ cuDom.scrollTo({
25
+ top: 0
26
+ });
27
+ };
28
+ React.useEffect(function () {
29
+ var scroll = function scroll(e) {
30
+ var top = e.target.scrollTop;
31
+ if (top > 10) {
32
+ setStyle({
33
+ display: "block"
34
+ });
35
+ return;
36
+ }
37
+ setStyle({
38
+ display: "none"
39
+ });
40
+ };
41
+ cuDom.addEventListener("scroll", scroll);
42
+ return function () {
43
+ cuDom.removeEventListener("scroll", scroll);
44
+ };
45
+ }, [dom]);
46
+ React.useEffect(function () {
47
+ var top = cuDom.scrollTop;
48
+ if (top > 10) {
49
+ setStyle({
50
+ display: "block"
51
+ });
52
+ return;
53
+ }
54
+ setStyle({
55
+ display: "none"
56
+ });
57
+ }, []);
58
+ return jsxRuntime.jsx("div", {
59
+ className: className,
60
+ style: style,
61
+ onClick: goTopFn
62
+ });
63
+ });
64
+
65
+ exports.default = GoTop;
66
+ // powered by h
@@ -3,7 +3,7 @@ import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
3
3
  import React from "react";
4
4
  import type { HTableInstance } from "../modal";
5
5
  import type { HRowSelection } from "../modal";
6
- import { AffixProps } from "antd/lib/affix";
6
+ import type { AffixProps } from "antd/lib/affix";
7
7
  interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
8
8
  configData?: ConfigDataModal;
9
9
  onPageChange?: (params: ParamsModal) => void;
@@ -14,6 +14,7 @@ interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "
14
14
  actionRender?: ActionRenderFn;
15
15
  rowSelection?: HRowSelection | false;
16
16
  affixProps?: AffixProps | false;
17
+ goTop?: boolean;
17
18
  }
18
- declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, ...props }: HTableBodyProps) => JSX.Element;
19
+ declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, goTop, ...props }: HTableBodyProps) => JSX.Element;
19
20
  export default _default;
@@ -24,7 +24,7 @@ var index$1 = require('../HTablePagination/index.js');
24
24
  var index = require('../hooks/index.js');
25
25
  var AlertMsg = require('./AlertMsg.js');
26
26
 
27
- var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps"];
27
+ var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop"];
28
28
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
29
29
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
30
30
  var defaultRender = function defaultRender() {
@@ -35,7 +35,7 @@ var defaultRender = function defaultRender() {
35
35
  var contentStyle = {
36
36
  paddingLeft: 24,
37
37
  paddingRight: 24,
38
- marginBottom: 16
38
+ paddingBottom: 16
39
39
  };
40
40
  var Body = (function (_ref) {
41
41
  var configData = _ref.configData,
@@ -54,6 +54,8 @@ var Body = (function (_ref) {
54
54
  options = _ref.options,
55
55
  actionRender = _ref.actionRender,
56
56
  affixProps = _ref.affixProps,
57
+ _ref$goTop = _ref.goTop,
58
+ goTop = _ref$goTop === void 0 ? true : _ref$goTop,
57
59
  props = _objectWithoutProperties(_ref, _excluded);
58
60
  var selectedRowKeys = rowSelection.selectedRowKeys;
59
61
  var _useHTableContext = context.useHTableContext(),
@@ -136,7 +138,8 @@ var Body = (function (_ref) {
136
138
  })), pagination !== false && jsxRuntime.jsx(index$1.default, _objectSpread({
137
139
  onPageChange: onPageChange,
138
140
  paginationStyle: paginationStyle,
139
- affixProps: affixProps
141
+ affixProps: affixProps,
142
+ goTop: goTop
140
143
  }, pagination))]
141
144
  })
142
145
  });
@@ -42,7 +42,10 @@ var Header = (function (_ref) {
42
42
  }, [configData]);
43
43
  var className = index.useClassName("hw-table-header");
44
44
  return jsxRuntime.jsx(antd.Card, {
45
- style: _objectSpread({}, headerStyle),
45
+ style: _objectSpread({
46
+ borderBottomLeftRadius: 0,
47
+ borderBottomRightRadius: 0
48
+ }, headerStyle),
46
49
  bordered: false,
47
50
  className: "hw_table_header ".concat(className),
48
51
  bodyStyle: {
@@ -2,10 +2,11 @@ import type { PaginationProps } from "antd";
2
2
  import type { ParamsModal } from "@/components/modal";
3
3
  import React from "react";
4
4
  import type { AffixProps } from "antd/lib/affix";
5
- interface IPaginationProps extends PaginationProps {
5
+ export interface IPaginationProps extends PaginationProps {
6
6
  onPageChange?: (params: ParamsModal) => void;
7
7
  paginationStyle?: React.CSSProperties;
8
8
  affixProps?: AffixProps | false;
9
+ goTop?: boolean;
9
10
  }
10
- declare const _default: ({ onPageChange, paginationStyle, affixProps, ...props }: IPaginationProps) => JSX.Element;
11
+ declare const _default: ({ onPageChange, paginationStyle, affixProps, goTop, ...props }: IPaginationProps) => JSX.Element;
11
12
  export default _default;
@@ -20,8 +20,9 @@ var antd = require('antd');
20
20
  var context = require('../context.js');
21
21
  var index = require('../hooks/index.js');
22
22
  var React = require('react');
23
+ var index$1 = require('../GoTop/index.js');
23
24
 
24
- var _excluded = ["onPageChange", "paginationStyle", "affixProps"],
25
+ var _excluded = ["onPageChange", "paginationStyle", "affixProps", "goTop"],
25
26
  _excluded2 = ["offsetBottom"];
26
27
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
28
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -29,6 +30,7 @@ var HTablePagination = (function (_ref) {
29
30
  var onPageChange = _ref.onPageChange,
30
31
  paginationStyle = _ref.paginationStyle,
31
32
  affixProps = _ref.affixProps,
33
+ goTop = _ref.goTop,
32
34
  props = _objectWithoutProperties(_ref, _excluded);
33
35
  var _useHTableContext = context.useHTableContext(),
34
36
  contextOnPageChange = _useHTableContext.onPageChange,
@@ -92,11 +94,11 @@ var HTablePagination = (function (_ref) {
92
94
  });
93
95
  }
94
96
  }, afProps), {}, {
95
- children: jsxRuntime.jsx(antd.Row, {
97
+ children: jsxRuntime.jsxs(antd.Row, {
96
98
  justify: "end",
97
99
  className: className,
98
100
  style: _objectSpread(_objectSpread({}, paginationStyle), style),
99
- children: jsxRuntime.jsx(antd.Pagination, _objectSpread({
101
+ children: [jsxRuntime.jsx(antd.Pagination, _objectSpread({
100
102
  size: "small",
101
103
  showQuickJumper: true,
102
104
  pageSize: pageSize,
@@ -115,7 +117,9 @@ var HTablePagination = (function (_ref) {
115
117
  current: pn
116
118
  });
117
119
  }
118
- }, props))
120
+ }, props)), goTop && jsxRuntime.jsx(index$1.default, {
121
+ affixProps: affixProps
122
+ })]
119
123
  })
120
124
  }));
121
125
  });
package/lib/index.css CHANGED
@@ -2,7 +2,7 @@
2
2
  border-bottom-left-radius: 4px;
3
3
  border-bottom-right-radius: 4px;
4
4
  background-color: #fff;
5
- overflow: hidden;
5
+ position: relative;
6
6
  }
7
7
  .ant-hw-table-body .ant-hw-table-pagination {
8
8
  padding: 12px 24px;
@@ -19,6 +19,18 @@
19
19
  padding: 24px;
20
20
  border-radius: 4px;
21
21
  background-color: #ffffff;
22
+ position: relative;
23
+ }
24
+ .ant-hw-top-btn {
25
+ position: absolute;
26
+ right: 10px;
27
+ bottom: 54px;
28
+ z-index: 9;
29
+ cursor: pointer;
30
+ width: 48px;
31
+ height: 48px;
32
+ background: url("./GoTop/goTop.png") no-repeat;
33
+ background-size: 100%;
22
34
  }
23
35
  .ant-hw-table-header {
24
36
  border-top-left-radius: 4px;
package/lib/modal.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { ColProps } from "antd";
5
5
  import type React from "react";
6
6
  import type { ModalProps } from "antd";
7
7
  import type { TableProps } from "antd/lib/table";
8
- import { AffixProps } from "antd/lib/affix";
8
+ import type { AffixProps } from "antd/lib/affix";
9
9
  export interface RowObj {
10
10
  keys?: React.Key[];
11
11
  rowData?: any[];
@@ -61,6 +61,7 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
61
61
  allPageCheck?: boolean;
62
62
  rowSelection?: HRowSelection | false;
63
63
  affixProps?: AffixProps | false;
64
+ goTop?: boolean;
64
65
  }
65
66
  export interface TableInstance {
66
67
  reload: (params?: ParamsModal) => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/table",
3
- "version": "0.0.5-beta-v6",
3
+ "version": "0.0.5-beta-v8",
4
4
  "description": "基于antd二次开发table组件",
5
5
  "keywords": [
6
6
  "table"
@@ -47,6 +47,7 @@
47
47
  "@babel/runtime-corejs3": "^7.21.5",
48
48
  "@rollup/plugin-babel": "^6.0.3",
49
49
  "@rollup/plugin-commonjs": "^25.0.0",
50
+ "@rollup/plugin-image": "^3.0.3",
50
51
  "@rollup/plugin-inject": "^5.0.3",
51
52
  "@rollup/plugin-node-resolve": "^15.0.2",
52
53
  "@rollup/plugin-url": "^8.0.1",
@@ -11,6 +11,8 @@ const postcss = require("rollup-plugin-postcss");
11
11
  const input = path.resolve(__dirname, "../src/components/index.tsx");
12
12
  const outDir = path.resolve(__dirname, "../lib");
13
13
  const esOutDir = path.resolve(__dirname, "../es");
14
+ const image = require("@rollup/plugin-image");
15
+
14
16
  module.exports = {
15
17
  input,
16
18
  output: [
@@ -36,6 +38,7 @@ module.exports = {
36
38
  clear({
37
39
  targets: [outDir, esOutDir],
38
40
  }),
41
+ image(),
39
42
  url({
40
43
  fileName: "[dirname][hash][extname]",
41
44
  }),
@@ -52,6 +52,10 @@ module.exports = {
52
52
  },
53
53
  ],
54
54
  },
55
+ {
56
+ test: /\.(png|jpe?g|gif|webp)$/,
57
+ type: "asset",
58
+ },
55
59
  ],
56
60
  },
57
61
  resolve: {
Binary file
@@ -0,0 +1,37 @@
1
+ import type { IPaginationProps } from "../HTablePagination/index";
2
+ import { useClassName } from "../hooks";
3
+ import { useEffect, useState } from "react";
4
+ export default ({ affixProps }: IPaginationProps) => {
5
+ const className = useClassName("hw-top-btn");
6
+ const { target } = affixProps || {};
7
+ const [style, setStyle] = useState({ display: "none" });
8
+ const dom = target?.();
9
+ const cuDom = dom || document.body;
10
+ const goTopFn = () => {
11
+ cuDom.scrollTo({ top: 0 });
12
+ };
13
+ useEffect(() => {
14
+ const scroll = (e) => {
15
+ const top = e.target.scrollTop;
16
+ if (top > 10) {
17
+ setStyle({ display: "block" });
18
+ return;
19
+ }
20
+ setStyle({ display: "none" });
21
+ };
22
+ cuDom.addEventListener("scroll", scroll);
23
+ return () => {
24
+ cuDom.removeEventListener("scroll", scroll);
25
+ };
26
+ }, [dom]);
27
+ useEffect(() => {
28
+ const top = (cuDom as HTMLElement).scrollTop;
29
+ if (top > 10) {
30
+ setStyle({ display: "block" });
31
+ return;
32
+ }
33
+ setStyle({ display: "none" });
34
+ }, []);
35
+
36
+ return <div className={className} style={style} onClick={goTopFn} />;
37
+ };
@@ -4,7 +4,7 @@ import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
4
4
  import { useCols, useSynchronousKeys } from "./hooks";
5
5
  import { useHTableContext } from "../context";
6
6
  import type { DetailedReactHTMLElement } from "react";
7
- import React, { useRef } from "react";
7
+ import React from "react";
8
8
  import { ConfigProvider, Empty, Row, Alert } from "antd";
9
9
  import type { HTableInstance } from "../modal";
10
10
  import { useHTableConfigContext } from "../TableConfig";
@@ -12,7 +12,8 @@ import HTablePagination from "../HTablePagination";
12
12
  import { useClassName } from "../hooks";
13
13
  import AlertMsg from "./AlertMsg";
14
14
  import type { HRowSelection } from "../modal";
15
- import {AffixProps} from "antd/lib/affix";
15
+ import type { AffixProps } from "antd/lib/affix";
16
+ import GoTop from "../GoTop";
16
17
  interface HTableBodyProps
17
18
  extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
18
19
  configData?: ConfigDataModal;
@@ -25,8 +26,9 @@ interface HTableBodyProps
25
26
  tableStyle?: React.CSSProperties;
26
27
  paginationStyle?: React.CSSProperties;
27
28
  actionRender?: ActionRenderFn;
28
- rowSelection?: HRowSelection|false;
29
+ rowSelection?: HRowSelection | false;
29
30
  affixProps?: AffixProps | false;
31
+ goTop?: boolean;
30
32
  }
31
33
  const defaultRender = () => {
32
34
  return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
@@ -34,7 +36,7 @@ const defaultRender = () => {
34
36
  const contentStyle = {
35
37
  paddingLeft: 24,
36
38
  paddingRight: 24,
37
- marginBottom: 16,
39
+ paddingBottom: 16,
38
40
  };
39
41
  export default ({
40
42
  configData,
@@ -49,7 +51,8 @@ export default ({
49
51
  headerTitle,
50
52
  options,
51
53
  actionRender,
52
- affixProps,
54
+ affixProps,
55
+ goTop = true,
53
56
  ...props
54
57
  }: HTableBodyProps) => {
55
58
  // @ts-ignore
@@ -135,6 +138,7 @@ export default ({
135
138
  onPageChange={onPageChange}
136
139
  paginationStyle={paginationStyle}
137
140
  affixProps={affixProps}
141
+ goTop={goTop}
138
142
  {...pagination}
139
143
  />
140
144
  )}
@@ -38,7 +38,11 @@ export default ({
38
38
  const className = useClassName("hw-table-header");
39
39
  return (
40
40
  <Card
41
- style={{ ...headerStyle }}
41
+ style={{
42
+ borderBottomLeftRadius: 0,
43
+ borderBottomRightRadius: 0,
44
+ ...headerStyle,
45
+ }}
42
46
  bordered={false}
43
47
  className={`hw_table_header ${className}`}
44
48
  bodyStyle={{ paddingBottom: 0 }}
@@ -1,19 +1,22 @@
1
1
  import type { PaginationProps } from "antd";
2
- import { Affix, Button, Pagination, Row, Space, Typography } from "antd";
2
+ import { Affix, Pagination, Row } from "antd";
3
3
  import { useHTableContext } from "../context";
4
4
  import type { ParamsModal } from "@/components/modal";
5
5
  import { useClassName } from "../hooks";
6
6
  import React, { useState } from "react";
7
7
  import type { AffixProps } from "antd/lib/affix";
8
- interface IPaginationProps extends PaginationProps {
8
+ import GoTop from "../GoTop";
9
+ export interface IPaginationProps extends PaginationProps {
9
10
  onPageChange?: (params: ParamsModal) => void;
10
11
  paginationStyle?: React.CSSProperties;
11
12
  affixProps?: AffixProps | false;
13
+ goTop?: boolean;
12
14
  }
13
15
  export default ({
14
16
  onPageChange,
15
17
  paginationStyle,
16
18
  affixProps,
19
+ goTop,
17
20
  ...props
18
21
  }: IPaginationProps) => {
19
22
  const { onPageChange: contextOnPageChange, data } = useHTableContext();
@@ -81,6 +84,7 @@ export default ({
81
84
  }}
82
85
  {...props}
83
86
  />
87
+ {goTop && <GoTop affixProps={affixProps} />}
84
88
  </Row>
85
89
  </Affix>
86
90
  );
@@ -1,7 +1,6 @@
1
1
  import Header from "./HTableHeader";
2
2
  import Body from "./HTableBody";
3
3
  import useCurrentTable from "./hooks/useCurrentTable";
4
- import Footer from "./HTableFooter";
5
4
  import useRowObj from "./hooks/useRowObj";
6
5
  import { HTableContext } from "./context";
7
6
  import { Space } from "antd";
@@ -3,7 +3,7 @@
3
3
  border-bottom-left-radius: 4px;
4
4
  border-bottom-right-radius: 4px;
5
5
  background-color: #fff;
6
- overflow: hidden;
6
+ position: relative;
7
7
  .@{ant-prefix}-hw-table-pagination{
8
8
  padding: 12px 24px;
9
9
  background-color:#ffffff;
@@ -20,8 +20,20 @@
20
20
  padding: 24px;
21
21
  border-radius: 4px;
22
22
  background-color: #ffffff;
23
+ position: relative;
23
24
  }
24
25
 
26
+ .@{ant-prefix}-hw-top-btn{
27
+ position: absolute;
28
+ right: 10px;
29
+ bottom: 54px;
30
+ z-index: 9;
31
+ cursor: pointer;
32
+ width: 48px;
33
+ height: 48px;
34
+ background: url("./GoTop/goTop.png") no-repeat;
35
+ background-size: 100%;
36
+ }
25
37
  .@{ant-prefix}-hw-table-header{
26
38
  border-top-left-radius: 4px;
27
39
  border-top-right-radius: 4px;
@@ -8,7 +8,7 @@ import type { ColProps } from "antd";
8
8
  import type React from "react";
9
9
  import type { ModalProps } from "antd";
10
10
  import type { TableProps } from "antd/lib/table";
11
- import {AffixProps} from "antd/lib/affix";
11
+ import type { AffixProps } from "antd/lib/affix";
12
12
 
13
13
  export interface RowObj {
14
14
  keys?: React.Key[];
@@ -92,6 +92,7 @@ export interface HTableProps
92
92
  allPageCheck?: boolean;
93
93
  rowSelection?: HRowSelection | false;
94
94
  affixProps?: AffixProps | false;
95
+ goTop?: boolean;
95
96
  }
96
97
  export interface TableInstance {
97
98
  reload: (params?: ParamsModal) => Promise<any>;
@@ -37,6 +37,9 @@ export default () => {
37
37
  rowKey={"id"}
38
38
  table={hTable}
39
39
  rowSelection={{}}
40
+ affixProps={{
41
+ target: () => document.querySelector(".body"),
42
+ }}
40
43
  options={{
41
44
  reload: false,
42
45
  setting: false,
@@ -31,7 +31,13 @@ export default () => {
31
31
  const { run, loading, error, data } = useRequest(
32
32
  (params) => {
33
33
  const { current = 1 } = params;
34
- console.log(params, "params");
34
+ const arrayData = [];
35
+ for (let i = 0; i < 100; i = i + 1) {
36
+ arrayData.push({
37
+ id: i,
38
+ name: "11",
39
+ });
40
+ }
35
41
  return new Promise((resolve, reject) => {
36
42
  setTimeout(() => {
37
43
  // reject(new Error("错误"));
@@ -39,12 +45,7 @@ export default () => {
39
45
  size: "10",
40
46
  current: current.toString(10),
41
47
  total: "100",
42
- records: [
43
- {
44
- id: 1,
45
- name: "111",
46
- },
47
- ],
48
+ records:arrayData
48
49
  });
49
50
  }, 2000);
50
51
  });
@@ -62,9 +63,10 @@ export default () => {
62
63
  <Space direction={"vertical"} style={{ width: "100%" }}>
63
64
  <HTableHeader />
64
65
  <HTableBody
65
- pagination={false}
66
- scroll={{ x: 1000, y: 100 }}
67
66
  headerTitle={<AddBtn />}
67
+ affixProps={{
68
+ target: () => document.querySelector(".body"),
69
+ }}
68
70
  rowSelection={{
69
71
  onChange: () => {
70
72
  console.log("rowSelection");
@@ -0,0 +1,46 @@
1
+ declare module "slash2";
2
+ declare module "*.css";
3
+ declare module "*.less";
4
+ declare module "*.scss";
5
+ declare module "*.sass";
6
+ declare module "*.svg";
7
+ declare module "*.png";
8
+ declare module "*.jpg";
9
+ declare module "*.jpeg";
10
+ declare module "*.gif";
11
+ declare module "*.bmp";
12
+ declare module "*.tiff";
13
+ declare module "omit.js";
14
+ declare module "numeral";
15
+ declare module "@antv/data-set";
16
+ declare module "mockjs";
17
+ declare module "react-fittext";
18
+ declare module "bizcharts-plugin-slider";
19
+
20
+ // google analytics interface
21
+ type GAFieldsObject = {
22
+ eventCategory: string;
23
+ eventAction: string;
24
+ eventLabel?: string;
25
+ eventValue?: number;
26
+ nonInteraction?: boolean;
27
+ };
28
+
29
+ interface Window {
30
+ ga: (
31
+ command: "send",
32
+ hitType: "event" | "pageview",
33
+ fieldsObject: GAFieldsObject | string
34
+ ) => void;
35
+ reloadAuthorized: () => void;
36
+ }
37
+
38
+ declare let ga: () => void;
39
+
40
+ // preview.pro.ant.design only do not use in your production ;
41
+ // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
42
+ declare let ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
43
+ | "site"
44
+ | undefined;
45
+
46
+ declare const REACT_APP_ENV: "test" | "dev" | "pre" | false;
package/tsconfig.json CHANGED
@@ -24,6 +24,6 @@
24
24
  "@/*": ["./src/*"]
25
25
  }
26
26
  },
27
- "include": ["src/**/*"],
27
+ "include": ["src/**/*", "typings/**/*"],
28
28
  "exclude": ["node_modules", "**/*.spec.ts", "**/*.css", "**/*.less"]
29
29
  }