@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.
Files changed (254) hide show
  1. package/dist/cjs/Button/button.d.ts +1 -1
  2. package/dist/cjs/CSV/download.d.ts +1 -1
  3. package/dist/cjs/Carousel/carousel.d.ts +2 -2
  4. package/dist/cjs/Carousel/carousel.js +9 -2
  5. package/dist/cjs/Carousel/interface.d.ts +5 -0
  6. package/dist/cjs/Cascader/cascader.js +53 -62
  7. package/dist/cjs/Cascader/interface.d.ts +19 -2
  8. package/dist/cjs/Cascader/node.js +11 -6
  9. package/dist/cjs/Cascader/search-list.js +2 -1
  10. package/dist/cjs/Cascader/utils/index.d.ts +58 -14
  11. package/dist/cjs/Cascader/utils/index.js +57 -73
  12. package/dist/cjs/Drawer/style/index.less +4 -0
  13. package/dist/cjs/FloatButton/float-button.d.ts +1 -1
  14. package/dist/cjs/Form/demo/basic.js +2 -2
  15. package/dist/cjs/Form/style/index.less +15 -0
  16. package/dist/cjs/Input/style/index.less +19 -17
  17. package/dist/cjs/InputNumber/style/index.less +0 -29
  18. package/dist/cjs/PickerPanel/interface.d.ts +44 -2
  19. package/dist/cjs/PickerPanel/panels/DatePanel/DateBody.d.ts +2 -1
  20. package/dist/cjs/PickerPanel/panels/DatePanel/DateHeader.d.ts +2 -1
  21. package/dist/cjs/PickerPanel/panels/DatePanel/DateHeader.js +1 -1
  22. package/dist/cjs/PickerPanel/panels/DatePanel/index.d.ts +2 -1
  23. package/dist/cjs/PickerPanel/panels/DateTimePanel/index.d.ts +7 -1
  24. package/dist/cjs/PickerPanel/panels/DateTimePanel/index.js +18 -4
  25. package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeBody.d.ts +2 -1
  26. package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeBody.js +1 -1
  27. package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeHeader.d.ts +2 -1
  28. package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeHeader.js +1 -1
  29. package/dist/cjs/PickerPanel/panels/DecadePanel/index.d.ts +2 -1
  30. package/dist/cjs/PickerPanel/panels/DecadePanel/index.js +1 -1
  31. package/dist/cjs/PickerPanel/panels/Header.d.ts +13 -1
  32. package/dist/cjs/PickerPanel/panels/MonthPanel/MonthBody.d.ts +2 -1
  33. package/dist/cjs/PickerPanel/panels/MonthPanel/MonthHeader.d.ts +2 -1
  34. package/dist/cjs/PickerPanel/panels/MonthPanel/MonthHeader.js +1 -1
  35. package/dist/cjs/PickerPanel/panels/MonthPanel/index.d.ts +2 -1
  36. package/dist/cjs/PickerPanel/panels/MonthPanel/index.js +1 -1
  37. package/dist/cjs/PickerPanel/panels/PanelBody.d.ts +21 -1
  38. package/dist/cjs/PickerPanel/panels/PanelBody.js +3 -3
  39. package/dist/cjs/PickerPanel/panels/QuarterPanel/QuarterBody.d.ts +2 -1
  40. package/dist/cjs/PickerPanel/panels/QuarterPanel/QuarterHeader.d.ts +2 -1
  41. package/dist/cjs/PickerPanel/panels/QuarterPanel/index.d.ts +2 -1
  42. package/dist/cjs/PickerPanel/panels/RangePanel/index.d.ts +2 -1
  43. package/dist/cjs/PickerPanel/panels/RangePanel/index.js +2 -2
  44. package/dist/cjs/PickerPanel/panels/RangePanel/interface.d.ts +5 -5
  45. package/dist/cjs/PickerPanel/panels/TimePanel/TimeBody.d.ts +17 -1
  46. package/dist/cjs/PickerPanel/panels/TimePanel/TimeCell.d.ts +7 -1
  47. package/dist/cjs/PickerPanel/panels/TimePanel/TimeCell.js +1 -1
  48. package/dist/cjs/PickerPanel/panels/TimePanel/TimeColumn.d.ts +14 -1
  49. package/dist/cjs/PickerPanel/panels/TimePanel/TimeColumn.js +1 -1
  50. package/dist/cjs/PickerPanel/panels/TimePanel/TimeHeader.d.ts +4 -1
  51. package/dist/cjs/PickerPanel/panels/TimePanel/index.d.ts +9 -1
  52. package/dist/cjs/PickerPanel/panels/WeekPanel/WeekBody.d.ts +2 -1
  53. package/dist/cjs/PickerPanel/panels/WeekPanel/WeekHeader.d.ts +2 -1
  54. package/dist/cjs/PickerPanel/panels/WeekPanel/index.d.ts +2 -1
  55. package/dist/cjs/PickerPanel/panels/YearPanel/YearBody.d.ts +2 -1
  56. package/dist/cjs/PickerPanel/panels/YearPanel/YearBody.js +2 -2
  57. package/dist/cjs/PickerPanel/panels/YearPanel/YearHeader.d.ts +2 -1
  58. package/dist/cjs/PickerPanel/panels/YearPanel/YearHeader.js +7 -1
  59. package/dist/cjs/PickerPanel/panels/YearPanel/index.d.ts +2 -1
  60. package/dist/cjs/PickerPanel/panels/YearPanel/index.js +1 -1
  61. package/dist/cjs/PickerPanel/utils/pickerUtils.d.ts +7 -7
  62. package/dist/cjs/PickerPanel/utils/pickerUtils.js +2 -2
  63. package/dist/cjs/Popover/style/index.less +1 -0
  64. package/dist/cjs/Select/interface.d.ts +77 -0
  65. package/dist/cjs/Select/option.d.ts +2 -1
  66. package/dist/cjs/Select/option.js +6 -3
  67. package/dist/cjs/Select/options.d.ts +3 -2
  68. package/dist/cjs/Select/options.js +53 -47
  69. package/dist/cjs/Select/select.js +1 -1
  70. package/dist/cjs/Select/style/index.less +8 -13
  71. package/dist/cjs/Selector/interface.d.ts +4 -0
  72. package/dist/cjs/Selector/selector.js +3 -0
  73. package/dist/cjs/Selector/style/index.less +21 -137
  74. package/dist/cjs/Table/hooks/useFilter.js +1 -1
  75. package/dist/cjs/Table/interface.d.ts +4 -0
  76. package/dist/cjs/Table/style/index.less +2 -0
  77. package/dist/cjs/Table/theader/filter.js +2 -1
  78. package/dist/cjs/Tabs/demo/basic.js +8 -1
  79. package/dist/cjs/Tabs/tabs.js +3 -1
  80. package/dist/cjs/Tag/demo/checkable.js +1 -0
  81. package/dist/cjs/Tag/tag.js +1 -1
  82. package/dist/cjs/TextArea/style/index.less +0 -17
  83. package/dist/cjs/Trigger/trigger.js +1 -1
  84. package/dist/cjs/hooks/useEvent.js +4 -1
  85. package/dist/cjs/style/color.css +1 -1
  86. package/dist/cjs/style/size.css +11 -2
  87. package/dist/cjs/style/themes.css +1 -1
  88. package/dist/cjs/style/variables.css +13 -4
  89. package/dist/cjs/version.d.ts +1 -1
  90. package/dist/cjs/version.js +1 -1
  91. package/dist/esm/Button/button.d.ts +1 -1
  92. package/dist/esm/CSV/download.d.ts +1 -1
  93. package/dist/esm/Carousel/carousel.d.ts +2 -2
  94. package/dist/esm/Carousel/carousel.js +5 -1
  95. package/dist/esm/Carousel/interface.d.ts +5 -0
  96. package/dist/esm/Cascader/cascader.js +49 -56
  97. package/dist/esm/Cascader/interface.d.ts +19 -2
  98. package/dist/esm/Cascader/node.js +8 -11
  99. package/dist/esm/Cascader/search-list.js +2 -1
  100. package/dist/esm/Cascader/utils/index.d.ts +58 -14
  101. package/dist/esm/Cascader/utils/index.js +124 -75
  102. package/dist/esm/Drawer/style/index.less +4 -0
  103. package/dist/esm/FloatButton/float-button.d.ts +1 -1
  104. package/dist/esm/Form/demo/basic.js +4 -2
  105. package/dist/esm/Form/style/index.less +15 -0
  106. package/dist/esm/Input/style/index.less +19 -17
  107. package/dist/esm/InputNumber/style/index.less +0 -29
  108. package/dist/esm/PickerPanel/interface.d.ts +44 -2
  109. package/dist/esm/PickerPanel/panels/DatePanel/DateBody.d.ts +2 -1
  110. package/dist/esm/PickerPanel/panels/DatePanel/DateHeader.d.ts +2 -1
  111. package/dist/esm/PickerPanel/panels/DatePanel/DateHeader.js +1 -1
  112. package/dist/esm/PickerPanel/panels/DatePanel/index.d.ts +2 -1
  113. package/dist/esm/PickerPanel/panels/DateTimePanel/index.d.ts +7 -1
  114. package/dist/esm/PickerPanel/panels/DateTimePanel/index.js +11 -7
  115. package/dist/esm/PickerPanel/panels/DecadePanel/DecadeBody.d.ts +2 -1
  116. package/dist/esm/PickerPanel/panels/DecadePanel/DecadeBody.js +2 -1
  117. package/dist/esm/PickerPanel/panels/DecadePanel/DecadeHeader.d.ts +2 -1
  118. package/dist/esm/PickerPanel/panels/DecadePanel/DecadeHeader.js +2 -1
  119. package/dist/esm/PickerPanel/panels/DecadePanel/index.d.ts +2 -1
  120. package/dist/esm/PickerPanel/panels/DecadePanel/index.js +1 -1
  121. package/dist/esm/PickerPanel/panels/Header.d.ts +13 -1
  122. package/dist/esm/PickerPanel/panels/MonthPanel/MonthBody.d.ts +2 -1
  123. package/dist/esm/PickerPanel/panels/MonthPanel/MonthHeader.d.ts +2 -1
  124. package/dist/esm/PickerPanel/panels/MonthPanel/MonthHeader.js +2 -1
  125. package/dist/esm/PickerPanel/panels/MonthPanel/index.d.ts +2 -1
  126. package/dist/esm/PickerPanel/panels/MonthPanel/index.js +1 -1
  127. package/dist/esm/PickerPanel/panels/PanelBody.d.ts +21 -1
  128. package/dist/esm/PickerPanel/panels/PanelBody.js +2 -4
  129. package/dist/esm/PickerPanel/panels/QuarterPanel/QuarterBody.d.ts +2 -1
  130. package/dist/esm/PickerPanel/panels/QuarterPanel/QuarterHeader.d.ts +2 -1
  131. package/dist/esm/PickerPanel/panels/QuarterPanel/index.d.ts +2 -1
  132. package/dist/esm/PickerPanel/panels/RangePanel/index.d.ts +2 -1
  133. package/dist/esm/PickerPanel/panels/RangePanel/index.js +2 -2
  134. package/dist/esm/PickerPanel/panels/RangePanel/interface.d.ts +5 -5
  135. package/dist/esm/PickerPanel/panels/TimePanel/TimeBody.d.ts +17 -1
  136. package/dist/esm/PickerPanel/panels/TimePanel/TimeCell.d.ts +7 -1
  137. package/dist/esm/PickerPanel/panels/TimePanel/TimeCell.js +1 -1
  138. package/dist/esm/PickerPanel/panels/TimePanel/TimeColumn.d.ts +14 -1
  139. package/dist/esm/PickerPanel/panels/TimePanel/TimeColumn.js +1 -1
  140. package/dist/esm/PickerPanel/panels/TimePanel/TimeHeader.d.ts +4 -1
  141. package/dist/esm/PickerPanel/panels/TimePanel/index.d.ts +9 -1
  142. package/dist/esm/PickerPanel/panels/WeekPanel/WeekBody.d.ts +2 -1
  143. package/dist/esm/PickerPanel/panels/WeekPanel/WeekHeader.d.ts +2 -1
  144. package/dist/esm/PickerPanel/panels/WeekPanel/index.d.ts +2 -1
  145. package/dist/esm/PickerPanel/panels/YearPanel/YearBody.d.ts +2 -1
  146. package/dist/esm/PickerPanel/panels/YearPanel/YearBody.js +3 -2
  147. package/dist/esm/PickerPanel/panels/YearPanel/YearHeader.d.ts +2 -1
  148. package/dist/esm/PickerPanel/panels/YearPanel/YearHeader.js +2 -1
  149. package/dist/esm/PickerPanel/panels/YearPanel/index.d.ts +2 -1
  150. package/dist/esm/PickerPanel/panels/YearPanel/index.js +1 -1
  151. package/dist/esm/PickerPanel/picker-panel.js +3 -0
  152. package/dist/esm/PickerPanel/utils/pickerUtils.d.ts +7 -7
  153. package/dist/esm/PickerPanel/utils/pickerUtils.js +4 -10
  154. package/dist/esm/Popover/style/index.less +1 -0
  155. package/dist/esm/Select/interface.d.ts +77 -0
  156. package/dist/esm/Select/option.d.ts +2 -1
  157. package/dist/esm/Select/option.js +11 -2
  158. package/dist/esm/Select/options.d.ts +3 -2
  159. package/dist/esm/Select/options.js +3 -1
  160. package/dist/esm/Select/select.js +1 -3
  161. package/dist/esm/Select/style/index.less +8 -13
  162. package/dist/esm/Selector/interface.d.ts +4 -0
  163. package/dist/esm/Selector/selector.js +4 -2
  164. package/dist/esm/Selector/style/index.less +21 -137
  165. package/dist/esm/Table/hooks/useFilter.js +1 -1
  166. package/dist/esm/Table/interface.d.ts +4 -0
  167. package/dist/esm/Table/style/index.less +2 -0
  168. package/dist/esm/Table/theader/filter.js +3 -4
  169. package/dist/esm/Tabs/demo/basic.js +4 -1
  170. package/dist/esm/Tabs/tabs.js +3 -1
  171. package/dist/esm/Tag/demo/checkable.js +1 -0
  172. package/dist/esm/Tag/tag.js +1 -1
  173. package/dist/esm/TextArea/style/index.less +0 -17
  174. package/dist/esm/Trigger/trigger.js +1 -1
  175. package/dist/esm/style/color.css +1 -1
  176. package/dist/esm/style/size.css +11 -2
  177. package/dist/esm/style/themes.css +1 -1
  178. package/dist/esm/style/variables.css +13 -4
  179. package/dist/esm/version.d.ts +1 -1
  180. package/dist/esm/version.js +1 -1
  181. package/dist/umd/yee-c.min.css +2 -2
  182. package/dist/umd/yee-c.min.js +1 -1
  183. package/package.json +1 -1
  184. package/src/Carousel/carousel.tsx +14 -3
  185. package/src/Carousel/interface.ts +6 -0
  186. package/src/Cascader/cascader.tsx +68 -63
  187. package/src/Cascader/column.tsx +1 -1
  188. package/src/Cascader/interface.ts +19 -2
  189. package/src/Cascader/node.tsx +12 -7
  190. package/src/Cascader/search-list.tsx +1 -1
  191. package/src/Cascader/utils/index.ts +130 -68
  192. package/src/Drawer/style/index.less +4 -0
  193. package/src/Dropdown/dropdown.tsx +1 -1
  194. package/src/FloatButton/float-button.tsx +5 -3
  195. package/src/Form/demo/basic.tsx +2 -2
  196. package/src/Form/style/index.less +15 -0
  197. package/src/Input/style/index.less +19 -17
  198. package/src/InputNumber/style/index.less +0 -29
  199. package/src/PickerPanel/interface.ts +43 -2
  200. package/src/PickerPanel/panels/DatePanel/DateBody.tsx +2 -1
  201. package/src/PickerPanel/panels/DatePanel/DateHeader.tsx +3 -2
  202. package/src/PickerPanel/panels/DatePanel/index.tsx +2 -1
  203. package/src/PickerPanel/panels/DateTimePanel/index.tsx +12 -5
  204. package/src/PickerPanel/panels/DecadePanel/DecadeBody.tsx +3 -2
  205. package/src/PickerPanel/panels/DecadePanel/DecadeHeader.tsx +3 -2
  206. package/src/PickerPanel/panels/DecadePanel/index.tsx +3 -2
  207. package/src/PickerPanel/panels/Header.tsx +14 -1
  208. package/src/PickerPanel/panels/MonthPanel/MonthBody.tsx +2 -1
  209. package/src/PickerPanel/panels/MonthPanel/MonthHeader.tsx +3 -2
  210. package/src/PickerPanel/panels/MonthPanel/index.tsx +3 -2
  211. package/src/PickerPanel/panels/PanelBody.tsx +27 -5
  212. package/src/PickerPanel/panels/QuarterPanel/QuarterBody.tsx +2 -1
  213. package/src/PickerPanel/panels/QuarterPanel/QuarterHeader.tsx +2 -1
  214. package/src/PickerPanel/panels/QuarterPanel/index.tsx +2 -1
  215. package/src/PickerPanel/panels/RangePanel/index.tsx +11 -9
  216. package/src/PickerPanel/panels/RangePanel/interface.ts +5 -5
  217. package/src/PickerPanel/panels/TimePanel/TimeBody.tsx +21 -5
  218. package/src/PickerPanel/panels/TimePanel/TimeCell.tsx +9 -2
  219. package/src/PickerPanel/panels/TimePanel/TimeColumn.tsx +15 -2
  220. package/src/PickerPanel/panels/TimePanel/TimeHeader.tsx +5 -1
  221. package/src/PickerPanel/panels/TimePanel/index.tsx +10 -1
  222. package/src/PickerPanel/panels/WeekPanel/WeekBody.tsx +2 -1
  223. package/src/PickerPanel/panels/WeekPanel/WeekHeader.tsx +2 -1
  224. package/src/PickerPanel/panels/WeekPanel/index.tsx +2 -1
  225. package/src/PickerPanel/panels/YearPanel/YearBody.tsx +4 -3
  226. package/src/PickerPanel/panels/YearPanel/YearHeader.tsx +9 -3
  227. package/src/PickerPanel/panels/YearPanel/index.tsx +3 -2
  228. package/src/PickerPanel/picker-panel.tsx +5 -3
  229. package/src/PickerPanel/utils/pickerUtils.ts +17 -8
  230. package/src/Popover/style/index.less +1 -0
  231. package/src/Select/interface.ts +87 -0
  232. package/src/Select/option.tsx +13 -4
  233. package/src/Select/options.tsx +49 -43
  234. package/src/Select/select.tsx +5 -2
  235. package/src/Select/style/index.less +8 -13
  236. package/src/Selector/interface.ts +4 -0
  237. package/src/Selector/selector.tsx +2 -0
  238. package/src/Selector/style/index.less +21 -137
  239. package/src/Splitter/hooks/useMove.ts +2 -2
  240. package/src/Table/hooks/useFilter.ts +1 -1
  241. package/src/Table/interface.ts +4 -0
  242. package/src/Table/style/index.less +2 -0
  243. package/src/Table/theader/filter.tsx +2 -2
  244. package/src/Tabs/demo/basic.tsx +7 -1
  245. package/src/Tabs/tabs.tsx +3 -2
  246. package/src/Tag/demo/checkable.tsx +1 -0
  247. package/src/Tag/tag.tsx +1 -1
  248. package/src/TextArea/style/index.less +0 -17
  249. package/src/Trigger/trigger.tsx +1 -1
  250. package/src/hooks/useEvent.ts +7 -4
  251. package/src/hooks/useMergedState.ts +6 -4
  252. package/src/style/color.css +1 -1
  253. package/src/style/size.css +11 -2
  254. package/src/version.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainbow-oh/yee-c",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "yee basic components",
5
5
  "keywords": [
6
6
  "react",
@@ -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 { CarouselProps } from './interface';
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({} as any);
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(child as any, { index });
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 { changeToView, flattenOptions, hasChild } from './utils';
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<Array<any>>([]);
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 as any);
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' && hasChild(item)) {
136
+ if (expandTrigger === 'hover' && !item.isLeaf) {
130
137
  const queue = columns.slice(0, level + 1);
131
- queue.push(item.children as FlattenOption[]);
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 (!hasChild(currentNode)) {
157
+ if (currentNode.isLeaf) {
152
158
  paths.push(currentNode.path);
153
159
  return;
154
160
  }
155
- const children = currentNode.children as FlattenOption[];
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 (hasChild(item)) {
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((v) => {
187
- const pathStr = v.join('-');
188
- return !descendantPathStrs.some((descPathStr) =>
189
- pathStr.startsWith(descPathStr),
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
- return path.map((_, i) => {
201
- const uid = path.slice(0, i + 1).join('-');
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
- return path.map((_, i) => {
214
- const uid = path.slice(0, i + 1).join('-');
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((item) => {
226
- const vs = item as Array<string | number>;
227
- const arr = vs.map((_, i) => vs.slice(0, i + 1).join('-'));
228
- return arr.map((uid: string) => nodeMap.get(uid));
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.map((_, i) => {
232
- const uid = item.path.slice(0, i + 1).join('-');
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 arr = item.path.map((_, i) =>
239
- item.path.slice(0, i + 1).join('-'),
235
+ const ancestors = item.path.map((_, i) =>
236
+ pathToUid(item.path.slice(0, i + 1)),
240
237
  );
241
- return arr.includes(opt.uid as string);
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.join('-');
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 parentIds: string[] = [];
313
- const childPathStrs = new Set(rawValues.map((v) => v.join('-')));
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, uid) => {
317
- if (hasChild(node)) {
318
- const allChildrenSelected = (node.children as FlattenOption[])?.every(
319
- (child) => childPathStrs.has(child.path.join('-')),
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
- parentIds.push(uid);
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((path) => {
329
- const pathStr = path.join('-');
330
- // Keep this path if it's not a child of any fully selected parent
331
- return !parentIds.some((parentId) =>
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
- const text = String(item.label);
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
  };
@@ -13,7 +13,7 @@ const Column = (props: ColumnProps) => {
13
13
  return (
14
14
  <ul className={`${prefixCls}-menu`} role="menu">
15
15
  {Array.isArray(data) &&
16
- data.map((item: any, idx: number) => {
16
+ data.map((item, idx: number) => {
17
17
  return (
18
18
  <Node
19
19
  {...item}
@@ -24,11 +24,27 @@ export type FieldNames = {
24
24
  children: string;
25
25
  };
26
26
 
27
- export type FlattenOption = Option & {
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
- $source: Option;
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
  /**
@@ -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 { hasChild, isHalfChecked } from './utils';
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, children, isLeaf, path, level } = props;
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 = hasChild(props);
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({ label, value, children })
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(mergedValue as (string | number)[][], currentNode);
83
- }, [nodeMap, uid, mergedValue, isParent, multiple]);
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`]: hasChild(props),
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.title || item.data.label;
38
+ const title = item.data.$source?.title || item.data.labelPath.join(' / ');
39
39
 
40
40
  return (
41
41
  <li