@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/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/es/alert/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
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); }
|
|
3
|
-
var _excluded = ["type", "showIcon", "closable", "ghost", "mini", "banner", "action", "prefixCls", "className"];
|
|
3
|
+
var _excluded = ["type", "showIcon", "closable", "closeIcon", "ghost", "mini", "banner", "action", "prefixCls", "className"];
|
|
4
4
|
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; }
|
|
5
5
|
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; }
|
|
6
6
|
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; }
|
|
@@ -33,6 +33,7 @@ var Alert = function Alert(_ref) {
|
|
|
33
33
|
_ref$showIcon = _ref.showIcon,
|
|
34
34
|
showIcon = _ref$showIcon === void 0 ? true : _ref$showIcon,
|
|
35
35
|
closable = _ref.closable,
|
|
36
|
+
closeIcon = _ref.closeIcon,
|
|
36
37
|
ghost = _ref.ghost,
|
|
37
38
|
mini = _ref.mini,
|
|
38
39
|
banner = _ref.banner,
|
|
@@ -48,11 +49,12 @@ var Alert = function Alert(_ref) {
|
|
|
48
49
|
var _useStyle = useStyle(prefixCls),
|
|
49
50
|
_useStyle2 = _slicedToArray(_useStyle, 1),
|
|
50
51
|
wrapCSSVar = _useStyle2[0];
|
|
51
|
-
var alertCls = classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-closable"), closable), "".concat(prefixCls, "-ghost"), ghost), "".concat(prefixCls, "-mini"), mini), "".concat(prefixCls, "-with-action"), !!action), className);
|
|
52
|
+
var alertCls = classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-closable"), closable || closeIcon), "".concat(prefixCls, "-ghost"), ghost), "".concat(prefixCls, "-mini"), mini), "".concat(prefixCls, "-with-action"), !!action), className);
|
|
52
53
|
return wrapCSSVar( /*#__PURE__*/_jsx(AntAlert, _objectSpread({
|
|
53
54
|
type: type,
|
|
54
55
|
showIcon: showIcon,
|
|
55
56
|
closable: closable,
|
|
57
|
+
closeIcon: closeIcon,
|
|
56
58
|
banner: banner,
|
|
57
59
|
icon: iconMapOutlined[type],
|
|
58
60
|
action: action,
|
|
@@ -11,7 +11,8 @@ var CountNumber = function CountNumber(_ref) {
|
|
|
11
11
|
return /*#__PURE__*/_jsx("div", {
|
|
12
12
|
className: classNames(className || getFilterCls(prefixCls, 'count')),
|
|
13
13
|
style: total ? {
|
|
14
|
-
width: '
|
|
14
|
+
width: 'fit-content',
|
|
15
|
+
padding: '0px 4px'
|
|
15
16
|
} : undefined,
|
|
16
17
|
children: total ? "".concat(count, "/").concat(total) : count
|
|
17
18
|
});
|
|
@@ -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>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
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); }
|
|
3
|
-
var _excluded = ["children", "icon", "label", "bordered", "onClear", "content", "footer", "trigger", "placement", "disabled", "loading", "selected", "extra", "autoCloseOnSelect", "onSelect", "showLabelDivider", "showSuffixIcon", "_isInWrapComponent", "style"],
|
|
3
|
+
var _excluded = ["children", "icon", "label", "bordered", "onClear", "content", "footer", "trigger", "placement", "disabled", "loading", "selected", "extra", "autoCloseOnSelect", "onSelect", "showLabelDivider", "showSuffixIcon", "_isInWrapComponent", "_isFlat", "style"],
|
|
4
4
|
_excluded2 = ["onOpenChange"];
|
|
5
5
|
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; }
|
|
6
6
|
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; }
|
|
@@ -55,6 +55,8 @@ var FilterButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
55
55
|
showSuffixIcon = _ref$showSuffixIcon === void 0 ? true : _ref$showSuffixIcon,
|
|
56
56
|
_ref$_isInWrapCompone = _ref._isInWrapComponent,
|
|
57
57
|
_isInWrapComponent = _ref$_isInWrapCompone === void 0 ? false : _ref$_isInWrapCompone,
|
|
58
|
+
_ref$_isFlat = _ref._isFlat,
|
|
59
|
+
_isFlat = _ref$_isFlat === void 0 ? false : _ref$_isFlat,
|
|
58
60
|
style = _ref.style,
|
|
59
61
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
60
62
|
var _theme$useToken = theme.useToken(),
|
|
@@ -103,7 +105,7 @@ var FilterButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
103
105
|
// 使用 useMemo 缓存 content,避免每次都重新创建
|
|
104
106
|
var popoverContent = useMemo(function () {
|
|
105
107
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
106
|
-
children: [(!isCollapsed || _isInWrapComponent) && /*#__PURE__*/_jsxs(Flex, {
|
|
108
|
+
children: [!_isFlat && (!isCollapsed || _isInWrapComponent) && /*#__PURE__*/_jsxs(Flex, {
|
|
107
109
|
justify: "space-between",
|
|
108
110
|
align: "center",
|
|
109
111
|
className: classNames(getFilterCls(prefixCls, 'button-label-wrapper'), showLabelDivider ? '' : getFilterCls(prefixCls, 'button-label-wrapper-no-border')),
|
|
@@ -123,7 +125,7 @@ var FilterButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
123
125
|
children: footer
|
|
124
126
|
})]
|
|
125
127
|
});
|
|
126
|
-
}, [content, footer, label, extra, isCollapsed, prefixCls, showLabelDivider, token]);
|
|
128
|
+
}, [content, footer, label, extra, isCollapsed, prefixCls, showLabelDivider, token, _isFlat, _isInWrapComponent]);
|
|
127
129
|
return wrapSSR( /*#__PURE__*/_jsx(Popover, _objectSpread(_objectSpread({
|
|
128
130
|
arrow: false,
|
|
129
131
|
placement: placement,
|
|
@@ -131,6 +133,7 @@ var FilterButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
131
133
|
content: popoverContent,
|
|
132
134
|
open: open && !disabled,
|
|
133
135
|
onOpenChange: handleOpenChange,
|
|
136
|
+
forceRender: _isInWrapComponent,
|
|
134
137
|
styles: {
|
|
135
138
|
body: {
|
|
136
139
|
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,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
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); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
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; }
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import Checkbox from "../../../../../checkbox";
|
|
10
|
+
import { collectLeafPaths } from "../../utils/countUtils";
|
|
11
|
+
import { getFilterCls } from "../../../../style";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
* 级联选择器的复选框选项组件(支持父节点和叶子节点)
|
|
15
|
+
*/
|
|
16
|
+
export var OptionCheckbox = function OptionCheckbox(_ref) {
|
|
17
|
+
var option = _ref.option,
|
|
18
|
+
currentPath = _ref.currentPath,
|
|
19
|
+
currentValue = _ref.currentValue,
|
|
20
|
+
hasChildren = _ref.hasChildren,
|
|
21
|
+
allChildrenSelected = _ref.allChildrenSelected,
|
|
22
|
+
selectedChildrenCount = _ref.selectedChildrenCount,
|
|
23
|
+
prefixCls = _ref.prefixCls,
|
|
24
|
+
onValueChange = _ref.onValueChange,
|
|
25
|
+
_onClick = _ref.onClick,
|
|
26
|
+
onAfterChange = _ref.onAfterChange;
|
|
27
|
+
var isExactMatch = currentValue.some(function (selectedPath) {
|
|
28
|
+
return selectedPath.length === currentPath.length && selectedPath.every(function (val, idx) {
|
|
29
|
+
return val === currentPath[idx];
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// 父节点(有子节点)
|
|
34
|
+
if (hasChildren) {
|
|
35
|
+
return /*#__PURE__*/_jsx(Checkbox, {
|
|
36
|
+
checked: allChildrenSelected,
|
|
37
|
+
indeterminate: selectedChildrenCount > 0 && !allChildrenSelected,
|
|
38
|
+
disabled: option.disabled,
|
|
39
|
+
onClick: function onClick(e) {
|
|
40
|
+
e.stopPropagation();
|
|
41
|
+
_onClick === null || _onClick === void 0 || _onClick(e);
|
|
42
|
+
},
|
|
43
|
+
onChange: function onChange() {
|
|
44
|
+
if (!option.disabled) {
|
|
45
|
+
if (allChildrenSelected) {
|
|
46
|
+
// 取消选中该路径下的所有项
|
|
47
|
+
onValueChange(currentValue.filter(function (selectedPath) {
|
|
48
|
+
if (selectedPath.length <= currentPath.length) return true;
|
|
49
|
+
return !currentPath.every(function (val, idx) {
|
|
50
|
+
return selectedPath[idx] === val;
|
|
51
|
+
});
|
|
52
|
+
}));
|
|
53
|
+
} else {
|
|
54
|
+
// 选中该路径下的所有叶子节点
|
|
55
|
+
var leafPaths = collectLeafPaths(option.children, currentPath);
|
|
56
|
+
var otherValues = currentValue.filter(function (selectedPath) {
|
|
57
|
+
if (selectedPath.length <= currentPath.length) return true;
|
|
58
|
+
return !currentPath.every(function (val, idx) {
|
|
59
|
+
return selectedPath[idx] === val;
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
onValueChange([].concat(_toConsumableArray(otherValues), _toConsumableArray(leafPaths)));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
67
|
+
className: getFilterCls(prefixCls, 'text-ellipsis'),
|
|
68
|
+
children: option.label
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 叶子节点(无子节点)
|
|
74
|
+
return /*#__PURE__*/_jsx(Checkbox, {
|
|
75
|
+
checked: isExactMatch,
|
|
76
|
+
disabled: option.disabled,
|
|
77
|
+
onClick: function onClick(e) {
|
|
78
|
+
e.stopPropagation();
|
|
79
|
+
_onClick === null || _onClick === void 0 || _onClick(e);
|
|
80
|
+
},
|
|
81
|
+
onChange: function onChange() {
|
|
82
|
+
if (!option.disabled) {
|
|
83
|
+
if (isExactMatch) {
|
|
84
|
+
onValueChange(currentValue.filter(function (item) {
|
|
85
|
+
return !(item.length === currentPath.length && item.every(function (val, idx) {
|
|
86
|
+
return val === currentPath[idx];
|
|
87
|
+
}));
|
|
88
|
+
}));
|
|
89
|
+
} else {
|
|
90
|
+
onValueChange([].concat(_toConsumableArray(currentValue), [currentPath]));
|
|
91
|
+
}
|
|
92
|
+
// 叶子节点勾选后,触发回调(用于关闭右侧面板)
|
|
93
|
+
onAfterChange === null || onAfterChange === void 0 || onAfterChange();
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
97
|
+
className: getFilterCls(prefixCls, 'text-ellipsis'),
|
|
98
|
+
children: option.label
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
};
|
|
@@ -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,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Flex } from 'antd';
|
|
4
|
+
import theme from "../../../../../theme";
|
|
5
|
+
import { CheckOutlined, RightOutlined } from '@oceanbase/icons';
|
|
6
|
+
import { getFilterCls } from "../../../../style";
|
|
7
|
+
import { GAP_SIZE_SMALL, ICON_SIZE } from "../../constants";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* 级联选择器的选项文本显示组件(单选模式)
|
|
13
|
+
*/
|
|
14
|
+
export var OptionItem = function OptionItem(_ref) {
|
|
15
|
+
var label = _ref.label,
|
|
16
|
+
hasChildren = _ref.hasChildren,
|
|
17
|
+
isSelected = _ref.isSelected,
|
|
18
|
+
isMultiple = _ref.isMultiple,
|
|
19
|
+
prefixCls = _ref.prefixCls;
|
|
20
|
+
var _theme$useToken = theme.useToken(),
|
|
21
|
+
token = _theme$useToken.token;
|
|
22
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
23
|
+
children: [label && /*#__PURE__*/_jsx("div", {
|
|
24
|
+
className: getFilterCls(prefixCls, 'text-ellipsis'),
|
|
25
|
+
style: {
|
|
26
|
+
flex: 1
|
|
27
|
+
},
|
|
28
|
+
children: label
|
|
29
|
+
}), /*#__PURE__*/_jsxs(Flex, {
|
|
30
|
+
align: "center",
|
|
31
|
+
gap: GAP_SIZE_SMALL,
|
|
32
|
+
children: [!isMultiple && !hasChildren && isSelected && /*#__PURE__*/_jsx(CheckOutlined, {
|
|
33
|
+
style: {
|
|
34
|
+
color: token.colorPrimary
|
|
35
|
+
}
|
|
36
|
+
}), hasChildren && /*#__PURE__*/_jsx(RightOutlined, {
|
|
37
|
+
style: {
|
|
38
|
+
fontSize: ICON_SIZE,
|
|
39
|
+
color: token.colorTextSecondary
|
|
40
|
+
}
|
|
41
|
+
})]
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -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,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { Cascader } from 'antd';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 类型工具:根据 multiple 属性推断 Cascader.Panel 的 value 类型
|
|
7
|
+
* - 单选 (multiple=false): string[]
|
|
8
|
+
* - 多选 (multiple=true): string[][]
|
|
9
|
+
*/
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* Flat 模式的级联内容容器组件
|
|
13
|
+
* 使用 antd 的 Cascader.Panel 实现多列展示
|
|
14
|
+
*/
|
|
15
|
+
export var FlatCascaderContent = function FlatCascaderContent(_ref) {
|
|
16
|
+
var options = _ref.options,
|
|
17
|
+
currentValue = _ref.currentValue,
|
|
18
|
+
filterButtonRef = _ref.filterButtonRef,
|
|
19
|
+
_ref$multiple = _ref.multiple,
|
|
20
|
+
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
21
|
+
onValueChange = _ref.onValueChange;
|
|
22
|
+
// 将组件内部的值格式转换为 Cascader.Panel 需要的格式
|
|
23
|
+
// 组件内部:[[parent, child], ...] 或 [[parent, child]]
|
|
24
|
+
// Cascader.Panel:
|
|
25
|
+
// - 单选 (multiple=false): string[]
|
|
26
|
+
// - 多选 (multiple=true): string[][]
|
|
27
|
+
|
|
28
|
+
var cascaderValue = useMemo(function () {
|
|
29
|
+
if (currentValue.length === 0) return undefined;
|
|
30
|
+
if (!multiple) {
|
|
31
|
+
// 单选:currentValue 是 [[parent, child]],返回 [parent, child]
|
|
32
|
+
return currentValue[0];
|
|
33
|
+
} else {
|
|
34
|
+
// 多选:currentValue 是 [[parent, child], ...]
|
|
35
|
+
return currentValue;
|
|
36
|
+
}
|
|
37
|
+
}, [currentValue, multiple]);
|
|
38
|
+
|
|
39
|
+
// 处理 Cascader.Panel 的值变化
|
|
40
|
+
var handleCascaderChange = function handleCascaderChange(value, _selectedOptions) {
|
|
41
|
+
if (multiple) {
|
|
42
|
+
// 多选:value 是 string[][],如 [['frontend', 'react'], ['backend', 'java']]
|
|
43
|
+
onValueChange(value);
|
|
44
|
+
} else {
|
|
45
|
+
var _filterButtonRef$curr;
|
|
46
|
+
// 单选:value 是 string[],如 ['frontend', 'react']
|
|
47
|
+
onValueChange([value]);
|
|
48
|
+
(_filterButtonRef$curr = filterButtonRef.current) === null || _filterButtonRef$curr === void 0 || _filterButtonRef$curr.closePopover();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// 使用条件渲染来处理 multiple 属性的类型问题
|
|
53
|
+
return multiple ? /*#__PURE__*/_jsx(Cascader.Panel, {
|
|
54
|
+
options: options,
|
|
55
|
+
value: cascaderValue,
|
|
56
|
+
onChange: handleCascaderChange,
|
|
57
|
+
multiple: multiple
|
|
58
|
+
}) : /*#__PURE__*/_jsx(Cascader.Panel, {
|
|
59
|
+
options: options,
|
|
60
|
+
value: cascaderValue,
|
|
61
|
+
onChange: handleCascaderChange,
|
|
62
|
+
multiple: false
|
|
63
|
+
});
|
|
64
|
+
};
|
|
@@ -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 {};
|