@rainbow-oh/yee-c 0.4.3 → 0.4.5
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/cjs/Button/button.d.ts +1 -1
- package/dist/cjs/CSV/download.d.ts +1 -1
- package/dist/cjs/Carousel/carousel.d.ts +2 -2
- package/dist/cjs/Carousel/carousel.js +9 -2
- package/dist/cjs/Carousel/interface.d.ts +5 -0
- package/dist/cjs/Cascader/cascader.js +53 -62
- package/dist/cjs/Cascader/interface.d.ts +19 -2
- package/dist/cjs/Cascader/node.js +11 -6
- package/dist/cjs/Cascader/search-list.js +2 -1
- package/dist/cjs/Cascader/utils/index.d.ts +58 -14
- package/dist/cjs/Cascader/utils/index.js +57 -73
- package/dist/cjs/Drawer/style/index.less +4 -0
- package/dist/cjs/FloatButton/float-button.d.ts +1 -1
- package/dist/cjs/Form/demo/basic.js +2 -2
- package/dist/cjs/Form/style/index.less +15 -0
- package/dist/cjs/Input/style/index.less +19 -17
- package/dist/cjs/InputNumber/style/index.less +0 -29
- package/dist/cjs/PickerPanel/interface.d.ts +44 -2
- package/dist/cjs/PickerPanel/panels/DatePanel/DateBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DatePanel/DateHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DatePanel/DateHeader.js +1 -1
- package/dist/cjs/PickerPanel/panels/DatePanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DateTimePanel/index.d.ts +7 -1
- package/dist/cjs/PickerPanel/panels/DateTimePanel/index.js +18 -4
- package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeBody.js +1 -1
- package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeHeader.js +1 -1
- package/dist/cjs/PickerPanel/panels/DecadePanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DecadePanel/index.js +1 -1
- package/dist/cjs/PickerPanel/panels/Header.d.ts +13 -1
- package/dist/cjs/PickerPanel/panels/MonthPanel/MonthBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/MonthPanel/MonthHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/MonthPanel/MonthHeader.js +1 -1
- package/dist/cjs/PickerPanel/panels/MonthPanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/MonthPanel/index.js +1 -1
- package/dist/cjs/PickerPanel/panels/PanelBody.d.ts +21 -1
- package/dist/cjs/PickerPanel/panels/PanelBody.js +3 -3
- package/dist/cjs/PickerPanel/panels/QuarterPanel/QuarterBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/QuarterPanel/QuarterHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/QuarterPanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/RangePanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/RangePanel/index.js +2 -2
- package/dist/cjs/PickerPanel/panels/RangePanel/interface.d.ts +5 -5
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeBody.d.ts +17 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeCell.d.ts +7 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeCell.js +1 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeColumn.d.ts +14 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeColumn.js +1 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeHeader.d.ts +4 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/index.d.ts +9 -1
- package/dist/cjs/PickerPanel/panels/WeekPanel/WeekBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/WeekPanel/WeekHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/WeekPanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/YearPanel/YearBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/YearPanel/YearBody.js +2 -2
- package/dist/cjs/PickerPanel/panels/YearPanel/YearHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/YearPanel/YearHeader.js +7 -1
- package/dist/cjs/PickerPanel/panels/YearPanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/YearPanel/index.js +1 -1
- package/dist/cjs/PickerPanel/utils/pickerUtils.d.ts +7 -7
- package/dist/cjs/PickerPanel/utils/pickerUtils.js +2 -2
- package/dist/cjs/Popover/style/index.less +1 -0
- package/dist/cjs/Select/interface.d.ts +77 -0
- package/dist/cjs/Select/option.d.ts +2 -1
- package/dist/cjs/Select/option.js +6 -3
- package/dist/cjs/Select/options.d.ts +3 -2
- package/dist/cjs/Select/options.js +53 -47
- package/dist/cjs/Select/select.js +1 -1
- package/dist/cjs/Select/style/index.less +8 -13
- package/dist/cjs/Selector/interface.d.ts +4 -0
- package/dist/cjs/Selector/selector.js +3 -0
- package/dist/cjs/Selector/style/index.less +21 -137
- package/dist/cjs/Table/hooks/useFilter.js +1 -1
- package/dist/cjs/Table/interface.d.ts +4 -0
- package/dist/cjs/Table/style/index.less +2 -0
- package/dist/cjs/Table/theader/filter.js +2 -1
- package/dist/cjs/Tabs/demo/basic.js +8 -1
- package/dist/cjs/Tabs/tabs.js +3 -1
- package/dist/cjs/Tag/demo/checkable.js +1 -0
- package/dist/cjs/Tag/tag.js +1 -1
- package/dist/cjs/TextArea/style/index.less +0 -17
- package/dist/cjs/Trigger/trigger.js +1 -1
- package/dist/cjs/hooks/useEvent.js +4 -1
- package/dist/cjs/style/color.css +1 -1
- package/dist/cjs/style/size.css +11 -2
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +13 -4
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Button/button.d.ts +1 -1
- package/dist/esm/CSV/download.d.ts +1 -1
- package/dist/esm/Carousel/carousel.d.ts +2 -2
- package/dist/esm/Carousel/carousel.js +5 -1
- package/dist/esm/Carousel/interface.d.ts +5 -0
- package/dist/esm/Cascader/cascader.js +49 -56
- package/dist/esm/Cascader/interface.d.ts +19 -2
- package/dist/esm/Cascader/node.js +8 -11
- package/dist/esm/Cascader/search-list.js +2 -1
- package/dist/esm/Cascader/utils/index.d.ts +58 -14
- package/dist/esm/Cascader/utils/index.js +124 -75
- package/dist/esm/Drawer/style/index.less +4 -0
- package/dist/esm/FloatButton/float-button.d.ts +1 -1
- package/dist/esm/Form/demo/basic.js +4 -2
- package/dist/esm/Form/style/index.less +15 -0
- package/dist/esm/Input/style/index.less +19 -17
- package/dist/esm/InputNumber/style/index.less +0 -29
- package/dist/esm/PickerPanel/interface.d.ts +44 -2
- package/dist/esm/PickerPanel/panels/DatePanel/DateBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DatePanel/DateHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DatePanel/DateHeader.js +1 -1
- package/dist/esm/PickerPanel/panels/DatePanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DateTimePanel/index.d.ts +7 -1
- package/dist/esm/PickerPanel/panels/DateTimePanel/index.js +11 -7
- package/dist/esm/PickerPanel/panels/DecadePanel/DecadeBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DecadePanel/DecadeBody.js +2 -1
- package/dist/esm/PickerPanel/panels/DecadePanel/DecadeHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DecadePanel/DecadeHeader.js +2 -1
- package/dist/esm/PickerPanel/panels/DecadePanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DecadePanel/index.js +1 -1
- package/dist/esm/PickerPanel/panels/Header.d.ts +13 -1
- package/dist/esm/PickerPanel/panels/MonthPanel/MonthBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/MonthPanel/MonthHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/MonthPanel/MonthHeader.js +2 -1
- package/dist/esm/PickerPanel/panels/MonthPanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/MonthPanel/index.js +1 -1
- package/dist/esm/PickerPanel/panels/PanelBody.d.ts +21 -1
- package/dist/esm/PickerPanel/panels/PanelBody.js +2 -4
- package/dist/esm/PickerPanel/panels/QuarterPanel/QuarterBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/QuarterPanel/QuarterHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/QuarterPanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/RangePanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/RangePanel/index.js +2 -2
- package/dist/esm/PickerPanel/panels/RangePanel/interface.d.ts +5 -5
- package/dist/esm/PickerPanel/panels/TimePanel/TimeBody.d.ts +17 -1
- package/dist/esm/PickerPanel/panels/TimePanel/TimeCell.d.ts +7 -1
- package/dist/esm/PickerPanel/panels/TimePanel/TimeCell.js +1 -1
- package/dist/esm/PickerPanel/panels/TimePanel/TimeColumn.d.ts +14 -1
- package/dist/esm/PickerPanel/panels/TimePanel/TimeColumn.js +1 -1
- package/dist/esm/PickerPanel/panels/TimePanel/TimeHeader.d.ts +4 -1
- package/dist/esm/PickerPanel/panels/TimePanel/index.d.ts +9 -1
- package/dist/esm/PickerPanel/panels/WeekPanel/WeekBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/WeekPanel/WeekHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/WeekPanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/YearPanel/YearBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/YearPanel/YearBody.js +3 -2
- package/dist/esm/PickerPanel/panels/YearPanel/YearHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/YearPanel/YearHeader.js +2 -1
- package/dist/esm/PickerPanel/panels/YearPanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/YearPanel/index.js +1 -1
- package/dist/esm/PickerPanel/picker-panel.js +3 -0
- package/dist/esm/PickerPanel/utils/pickerUtils.d.ts +7 -7
- package/dist/esm/PickerPanel/utils/pickerUtils.js +4 -10
- package/dist/esm/Popover/style/index.less +1 -0
- package/dist/esm/Select/interface.d.ts +77 -0
- package/dist/esm/Select/option.d.ts +2 -1
- package/dist/esm/Select/option.js +11 -2
- package/dist/esm/Select/options.d.ts +3 -2
- package/dist/esm/Select/options.js +3 -1
- package/dist/esm/Select/select.js +1 -3
- package/dist/esm/Select/style/index.less +8 -13
- package/dist/esm/Selector/interface.d.ts +4 -0
- package/dist/esm/Selector/selector.js +4 -2
- package/dist/esm/Selector/style/index.less +21 -137
- package/dist/esm/Table/hooks/useFilter.js +1 -1
- package/dist/esm/Table/interface.d.ts +4 -0
- package/dist/esm/Table/style/index.less +2 -0
- package/dist/esm/Table/theader/filter.js +3 -4
- package/dist/esm/Tabs/demo/basic.js +4 -1
- package/dist/esm/Tabs/tabs.js +3 -1
- package/dist/esm/Tag/demo/checkable.js +1 -0
- package/dist/esm/Tag/tag.js +1 -1
- package/dist/esm/TextArea/style/index.less +0 -17
- package/dist/esm/Trigger/trigger.js +1 -1
- package/dist/esm/style/color.css +1 -1
- package/dist/esm/style/size.css +11 -2
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +13 -4
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +2 -2
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Carousel/carousel.tsx +14 -3
- package/src/Carousel/interface.ts +6 -0
- package/src/Cascader/cascader.tsx +68 -63
- package/src/Cascader/column.tsx +1 -1
- package/src/Cascader/interface.ts +19 -2
- package/src/Cascader/node.tsx +12 -7
- package/src/Cascader/search-list.tsx +1 -1
- package/src/Cascader/utils/index.ts +130 -68
- package/src/Drawer/style/index.less +4 -0
- package/src/Dropdown/dropdown.tsx +1 -1
- package/src/FloatButton/float-button.tsx +5 -3
- package/src/Form/demo/basic.tsx +2 -2
- package/src/Form/style/index.less +15 -0
- package/src/Input/style/index.less +19 -17
- package/src/InputNumber/style/index.less +0 -29
- package/src/PickerPanel/interface.ts +43 -2
- package/src/PickerPanel/panels/DatePanel/DateBody.tsx +2 -1
- package/src/PickerPanel/panels/DatePanel/DateHeader.tsx +3 -2
- package/src/PickerPanel/panels/DatePanel/index.tsx +2 -1
- package/src/PickerPanel/panels/DateTimePanel/index.tsx +12 -5
- package/src/PickerPanel/panels/DecadePanel/DecadeBody.tsx +3 -2
- package/src/PickerPanel/panels/DecadePanel/DecadeHeader.tsx +3 -2
- package/src/PickerPanel/panels/DecadePanel/index.tsx +3 -2
- package/src/PickerPanel/panels/Header.tsx +14 -1
- package/src/PickerPanel/panels/MonthPanel/MonthBody.tsx +2 -1
- package/src/PickerPanel/panels/MonthPanel/MonthHeader.tsx +3 -2
- package/src/PickerPanel/panels/MonthPanel/index.tsx +3 -2
- package/src/PickerPanel/panels/PanelBody.tsx +27 -5
- package/src/PickerPanel/panels/QuarterPanel/QuarterBody.tsx +2 -1
- package/src/PickerPanel/panels/QuarterPanel/QuarterHeader.tsx +2 -1
- package/src/PickerPanel/panels/QuarterPanel/index.tsx +2 -1
- package/src/PickerPanel/panels/RangePanel/index.tsx +11 -9
- package/src/PickerPanel/panels/RangePanel/interface.ts +5 -5
- package/src/PickerPanel/panels/TimePanel/TimeBody.tsx +21 -5
- package/src/PickerPanel/panels/TimePanel/TimeCell.tsx +9 -2
- package/src/PickerPanel/panels/TimePanel/TimeColumn.tsx +15 -2
- package/src/PickerPanel/panels/TimePanel/TimeHeader.tsx +5 -1
- package/src/PickerPanel/panels/TimePanel/index.tsx +10 -1
- package/src/PickerPanel/panels/WeekPanel/WeekBody.tsx +2 -1
- package/src/PickerPanel/panels/WeekPanel/WeekHeader.tsx +2 -1
- package/src/PickerPanel/panels/WeekPanel/index.tsx +2 -1
- package/src/PickerPanel/panels/YearPanel/YearBody.tsx +4 -3
- package/src/PickerPanel/panels/YearPanel/YearHeader.tsx +9 -3
- package/src/PickerPanel/panels/YearPanel/index.tsx +3 -2
- package/src/PickerPanel/picker-panel.tsx +5 -3
- package/src/PickerPanel/utils/pickerUtils.ts +17 -8
- package/src/Popover/style/index.less +1 -0
- package/src/Select/interface.ts +87 -0
- package/src/Select/option.tsx +13 -4
- package/src/Select/options.tsx +49 -43
- package/src/Select/select.tsx +5 -2
- package/src/Select/style/index.less +8 -13
- package/src/Selector/interface.ts +4 -0
- package/src/Selector/selector.tsx +2 -0
- package/src/Selector/style/index.less +21 -137
- package/src/Splitter/hooks/useMove.ts +2 -2
- package/src/Table/hooks/useFilter.ts +1 -1
- package/src/Table/interface.ts +4 -0
- package/src/Table/style/index.less +2 -0
- package/src/Table/theader/filter.tsx +2 -2
- package/src/Tabs/demo/basic.tsx +7 -1
- package/src/Tabs/tabs.tsx +3 -2
- package/src/Tag/demo/checkable.tsx +1 -0
- package/src/Tag/tag.tsx +1 -1
- package/src/TextArea/style/index.less +0 -17
- package/src/Trigger/trigger.tsx +1 -1
- package/src/hooks/useEvent.ts +7 -4
- package/src/hooks/useMergedState.ts +6 -4
- package/src/style/color.css +1 -1
- package/src/style/size.css +11 -2
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -16,13 +16,21 @@ import { GlobalContext } from '../Config-Provider';
|
|
|
16
16
|
import useElementSize from '../hooks/useElementSize';
|
|
17
17
|
import mergeContextToProps from '../utils/mergeContextToProps';
|
|
18
18
|
import Item from './carousel-item';
|
|
19
|
-
import type {
|
|
19
|
+
import type {
|
|
20
|
+
CarouselContextProps,
|
|
21
|
+
CarouselItemProps,
|
|
22
|
+
CarouselProps,
|
|
23
|
+
} from './interface';
|
|
20
24
|
|
|
21
25
|
import './style/index.less';
|
|
22
26
|
|
|
23
27
|
const DEFAULT_ANIMATION_DURATION = 500;
|
|
24
28
|
|
|
25
|
-
export const CarouselCtx = React.createContext({
|
|
29
|
+
export const CarouselCtx = React.createContext<CarouselContextProps>({
|
|
30
|
+
prefixCls: 'yee-carousel',
|
|
31
|
+
effect: 'scrollx',
|
|
32
|
+
current: 1,
|
|
33
|
+
});
|
|
26
34
|
|
|
27
35
|
const Carousel = React.forwardRef(
|
|
28
36
|
(baseprops: CarouselProps, ref: React.Ref<HTMLDivElement>) => {
|
|
@@ -249,7 +257,10 @@ const Carousel = React.forwardRef(
|
|
|
249
257
|
|
|
250
258
|
const renderFadeChilds = () => {
|
|
251
259
|
return React.Children.map(children, (child, index) => {
|
|
252
|
-
return React.cloneElement(
|
|
260
|
+
return React.cloneElement(
|
|
261
|
+
child as React.ReactElement<CarouselItemProps>,
|
|
262
|
+
{ index },
|
|
263
|
+
);
|
|
253
264
|
});
|
|
254
265
|
};
|
|
255
266
|
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export type SemanticDOM = 'dot' | 'prev' | 'next';
|
|
2
2
|
|
|
3
|
+
export interface CarouselContextProps {
|
|
4
|
+
prefixCls: string;
|
|
5
|
+
effect: 'fade' | 'scrollx';
|
|
6
|
+
current: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
3
9
|
export interface CarouselItemProps {
|
|
4
10
|
index: number;
|
|
5
11
|
style?: React.CSSProperties;
|
|
@@ -17,7 +17,13 @@ import isEqual from '../utils/isEqual';
|
|
|
17
17
|
import mergeContextToProps from '../utils/mergeContextToProps';
|
|
18
18
|
import Column from './column';
|
|
19
19
|
import SearchList from './search-list';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
changeToView,
|
|
22
|
+
flattenOptions,
|
|
23
|
+
getChildren,
|
|
24
|
+
isSamePrefixPath,
|
|
25
|
+
pathToUid,
|
|
26
|
+
} from './utils';
|
|
21
27
|
|
|
22
28
|
import type {
|
|
23
29
|
CascaderContextValue,
|
|
@@ -41,7 +47,7 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
41
47
|
options,
|
|
42
48
|
placement = 'bottomLeft',
|
|
43
49
|
popupClassName,
|
|
44
|
-
searchable,
|
|
50
|
+
searchable = true,
|
|
45
51
|
fieldNames = {
|
|
46
52
|
label: 'label',
|
|
47
53
|
value: 'value',
|
|
@@ -59,7 +65,9 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
59
65
|
|
|
60
66
|
// Status variables for internal use
|
|
61
67
|
const [columns, setColumns] = useState<Array<FlattenOption[]>>([]);
|
|
62
|
-
const [expandedPath, setExpandedPath] = useState<
|
|
68
|
+
const [expandedPath, setExpandedPath] = useState<
|
|
69
|
+
Array<{ key: string; label: string }>
|
|
70
|
+
>([]);
|
|
63
71
|
const [searchValue, setSearchValue] = useState(''); // Input field input
|
|
64
72
|
// NOTE: popupVisible uses ref instead of state to avoid triggering re-renders
|
|
65
73
|
// This is intentional - it's only used for side effects tracking, not for rendering
|
|
@@ -97,11 +105,10 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
97
105
|
currentValue || [],
|
|
98
106
|
flatOptions,
|
|
99
107
|
{
|
|
100
|
-
needNext: true, // Set to true to expand to full path
|
|
101
108
|
multiple,
|
|
102
109
|
},
|
|
103
110
|
);
|
|
104
|
-
setColumns(newQueue
|
|
111
|
+
setColumns(newQueue);
|
|
105
112
|
setExpandedPath(newPath);
|
|
106
113
|
},
|
|
107
114
|
[flatOptions, multiple],
|
|
@@ -126,9 +133,9 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
126
133
|
|
|
127
134
|
// node mouse evt
|
|
128
135
|
const onNodeMouseEnter = (item: FlattenOption, level: number) => {
|
|
129
|
-
if (expandTrigger === 'hover' &&
|
|
136
|
+
if (expandTrigger === 'hover' && !item.isLeaf) {
|
|
130
137
|
const queue = columns.slice(0, level + 1);
|
|
131
|
-
queue.push(item.
|
|
138
|
+
queue.push(getChildren(flatOptions, item.uid));
|
|
132
139
|
setColumns(queue);
|
|
133
140
|
// Also update expandedPath to maintain highlight state
|
|
134
141
|
setExpandedPath((prev) => [
|
|
@@ -139,7 +146,6 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
139
146
|
};
|
|
140
147
|
|
|
141
148
|
// Helper function to get all descendant paths of a node
|
|
142
|
-
// Note: For very deep trees, consider adding maxDepth parameter or prevent stack overflow
|
|
143
149
|
const getAllDescendantPaths = useCallback(
|
|
144
150
|
(
|
|
145
151
|
node: FlattenOption,
|
|
@@ -148,17 +154,17 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
148
154
|
const paths: Array<Array<string | number>> = [];
|
|
149
155
|
const traverse = (currentNode: FlattenOption, depth: number) => {
|
|
150
156
|
if (depth > maxDepth) return; // Prevent stack overflow
|
|
151
|
-
if (
|
|
157
|
+
if (currentNode.isLeaf) {
|
|
152
158
|
paths.push(currentNode.path);
|
|
153
159
|
return;
|
|
154
160
|
}
|
|
155
|
-
const children = currentNode.
|
|
161
|
+
const children = getChildren(flatOptions, currentNode.uid);
|
|
156
162
|
children.forEach((child) => traverse(child, depth + 1));
|
|
157
163
|
};
|
|
158
164
|
traverse(node, 0);
|
|
159
165
|
return paths;
|
|
160
166
|
},
|
|
161
|
-
[],
|
|
167
|
+
[flatOptions],
|
|
162
168
|
);
|
|
163
169
|
|
|
164
170
|
// cascader node click
|
|
@@ -177,18 +183,17 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
177
183
|
// Check if current path is already selected
|
|
178
184
|
const isSelected = currentValue.some((v) => isEqual(v, item.path));
|
|
179
185
|
|
|
180
|
-
if (
|
|
186
|
+
if (!item.isLeaf) {
|
|
181
187
|
// Parent node: select/deselect all descendants
|
|
182
188
|
const descendantPaths = getAllDescendantPaths(item, 50); // Limit to depth 50 to prevent performance issues
|
|
183
|
-
const descendantPathStrs = descendantPaths.map((p) => p.join('-'));
|
|
184
189
|
|
|
185
190
|
// Filter out all descendant paths from current value
|
|
186
|
-
let filteredValue = currentValue.filter(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
let filteredValue = currentValue.filter(
|
|
192
|
+
(v) =>
|
|
193
|
+
!descendantPaths.some((descPath) =>
|
|
194
|
+
isSamePrefixPath(descPath, v),
|
|
195
|
+
),
|
|
196
|
+
);
|
|
192
197
|
|
|
193
198
|
if (!isSelected) {
|
|
194
199
|
// Add all descendant paths
|
|
@@ -196,12 +201,9 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
196
201
|
}
|
|
197
202
|
|
|
198
203
|
newValue = filteredValue;
|
|
199
|
-
newOpts = filteredValue.map((path) =>
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return nodeMap.get(uid);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
204
|
+
newOpts = filteredValue.map((path) =>
|
|
205
|
+
path.map((_, i) => nodeMap.get(pathToUid(path.slice(0, i + 1)))),
|
|
206
|
+
);
|
|
205
207
|
} else {
|
|
206
208
|
// Leaf node: toggle individual selection
|
|
207
209
|
if (isSelected) {
|
|
@@ -209,12 +211,9 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
209
211
|
} else {
|
|
210
212
|
newValue = [...currentValue, item.path];
|
|
211
213
|
}
|
|
212
|
-
newOpts = (newValue as Array<Array<string | number>>).map((path) =>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return nodeMap.get(uid);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
214
|
+
newOpts = (newValue as Array<Array<string | number>>).map((path) =>
|
|
215
|
+
path.map((_, i) => nodeMap.get(pathToUid(path.slice(0, i + 1)))),
|
|
216
|
+
);
|
|
218
217
|
}
|
|
219
218
|
changed = true;
|
|
220
219
|
} else if (shouldSelect) {
|
|
@@ -222,23 +221,21 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
222
221
|
newValue = multiple ? [...mergedValue, item.path] : item.path;
|
|
223
222
|
newOpts = multiple
|
|
224
223
|
? [
|
|
225
|
-
...(mergedValue as Array<Array<string | number>>).map((
|
|
226
|
-
const vs =
|
|
227
|
-
|
|
228
|
-
|
|
224
|
+
...(mergedValue as Array<Array<string | number>>).map((path) => {
|
|
225
|
+
const vs = path as Array<string | number>;
|
|
226
|
+
return vs.map((_, i) =>
|
|
227
|
+
nodeMap.get(pathToUid(vs.slice(0, i + 1))),
|
|
228
|
+
);
|
|
229
229
|
}),
|
|
230
|
-
|
|
231
|
-
item.path.
|
|
232
|
-
|
|
233
|
-
return nodeMap.get(uid);
|
|
234
|
-
}),
|
|
235
|
-
],
|
|
230
|
+
item.path.map((_, i) =>
|
|
231
|
+
nodeMap.get(pathToUid(item.path.slice(0, i + 1))),
|
|
232
|
+
),
|
|
236
233
|
]
|
|
237
234
|
: flatOptions.filter((opt: FlattenOption) => {
|
|
238
|
-
const
|
|
239
|
-
item.path.slice(0, i + 1)
|
|
235
|
+
const ancestors = item.path.map((_, i) =>
|
|
236
|
+
pathToUid(item.path.slice(0, i + 1)),
|
|
240
237
|
);
|
|
241
|
-
return
|
|
238
|
+
return ancestors.includes(opt.uid);
|
|
242
239
|
});
|
|
243
240
|
changed = true;
|
|
244
241
|
} else {
|
|
@@ -289,7 +286,7 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
289
286
|
return { options: [], selectedKeys: [] };
|
|
290
287
|
|
|
291
288
|
const { fullNode = false, onlyParentNode = false } = props;
|
|
292
|
-
const formatKey = (val: Array<string | number>) => val
|
|
289
|
+
const formatKey = (val: Array<string | number>) => pathToUid(val);
|
|
293
290
|
|
|
294
291
|
let rawValues: (string | number)[][] = [];
|
|
295
292
|
|
|
@@ -308,30 +305,27 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
308
305
|
// Filter values based on onlyParentNode option
|
|
309
306
|
let displayValues = rawValues;
|
|
310
307
|
if (multiple && onlyParentNode) {
|
|
311
|
-
// Find parent nodes that have all children selected
|
|
312
|
-
const
|
|
313
|
-
const
|
|
308
|
+
// Find parent nodes that have all (direct) children selected
|
|
309
|
+
const selectedPathKeys = new Set(rawValues.map(pathToUid));
|
|
310
|
+
const parentPaths: Array<Array<string | number>> = [];
|
|
314
311
|
|
|
315
312
|
// Check each node to see if it's a fully selected parent
|
|
316
|
-
nodeMap.forEach((node
|
|
317
|
-
if (
|
|
318
|
-
const allChildrenSelected = (node.
|
|
319
|
-
(child) =>
|
|
313
|
+
nodeMap.forEach((node) => {
|
|
314
|
+
if (!node.isLeaf) {
|
|
315
|
+
const allChildrenSelected = getChildren(flatOptions, node.uid).every(
|
|
316
|
+
(child) => selectedPathKeys.has(pathToUid(child.path)),
|
|
320
317
|
);
|
|
321
318
|
if (allChildrenSelected) {
|
|
322
|
-
|
|
319
|
+
parentPaths.push(node.path);
|
|
323
320
|
}
|
|
324
321
|
}
|
|
325
322
|
});
|
|
326
323
|
|
|
327
324
|
// Filter out child nodes whose parent is fully selected
|
|
328
|
-
displayValues = rawValues.filter(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
pathStr.startsWith(parentId + '-'),
|
|
333
|
-
);
|
|
334
|
-
});
|
|
325
|
+
displayValues = rawValues.filter(
|
|
326
|
+
(path) =>
|
|
327
|
+
!parentPaths.some((parentPath) => isSamePrefixPath(parentPath, path)),
|
|
328
|
+
);
|
|
335
329
|
}
|
|
336
330
|
|
|
337
331
|
const displayOptions = displayValues.map((valPath) => {
|
|
@@ -348,8 +342,7 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
348
342
|
options: opts,
|
|
349
343
|
});
|
|
350
344
|
} else {
|
|
351
|
-
const source =
|
|
352
|
-
opts[opts.length - 1]?.$source ?? opts[opts.length - 1];
|
|
345
|
+
const source = opts[opts.length - 1]?.$source;
|
|
353
346
|
label = (source?.[optionLabelProp as string] ??
|
|
354
347
|
'') as React.ReactNode;
|
|
355
348
|
}
|
|
@@ -367,6 +360,7 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
367
360
|
multiple,
|
|
368
361
|
mergedValue,
|
|
369
362
|
nodeMap,
|
|
363
|
+
flatOptions,
|
|
370
364
|
optionLabelProp,
|
|
371
365
|
props.fullNode,
|
|
372
366
|
props.onlyParentNode,
|
|
@@ -377,6 +371,12 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
377
371
|
popupVisible.current = newVisible;
|
|
378
372
|
};
|
|
379
373
|
|
|
374
|
+
const handleClear = () => {
|
|
375
|
+
setSearchValue('');
|
|
376
|
+
setMergedValue([]);
|
|
377
|
+
onChange?.([], []);
|
|
378
|
+
};
|
|
379
|
+
|
|
380
380
|
// Performance Note: For large datasets (1000+ options), consider:
|
|
381
381
|
// 1. Adding debounce to the search input
|
|
382
382
|
// 2. Implementing virtual scrolling for search results
|
|
@@ -390,7 +390,11 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
390
390
|
}> = [];
|
|
391
391
|
|
|
392
392
|
for (const item of flatOptions) {
|
|
393
|
-
|
|
393
|
+
// Match against the full breadcrumb (e.g. "A / B / C") so that:
|
|
394
|
+
// - searching a parent label surfaces its descendants,
|
|
395
|
+
// - the result row shows the full path to disambiguate duplicate leaf
|
|
396
|
+
// labels across different parents.
|
|
397
|
+
const text = item.labelPath.join(' / ');
|
|
394
398
|
const textLower = text.toLowerCase();
|
|
395
399
|
if (textLower.includes(lowStr)) {
|
|
396
400
|
const matches: Array<{ text: string; highlight: boolean }> = [];
|
|
@@ -435,6 +439,7 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
435
439
|
mode={multiple ? 'multiple' : undefined}
|
|
436
440
|
value={searchValue}
|
|
437
441
|
onSearch={handleSearch}
|
|
442
|
+
onClear={handleClear}
|
|
438
443
|
/>
|
|
439
444
|
);
|
|
440
445
|
};
|
package/src/Cascader/column.tsx
CHANGED
|
@@ -24,11 +24,27 @@ export type FieldNames = {
|
|
|
24
24
|
children: string;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Flattened representation of a tree node.
|
|
29
|
+
*
|
|
30
|
+
* Deliberately a concrete type (not `Option & ...`) so that:
|
|
31
|
+
* - `.label` / `.value` / `.isLeaf` resolve to their precise types (an index
|
|
32
|
+
* signature on `Option` would otherwise widen them to `unknown`),
|
|
33
|
+
* - `.children` is a compile error — flattened nodes intentionally do not
|
|
34
|
+
* carry children; use `getChildren(data, uid)` instead.
|
|
35
|
+
* Dynamic/extra-field access should go through `$source` (the raw node).
|
|
36
|
+
*/
|
|
37
|
+
export type FlattenOption = {
|
|
38
|
+
$source: Option;
|
|
39
|
+
label: string;
|
|
40
|
+
value: string | number;
|
|
28
41
|
pid: string;
|
|
29
42
|
uid: string;
|
|
30
43
|
path: Array<string | number>;
|
|
31
|
-
|
|
44
|
+
labelPath: string[];
|
|
45
|
+
level: number;
|
|
46
|
+
isLeaf: boolean;
|
|
47
|
+
disabled?: boolean;
|
|
32
48
|
};
|
|
33
49
|
|
|
34
50
|
export type NodeProps = FlattenOption & {
|
|
@@ -104,6 +120,7 @@ export interface CascaderProps extends Omit<
|
|
|
104
120
|
multiple?: boolean;
|
|
105
121
|
/**
|
|
106
122
|
* Is it searchable
|
|
123
|
+
* @default true
|
|
107
124
|
*/
|
|
108
125
|
searchable?: boolean;
|
|
109
126
|
/**
|
package/src/Cascader/node.tsx
CHANGED
|
@@ -5,12 +5,12 @@ import Checkbox from '../Checkbox';
|
|
|
5
5
|
import Spin from '../Spin';
|
|
6
6
|
import isEqual from '../utils/isEqual';
|
|
7
7
|
import { CascaderCtx } from './cascader';
|
|
8
|
-
import {
|
|
8
|
+
import { getChildren, isHalfChecked } from './utils';
|
|
9
9
|
|
|
10
10
|
import type { NodeProps } from './interface';
|
|
11
11
|
|
|
12
12
|
const Node = (props: NodeProps) => {
|
|
13
|
-
const { uid, value, disabled, label,
|
|
13
|
+
const { uid, value, disabled, label, $source, isLeaf, path, level } = props;
|
|
14
14
|
|
|
15
15
|
const {
|
|
16
16
|
prefixCls,
|
|
@@ -19,11 +19,12 @@ const Node = (props: NodeProps) => {
|
|
|
19
19
|
mergedValue,
|
|
20
20
|
loadData,
|
|
21
21
|
nodeMap,
|
|
22
|
+
flatOptions,
|
|
22
23
|
onNodeMouseEnter,
|
|
23
24
|
onItemClick,
|
|
24
25
|
} = useContext(CascaderCtx);
|
|
25
26
|
|
|
26
|
-
const isParent =
|
|
27
|
+
const isParent = !isLeaf;
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* 0: not load
|
|
@@ -50,7 +51,7 @@ const Node = (props: NodeProps) => {
|
|
|
50
51
|
const handleLoadData = () => {
|
|
51
52
|
if (loadData && isLeaf === false) {
|
|
52
53
|
setLoad(1);
|
|
53
|
-
loadData(
|
|
54
|
+
loadData($source)
|
|
54
55
|
?.then(() => {
|
|
55
56
|
setLoad(2);
|
|
56
57
|
})
|
|
@@ -79,13 +80,17 @@ const Node = (props: NodeProps) => {
|
|
|
79
80
|
const [checkedAll, indeterminate] = useMemo(() => {
|
|
80
81
|
const currentNode = nodeMap.get(uid);
|
|
81
82
|
if (!multiple || !currentNode || !isParent) return [false, false];
|
|
82
|
-
return isHalfChecked(
|
|
83
|
-
|
|
83
|
+
return isHalfChecked(
|
|
84
|
+
mergedValue as (string | number)[][],
|
|
85
|
+
currentNode,
|
|
86
|
+
getChildren(flatOptions, uid),
|
|
87
|
+
);
|
|
88
|
+
}, [nodeMap, uid, mergedValue, flatOptions, isParent, multiple]);
|
|
84
89
|
|
|
85
90
|
const clsName = clsx(
|
|
86
91
|
`${prefixCls}-menu-item`,
|
|
87
92
|
{
|
|
88
|
-
[`${prefixCls}-menu-item-expand`]:
|
|
93
|
+
[`${prefixCls}-menu-item-expand`]: !isLeaf,
|
|
89
94
|
[`${prefixCls}-menu-item-disabled`]: disabled,
|
|
90
95
|
active: expandedPath[level]?.key === uid,
|
|
91
96
|
},
|
|
@@ -35,7 +35,7 @@ const SearchList = (props: SearchListProps) => {
|
|
|
35
35
|
<ul className={`${prefixCls}-filter-menu`}>
|
|
36
36
|
{items.length ? (
|
|
37
37
|
items.map((item) => {
|
|
38
|
-
const title = item.data
|
|
38
|
+
const title = item.data.$source?.title || item.data.labelPath.join(' / ');
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
41
|
<li
|