@hsu-react/ui 0.0.9 → 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/FormItem/ItemContainer/index.d.ts +2 -0
- package/es/components/FormItem/ItemContainer/index.js +4 -15
- 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/FormItem/ItemContainer/index.d.ts +2 -0
- package/lib/components/FormItem/ItemContainer/index.js +2 -5
- 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/FormItem/ItemContainer/index.tsx +4 -7
- 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
|
@@ -5,16 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _antd = require("antd");
|
|
9
|
-
var _FormItem = _interopRequireDefault(require("../../FormItem"));
|
|
10
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
9
|
var _indexModule = _interopRequireDefault(require("../index.module.scss"));
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var _SearchButtons = require("../_components/SearchButtons");
|
|
15
|
-
var _FilterDropdown = require("../_components/FilterDropdown");
|
|
16
|
-
var _ExpandButton = require("../_components/ExpandButton");
|
|
17
|
-
var _CollapseToggle = require("../_components/CollapseToggle");
|
|
10
|
+
var _SearchBase = _interopRequireDefault(require("../_components/SearchBase"));
|
|
11
|
+
var _CollapseToggle = require("./_components/CollapseToggle");
|
|
18
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -27,70 +21,15 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
27
21
|
*/
|
|
28
22
|
const SearchCollapsible = props => {
|
|
29
23
|
const {
|
|
30
|
-
searchItems = [],
|
|
31
|
-
moreSearchItems = [],
|
|
32
24
|
className,
|
|
33
|
-
onSearch,
|
|
34
|
-
onReset,
|
|
35
|
-
externalForm,
|
|
36
|
-
hasPermi,
|
|
37
|
-
columnNum = 4,
|
|
38
|
-
beforeButtonGroup,
|
|
39
|
-
affterButtonGroup,
|
|
40
|
-
searchData,
|
|
41
|
-
setFilter,
|
|
42
|
-
minLabelWidth,
|
|
43
25
|
defaultExpanded = false,
|
|
44
26
|
onCollapseToggle,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
baseWidth,
|
|
48
|
-
onValuesChange,
|
|
49
|
-
searchDisabled = false,
|
|
50
|
-
showAllSearchItems = false,
|
|
51
|
-
searchText,
|
|
52
|
-
resetText,
|
|
53
|
-
onFilterChange,
|
|
54
|
-
columnOffsetWidth = 0
|
|
27
|
+
setFilter,
|
|
28
|
+
...rest
|
|
55
29
|
} = props;
|
|
56
|
-
|
|
30
|
+
|
|
57
31
|
// collapse 的语义是反的,所以需要取反 defaultExpanded
|
|
58
32
|
const [collapse, setCollapse] = (0, _react.useState)(!defaultExpanded);
|
|
59
|
-
const {
|
|
60
|
-
containerRef,
|
|
61
|
-
buttonGroupRef,
|
|
62
|
-
cls,
|
|
63
|
-
getLabelWidth,
|
|
64
|
-
processedSearchItems,
|
|
65
|
-
setSearchItems,
|
|
66
|
-
currentSearchItems,
|
|
67
|
-
totalColumnNum,
|
|
68
|
-
expand,
|
|
69
|
-
toggleExpand,
|
|
70
|
-
showExpandButton,
|
|
71
|
-
onSearchClick,
|
|
72
|
-
onResetClick,
|
|
73
|
-
shouldRender,
|
|
74
|
-
permitted
|
|
75
|
-
} = (0, _hooks.useSearchCommon)({
|
|
76
|
-
form,
|
|
77
|
-
searchItems,
|
|
78
|
-
moreSearchItems,
|
|
79
|
-
searchData,
|
|
80
|
-
hasPermi,
|
|
81
|
-
beforeButtonGroup,
|
|
82
|
-
affterButtonGroup,
|
|
83
|
-
columnNum,
|
|
84
|
-
autoAdaptWidth,
|
|
85
|
-
defaultExpanded,
|
|
86
|
-
onExpandChange,
|
|
87
|
-
showAllSearchItems,
|
|
88
|
-
minLabelWidth,
|
|
89
|
-
baseWidth,
|
|
90
|
-
onSearch,
|
|
91
|
-
onReset,
|
|
92
|
-
columnOffsetWidth
|
|
93
|
-
});
|
|
94
33
|
|
|
95
34
|
// 处理折叠切换
|
|
96
35
|
const handleCollapseToggle = (0, _react.useCallback)(() => {
|
|
@@ -100,68 +39,17 @@ const SearchCollapsible = props => {
|
|
|
100
39
|
return newCollapse;
|
|
101
40
|
});
|
|
102
41
|
}, [onCollapseToggle]);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
className: (0, _classnames.default)(_indexModule.default.Search, className, {
|
|
109
|
-
[_indexModule.default.collapseExpand]: true,
|
|
42
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchBase.default, {
|
|
43
|
+
...rest,
|
|
44
|
+
defaultExpanded: defaultExpanded,
|
|
45
|
+
showFilter: !!setFilter,
|
|
46
|
+
className: (0, _classnames.default)(className, _indexModule.default.collapseExpand, {
|
|
110
47
|
[_indexModule.default.collapse]: collapse
|
|
111
48
|
}),
|
|
112
|
-
|
|
113
|
-
"--column-number": totalColumnNum,
|
|
114
|
-
"--column-offset-width": `${columnOffsetWidth}px`
|
|
115
|
-
},
|
|
116
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
117
|
-
className: (0, _classnames.default)(_indexModule.default.searchOption, _indexModule.default[expand.toString()]),
|
|
118
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Form, {
|
|
119
|
-
form: form,
|
|
120
|
-
className: (0, _classnames.default)(_indexModule.default.option, cls),
|
|
121
|
-
onValuesChange: onValuesChange,
|
|
122
|
-
children: [permitted && currentSearchItems?.map((item, idx) => {
|
|
123
|
-
// 计算同一列的项(用于计算标签宽度)
|
|
124
|
-
const visibleCurrentItems = currentSearchItems.filter(i => i.visible !== false);
|
|
125
|
-
const columnIndex = idx % totalColumnNum;
|
|
126
|
-
const sameColumnItems = visibleCurrentItems.filter((_, _idx) => _idx % totalColumnNum === columnIndex);
|
|
127
|
-
return /*#__PURE__*/(0, _react.createElement)(_FormItem.default, {
|
|
128
|
-
...item,
|
|
129
|
-
key: item.name,
|
|
130
|
-
className: (0, _classnames.default)(_indexModule.default.item, item.className, {
|
|
131
|
-
[_indexModule.default.unFill]: item.width !== undefined
|
|
132
|
-
}),
|
|
133
|
-
labelWidth: item.width !== undefined ? undefined : getLabelWidth(sameColumnItems, undefined, minLabelWidth)
|
|
134
|
-
});
|
|
135
|
-
}), (beforeButtonGroup?.length || affterButtonGroup?.length || permitted) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ButtonGroup.ButtonGroup, {
|
|
136
|
-
beforeButtonGroup: beforeButtonGroup,
|
|
137
|
-
affterButtonGroup: affterButtonGroup,
|
|
138
|
-
expandButton: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandButton.ExpandButton, {
|
|
139
|
-
expand: expand,
|
|
140
|
-
toggleExpand: toggleExpand,
|
|
141
|
-
advancedFilters: false,
|
|
142
|
-
showExpandButton: showExpandButton,
|
|
143
|
-
showAllSearchItems: showAllSearchItems || !!moreSearchItems?.length
|
|
144
|
-
}),
|
|
145
|
-
permitted: permitted,
|
|
146
|
-
ref: buttonGroupRef,
|
|
147
|
-
children: [currentSearchItems.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchButtons.SearchButtons, {
|
|
148
|
-
onSearch: onSearchClick,
|
|
149
|
-
onReset: onResetClick,
|
|
150
|
-
searchDisabled: searchDisabled,
|
|
151
|
-
searchText: searchText,
|
|
152
|
-
resetText: resetText
|
|
153
|
-
}), setFilter && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FilterDropdown.FilterDropdown, {
|
|
154
|
-
searchItems: processedSearchItems,
|
|
155
|
-
originalSearchItems: searchItems,
|
|
156
|
-
setSearchItems: setSearchItems,
|
|
157
|
-
onFilterChange: onFilterChange
|
|
158
|
-
})]
|
|
159
|
-
})]
|
|
160
|
-
})
|
|
161
|
-
}), permitted && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CollapseToggle.CollapseToggle, {
|
|
49
|
+
afterForm: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CollapseToggle.CollapseToggle, {
|
|
162
50
|
collapse: collapse,
|
|
163
51
|
onToggle: handleCollapseToggle
|
|
164
|
-
})
|
|
52
|
+
})
|
|
165
53
|
});
|
|
166
54
|
};
|
|
167
55
|
var _default = exports.default = SearchCollapsible;
|
|
@@ -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
|
* - 提供下拉菜单,允许用户动态选择显示哪些搜索项
|
|
@@ -25,123 +15,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
25
15
|
* - 提供更灵活的搜索体验
|
|
26
16
|
*/
|
|
27
17
|
const SearchWithFilter = props => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
className,
|
|
32
|
-
onSearch,
|
|
33
|
-
onReset,
|
|
34
|
-
externalForm,
|
|
35
|
-
hasPermi,
|
|
36
|
-
columnNum = 4,
|
|
37
|
-
beforeButtonGroup,
|
|
38
|
-
affterButtonGroup,
|
|
39
|
-
searchData,
|
|
40
|
-
minLabelWidth,
|
|
41
|
-
defaultExpanded = false,
|
|
42
|
-
onExpandChange,
|
|
43
|
-
autoAdaptWidth = true,
|
|
44
|
-
baseWidth,
|
|
45
|
-
onValuesChange,
|
|
46
|
-
searchDisabled = false,
|
|
47
|
-
showAllSearchItems = false,
|
|
48
|
-
searchText,
|
|
49
|
-
resetText,
|
|
50
|
-
onFilterChange,
|
|
51
|
-
columnOffsetWidth = 0
|
|
52
|
-
} = props;
|
|
53
|
-
const [form] = _antd.Form.useForm(externalForm);
|
|
54
|
-
const {
|
|
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,
|
|
83
|
-
minLabelWidth,
|
|
84
|
-
baseWidth,
|
|
85
|
-
onSearch,
|
|
86
|
-
onReset,
|
|
87
|
-
columnOffsetWidth
|
|
88
|
-
});
|
|
89
|
-
if (!shouldRender) {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
93
|
-
ref: containerRef,
|
|
94
|
-
className: (0, _classnames.default)(_indexModule.default.Search, className),
|
|
95
|
-
style: {
|
|
96
|
-
"--column-number": totalColumnNum,
|
|
97
|
-
"--column-offset-width": `${columnOffsetWidth}px`
|
|
98
|
-
},
|
|
99
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
100
|
-
className: (0, _classnames.default)(_indexModule.default.searchOption, _indexModule.default[expand.toString()]),
|
|
101
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Form, {
|
|
102
|
-
form: form,
|
|
103
|
-
className: (0, _classnames.default)(_indexModule.default.option, cls),
|
|
104
|
-
onValuesChange: onValuesChange,
|
|
105
|
-
children: [permitted && currentSearchItems?.map((item, idx) => {
|
|
106
|
-
// 计算同一列的项(用于计算标签宽度)
|
|
107
|
-
const visibleCurrentItems = currentSearchItems.filter(i => i.visible !== false);
|
|
108
|
-
const columnIndex = idx % totalColumnNum;
|
|
109
|
-
const sameColumnItems = visibleCurrentItems.filter((_, _idx) => _idx % totalColumnNum === columnIndex);
|
|
110
|
-
return /*#__PURE__*/(0, _react.createElement)(_FormItem.default, {
|
|
111
|
-
...item,
|
|
112
|
-
key: item.name,
|
|
113
|
-
className: (0, _classnames.default)(_indexModule.default.item, item.className, {
|
|
114
|
-
[_indexModule.default.unFill]: item.width !== undefined
|
|
115
|
-
}),
|
|
116
|
-
labelWidth: item.width !== undefined ? undefined : getLabelWidth(sameColumnItems, undefined, minLabelWidth)
|
|
117
|
-
});
|
|
118
|
-
}), (beforeButtonGroup?.length || affterButtonGroup?.length || permitted) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ButtonGroup.ButtonGroup, {
|
|
119
|
-
beforeButtonGroup: beforeButtonGroup,
|
|
120
|
-
affterButtonGroup: affterButtonGroup,
|
|
121
|
-
expandButton: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandButton.ExpandButton, {
|
|
122
|
-
expand: expand,
|
|
123
|
-
toggleExpand: toggleExpand,
|
|
124
|
-
advancedFilters: false,
|
|
125
|
-
showExpandButton: showExpandButton,
|
|
126
|
-
showAllSearchItems: showAllSearchItems || !!moreSearchItems?.length
|
|
127
|
-
}),
|
|
128
|
-
permitted: permitted,
|
|
129
|
-
ref: buttonGroupRef,
|
|
130
|
-
children: [currentSearchItems.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchButtons.SearchButtons, {
|
|
131
|
-
onSearch: onSearchClick,
|
|
132
|
-
onReset: onResetClick,
|
|
133
|
-
searchDisabled: searchDisabled,
|
|
134
|
-
searchText: searchText,
|
|
135
|
-
resetText: resetText
|
|
136
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FilterDropdown.FilterDropdown, {
|
|
137
|
-
searchItems: processedSearchItems,
|
|
138
|
-
originalSearchItems: searchItems,
|
|
139
|
-
setSearchItems: setSearchItems,
|
|
140
|
-
onFilterChange: onFilterChange
|
|
141
|
-
})]
|
|
142
|
-
})]
|
|
143
|
-
})
|
|
144
|
-
})
|
|
18
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchBase.default, {
|
|
19
|
+
...props,
|
|
20
|
+
showFilter: true
|
|
145
21
|
});
|
|
146
22
|
};
|
|
147
23
|
var _default = exports.default = SearchWithFilter;
|
|
@@ -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;
|