@hw-component/table 0.0.5-beta-v2 → 0.0.5-beta-v3

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.
@@ -32,7 +32,7 @@ var defaultRender = function defaultRender() {
32
32
  var contentStyle = {
33
33
  paddingLeft: 24,
34
34
  paddingRight: 24,
35
- marginBottom: 12
35
+ marginBottom: 16
36
36
  };
37
37
  var Body = (function (_ref) {
38
38
  var configData = _ref.configData,
@@ -1,9 +1,11 @@
1
1
  import type { PaginationProps } from "antd";
2
2
  import type { ParamsModal } from "@/components/modal";
3
3
  import React from "react";
4
+ import type { AffixProps } from "antd/lib/affix";
4
5
  interface IPaginationProps extends PaginationProps {
5
6
  onPageChange?: (params: ParamsModal) => void;
6
7
  paginationStyle?: React.CSSProperties;
8
+ affixProps?: AffixProps | false;
7
9
  }
8
- declare const _default: ({ onPageChange, paginationStyle, ...props }: IPaginationProps) => JSX.Element;
10
+ declare const _default: ({ onPageChange, paginationStyle, affixProps, ...props }: IPaginationProps) => JSX.Element;
9
11
  export default _default;
@@ -7,22 +7,25 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/fo
7
7
  import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
8
8
  import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
9
9
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
10
- import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
11
10
  import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
11
+ 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
15
  import { jsx, Fragment } from 'react/jsx-runtime';
16
- import { Row, Pagination } from 'antd';
16
+ import { Row, Pagination, Affix } from 'antd';
17
17
  import { useHTableContext } from '../context.js';
18
18
  import { useClassName } from '../hooks/index.js';
19
+ import { useState } from 'react';
19
20
 
20
- var _excluded = ["onPageChange", "paginationStyle"];
21
+ var _excluded = ["onPageChange", "paginationStyle", "affixProps"],
22
+ _excluded2 = ["offsetBottom"];
21
23
  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; }
22
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
24
+ 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; }
23
25
  var HTablePagination = (function (_ref) {
24
26
  var onPageChange = _ref.onPageChange,
25
27
  paginationStyle = _ref.paginationStyle,
28
+ affixProps = _ref.affixProps,
26
29
  props = _objectWithoutProperties(_ref, _excluded);
27
30
  var _useHTableContext = useHTableContext(),
28
31
  contextOnPageChange = _useHTableContext.onPageChange,
@@ -36,7 +39,14 @@ var HTablePagination = (function (_ref) {
36
39
  var pageSize = _Number$parseInt(size || "10", 10);
37
40
  var pageTotal = _Number$parseInt(total || "0", 10);
38
41
  var className = useClassName("hw-table-pagination");
39
- if (data) {
42
+ var _useState = useState({}),
43
+ _useState2 = _slicedToArray(_useState, 2),
44
+ style = _useState2[0],
45
+ setStyle = _useState2[1];
46
+ if (!data) {
47
+ return jsx(Fragment, {});
48
+ }
49
+ if (affixProps === false) {
40
50
  return jsx(Row, {
41
51
  justify: "end",
42
52
  className: className,
@@ -63,7 +73,48 @@ var HTablePagination = (function (_ref) {
63
73
  }, props))
64
74
  });
65
75
  }
66
- return jsx(Fragment, {});
76
+ var _ref5 = affixProps || {},
77
+ _ref5$offsetBottom = _ref5.offsetBottom,
78
+ offsetBottom = _ref5$offsetBottom === void 0 ? 0 : _ref5$offsetBottom,
79
+ afProps = _objectWithoutProperties(_ref5, _excluded2);
80
+ return jsx(Affix, _objectSpread(_objectSpread({
81
+ offsetBottom: offsetBottom,
82
+ onChange: function onChange(affixed) {
83
+ if (!affixed) {
84
+ setStyle({});
85
+ return;
86
+ }
87
+ setStyle({
88
+ boxShadow: "0px -3px 10px 1px rgba(165,165,165,0.16)"
89
+ });
90
+ }
91
+ }, afProps), {}, {
92
+ children: jsx(Row, {
93
+ justify: "end",
94
+ className: className,
95
+ style: _objectSpread(_objectSpread({}, paginationStyle), style),
96
+ children: jsx(Pagination, _objectSpread({
97
+ size: "small",
98
+ showQuickJumper: true,
99
+ pageSize: pageSize,
100
+ current: pageCurrent,
101
+ showTotal: function showTotal(totalNum, _ref6) {
102
+ var _context3, _context4;
103
+ var _ref7 = _slicedToArray(_ref6, 2),
104
+ showCurrent = _ref7[0],
105
+ showCurrentEnd = _ref7[1];
106
+ return _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "\u7B2C".concat(showCurrent, "-")).call(_context4, showCurrentEnd, "/\u603B\u5171")).call(_context3, totalNum, "\u6761");
107
+ },
108
+ total: pageTotal,
109
+ onChange: function onChange(pn, ps) {
110
+ tableOnPageChange({
111
+ size: ps,
112
+ current: pn
113
+ });
114
+ }
115
+ }, props))
116
+ })
117
+ }));
67
118
  });
68
119
 
69
120
  export { HTablePagination as default };
package/es/index.css CHANGED
@@ -5,7 +5,15 @@
5
5
  overflow: hidden;
6
6
  }
7
7
  .ant-hw-table-body .ant-hw-table-pagination {
8
- padding: 0 24px 24px;
8
+ padding: 12px 24px;
9
+ background-color: #ffffff;
10
+ border-radius: 0px;
11
+ }
12
+ .ant-hw-table-body .ant-pro-card-body {
13
+ padding-bottom: 0px;
14
+ }
15
+ .ant-hw-table-body .ant-pro-table-list-toolbar-container {
16
+ padding-top: 0px;
9
17
  }
10
18
  .ant-hw-table-pagination {
11
19
  padding: 24px;
@@ -35,7 +35,7 @@ var defaultRender = function defaultRender() {
35
35
  var contentStyle = {
36
36
  paddingLeft: 24,
37
37
  paddingRight: 24,
38
- marginBottom: 12
38
+ marginBottom: 16
39
39
  };
40
40
  var Body = (function (_ref) {
41
41
  var configData = _ref.configData,
@@ -1,9 +1,11 @@
1
1
  import type { PaginationProps } from "antd";
2
2
  import type { ParamsModal } from "@/components/modal";
3
3
  import React from "react";
4
+ import type { AffixProps } from "antd/lib/affix";
4
5
  interface IPaginationProps extends PaginationProps {
5
6
  onPageChange?: (params: ParamsModal) => void;
6
7
  paginationStyle?: React.CSSProperties;
8
+ affixProps?: AffixProps | false;
7
9
  }
8
- declare const _default: ({ onPageChange, paginationStyle, ...props }: IPaginationProps) => JSX.Element;
10
+ declare const _default: ({ onPageChange, paginationStyle, affixProps, ...props }: IPaginationProps) => JSX.Element;
9
11
  export default _default;
@@ -10,8 +10,8 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/
10
10
  var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
11
11
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
12
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
13
- var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
14
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
+ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
15
15
  var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
16
16
  var _Number$parseInt = require('@babel/runtime-corejs3/core-js/number/parse-int');
17
17
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/concat');
@@ -19,13 +19,16 @@ var jsxRuntime = require('react/jsx-runtime');
19
19
  var antd = require('antd');
20
20
  var context = require('../context.js');
21
21
  var index = require('../hooks/index.js');
22
+ var React = require('react');
22
23
 
23
- var _excluded = ["onPageChange", "paginationStyle"];
24
+ var _excluded = ["onPageChange", "paginationStyle", "affixProps"],
25
+ _excluded2 = ["offsetBottom"];
24
26
  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; }
25
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
27
+ 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
28
  var HTablePagination = (function (_ref) {
27
29
  var onPageChange = _ref.onPageChange,
28
30
  paginationStyle = _ref.paginationStyle,
31
+ affixProps = _ref.affixProps,
29
32
  props = _objectWithoutProperties(_ref, _excluded);
30
33
  var _useHTableContext = context.useHTableContext(),
31
34
  contextOnPageChange = _useHTableContext.onPageChange,
@@ -39,7 +42,14 @@ var HTablePagination = (function (_ref) {
39
42
  var pageSize = _Number$parseInt(size || "10", 10);
40
43
  var pageTotal = _Number$parseInt(total || "0", 10);
41
44
  var className = index.useClassName("hw-table-pagination");
42
- if (data) {
45
+ var _useState = React.useState({}),
46
+ _useState2 = _slicedToArray(_useState, 2),
47
+ style = _useState2[0],
48
+ setStyle = _useState2[1];
49
+ if (!data) {
50
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {});
51
+ }
52
+ if (affixProps === false) {
43
53
  return jsxRuntime.jsx(antd.Row, {
44
54
  justify: "end",
45
55
  className: className,
@@ -66,7 +76,48 @@ var HTablePagination = (function (_ref) {
66
76
  }, props))
67
77
  });
68
78
  }
69
- return jsxRuntime.jsx(jsxRuntime.Fragment, {});
79
+ var _ref5 = affixProps || {},
80
+ _ref5$offsetBottom = _ref5.offsetBottom,
81
+ offsetBottom = _ref5$offsetBottom === void 0 ? 0 : _ref5$offsetBottom,
82
+ afProps = _objectWithoutProperties(_ref5, _excluded2);
83
+ return jsxRuntime.jsx(antd.Affix, _objectSpread(_objectSpread({
84
+ offsetBottom: offsetBottom,
85
+ onChange: function onChange(affixed) {
86
+ if (!affixed) {
87
+ setStyle({});
88
+ return;
89
+ }
90
+ setStyle({
91
+ boxShadow: "0px -3px 10px 1px rgba(165,165,165,0.16)"
92
+ });
93
+ }
94
+ }, afProps), {}, {
95
+ children: jsxRuntime.jsx(antd.Row, {
96
+ justify: "end",
97
+ className: className,
98
+ style: _objectSpread(_objectSpread({}, paginationStyle), style),
99
+ children: jsxRuntime.jsx(antd.Pagination, _objectSpread({
100
+ size: "small",
101
+ showQuickJumper: true,
102
+ pageSize: pageSize,
103
+ current: pageCurrent,
104
+ showTotal: function showTotal(totalNum, _ref6) {
105
+ var _context3, _context4;
106
+ var _ref7 = _slicedToArray(_ref6, 2),
107
+ showCurrent = _ref7[0],
108
+ showCurrentEnd = _ref7[1];
109
+ return _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "\u7B2C".concat(showCurrent, "-")).call(_context4, showCurrentEnd, "/\u603B\u5171")).call(_context3, totalNum, "\u6761");
110
+ },
111
+ total: pageTotal,
112
+ onChange: function onChange(pn, ps) {
113
+ tableOnPageChange({
114
+ size: ps,
115
+ current: pn
116
+ });
117
+ }
118
+ }, props))
119
+ })
120
+ }));
70
121
  });
71
122
 
72
123
  exports.default = HTablePagination;
package/lib/index.css CHANGED
@@ -5,7 +5,15 @@
5
5
  overflow: hidden;
6
6
  }
7
7
  .ant-hw-table-body .ant-hw-table-pagination {
8
- padding: 0 24px 24px;
8
+ padding: 12px 24px;
9
+ background-color: #ffffff;
10
+ border-radius: 0px;
11
+ }
12
+ .ant-hw-table-body .ant-pro-card-body {
13
+ padding-bottom: 0px;
14
+ }
15
+ .ant-hw-table-body .ant-pro-table-list-toolbar-container {
16
+ padding-top: 0px;
9
17
  }
10
18
  .ant-hw-table-pagination {
11
19
  padding: 24px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/table",
3
- "version": "0.0.5-beta-v2",
3
+ "version": "0.0.5-beta-v3",
4
4
  "description": "基于antd二次开发table组件",
5
5
  "keywords": [
6
6
  "table"
@@ -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 from "react";
7
+ import React, { useRef } from "react";
8
8
  import { ConfigProvider, Empty, Row, Alert } from "antd";
9
9
  import type { HTableInstance } from "../modal";
10
10
  import { useHTableConfigContext } from "../TableConfig";
@@ -32,7 +32,7 @@ const defaultRender = () => {
32
32
  const contentStyle = {
33
33
  paddingLeft: 24,
34
34
  paddingRight: 24,
35
- marginBottom: 12,
35
+ marginBottom: 16,
36
36
  };
37
37
  export default ({
38
38
  configData,
@@ -79,7 +79,6 @@ export default ({
79
79
 
80
80
  const alwaysShowAlert = keys.length > 0 || selectAll;
81
81
  const className = useClassName("hw-table-body");
82
-
83
82
  return (
84
83
  <div style={tableStyle} className={`hw_table_body ${className}`}>
85
84
  <ConfigProvider
@@ -1,16 +1,19 @@
1
1
  import type { PaginationProps } from "antd";
2
- import { Button, Pagination, Row, Space, Typography } from "antd";
2
+ import { Affix, Button, Pagination, Row, Space, Typography } from "antd";
3
3
  import { useHTableContext } from "../context";
4
4
  import type { ParamsModal } from "@/components/modal";
5
5
  import { useClassName } from "../hooks";
6
- import React from "react";
6
+ import React, { useState } from "react";
7
+ import type { AffixProps } from "antd/lib/affix";
7
8
  interface IPaginationProps extends PaginationProps {
8
9
  onPageChange?: (params: ParamsModal) => void;
9
10
  paginationStyle?: React.CSSProperties;
11
+ affixProps?: AffixProps | false;
10
12
  }
11
13
  export default ({
12
14
  onPageChange,
13
15
  paginationStyle,
16
+ affixProps,
14
17
  ...props
15
18
  }: IPaginationProps) => {
16
19
  const { onPageChange: contextOnPageChange, data } = useHTableContext();
@@ -20,7 +23,11 @@ export default ({
20
23
  const pageSize = Number.parseInt(size || "10", 10);
21
24
  const pageTotal = Number.parseInt(total || "0", 10);
22
25
  const className = useClassName("hw-table-pagination");
23
- if (data) {
26
+ const [style, setStyle] = useState({});
27
+ if (!data) {
28
+ return <></>;
29
+ }
30
+ if (affixProps === false) {
24
31
  return (
25
32
  <Row justify={"end"} className={className} style={paginationStyle}>
26
33
  <Pagination
@@ -40,5 +47,41 @@ export default ({
40
47
  </Row>
41
48
  );
42
49
  }
43
- return <></>;
50
+ const { offsetBottom = 0, ...afProps } = affixProps || {};
51
+ return (
52
+ <Affix
53
+ offsetBottom={offsetBottom}
54
+ onChange={(affixed) => {
55
+ if (!affixed) {
56
+ setStyle({});
57
+ return;
58
+ }
59
+ setStyle({
60
+ boxShadow: "0px -3px 10px 1px rgba(165,165,165,0.16)",
61
+ });
62
+ }}
63
+ {...afProps}
64
+ >
65
+ <Row
66
+ justify={"end"}
67
+ className={className}
68
+ style={{ ...paginationStyle, ...style }}
69
+ >
70
+ <Pagination
71
+ size={"small"}
72
+ showQuickJumper={true}
73
+ pageSize={pageSize}
74
+ current={pageCurrent}
75
+ showTotal={(totalNum, [showCurrent, showCurrentEnd]) => {
76
+ return `第${showCurrent}-${showCurrentEnd}/总共${totalNum}条`;
77
+ }}
78
+ total={pageTotal}
79
+ onChange={(pn, ps) => {
80
+ tableOnPageChange({ size: ps, current: pn });
81
+ }}
82
+ {...props}
83
+ />
84
+ </Row>
85
+ </Affix>
86
+ );
44
87
  };
@@ -5,7 +5,15 @@
5
5
  background-color: #fff;
6
6
  overflow: hidden;
7
7
  .@{ant-prefix}-hw-table-pagination{
8
- padding: 0 24px 24px;
8
+ padding: 12px 24px;
9
+ background-color:#ffffff;
10
+ border-radius: 0px;
11
+ }
12
+ .@{ant-prefix}-pro-card-body{
13
+ padding-bottom: 0px;
14
+ }
15
+ .@{ant-prefix}-pro-table-list-toolbar-container{
16
+ padding-top: 0px;
9
17
  }
10
18
  }
11
19
  .@{ant-prefix}-hw-table-pagination{
@@ -49,7 +49,7 @@ export default () => {
49
49
  request={(params) => {
50
50
  const { current = 1 } = params;
51
51
  const arrayData = [];
52
- for (let i = 0; i < 10; i = i + 1) {
52
+ for (let i = 0; i < 100; i = i + 1) {
53
53
  arrayData.push({
54
54
  id: i,
55
55
  name: "11",