@laser-ui/components 1.6.0 → 2.0.0

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 (297) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/accordion/Accordion.d.ts +1 -1
  3. package/accordion/Accordion.js +13 -25
  4. package/accordion/types.d.ts +1 -0
  5. package/affix/Affix.d.ts +2 -2
  6. package/affix/Affix.js +27 -32
  7. package/affix/types.d.ts +7 -2
  8. package/alert/Alert.d.ts +1 -1
  9. package/alert/Alert.js +12 -21
  10. package/anchor/Anchor.d.ts +2 -4
  11. package/anchor/Anchor.js +34 -26
  12. package/anchor/types.d.ts +1 -0
  13. package/avatar/Avatar.d.ts +1 -1
  14. package/avatar/Avatar.js +9 -3
  15. package/badge/Badge.d.ts +1 -1
  16. package/badge/Badge.js +22 -41
  17. package/badge/BadgeText.js +12 -26
  18. package/badge/internal/BadgeNumber.d.ts +2 -2
  19. package/badge/internal/BadgeNumber.js +34 -24
  20. package/base-input/BaseInput.d.ts +1 -2
  21. package/base-input/BaseInput.js +4 -4
  22. package/base-input/types.d.ts +1 -0
  23. package/breadcrumb/Breadcrumb.d.ts +1 -1
  24. package/button/Button.d.ts +1 -2
  25. package/button/Button.js +18 -22
  26. package/button/types.d.ts +1 -0
  27. package/card/Card.d.ts +1 -1
  28. package/card/CardAction.d.ts +1 -1
  29. package/card/CardAction.js +3 -4
  30. package/card/CardActions.d.ts +1 -1
  31. package/card/CardActions.js +7 -3
  32. package/card/CardContent.d.ts +1 -1
  33. package/card/CardHeader.d.ts +1 -1
  34. package/card/types.d.ts +5 -1
  35. package/cascader/Cascader.d.ts +2 -4
  36. package/cascader/Cascader.js +217 -214
  37. package/cascader/internal/CascaderPanel.d.ts +2 -2
  38. package/cascader/internal/CascaderPanel.js +21 -7
  39. package/cascader/internal/CascaderSearchPanel.d.ts +2 -2
  40. package/cascader/internal/CascaderSearchPanel.js +15 -6
  41. package/cascader/types.d.ts +3 -3
  42. package/checkbox/Checkbox.d.ts +1 -1
  43. package/checkbox/Checkbox.js +4 -5
  44. package/checkbox/CheckboxGroup.d.ts +1 -1
  45. package/checkbox/CheckboxGroup.js +8 -7
  46. package/checkbox/types.d.ts +14 -4
  47. package/{internal/circular-progress → circular-progress}/CircularProgress.d.ts +1 -1
  48. package/{internal/circular-progress → circular-progress}/CircularProgress.js +2 -2
  49. package/compose/Compose.d.ts +1 -1
  50. package/compose/ComposeItem.d.ts +1 -1
  51. package/config-provider/ConfigProvider.d.ts +1 -1
  52. package/config-provider/ConfigProvider.js +3 -3
  53. package/date-picker/DatePicker.d.ts +2 -2
  54. package/date-picker/DatePicker.js +116 -98
  55. package/date-picker/internal/DatePickerPanel.d.ts +2 -1
  56. package/date-picker/internal/DatePickerPanel.js +4 -4
  57. package/date-picker/types.d.ts +3 -3
  58. package/dialog-service.d.ts +9 -6
  59. package/dialog-service.js +50 -26
  60. package/drawer/Drawer.d.ts +1 -1
  61. package/drawer/Drawer.js +83 -92
  62. package/drawer/DrawerFooter.d.ts +1 -1
  63. package/drawer/DrawerFooter.js +12 -9
  64. package/drawer/DrawerHeader.d.ts +1 -1
  65. package/drawer/DrawerHeader.js +10 -7
  66. package/drawer/types.d.ts +9 -2
  67. package/drawer/vars.d.ts +5 -1
  68. package/drawer/vars.js +1 -1
  69. package/dropdown/Dropdown.d.ts +2 -4
  70. package/dropdown/Dropdown.js +83 -104
  71. package/dropdown/internal/DropdownGroup.d.ts +1 -1
  72. package/dropdown/internal/DropdownItem.d.ts +1 -1
  73. package/dropdown/internal/DropdownSub.d.ts +2 -1
  74. package/dropdown/internal/DropdownSub.js +26 -49
  75. package/dropdown/types.d.ts +15 -2
  76. package/empty/Empty.d.ts +1 -1
  77. package/fab/Fab.d.ts +1 -1
  78. package/fab/Fab.js +19 -14
  79. package/fab/FabBacktop.d.ts +1 -1
  80. package/fab/FabBacktop.js +24 -31
  81. package/fab/FabButton.d.ts +1 -1
  82. package/fab/FabButton.js +37 -10
  83. package/fab/types.d.ts +6 -2
  84. package/fab/vars.d.ts +14 -0
  85. package/fab/vars.js +4 -0
  86. package/form/Form.d.ts +1 -1
  87. package/form/Form.js +7 -2
  88. package/form/FormItem.d.ts +1 -1
  89. package/form/FormItem.js +35 -24
  90. package/form/internal/FormError.d.ts +3 -2
  91. package/form/internal/FormError.js +10 -19
  92. package/hooks/index.d.ts +0 -2
  93. package/hooks/index.js +0 -2
  94. package/hooks/useComponentProps.js +2 -2
  95. package/hooks/useFocusVisible.d.ts +9 -2
  96. package/hooks/useFocusVisible.js +5 -11
  97. package/hooks/useLayout.d.ts +2 -2
  98. package/hooks/useLayout.js +2 -2
  99. package/hooks/useNamespace.js +2 -2
  100. package/hooks/useNestedPopup.d.ts +1 -1
  101. package/hooks/useScopedProps.js +2 -2
  102. package/hooks/useStyled.js +2 -2
  103. package/hooks/useTranslation.js +2 -2
  104. package/icon/Icon.d.ts +1 -1
  105. package/icon/Icon.js +7 -4
  106. package/image/Image.d.ts +1 -1
  107. package/image/Image.js +6 -2
  108. package/image/ImageAction.d.ts +1 -1
  109. package/image/ImageAction.js +3 -4
  110. package/image/ImageLoader.d.ts +1 -1
  111. package/image/ImagePreview.d.ts +1 -1
  112. package/image/ImagePreview.js +95 -110
  113. package/image/types.d.ts +6 -2
  114. package/input/Input.d.ts +1 -1
  115. package/input/Input.js +12 -8
  116. package/input/InputNumber.js +49 -40
  117. package/input/types.d.ts +3 -5
  118. package/internal/lazy-loading/LazyLoading.d.ts +3 -0
  119. package/internal/lazy-loading/LazyLoading.js +9 -0
  120. package/internal/lazy-loading/index.d.ts +2 -0
  121. package/internal/lazy-loading/index.js +1 -0
  122. package/internal/lazy-loading/types.d.ts +7 -0
  123. package/internal/popup/Popup.d.ts +1 -1
  124. package/internal/popup/Popup.js +40 -68
  125. package/internal/popup/types.d.ts +13 -6
  126. package/internal/portal/Portal.d.ts +1 -1
  127. package/internal/portal/Portal.js +12 -6
  128. package/internal/portal/types.d.ts +3 -2
  129. package/mask/Mask.d.ts +3 -0
  130. package/mask/Mask.js +31 -0
  131. package/menu/Menu.d.ts +2 -4
  132. package/menu/Menu.js +37 -42
  133. package/menu/internal/MenuGroup.d.ts +1 -1
  134. package/menu/internal/MenuItem.d.ts +1 -1
  135. package/menu/internal/MenuItem.js +14 -10
  136. package/menu/internal/MenuSub.d.ts +2 -1
  137. package/menu/internal/MenuSub.js +43 -70
  138. package/menu/types.d.ts +1 -0
  139. package/modal/Modal.d.ts +1 -1
  140. package/modal/Modal.js +77 -80
  141. package/modal/ModalAlert.d.ts +1 -1
  142. package/modal/ModalFooter.d.ts +1 -1
  143. package/modal/ModalFooter.js +12 -9
  144. package/modal/ModalHeader.d.ts +1 -1
  145. package/modal/ModalHeader.js +10 -7
  146. package/modal/types.d.ts +9 -2
  147. package/modal/vars.d.ts +5 -0
  148. package/modal/vars.js +2 -0
  149. package/notification/Notification.d.ts +1 -1
  150. package/notification/Notification.js +44 -71
  151. package/notification/types.d.ts +1 -0
  152. package/package.json +2 -2
  153. package/pagination/Pagination.d.ts +1 -1
  154. package/pagination/Pagination.js +9 -6
  155. package/popover/Popover.d.ts +2 -2
  156. package/popover/Popover.js +82 -118
  157. package/popover/PopoverFooter.d.ts +1 -1
  158. package/popover/PopoverFooter.js +12 -9
  159. package/popover/PopoverHeader.d.ts +1 -1
  160. package/popover/PopoverHeader.js +10 -7
  161. package/popover/types.d.ts +18 -4
  162. package/popover/vars.d.ts +5 -0
  163. package/popover/vars.js +2 -0
  164. package/progress/Progress.d.ts +1 -1
  165. package/radio/Radio.d.ts +1 -1
  166. package/radio/Radio.js +18 -13
  167. package/radio/RadioGroup.d.ts +1 -1
  168. package/radio/RadioGroup.js +12 -7
  169. package/radio/types.d.ts +16 -4
  170. package/radio/vars.d.ts +6 -0
  171. package/radio/vars.js +2 -0
  172. package/rating/Rating.d.ts +1 -1
  173. package/rating/internal/RatingStar.d.ts +1 -1
  174. package/rating/internal/RatingStar.js +23 -21
  175. package/root/Root.d.ts +1 -1
  176. package/root/Root.js +1 -1
  177. package/select/Select.d.ts +2 -4
  178. package/select/Select.js +245 -243
  179. package/select/types.d.ts +3 -3
  180. package/separator/Separator.d.ts +1 -1
  181. package/skeleton/Skeleton.d.ts +1 -1
  182. package/slider/Slider.d.ts +1 -1
  183. package/slider/Slider.js +54 -34
  184. package/slider/types.d.ts +2 -3
  185. package/slides/Slides.d.ts +1 -1
  186. package/slides/Slides.js +8 -3
  187. package/spinner/Spinner.d.ts +1 -1
  188. package/spinner/Spinner.js +27 -29
  189. package/stepper/Stepper.d.ts +1 -1
  190. package/stepper/Stepper.js +9 -16
  191. package/switch/Switch.js +33 -24
  192. package/switch/types.d.ts +2 -3
  193. package/table/Table.d.ts +1 -1
  194. package/table/Table.js +14 -10
  195. package/table/TableEmpty.d.ts +1 -1
  196. package/table/TableEmpty.js +9 -3
  197. package/table/TableExpand.d.ts +1 -1
  198. package/table/TableFilter.d.ts +1 -1
  199. package/table/TableFilter.js +1 -1
  200. package/table/TableTd.d.ts +1 -1
  201. package/table/TableTh.d.ts +1 -1
  202. package/table/TableThAction.d.ts +1 -1
  203. package/table/TableThAction.js +3 -4
  204. package/table/internal/TableCell.d.ts +1 -1
  205. package/table/internal/TableCell.js +13 -5
  206. package/table/types.d.ts +9 -2
  207. package/tabs/Tabs.d.ts +2 -4
  208. package/tabs/Tabs.js +41 -25
  209. package/tabs/types.d.ts +1 -0
  210. package/tag/Tag.d.ts +1 -1
  211. package/textarea/Textarea.d.ts +1 -1
  212. package/textarea/Textarea.js +15 -8
  213. package/textarea/types.d.ts +1 -0
  214. package/time-picker/TimePicker.d.ts +2 -2
  215. package/time-picker/TimePicker.js +89 -75
  216. package/time-picker/internal/TimePickerPanel.d.ts +2 -1
  217. package/time-picker/internal/TimePickerPanel.js +22 -7
  218. package/time-picker/types.d.ts +3 -3
  219. package/timeline/Timeline.d.ts +1 -1
  220. package/toast/Toast.d.ts +1 -1
  221. package/toast/Toast.js +44 -72
  222. package/toast/types.d.ts +1 -0
  223. package/tooltip/Tooltip.d.ts +2 -2
  224. package/tooltip/Tooltip.js +50 -74
  225. package/tooltip/types.d.ts +10 -2
  226. package/transfer/Transfer.d.ts +1 -1
  227. package/transfer/internal/TransferPanel.d.ts +1 -1
  228. package/transfer/internal/TransferPanel.js +7 -2
  229. package/{internal/transition → transition}/CollapseTransition.d.ts +1 -1
  230. package/transition/CollapseTransition.js +65 -0
  231. package/transition/Transition.d.ts +3 -0
  232. package/transition/Transition.js +148 -0
  233. package/transition/types.d.ts +29 -0
  234. package/tree/Tree.d.ts +1 -1
  235. package/tree/Tree.js +19 -7
  236. package/tree/internal/TreePanel.d.ts +2 -2
  237. package/tree/internal/TreePanel.js +32 -26
  238. package/tree-select/TreeSelect.d.ts +2 -4
  239. package/tree-select/TreeSelect.js +216 -213
  240. package/tree-select/internal/TreeSelectSearchPanel.d.ts +2 -2
  241. package/tree-select/internal/TreeSelectSearchPanel.js +15 -6
  242. package/tree-select/types.d.ts +3 -3
  243. package/types.d.ts +1 -1
  244. package/upload/Upload.d.ts +1 -3
  245. package/upload/Upload.js +41 -50
  246. package/upload/UploadAction.d.ts +1 -1
  247. package/upload/UploadAction.js +19 -16
  248. package/upload/UploadButton.d.ts +1 -1
  249. package/upload/UploadButton.js +16 -12
  250. package/upload/UploadList.d.ts +1 -1
  251. package/upload/UploadList.js +52 -47
  252. package/upload/UploadPicture.d.ts +1 -1
  253. package/upload/UploadPicture.js +47 -53
  254. package/upload/UploadPictureList.d.ts +1 -1
  255. package/upload/UploadPictureList.js +52 -47
  256. package/upload/UploadPreviewAction.d.ts +1 -1
  257. package/upload/UploadPreviewAction.js +15 -14
  258. package/upload/hooks.d.ts +2 -0
  259. package/upload/types.d.ts +27 -6
  260. package/upload/vars.d.ts +11 -0
  261. package/upload/vars.js +3 -0
  262. package/virtual-scroll/VirtualScroll.d.ts +2 -4
  263. package/virtual-scroll/VirtualScroll.js +13 -21
  264. package/virtual-scroll/types.d.ts +2 -1
  265. package/wave/Wave.d.ts +3 -0
  266. package/{internal/wave → wave}/Wave.js +6 -6
  267. package/{internal/wave → wave}/types.d.ts +1 -0
  268. package/wave/types.js +1 -0
  269. package/hooks/useJSS.d.ts +0 -1
  270. package/hooks/useJSS.js +0 -15
  271. package/hooks/useNextTick.d.ts +0 -2
  272. package/internal/mask/Mask.d.ts +0 -3
  273. package/internal/mask/Mask.js +0 -36
  274. package/internal/transition/CollapseTransition.js +0 -101
  275. package/internal/transition/Transition.d.ts +0 -3
  276. package/internal/transition/Transition.js +0 -87
  277. package/internal/transition/types.d.ts +0 -33
  278. package/internal/wave/Wave.d.ts +0 -3
  279. /package/{internal/circular-progress → circular-progress}/index.d.ts +0 -0
  280. /package/{internal/circular-progress → circular-progress}/index.js +0 -0
  281. /package/{internal/circular-progress → circular-progress}/vars.d.ts +0 -0
  282. /package/{internal/circular-progress → circular-progress}/vars.js +0 -0
  283. /package/internal/{mask → lazy-loading}/types.js +0 -0
  284. /package/{internal/mask → mask}/index.d.ts +0 -0
  285. /package/{internal/mask → mask}/index.js +0 -0
  286. /package/{internal/mask → mask}/types.d.ts +0 -0
  287. /package/{internal/transition → mask}/types.js +0 -0
  288. /package/{internal/mask → mask}/vars.d.ts +0 -0
  289. /package/{internal/mask → mask}/vars.js +0 -0
  290. /package/{internal/transition → transition}/index.d.ts +0 -0
  291. /package/{internal/transition → transition}/index.js +0 -0
  292. /package/{internal/wave → transition}/types.js +0 -0
  293. /package/{hooks/useNextTick.js → upload/hooks.js} +0 -0
  294. /package/{internal/wave → wave}/index.d.ts +0 -0
  295. /package/{internal/wave → wave}/index.js +0 -0
  296. /package/{internal/wave → wave}/vars.d.ts +0 -0
  297. /package/{internal/wave → wave}/vars.js +0 -0
@@ -1,36 +1,35 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useEventCallback, useForkRef, useResize } from '@laser-ui/hooks';
4
- import { findNested } from '@laser-ui/utils';
3
+ import { useEventCallback, useResize } from '@laser-ui/hooks';
4
+ import { findNested, setRef } from '@laser-ui/utils';
5
5
  import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
6
6
  import CloseOutlined from '@material-design-icons/svg/outlined/close.svg?react';
7
7
  import KeyboardArrowDownOutlined from '@material-design-icons/svg/outlined/keyboard_arrow_down.svg?react';
8
8
  import SearchOutlined from '@material-design-icons/svg/outlined/search.svg?react';
9
9
  import { isNull, isUndefined } from 'lodash';
10
- import { createElement, forwardRef, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
10
+ import { useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
11
11
  import { CascaderPanel } from './internal/CascaderPanel';
12
12
  import { CascaderSearchPanel } from './internal/CascaderSearchPanel';
13
13
  import { CLASSES } from './vars';
14
14
  import { BaseInput } from '../base-input';
15
+ import { CircularProgress } from '../circular-progress';
15
16
  import { Dropdown } from '../dropdown';
16
- import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useJSS, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
17
+ import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
17
18
  import { Icon } from '../icon';
18
- import { CircularProgress } from '../internal/circular-progress';
19
19
  import { Portal } from '../internal/portal';
20
- import { Transition } from '../internal/transition';
21
20
  import { ROOT_DATA } from '../root/vars';
22
21
  import { Tag } from '../tag';
22
+ import { Transition } from '../transition';
23
23
  import { MultipleTreeNode } from '../tree/node/multiple-node';
24
24
  import { SingleTreeNode } from '../tree/node/single-node';
25
25
  import { getTreeNodeLabel } from '../tree/utils';
26
26
  import { TREE_NODE_KEY } from '../tree/vars';
27
27
  import { getVerticalSidePosition, isPrintableCharacter, mergeCS } from '../utils';
28
28
  import { TTANSITION_DURING_POPUP, WINDOW_SPACE } from '../vars';
29
- function CascaderFC(props, ref) {
30
- const _a = useComponentProps('Cascader', props), { styleOverrides, styleProvider, formControl, list, model, defaultModel, visible: visibleProp, defaultVisible, placeholder, multiple = false, searchable = false, searchValue: searchValueProp, defaultSearchValue, onlyLeafSelectable = true, clearable: clearableProp = false, loading = false, size: sizeProp, disabled: disabledProp = false, virtual = false, escClosable = true, customItem, customSelected, customSearch, inputRef: inputRefProp, inputRender, popupRender, onModelChange, onVisibleChange, onSearch, onClear, onFirstFocus, afterVisibleChange } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "formControl", "list", "model", "defaultModel", "visible", "defaultVisible", "placeholder", "multiple", "searchable", "searchValue", "defaultSearchValue", "onlyLeafSelectable", "clearable", "loading", "size", "disabled", "virtual", "escClosable", "customItem", "customSelected", "customSearch", "inputRef", "inputRender", "popupRender", "onModelChange", "onVisibleChange", "onSearch", "onClear", "onFirstFocus", "afterVisibleChange"]);
29
+ export function Cascader(props) {
30
+ const _a = useComponentProps('Cascader', props), { ref, styleOverrides, styleProvider, formControl, list, model, defaultModel, visible: visibleProp, defaultVisible, placeholder, multiple = false, searchable = false, searchValue: searchValueProp, defaultSearchValue, onlyLeafSelectable = true, clearable: clearableProp = false, loading = false, size: sizeProp, disabled: disabledProp = false, virtual = false, escClosable = true, customItem, customSelected, customSearch, inputProps, popupRender, onModelChange, onVisibleChange, onSearch, onClear, onFirstFocus, afterVisibleChange } = _a, restProps = __rest(_a, ["ref", "styleOverrides", "styleProvider", "formControl", "list", "model", "defaultModel", "visible", "defaultVisible", "placeholder", "multiple", "searchable", "searchValue", "defaultSearchValue", "onlyLeafSelectable", "clearable", "loading", "size", "disabled", "virtual", "escClosable", "customItem", "customSelected", "customSearch", "inputProps", "popupRender", "onModelChange", "onVisibleChange", "onSearch", "onClear", "onFirstFocus", "afterVisibleChange"]);
31
31
  const namespace = useNamespace();
32
32
  const styled = useStyled(CLASSES, { cascader: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.cascader, 'cascader-popup': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['cascader-popup'] }, styleOverrides);
33
- const sheet = useJSS();
34
33
  const { t } = useTranslation();
35
34
  const uniqueId = useId();
36
35
  const listId = `${namespace}-cascader-list-${uniqueId}`;
@@ -39,11 +38,8 @@ function CascaderFC(props, ref) {
39
38
  const boxRef = useRef(null);
40
39
  const popupRef = useRef(null);
41
40
  const inputRef = useRef(null);
42
- const combineInputRef = useForkRef(inputRef, inputRefProp);
43
41
  const focusRef = useRef(null);
44
- const dataRef = useRef({
45
- itemFocused: new Set(),
46
- });
42
+ const itemFocused = useRef(new Set());
47
43
  const [nodes, nodesMap] = useMemo(() => {
48
44
  const nodes = list.map((item) => multiple
49
45
  ? new MultipleTreeNode(item, (origin) => origin.value, {
@@ -141,11 +137,11 @@ function CascaderFC(props, ref) {
141
137
  return searchList;
142
138
  })();
143
139
  const isEmpty = hasSearch ? searchList.length === 0 : nodes.length === 0;
144
- const [focusVisible, focusVisibleWrapper] = useFocusVisible((code) => code.startsWith('Arrow') || ['Home', 'End', 'Enter', 'Space'].includes(code));
140
+ const [focusVisible, focusVisibleProps] = useFocusVisible((code) => code.startsWith('Arrow') || ['Home', 'End', 'Enter', 'Space'].includes(code));
145
141
  const [_itemFocusedWithoutSearch, setItemFocusedWithoutSearch] = useState();
146
142
  const changeItemFocusedWithoutSearch = (node) => {
147
- if (!dataRef.current.itemFocused.has(node.id)) {
148
- dataRef.current.itemFocused.add(node.id);
143
+ if (!itemFocused.current.has(node.id)) {
144
+ itemFocused.current.add(node.id);
149
145
  onFirstFocus === null || onFirstFocus === void 0 ? void 0 : onFirstFocus(node.id, node.origin);
150
146
  }
151
147
  setItemFocusedWithoutSearch(node);
@@ -163,8 +159,8 @@ function CascaderFC(props, ref) {
163
159
  })();
164
160
  const [_itemFocusedWithSearch, setItemFocusedWithSearch] = useState();
165
161
  const changeItemFocusedWithSearch = (item) => {
166
- if (!dataRef.current.itemFocused.has(item.value)) {
167
- dataRef.current.itemFocused.add(item.value);
162
+ if (!itemFocused.current.has(item.value)) {
163
+ itemFocused.current.add(item.value);
168
164
  onFirstFocus === null || onFirstFocus === void 0 ? void 0 : onFirstFocus(item.value, item[TREE_NODE_KEY].origin);
169
165
  }
170
166
  setItemFocusedWithSearch(item);
@@ -180,7 +176,6 @@ function CascaderFC(props, ref) {
180
176
  })();
181
177
  const maxZIndex = useMaxIndex(visible);
182
178
  const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${maxZIndex})`;
183
- const transformOrigin = useRef();
184
179
  const updatePosition = useEventCallback(() => {
185
180
  if (visible && boxRef.current && popupRef.current) {
186
181
  const height = popupRef.current.offsetHeight;
@@ -190,16 +185,10 @@ function CascaderFC(props, ref) {
190
185
  placement: 'bottom-left',
191
186
  inWindow: WINDOW_SPACE,
192
187
  });
193
- transformOrigin.current = position.transformOrigin;
194
- if (sheet.classes.position) {
195
- popupRef.current.classList.toggle(sheet.classes.position, false);
196
- }
197
- sheet.replaceRule('position', {
198
- top: position.top,
199
- left: position.left,
200
- maxWidth,
201
- });
202
- popupRef.current.classList.toggle(sheet.classes.position, true);
188
+ popupRef.current.style.setProperty(`--popup-down-transform-origin`, position.transformOrigin);
189
+ popupRef.current.style.top = position.top + 'px';
190
+ popupRef.current.style.left = position.left + 'px';
191
+ popupRef.current.style.maxWidth = maxWidth + 'px';
203
192
  }
204
193
  });
205
194
  useContainerScrolling(boxRef, updatePosition, !visible);
@@ -214,141 +203,9 @@ function CascaderFC(props, ref) {
214
203
  e.preventDefault();
215
204
  }
216
205
  };
217
- const scrollCallback = useRef();
206
+ const scrollCallback = useRef(() => { });
218
207
  const inputable = searchable && visible;
219
208
  const clearable = clearableProp && hasSelected && !visible && !loading && !disabled;
220
- const inputNode = focusVisibleWrapper(createElement(searchable ? BaseInput : 'div', Object.assign(Object.assign(Object.assign(Object.assign({}, mergeCS(styled('cascader__search'), {
221
- style: {
222
- opacity: inputable ? undefined : 0,
223
- zIndex: inputable ? undefined : -1,
224
- },
225
- })), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria), { ref: combineInputRef, tabIndex: disabled ? -1 : 0, role: 'combobox', 'aria-haspopup': 'listbox', 'aria-expanded': visible, 'aria-controls': listId, onBlur: () => {
226
- changeVisible(false);
227
- }, onKeyDown: (e) => {
228
- if (e.code === 'Escape') {
229
- if (visible && escClosable) {
230
- e.stopPropagation();
231
- e.preventDefault();
232
- changeVisible(false);
233
- }
234
- }
235
- else {
236
- const focusItem = (code) => {
237
- if (focusRef.current) {
238
- const item = focusRef.current(code);
239
- if (item) {
240
- hasSearch ? changeItemFocusedWithSearch(item) : changeItemFocusedWithoutSearch(item);
241
- if (virtual === false && !code.includes('level')) {
242
- scrollCallback.current = () => {
243
- const el = document.getElementById(getItemId(hasSearch ? item.value : item.id));
244
- if (el) {
245
- focusRef.current(el);
246
- }
247
- };
248
- if (visible) {
249
- scrollCallback.current();
250
- scrollCallback.current = undefined;
251
- }
252
- }
253
- }
254
- }
255
- };
256
- if (visible) {
257
- switch (e.code) {
258
- case 'ArrowUp': {
259
- e.preventDefault();
260
- focusItem('prev');
261
- break;
262
- }
263
- case 'ArrowDown': {
264
- e.preventDefault();
265
- focusItem('next');
266
- break;
267
- }
268
- case 'ArrowLeft': {
269
- if (!hasSearch) {
270
- e.preventDefault();
271
- focusItem('prev-level');
272
- }
273
- break;
274
- }
275
- case 'ArrowRight': {
276
- if (!hasSearch) {
277
- e.preventDefault();
278
- focusItem('next-level');
279
- }
280
- break;
281
- }
282
- case 'Home': {
283
- e.preventDefault();
284
- focusItem('first');
285
- break;
286
- }
287
- case 'End': {
288
- e.preventDefault();
289
- focusItem('last');
290
- break;
291
- }
292
- default: {
293
- if (e.code === 'Enter' || (e.code === 'Space' && !searchable)) {
294
- e.preventDefault();
295
- if (hasSearch) {
296
- if (itemFocusedWithSearch) {
297
- changeSelectedByClickWithSearch(itemFocusedWithSearch);
298
- }
299
- }
300
- else {
301
- if (itemFocusedWithoutSearch) {
302
- changeSelectedByClickWithoutSearch(itemFocusedWithoutSearch);
303
- }
304
- }
305
- }
306
- break;
307
- }
308
- }
309
- }
310
- else if (!(searchable && ['Home', 'End', 'Enter', 'Space'].includes(e.code))) {
311
- switch (e.code) {
312
- case 'End':
313
- case 'ArrowUp': {
314
- e.preventDefault();
315
- changeVisible(true);
316
- focusItem('last');
317
- break;
318
- }
319
- case 'Home':
320
- case 'ArrowDown': {
321
- e.preventDefault();
322
- changeVisible(true);
323
- focusItem('first');
324
- break;
325
- }
326
- case 'Enter':
327
- case 'Space': {
328
- e.preventDefault();
329
- changeVisible(true);
330
- break;
331
- }
332
- default: {
333
- if (isPrintableCharacter(e.key)) {
334
- changeVisible(true);
335
- }
336
- break;
337
- }
338
- }
339
- }
340
- }
341
- } }), searchable
342
- ? {
343
- type: 'text',
344
- value: searchValue,
345
- autoComplete: 'off',
346
- disabled,
347
- onValueChange: (val) => {
348
- changeSearchValue(val);
349
- },
350
- }
351
- : {})));
352
209
  const [selectedNode, suffixNode, selectedLabel] = (() => {
353
210
  let selectedNode = null;
354
211
  let suffixNode = null;
@@ -372,7 +229,7 @@ function CascaderFC(props, ref) {
372
229
  draft.splice(draft.findIndex((v) => v === id), 1);
373
230
  });
374
231
  return false;
375
- }, children: _jsx(Tag, { tabIndex: -1, size: size, children: selected.size }) }));
232
+ }, children: (dropdownProps) => (_jsx(Tag, Object.assign({}, dropdownProps, { tabIndex: -1, size: size, children: selected.size }))) }));
376
233
  selectedNode = selectedNodes.map(({ value, label, node }) => (_jsxs(Tag, { size: size, children: [label, !((node === null || node === void 0 ? void 0 : node.disabled) || disabled) && (_jsx("div", Object.assign({}, styled('cascader__close'), { role: "button", "aria-label": t('Close'), onClick: (e) => {
377
234
  e.stopPropagation();
378
235
  const checkeds = node.changeStatus('UNCHECKED', selected);
@@ -398,7 +255,12 @@ function CascaderFC(props, ref) {
398
255
  }), {
399
256
  className: restProps.className,
400
257
  style: restProps.style,
401
- }), designProps, { ref: boxRef, onMouseDown: (e) => {
258
+ }), designProps, { ref: (instance) => {
259
+ boxRef.current = instance;
260
+ return () => {
261
+ boxRef.current = null;
262
+ };
263
+ }, onMouseDown: (e) => {
402
264
  var _a;
403
265
  (_a = restProps.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
404
266
  preventBlur(e);
@@ -411,7 +273,158 @@ function CascaderFC(props, ref) {
411
273
  (_a = restProps.onClick) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
412
274
  (_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
413
275
  changeVisible((draft) => (searchable ? true : !draft));
414
- }, children: [_jsxs("div", Object.assign({}, styled('cascader__container'), { title: selectedLabel, children: [inputRender ? inputRender(inputNode) : inputNode, !inputable &&
276
+ }, children: [_jsxs("div", Object.assign({}, styled('cascader__container'), { title: selectedLabel, children: [(() => {
277
+ const nodeProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, inputProps), mergeCS(styled('cascader__search'), {
278
+ style: {
279
+ opacity: inputable ? undefined : 0,
280
+ zIndex: inputable ? undefined : -1,
281
+ },
282
+ })), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria), { ref: (instance) => {
283
+ inputRef.current = instance;
284
+ const ret = setRef(inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref, instance);
285
+ return () => {
286
+ inputRef.current = null;
287
+ ret();
288
+ };
289
+ }, tabIndex: disabled ? -1 : 0, role: 'combobox', 'aria-haspopup': 'listbox', 'aria-expanded': visible, 'aria-controls': listId, onFocus: (e) => {
290
+ var _a;
291
+ (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
292
+ focusVisibleProps.onFocus(e);
293
+ }, onBlur: (e) => {
294
+ var _a;
295
+ (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
296
+ focusVisibleProps.onBlur(e);
297
+ changeVisible(false);
298
+ }, onKeyDown: (e) => {
299
+ var _a;
300
+ (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
301
+ focusVisibleProps.onKeyDown(e);
302
+ if (e.code === 'Escape') {
303
+ if (visible && escClosable) {
304
+ e.stopPropagation();
305
+ e.preventDefault();
306
+ changeVisible(false);
307
+ }
308
+ }
309
+ else {
310
+ const focusItem = (code) => {
311
+ if (focusRef.current) {
312
+ const item = focusRef.current(code);
313
+ if (item) {
314
+ hasSearch ? changeItemFocusedWithSearch(item) : changeItemFocusedWithoutSearch(item);
315
+ if (virtual === false && !code.includes('level')) {
316
+ scrollCallback.current = () => {
317
+ scrollCallback.current = () => { };
318
+ const el = document.getElementById(getItemId(hasSearch ? item.value : item.id));
319
+ if (el) {
320
+ focusRef.current(el);
321
+ }
322
+ };
323
+ if (visible) {
324
+ scrollCallback.current();
325
+ }
326
+ }
327
+ }
328
+ }
329
+ };
330
+ if (visible) {
331
+ switch (e.code) {
332
+ case 'ArrowUp': {
333
+ e.preventDefault();
334
+ focusItem('prev');
335
+ break;
336
+ }
337
+ case 'ArrowDown': {
338
+ e.preventDefault();
339
+ focusItem('next');
340
+ break;
341
+ }
342
+ case 'ArrowLeft': {
343
+ if (!hasSearch) {
344
+ e.preventDefault();
345
+ focusItem('prev-level');
346
+ }
347
+ break;
348
+ }
349
+ case 'ArrowRight': {
350
+ if (!hasSearch) {
351
+ e.preventDefault();
352
+ focusItem('next-level');
353
+ }
354
+ break;
355
+ }
356
+ case 'Home': {
357
+ e.preventDefault();
358
+ focusItem('first');
359
+ break;
360
+ }
361
+ case 'End': {
362
+ e.preventDefault();
363
+ focusItem('last');
364
+ break;
365
+ }
366
+ default: {
367
+ if (e.code === 'Enter' || (e.code === 'Space' && !searchable)) {
368
+ e.preventDefault();
369
+ if (hasSearch) {
370
+ if (itemFocusedWithSearch) {
371
+ changeSelectedByClickWithSearch(itemFocusedWithSearch);
372
+ }
373
+ }
374
+ else {
375
+ if (itemFocusedWithoutSearch) {
376
+ changeSelectedByClickWithoutSearch(itemFocusedWithoutSearch);
377
+ }
378
+ }
379
+ }
380
+ break;
381
+ }
382
+ }
383
+ }
384
+ else if (!(searchable && ['Home', 'End', 'Enter', 'Space'].includes(e.code))) {
385
+ switch (e.code) {
386
+ case 'End':
387
+ case 'ArrowUp': {
388
+ e.preventDefault();
389
+ changeVisible(true);
390
+ focusItem('last');
391
+ break;
392
+ }
393
+ case 'Home':
394
+ case 'ArrowDown': {
395
+ e.preventDefault();
396
+ changeVisible(true);
397
+ focusItem('first');
398
+ break;
399
+ }
400
+ case 'Enter':
401
+ case 'Space': {
402
+ e.preventDefault();
403
+ changeVisible(true);
404
+ break;
405
+ }
406
+ default: {
407
+ if (isPrintableCharacter(e.key)) {
408
+ changeVisible(true);
409
+ }
410
+ break;
411
+ }
412
+ }
413
+ }
414
+ }
415
+ } }), searchable
416
+ ? {
417
+ type: 'text',
418
+ value: searchValue,
419
+ autoComplete: 'off',
420
+ disabled,
421
+ onValueChange: (val) => {
422
+ changeSearchValue(val);
423
+ },
424
+ }
425
+ : {});
426
+ return searchable ? _jsx(BaseInput, Object.assign({}, nodeProps)) : _jsx("div", Object.assign({}, nodeProps));
427
+ })(), !inputable &&
415
428
  (hasSelected ? (_jsx("div", Object.assign({}, styled('cascader__content'), { children: selectedNode }))) : placeholder ? (_jsx("div", Object.assign({}, styled('cascader__placeholder-wrapper'), { children: _jsx("div", Object.assign({}, styled('cascader__placeholder'), { children: placeholder })) }))) : null)] })), multiple && (_jsx("div", Object.assign({}, styled('cascader__multiple-count'), { onClick: (e) => {
416
429
  e.stopPropagation();
417
430
  }, children: suffixNode }))), clearable && (_jsx("div", Object.assign({}, styled('cascader__clear'), { role: "button", "aria-label": t('Clear'), onClick: (e) => {
@@ -433,56 +446,46 @@ function CascaderFC(props, ref) {
433
446
  document.body.appendChild(el);
434
447
  }
435
448
  return el;
436
- }, children: _jsx(Transition, { enter: visible, during: TTANSITION_DURING_POPUP, afterRender: () => {
437
- var _a;
449
+ }, children: _jsx(Transition, { enter: visible, name: `${namespace}-popup-down`, duration: TTANSITION_DURING_POPUP, onSkipEnter: () => {
450
+ updatePosition();
451
+ scrollCallback.current();
452
+ }, onBeforeEnter: () => {
438
453
  updatePosition();
439
- (_a = scrollCallback.current) === null || _a === void 0 ? void 0 : _a.call(scrollCallback);
440
- scrollCallback.current = undefined;
441
- }, afterEnter: () => {
454
+ scrollCallback.current();
455
+ }, onAfterEnter: () => {
442
456
  afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
443
- }, afterLeave: () => {
457
+ }, onAfterLeave: () => {
444
458
  afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
445
- }, children: (state) => {
446
- let transitionStyle = {};
447
- switch (state) {
448
- case 'enter':
449
- transitionStyle = { transform: 'scaleY(0.7)', opacity: 0 };
450
- break;
451
- case 'entering':
452
- transitionStyle = {
453
- transition: ['transform', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING_POPUP}ms ease-out`).join(', '),
454
- transformOrigin: transformOrigin.current,
455
- };
456
- break;
457
- case 'leaving':
458
- transitionStyle = {
459
- transform: 'scaleY(0.7)',
460
- opacity: 0,
461
- transition: ['transform', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING_POPUP}ms ease-in`).join(', '),
462
- transformOrigin: transformOrigin.current,
463
- };
464
- break;
465
- case 'leaved':
466
- transitionStyle = { display: 'none' };
467
- break;
468
- default:
469
- break;
470
- }
471
- return (_jsx("div", Object.assign({}, mergeCS(styled('cascader-popup'), {
472
- style: Object.assign({ zIndex }, transitionStyle),
473
- }), { ref: popupRef, onMouseDown: (e) => {
474
- preventBlur(e);
475
- }, onMouseUp: (e) => {
476
- preventBlur(e);
477
- }, children: (() => {
478
- const el = (_jsxs("div", Object.assign({}, styled('cascader-popup__content'), { children: [loading && (_jsx("div", Object.assign({}, styled('cascader-popup__loading', {
479
- 'cascader-popup__loading--empty': isEmpty,
480
- }), { children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) }))), loading && isEmpty ? null : hasSearch ? (_jsx(CascaderSearchPanel, { ref: focusRef, namespace: namespace, styled: styled, id: listId, list: searchList, customItem: customItem, itemId: getItemId, itemFocused: itemFocusedWithSearch, multiple: multiple, onlyLeafSelectable: onlyLeafSelectable, virtual: virtual, focusVisible: focusVisible, onClick: (item) => {
481
- changeItemFocusedWithSearch(item);
482
- changeSelectedByClickWithSearch(item);
483
- } })) : (_jsx(CascaderPanel, { ref: focusRef, namespace: namespace, styled: styled, id: listId, list: nodes, customItem: customItem, itemId: getItemId, itemSelected: !multiple && hasSelected ? nodesMap.get(selected) : undefined, itemFocused: itemFocusedWithoutSearch, multiple: multiple, virtual: virtual, focusVisible: focusVisible, onFocus: changeItemFocusedWithoutSearch, onClick: changeSelectedByClickWithoutSearch }))] })));
484
- return popupRender ? popupRender(el) : el;
485
- })() })));
486
- } }) })] }));
459
+ }, children: (transitionRef, leaved) => (_jsx("div", Object.assign({}, mergeCS(styled('cascader-popup'), {
460
+ style: Object.assign({ zIndex }, (leaved ? { display: 'none' } : undefined)),
461
+ }), { ref: (instance) => {
462
+ popupRef.current = instance;
463
+ transitionRef(instance);
464
+ return () => {
465
+ popupRef.current = null;
466
+ transitionRef(null);
467
+ };
468
+ }, onMouseDown: (e) => {
469
+ preventBlur(e);
470
+ }, onMouseUp: (e) => {
471
+ preventBlur(e);
472
+ }, children: (() => {
473
+ const el = (_jsxs("div", Object.assign({}, styled('cascader-popup__content'), { children: [loading && (_jsx("div", Object.assign({}, styled('cascader-popup__loading', {
474
+ 'cascader-popup__loading--empty': isEmpty,
475
+ }), { children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) }))), loading && isEmpty ? null : hasSearch ? (_jsx(CascaderSearchPanel, { ref: (instance) => {
476
+ focusRef.current = instance;
477
+ return () => {
478
+ focusRef.current = null;
479
+ };
480
+ }, namespace: namespace, styled: styled, id: listId, list: searchList, customItem: customItem, itemId: getItemId, itemFocused: itemFocusedWithSearch, multiple: multiple, onlyLeafSelectable: onlyLeafSelectable, virtual: virtual, focusVisible: focusVisible, onClick: (item) => {
481
+ changeItemFocusedWithSearch(item);
482
+ changeSelectedByClickWithSearch(item);
483
+ } })) : (_jsx(CascaderPanel, { ref: (instance) => {
484
+ focusRef.current = instance;
485
+ return () => {
486
+ focusRef.current = null;
487
+ };
488
+ }, namespace: namespace, styled: styled, id: listId, list: nodes, customItem: customItem, itemId: getItemId, itemSelected: !multiple && hasSelected ? nodesMap.get(selected) : undefined, itemFocused: itemFocusedWithoutSearch, multiple: multiple, virtual: virtual, focusVisible: focusVisible, onFocus: changeItemFocusedWithoutSearch, onClick: changeSelectedByClickWithoutSearch }))] })));
489
+ return popupRender ? popupRender(el) : el;
490
+ })() }))) }) })] }));
487
491
  }
488
- export const Cascader = forwardRef(CascaderFC);
@@ -4,6 +4,7 @@ import type { AbstractTreeNode } from '../../tree/node/abstract-node';
4
4
  import type { CascaderItem } from '../types';
5
5
  import type { CLASSES } from '../vars';
6
6
  interface CascaderPanelProps<V extends React.Key, T extends CascaderItem<V>> {
7
+ ref?: React.Ref<(code: any) => AbstractTreeNode<V, T> | undefined>;
7
8
  namespace: string;
8
9
  styled: Styled<typeof CLASSES>;
9
10
  id: string | undefined;
@@ -18,6 +19,5 @@ interface CascaderPanelProps<V extends React.Key, T extends CascaderItem<V>> {
18
19
  onFocus: (item: AbstractTreeNode<V, T>) => void;
19
20
  onClick: (item: AbstractTreeNode<V, T>) => void;
20
21
  }
21
- declare function CascaderPanelFC<V extends React.Key, T extends CascaderItem<V>>(props: CascaderPanelProps<V, T>, ref: React.ForwardedRef<any>): JSX.Element | null;
22
- export declare const CascaderPanel: <V extends React.Key, T extends CascaderItem<V>>(props: CascaderPanelProps<V, T> & React.RefAttributes<any>) => ReturnType<typeof CascaderPanelFC>;
22
+ export declare function CascaderPanel<V extends React.Key, T extends CascaderItem<V>>(props: CascaderPanelProps<V, T>): React.ReactElement | null;
23
23
  export {};
@@ -4,14 +4,14 @@ import { useEventCallback } from '@laser-ui/hooks';
4
4
  import { scrollIntoViewIfNeeded } from '@laser-ui/utils';
5
5
  import KeyboardArrowRightOutlined from '@material-design-icons/svg/outlined/keyboard_arrow_right.svg?react';
6
6
  import { isNumber, isUndefined } from 'lodash';
7
- import { forwardRef, useImperativeHandle, useMemo, useRef } from 'react';
7
+ import { useImperativeHandle, useMemo, useRef } from 'react';
8
8
  import { Checkbox } from '../../checkbox';
9
+ import { CircularProgress } from '../../circular-progress';
9
10
  import { Empty } from '../../empty';
10
11
  import { Icon } from '../../icon';
11
- import { CircularProgress } from '../../internal/circular-progress';
12
12
  import { VirtualScroll } from '../../virtual-scroll';
13
- function CascaderPanelFC(props, ref) {
14
- const { namespace, styled, id, list, customItem, itemId, itemSelected, itemFocused, multiple, virtual, focusVisible, onFocus, onClick, _root = true, } = props;
13
+ export function CascaderPanel(props) {
14
+ const { ref, namespace, styled, id, list, customItem, itemId, itemSelected, itemFocused, multiple, virtual, focusVisible, onFocus, onClick, _root = true, } = props;
15
15
  const listRef = useRef(null);
16
16
  const vsRef = useRef(null);
17
17
  const focusRef = useRef(null);
@@ -99,7 +99,12 @@ function CascaderPanelFC(props, ref) {
99
99
  itemSize: isNumber(virtual) ? virtual : 32,
100
100
  itemFocusable: (item) => item.enabled,
101
101
  }), [list, virtual]);
102
- return (_jsxs(_Fragment, { children: [_jsx(VirtualScroll, Object.assign({}, vsProps, { ref: vsRef, enable: virtual !== false, listSize: 264, listPadding: 4, itemRender: (item, index, props) => {
102
+ return (_jsxs(_Fragment, { children: [_jsx(VirtualScroll, Object.assign({}, vsProps, { ref: (instance) => {
103
+ vsRef.current = instance;
104
+ return () => {
105
+ vsRef.current = null;
106
+ };
107
+ }, enable: virtual !== false, listSize: 264, listPadding: 4, itemRender: (item, index, props) => {
103
108
  let isSelectedAncestry = false;
104
109
  if (item.children && itemSelected) {
105
110
  let node = itemSelected;
@@ -130,6 +135,15 @@ function CascaderPanelFC(props, ref) {
130
135
  } }) }))),
131
136
  _jsx("div", Object.assign({}, styled('cascader__option-content'), { children: customItem ? customItem(item.origin) : item.origin.label })),
132
137
  !item.isLeaf && (_jsx("div", Object.assign({}, styled('cascader__option-icon'), { children: _jsx(Icon, { children: item.origin.loading ? _jsx(CircularProgress, {}) : _jsx(KeyboardArrowRightOutlined, {}) }) })))));
133
- }, itemFocused: nodeFocused === null || nodeFocused === void 0 ? void 0 : nodeFocused.id, placeholder: "li", children: (vsList, onScroll) => (_jsx("ul", Object.assign({}, styled('cascader__list', 'cascader__list--inline'), { ref: listRef, id: id, tabIndex: -1, role: "listbox", "aria-multiselectable": multiple, "aria-activedescendant": _root && !isUndefined(itemFocused) ? itemId(itemFocused.id) : undefined, onScroll: onScroll, children: list.length === 0 ? _jsx(Empty, { style: { padding: '12px 28px' }, image: Empty.SIMPLE_IMG }) : vsList }))) })), nodeFocused && !nodeFocused.origin.loading && nodeFocused.children && (_jsx(CascaderPanel, Object.assign({}, props, { _root: false, ref: focusRef, id: undefined, list: nodeFocused.children })))] }));
138
+ }, itemFocused: nodeFocused === null || nodeFocused === void 0 ? void 0 : nodeFocused.id, placeholder: "li", children: (vsList, onScroll) => (_jsx("ul", Object.assign({}, styled('cascader__list', 'cascader__list--inline'), { ref: (instance) => {
139
+ listRef.current = instance;
140
+ return () => {
141
+ listRef.current = null;
142
+ };
143
+ }, id: id, tabIndex: -1, role: "listbox", "aria-multiselectable": multiple, "aria-activedescendant": _root && !isUndefined(itemFocused) ? itemId(itemFocused.id) : undefined, onScroll: onScroll, children: list.length === 0 ? _jsx(Empty, { style: { padding: '12px 28px' }, image: Empty.SIMPLE_IMG }) : vsList }))) })), nodeFocused && !nodeFocused.origin.loading && nodeFocused.children && (_jsx(CascaderPanel, Object.assign({}, props, { _root: false, ref: (instance) => {
144
+ focusRef.current = instance;
145
+ return () => {
146
+ focusRef.current = null;
147
+ };
148
+ }, id: undefined, list: nodeFocused.children })))] }));
134
149
  }
135
- export const CascaderPanel = forwardRef(CascaderPanelFC);
@@ -4,6 +4,7 @@ import type { Styled } from '../../hooks/useStyled';
4
4
  import type { CascaderItem } from '../types';
5
5
  import type { CLASSES } from '../vars';
6
6
  interface CascaderSearchPanelProps<V extends React.Key, T extends CascaderItem<V>> {
7
+ ref?: React.Ref<(code: any) => CascaderSearchPanelItem<V, T> | undefined>;
7
8
  namespace: string;
8
9
  styled: Styled<typeof CLASSES>;
9
10
  id: string;
@@ -17,6 +18,5 @@ interface CascaderSearchPanelProps<V extends React.Key, T extends CascaderItem<V
17
18
  focusVisible: boolean;
18
19
  onClick: (item: CascaderSearchPanelItem<V, T>) => void;
19
20
  }
20
- declare function CascaderSearchPanelFC<V extends React.Key, T extends CascaderItem<V>>(props: CascaderSearchPanelProps<V, T>, ref: React.ForwardedRef<any>): JSX.Element | null;
21
- export declare const CascaderSearchPanel: <V extends React.Key, T extends CascaderItem<V>>(props: CascaderSearchPanelProps<V, T> & React.RefAttributes<any>) => ReturnType<typeof CascaderSearchPanelFC>;
21
+ export declare function CascaderSearchPanel<V extends React.Key, T extends CascaderItem<V>>(props: CascaderSearchPanelProps<V, T>): React.ReactElement | null;
22
22
  export {};