@oceanbase/design 1.0.0-alpha.16 → 1.0.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/design.min.js +1 -1
- package/es/alert/index.d.ts +1 -1
- package/es/alert/index.js +4 -2
- package/es/filter/components/FilterButton.js +1 -0
- package/es/filter/components/FilterCheckbox.js +29 -7
- package/es/filter/components/FilterWrap.js +30 -1
- package/es/filter/components/ResponsiveFilterGroup.js +251 -359
- package/es/filter/index.js +10 -6
- package/lib/alert/index.d.ts +1 -1
- package/lib/alert/index.js +3 -1
- package/lib/filter/components/FilterButton.js +1 -0
- package/lib/filter/components/FilterCheckbox.js +29 -7
- package/lib/filter/components/FilterWrap.js +28 -1
- package/lib/filter/components/ResponsiveFilterGroup.js +213 -340
- package/lib/filter/index.js +10 -6
- package/package.json +2 -2
package/es/filter/index.js
CHANGED
|
@@ -8,14 +8,18 @@ import Switch from "./components/FilterSwitch";
|
|
|
8
8
|
import Wrap from "./components/FilterWrap";
|
|
9
9
|
import ResponsiveGroup from "./components/ResponsiveFilterGroup";
|
|
10
10
|
export { FilterProvider, useFilterContext } from "./FilterContext";
|
|
11
|
+
function markAsFilterComponent(component) {
|
|
12
|
+
component.__isFilterComponent = true;
|
|
13
|
+
return component;
|
|
14
|
+
}
|
|
11
15
|
var Filter = {
|
|
12
|
-
Select: Select,
|
|
13
|
-
Checkbox: Checkbox,
|
|
14
|
-
Range: Range,
|
|
16
|
+
Select: markAsFilterComponent(Select),
|
|
17
|
+
Checkbox: markAsFilterComponent(Checkbox),
|
|
18
|
+
Range: markAsFilterComponent(Range),
|
|
15
19
|
Wrap: Wrap,
|
|
16
|
-
Cascader: Cascader,
|
|
17
|
-
Switch: Switch,
|
|
18
|
-
Input: Input,
|
|
20
|
+
Cascader: markAsFilterComponent(Cascader),
|
|
21
|
+
Switch: markAsFilterComponent(Switch),
|
|
22
|
+
Input: markAsFilterComponent(Input),
|
|
19
23
|
ResponsiveGroup: ResponsiveGroup
|
|
20
24
|
};
|
|
21
25
|
export default Filter;
|
package/lib/alert/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface AlertProps extends AntAlertProps {
|
|
|
6
6
|
mini?: boolean;
|
|
7
7
|
}
|
|
8
8
|
declare const Alert: {
|
|
9
|
-
({ type: typeProp, showIcon, closable, ghost, mini, banner, action, prefixCls: customizePrefixCls, className, ...restProps }: AlertProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
9
|
+
({ type: typeProp, showIcon, closable, closeIcon, ghost, mini, banner, action, prefixCls: customizePrefixCls, className, ...restProps }: AlertProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
10
10
|
ErrorBoundary: typeof import("antd/es/alert/ErrorBoundary").default;
|
|
11
11
|
displayName: string;
|
|
12
12
|
};
|
package/lib/alert/index.js
CHANGED
|
@@ -37,6 +37,7 @@ const Alert = ({
|
|
|
37
37
|
type: typeProp,
|
|
38
38
|
showIcon = true,
|
|
39
39
|
closable,
|
|
40
|
+
closeIcon,
|
|
40
41
|
ghost,
|
|
41
42
|
mini,
|
|
42
43
|
banner,
|
|
@@ -53,7 +54,7 @@ const Alert = ({
|
|
|
53
54
|
const prefixCls = getPrefixCls('alert', customizePrefixCls);
|
|
54
55
|
const [wrapCSSVar] = (0, _style.default)(prefixCls);
|
|
55
56
|
const alertCls = (0, _classnames.default)({
|
|
56
|
-
[`${prefixCls}-closable`]: closable,
|
|
57
|
+
[`${prefixCls}-closable`]: closable || closeIcon,
|
|
57
58
|
[`${prefixCls}-ghost`]: ghost,
|
|
58
59
|
[`${prefixCls}-mini`]: mini,
|
|
59
60
|
[`${prefixCls}-with-action`]: !!action
|
|
@@ -62,6 +63,7 @@ const Alert = ({
|
|
|
62
63
|
type: type,
|
|
63
64
|
showIcon: showIcon,
|
|
64
65
|
closable: closable,
|
|
66
|
+
closeIcon: closeIcon,
|
|
65
67
|
banner: banner,
|
|
66
68
|
icon: iconMapOutlined[type],
|
|
67
69
|
action: action,
|
|
@@ -143,8 +143,30 @@ const FilterCheckbox = ({
|
|
|
143
143
|
const iconWidth = 10;
|
|
144
144
|
const iconWidthUnselected = 8;
|
|
145
145
|
const overlapDistance = 6;
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
|
|
147
|
+
// 按颜色分组选项,并检查每种颜色是否有选中的选项
|
|
148
|
+
const colorGroups = [];
|
|
149
|
+
const colorMap = new Map();
|
|
150
|
+
options.forEach(option => {
|
|
151
|
+
if (option.color) {
|
|
152
|
+
const isSelected = selectedValues.includes(option.value);
|
|
153
|
+
const existing = colorMap.get(option.color);
|
|
154
|
+
if (existing) {
|
|
155
|
+
// 如果已有该颜色,更新选中状态(只要有一个选中即为选中)
|
|
156
|
+
if (isSelected) {
|
|
157
|
+
existing.hasSelected = true;
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
const group = {
|
|
161
|
+
color: option.color,
|
|
162
|
+
hasSelected: isSelected
|
|
163
|
+
};
|
|
164
|
+
colorMap.set(option.color, group);
|
|
165
|
+
colorGroups.push(group);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const containerWidth = iconWidth + (colorGroups.length - 1) * overlapDistance + 1;
|
|
148
170
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
149
171
|
style: {
|
|
150
172
|
position: 'relative',
|
|
@@ -153,8 +175,8 @@ const FilterCheckbox = ({
|
|
|
153
175
|
display: 'flex',
|
|
154
176
|
alignItems: 'center'
|
|
155
177
|
},
|
|
156
|
-
children:
|
|
157
|
-
const isSelected =
|
|
178
|
+
children: colorGroups.map((group, index) => {
|
|
179
|
+
const isSelected = group.hasSelected;
|
|
158
180
|
const baseSize = isSelected ? iconWidth : iconWidthUnselected;
|
|
159
181
|
return isSelected ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
160
182
|
style: {
|
|
@@ -164,10 +186,10 @@ const FilterCheckbox = ({
|
|
|
164
186
|
height: baseSize,
|
|
165
187
|
borderRadius: '50%',
|
|
166
188
|
zIndex: index,
|
|
167
|
-
backgroundColor:
|
|
189
|
+
backgroundColor: group.color,
|
|
168
190
|
border: `1px solid ${token.white}`
|
|
169
191
|
}
|
|
170
|
-
},
|
|
192
|
+
}, group.color) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
171
193
|
style: {
|
|
172
194
|
position: 'absolute',
|
|
173
195
|
left: index * overlapDistance,
|
|
@@ -184,7 +206,7 @@ const FilterCheckbox = ({
|
|
|
184
206
|
border: `1px solid ${token.colorBorderSecondary}`
|
|
185
207
|
}
|
|
186
208
|
})
|
|
187
|
-
},
|
|
209
|
+
}, group.color);
|
|
188
210
|
})
|
|
189
211
|
});
|
|
190
212
|
}, [isStatusMode, options, selectedValues, token]);
|
|
@@ -56,12 +56,39 @@ const FilterWrap = ({
|
|
|
56
56
|
value: item.value
|
|
57
57
|
})));
|
|
58
58
|
}, [collapsed, contextValue.filterValues]);
|
|
59
|
-
const
|
|
59
|
+
const allFilterValues = (0, _react.useMemo)(() => {
|
|
60
60
|
if (!collapsed) return [];
|
|
61
61
|
return contextValue.filterValues || [];
|
|
62
62
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
63
|
}, [collapsed, stableFilterValuesKey]);
|
|
64
64
|
|
|
65
|
+
// 从 children 中递归提取 label 集合,用于过滤 filterValues 只保留当前折叠项的值
|
|
66
|
+
// children 结构可能是 Fragment → Form.Item → Filter.Select,需要递归查找
|
|
67
|
+
const childLabelSet = (0, _react.useMemo)(() => {
|
|
68
|
+
const labels = new Set();
|
|
69
|
+
const extractLabel = node => {
|
|
70
|
+
if (! /*#__PURE__*/(0, _react.isValidElement)(node)) return;
|
|
71
|
+
const props = node.props;
|
|
72
|
+
if (props.label !== undefined) {
|
|
73
|
+
labels.add(props.label);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (props.children) {
|
|
77
|
+
if ( /*#__PURE__*/(0, _react.isValidElement)(props.children)) {
|
|
78
|
+
extractLabel(props.children);
|
|
79
|
+
} else if (Array.isArray(props.children)) {
|
|
80
|
+
props.children.forEach(extractLabel);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
_react.Children.forEach(children, extractLabel);
|
|
85
|
+
return labels;
|
|
86
|
+
}, [children]);
|
|
87
|
+
const filterValues = (0, _react.useMemo)(() => {
|
|
88
|
+
if (childLabelSet.size === 0) return allFilterValues;
|
|
89
|
+
return allFilterValues.filter(item => childLabelSet.has(item.label));
|
|
90
|
+
}, [allFilterValues, childLabelSet]);
|
|
91
|
+
|
|
65
92
|
// 格式化值用于 Tooltip 显示
|
|
66
93
|
const formatValueForTooltip = (0, _react.useCallback)((value, options, componentName) => {
|
|
67
94
|
if (!value) return '';
|