@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
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import FormItem from "../FormItem";
|
|
3
|
-
import React, { CSSProperties } from "react";
|
|
4
|
-
import classNames from "classnames";
|
|
5
|
-
import styles from "./index.module.scss";
|
|
6
|
-
import { useSearchCommon } from "./_hooks";
|
|
1
|
+
import React from "react";
|
|
7
2
|
import SearchCard, { SearchCardProps } from "./SearchCard";
|
|
8
3
|
import SearchAdvanced from "./SearchAdvanced";
|
|
9
4
|
import SearchCollapsible from "./SearchCollapsible";
|
|
10
5
|
import SearchWithFilter from "./SearchWithFilter";
|
|
11
6
|
import SearchWithMore from "./SearchWithMore";
|
|
12
|
-
import
|
|
13
|
-
import { SearchButtons } from "./_components/SearchButtons";
|
|
14
|
-
import { ExpandButton } from "./_components/ExpandButton";
|
|
7
|
+
import SearchBase from "./_components/SearchBase";
|
|
15
8
|
import { BaseSearchProps } from "./_types";
|
|
16
9
|
import { ChakraButtonProps } from "../Button";
|
|
17
10
|
|
|
@@ -43,151 +36,12 @@ export type SearchModePropsMap = {
|
|
|
43
36
|
WithMore: React.ComponentProps<SearchFC["WithMore"]>;
|
|
44
37
|
};
|
|
45
38
|
|
|
39
|
+
/**
|
|
40
|
+
* 基础 Search 组件
|
|
41
|
+
* - 标准的搜索表单布局,自适应列数与展开/收起
|
|
42
|
+
*/
|
|
46
43
|
const Search: SearchFC = (props) => {
|
|
47
|
-
|
|
48
|
-
searchItems = [],
|
|
49
|
-
moreSearchItems = [],
|
|
50
|
-
className,
|
|
51
|
-
onSearch,
|
|
52
|
-
onReset,
|
|
53
|
-
externalForm,
|
|
54
|
-
hasPermi,
|
|
55
|
-
columnNum = 4,
|
|
56
|
-
beforeButtonGroup,
|
|
57
|
-
affterButtonGroup,
|
|
58
|
-
searchData,
|
|
59
|
-
minLabelWidth,
|
|
60
|
-
defaultExpanded = false,
|
|
61
|
-
onExpandChange,
|
|
62
|
-
autoAdaptWidth = true,
|
|
63
|
-
baseWidth,
|
|
64
|
-
onValuesChange,
|
|
65
|
-
searchDisabled = false,
|
|
66
|
-
showAllSearchItems = false,
|
|
67
|
-
searchText,
|
|
68
|
-
resetText,
|
|
69
|
-
columnOffsetWidth = 0,
|
|
70
|
-
} = props;
|
|
71
|
-
|
|
72
|
-
const [form] = AntdForm.useForm(externalForm);
|
|
73
|
-
|
|
74
|
-
const {
|
|
75
|
-
containerRef,
|
|
76
|
-
buttonGroupRef,
|
|
77
|
-
cls,
|
|
78
|
-
getLabelWidth,
|
|
79
|
-
currentSearchItems,
|
|
80
|
-
totalColumnNum,
|
|
81
|
-
expand,
|
|
82
|
-
toggleExpand,
|
|
83
|
-
showExpandButton,
|
|
84
|
-
onSearchClick,
|
|
85
|
-
onResetClick,
|
|
86
|
-
shouldRender,
|
|
87
|
-
permitted,
|
|
88
|
-
} = useSearchCommon({
|
|
89
|
-
form,
|
|
90
|
-
searchItems,
|
|
91
|
-
moreSearchItems,
|
|
92
|
-
searchData,
|
|
93
|
-
hasPermi,
|
|
94
|
-
beforeButtonGroup,
|
|
95
|
-
affterButtonGroup,
|
|
96
|
-
columnNum,
|
|
97
|
-
autoAdaptWidth,
|
|
98
|
-
defaultExpanded,
|
|
99
|
-
onExpandChange,
|
|
100
|
-
showAllSearchItems,
|
|
101
|
-
minLabelWidth,
|
|
102
|
-
baseWidth,
|
|
103
|
-
onSearch,
|
|
104
|
-
onReset,
|
|
105
|
-
columnOffsetWidth,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
if (!shouldRender) {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<div
|
|
114
|
-
ref={containerRef}
|
|
115
|
-
className={classNames(styles.Search, className)}
|
|
116
|
-
style={
|
|
117
|
-
{
|
|
118
|
-
"--column-number": totalColumnNum,
|
|
119
|
-
"--column-offset-width": `${columnOffsetWidth}px`,
|
|
120
|
-
} as CSSProperties
|
|
121
|
-
}
|
|
122
|
-
>
|
|
123
|
-
<div
|
|
124
|
-
className={classNames(styles.searchOption, styles[expand.toString()])}
|
|
125
|
-
>
|
|
126
|
-
<AntdForm
|
|
127
|
-
form={form}
|
|
128
|
-
className={classNames(styles.option, cls)}
|
|
129
|
-
onValuesChange={onValuesChange}
|
|
130
|
-
>
|
|
131
|
-
{permitted &&
|
|
132
|
-
currentSearchItems?.map((item, idx) => {
|
|
133
|
-
const visibleCurrentItems = currentSearchItems.filter(
|
|
134
|
-
(i) => i.visible !== false
|
|
135
|
-
);
|
|
136
|
-
const columnIndex = idx % totalColumnNum;
|
|
137
|
-
const sameColumnItems = visibleCurrentItems.filter(
|
|
138
|
-
(_, _idx) => _idx % totalColumnNum === columnIndex
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<FormItem
|
|
143
|
-
{...item}
|
|
144
|
-
key={item.name}
|
|
145
|
-
className={classNames(styles.item, item.className, {
|
|
146
|
-
[styles.unFill]: item.width !== undefined,
|
|
147
|
-
})}
|
|
148
|
-
labelWidth={
|
|
149
|
-
item.width !== undefined
|
|
150
|
-
? undefined
|
|
151
|
-
: getLabelWidth(sameColumnItems, undefined, minLabelWidth)
|
|
152
|
-
}
|
|
153
|
-
/>
|
|
154
|
-
);
|
|
155
|
-
})}
|
|
156
|
-
{(beforeButtonGroup?.length ||
|
|
157
|
-
affterButtonGroup?.length ||
|
|
158
|
-
permitted) && (
|
|
159
|
-
<ButtonGroup
|
|
160
|
-
beforeButtonGroup={beforeButtonGroup}
|
|
161
|
-
affterButtonGroup={affterButtonGroup}
|
|
162
|
-
expandButton={
|
|
163
|
-
<ExpandButton
|
|
164
|
-
expand={expand}
|
|
165
|
-
toggleExpand={toggleExpand}
|
|
166
|
-
advancedFilters={false}
|
|
167
|
-
showExpandButton={showExpandButton}
|
|
168
|
-
showAllSearchItems={
|
|
169
|
-
showAllSearchItems || !!moreSearchItems?.length
|
|
170
|
-
}
|
|
171
|
-
/>
|
|
172
|
-
}
|
|
173
|
-
permitted={permitted}
|
|
174
|
-
ref={buttonGroupRef}
|
|
175
|
-
>
|
|
176
|
-
{currentSearchItems.length > 0 && (
|
|
177
|
-
<SearchButtons
|
|
178
|
-
onSearch={onSearchClick}
|
|
179
|
-
onReset={onResetClick}
|
|
180
|
-
searchDisabled={searchDisabled}
|
|
181
|
-
searchText={searchText}
|
|
182
|
-
resetText={resetText}
|
|
183
|
-
/>
|
|
184
|
-
)}
|
|
185
|
-
</ButtonGroup>
|
|
186
|
-
)}
|
|
187
|
-
</AntdForm>
|
|
188
|
-
</div>
|
|
189
|
-
</div>
|
|
190
|
-
);
|
|
44
|
+
return <SearchBase {...props} />;
|
|
191
45
|
};
|
|
192
46
|
|
|
193
47
|
Search.Card = SearchCard;
|
|
@@ -23,6 +23,8 @@ import { PaginationProps } from "../_components/Pagination";
|
|
|
23
23
|
const MEASURE_ALIGN_FONT_SIZE = 14;
|
|
24
24
|
// Canvas measureText 仅返回 advance width,较 DOM 实际渲染偏窄约 1px,补 2px 缓冲避免最宽行被挤压
|
|
25
25
|
const MEASURE_ALIGN_BUFFER_PX = 2;
|
|
26
|
+
// 单元格左右内边距合计(--td-padding: 4px 8px),用于把列宽抬到能放下定宽内容块
|
|
27
|
+
const MEASURE_ALIGN_CELL_PADDING_PX = 16;
|
|
26
28
|
|
|
27
29
|
// 计算 measureAlign 列的定宽(取本列所有行展示文本的最大像素宽)
|
|
28
30
|
const getMeasureAlignWidth = <T extends AnyObject>(
|
|
@@ -159,6 +161,21 @@ const useTableColumns = <T extends AnyObject>(
|
|
|
159
161
|
item.width = Math.max(titleWidth, dataIndexWidth) + 32;
|
|
160
162
|
}
|
|
161
163
|
|
|
164
|
+
// measureAlign 列:列宽须容得下最宽行的定宽内容块 + 单元格左右内边距,
|
|
165
|
+
// 否则出现超长值(如 +3357.52%)时内容会被列宽截断;声明的 width 只作下限。
|
|
166
|
+
if (item.measureAlign && typeof item.width === "number") {
|
|
167
|
+
const measured = getMeasureAlignWidth(
|
|
168
|
+
item as ColumnType<T>,
|
|
169
|
+
dataSource
|
|
170
|
+
);
|
|
171
|
+
if (measured > 0) {
|
|
172
|
+
item.width = Math.max(
|
|
173
|
+
item.width,
|
|
174
|
+
measured + MEASURE_ALIGN_CELL_PADDING_PX
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
162
179
|
return item;
|
|
163
180
|
})
|
|
164
181
|
?.map((item) => {
|
|
File without changes
|
|
File without changes
|