@laser-ui/components 1.6.1 → 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 (298) hide show
  1. package/CHANGELOG.md +10 -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 +94 -109
  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/LICENSE +0 -21
  270. package/hooks/useJSS.d.ts +0 -1
  271. package/hooks/useJSS.js +0 -15
  272. package/hooks/useNextTick.d.ts +0 -2
  273. package/internal/mask/Mask.d.ts +0 -3
  274. package/internal/mask/Mask.js +0 -36
  275. package/internal/transition/CollapseTransition.js +0 -101
  276. package/internal/transition/Transition.d.ts +0 -3
  277. package/internal/transition/Transition.js +0 -87
  278. package/internal/transition/types.d.ts +0 -33
  279. package/internal/wave/Wave.d.ts +0 -3
  280. /package/{internal/circular-progress → circular-progress}/index.d.ts +0 -0
  281. /package/{internal/circular-progress → circular-progress}/index.js +0 -0
  282. /package/{internal/circular-progress → circular-progress}/vars.d.ts +0 -0
  283. /package/{internal/circular-progress → circular-progress}/vars.js +0 -0
  284. /package/internal/{mask → lazy-loading}/types.js +0 -0
  285. /package/{internal/mask → mask}/index.d.ts +0 -0
  286. /package/{internal/mask → mask}/index.js +0 -0
  287. /package/{internal/mask → mask}/types.d.ts +0 -0
  288. /package/{internal/transition → mask}/types.js +0 -0
  289. /package/{internal/mask → mask}/vars.d.ts +0 -0
  290. /package/{internal/mask → mask}/vars.js +0 -0
  291. /package/{internal/transition → transition}/index.d.ts +0 -0
  292. /package/{internal/transition → transition}/index.js +0 -0
  293. /package/{internal/wave → transition}/types.js +0 -0
  294. /package/{hooks/useNextTick.js → upload/hooks.js} +0 -0
  295. /package/{internal/wave → wave}/index.d.ts +0 -0
  296. /package/{internal/wave → wave}/index.js +0 -0
  297. /package/{internal/wave → wave}/vars.d.ts +0 -0
  298. /package/{internal/wave → wave}/vars.js +0 -0
@@ -1,24 +1,24 @@
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, isNumber, 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 { TreeSelectSearchPanel } from './internal/TreeSelectSearchPanel';
12
12
  import { CLASSES } from './vars';
13
13
  import { BaseInput } from '../base-input';
14
+ import { CircularProgress } from '../circular-progress';
14
15
  import { Dropdown } from '../dropdown';
15
- import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useJSS, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
16
+ import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
16
17
  import { Icon } from '../icon';
17
- import { CircularProgress } from '../internal/circular-progress';
18
18
  import { Portal } from '../internal/portal';
19
- import { Transition } from '../internal/transition';
20
19
  import { ROOT_DATA } from '../root/vars';
21
20
  import { Tag } from '../tag';
21
+ import { Transition } from '../transition';
22
22
  import { TreePanel } from '../tree/internal/TreePanel';
23
23
  import { MultipleTreeNode } from '../tree/node/multiple-node';
24
24
  import { SingleTreeNode } from '../tree/node/single-node';
@@ -26,18 +26,15 @@ 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 TreeSelectFC(props, ref) {
30
- const _a = useComponentProps('TreeSelect', props), { styleOverrides, styleProvider, formControl, list, model, defaultModel, expands: expandsProp, defaultExpands, visible: visibleProp, defaultVisible, placeholder, multiple = false, searchable = false, searchValue: searchValueProp, defaultSearchValue, onlyLeafSelectable = true, showLine = false, clearable: clearableProp = false, loading = false, size: sizeProp, disabled: disabledProp = false, virtual = false, escClosable = true, customItem, customSelected, customSearch, inputRef: inputRefProp, inputRender, popupRender, onModelChange, onFirstExpand, onExpandsChange, onVisibleChange, onSearch, onClear, afterVisibleChange, onScrollBottom } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "formControl", "list", "model", "defaultModel", "expands", "defaultExpands", "visible", "defaultVisible", "placeholder", "multiple", "searchable", "searchValue", "defaultSearchValue", "onlyLeafSelectable", "showLine", "clearable", "loading", "size", "disabled", "virtual", "escClosable", "customItem", "customSelected", "customSearch", "inputRef", "inputRender", "popupRender", "onModelChange", "onFirstExpand", "onExpandsChange", "onVisibleChange", "onSearch", "onClear", "afterVisibleChange", "onScrollBottom"]);
29
+ export function TreeSelect(props) {
30
+ const _a = useComponentProps('TreeSelect', props), { ref, styleOverrides, styleProvider, formControl, list, model, defaultModel, expands: expandsProp, defaultExpands, visible: visibleProp, defaultVisible, placeholder, multiple = false, searchable = false, searchValue: searchValueProp, defaultSearchValue, onlyLeafSelectable = true, showLine = false, clearable: clearableProp = false, loading = false, size: sizeProp, disabled: disabledProp = false, virtual = false, escClosable = true, customItem, customSelected, customSearch, inputProps, popupRender, onModelChange, onFirstExpand, onExpandsChange, onVisibleChange, onSearch, onClear, afterVisibleChange, onScrollBottom } = _a, restProps = __rest(_a, ["ref", "styleOverrides", "styleProvider", "formControl", "list", "model", "defaultModel", "expands", "defaultExpands", "visible", "defaultVisible", "placeholder", "multiple", "searchable", "searchValue", "defaultSearchValue", "onlyLeafSelectable", "showLine", "clearable", "loading", "size", "disabled", "virtual", "escClosable", "customItem", "customSelected", "customSearch", "inputProps", "popupRender", "onModelChange", "onFirstExpand", "onExpandsChange", "onVisibleChange", "onSearch", "onClear", "afterVisibleChange", "onScrollBottom"]);
31
31
  const namespace = useNamespace();
32
32
  const styled = useStyled(CLASSES, {
33
33
  'tree-select': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['tree-select'],
34
34
  tree: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.tree,
35
35
  'tree-select-popup': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['tree-select-popup'],
36
36
  }, styleOverrides);
37
- const sheet = useJSS();
38
- const dataRef = useRef({
39
- expands: new Set(),
40
- });
37
+ const expandSaved = useRef(new Set());
41
38
  const { t } = useTranslation();
42
39
  const uniqueId = useId();
43
40
  const listId = `${namespace}-tree-select-list-${uniqueId}`;
@@ -46,7 +43,6 @@ function TreeSelectFC(props, ref) {
46
43
  const boxRef = useRef(null);
47
44
  const popupRef = useRef(null);
48
45
  const inputRef = useRef(null);
49
- const combineInputRef = useForkRef(inputRef, inputRefProp);
50
46
  const focusRef = useRef(null);
51
47
  const [nodes, nodesMap] = useMemo(() => {
52
48
  const nodes = list.map((item) => multiple
@@ -149,7 +145,7 @@ function TreeSelectFC(props, ref) {
149
145
  return searchList;
150
146
  })();
151
147
  const isEmpty = hasSearch ? searchList.length === 0 : nodes.length === 0;
152
- const [focusVisible, focusVisibleWrapper] = useFocusVisible((code) => code.startsWith('Arrow') || ['Home', 'End', 'Enter', 'Space'].includes(code));
148
+ const [focusVisible, focusVisibleProps] = useFocusVisible((code) => code.startsWith('Arrow') || ['Home', 'End', 'Enter', 'Space'].includes(code));
153
149
  const [_itemFocusedWithoutSearch, setItemFocusedWithoutSearch] = useState();
154
150
  const itemFocusedWithoutSearch = (() => {
155
151
  let itemFocused;
@@ -179,7 +175,6 @@ function TreeSelectFC(props, ref) {
179
175
  })();
180
176
  const maxZIndex = useMaxIndex(visible);
181
177
  const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${maxZIndex})`;
182
- const transformOrigin = useRef();
183
178
  const updatePosition = useEventCallback(() => {
184
179
  if (visible && boxRef.current && popupRef.current) {
185
180
  const boxWidth = boxRef.current.offsetWidth;
@@ -190,17 +185,11 @@ function TreeSelectFC(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
- minWidth: Math.min(boxWidth, maxWidth),
201
- maxWidth,
202
- });
203
- 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.minWidth = Math.min(boxWidth, maxWidth) + 'px';
192
+ popupRef.current.style.maxWidth = maxWidth + 'px';
204
193
  }
205
194
  });
206
195
  useContainerScrolling(boxRef, updatePosition, !visible);
@@ -224,8 +213,8 @@ function TreeSelectFC(props, ref) {
224
213
  });
225
214
  }
226
215
  else {
227
- if (!dataRef.current.expands.has(node.id)) {
228
- dataRef.current.expands.add(node.id);
216
+ if (!expandSaved.current.has(node.id)) {
217
+ expandSaved.current.add(node.id);
229
218
  onFirstExpand === null || onFirstExpand === void 0 ? void 0 : onFirstExpand(node.id, node.origin);
230
219
  }
231
220
  changeExpands((draft) => {
@@ -234,141 +223,9 @@ function TreeSelectFC(props, ref) {
234
223
  }
235
224
  }
236
225
  };
237
- const scrollCallback = useRef();
226
+ const scrollCallback = useRef(() => { });
238
227
  const inputable = searchable && visible;
239
228
  const clearable = clearableProp && hasSelected && !visible && !loading && !disabled;
240
- const inputNode = focusVisibleWrapper(createElement(searchable ? BaseInput : 'div', Object.assign(Object.assign(Object.assign(Object.assign({}, mergeCS(styled('tree-select__search'), {
241
- style: {
242
- opacity: inputable ? undefined : 0,
243
- zIndex: inputable ? undefined : -1,
244
- },
245
- })), 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: () => {
246
- changeVisible(false);
247
- }, onKeyDown: (e) => {
248
- if (e.code === 'Escape') {
249
- if (visible && escClosable) {
250
- e.stopPropagation();
251
- e.preventDefault();
252
- changeVisible(false);
253
- }
254
- }
255
- else {
256
- const itemFocused = (code) => {
257
- if (focusRef.current) {
258
- const item = focusRef.current(code);
259
- if (item) {
260
- hasSearch ? setItemFocusedWithSearch(item) : setItemFocusedWithoutSearch(item);
261
- if (virtual === false && !code.includes('level')) {
262
- scrollCallback.current = () => {
263
- const el = document.getElementById(getItemId(hasSearch ? item.value : item.id));
264
- if (el) {
265
- focusRef.current(el);
266
- }
267
- };
268
- if (visible) {
269
- scrollCallback.current();
270
- scrollCallback.current = undefined;
271
- }
272
- }
273
- }
274
- }
275
- };
276
- if (visible) {
277
- switch (e.code) {
278
- case 'ArrowUp': {
279
- e.preventDefault();
280
- itemFocused('prev');
281
- break;
282
- }
283
- case 'ArrowDown': {
284
- e.preventDefault();
285
- itemFocused('next');
286
- break;
287
- }
288
- case 'ArrowLeft': {
289
- if (!hasSearch) {
290
- e.preventDefault();
291
- itemFocused('prev-level');
292
- }
293
- break;
294
- }
295
- case 'ArrowRight': {
296
- if (!hasSearch) {
297
- e.preventDefault();
298
- itemFocused('next-level');
299
- }
300
- break;
301
- }
302
- case 'Home': {
303
- e.preventDefault();
304
- itemFocused('first');
305
- break;
306
- }
307
- case 'End': {
308
- e.preventDefault();
309
- itemFocused('last');
310
- break;
311
- }
312
- default: {
313
- if (e.code === 'Enter' || (e.code === 'Space' && !searchable)) {
314
- e.preventDefault();
315
- if (hasSearch) {
316
- if (itemFocusedWithSearch) {
317
- changeSelectedByClickWithSearch(itemFocusedWithSearch);
318
- }
319
- }
320
- else {
321
- if (itemFocusedWithoutSearch) {
322
- changeSelectedByClickWithoutSearch(itemFocusedWithoutSearch);
323
- }
324
- }
325
- }
326
- break;
327
- }
328
- }
329
- }
330
- else if (!(searchable && ['Home', 'End', 'Enter', 'Space'].includes(e.code))) {
331
- switch (e.code) {
332
- case 'End':
333
- case 'ArrowUp': {
334
- e.preventDefault();
335
- changeVisible(true);
336
- itemFocused('last');
337
- break;
338
- }
339
- case 'Home':
340
- case 'ArrowDown': {
341
- e.preventDefault();
342
- changeVisible(true);
343
- itemFocused('first');
344
- break;
345
- }
346
- case 'Enter':
347
- case 'Space': {
348
- e.preventDefault();
349
- changeVisible(true);
350
- break;
351
- }
352
- default: {
353
- if (isPrintableCharacter(e.key)) {
354
- changeVisible(true);
355
- }
356
- break;
357
- }
358
- }
359
- }
360
- }
361
- } }), searchable
362
- ? {
363
- type: 'text',
364
- value: searchValue,
365
- autoComplete: 'off',
366
- disabled,
367
- onValueChange: (val) => {
368
- changeSearchValue(val);
369
- },
370
- }
371
- : {})));
372
229
  const [selectedNode, suffixNode, selectedLabel] = (() => {
373
230
  let selectedNode = null;
374
231
  let suffixNode = null;
@@ -392,7 +249,7 @@ function TreeSelectFC(props, ref) {
392
249
  draft.splice(draft.findIndex((v) => v === id), 1);
393
250
  });
394
251
  return false;
395
- }, children: _jsx(Tag, { tabIndex: -1, size: size, children: selected.size }) }));
252
+ }, children: (dropdownProps) => (_jsx(Tag, Object.assign({}, dropdownProps, { tabIndex: -1, size: size, children: selected.size }))) }));
396
253
  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('tree-select__close'), { role: "button", "aria-label": t('Close'), onClick: (e) => {
397
254
  e.stopPropagation();
398
255
  const checkeds = node.changeStatus('UNCHECKED', selected);
@@ -418,7 +275,12 @@ function TreeSelectFC(props, ref) {
418
275
  }), {
419
276
  className: restProps.className,
420
277
  style: restProps.style,
421
- }), designProps, { ref: boxRef, onMouseDown: (e) => {
278
+ }), designProps, { ref: (instance) => {
279
+ boxRef.current = instance;
280
+ return () => {
281
+ boxRef.current = null;
282
+ };
283
+ }, onMouseDown: (e) => {
422
284
  var _a;
423
285
  (_a = restProps.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
424
286
  preventBlur(e);
@@ -431,7 +293,158 @@ function TreeSelectFC(props, ref) {
431
293
  (_a = restProps.onClick) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
432
294
  (_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
433
295
  changeVisible((draft) => (searchable ? true : !draft));
434
- }, children: [_jsxs("div", Object.assign({}, styled('tree-select__container'), { title: selectedLabel, children: [inputRender ? inputRender(inputNode) : inputNode, !inputable &&
296
+ }, children: [_jsxs("div", Object.assign({}, styled('tree-select__container'), { title: selectedLabel, children: [(() => {
297
+ const nodeProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, inputProps), mergeCS(styled('tree-select__search'), {
298
+ style: {
299
+ opacity: inputable ? undefined : 0,
300
+ zIndex: inputable ? undefined : -1,
301
+ },
302
+ })), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria), { ref: (instance) => {
303
+ inputRef.current = instance;
304
+ const ret = setRef(inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref, instance);
305
+ return () => {
306
+ inputRef.current = null;
307
+ ret();
308
+ };
309
+ }, tabIndex: disabled ? -1 : 0, role: 'combobox', 'aria-haspopup': 'listbox', 'aria-expanded': visible, 'aria-controls': listId, onFocus: (e) => {
310
+ var _a;
311
+ (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
312
+ focusVisibleProps.onFocus(e);
313
+ }, onBlur: (e) => {
314
+ var _a;
315
+ (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
316
+ focusVisibleProps.onBlur(e);
317
+ changeVisible(false);
318
+ }, onKeyDown: (e) => {
319
+ var _a;
320
+ (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
321
+ focusVisibleProps.onKeyDown(e);
322
+ if (e.code === 'Escape') {
323
+ if (visible && escClosable) {
324
+ e.stopPropagation();
325
+ e.preventDefault();
326
+ changeVisible(false);
327
+ }
328
+ }
329
+ else {
330
+ const itemFocused = (code) => {
331
+ if (focusRef.current) {
332
+ const item = focusRef.current(code);
333
+ if (item) {
334
+ hasSearch ? setItemFocusedWithSearch(item) : setItemFocusedWithoutSearch(item);
335
+ if (virtual === false && !code.includes('level')) {
336
+ scrollCallback.current = () => {
337
+ scrollCallback.current = () => { };
338
+ const el = document.getElementById(getItemId(hasSearch ? item.value : item.id));
339
+ if (el) {
340
+ focusRef.current(el);
341
+ }
342
+ };
343
+ if (visible) {
344
+ scrollCallback.current();
345
+ }
346
+ }
347
+ }
348
+ }
349
+ };
350
+ if (visible) {
351
+ switch (e.code) {
352
+ case 'ArrowUp': {
353
+ e.preventDefault();
354
+ itemFocused('prev');
355
+ break;
356
+ }
357
+ case 'ArrowDown': {
358
+ e.preventDefault();
359
+ itemFocused('next');
360
+ break;
361
+ }
362
+ case 'ArrowLeft': {
363
+ if (!hasSearch) {
364
+ e.preventDefault();
365
+ itemFocused('prev-level');
366
+ }
367
+ break;
368
+ }
369
+ case 'ArrowRight': {
370
+ if (!hasSearch) {
371
+ e.preventDefault();
372
+ itemFocused('next-level');
373
+ }
374
+ break;
375
+ }
376
+ case 'Home': {
377
+ e.preventDefault();
378
+ itemFocused('first');
379
+ break;
380
+ }
381
+ case 'End': {
382
+ e.preventDefault();
383
+ itemFocused('last');
384
+ break;
385
+ }
386
+ default: {
387
+ if (e.code === 'Enter' || (e.code === 'Space' && !searchable)) {
388
+ e.preventDefault();
389
+ if (hasSearch) {
390
+ if (itemFocusedWithSearch) {
391
+ changeSelectedByClickWithSearch(itemFocusedWithSearch);
392
+ }
393
+ }
394
+ else {
395
+ if (itemFocusedWithoutSearch) {
396
+ changeSelectedByClickWithoutSearch(itemFocusedWithoutSearch);
397
+ }
398
+ }
399
+ }
400
+ break;
401
+ }
402
+ }
403
+ }
404
+ else if (!(searchable && ['Home', 'End', 'Enter', 'Space'].includes(e.code))) {
405
+ switch (e.code) {
406
+ case 'End':
407
+ case 'ArrowUp': {
408
+ e.preventDefault();
409
+ changeVisible(true);
410
+ itemFocused('last');
411
+ break;
412
+ }
413
+ case 'Home':
414
+ case 'ArrowDown': {
415
+ e.preventDefault();
416
+ changeVisible(true);
417
+ itemFocused('first');
418
+ break;
419
+ }
420
+ case 'Enter':
421
+ case 'Space': {
422
+ e.preventDefault();
423
+ changeVisible(true);
424
+ break;
425
+ }
426
+ default: {
427
+ if (isPrintableCharacter(e.key)) {
428
+ changeVisible(true);
429
+ }
430
+ break;
431
+ }
432
+ }
433
+ }
434
+ }
435
+ } }), searchable
436
+ ? {
437
+ type: 'text',
438
+ value: searchValue,
439
+ autoComplete: 'off',
440
+ disabled,
441
+ onValueChange: (val) => {
442
+ changeSearchValue(val);
443
+ },
444
+ }
445
+ : {});
446
+ return searchable ? _jsx(BaseInput, Object.assign({}, nodeProps)) : _jsx("div", Object.assign({}, nodeProps));
447
+ })(), !inputable &&
435
448
  (hasSelected ? (_jsx("div", Object.assign({}, styled('tree-select__content'), { children: selectedNode }))) : placeholder ? (_jsx("div", Object.assign({}, styled('tree-select__placeholder-wrapper'), { children: _jsx("div", Object.assign({}, styled('tree-select__placeholder'), { children: placeholder })) }))) : null)] })), multiple && (_jsx("div", Object.assign({}, styled('tree-select__multiple-count'), { onClick: (e) => {
436
449
  e.stopPropagation();
437
450
  }, children: suffixNode }))), clearable && (_jsx("div", Object.assign({}, styled('tree-select__clear'), { role: "button", "aria-label": t('Clear'), onClick: (e) => {
@@ -453,56 +466,46 @@ function TreeSelectFC(props, ref) {
453
466
  document.body.appendChild(el);
454
467
  }
455
468
  return el;
456
- }, children: _jsx(Transition, { enter: visible, during: TTANSITION_DURING_POPUP, afterRender: () => {
457
- var _a;
469
+ }, children: _jsx(Transition, { enter: visible, name: `${namespace}-popup-down`, duration: TTANSITION_DURING_POPUP, onSkipEnter: () => {
470
+ updatePosition();
471
+ scrollCallback.current();
472
+ }, onBeforeEnter: () => {
458
473
  updatePosition();
459
- (_a = scrollCallback.current) === null || _a === void 0 ? void 0 : _a.call(scrollCallback);
460
- scrollCallback.current = undefined;
461
- }, afterEnter: () => {
474
+ scrollCallback.current();
475
+ }, onAfterEnter: () => {
462
476
  afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
463
- }, afterLeave: () => {
477
+ }, onAfterLeave: () => {
464
478
  afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
465
- }, children: (state) => {
466
- let transitionStyle = {};
467
- switch (state) {
468
- case 'enter':
469
- transitionStyle = { transform: 'scaleY(0.7)', opacity: 0 };
470
- break;
471
- case 'entering':
472
- transitionStyle = {
473
- transition: ['transform', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING_POPUP}ms ease-out`).join(', '),
474
- transformOrigin: transformOrigin.current,
475
- };
476
- break;
477
- case 'leaving':
478
- transitionStyle = {
479
- transform: 'scaleY(0.7)',
480
- opacity: 0,
481
- transition: ['transform', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING_POPUP}ms ease-in`).join(', '),
482
- transformOrigin: transformOrigin.current,
483
- };
484
- break;
485
- case 'leaved':
486
- transitionStyle = { display: 'none' };
487
- break;
488
- default:
489
- break;
490
- }
491
- return (_jsx("div", Object.assign({}, mergeCS(styled('tree-select-popup'), {
492
- style: Object.assign({ zIndex }, transitionStyle),
493
- }), { ref: popupRef, onMouseDown: (e) => {
494
- preventBlur(e);
495
- }, onMouseUp: (e) => {
496
- preventBlur(e);
497
- }, children: (() => {
498
- const el = (_jsxs("div", Object.assign({}, styled('tree-select-popup__content'), { children: [loading && (_jsx("div", Object.assign({}, styled('tree-select-popup__loading', {
499
- 'tree-select-popup__loading--empty': isEmpty,
500
- }), { children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) }))), loading && isEmpty ? null : hasSearch ? (_jsx(TreeSelectSearchPanel, { 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) => {
501
- setItemFocusedWithSearch(item);
502
- changeSelectedByClickWithSearch(item);
503
- } })) : (_jsx(TreePanel, { style: { maxHeight: 264, padding: '4px 0' }, ref: focusRef, id: listId, namespace: namespace, styled: styled, list: nodes, itemId: getItemId, itemSelected: !multiple && hasSelected ? nodesMap.get(selected) : undefined, itemFocused: itemFocusedWithoutSearch, expands: expands, customItem: customItem, showLine: showLine, multiple: multiple, onlyLeafSelectable: onlyLeafSelectable, disabled: false, virtual: virtual === false ? undefined : { listSize: 264, listPadding: 4, itemSize: isNumber(virtual) ? virtual : 32 }, focusVisible: focusVisible, onNodeFocus: setItemFocusedWithoutSearch, onNodeExpand: handleExpand, onNodeClick: changeSelectedByClickWithoutSearch, onScrollBottom: onScrollBottom }))] })));
504
- return popupRender ? popupRender(el) : el;
505
- })() })));
506
- } }) })] }));
479
+ }, children: (transitionRef, leaved) => (_jsx("div", Object.assign({}, mergeCS(styled('tree-select-popup'), {
480
+ style: Object.assign({ zIndex }, (leaved ? { display: 'none' } : undefined)),
481
+ }), { ref: (instance) => {
482
+ popupRef.current = instance;
483
+ transitionRef(instance);
484
+ return () => {
485
+ popupRef.current = null;
486
+ transitionRef(null);
487
+ };
488
+ }, onMouseDown: (e) => {
489
+ preventBlur(e);
490
+ }, onMouseUp: (e) => {
491
+ preventBlur(e);
492
+ }, children: (() => {
493
+ const el = (_jsxs("div", Object.assign({}, styled('tree-select-popup__content'), { children: [loading && (_jsx("div", Object.assign({}, styled('tree-select-popup__loading', {
494
+ 'tree-select-popup__loading--empty': isEmpty,
495
+ }), { children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) }))), loading && isEmpty ? null : hasSearch ? (_jsx(TreeSelectSearchPanel, { ref: (instance) => {
496
+ focusRef.current = instance;
497
+ return () => {
498
+ focusRef.current = null;
499
+ };
500
+ }, namespace: namespace, styled: styled, id: listId, list: searchList, customItem: customItem, itemId: getItemId, itemFocused: itemFocusedWithSearch, multiple: multiple, onlyLeafSelectable: onlyLeafSelectable, virtual: virtual, focusVisible: focusVisible, onClick: (item) => {
501
+ setItemFocusedWithSearch(item);
502
+ changeSelectedByClickWithSearch(item);
503
+ } })) : (_jsx(TreePanel, { style: { maxHeight: 264, padding: '4px 0' }, ref: (instance) => {
504
+ focusRef.current = instance;
505
+ return () => {
506
+ focusRef.current = null;
507
+ };
508
+ }, id: listId, namespace: namespace, styled: styled, list: nodes, itemId: getItemId, itemSelected: !multiple && hasSelected ? nodesMap.get(selected) : undefined, itemFocused: itemFocusedWithoutSearch, expands: expands, customItem: customItem, showLine: showLine, multiple: multiple, onlyLeafSelectable: onlyLeafSelectable, disabled: false, virtual: virtual === false ? undefined : { listSize: 264, listPadding: 4, itemSize: isNumber(virtual) ? virtual : 32 }, focusVisible: focusVisible, onNodeFocus: setItemFocusedWithoutSearch, onNodeExpand: handleExpand, onNodeClick: changeSelectedByClickWithoutSearch, onScrollBottom: onScrollBottom }))] })));
509
+ return popupRender ? popupRender(el) : el;
510
+ })() }))) }) })] }));
507
511
  }
508
- export const TreeSelect = forwardRef(TreeSelectFC);
@@ -4,6 +4,7 @@ import type { Styled } from '../../hooks/useStyled';
4
4
  import type { TreeItem } from '../../tree/types';
5
5
  import type { CLASSES } from '../vars';
6
6
  interface TreeSelectSearchPanelProps<V extends React.Key, T extends TreeItem<V>> {
7
+ ref?: React.Ref<(code: any) => TreeSelectSearchPanelItem<V, T> | undefined>;
7
8
  namespace: string;
8
9
  styled: Styled<typeof CLASSES>;
9
10
  id: string;
@@ -17,6 +18,5 @@ interface TreeSelectSearchPanelProps<V extends React.Key, T extends TreeItem<V>>
17
18
  focusVisible: boolean;
18
19
  onClick: (item: TreeSelectSearchPanelItem<V, T>) => void;
19
20
  }
20
- declare function TreeSelectSearchPanelFC<V extends React.Key, T extends TreeItem<V>>(props: TreeSelectSearchPanelProps<V, T>, ref: React.ForwardedRef<any>): JSX.Element | null;
21
- export declare const TreeSelectSearchPanel: <V extends React.Key, T extends TreeItem<V>>(props: TreeSelectSearchPanelProps<V, T> & React.RefAttributes<any>) => ReturnType<typeof TreeSelectSearchPanelFC>;
21
+ export declare function TreeSelectSearchPanel<V extends React.Key, T extends TreeItem<V>>(props: TreeSelectSearchPanelProps<V, T>): React.ReactElement | null;
22
22
  export {};
@@ -3,14 +3,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useEventCallback } from '@laser-ui/hooks';
4
4
  import { scrollIntoViewIfNeeded } from '@laser-ui/utils';
5
5
  import { isNumber, isUndefined } from 'lodash';
6
- import { forwardRef, useImperativeHandle, useMemo, useRef } from 'react';
6
+ import { useImperativeHandle, useMemo, useRef } from 'react';
7
7
  import { Checkbox } from '../../checkbox';
8
8
  import { Empty } from '../../empty';
9
9
  import { getTreeNodeLabel } from '../../tree/utils';
10
10
  import { TREE_NODE_KEY } from '../../tree/vars';
11
11
  import { VirtualScroll } from '../../virtual-scroll';
12
- function TreeSelectSearchPanelFC(props, ref) {
13
- const { namespace, styled, id, list, customItem, itemId, itemFocused, multiple, onlyLeafSelectable, virtual, focusVisible, onClick } = props;
12
+ export function TreeSelectSearchPanel(props) {
13
+ const { ref, namespace, styled, id, list, customItem, itemId, itemFocused, multiple, onlyLeafSelectable, virtual, focusVisible, onClick, } = props;
14
14
  const listRef = useRef(null);
15
15
  const vsRef = useRef(null);
16
16
  const handleKeyDown = useEventCallback((code) => {
@@ -46,7 +46,12 @@ function TreeSelectSearchPanelFC(props, ref) {
46
46
  itemSize: isNumber(virtual) ? virtual : 32,
47
47
  itemFocusable: (item) => item[TREE_NODE_KEY].enabled,
48
48
  }), [list, virtual]);
49
- return (_jsx(VirtualScroll, Object.assign({}, vsProps, { ref: vsRef, enable: virtual !== false, listSize: 264, listPadding: 4, itemRender: (item, index, props) => {
49
+ return (_jsx(VirtualScroll, Object.assign({}, vsProps, { ref: (instance) => {
50
+ vsRef.current = instance;
51
+ return () => {
52
+ vsRef.current = null;
53
+ };
54
+ }, enable: virtual !== false, listSize: 264, listPadding: 4, itemRender: (item, index, props) => {
50
55
  const node = item[TREE_NODE_KEY];
51
56
  let inSelected = node.checked;
52
57
  if (!onlyLeafSelectable) {
@@ -68,6 +73,10 @@ function TreeSelectSearchPanelFC(props, ref) {
68
73
  focusVisible && (itemFocused === null || itemFocused === void 0 ? void 0 : itemFocused.value) === item.value && _jsx("div", { className: `${namespace}-focus-outline` }),
69
74
  multiple && (_jsx("div", Object.assign({}, styled('tree__option-checkbox'), { children: _jsx(Checkbox, { model: node.checked, disabled: node.disabled }) }))),
70
75
  _jsx("div", Object.assign({}, styled('tree__option-content'), { children: customItem ? customItem(node.origin) : getTreeNodeLabel(node) }))));
71
- }, itemFocused: itemFocused === null || itemFocused === void 0 ? void 0 : itemFocused.value, placeholder: "li", children: (vsList, onScroll) => (_jsx("ul", Object.assign({}, styled('tree'), { ref: listRef, id: id, tabIndex: -1, role: "listbox", "aria-multiselectable": multiple, "aria-activedescendant": isUndefined(itemFocused) ? undefined : itemId(itemFocused.value), onScroll: onScroll, children: list.length === 0 ? _jsx(Empty, { style: { padding: '12px 28px' }, image: Empty.SIMPLE_IMG }) : vsList }))) })));
76
+ }, itemFocused: itemFocused === null || itemFocused === void 0 ? void 0 : itemFocused.value, placeholder: "li", children: (vsList, onScroll) => (_jsx("ul", Object.assign({}, styled('tree'), { ref: (instance) => {
77
+ listRef.current = instance;
78
+ return () => {
79
+ listRef.current = null;
80
+ };
81
+ }, id: id, tabIndex: -1, role: "listbox", "aria-multiselectable": multiple, "aria-activedescendant": isUndefined(itemFocused) ? undefined : itemId(itemFocused.value), onScroll: onScroll, children: list.length === 0 ? _jsx(Empty, { style: { padding: '12px 28px' }, image: Empty.SIMPLE_IMG }) : vsList }))) })));
72
82
  }
73
- export const TreeSelectSearchPanel = forwardRef(TreeSelectSearchPanelFC);
@@ -2,12 +2,13 @@
2
2
  import type { CLASSES } from './vars';
3
3
  import type { FormControlProvider } from '../form/types';
4
4
  import type { TreeItem } from '../tree/types';
5
- import type { BaseProps, CloneHTMLElement, Size } from '../types';
5
+ import type { BaseProps, Size } from '../types';
6
6
  export {};
7
7
  export interface TreeSelectRef {
8
8
  updatePosition: () => void;
9
9
  }
10
10
  export interface TreeSelectProps<V extends React.Key, T extends TreeItem<V>> extends BaseProps<'tree-select' | 'tree' | 'tree-select-popup', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
11
+ ref?: React.Ref<TreeSelectRef>;
11
12
  formControl?: FormControlProvider;
12
13
  list: T[];
13
14
  model?: V | null | V[];
@@ -35,8 +36,7 @@ export interface TreeSelectProps<V extends React.Key, T extends TreeItem<V>> ext
35
36
  filter?: (value: string, item: T) => boolean;
36
37
  sort?: (a: T, b: T) => number;
37
38
  };
38
- inputRef?: React.ForwardedRef<HTMLInputElement>;
39
- inputRender?: CloneHTMLElement;
39
+ inputProps?: React.ComponentPropsWithRef<'input'>;
40
40
  popupRender?: (el: React.ReactElement) => React.ReactNode;
41
41
  onModelChange?: (value: any, origin: any) => void;
42
42
  onFirstExpand?: (value: V, origin: T) => void;