@hsu-react/ui 0.0.8 → 0.0.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/es/components/Chart/Bar/index.d.ts +5 -1
- package/es/components/Chart/Bar/index.js +84 -9
- package/es/components/Chart/Line/index.d.ts +5 -1
- package/es/components/Chart/Line/index.js +84 -9
- package/es/components/Chart/_utils/autoSmooth.d.ts +2 -0
- package/es/components/Chart/_utils/autoSmooth.js +12 -2
- package/es/components/Chart/_utils/cartesian.d.ts +11 -0
- package/es/components/Chart/_utils/cartesian.js +19 -0
- package/es/components/Chart/chartUtils/chartTooltipFormatter.d.ts +2 -0
- package/es/components/Chart/chartUtils/chartTooltipFormatter.js +13 -3
- package/es/components/Chart/chartUtils/index.d.ts +5 -2
- package/es/components/Chart/chartUtils/index.js +3 -1
- package/es/components/Chart/chartUtils/useDataZoomWindow.d.ts +19 -0
- package/es/components/Chart/chartUtils/useDataZoomWindow.js +37 -0
- package/es/components/Chart/chartUtils/useLegendSelection.d.ts +14 -0
- package/es/components/Chart/chartUtils/useLegendSelection.js +35 -0
- package/es/components/FormItem/ItemContainer/index.d.ts +2 -0
- package/es/components/FormItem/ItemContainer/index.js +4 -15
- package/es/components/Modal/index.module.scss +1 -0
- package/es/components/Panel/ListPanel/ListModalPanel/index.js +33 -5
- package/es/components/Panel/ListPanel/ListModalPanel/index.module.scss +17 -2
- package/es/components/Panel/ListPanel/index.module.scss +11 -12
- package/es/components/Search/{_components → SearchAdvanced/_components}/AdvancedFiltersDrawer/index.d.ts +3 -3
- package/es/components/Search/{_components → SearchAdvanced/_components}/AdvancedFiltersDrawer/index.js +3 -3
- package/es/components/Search/SearchAdvanced/index.js +26 -148
- package/es/components/Search/SearchCard/index.js +1 -1
- package/es/components/Search/{_components → SearchCollapsible/_components}/CollapseToggle/index.js +2 -2
- package/es/components/Search/SearchCollapsible/index.js +17 -138
- package/es/components/Search/SearchWithFilter/index.js +4 -143
- package/es/components/Search/SearchWithMore/index.js +11 -142
- package/es/components/Search/_components/FilterDropdown/index.js +5 -6
- package/es/components/Search/_components/SearchBase/index.d.ts +32 -0
- package/es/components/Search/_components/SearchBase/index.js +185 -0
- package/es/components/Search/_hooks/useSearchCommon.js +5 -11
- package/es/components/Search/_hooks/useSearchExpand.js +4 -13
- package/es/components/Search/_utils/calculateButtonGroupAndColumnWidth.js +3 -10
- package/es/components/Search/_utils/calculateVisibleItems.js +4 -5
- package/es/components/Search/_utils/index.d.ts +2 -0
- package/es/components/Search/_utils/index.js +3 -1
- package/es/components/Search/_utils/measureButtonGroupWidth.d.ts +6 -0
- package/es/components/Search/_utils/measureButtonGroupWidth.js +18 -0
- package/es/components/Search/_utils/shouldDisplayExtraItem.d.ts +11 -0
- package/es/components/Search/_utils/shouldDisplayExtraItem.js +13 -0
- package/es/components/Search/index.d.ts +4 -0
- package/es/components/Search/index.js +6 -133
- package/es/components/Table/_hooks/useTableColumns.js +11 -0
- package/lib/components/Chart/Bar/index.d.ts +5 -1
- package/lib/components/Chart/Bar/index.js +68 -4
- package/lib/components/Chart/Line/index.d.ts +5 -1
- package/lib/components/Chart/Line/index.js +68 -4
- package/lib/components/Chart/_utils/autoSmooth.d.ts +2 -0
- package/lib/components/Chart/_utils/autoSmooth.js +11 -1
- package/lib/components/Chart/_utils/cartesian.d.ts +11 -0
- package/lib/components/Chart/_utils/cartesian.js +21 -1
- package/lib/components/Chart/chartUtils/chartTooltipFormatter.d.ts +2 -0
- package/lib/components/Chart/chartUtils/chartTooltipFormatter.js +5 -3
- package/lib/components/Chart/chartUtils/index.d.ts +5 -2
- package/lib/components/Chart/chartUtils/index.js +14 -0
- package/lib/components/Chart/chartUtils/useDataZoomWindow.d.ts +19 -0
- package/lib/components/Chart/chartUtils/useDataZoomWindow.js +31 -0
- package/lib/components/Chart/chartUtils/useLegendSelection.d.ts +14 -0
- package/lib/components/Chart/chartUtils/useLegendSelection.js +26 -0
- package/lib/components/FormItem/ItemContainer/index.d.ts +2 -0
- package/lib/components/FormItem/ItemContainer/index.js +2 -5
- package/lib/components/Modal/index.module.scss +1 -0
- package/lib/components/Panel/ListPanel/ListModalPanel/index.js +21 -2
- package/lib/components/Panel/ListPanel/ListModalPanel/index.module.scss +17 -2
- package/lib/components/Panel/ListPanel/index.module.scss +11 -12
- package/lib/components/Search/{_components → SearchAdvanced/_components}/AdvancedFiltersDrawer/index.d.ts +3 -3
- package/lib/components/Search/{_components → SearchAdvanced/_components}/AdvancedFiltersDrawer/index.js +3 -3
- package/lib/components/Search/SearchAdvanced/index.js +19 -134
- package/lib/components/Search/SearchCard/index.js +1 -1
- package/lib/components/Search/{_components → SearchCollapsible/_components}/CollapseToggle/index.js +2 -2
- package/lib/components/Search/SearchCollapsible/index.js +12 -124
- package/lib/components/Search/SearchWithFilter/index.js +5 -129
- package/lib/components/Search/SearchWithMore/index.js +7 -126
- package/lib/components/Search/_components/FilterDropdown/index.js +5 -6
- package/lib/components/Search/_components/SearchBase/index.d.ts +32 -0
- package/lib/components/Search/_components/SearchBase/index.js +169 -0
- package/lib/components/Search/_hooks/useSearchCommon.js +4 -6
- package/lib/components/Search/_hooks/useSearchExpand.js +2 -13
- package/lib/components/Search/_utils/calculateButtonGroupAndColumnWidth.js +2 -10
- package/lib/components/Search/_utils/calculateVisibleItems.js +3 -5
- package/lib/components/Search/_utils/index.d.ts +2 -0
- package/lib/components/Search/_utils/index.js +15 -1
- package/lib/components/Search/_utils/measureButtonGroupWidth.d.ts +6 -0
- package/lib/components/Search/_utils/measureButtonGroupWidth.js +24 -0
- package/lib/components/Search/_utils/shouldDisplayExtraItem.d.ts +11 -0
- package/lib/components/Search/_utils/shouldDisplayExtraItem.js +19 -0
- package/lib/components/Search/index.d.ts +4 -0
- package/lib/components/Search/index.js +8 -119
- package/lib/components/Table/_hooks/useTableColumns.js +11 -0
- package/package.json +1 -1
- package/src/components/Chart/Bar/index.tsx +132 -2
- package/src/components/Chart/Line/index.tsx +132 -2
- package/src/components/Chart/_utils/autoSmooth.ts +181 -164
- package/src/components/Chart/_utils/cartesian.ts +28 -0
- package/src/components/Chart/chartUtils/chartTooltipFormatter.ts +11 -2
- package/src/components/Chart/chartUtils/index.ts +53 -37
- package/src/components/Chart/chartUtils/useDataZoomWindow.ts +61 -0
- package/src/components/Chart/chartUtils/useLegendSelection.ts +35 -0
- package/src/components/FormItem/ItemContainer/index.tsx +4 -7
- package/src/components/Modal/index.module.scss +1 -0
- package/src/components/Panel/ListPanel/ListModalPanel/index.module.scss +17 -2
- package/src/components/Panel/ListPanel/ListModalPanel/index.tsx +261 -233
- package/src/components/Panel/ListPanel/index.module.scss +11 -12
- package/src/components/Search/{_components → SearchAdvanced/_components}/AdvancedFiltersDrawer/index.tsx +6 -6
- package/src/components/Search/SearchAdvanced/index.tsx +25 -164
- package/src/components/Search/SearchCard/index.tsx +1 -1
- package/src/components/Search/{_components → SearchCollapsible/_components}/CollapseToggle/index.tsx +2 -2
- package/src/components/Search/SearchCollapsible/index.tsx +13 -162
- package/src/components/Search/SearchWithFilter/index.tsx +2 -164
- package/src/components/Search/SearchWithMore/index.tsx +9 -161
- package/src/components/Search/_components/FilterDropdown/index.tsx +5 -6
- package/src/components/Search/_components/SearchBase/index.tsx +224 -0
- package/src/components/Search/_hooks/useSearchCommon.ts +10 -13
- package/src/components/Search/_hooks/useSearchExpand.ts +3 -13
- package/src/components/Search/_utils/calculateButtonGroupAndColumnWidth.ts +2 -10
- package/src/components/Search/_utils/calculateVisibleItems.ts +10 -11
- package/src/components/Search/_utils/index.ts +2 -0
- package/src/components/Search/_utils/measureButtonGroupWidth.ts +23 -0
- package/src/components/Search/_utils/shouldDisplayExtraItem.ts +23 -0
- package/src/components/Search/index.tsx +7 -153
- package/src/components/Table/_hooks/useTableColumns.tsx +17 -0
- /package/es/components/Search/{_components → SearchCollapsible/_components}/CollapseToggle/index.d.ts +0 -0
- /package/lib/components/Search/{_components → SearchCollapsible/_components}/CollapseToggle/index.d.ts +0 -0
|
@@ -4,20 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
8
|
-
var
|
|
9
|
-
var _FormItem = _interopRequireDefault(require("../../FormItem"));
|
|
10
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _indexModule = _interopRequireDefault(require("../index.module.scss"));
|
|
12
|
-
var _hooks = require("../_hooks");
|
|
13
|
-
var _ButtonGroup = require("../_components/ButtonGroup");
|
|
14
|
-
var _SearchButtons = require("../_components/SearchButtons");
|
|
15
|
-
var _FilterDropdown = require("../_components/FilterDropdown");
|
|
16
|
-
var _ExpandButton = require("../_components/ExpandButton");
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _SearchBase = _interopRequireDefault(require("../_components/SearchBase"));
|
|
17
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
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); }
|
|
20
|
-
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; }
|
|
21
11
|
/**
|
|
22
12
|
* 带更多搜索项的 Search 组件
|
|
23
13
|
* - 将搜索项分为基础项和更多项两组
|
|
@@ -26,123 +16,14 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
26
16
|
*/
|
|
27
17
|
const SearchWithMore = props => {
|
|
28
18
|
const {
|
|
29
|
-
searchItems = [],
|
|
30
|
-
moreSearchItems,
|
|
31
|
-
className,
|
|
32
|
-
onSearch,
|
|
33
|
-
onReset,
|
|
34
|
-
externalForm,
|
|
35
|
-
hasPermi,
|
|
36
|
-
columnNum = 4,
|
|
37
|
-
beforeButtonGroup,
|
|
38
|
-
affterButtonGroup,
|
|
39
|
-
searchData,
|
|
40
19
|
setFilter,
|
|
41
|
-
|
|
42
|
-
defaultExpanded = false,
|
|
43
|
-
onExpandChange,
|
|
44
|
-
autoAdaptWidth = true,
|
|
45
|
-
baseWidth,
|
|
46
|
-
onValuesChange,
|
|
47
|
-
searchDisabled = false,
|
|
48
|
-
searchText,
|
|
49
|
-
resetText,
|
|
50
|
-
onFilterChange,
|
|
51
|
-
columnOffsetWidth = 0
|
|
20
|
+
...rest
|
|
52
21
|
} = props;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
containerRef,
|
|
56
|
-
buttonGroupRef,
|
|
57
|
-
cls,
|
|
58
|
-
getLabelWidth,
|
|
59
|
-
processedSearchItems,
|
|
60
|
-
setSearchItems,
|
|
61
|
-
currentSearchItems,
|
|
62
|
-
totalColumnNum,
|
|
63
|
-
expand,
|
|
64
|
-
toggleExpand,
|
|
65
|
-
showExpandButton,
|
|
66
|
-
onSearchClick,
|
|
67
|
-
onResetClick,
|
|
68
|
-
shouldRender,
|
|
69
|
-
permitted
|
|
70
|
-
} = (0, _hooks.useSearchCommon)({
|
|
71
|
-
form,
|
|
72
|
-
searchItems,
|
|
73
|
-
moreSearchItems,
|
|
74
|
-
searchData,
|
|
75
|
-
hasPermi,
|
|
76
|
-
beforeButtonGroup,
|
|
77
|
-
affterButtonGroup,
|
|
78
|
-
columnNum,
|
|
79
|
-
autoAdaptWidth,
|
|
80
|
-
defaultExpanded,
|
|
81
|
-
onExpandChange,
|
|
82
|
-
showAllSearchItems: true,
|
|
22
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchBase.default, {
|
|
23
|
+
...rest,
|
|
83
24
|
// SearchWithMore 始终显示所有搜索项
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
onSearch,
|
|
87
|
-
onReset,
|
|
88
|
-
columnOffsetWidth
|
|
89
|
-
});
|
|
90
|
-
if (!shouldRender) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
94
|
-
ref: containerRef,
|
|
95
|
-
className: (0, _classnames.default)(_indexModule.default.Search, className),
|
|
96
|
-
style: {
|
|
97
|
-
"--column-number": totalColumnNum,
|
|
98
|
-
"--column-offset-width": `${columnOffsetWidth}px`
|
|
99
|
-
},
|
|
100
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
101
|
-
className: (0, _classnames.default)(_indexModule.default.searchOption, _indexModule.default[expand.toString()]),
|
|
102
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Form, {
|
|
103
|
-
form: form,
|
|
104
|
-
className: (0, _classnames.default)(_indexModule.default.option, cls),
|
|
105
|
-
onValuesChange: onValuesChange,
|
|
106
|
-
children: [permitted && currentSearchItems?.map((item, idx) => {
|
|
107
|
-
// 计算同一列的项(用于计算标签宽度)
|
|
108
|
-
const visibleCurrentItems = currentSearchItems.filter(i => i.visible !== false);
|
|
109
|
-
const columnIndex = idx % totalColumnNum;
|
|
110
|
-
const sameColumnItems = visibleCurrentItems.filter((_, _idx) => _idx % totalColumnNum === columnIndex);
|
|
111
|
-
return /*#__PURE__*/(0, _react.createElement)(_FormItem.default, {
|
|
112
|
-
...item,
|
|
113
|
-
key: item.name,
|
|
114
|
-
className: (0, _classnames.default)(_indexModule.default.item, item.className, {
|
|
115
|
-
[_indexModule.default.unFill]: item.width !== undefined
|
|
116
|
-
}),
|
|
117
|
-
labelWidth: item.width !== undefined ? undefined : getLabelWidth(sameColumnItems, undefined, minLabelWidth)
|
|
118
|
-
});
|
|
119
|
-
}), (beforeButtonGroup?.length || affterButtonGroup?.length || permitted) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ButtonGroup.ButtonGroup, {
|
|
120
|
-
beforeButtonGroup: beforeButtonGroup,
|
|
121
|
-
affterButtonGroup: affterButtonGroup,
|
|
122
|
-
expandButton: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandButton.ExpandButton, {
|
|
123
|
-
expand: expand,
|
|
124
|
-
toggleExpand: toggleExpand,
|
|
125
|
-
advancedFilters: false,
|
|
126
|
-
showExpandButton: showExpandButton,
|
|
127
|
-
showAllSearchItems: true
|
|
128
|
-
}),
|
|
129
|
-
permitted: permitted,
|
|
130
|
-
ref: buttonGroupRef,
|
|
131
|
-
children: [currentSearchItems.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchButtons.SearchButtons, {
|
|
132
|
-
onSearch: onSearchClick,
|
|
133
|
-
onReset: onResetClick,
|
|
134
|
-
searchDisabled: searchDisabled,
|
|
135
|
-
searchText: searchText,
|
|
136
|
-
resetText: resetText
|
|
137
|
-
}), setFilter && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FilterDropdown.FilterDropdown, {
|
|
138
|
-
searchItems: processedSearchItems,
|
|
139
|
-
originalSearchItems: searchItems,
|
|
140
|
-
setSearchItems: setSearchItems,
|
|
141
|
-
onFilterChange: onFilterChange
|
|
142
|
-
})]
|
|
143
|
-
})]
|
|
144
|
-
})
|
|
145
|
-
})
|
|
25
|
+
showAllSearchItems: true,
|
|
26
|
+
showFilter: !!setFilter
|
|
146
27
|
});
|
|
147
28
|
};
|
|
148
29
|
var _default = exports.default = SearchWithMore;
|
|
@@ -22,15 +22,14 @@ const FilterDropdown = ({
|
|
|
22
22
|
}) => {
|
|
23
23
|
const [open, setOpen] = (0, _react.useState)(false);
|
|
24
24
|
(0, _react.useEffect)(() => {
|
|
25
|
-
|
|
25
|
+
const handleDocumentClick = () => {
|
|
26
26
|
setOpen(false);
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
|
+
document.addEventListener("click", handleDocumentClick);
|
|
28
29
|
return () => {
|
|
29
|
-
document.removeEventListener("click",
|
|
30
|
-
setOpen(false);
|
|
31
|
-
});
|
|
30
|
+
document.removeEventListener("click", handleDocumentClick);
|
|
32
31
|
};
|
|
33
|
-
}, [
|
|
32
|
+
}, []);
|
|
34
33
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Dropdown, {
|
|
35
34
|
open: open,
|
|
36
35
|
overlayClassName: _indexModule.default.filterDropdown,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { FormInstance } from "antd";
|
|
3
|
+
import { FormItemProps } from "../../../FormItem";
|
|
4
|
+
import type useLabelWidth from "../../../../hooks/useLabelWidth";
|
|
5
|
+
import { SearchPropsWithFilter } from "../../_types";
|
|
6
|
+
/** 暴露给变体扩展渲染(如高级筛选抽屉)的上下文 */
|
|
7
|
+
export interface SearchBaseContext {
|
|
8
|
+
form: FormInstance;
|
|
9
|
+
expand: boolean;
|
|
10
|
+
setExpand?: (expand: boolean) => void;
|
|
11
|
+
processedSearchItems: FormItemProps[];
|
|
12
|
+
getLabelWidth: ReturnType<typeof useLabelWidth>[1];
|
|
13
|
+
onSearchClick: () => void;
|
|
14
|
+
onResetClick: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface SearchBaseProps extends SearchPropsWithFilter {
|
|
17
|
+
/** 高级筛选模式:搜索项不显示 label,展开按钮显示为"高级筛选" */
|
|
18
|
+
advancedFilters?: boolean;
|
|
19
|
+
/** 是否渲染 FilterDropdown(筛选器设置下拉) */
|
|
20
|
+
showFilter?: boolean;
|
|
21
|
+
/** 表单区域之后、容器之内的附加内容(如折叠开关),仅在有权限时渲染 */
|
|
22
|
+
afterForm?: ReactNode;
|
|
23
|
+
/** 容器之外的附加内容(如高级筛选抽屉),仅在有权限时渲染 */
|
|
24
|
+
renderOutside?: (ctx: SearchBaseContext) => ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Search 各变体共享的基础实现:
|
|
28
|
+
* 表单渲染、列布局、展开/收起、按钮组、权限控制。
|
|
29
|
+
* 变体只负责自身差异(筛选器、折叠开关、高级筛选抽屉等)。
|
|
30
|
+
*/
|
|
31
|
+
declare const SearchBase: React.FC<SearchBaseProps>;
|
|
32
|
+
export default SearchBase;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _antd = require("antd");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _FormItem = _interopRequireDefault(require("../../../FormItem"));
|
|
11
|
+
var _indexModule = _interopRequireDefault(require("../../index.module.scss"));
|
|
12
|
+
var _hooks = require("../../_hooks");
|
|
13
|
+
var _ButtonGroup = require("../ButtonGroup");
|
|
14
|
+
var _SearchButtons = require("../SearchButtons");
|
|
15
|
+
var _ExpandButton = require("../ExpandButton");
|
|
16
|
+
var _FilterDropdown = require("../FilterDropdown");
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
/** 暴露给变体扩展渲染(如高级筛选抽屉)的上下文 */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Search 各变体共享的基础实现:
|
|
25
|
+
* 表单渲染、列布局、展开/收起、按钮组、权限控制。
|
|
26
|
+
* 变体只负责自身差异(筛选器、折叠开关、高级筛选抽屉等)。
|
|
27
|
+
*/
|
|
28
|
+
const SearchBase = props => {
|
|
29
|
+
const {
|
|
30
|
+
searchItems = [],
|
|
31
|
+
moreSearchItems = [],
|
|
32
|
+
className,
|
|
33
|
+
onSearch,
|
|
34
|
+
onReset,
|
|
35
|
+
externalForm,
|
|
36
|
+
hasPermi,
|
|
37
|
+
columnNum = 4,
|
|
38
|
+
beforeButtonGroup,
|
|
39
|
+
affterButtonGroup,
|
|
40
|
+
searchData,
|
|
41
|
+
minLabelWidth,
|
|
42
|
+
defaultExpanded = false,
|
|
43
|
+
onExpandChange,
|
|
44
|
+
autoAdaptWidth = true,
|
|
45
|
+
baseWidth,
|
|
46
|
+
onValuesChange,
|
|
47
|
+
searchDisabled = false,
|
|
48
|
+
showAllSearchItems = false,
|
|
49
|
+
searchText,
|
|
50
|
+
resetText,
|
|
51
|
+
onFilterChange,
|
|
52
|
+
columnOffsetWidth = 0,
|
|
53
|
+
advancedFilters = false,
|
|
54
|
+
showFilter = false,
|
|
55
|
+
afterForm,
|
|
56
|
+
renderOutside
|
|
57
|
+
} = props;
|
|
58
|
+
const [form] = _antd.Form.useForm(externalForm);
|
|
59
|
+
const {
|
|
60
|
+
containerRef,
|
|
61
|
+
buttonGroupRef,
|
|
62
|
+
cls,
|
|
63
|
+
getLabelWidth,
|
|
64
|
+
processedSearchItems,
|
|
65
|
+
setSearchItems,
|
|
66
|
+
currentSearchItems,
|
|
67
|
+
totalColumnNum,
|
|
68
|
+
expand,
|
|
69
|
+
setExpand,
|
|
70
|
+
toggleExpand,
|
|
71
|
+
showExpandButton,
|
|
72
|
+
onSearchClick,
|
|
73
|
+
onResetClick,
|
|
74
|
+
shouldRender,
|
|
75
|
+
permitted
|
|
76
|
+
} = (0, _hooks.useSearchCommon)({
|
|
77
|
+
form,
|
|
78
|
+
searchItems,
|
|
79
|
+
moreSearchItems,
|
|
80
|
+
searchData,
|
|
81
|
+
hasPermi,
|
|
82
|
+
beforeButtonGroup,
|
|
83
|
+
affterButtonGroup,
|
|
84
|
+
columnNum,
|
|
85
|
+
autoAdaptWidth,
|
|
86
|
+
defaultExpanded,
|
|
87
|
+
onExpandChange,
|
|
88
|
+
showAllSearchItems,
|
|
89
|
+
minLabelWidth,
|
|
90
|
+
baseWidth,
|
|
91
|
+
onSearch,
|
|
92
|
+
onReset,
|
|
93
|
+
columnOffsetWidth
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// 按列分组预计算(用于对齐同列 label 宽度),避免在 map 中逐项重复 filter
|
|
97
|
+
const columnGroups = (0, _react.useMemo)(() => {
|
|
98
|
+
const groups = Array.from({
|
|
99
|
+
length: totalColumnNum
|
|
100
|
+
}, () => []);
|
|
101
|
+
currentSearchItems.forEach((item, idx) => {
|
|
102
|
+
groups[idx % totalColumnNum].push(item);
|
|
103
|
+
});
|
|
104
|
+
return groups;
|
|
105
|
+
}, [currentSearchItems, totalColumnNum]);
|
|
106
|
+
if (!shouldRender) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
110
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
111
|
+
ref: containerRef,
|
|
112
|
+
className: (0, _classnames.default)(_indexModule.default.Search, className),
|
|
113
|
+
style: {
|
|
114
|
+
"--column-number": totalColumnNum,
|
|
115
|
+
"--column-offset-width": `${columnOffsetWidth}px`
|
|
116
|
+
},
|
|
117
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
118
|
+
className: (0, _classnames.default)(_indexModule.default.searchOption, _indexModule.default[expand.toString()]),
|
|
119
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Form, {
|
|
120
|
+
form: form,
|
|
121
|
+
className: (0, _classnames.default)(_indexModule.default.option, cls),
|
|
122
|
+
onValuesChange: onValuesChange,
|
|
123
|
+
children: [permitted && currentSearchItems.map((item, idx) => /*#__PURE__*/(0, _react.createElement)(_FormItem.default, {
|
|
124
|
+
...item,
|
|
125
|
+
key: item.name,
|
|
126
|
+
className: (0, _classnames.default)(_indexModule.default.item, item.className, {
|
|
127
|
+
[_indexModule.default.unFill]: item.width !== undefined
|
|
128
|
+
}),
|
|
129
|
+
label: advancedFilters ? undefined : item.label,
|
|
130
|
+
labelWidth: advancedFilters || item.width !== undefined ? undefined : getLabelWidth(columnGroups[idx % totalColumnNum], undefined, minLabelWidth)
|
|
131
|
+
})), (beforeButtonGroup?.length || affterButtonGroup?.length || permitted) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ButtonGroup.ButtonGroup, {
|
|
132
|
+
beforeButtonGroup: beforeButtonGroup,
|
|
133
|
+
affterButtonGroup: affterButtonGroup,
|
|
134
|
+
expandButton: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandButton.ExpandButton, {
|
|
135
|
+
expand: expand,
|
|
136
|
+
toggleExpand: toggleExpand,
|
|
137
|
+
advancedFilters: advancedFilters,
|
|
138
|
+
showExpandButton: showExpandButton,
|
|
139
|
+
showAllSearchItems: showAllSearchItems || !!moreSearchItems?.length
|
|
140
|
+
}),
|
|
141
|
+
permitted: permitted,
|
|
142
|
+
ref: buttonGroupRef,
|
|
143
|
+
children: [currentSearchItems.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchButtons.SearchButtons, {
|
|
144
|
+
onSearch: onSearchClick,
|
|
145
|
+
onReset: onResetClick,
|
|
146
|
+
searchDisabled: searchDisabled,
|
|
147
|
+
searchText: searchText,
|
|
148
|
+
resetText: resetText
|
|
149
|
+
}), showFilter && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FilterDropdown.FilterDropdown, {
|
|
150
|
+
searchItems: processedSearchItems,
|
|
151
|
+
originalSearchItems: searchItems,
|
|
152
|
+
setSearchItems: setSearchItems,
|
|
153
|
+
onFilterChange: onFilterChange
|
|
154
|
+
})]
|
|
155
|
+
})]
|
|
156
|
+
})
|
|
157
|
+
}), permitted && afterForm]
|
|
158
|
+
}), permitted && renderOutside?.({
|
|
159
|
+
form,
|
|
160
|
+
expand,
|
|
161
|
+
setExpand,
|
|
162
|
+
processedSearchItems,
|
|
163
|
+
getLabelWidth,
|
|
164
|
+
onSearchClick,
|
|
165
|
+
onResetClick
|
|
166
|
+
})]
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
var _default = exports.default = SearchBase;
|
|
@@ -61,12 +61,10 @@ const useSearchCommon = params => {
|
|
|
61
61
|
}, [moreSearchItems]);
|
|
62
62
|
|
|
63
63
|
// 计算可见的搜索项数量
|
|
64
|
-
const visibleSearchItemCount =
|
|
65
|
-
return visibleSearchItems.length;
|
|
66
|
-
}, [visibleSearchItems]);
|
|
64
|
+
const visibleSearchItemCount = visibleSearchItems.length;
|
|
67
65
|
|
|
68
66
|
// 计算总列数(包括按钮组)
|
|
69
|
-
const baseTotalColumnNum =
|
|
67
|
+
const baseTotalColumnNum = columnNum + 1;
|
|
70
68
|
|
|
71
69
|
// 根据容器宽度动态调整列数
|
|
72
70
|
const totalColumnNum = (0, _useAdaptiveColumnNum.useAdaptiveColumnNum)(containerRef, baseTotalColumnNum, autoAdaptWidth, 1,
|
|
@@ -78,7 +76,7 @@ const useSearchCommon = params => {
|
|
|
78
76
|
baseWidth);
|
|
79
77
|
|
|
80
78
|
// 计算调整后的搜索项列数(不包括按钮组)
|
|
81
|
-
const adaptiveColumnNum =
|
|
79
|
+
const adaptiveColumnNum = Math.max(1, totalColumnNum - 1);
|
|
82
80
|
|
|
83
81
|
// 使用基于宽度的展开/收起控制
|
|
84
82
|
const {
|
|
@@ -142,7 +140,7 @@ const useSearchCommon = params => {
|
|
|
142
140
|
} = (0, _utils.calculateButtonGroupAndColumnWidth)(containerRef, buttonGroupRef, adaptiveColumnNum, columnOffsetWidth);
|
|
143
141
|
|
|
144
142
|
// 判断按钮组宽度是否大于列宽,如果是,则显示 实际搜索项数量+1
|
|
145
|
-
if (
|
|
143
|
+
if ((0, _utils.shouldDisplayExtraItem)(buttonGroupWidth, columnWidth, adaptiveColumnNum, visibleSearchItemCount)) {
|
|
146
144
|
return adaptiveColumnNum + 1;
|
|
147
145
|
}
|
|
148
146
|
return adaptiveColumnNum;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useSearchExpand = useSearchExpand;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var _utils = require("../_utils");
|
|
8
9
|
/**
|
|
9
10
|
* 基于宽度自适应控制展开/收起的Hook
|
|
10
11
|
* @param containerRef 容器引用
|
|
@@ -34,19 +35,7 @@ function useSearchExpand(containerRef, buttonGroupRef, itemClassName, itemCount,
|
|
|
34
35
|
const availableWidth = containerWidth - 30; // 15px padding on each side
|
|
35
36
|
|
|
36
37
|
// 获取按钮组的实际宽度(计算所有子元素宽度总和)
|
|
37
|
-
|
|
38
|
-
const buttonChildren = Array.from(buttonGroupRef.current.children);
|
|
39
|
-
if (buttonChildren.length > 0) {
|
|
40
|
-
// 计算所有子元素的宽度总和
|
|
41
|
-
let totalWidth = 0;
|
|
42
|
-
buttonChildren?.forEach(child => {
|
|
43
|
-
totalWidth += child.offsetWidth;
|
|
44
|
-
});
|
|
45
|
-
// 加上子元素之间的间距(column-gap: 10px)
|
|
46
|
-
const childGap = 5;
|
|
47
|
-
totalWidth += (buttonChildren.length - 1) * childGap;
|
|
48
|
-
buttonGroupWidth = totalWidth;
|
|
49
|
-
}
|
|
38
|
+
const buttonGroupWidth = (0, _utils.measureButtonGroupWidth)(buttonGroupRef.current) ?? 0;
|
|
50
39
|
|
|
51
40
|
// 获取所有搜索项元素
|
|
52
41
|
const items = container.querySelectorAll(`${itemClassName}`);
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.calculateButtonGroupAndColumnWidth = calculateButtonGroupAndColumnWidth;
|
|
7
|
+
var _measureButtonGroupWidth = require("./measureButtonGroupWidth");
|
|
7
8
|
/**
|
|
8
9
|
* 计算按钮组宽度和列宽
|
|
9
10
|
* @param containerRef 容器引用
|
|
@@ -21,16 +22,7 @@ function calculateButtonGroupAndColumnWidth(containerRef, buttonGroupRef, adapti
|
|
|
21
22
|
const gap = 10; // 项之间的间距
|
|
22
23
|
|
|
23
24
|
// 计算按钮组宽度
|
|
24
|
-
|
|
25
|
-
if (buttonChildren.length > 0) {
|
|
26
|
-
let totalWidth = 0;
|
|
27
|
-
buttonChildren?.forEach(child => {
|
|
28
|
-
totalWidth += child.offsetWidth;
|
|
29
|
-
});
|
|
30
|
-
const childGap = 5;
|
|
31
|
-
totalWidth += (buttonChildren.length - 1) * childGap;
|
|
32
|
-
buttonGroupWidth = totalWidth;
|
|
33
|
-
}
|
|
25
|
+
buttonGroupWidth = (0, _measureButtonGroupWidth.measureButtonGroupWidth)(buttonGroupRef.current);
|
|
34
26
|
|
|
35
27
|
// 计算列宽(单个搜索项的默认宽度)
|
|
36
28
|
if (adaptiveColumnNum > 0) {
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.calculateVisibleItems = calculateVisibleItems;
|
|
7
|
+
var _shouldDisplayExtraItem = require("./shouldDisplayExtraItem");
|
|
7
8
|
/**
|
|
8
9
|
* 计算当前应该显示的搜索项
|
|
9
10
|
* @param searchItems 所有搜索项
|
|
@@ -17,7 +18,7 @@ exports.calculateVisibleItems = calculateVisibleItems;
|
|
|
17
18
|
*/
|
|
18
19
|
function calculateVisibleItems(searchItems, expand, columnNum, visibleItemCount, autoAdaptWidth, buttonGroupWidth, columnWidth) {
|
|
19
20
|
const visibleItems = searchItems.filter(item => item.visible);
|
|
20
|
-
const hasCustomWidth = searchItems.
|
|
21
|
+
const hasCustomWidth = searchItems.some(item => item.width !== undefined);
|
|
21
22
|
if (!expand) {
|
|
22
23
|
// 当有自定义宽度时,使用自适应计算
|
|
23
24
|
if (hasCustomWidth && autoAdaptWidth) {
|
|
@@ -27,10 +28,7 @@ function calculateVisibleItems(searchItems, expand, columnNum, visibleItemCount,
|
|
|
27
28
|
} else if (!hasCustomWidth) {
|
|
28
29
|
// 没有自定义宽度时,使用 columnNum(实际搜索项数量)
|
|
29
30
|
// 判断按钮组宽度是否大于列宽,如果是,则显示 实际搜索项数量+1
|
|
30
|
-
|
|
31
|
-
if (buttonGroupWidth !== undefined && columnWidth !== undefined && (buttonGroupWidth > columnWidth || buttonGroupWidth < columnWidth && columnNum + 1 === visibleItems.length)) {
|
|
32
|
-
displayCount = columnNum + 1;
|
|
33
|
-
}
|
|
31
|
+
const displayCount = (0, _shouldDisplayExtraItem.shouldDisplayExtraItem)(buttonGroupWidth, columnWidth, columnNum, visibleItems.length) ? columnNum + 1 : columnNum;
|
|
34
32
|
if (visibleItems.length >= displayCount) {
|
|
35
33
|
return visibleItems.slice(0, displayCount);
|
|
36
34
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { cleanSearchData } from "./cleanSearchData";
|
|
2
2
|
export { calculateVisibleItems } from "./calculateVisibleItems";
|
|
3
3
|
export { calculateButtonGroupAndColumnWidth } from "./calculateButtonGroupAndColumnWidth";
|
|
4
|
+
export { measureButtonGroupWidth } from "./measureButtonGroupWidth";
|
|
5
|
+
export { shouldDisplayExtraItem } from "./shouldDisplayExtraItem";
|
|
@@ -21,6 +21,20 @@ Object.defineProperty(exports, "cleanSearchData", {
|
|
|
21
21
|
return _cleanSearchData.cleanSearchData;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "measureButtonGroupWidth", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _measureButtonGroupWidth.measureButtonGroupWidth;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "shouldDisplayExtraItem", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _shouldDisplayExtraItem.shouldDisplayExtraItem;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
24
36
|
var _cleanSearchData = require("./cleanSearchData");
|
|
25
37
|
var _calculateVisibleItems = require("./calculateVisibleItems");
|
|
26
|
-
var _calculateButtonGroupAndColumnWidth = require("./calculateButtonGroupAndColumnWidth");
|
|
38
|
+
var _calculateButtonGroupAndColumnWidth = require("./calculateButtonGroupAndColumnWidth");
|
|
39
|
+
var _measureButtonGroupWidth = require("./measureButtonGroupWidth");
|
|
40
|
+
var _shouldDisplayExtraItem = require("./shouldDisplayExtraItem");
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.measureButtonGroupWidth = measureButtonGroupWidth;
|
|
7
|
+
/**
|
|
8
|
+
* 计算按钮组的实际宽度(所有子元素宽度总和 + 子元素间距)
|
|
9
|
+
* @param buttonGroupEl 按钮组元素
|
|
10
|
+
* @returns 按钮组宽度;无子元素时返回 undefined
|
|
11
|
+
*/
|
|
12
|
+
function measureButtonGroupWidth(buttonGroupEl) {
|
|
13
|
+
if (!buttonGroupEl) return undefined;
|
|
14
|
+
const buttonChildren = Array.from(buttonGroupEl.children);
|
|
15
|
+
if (buttonChildren.length === 0) return undefined;
|
|
16
|
+
let totalWidth = 0;
|
|
17
|
+
buttonChildren.forEach(child => {
|
|
18
|
+
totalWidth += child.offsetWidth;
|
|
19
|
+
});
|
|
20
|
+
// 加上子元素之间的间距
|
|
21
|
+
const childGap = 5;
|
|
22
|
+
totalWidth += (buttonChildren.length - 1) * childGap;
|
|
23
|
+
return totalWidth;
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断收起状态下是否应多显示一个搜索项
|
|
3
|
+
*
|
|
4
|
+
* 规则:按钮组宽度大于列宽(按钮组独占更宽空间,首行有富余);
|
|
5
|
+
* 或按钮组宽度小于列宽且可见项刚好比列数多 1(此时收起只会藏起 1 项,不如直接放下)。
|
|
6
|
+
* @param buttonGroupWidth 按钮组宽度
|
|
7
|
+
* @param columnWidth 列宽
|
|
8
|
+
* @param columnNum 搜索项列数(不含按钮组)
|
|
9
|
+
* @param visibleCount 可见搜索项总数
|
|
10
|
+
*/
|
|
11
|
+
export declare function shouldDisplayExtraItem(buttonGroupWidth: number | undefined, columnWidth: number | undefined, columnNum: number, visibleCount: number): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shouldDisplayExtraItem = shouldDisplayExtraItem;
|
|
7
|
+
/**
|
|
8
|
+
* 判断收起状态下是否应多显示一个搜索项
|
|
9
|
+
*
|
|
10
|
+
* 规则:按钮组宽度大于列宽(按钮组独占更宽空间,首行有富余);
|
|
11
|
+
* 或按钮组宽度小于列宽且可见项刚好比列数多 1(此时收起只会藏起 1 项,不如直接放下)。
|
|
12
|
+
* @param buttonGroupWidth 按钮组宽度
|
|
13
|
+
* @param columnWidth 列宽
|
|
14
|
+
* @param columnNum 搜索项列数(不含按钮组)
|
|
15
|
+
* @param visibleCount 可见搜索项总数
|
|
16
|
+
*/
|
|
17
|
+
function shouldDisplayExtraItem(buttonGroupWidth, columnWidth, columnNum, visibleCount) {
|
|
18
|
+
return buttonGroupWidth !== undefined && columnWidth !== undefined && (buttonGroupWidth > columnWidth || buttonGroupWidth < columnWidth && columnNum + 1 === visibleCount);
|
|
19
|
+
}
|
|
@@ -26,5 +26,9 @@ export type SearchModePropsMap = {
|
|
|
26
26
|
WithFilter: React.ComponentProps<SearchFC["WithFilter"]>;
|
|
27
27
|
WithMore: React.ComponentProps<SearchFC["WithMore"]>;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* 基础 Search 组件
|
|
31
|
+
* - 标准的搜索表单布局,自适应列数与展开/收起
|
|
32
|
+
*/
|
|
29
33
|
declare const Search: SearchFC;
|
|
30
34
|
export default Search;
|