@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
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React, { useMemo } from "react";
|
|
14
|
+
import { Form as AntdForm } from "antd";
|
|
15
|
+
import classNames from "classnames";
|
|
16
|
+
import FormItem from "../../../FormItem";
|
|
17
|
+
import styles from "../../index.module.scss";
|
|
18
|
+
import { useSearchCommon } from "../../_hooks";
|
|
19
|
+
import { ButtonGroup } from "../ButtonGroup";
|
|
20
|
+
import { SearchButtons } from "../SearchButtons";
|
|
21
|
+
import { ExpandButton } from "../ExpandButton";
|
|
22
|
+
import { FilterDropdown } from "../FilterDropdown";
|
|
23
|
+
|
|
24
|
+
/** 暴露给变体扩展渲染(如高级筛选抽屉)的上下文 */
|
|
25
|
+
import { createElement as _createElement } from "react";
|
|
26
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
29
|
+
/**
|
|
30
|
+
* Search 各变体共享的基础实现:
|
|
31
|
+
* 表单渲染、列布局、展开/收起、按钮组、权限控制。
|
|
32
|
+
* 变体只负责自身差异(筛选器、折叠开关、高级筛选抽屉等)。
|
|
33
|
+
*/
|
|
34
|
+
var SearchBase = function SearchBase(props) {
|
|
35
|
+
var _props$searchItems = props.searchItems,
|
|
36
|
+
searchItems = _props$searchItems === void 0 ? [] : _props$searchItems,
|
|
37
|
+
_props$moreSearchItem = props.moreSearchItems,
|
|
38
|
+
moreSearchItems = _props$moreSearchItem === void 0 ? [] : _props$moreSearchItem,
|
|
39
|
+
className = props.className,
|
|
40
|
+
onSearch = props.onSearch,
|
|
41
|
+
onReset = props.onReset,
|
|
42
|
+
externalForm = props.externalForm,
|
|
43
|
+
hasPermi = props.hasPermi,
|
|
44
|
+
_props$columnNum = props.columnNum,
|
|
45
|
+
columnNum = _props$columnNum === void 0 ? 4 : _props$columnNum,
|
|
46
|
+
beforeButtonGroup = props.beforeButtonGroup,
|
|
47
|
+
affterButtonGroup = props.affterButtonGroup,
|
|
48
|
+
searchData = props.searchData,
|
|
49
|
+
minLabelWidth = props.minLabelWidth,
|
|
50
|
+
_props$defaultExpande = props.defaultExpanded,
|
|
51
|
+
defaultExpanded = _props$defaultExpande === void 0 ? false : _props$defaultExpande,
|
|
52
|
+
onExpandChange = props.onExpandChange,
|
|
53
|
+
_props$autoAdaptWidth = props.autoAdaptWidth,
|
|
54
|
+
autoAdaptWidth = _props$autoAdaptWidth === void 0 ? true : _props$autoAdaptWidth,
|
|
55
|
+
baseWidth = props.baseWidth,
|
|
56
|
+
onValuesChange = props.onValuesChange,
|
|
57
|
+
_props$searchDisabled = props.searchDisabled,
|
|
58
|
+
searchDisabled = _props$searchDisabled === void 0 ? false : _props$searchDisabled,
|
|
59
|
+
_props$showAllSearchI = props.showAllSearchItems,
|
|
60
|
+
showAllSearchItems = _props$showAllSearchI === void 0 ? false : _props$showAllSearchI,
|
|
61
|
+
searchText = props.searchText,
|
|
62
|
+
resetText = props.resetText,
|
|
63
|
+
onFilterChange = props.onFilterChange,
|
|
64
|
+
_props$columnOffsetWi = props.columnOffsetWidth,
|
|
65
|
+
columnOffsetWidth = _props$columnOffsetWi === void 0 ? 0 : _props$columnOffsetWi,
|
|
66
|
+
_props$advancedFilter = props.advancedFilters,
|
|
67
|
+
advancedFilters = _props$advancedFilter === void 0 ? false : _props$advancedFilter,
|
|
68
|
+
_props$showFilter = props.showFilter,
|
|
69
|
+
showFilter = _props$showFilter === void 0 ? false : _props$showFilter,
|
|
70
|
+
afterForm = props.afterForm,
|
|
71
|
+
renderOutside = props.renderOutside;
|
|
72
|
+
var _AntdForm$useForm = AntdForm.useForm(externalForm),
|
|
73
|
+
_AntdForm$useForm2 = _slicedToArray(_AntdForm$useForm, 1),
|
|
74
|
+
form = _AntdForm$useForm2[0];
|
|
75
|
+
var _useSearchCommon = useSearchCommon({
|
|
76
|
+
form: form,
|
|
77
|
+
searchItems: searchItems,
|
|
78
|
+
moreSearchItems: moreSearchItems,
|
|
79
|
+
searchData: searchData,
|
|
80
|
+
hasPermi: hasPermi,
|
|
81
|
+
beforeButtonGroup: beforeButtonGroup,
|
|
82
|
+
affterButtonGroup: affterButtonGroup,
|
|
83
|
+
columnNum: columnNum,
|
|
84
|
+
autoAdaptWidth: autoAdaptWidth,
|
|
85
|
+
defaultExpanded: defaultExpanded,
|
|
86
|
+
onExpandChange: onExpandChange,
|
|
87
|
+
showAllSearchItems: showAllSearchItems,
|
|
88
|
+
minLabelWidth: minLabelWidth,
|
|
89
|
+
baseWidth: baseWidth,
|
|
90
|
+
onSearch: onSearch,
|
|
91
|
+
onReset: onReset,
|
|
92
|
+
columnOffsetWidth: columnOffsetWidth
|
|
93
|
+
}),
|
|
94
|
+
containerRef = _useSearchCommon.containerRef,
|
|
95
|
+
buttonGroupRef = _useSearchCommon.buttonGroupRef,
|
|
96
|
+
cls = _useSearchCommon.cls,
|
|
97
|
+
getLabelWidth = _useSearchCommon.getLabelWidth,
|
|
98
|
+
processedSearchItems = _useSearchCommon.processedSearchItems,
|
|
99
|
+
setSearchItems = _useSearchCommon.setSearchItems,
|
|
100
|
+
currentSearchItems = _useSearchCommon.currentSearchItems,
|
|
101
|
+
totalColumnNum = _useSearchCommon.totalColumnNum,
|
|
102
|
+
expand = _useSearchCommon.expand,
|
|
103
|
+
setExpand = _useSearchCommon.setExpand,
|
|
104
|
+
toggleExpand = _useSearchCommon.toggleExpand,
|
|
105
|
+
showExpandButton = _useSearchCommon.showExpandButton,
|
|
106
|
+
onSearchClick = _useSearchCommon.onSearchClick,
|
|
107
|
+
onResetClick = _useSearchCommon.onResetClick,
|
|
108
|
+
shouldRender = _useSearchCommon.shouldRender,
|
|
109
|
+
permitted = _useSearchCommon.permitted;
|
|
110
|
+
|
|
111
|
+
// 按列分组预计算(用于对齐同列 label 宽度),避免在 map 中逐项重复 filter
|
|
112
|
+
var columnGroups = useMemo(function () {
|
|
113
|
+
var groups = Array.from({
|
|
114
|
+
length: totalColumnNum
|
|
115
|
+
}, function () {
|
|
116
|
+
return [];
|
|
117
|
+
});
|
|
118
|
+
currentSearchItems.forEach(function (item, idx) {
|
|
119
|
+
groups[idx % totalColumnNum].push(item);
|
|
120
|
+
});
|
|
121
|
+
return groups;
|
|
122
|
+
}, [currentSearchItems, totalColumnNum]);
|
|
123
|
+
if (!shouldRender) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
127
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
128
|
+
ref: containerRef,
|
|
129
|
+
className: classNames(styles.Search, className),
|
|
130
|
+
style: {
|
|
131
|
+
"--column-number": totalColumnNum,
|
|
132
|
+
"--column-offset-width": "".concat(columnOffsetWidth, "px")
|
|
133
|
+
},
|
|
134
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
135
|
+
className: classNames(styles.searchOption, styles[expand.toString()]),
|
|
136
|
+
children: /*#__PURE__*/_jsxs(AntdForm, {
|
|
137
|
+
form: form,
|
|
138
|
+
className: classNames(styles.option, cls),
|
|
139
|
+
onValuesChange: onValuesChange,
|
|
140
|
+
children: [permitted && currentSearchItems.map(function (item, idx) {
|
|
141
|
+
return /*#__PURE__*/_createElement(FormItem, _objectSpread(_objectSpread({}, item), {}, {
|
|
142
|
+
key: item.name,
|
|
143
|
+
className: classNames(styles.item, item.className, _defineProperty({}, styles.unFill, item.width !== undefined)),
|
|
144
|
+
label: advancedFilters ? undefined : item.label,
|
|
145
|
+
labelWidth: advancedFilters || item.width !== undefined ? undefined : getLabelWidth(columnGroups[idx % totalColumnNum], undefined, minLabelWidth)
|
|
146
|
+
}));
|
|
147
|
+
}), ((beforeButtonGroup === null || beforeButtonGroup === void 0 ? void 0 : beforeButtonGroup.length) || (affterButtonGroup === null || affterButtonGroup === void 0 ? void 0 : affterButtonGroup.length) || permitted) && /*#__PURE__*/_jsxs(ButtonGroup, {
|
|
148
|
+
beforeButtonGroup: beforeButtonGroup,
|
|
149
|
+
affterButtonGroup: affterButtonGroup,
|
|
150
|
+
expandButton: /*#__PURE__*/_jsx(ExpandButton, {
|
|
151
|
+
expand: expand,
|
|
152
|
+
toggleExpand: toggleExpand,
|
|
153
|
+
advancedFilters: advancedFilters,
|
|
154
|
+
showExpandButton: showExpandButton,
|
|
155
|
+
showAllSearchItems: showAllSearchItems || !!(moreSearchItems !== null && moreSearchItems !== void 0 && moreSearchItems.length)
|
|
156
|
+
}),
|
|
157
|
+
permitted: permitted,
|
|
158
|
+
ref: buttonGroupRef,
|
|
159
|
+
children: [currentSearchItems.length > 0 && /*#__PURE__*/_jsx(SearchButtons, {
|
|
160
|
+
onSearch: onSearchClick,
|
|
161
|
+
onReset: onResetClick,
|
|
162
|
+
searchDisabled: searchDisabled,
|
|
163
|
+
searchText: searchText,
|
|
164
|
+
resetText: resetText
|
|
165
|
+
}), showFilter && /*#__PURE__*/_jsx(FilterDropdown, {
|
|
166
|
+
searchItems: processedSearchItems,
|
|
167
|
+
originalSearchItems: searchItems,
|
|
168
|
+
setSearchItems: setSearchItems,
|
|
169
|
+
onFilterChange: onFilterChange
|
|
170
|
+
})]
|
|
171
|
+
})]
|
|
172
|
+
})
|
|
173
|
+
}), permitted && afterForm]
|
|
174
|
+
}), permitted && (renderOutside === null || renderOutside === void 0 ? void 0 : renderOutside({
|
|
175
|
+
form: form,
|
|
176
|
+
expand: expand,
|
|
177
|
+
setExpand: setExpand,
|
|
178
|
+
processedSearchItems: processedSearchItems,
|
|
179
|
+
getLabelWidth: getLabelWidth,
|
|
180
|
+
onSearchClick: onSearchClick,
|
|
181
|
+
onResetClick: onResetClick
|
|
182
|
+
}))]
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
export default SearchBase;
|
|
@@ -16,7 +16,7 @@ import { useSearchItems } from "./useSearchItems";
|
|
|
16
16
|
import { useSearchForm } from "./useSearchForm";
|
|
17
17
|
import { useAdaptiveColumnNum } from "./useAdaptiveColumnNum";
|
|
18
18
|
import { useSearchExpand } from "./useSearchExpand";
|
|
19
|
-
import { cleanSearchData, calculateVisibleItems, calculateButtonGroupAndColumnWidth } from "../_utils";
|
|
19
|
+
import { cleanSearchData, calculateVisibleItems, calculateButtonGroupAndColumnWidth, shouldDisplayExtraItem } from "../_utils";
|
|
20
20
|
import styles from "../index.module.scss";
|
|
21
21
|
/**
|
|
22
22
|
* 提取所有 Search 组件的通用逻辑
|
|
@@ -70,14 +70,10 @@ export var useSearchCommon = function useSearchCommon(params) {
|
|
|
70
70
|
}, [moreSearchItems]);
|
|
71
71
|
|
|
72
72
|
// 计算可见的搜索项数量
|
|
73
|
-
var visibleSearchItemCount =
|
|
74
|
-
return visibleSearchItems.length;
|
|
75
|
-
}, [visibleSearchItems]);
|
|
73
|
+
var visibleSearchItemCount = visibleSearchItems.length;
|
|
76
74
|
|
|
77
75
|
// 计算总列数(包括按钮组)
|
|
78
|
-
var baseTotalColumnNum =
|
|
79
|
-
return columnNum + 1;
|
|
80
|
-
}, [columnNum]);
|
|
76
|
+
var baseTotalColumnNum = columnNum + 1;
|
|
81
77
|
|
|
82
78
|
// 根据容器宽度动态调整列数
|
|
83
79
|
var totalColumnNum = useAdaptiveColumnNum(containerRef, baseTotalColumnNum, autoAdaptWidth, 1,
|
|
@@ -89,9 +85,7 @@ export var useSearchCommon = function useSearchCommon(params) {
|
|
|
89
85
|
baseWidth);
|
|
90
86
|
|
|
91
87
|
// 计算调整后的搜索项列数(不包括按钮组)
|
|
92
|
-
var adaptiveColumnNum =
|
|
93
|
-
return Math.max(1, totalColumnNum - 1);
|
|
94
|
-
}, [totalColumnNum]);
|
|
88
|
+
var adaptiveColumnNum = Math.max(1, totalColumnNum - 1);
|
|
95
89
|
|
|
96
90
|
// 使用基于宽度的展开/收起控制
|
|
97
91
|
var _useSearchExpand = useSearchExpand(containerRef, buttonGroupRef, ".".concat(cls, " .").concat(styles.item), visibleSearchItemCount, adaptiveColumnNum, autoAdaptWidth, defaultExpanded, onExpandChange, processedSearchItems, showAllSearchItems || !!(moreSearchItems !== null && moreSearchItems !== void 0 && moreSearchItems.length), columnOffsetWidth),
|
|
@@ -155,7 +149,7 @@ export var useSearchCommon = function useSearchCommon(params) {
|
|
|
155
149
|
columnWidth = _calculateButtonGroup.columnWidth;
|
|
156
150
|
|
|
157
151
|
// 判断按钮组宽度是否大于列宽,如果是,则显示 实际搜索项数量+1
|
|
158
|
-
if (
|
|
152
|
+
if (shouldDisplayExtraItem(buttonGroupWidth, columnWidth, adaptiveColumnNum, visibleSearchItemCount)) {
|
|
159
153
|
return adaptiveColumnNum + 1;
|
|
160
154
|
}
|
|
161
155
|
return adaptiveColumnNum;
|
|
@@ -5,6 +5,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { useState, useEffect, useCallback } from "react";
|
|
8
|
+
import { measureButtonGroupWidth } from "../_utils";
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* 基于宽度自适应控制展开/收起的Hook
|
|
10
12
|
* @param containerRef 容器引用
|
|
@@ -35,25 +37,14 @@ export function useSearchExpand(containerRef, buttonGroupRef, itemClassName, ite
|
|
|
35
37
|
}
|
|
36
38
|
var container = containerRef.current;
|
|
37
39
|
var calculateVisibleItems = function calculateVisibleItems() {
|
|
40
|
+
var _measureButtonGroupWi;
|
|
38
41
|
if (!containerRef.current || !buttonGroupRef.current) return;
|
|
39
42
|
var containerWidth = container.offsetWidth;
|
|
40
43
|
// 减去padding
|
|
41
44
|
var availableWidth = containerWidth - 30; // 15px padding on each side
|
|
42
45
|
|
|
43
46
|
// 获取按钮组的实际宽度(计算所有子元素宽度总和)
|
|
44
|
-
var buttonGroupWidth = 0;
|
|
45
|
-
var buttonChildren = Array.from(buttonGroupRef.current.children);
|
|
46
|
-
if (buttonChildren.length > 0) {
|
|
47
|
-
// 计算所有子元素的宽度总和
|
|
48
|
-
var totalWidth = 0;
|
|
49
|
-
buttonChildren === null || buttonChildren === void 0 || buttonChildren.forEach(function (child) {
|
|
50
|
-
totalWidth += child.offsetWidth;
|
|
51
|
-
});
|
|
52
|
-
// 加上子元素之间的间距(column-gap: 10px)
|
|
53
|
-
var childGap = 5;
|
|
54
|
-
totalWidth += (buttonChildren.length - 1) * childGap;
|
|
55
|
-
buttonGroupWidth = totalWidth;
|
|
56
|
-
}
|
|
47
|
+
var buttonGroupWidth = (_measureButtonGroupWi = measureButtonGroupWidth(buttonGroupRef.current)) !== null && _measureButtonGroupWi !== void 0 ? _measureButtonGroupWi : 0;
|
|
57
48
|
|
|
58
49
|
// 获取所有搜索项元素
|
|
59
50
|
var items = container.querySelectorAll("".concat(itemClassName));
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { measureButtonGroupWidth } from "./measureButtonGroupWidth";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 计算按钮组宽度和列宽
|
|
3
5
|
* @param containerRef 容器引用
|
|
@@ -16,16 +18,7 @@ export function calculateButtonGroupAndColumnWidth(containerRef, buttonGroupRef,
|
|
|
16
18
|
var gap = 10; // 项之间的间距
|
|
17
19
|
|
|
18
20
|
// 计算按钮组宽度
|
|
19
|
-
|
|
20
|
-
if (buttonChildren.length > 0) {
|
|
21
|
-
var totalWidth = 0;
|
|
22
|
-
buttonChildren === null || buttonChildren === void 0 || buttonChildren.forEach(function (child) {
|
|
23
|
-
totalWidth += child.offsetWidth;
|
|
24
|
-
});
|
|
25
|
-
var childGap = 5;
|
|
26
|
-
totalWidth += (buttonChildren.length - 1) * childGap;
|
|
27
|
-
buttonGroupWidth = totalWidth;
|
|
28
|
-
}
|
|
21
|
+
buttonGroupWidth = measureButtonGroupWidth(buttonGroupRef.current);
|
|
29
22
|
|
|
30
23
|
// 计算列宽(单个搜索项的默认宽度)
|
|
31
24
|
if (adaptiveColumnNum > 0) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { shouldDisplayExtraItem } from "./shouldDisplayExtraItem";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 计算当前应该显示的搜索项
|
|
3
5
|
* @param searchItems 所有搜索项
|
|
@@ -13,7 +15,7 @@ export function calculateVisibleItems(searchItems, expand, columnNum, visibleIte
|
|
|
13
15
|
var visibleItems = searchItems.filter(function (item) {
|
|
14
16
|
return item.visible;
|
|
15
17
|
});
|
|
16
|
-
var hasCustomWidth = searchItems.
|
|
18
|
+
var hasCustomWidth = searchItems.some(function (item) {
|
|
17
19
|
return item.width !== undefined;
|
|
18
20
|
});
|
|
19
21
|
if (!expand) {
|
|
@@ -25,10 +27,7 @@ export function calculateVisibleItems(searchItems, expand, columnNum, visibleIte
|
|
|
25
27
|
} else if (!hasCustomWidth) {
|
|
26
28
|
// 没有自定义宽度时,使用 columnNum(实际搜索项数量)
|
|
27
29
|
// 判断按钮组宽度是否大于列宽,如果是,则显示 实际搜索项数量+1
|
|
28
|
-
var displayCount = columnNum;
|
|
29
|
-
if (buttonGroupWidth !== undefined && columnWidth !== undefined && (buttonGroupWidth > columnWidth || buttonGroupWidth < columnWidth && columnNum + 1 === visibleItems.length)) {
|
|
30
|
-
displayCount = columnNum + 1;
|
|
31
|
-
}
|
|
30
|
+
var displayCount = shouldDisplayExtraItem(buttonGroupWidth, columnWidth, columnNum, visibleItems.length) ? columnNum + 1 : columnNum;
|
|
32
31
|
if (visibleItems.length >= displayCount) {
|
|
33
32
|
return visibleItems.slice(0, displayCount);
|
|
34
33
|
}
|
|
@@ -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";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { cleanSearchData } from "./cleanSearchData";
|
|
2
2
|
export { calculateVisibleItems } from "./calculateVisibleItems";
|
|
3
|
-
export { calculateButtonGroupAndColumnWidth } from "./calculateButtonGroupAndColumnWidth";
|
|
3
|
+
export { calculateButtonGroupAndColumnWidth } from "./calculateButtonGroupAndColumnWidth";
|
|
4
|
+
export { measureButtonGroupWidth } from "./measureButtonGroupWidth";
|
|
5
|
+
export { shouldDisplayExtraItem } from "./shouldDisplayExtraItem";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 计算按钮组的实际宽度(所有子元素宽度总和 + 子元素间距)
|
|
3
|
+
* @param buttonGroupEl 按钮组元素
|
|
4
|
+
* @returns 按钮组宽度;无子元素时返回 undefined
|
|
5
|
+
*/
|
|
6
|
+
export function measureButtonGroupWidth(buttonGroupEl) {
|
|
7
|
+
if (!buttonGroupEl) return undefined;
|
|
8
|
+
var buttonChildren = Array.from(buttonGroupEl.children);
|
|
9
|
+
if (buttonChildren.length === 0) return undefined;
|
|
10
|
+
var totalWidth = 0;
|
|
11
|
+
buttonChildren.forEach(function (child) {
|
|
12
|
+
totalWidth += child.offsetWidth;
|
|
13
|
+
});
|
|
14
|
+
// 加上子元素之间的间距
|
|
15
|
+
var childGap = 5;
|
|
16
|
+
totalWidth += (buttonChildren.length - 1) * childGap;
|
|
17
|
+
return totalWidth;
|
|
18
|
+
}
|
|
@@ -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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断收起状态下是否应多显示一个搜索项
|
|
3
|
+
*
|
|
4
|
+
* 规则:按钮组宽度大于列宽(按钮组独占更宽空间,首行有富余);
|
|
5
|
+
* 或按钮组宽度小于列宽且可见项刚好比列数多 1(此时收起只会藏起 1 项,不如直接放下)。
|
|
6
|
+
* @param buttonGroupWidth 按钮组宽度
|
|
7
|
+
* @param columnWidth 列宽
|
|
8
|
+
* @param columnNum 搜索项列数(不含按钮组)
|
|
9
|
+
* @param visibleCount 可见搜索项总数
|
|
10
|
+
*/
|
|
11
|
+
export function shouldDisplayExtraItem(buttonGroupWidth, columnWidth, columnNum, visibleCount) {
|
|
12
|
+
return buttonGroupWidth !== undefined && columnWidth !== undefined && (buttonGroupWidth > columnWidth || buttonGroupWidth < columnWidth && columnNum + 1 === visibleCount);
|
|
13
|
+
}
|
|
@@ -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;
|
|
@@ -4,151 +4,24 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
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; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import { Form as AntdForm } from "antd";
|
|
14
|
-
import FormItem from "../FormItem";
|
|
15
7
|
import React from "react";
|
|
16
|
-
import classNames from "classnames";
|
|
17
|
-
import styles from "./index.module.scss";
|
|
18
|
-
import { useSearchCommon } from "./_hooks";
|
|
19
8
|
import SearchCard from "./SearchCard";
|
|
20
9
|
import SearchAdvanced from "./SearchAdvanced";
|
|
21
10
|
import SearchCollapsible from "./SearchCollapsible";
|
|
22
11
|
import SearchWithFilter from "./SearchWithFilter";
|
|
23
12
|
import SearchWithMore from "./SearchWithMore";
|
|
24
|
-
import
|
|
25
|
-
import { SearchButtons } from "./_components/SearchButtons";
|
|
26
|
-
import { ExpandButton } from "./_components/ExpandButton";
|
|
13
|
+
import SearchBase from "./_components/SearchBase";
|
|
27
14
|
|
|
28
15
|
// 导出所有可用的 Search 模式键名
|
|
29
16
|
|
|
30
17
|
// 导出 Search 模式映射类型
|
|
31
|
-
import { createElement as _createElement } from "react";
|
|
32
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
33
|
-
|
|
19
|
+
/**
|
|
20
|
+
* 基础 Search 组件
|
|
21
|
+
* - 标准的搜索表单布局,自适应列数与展开/收起
|
|
22
|
+
*/
|
|
34
23
|
var Search = function Search(props) {
|
|
35
|
-
|
|
36
|
-
searchItems = _props$searchItems === void 0 ? [] : _props$searchItems,
|
|
37
|
-
_props$moreSearchItem = props.moreSearchItems,
|
|
38
|
-
moreSearchItems = _props$moreSearchItem === void 0 ? [] : _props$moreSearchItem,
|
|
39
|
-
className = props.className,
|
|
40
|
-
onSearch = props.onSearch,
|
|
41
|
-
onReset = props.onReset,
|
|
42
|
-
externalForm = props.externalForm,
|
|
43
|
-
hasPermi = props.hasPermi,
|
|
44
|
-
_props$columnNum = props.columnNum,
|
|
45
|
-
columnNum = _props$columnNum === void 0 ? 4 : _props$columnNum,
|
|
46
|
-
beforeButtonGroup = props.beforeButtonGroup,
|
|
47
|
-
affterButtonGroup = props.affterButtonGroup,
|
|
48
|
-
searchData = props.searchData,
|
|
49
|
-
minLabelWidth = props.minLabelWidth,
|
|
50
|
-
_props$defaultExpande = props.defaultExpanded,
|
|
51
|
-
defaultExpanded = _props$defaultExpande === void 0 ? false : _props$defaultExpande,
|
|
52
|
-
onExpandChange = props.onExpandChange,
|
|
53
|
-
_props$autoAdaptWidth = props.autoAdaptWidth,
|
|
54
|
-
autoAdaptWidth = _props$autoAdaptWidth === void 0 ? true : _props$autoAdaptWidth,
|
|
55
|
-
baseWidth = props.baseWidth,
|
|
56
|
-
onValuesChange = props.onValuesChange,
|
|
57
|
-
_props$searchDisabled = props.searchDisabled,
|
|
58
|
-
searchDisabled = _props$searchDisabled === void 0 ? false : _props$searchDisabled,
|
|
59
|
-
_props$showAllSearchI = props.showAllSearchItems,
|
|
60
|
-
showAllSearchItems = _props$showAllSearchI === void 0 ? false : _props$showAllSearchI,
|
|
61
|
-
searchText = props.searchText,
|
|
62
|
-
resetText = props.resetText,
|
|
63
|
-
_props$columnOffsetWi = props.columnOffsetWidth,
|
|
64
|
-
columnOffsetWidth = _props$columnOffsetWi === void 0 ? 0 : _props$columnOffsetWi;
|
|
65
|
-
var _AntdForm$useForm = AntdForm.useForm(externalForm),
|
|
66
|
-
_AntdForm$useForm2 = _slicedToArray(_AntdForm$useForm, 1),
|
|
67
|
-
form = _AntdForm$useForm2[0];
|
|
68
|
-
var _useSearchCommon = useSearchCommon({
|
|
69
|
-
form: form,
|
|
70
|
-
searchItems: searchItems,
|
|
71
|
-
moreSearchItems: moreSearchItems,
|
|
72
|
-
searchData: searchData,
|
|
73
|
-
hasPermi: hasPermi,
|
|
74
|
-
beforeButtonGroup: beforeButtonGroup,
|
|
75
|
-
affterButtonGroup: affterButtonGroup,
|
|
76
|
-
columnNum: columnNum,
|
|
77
|
-
autoAdaptWidth: autoAdaptWidth,
|
|
78
|
-
defaultExpanded: defaultExpanded,
|
|
79
|
-
onExpandChange: onExpandChange,
|
|
80
|
-
showAllSearchItems: showAllSearchItems,
|
|
81
|
-
minLabelWidth: minLabelWidth,
|
|
82
|
-
baseWidth: baseWidth,
|
|
83
|
-
onSearch: onSearch,
|
|
84
|
-
onReset: onReset,
|
|
85
|
-
columnOffsetWidth: columnOffsetWidth
|
|
86
|
-
}),
|
|
87
|
-
containerRef = _useSearchCommon.containerRef,
|
|
88
|
-
buttonGroupRef = _useSearchCommon.buttonGroupRef,
|
|
89
|
-
cls = _useSearchCommon.cls,
|
|
90
|
-
getLabelWidth = _useSearchCommon.getLabelWidth,
|
|
91
|
-
currentSearchItems = _useSearchCommon.currentSearchItems,
|
|
92
|
-
totalColumnNum = _useSearchCommon.totalColumnNum,
|
|
93
|
-
expand = _useSearchCommon.expand,
|
|
94
|
-
toggleExpand = _useSearchCommon.toggleExpand,
|
|
95
|
-
showExpandButton = _useSearchCommon.showExpandButton,
|
|
96
|
-
onSearchClick = _useSearchCommon.onSearchClick,
|
|
97
|
-
onResetClick = _useSearchCommon.onResetClick,
|
|
98
|
-
shouldRender = _useSearchCommon.shouldRender,
|
|
99
|
-
permitted = _useSearchCommon.permitted;
|
|
100
|
-
if (!shouldRender) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
return /*#__PURE__*/_jsx("div", {
|
|
104
|
-
ref: containerRef,
|
|
105
|
-
className: classNames(styles.Search, className),
|
|
106
|
-
style: {
|
|
107
|
-
"--column-number": totalColumnNum,
|
|
108
|
-
"--column-offset-width": "".concat(columnOffsetWidth, "px")
|
|
109
|
-
},
|
|
110
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
111
|
-
className: classNames(styles.searchOption, styles[expand.toString()]),
|
|
112
|
-
children: /*#__PURE__*/_jsxs(AntdForm, {
|
|
113
|
-
form: form,
|
|
114
|
-
className: classNames(styles.option, cls),
|
|
115
|
-
onValuesChange: onValuesChange,
|
|
116
|
-
children: [permitted && (currentSearchItems === null || currentSearchItems === void 0 ? void 0 : currentSearchItems.map(function (item, idx) {
|
|
117
|
-
var visibleCurrentItems = currentSearchItems.filter(function (i) {
|
|
118
|
-
return i.visible !== false;
|
|
119
|
-
});
|
|
120
|
-
var columnIndex = idx % totalColumnNum;
|
|
121
|
-
var sameColumnItems = visibleCurrentItems.filter(function (_, _idx) {
|
|
122
|
-
return _idx % totalColumnNum === columnIndex;
|
|
123
|
-
});
|
|
124
|
-
return /*#__PURE__*/_createElement(FormItem, _objectSpread(_objectSpread({}, item), {}, {
|
|
125
|
-
key: item.name,
|
|
126
|
-
className: classNames(styles.item, item.className, _defineProperty({}, styles.unFill, item.width !== undefined)),
|
|
127
|
-
labelWidth: item.width !== undefined ? undefined : getLabelWidth(sameColumnItems, undefined, minLabelWidth)
|
|
128
|
-
}));
|
|
129
|
-
})), ((beforeButtonGroup === null || beforeButtonGroup === void 0 ? void 0 : beforeButtonGroup.length) || (affterButtonGroup === null || affterButtonGroup === void 0 ? void 0 : affterButtonGroup.length) || permitted) && /*#__PURE__*/_jsx(ButtonGroup, {
|
|
130
|
-
beforeButtonGroup: beforeButtonGroup,
|
|
131
|
-
affterButtonGroup: affterButtonGroup,
|
|
132
|
-
expandButton: /*#__PURE__*/_jsx(ExpandButton, {
|
|
133
|
-
expand: expand,
|
|
134
|
-
toggleExpand: toggleExpand,
|
|
135
|
-
advancedFilters: false,
|
|
136
|
-
showExpandButton: showExpandButton,
|
|
137
|
-
showAllSearchItems: showAllSearchItems || !!(moreSearchItems !== null && moreSearchItems !== void 0 && moreSearchItems.length)
|
|
138
|
-
}),
|
|
139
|
-
permitted: permitted,
|
|
140
|
-
ref: buttonGroupRef,
|
|
141
|
-
children: currentSearchItems.length > 0 && /*#__PURE__*/_jsx(SearchButtons, {
|
|
142
|
-
onSearch: onSearchClick,
|
|
143
|
-
onReset: onResetClick,
|
|
144
|
-
searchDisabled: searchDisabled,
|
|
145
|
-
searchText: searchText,
|
|
146
|
-
resetText: resetText
|
|
147
|
-
})
|
|
148
|
-
})]
|
|
149
|
-
})
|
|
150
|
-
})
|
|
151
|
-
});
|
|
24
|
+
return /*#__PURE__*/_jsx(SearchBase, _objectSpread({}, props));
|
|
152
25
|
};
|
|
153
26
|
Search.Card = SearchCard;
|
|
154
27
|
Search.Advanced = SearchAdvanced;
|
|
@@ -26,6 +26,8 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
26
26
|
var MEASURE_ALIGN_FONT_SIZE = 14;
|
|
27
27
|
// Canvas measureText 仅返回 advance width,较 DOM 实际渲染偏窄约 1px,补 2px 缓冲避免最宽行被挤压
|
|
28
28
|
var MEASURE_ALIGN_BUFFER_PX = 2;
|
|
29
|
+
// 单元格左右内边距合计(--td-padding: 4px 8px),用于把列宽抬到能放下定宽内容块
|
|
30
|
+
var MEASURE_ALIGN_CELL_PADDING_PX = 16;
|
|
29
31
|
|
|
30
32
|
// 计算 measureAlign 列的定宽(取本列所有行展示文本的最大像素宽)
|
|
31
33
|
var getMeasureAlignWidth = function getMeasureAlignWidth(column, dataSource) {
|
|
@@ -124,6 +126,15 @@ var useTableColumns = function useTableColumns(params) {
|
|
|
124
126
|
}, 0)) !== null && _dataSource$reduce !== void 0 ? _dataSource$reduce : 0 : 0;
|
|
125
127
|
item.width = Math.max(titleWidth, dataIndexWidth) + 32;
|
|
126
128
|
}
|
|
129
|
+
|
|
130
|
+
// measureAlign 列:列宽须容得下最宽行的定宽内容块 + 单元格左右内边距,
|
|
131
|
+
// 否则出现超长值(如 +3357.52%)时内容会被列宽截断;声明的 width 只作下限。
|
|
132
|
+
if (item.measureAlign && typeof item.width === "number") {
|
|
133
|
+
var measured = getMeasureAlignWidth(item, dataSource);
|
|
134
|
+
if (measured > 0) {
|
|
135
|
+
item.width = Math.max(item.width, measured + MEASURE_ALIGN_CELL_PADDING_PX);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
127
138
|
return item;
|
|
128
139
|
})) === null || _cloned$map === void 0 ? void 0 : _cloned$map.map(function (item) {
|
|
129
140
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as echarts from "echarts";
|
|
2
2
|
import { ChartCommonProps, SeriesDataType } from "..";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { ChartScrollConfig } from "../_utils/cartesian";
|
|
4
|
+
import { ChartScrollConfig, DataZoomIndexWindow } from "../_utils/cartesian";
|
|
5
5
|
export interface ChartBarProps extends ChartCommonProps {
|
|
6
6
|
chartTitle?: string;
|
|
7
7
|
xAxisData?: Array<string>;
|
|
@@ -9,6 +9,10 @@ export interface ChartBarProps extends ChartCommonProps {
|
|
|
9
9
|
legendData?: string[];
|
|
10
10
|
scrollConfig?: ChartScrollConfig;
|
|
11
11
|
onClick?: (event: echarts.ECElementEvent) => void;
|
|
12
|
+
/** 图例点选变化回调,参数为当前各系列选中状态(配合 legend.selected 可实现坐标轴重算) */
|
|
13
|
+
onLegendSelectChanged?: (selected: Record<string, boolean>) => void;
|
|
14
|
+
/** dataZoom 可见窗口变化回调(滑块/滚轮/自动滚动/初始同步均触发),参数为当前可见的 x 轴索引区间(配合 useDataZoomWindow 可按展示部分重算坐标轴) */
|
|
15
|
+
onDataZoomWindowChanged?: (window: DataZoomIndexWindow) => void;
|
|
12
16
|
/** 是否启用图例自动滚动,默认 false */
|
|
13
17
|
enableLegendAutoScroll?: boolean;
|
|
14
18
|
/** 图例每页可见数量,默认 8 */
|