@oceanbase/design 1.0.0-alpha.15 → 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/CountNumber.js +2 -1
- package/es/filter/components/FilterButton.d.ts +2 -0
- package/es/filter/components/FilterButton.js +6 -3
- package/es/filter/components/FilterCascader/components/CascaderOption/OptionCheckbox.d.ts +20 -0
- package/es/filter/components/FilterCascader/components/CascaderOption/OptionCheckbox.js +101 -0
- package/es/filter/components/FilterCascader/components/CascaderOption/OptionItem.d.ts +13 -0
- package/es/filter/components/FilterCascader/components/CascaderOption/OptionItem.js +44 -0
- package/es/filter/components/FilterCascader/components/FlatCascaderContent/index.d.ts +16 -0
- package/es/filter/components/FilterCascader/components/FlatCascaderContent/index.js +64 -0
- package/es/filter/components/FilterCascader/components/NormalCascaderContent.d.ts +24 -0
- package/es/filter/components/FilterCascader/components/NormalCascaderContent.js +284 -0
- package/es/filter/components/FilterCascader/constants.d.ts +7 -0
- package/es/filter/components/FilterCascader/constants.js +8 -0
- package/es/filter/components/FilterCascader/hooks/useCascaderCallbacks.d.ts +12 -0
- package/es/filter/components/FilterCascader/hooks/useCascaderCallbacks.js +101 -0
- package/es/filter/components/FilterCascader/hooks/useCascaderLabels.d.ts +9 -0
- package/es/filter/components/FilterCascader/hooks/useCascaderLabels.js +50 -0
- package/es/filter/components/FilterCascader/hooks/useNormalizedValue.d.ts +7 -0
- package/es/filter/components/FilterCascader/hooks/useNormalizedValue.js +53 -0
- package/es/filter/components/FilterCascader/index.d.ts +5 -0
- package/es/filter/components/FilterCascader/index.js +317 -0
- package/es/filter/components/FilterCascader/types.d.ts +56 -0
- package/es/filter/components/FilterCascader/types.js +1 -0
- package/es/filter/components/FilterCascader/utils/countUtils.d.ts +13 -0
- package/es/filter/components/FilterCascader/utils/countUtils.js +48 -0
- package/es/filter/components/FilterCascader/utils/pathUtils.d.ts +17 -0
- package/es/filter/components/FilterCascader/utils/pathUtils.js +91 -0
- package/es/filter/components/FilterCheckbox.js +29 -7
- package/es/filter/components/FilterWrap.js +30 -1
- package/es/filter/components/ResponsiveFilterGroup.js +252 -359
- package/es/filter/index.d.ts +1 -1
- package/es/filter/index.js +11 -7
- package/es/filter/style/index.js +9 -2
- package/es/filter/type.d.ts +5 -0
- package/es/table/index.d.ts +2 -2
- package/lib/alert/index.d.ts +1 -1
- package/lib/alert/index.js +3 -1
- package/lib/filter/components/CountNumber.js +2 -1
- package/lib/filter/components/FilterButton.d.ts +2 -0
- package/lib/filter/components/FilterButton.js +4 -2
- package/lib/filter/components/FilterCascader/components/CascaderOption/OptionCheckbox.d.ts +20 -0
- package/lib/filter/components/FilterCascader/components/CascaderOption/OptionCheckbox.js +91 -0
- package/lib/filter/components/FilterCascader/components/CascaderOption/OptionItem.d.ts +13 -0
- package/lib/filter/components/FilterCascader/components/CascaderOption/OptionItem.js +51 -0
- package/lib/filter/components/FilterCascader/components/FlatCascaderContent/index.d.ts +16 -0
- package/lib/filter/components/FilterCascader/components/FlatCascaderContent/index.js +70 -0
- package/lib/filter/components/FilterCascader/components/NormalCascaderContent.d.ts +24 -0
- package/lib/filter/components/FilterCascader/components/NormalCascaderContent.js +263 -0
- package/lib/filter/components/FilterCascader/constants.d.ts +7 -0
- package/lib/filter/components/FilterCascader/constants.js +14 -0
- package/lib/filter/components/FilterCascader/hooks/useCascaderCallbacks.d.ts +12 -0
- package/lib/filter/components/FilterCascader/hooks/useCascaderCallbacks.js +81 -0
- package/lib/filter/components/FilterCascader/hooks/useCascaderLabels.d.ts +9 -0
- package/lib/filter/components/FilterCascader/hooks/useCascaderLabels.js +56 -0
- package/lib/filter/components/FilterCascader/hooks/useNormalizedValue.d.ts +7 -0
- package/lib/filter/components/FilterCascader/hooks/useNormalizedValue.js +48 -0
- package/lib/filter/components/FilterCascader/index.d.ts +5 -0
- package/lib/filter/components/FilterCascader/index.js +298 -0
- package/lib/filter/components/FilterCascader/types.d.ts +56 -0
- package/lib/filter/components/FilterCascader/types.js +5 -0
- package/lib/filter/components/FilterCascader/utils/countUtils.d.ts +13 -0
- package/lib/filter/components/FilterCascader/utils/countUtils.js +49 -0
- package/lib/filter/components/FilterCascader/utils/pathUtils.d.ts +17 -0
- package/lib/filter/components/FilterCascader/utils/pathUtils.js +56 -0
- package/lib/filter/components/FilterCheckbox.js +29 -7
- package/lib/filter/components/FilterWrap.js +28 -1
- package/lib/filter/components/ResponsiveFilterGroup.js +214 -340
- package/lib/filter/index.d.ts +1 -1
- package/lib/filter/index.js +11 -7
- package/lib/filter/style/index.js +10 -1
- package/lib/filter/type.d.ts +5 -0
- package/package.json +3 -3
- package/es/filter/components/FilterCascader.d.ts +0 -31
- package/es/filter/components/FilterCascader.js +0 -529
- package/lib/filter/components/FilterCascader.d.ts +0 -31
- package/lib/filter/components/FilterCascader.js +0 -449
package/es/filter/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare const Filter: {
|
|
|
14
14
|
Checkbox: import("react").NamedExoticComponent<import("./components/FilterCheckbox").FilterCheckboxProps>;
|
|
15
15
|
Range: import("react").FC<import("./components/FilterRange").FilterRangeProps>;
|
|
16
16
|
Wrap: import("react").FC<import("./components/FilterWrap").FilterWrapProps>;
|
|
17
|
-
Cascader: import("react").FC<import("./components/FilterCascader").FilterCascaderProps>;
|
|
17
|
+
Cascader: import("react").FC<import("./components/FilterCascader/types").FilterCascaderProps>;
|
|
18
18
|
Switch: import("react").FC<import("./components/FilterSwitch").FilterSwitchProps>;
|
|
19
19
|
Input: import("react").FC<import("./components/FilterInput").FilterInputProps>;
|
|
20
20
|
ResponsiveGroup: import("react").FC<import("./components/ResponsiveFilterGroup").ResponsiveFilterGroupProps>;
|
package/es/filter/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import Cascader from "./components/FilterCascader";
|
|
2
|
+
import Cascader from "./components/FilterCascader/index";
|
|
3
3
|
import Checkbox from "./components/FilterCheckbox";
|
|
4
4
|
import Range from "./components/FilterRange";
|
|
5
5
|
import Input from "./components/FilterInput";
|
|
@@ -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/es/filter/style/index.js
CHANGED
|
@@ -10,11 +10,12 @@ import themeConfig from "../../theme";
|
|
|
10
10
|
import ConfigProvider from "../../config-provider";
|
|
11
11
|
var genSelectOptionStyle = function genSelectOptionStyle(token) {
|
|
12
12
|
var componentCls = token.componentCls;
|
|
13
|
-
return _defineProperty({}, "".concat(componentCls, "-select-option"), _defineProperty({
|
|
13
|
+
return _defineProperty({}, "".concat(componentCls, "-select-option"), _defineProperty(_defineProperty({
|
|
14
14
|
paddingBlock: token.paddingXXS,
|
|
15
15
|
paddingInline: token.paddingXS,
|
|
16
16
|
cursor: 'pointer',
|
|
17
17
|
borderRadius: token.borderRadius,
|
|
18
|
+
transition: "background-color ".concat(token.motionDurationMid, " ease-in-out"),
|
|
18
19
|
'&:hover': _defineProperty(_defineProperty({
|
|
19
20
|
backgroundColor: token.colorBgTextHover
|
|
20
21
|
}, "".concat(componentCls, "-arrow-icon"), {
|
|
@@ -26,6 +27,11 @@ var genSelectOptionStyle = function genSelectOptionStyle(token) {
|
|
|
26
27
|
})
|
|
27
28
|
}, "&".concat(componentCls, "-has-selected"), {
|
|
28
29
|
backgroundColor: token.colorBgTextHover
|
|
30
|
+
}), "&".concat(componentCls, "-flat-active"), {
|
|
31
|
+
backgroundColor: token.colorBgTextHover,
|
|
32
|
+
'&:hover': {
|
|
33
|
+
backgroundColor: token.colorBgTextHover
|
|
34
|
+
}
|
|
29
35
|
}));
|
|
30
36
|
};
|
|
31
37
|
var genCheckboxOptionStyle = function genCheckboxOptionStyle(token) {
|
|
@@ -96,7 +102,8 @@ var genIconStyle = function genIconStyle(token) {
|
|
|
96
102
|
marginRight: token.paddingXXS,
|
|
97
103
|
color: token.colorIcon
|
|
98
104
|
}), "".concat(componentCls, "-icon-wrapper"), _objectSpread({}, baseIconWrapperStyle)), "".concat(componentCls, "-count"), _objectSpread(_objectSpread({}, baseCountStyle), {}, {
|
|
99
|
-
backgroundColor: 'var(--ob-color-border-container)'
|
|
105
|
+
backgroundColor: 'var(--ob-color-border-container)',
|
|
106
|
+
padding: '0px 2px'
|
|
100
107
|
})), "".concat(componentCls, "-arrow-icon"), {
|
|
101
108
|
opacity: 1,
|
|
102
109
|
fontSize: token.fontSizeSM,
|
package/es/filter/type.d.ts
CHANGED
package/es/table/index.d.ts
CHANGED
|
@@ -38,8 +38,8 @@ declare const _default: (<RecordType extends AnyObject = AnyObject>(props: Table
|
|
|
38
38
|
SELECTION_ALL: "SELECT_ALL";
|
|
39
39
|
SELECTION_INVERT: "SELECT_INVERT";
|
|
40
40
|
SELECTION_NONE: "SELECT_NONE";
|
|
41
|
-
Column: <
|
|
42
|
-
ColumnGroup: <
|
|
41
|
+
Column: <RecordType_1 extends import("antd/es/_util/type").AnyObject>(_: import("antd").TableColumnProps<RecordType_1>) => null;
|
|
42
|
+
ColumnGroup: <RecordType_2 extends import("antd/es/_util/type").AnyObject>(_: import("antd/es/table/ColumnGroup").ColumnGroupProps<RecordType_2>) => null;
|
|
43
43
|
Summary: typeof Summary;
|
|
44
44
|
useStyle: (prefixCls: string, rootCls?: string) => readonly [(node: ReactElement<any, string | React.JSXElementConstructor<any>>) => ReactElement<any, string | React.JSXElementConstructor<any>>, string, string];
|
|
45
45
|
useDefaultPagination: (pagination?: false | import("antd").TablePaginationConfig) => false | import("antd").TablePaginationConfig;
|
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,
|
|
@@ -21,7 +21,8 @@ const CountNumber = ({
|
|
|
21
21
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
22
22
|
className: (0, _classnames.default)(className || (0, _style.getFilterCls)(prefixCls, 'count')),
|
|
23
23
|
style: total ? {
|
|
24
|
-
width: '
|
|
24
|
+
width: 'fit-content',
|
|
25
|
+
padding: '0px 4px'
|
|
25
26
|
} : undefined,
|
|
26
27
|
children: total ? `${count}/${total}` : count
|
|
27
28
|
});
|
|
@@ -26,6 +26,8 @@ interface FilterButtonProps extends BaseFilterProps, InternalFilterProps {
|
|
|
26
26
|
showLabelDivider?: boolean;
|
|
27
27
|
/** 是否显示后缀图标区域(包括下拉箭头和清除图标),默认 true */
|
|
28
28
|
showSuffixIcon?: boolean;
|
|
29
|
+
/** 是否为 flat 模式(内部使用) */
|
|
30
|
+
_isFlat?: boolean;
|
|
29
31
|
style?: React.CSSProperties;
|
|
30
32
|
}
|
|
31
33
|
declare const FilterButton: React.ForwardRefExoticComponent<FilterButtonProps & React.RefAttributes<FilterButtonRef>>;
|
|
@@ -35,6 +35,7 @@ const FilterButton = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
35
35
|
showLabelDivider = false,
|
|
36
36
|
showSuffixIcon = true,
|
|
37
37
|
_isInWrapComponent = false,
|
|
38
|
+
_isFlat = false,
|
|
38
39
|
style,
|
|
39
40
|
...restProps
|
|
40
41
|
}, ref) => {
|
|
@@ -83,7 +84,7 @@ const FilterButton = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
83
84
|
|
|
84
85
|
// 使用 useMemo 缓存 content,避免每次都重新创建
|
|
85
86
|
const popoverContent = (0, _react.useMemo)(() => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
86
|
-
children: [(!isCollapsed || _isInWrapComponent) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Flex, {
|
|
87
|
+
children: [!_isFlat && (!isCollapsed || _isInWrapComponent) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Flex, {
|
|
87
88
|
justify: "space-between",
|
|
88
89
|
align: "center",
|
|
89
90
|
className: (0, _classnames.default)((0, _style.getFilterCls)(prefixCls, 'button-label-wrapper'), showLabelDivider ? '' : (0, _style.getFilterCls)(prefixCls, 'button-label-wrapper-no-border')),
|
|
@@ -102,7 +103,7 @@ const FilterButton = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
102
103
|
},
|
|
103
104
|
children: footer
|
|
104
105
|
})]
|
|
105
|
-
}), [content, footer, label, extra, isCollapsed, prefixCls, showLabelDivider, token]);
|
|
106
|
+
}), [content, footer, label, extra, isCollapsed, prefixCls, showLabelDivider, token, _isFlat, _isInWrapComponent]);
|
|
106
107
|
return wrapSSR( /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Popover, {
|
|
107
108
|
arrow: false,
|
|
108
109
|
placement: placement,
|
|
@@ -110,6 +111,7 @@ const FilterButton = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
110
111
|
content: popoverContent,
|
|
111
112
|
open: open && !disabled,
|
|
112
113
|
onOpenChange: handleOpenChange,
|
|
114
|
+
forceRender: _isInWrapComponent,
|
|
113
115
|
styles: {
|
|
114
116
|
body: {
|
|
115
117
|
padding: 0,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CascaderOption } from '../../types';
|
|
3
|
+
interface OptionCheckboxProps {
|
|
4
|
+
option: CascaderOption;
|
|
5
|
+
currentPath: string[];
|
|
6
|
+
currentValue: string[][];
|
|
7
|
+
hasChildren: boolean;
|
|
8
|
+
allChildrenCount: number;
|
|
9
|
+
selectedChildrenCount: number;
|
|
10
|
+
allChildrenSelected: boolean;
|
|
11
|
+
prefixCls: string;
|
|
12
|
+
onValueChange: (value: string[][]) => void;
|
|
13
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
14
|
+
onAfterChange?: () => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 级联选择器的复选框选项组件(支持父节点和叶子节点)
|
|
18
|
+
*/
|
|
19
|
+
export declare const OptionCheckbox: React.FC<OptionCheckboxProps>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OptionCheckbox = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _checkbox = _interopRequireDefault(require("../../../../../checkbox"));
|
|
9
|
+
var _countUtils = require("../../utils/countUtils");
|
|
10
|
+
var _style = require("../../../../style");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
/**
|
|
14
|
+
* 级联选择器的复选框选项组件(支持父节点和叶子节点)
|
|
15
|
+
*/
|
|
16
|
+
const OptionCheckbox = ({
|
|
17
|
+
option,
|
|
18
|
+
currentPath,
|
|
19
|
+
currentValue,
|
|
20
|
+
hasChildren,
|
|
21
|
+
allChildrenSelected,
|
|
22
|
+
selectedChildrenCount,
|
|
23
|
+
prefixCls,
|
|
24
|
+
onValueChange,
|
|
25
|
+
onClick,
|
|
26
|
+
onAfterChange
|
|
27
|
+
}) => {
|
|
28
|
+
const isExactMatch = currentValue.some(selectedPath => selectedPath.length === currentPath.length && selectedPath.every((val, idx) => val === currentPath[idx]));
|
|
29
|
+
|
|
30
|
+
// 父节点(有子节点)
|
|
31
|
+
if (hasChildren) {
|
|
32
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_checkbox.default, {
|
|
33
|
+
checked: allChildrenSelected,
|
|
34
|
+
indeterminate: selectedChildrenCount > 0 && !allChildrenSelected,
|
|
35
|
+
disabled: option.disabled,
|
|
36
|
+
onClick: e => {
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
onClick?.(e);
|
|
39
|
+
},
|
|
40
|
+
onChange: () => {
|
|
41
|
+
if (!option.disabled) {
|
|
42
|
+
if (allChildrenSelected) {
|
|
43
|
+
// 取消选中该路径下的所有项
|
|
44
|
+
onValueChange(currentValue.filter(selectedPath => {
|
|
45
|
+
if (selectedPath.length <= currentPath.length) return true;
|
|
46
|
+
return !currentPath.every((val, idx) => selectedPath[idx] === val);
|
|
47
|
+
}));
|
|
48
|
+
} else {
|
|
49
|
+
// 选中该路径下的所有叶子节点
|
|
50
|
+
const leafPaths = (0, _countUtils.collectLeafPaths)(option.children, currentPath);
|
|
51
|
+
const otherValues = currentValue.filter(selectedPath => {
|
|
52
|
+
if (selectedPath.length <= currentPath.length) return true;
|
|
53
|
+
return !currentPath.every((val, idx) => selectedPath[idx] === val);
|
|
54
|
+
});
|
|
55
|
+
onValueChange([...otherValues, ...leafPaths]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
60
|
+
className: (0, _style.getFilterCls)(prefixCls, 'text-ellipsis'),
|
|
61
|
+
children: option.label
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 叶子节点(无子节点)
|
|
67
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_checkbox.default, {
|
|
68
|
+
checked: isExactMatch,
|
|
69
|
+
disabled: option.disabled,
|
|
70
|
+
onClick: e => {
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
onClick?.(e);
|
|
73
|
+
},
|
|
74
|
+
onChange: () => {
|
|
75
|
+
if (!option.disabled) {
|
|
76
|
+
if (isExactMatch) {
|
|
77
|
+
onValueChange(currentValue.filter(item => !(item.length === currentPath.length && item.every((val, idx) => val === currentPath[idx]))));
|
|
78
|
+
} else {
|
|
79
|
+
onValueChange([...currentValue, currentPath]);
|
|
80
|
+
}
|
|
81
|
+
// 叶子节点勾选后,触发回调(用于关闭右侧面板)
|
|
82
|
+
onAfterChange?.();
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
86
|
+
className: (0, _style.getFilterCls)(prefixCls, 'text-ellipsis'),
|
|
87
|
+
children: option.label
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
exports.OptionCheckbox = OptionCheckbox;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface OptionItemProps {
|
|
3
|
+
label: React.ReactNode;
|
|
4
|
+
hasChildren: boolean;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
isMultiple: boolean;
|
|
7
|
+
prefixCls: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 级联选择器的选项文本显示组件(单选模式)
|
|
11
|
+
*/
|
|
12
|
+
export declare const OptionItem: React.FC<OptionItemProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OptionItem = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _antd = require("antd");
|
|
9
|
+
var _theme = _interopRequireDefault(require("../../../../../theme"));
|
|
10
|
+
var _icons = require("@oceanbase/icons");
|
|
11
|
+
var _style = require("../../../../style");
|
|
12
|
+
var _constants = require("../../constants");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
/**
|
|
16
|
+
* 级联选择器的选项文本显示组件(单选模式)
|
|
17
|
+
*/
|
|
18
|
+
const OptionItem = ({
|
|
19
|
+
label,
|
|
20
|
+
hasChildren,
|
|
21
|
+
isSelected,
|
|
22
|
+
isMultiple,
|
|
23
|
+
prefixCls
|
|
24
|
+
}) => {
|
|
25
|
+
const {
|
|
26
|
+
token
|
|
27
|
+
} = _theme.default.useToken();
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
29
|
+
children: [label && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
30
|
+
className: (0, _style.getFilterCls)(prefixCls, 'text-ellipsis'),
|
|
31
|
+
style: {
|
|
32
|
+
flex: 1
|
|
33
|
+
},
|
|
34
|
+
children: label
|
|
35
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Flex, {
|
|
36
|
+
align: "center",
|
|
37
|
+
gap: _constants.GAP_SIZE_SMALL,
|
|
38
|
+
children: [!isMultiple && !hasChildren && isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CheckOutlined, {
|
|
39
|
+
style: {
|
|
40
|
+
color: token.colorPrimary
|
|
41
|
+
}
|
|
42
|
+
}), hasChildren && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.RightOutlined, {
|
|
43
|
+
style: {
|
|
44
|
+
fontSize: _constants.ICON_SIZE,
|
|
45
|
+
color: token.colorTextSecondary
|
|
46
|
+
}
|
|
47
|
+
})]
|
|
48
|
+
})]
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
exports.OptionItem = OptionItem;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CascaderOption } from '../../types';
|
|
3
|
+
import type { FilterButtonRef } from '../../../FilterButton';
|
|
4
|
+
interface FlatCascaderContentProps {
|
|
5
|
+
options: CascaderOption[];
|
|
6
|
+
currentValue: string[][];
|
|
7
|
+
multiple: boolean;
|
|
8
|
+
filterButtonRef: React.RefObject<FilterButtonRef>;
|
|
9
|
+
onValueChange: (value: string[][]) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Flat 模式的级联内容容器组件
|
|
13
|
+
* 使用 antd 的 Cascader.Panel 实现多列展示
|
|
14
|
+
*/
|
|
15
|
+
export declare const FlatCascaderContent: React.FC<FlatCascaderContentProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FlatCascaderContent = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _antd = require("antd");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
/**
|
|
13
|
+
* 类型工具:根据 multiple 属性推断 Cascader.Panel 的 value 类型
|
|
14
|
+
* - 单选 (multiple=false): string[]
|
|
15
|
+
* - 多选 (multiple=true): string[][]
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Flat 模式的级联内容容器组件
|
|
19
|
+
* 使用 antd 的 Cascader.Panel 实现多列展示
|
|
20
|
+
*/
|
|
21
|
+
const FlatCascaderContent = ({
|
|
22
|
+
options,
|
|
23
|
+
currentValue,
|
|
24
|
+
filterButtonRef,
|
|
25
|
+
multiple = false,
|
|
26
|
+
onValueChange
|
|
27
|
+
}) => {
|
|
28
|
+
// 将组件内部的值格式转换为 Cascader.Panel 需要的格式
|
|
29
|
+
// 组件内部:[[parent, child], ...] 或 [[parent, child]]
|
|
30
|
+
// Cascader.Panel:
|
|
31
|
+
// - 单选 (multiple=false): string[]
|
|
32
|
+
// - 多选 (multiple=true): string[][]
|
|
33
|
+
|
|
34
|
+
const cascaderValue = (0, _react.useMemo)(() => {
|
|
35
|
+
if (currentValue.length === 0) return undefined;
|
|
36
|
+
if (!multiple) {
|
|
37
|
+
// 单选:currentValue 是 [[parent, child]],返回 [parent, child]
|
|
38
|
+
return currentValue[0];
|
|
39
|
+
} else {
|
|
40
|
+
// 多选:currentValue 是 [[parent, child], ...]
|
|
41
|
+
return currentValue;
|
|
42
|
+
}
|
|
43
|
+
}, [currentValue, multiple]);
|
|
44
|
+
|
|
45
|
+
// 处理 Cascader.Panel 的值变化
|
|
46
|
+
const handleCascaderChange = (value, _selectedOptions) => {
|
|
47
|
+
if (multiple) {
|
|
48
|
+
// 多选:value 是 string[][],如 [['frontend', 'react'], ['backend', 'java']]
|
|
49
|
+
onValueChange(value);
|
|
50
|
+
} else {
|
|
51
|
+
// 单选:value 是 string[],如 ['frontend', 'react']
|
|
52
|
+
onValueChange([value]);
|
|
53
|
+
filterButtonRef.current?.closePopover();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// 使用条件渲染来处理 multiple 属性的类型问题
|
|
58
|
+
return multiple ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Cascader.Panel, {
|
|
59
|
+
options: options,
|
|
60
|
+
value: cascaderValue,
|
|
61
|
+
onChange: handleCascaderChange,
|
|
62
|
+
multiple: multiple
|
|
63
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Cascader.Panel, {
|
|
64
|
+
options: options,
|
|
65
|
+
value: cascaderValue,
|
|
66
|
+
onChange: handleCascaderChange,
|
|
67
|
+
multiple: false
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
exports.FlatCascaderContent = FlatCascaderContent;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CascaderOption } from '../types';
|
|
3
|
+
import type { FilterButtonRef } from '../../FilterButton';
|
|
4
|
+
interface NormalCascaderContentProps {
|
|
5
|
+
options: CascaderOption[];
|
|
6
|
+
currentValue: string[][];
|
|
7
|
+
multiple: boolean;
|
|
8
|
+
prefixCls: string;
|
|
9
|
+
openPopoverKey: string | null;
|
|
10
|
+
filterButtonRef: React.RefObject<FilterButtonRef>;
|
|
11
|
+
onOpenPopoverKeyChange: (key: string | null) => void;
|
|
12
|
+
onValueChange: (value: string[][]) => void;
|
|
13
|
+
onHandleChange: (parentValue: string, childValue: string) => void;
|
|
14
|
+
onClearByParent: (parentValue: string) => void;
|
|
15
|
+
onSelectAllChildren: (option: CascaderOption) => void;
|
|
16
|
+
showSearch?: boolean;
|
|
17
|
+
searchKeyword?: string;
|
|
18
|
+
onSearchChange?: (value: string) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 非 Flat 模式的级联内容组件
|
|
22
|
+
*/
|
|
23
|
+
export declare const NormalCascaderContent: React.FC<NormalCascaderContentProps>;
|
|
24
|
+
export {};
|