ebaoferc 0.1.9 → 0.1.10
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.
- package/dist/components/FlexRowCol/index.d.ts +1 -1
- package/dist/components/FlexRowCol/index.js +54 -46
- package/dist/components/QueryProCard/index.less +9 -9
- package/dist/components/StyledQueryFilter/index.js +20 -36
- package/dist/components/StyledQueryFilter/index.less +34 -34
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ColProps, RowProps } from 'antd';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
3
|
export declare const Gutter: [number, number];
|
|
4
|
-
export default function (props: PropsWithChildren<{
|
|
4
|
+
export default function FlexRowCol(props: PropsWithChildren<{
|
|
5
5
|
colProps?: ColProps;
|
|
6
6
|
width?: number;
|
|
7
7
|
maxColCount?: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
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 = ["colProps", "width", "maxColCount", "gutter", "collapsedLineCount", "collapsed", "lineCountChange"];
|
|
2
|
+
var _excluded = ["colProps", "width", "maxColCount", "gutter", "collapsedLineCount", "collapsed", "lineCountChange", "children"];
|
|
3
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
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
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; }
|
|
@@ -9,11 +9,12 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
9
9
|
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; }
|
|
10
10
|
import { useSize } from 'ahooks';
|
|
11
11
|
import { Col, Row } from 'antd';
|
|
12
|
-
import React, { Children, isValidElement, useEffect, useRef } from 'react';
|
|
12
|
+
import React, { Children, isValidElement, useEffect, useMemo, useRef } from 'react';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
export var Gutter = [24, 0];
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
|
|
16
|
+
// FlexRowCol 组件用于创建一个灵活的行列布局
|
|
17
|
+
export default function FlexRowCol(props) {
|
|
17
18
|
var _props$colProps = props.colProps,
|
|
18
19
|
colProps = _props$colProps === void 0 ? {
|
|
19
20
|
span: 12
|
|
@@ -26,61 +27,68 @@ export default function (props) {
|
|
|
26
27
|
_props$collapsedLineC = props.collapsedLineCount,
|
|
27
28
|
collapsedLineCount = _props$collapsedLineC === void 0 ? Number.POSITIVE_INFINITY : _props$collapsedLineC,
|
|
28
29
|
_props$collapsed = props.collapsed,
|
|
29
|
-
collapsed = _props$collapsed === void 0 ?
|
|
30
|
+
collapsed = _props$collapsed === void 0 ? true : _props$collapsed,
|
|
30
31
|
lineCountChange = props.lineCountChange,
|
|
32
|
+
children = props.children,
|
|
31
33
|
rest = _objectWithoutProperties(props, _excluded);
|
|
34
|
+
|
|
35
|
+
// 使用 ref 和 useSize 钩子获取容器宽度
|
|
32
36
|
var ref = useRef(null);
|
|
33
37
|
var size = useSize(ref);
|
|
34
38
|
|
|
35
|
-
//
|
|
36
|
-
var
|
|
39
|
+
// 使用 useMemo 计算布局,避免不必要的重复计算
|
|
40
|
+
var _useMemo = useMemo(function () {
|
|
41
|
+
var gapX = (gutter === null || gutter === void 0 ? void 0 : gutter[0]) || 0;
|
|
42
|
+
var itemWidth = width + gapX;
|
|
43
|
+
var containerWidth = (size === null || size === void 0 ? void 0 : size.width) || 0;
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
// 计算每行可容纳的列数
|
|
46
|
+
var preColCount = Math.floor(containerWidth / itemWidth);
|
|
47
|
+
var colCount = maxColCount && preColCount > maxColCount ? maxColCount : preColCount;
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
// 计算每列的 span 值
|
|
50
|
+
var span = Math.floor(24 / colCount);
|
|
51
|
+
var _colProps = _objectSpread(_objectSpread({}, colProps), {}, {
|
|
52
|
+
span: span > 24 ? 24 : span
|
|
53
|
+
});
|
|
54
|
+
var count = 0;
|
|
55
|
+
// 处理子元素,计算 hidden 属性
|
|
56
|
+
var processedChildren = Children.toArray(children).filter(function (child) {
|
|
57
|
+
return /*#__PURE__*/isValidElement(child) && !child.props.hidden;
|
|
58
|
+
}).map(function (child, index) {
|
|
59
|
+
if (! /*#__PURE__*/isValidElement(child)) return child;
|
|
60
|
+
count++;
|
|
61
|
+
var childColProps = child.props.colProps || _colProps;
|
|
62
|
+
var hidden = collapsed && index >= colCount * collapsedLineCount;
|
|
63
|
+
return /*#__PURE__*/_jsx(Col, _objectSpread(_objectSpread({}, childColProps), {}, {
|
|
64
|
+
children: /*#__PURE__*/React.cloneElement(child, {
|
|
65
|
+
hidden: hidden
|
|
66
|
+
})
|
|
67
|
+
}), child.key || count);
|
|
68
|
+
});
|
|
45
69
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
70
|
+
// 计算行数
|
|
71
|
+
var lineCount = Math.ceil(count / (colCount || 1));
|
|
72
|
+
return {
|
|
73
|
+
lineCount: lineCount,
|
|
74
|
+
processedChildren: processedChildren
|
|
75
|
+
};
|
|
76
|
+
}, [size, width, maxColCount, gutter, collapsedLineCount, collapsed, colProps, children]),
|
|
77
|
+
lineCount = _useMemo.lineCount,
|
|
78
|
+
processedChildren = _useMemo.processedChildren;
|
|
52
79
|
|
|
53
|
-
//
|
|
54
|
-
var lineCount = colCount && Math.ceil(renderItemCount / colCount);
|
|
55
|
-
|
|
56
|
-
// 根据一行能放下的个数,计算每个子元素的宽度
|
|
57
|
-
var span = Math.floor(24 / colCount);
|
|
58
|
-
var count = 0;
|
|
59
|
-
var _colProps = _objectSpread(_objectSpread({}, colProps), {}, {
|
|
60
|
-
span: span > 24 ? 24 : span
|
|
61
|
-
});
|
|
80
|
+
// 当行数变化时,调用 lineCountChange 回调
|
|
62
81
|
useEffect(function () {
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
if (size !== null && size !== void 0 && size.width) {
|
|
83
|
+
lineCountChange === null || lineCountChange === void 0 || lineCountChange(lineCount);
|
|
84
|
+
}
|
|
85
|
+
}, [lineCount, lineCountChange, size === null || size === void 0 ? void 0 : size.width]);
|
|
86
|
+
// console.log(lineCount);
|
|
87
|
+
// 渲染行列布局
|
|
65
88
|
return /*#__PURE__*/_jsx(Row, _objectSpread(_objectSpread({
|
|
66
89
|
gutter: gutter
|
|
67
90
|
}, rest), {}, {
|
|
68
91
|
ref: ref,
|
|
69
|
-
children:
|
|
70
|
-
if (! /*#__PURE__*/isValidElement(child)) {
|
|
71
|
-
return child;
|
|
72
|
-
}
|
|
73
|
-
if (child.props.hidden) {
|
|
74
|
-
return child;
|
|
75
|
-
}
|
|
76
|
-
var childColProps = child.props.colProps || _colProps;
|
|
77
|
-
count++;
|
|
78
|
-
var hidden = count > colCount * collapsedLineCount && collapsed;
|
|
79
|
-
return /*#__PURE__*/_jsx(Col, _objectSpread(_objectSpread({}, childColProps), {}, {
|
|
80
|
-
children: /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
|
|
81
|
-
hidden: hidden
|
|
82
|
-
}))
|
|
83
|
-
}));
|
|
84
|
-
})
|
|
92
|
+
children: size !== null && size !== void 0 && size.width ? processedChildren : null
|
|
85
93
|
}));
|
|
86
94
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
.custom-filter-card-container-wrapper {
|
|
2
|
-
.ant-pro-card-body {
|
|
3
|
-
padding-bottom: 0 !important;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.ant-form-item {
|
|
7
|
-
margin-bottom: 16px;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
.custom-filter-card-container-wrapper {
|
|
2
|
+
.ant-pro-card-body {
|
|
3
|
+
padding-bottom: 0 !important;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.ant-form-item {
|
|
7
|
+
margin-bottom: 16px;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -17,7 +17,7 @@ import { DownOutlined } from '@ant-design/icons';
|
|
|
17
17
|
import { ProForm } from '@ant-design/pro-components';
|
|
18
18
|
import { Button, Form } from 'antd';
|
|
19
19
|
import classNames from 'classnames';
|
|
20
|
-
import React from 'react';
|
|
20
|
+
import React, { useCallback, useState } from 'react';
|
|
21
21
|
import FlexRowCol from "../FlexRowCol";
|
|
22
22
|
import "./index.less";
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -35,25 +35,28 @@ export default function StyledQueryFilter(props) {
|
|
|
35
35
|
var _Form$useForm = Form.useForm(form),
|
|
36
36
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
37
37
|
_form = _Form$useForm2[0];
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
collapsed =
|
|
41
|
-
setCollapsed =
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
var _useState = useState(false),
|
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
+
collapsed = _useState2[0],
|
|
41
|
+
setCollapsed = _useState2[1];
|
|
42
|
+
var _useState3 = useState(false),
|
|
43
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
44
|
+
showExpandButton = _useState4[0],
|
|
45
|
+
setShowExpandButton = _useState4[1];
|
|
46
46
|
if (labelWidth) {
|
|
47
47
|
rest.labelCol = {
|
|
48
48
|
flex: "0 0 ".concat(labelWidth, "px")
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
function reset(e) {
|
|
51
|
+
var reset = function reset(e) {
|
|
52
52
|
_form.resetFields();
|
|
53
53
|
if (onReset) {
|
|
54
|
-
onReset(e);
|
|
54
|
+
onReset(e); // 类型断言,因为 onReset 可能期望 FormEvent
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
};
|
|
57
|
+
var handleLineCountChange = useCallback(function (count) {
|
|
58
|
+
setShowExpandButton(count > collapsedLineCount);
|
|
59
|
+
}, [collapsedLineCount]);
|
|
57
60
|
return /*#__PURE__*/_jsxs("div", {
|
|
58
61
|
className: "custom-styled-query-filter",
|
|
59
62
|
children: [/*#__PURE__*/_jsx(ProForm, _objectSpread(_objectSpread({
|
|
@@ -66,14 +69,7 @@ export default function StyledQueryFilter(props) {
|
|
|
66
69
|
children: /*#__PURE__*/_jsx(FlexRowCol, {
|
|
67
70
|
collapsed: collapsed,
|
|
68
71
|
collapsedLineCount: collapsedLineCount,
|
|
69
|
-
lineCountChange:
|
|
70
|
-
setLineCount(lineCount);
|
|
71
|
-
if (lineCount > collapsedLineCount) {
|
|
72
|
-
setCollapsed(true);
|
|
73
|
-
} else {
|
|
74
|
-
setCollapsed(false);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
72
|
+
lineCountChange: handleLineCountChange,
|
|
77
73
|
width: itemWith,
|
|
78
74
|
children: children
|
|
79
75
|
})
|
|
@@ -91,25 +87,13 @@ export default function StyledQueryFilter(props) {
|
|
|
91
87
|
},
|
|
92
88
|
children: "\u67E5\u8BE2"
|
|
93
89
|
})]
|
|
94
|
-
}),
|
|
95
|
-
children:
|
|
96
|
-
type: "link",
|
|
97
|
-
onClick: function onClick() {
|
|
98
|
-
return setCollapsed(false);
|
|
99
|
-
},
|
|
100
|
-
children: ["\u5C55\u5F00", /*#__PURE__*/_jsx(DownOutlined, {
|
|
101
|
-
style: {
|
|
102
|
-
marginInlineStart: '0.5em',
|
|
103
|
-
transition: '0.3s all',
|
|
104
|
-
transform: "rotate(".concat(collapsed ? 0 : 0.5, "turn)")
|
|
105
|
-
}
|
|
106
|
-
})]
|
|
107
|
-
}) : /*#__PURE__*/_jsxs(Button, {
|
|
90
|
+
}), showExpandButton && /*#__PURE__*/_jsx("div", {
|
|
91
|
+
children: /*#__PURE__*/_jsxs(Button, {
|
|
108
92
|
type: "link",
|
|
109
93
|
onClick: function onClick() {
|
|
110
|
-
return setCollapsed(
|
|
94
|
+
return setCollapsed(!collapsed);
|
|
111
95
|
},
|
|
112
|
-
children: [
|
|
96
|
+
children: [collapsed ? '展开' : '收起', /*#__PURE__*/_jsx(DownOutlined, {
|
|
113
97
|
style: {
|
|
114
98
|
marginInlineStart: '0.5em',
|
|
115
99
|
transition: '0.3s all',
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
.custom-styled-query-filter {
|
|
2
|
-
display: flex;
|
|
3
|
-
justify-content: space-between;
|
|
4
|
-
column-gap: 16px;
|
|
5
|
-
|
|
6
|
-
&__form {
|
|
7
|
-
flex: 1;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
&__right {
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
justify-content: space-between;
|
|
14
|
-
align-items: flex-end;
|
|
15
|
-
|
|
16
|
-
.ant-btn-link {
|
|
17
|
-
padding-right: 0;
|
|
18
|
-
margin-bottom: 28px;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&__submitter {
|
|
23
|
-
display: flex;
|
|
24
|
-
column-gap: 8px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.ant-form-item-no-colon {
|
|
28
|
-
margin-right: 10px;
|
|
29
|
-
|
|
30
|
-
&::after {
|
|
31
|
-
display: none;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
.custom-styled-query-filter {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: space-between;
|
|
4
|
+
column-gap: 16px;
|
|
5
|
+
|
|
6
|
+
&__form {
|
|
7
|
+
flex: 1;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&__right {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
align-items: flex-end;
|
|
15
|
+
|
|
16
|
+
.ant-btn-link {
|
|
17
|
+
padding-right: 0;
|
|
18
|
+
margin-bottom: 28px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__submitter {
|
|
23
|
+
display: flex;
|
|
24
|
+
column-gap: 8px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ant-form-item-no-colon {
|
|
28
|
+
margin-right: 10px;
|
|
29
|
+
|
|
30
|
+
&::after {
|
|
31
|
+
display: none;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|