@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
@@ -15,5 +15,5 @@ interface TableCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
15
15
  } | undefined;
16
16
  ellipsis: boolean;
17
17
  }
18
- export declare function TableCell(props: TableCellProps): JSX.Element | null;
18
+ export declare function TableCell(props: TableCellProps): React.ReactElement | null;
19
19
  export {};
@@ -1,7 +1,8 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useIsomorphicLayoutEffect } from '@laser-ui/hooks';
3
4
  import { isNumber, isUndefined } from 'lodash';
4
- import { createElement, useContext, useEffect, useRef } from 'react';
5
+ import { use, useRef } from 'react';
5
6
  import { mergeCS } from '../../utils';
6
7
  import { TableContext } from '../vars';
7
8
  const ZINDEX_CONFIG = {
@@ -12,7 +13,7 @@ const ZINDEX_CONFIG = {
12
13
  };
13
14
  export function TableCell(props) {
14
15
  const { children, namespace, styled, tag, width, align, fixed, ellipsis: ellipsisProp } = props, restProps = __rest(props, ["children", "namespace", "styled", "tag", "width", "align", "fixed", "ellipsis"]);
15
- const tableContext = useContext(TableContext);
16
+ const tableContext = use(TableContext);
16
17
  const cellRef = useRef(null);
17
18
  const ellipsis = ellipsisProp || tableContext.ellipsis;
18
19
  let fixedLeft = false;
@@ -28,7 +29,7 @@ export function TableCell(props) {
28
29
  fixedRight = true;
29
30
  }
30
31
  }
31
- useEffect(() => {
32
+ useIsomorphicLayoutEffect(() => {
32
33
  if (cellRef.current && cellRef.current.parentElement) {
33
34
  let showShadow = false;
34
35
  if (fixedLeft && tableContext.fixed.includes('left')) {
@@ -46,16 +47,23 @@ export function TableCell(props) {
46
47
  cellRef.current.classList.toggle(`${namespace}-table__cell--fixed-shadow`, showShadow);
47
48
  }
48
49
  });
49
- return createElement(tag, Object.assign(Object.assign(Object.assign({}, restProps), mergeCS(styled('table__cell', `table__cell--${align}`, {
50
+ const nodeProps = Object.assign(Object.assign(Object.assign({}, restProps), mergeCS(styled('table__cell', `table__cell--${align}`, {
50
51
  'table__cell--fixed-left': fixedLeft,
51
52
  'table__cell--fixed-right': fixedRight,
52
53
  'table__cell--ellipsis': ellipsis,
53
54
  }), {
54
55
  className: restProps.className,
55
56
  style: Object.assign(Object.assign(Object.assign({}, restProps.style), fixedStyle), { width: isUndefined(width) ? undefined : width }),
56
- })), { ref: cellRef }), _jsx("div", Object.assign({}, mergeCS(styled('table__cell-content'), {
57
+ })), { ref: (instance) => {
58
+ cellRef.current = instance;
59
+ return () => {
60
+ cellRef.current = null;
61
+ };
62
+ } });
63
+ const child = (_jsx("div", Object.assign({}, mergeCS(styled('table__cell-content'), {
57
64
  style: {
58
65
  width: isUndefined(width) ? undefined : `calc(${width}${isNumber(width) ? 'px' : ''} - var(--padding-size) * 2)`,
59
66
  },
60
67
  }), { children: children })));
68
+ return tag === 'th' ? _jsx("th", Object.assign({}, nodeProps, { children: child })) : _jsx("td", Object.assign({}, nodeProps, { children: child }));
61
69
  }
package/table/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { CLASSES } from './vars';
3
- import type { BaseProps, CloneHTMLElement, PopupPlacement } from '../types';
3
+ import type { BaseProps, PopupPlacement } from '../types';
4
4
  export {};
5
5
  export interface TableContextData {
6
6
  fixed: ('left' | 'right')[];
@@ -40,7 +40,13 @@ export interface TableTdProps extends BaseProps<'table', typeof CLASSES>, React.
40
40
  ellipsis?: boolean;
41
41
  }
42
42
  export interface TableFilterProps extends BaseProps<'table', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'content'> {
43
- children: React.ReactElement | ((render: CloneHTMLElement) => React.ReactNode);
43
+ children: (props: {
44
+ id: string;
45
+ onClick: React.MouseEventHandler<HTMLElement>;
46
+ onMouseEnter: React.MouseEventHandler<HTMLElement>;
47
+ onMouseLeave: React.MouseEventHandler<HTMLElement>;
48
+ onKeyDown: React.KeyboardEventHandler<HTMLElement>;
49
+ }) => React.ReactNode;
44
50
  content?: React.ReactNode;
45
51
  footer?: React.ReactElement | false;
46
52
  visible?: boolean;
@@ -60,6 +66,7 @@ export interface TableFilterProps extends BaseProps<'table', typeof CLASSES>, Om
60
66
  afterVisibleChange?: (visible: boolean) => void;
61
67
  }
62
68
  export interface TableThActionProps extends BaseProps<'table', typeof CLASSES>, React.HTMLAttributes<HTMLDivElement> {
69
+ ref?: React.Ref<HTMLDivElement>;
63
70
  active?: boolean;
64
71
  disabled?: boolean;
65
72
  }
package/tabs/Tabs.d.ts CHANGED
@@ -1,5 +1,3 @@
1
1
  /// <reference types="react" />
2
- import type { TabsItem, TabsProps, TabsRef } from './types';
3
- declare function TabsFC<ID extends React.Key, T extends TabsItem<ID>>(props: TabsProps<ID, T>, ref: React.ForwardedRef<TabsRef>): JSX.Element | null;
4
- export declare const Tabs: <ID extends React.Key, T extends TabsItem<ID>>(props: TabsProps<ID, T> & React.RefAttributes<TabsRef>) => ReturnType<typeof TabsFC>;
5
- export {};
2
+ import type { TabsItem, TabsProps } from './types';
3
+ export declare function Tabs<ID extends React.Key, T extends TabsItem<ID>>(props: TabsProps<ID, T>): React.ReactElement | null;
package/tabs/Tabs.js CHANGED
@@ -6,15 +6,16 @@ import { checkScrollEnd, findNested } from '@laser-ui/utils';
6
6
  import AddOutlined from '@material-design-icons/svg/outlined/add.svg?react';
7
7
  import CloseOutlined from '@material-design-icons/svg/outlined/close.svg?react';
8
8
  import MoreHorizOutlined from '@material-design-icons/svg/outlined/more_horiz.svg?react';
9
- import { isNull, isUndefined, nth } from 'lodash';
10
- import { forwardRef, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
9
+ import { isUndefined, nth } from 'lodash';
10
+ import { useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
11
11
  import { CLASSES } from './vars';
12
12
  import { Dropdown } from '../dropdown';
13
13
  import { useComponentProps, useControlled, useNamespace, useStyled, useTranslation } from '../hooks';
14
14
  import { Icon } from '../icon';
15
+ import { LazyLoading } from '../internal/lazy-loading';
15
16
  import { mergeCS } from '../utils';
16
- function TabsFC(props, ref) {
17
- const _a = useComponentProps('Tabs', props), { styleOverrides, styleProvider, list, active: activeProp, defaultActive: _defaultActive, pattern, placement = 'top', center = false, size = 'medium', addible = false, lazyLoading = true, onActiveChange, onAddClick, onClose } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "list", "active", "defaultActive", "pattern", "placement", "center", "size", "addible", "lazyLoading", "onActiveChange", "onAddClick", "onClose"]);
17
+ export function Tabs(props) {
18
+ const _a = useComponentProps('Tabs', props), { ref, styleOverrides, styleProvider, list, active: activeProp, defaultActive: _defaultActive, pattern, placement = 'top', center = false, size = 'medium', addible = false, lazyLoading = true, onActiveChange, onAddClick, onClose } = _a, restProps = __rest(_a, ["ref", "styleOverrides", "styleProvider", "list", "active", "defaultActive", "pattern", "placement", "center", "size", "addible", "lazyLoading", "onActiveChange", "onAddClick", "onClose"]);
18
19
  const namespace = useNamespace();
19
20
  const styled = useStyled(CLASSES, { tabs: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.tabs }, styleOverrides);
20
21
  const { t } = useTranslation();
@@ -43,23 +44,10 @@ function TabsFC(props, ref) {
43
44
  return null;
44
45
  }, []);
45
46
  const [active, changeActive] = useControlled(defaultActive, activeProp, (id) => {
46
- panelLoaded.current.add(id);
47
47
  if (onActiveChange) {
48
48
  onActiveChange(id, findNested(list, (item) => item.id === id));
49
49
  }
50
50
  });
51
- const panelLoaded = useRef(new Set(isNull(defaultActive) ? [] : [defaultActive]));
52
- const newPanelLoaded = new Set();
53
- const panels = list.map((item) => {
54
- const { id: itemId, panel: itemPanel } = item;
55
- const hidden = itemId !== active;
56
- const loaded = panelLoaded.current.has(itemId);
57
- if (loaded) {
58
- newPanelLoaded.add(itemId);
59
- }
60
- return (_createElement("div", Object.assign({}, styled('tabs__tabpanel'), { key: itemId, id: getPanelId(itemId), tabIndex: 0, hidden: hidden, role: "tabpanel", "aria-labelledby": getTabId(itemId) }), lazyLoading && hidden && !loaded ? null : itemPanel));
61
- });
62
- panelLoaded.current = newPanelLoaded;
63
51
  const refreshTabs = () => {
64
52
  const tablistWrapperEl = tablistWrapperRef.current;
65
53
  if (tablistWrapperEl) {
@@ -96,7 +84,6 @@ function TabsFC(props, ref) {
96
84
  };
97
85
  useIsomorphicLayoutEffect(() => {
98
86
  refreshTabs();
99
- // eslint-disable-next-line react-hooks/exhaustive-deps
100
87
  }, []);
101
88
  useResize(tablistWrapperRef, refreshTabs);
102
89
  useResize(tablistRef, refreshTabs);
@@ -131,9 +118,24 @@ function TabsFC(props, ref) {
131
118
  }), {
132
119
  className: restProps.className,
133
120
  style: restProps.style,
134
- }), { ref: tabsRef, children: [_jsx("div", Object.assign({}, styled('tabs__tablist-wrapper'), { ref: tablistWrapperRef, onScroll: () => {
121
+ }), { ref: (instance) => {
122
+ tabsRef.current = instance;
123
+ return () => {
124
+ tabsRef.current = null;
125
+ };
126
+ }, children: [_jsx("div", Object.assign({}, styled('tabs__tablist-wrapper'), { ref: (instance) => {
127
+ tablistWrapperRef.current = instance;
128
+ return () => {
129
+ tablistWrapperRef.current = null;
130
+ };
131
+ }, onScroll: () => {
135
132
  refreshTabs();
136
- }, children: _jsxs("div", Object.assign({}, styled('tabs__tablist'), { ref: tablistRef, role: "tablist", "aria-orientation": isHorizontal ? 'horizontal' : 'vertical', children: [list.map((item, index) => {
133
+ }, children: _jsxs("div", Object.assign({}, styled('tabs__tablist'), { ref: (instance) => {
134
+ tablistRef.current = instance;
135
+ return () => {
136
+ tablistRef.current = null;
137
+ };
138
+ }, role: "tablist", "aria-orientation": isHorizontal ? 'horizontal' : 'vertical', children: [list.map((item, index) => {
137
139
  const { id: itemId, title: itemTitle, disabled: itemDisabled, closable: itemClosable } = item;
138
140
  const isActive = itemId === active;
139
141
  const getTab = (next, _index = index) => {
@@ -242,7 +244,12 @@ function TabsFC(props, ref) {
242
244
  e.stopPropagation();
243
245
  closeTab();
244
246
  }, children: _jsx(Icon, { children: _jsx(CloseOutlined, {}) }) })))));
245
- }), (listOverflow || addible) && (_jsxs("div", Object.assign({}, styled('tabs__button-container'), { ref: buttonContainerRef, children: [listOverflow && (_jsx(Dropdown, { list: dropdownList.map((tab) => {
247
+ }), (listOverflow || addible) && (_jsxs("div", Object.assign({}, styled('tabs__button-container'), { ref: (instance) => {
248
+ buttonContainerRef.current = instance;
249
+ return () => {
250
+ buttonContainerRef.current = null;
251
+ };
252
+ }, children: [listOverflow && (_jsx(Dropdown, { list: dropdownList.map((tab) => {
246
253
  const { id: itemId, title: itemTitle, dropdownRender: itemDropdownRender, disabled: itemDisabled } = tab;
247
254
  return {
248
255
  id: itemId,
@@ -253,10 +260,19 @@ function TabsFC(props, ref) {
253
260
  };
254
261
  }), placement: placement === 'left' ? 'bottom-left' : 'bottom-right', onClick: (id) => {
255
262
  changeActive(id);
256
- }, children: _jsx("div", Object.assign({}, styled('tabs__button', 'tabs__button--more', {
263
+ }, children: (dropdownProps) => (_jsx("div", Object.assign({}, styled('tabs__button', 'tabs__button--more', {
257
264
  'tabs__button.is-end': scrollEnd,
258
- }), { "aria-label": t('More'), children: _jsx(Icon, { size: iconSize, children: _jsx(MoreHorizOutlined, {}) }) })) })), addible && (_jsx("div", Object.assign({}, styled('tabs__button', 'tabs__button--add'), { role: "button", "aria-label": t('Add'), onClick: () => {
265
+ }), dropdownProps, { "aria-label": t('More'), children: _jsx(Icon, { size: iconSize, children: _jsx(MoreHorizOutlined, {}) }) }))) })), addible && (_jsx("div", Object.assign({}, styled('tabs__button', 'tabs__button--add'), { role: "button", "aria-label": t('Add'), onClick: () => {
259
266
  onAddClick === null || onAddClick === void 0 ? void 0 : onAddClick();
260
- }, children: _jsx(Icon, { size: iconSize, children: _jsx(AddOutlined, {}) }) })))] }))), _jsx("div", Object.assign({}, styled(pattern === 'wrap' ? 'tabs__wrap-indicator' : pattern === 'slider' ? 'tabs__slider-indicator' : 'tabs__indicator'), { ref: indicatorRef }))] })) })), panels] })));
267
+ }, children: _jsx(Icon, { size: iconSize, children: _jsx(AddOutlined, {}) }) })))] }))), _jsx("div", Object.assign({}, styled(pattern === 'wrap' ? 'tabs__wrap-indicator' : pattern === 'slider' ? 'tabs__slider-indicator' : 'tabs__indicator'), { ref: (instance) => {
268
+ indicatorRef.current = instance;
269
+ return () => {
270
+ indicatorRef.current = null;
271
+ };
272
+ } }))] })) })), list.map((item) => {
273
+ const { id: itemId, panel: itemPanel } = item;
274
+ const hidden = itemId !== active;
275
+ return (_createElement("div", Object.assign({}, styled('tabs__tabpanel'), { key: itemId, id: getPanelId(itemId), tabIndex: 0, hidden: hidden, role: "tabpanel", "aria-labelledby": getTabId(itemId) }),
276
+ _jsx(LazyLoading, { hidden: hidden, disabled: !lazyLoading, children: itemPanel })));
277
+ })] })));
261
278
  }
262
- export const Tabs = forwardRef(TabsFC);
package/tabs/types.d.ts CHANGED
@@ -14,6 +14,7 @@ export interface TabsItem<ID extends React.Key> {
14
14
  disabled?: boolean;
15
15
  }
16
16
  export interface TabsProps<ID extends React.Key, T extends TabsItem<ID>> extends BaseProps<'tabs', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
17
+ ref?: React.Ref<TabsRef>;
17
18
  list: T[];
18
19
  active?: ID;
19
20
  defaultActive?: ID;
package/tag/Tag.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { TagProps } from './types';
3
- export declare function Tag(props: TagProps): JSX.Element | null;
3
+ export declare function Tag(props: TagProps): React.ReactElement | null;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { TextareaProps } from './types';
3
- export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
3
+ export declare function Textarea(props: TextareaProps): React.ReactElement | null;
@@ -1,19 +1,19 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useForkRef } from '@laser-ui/hooks';
3
+ import { useIsomorphicLayoutEffect } from '@laser-ui/hooks';
4
+ import { setRef } from '@laser-ui/utils';
4
5
  import { isFunction, isNumber, isUndefined } from 'lodash';
5
- import { forwardRef, useEffect, useRef } from 'react';
6
+ import { useRef } from 'react';
6
7
  import { CLASSES } from './vars';
7
8
  import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled } from '../hooks';
8
9
  import { mergeCS } from '../utils';
9
- export const Textarea = forwardRef((props, ref) => {
10
- const _a = useComponentProps('Textarea', props), { styleOverrides, styleProvider, formControl, model, defaultModel, autoRows = false, resizable = true, showCount = false, size: sizeProp, onModelChange } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "autoRows", "resizable", "showCount", "size", "onModelChange"]);
10
+ export function Textarea(props) {
11
+ const _a = useComponentProps('Textarea', props), { ref, styleOverrides, styleProvider, formControl, model, defaultModel, autoRows = false, resizable = true, showCount = false, size: sizeProp, onModelChange } = _a, restProps = __rest(_a, ["ref", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "autoRows", "resizable", "showCount", "size", "onModelChange"]);
11
12
  const styled = useStyled(CLASSES, { textarea: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.textarea }, styleOverrides);
12
13
  const textareaRef = useRef(null);
13
- const combineTextareaRef = useForkRef(textareaRef, ref);
14
14
  const [value, changeValue] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : '', model, onModelChange, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
15
15
  const { size, disabled } = useScopedProps({ size: sizeProp, disabled: restProps.disabled || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
16
- useEffect(() => {
16
+ useIsomorphicLayoutEffect(() => {
17
17
  const textareaEl = textareaRef.current;
18
18
  if (textareaEl && autoRows !== false) {
19
19
  const cssText = textareaEl.style.cssText;
@@ -50,7 +50,14 @@ export const Textarea = forwardRef((props, ref) => {
50
50
  return (_jsxs(_Fragment, { children: [_jsx("textarea", Object.assign({}, restProps, mergeCS(styled('textarea', `textarea--${size}`), {
51
51
  className: restProps.className,
52
52
  style: Object.assign(Object.assign({}, restProps.style), { resize: resizable && autoRows === false ? undefined : 'none' }),
53
- }), designProps, { ref: combineTextareaRef, value: value, disabled: disabled, onChange: (e) => {
53
+ }), designProps, { ref: (instance) => {
54
+ const ret = setRef(ref, instance);
55
+ textareaRef.current = instance;
56
+ return () => {
57
+ ret();
58
+ textareaRef.current = null;
59
+ };
60
+ }, value: value, disabled: disabled, onChange: (e) => {
54
61
  var _a;
55
62
  (_a = restProps.onChange) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
56
63
  changeValue(e.currentTarget.value);
@@ -59,4 +66,4 @@ export const Textarea = forwardRef((props, ref) => {
59
66
  : isUndefined(restProps.maxLength)
60
67
  ? value.length
61
68
  : `${value.length} / ${restProps.maxLength}` })))] }));
62
- });
69
+ }
@@ -4,6 +4,7 @@ import type { FormControlProvider } from '../form/types';
4
4
  import type { BaseProps, Size } from '../types';
5
5
  export {};
6
6
  export interface TextareaProps extends BaseProps<'textarea', typeof CLASSES>, React.TextareaHTMLAttributes<HTMLTextAreaElement> {
7
+ ref?: React.Ref<HTMLTextAreaElement>;
7
8
  formControl?: FormControlProvider;
8
9
  model?: string;
9
10
  defaultModel?: string;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import type { TimePickerProps, TimePickerRef } from './types';
3
- export declare const TimePicker: import("react").ForwardRefExoticComponent<TimePickerProps & import("react").RefAttributes<TimePickerRef>>;
2
+ import type { TimePickerProps } from './types';
3
+ export declare function TimePicker(props: TimePickerProps): React.ReactElement | null;
@@ -1,30 +1,30 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useAsync, useEventCallback, useForceUpdate, useForkRef, useImmer, useResize } from '@laser-ui/hooks';
3
+ import { useAsync, useEventCallback, useForceUpdate, useImmer, useIsomorphicLayoutEffect, useResize } from '@laser-ui/hooks';
4
+ import { setRef } from '@laser-ui/utils';
4
5
  import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
5
6
  import AccessTimeOutlined from '@material-design-icons/svg/outlined/access_time.svg?react';
6
7
  import SwapHorizOutlined from '@material-design-icons/svg/outlined/swap_horiz.svg?react';
7
8
  import { isNull, isUndefined } from 'lodash';
8
- import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
9
+ import { useEffect, useImperativeHandle, useRef } from 'react';
9
10
  import { TimePickerPanel } from './internal/TimePickerPanel';
10
11
  import { deepCompareDate, orderTime } from './utils';
11
12
  import { CLASSES } from './vars';
12
13
  import { BaseInput } from '../base-input';
13
14
  import { Button } from '../button';
14
15
  import dayjs from '../dayjs';
15
- import { useComponentProps, useContainerScrolling, useControlled, useDesign, useJSS, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
16
+ import { useComponentProps, useContainerScrolling, useControlled, useDesign, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
16
17
  import { Icon } from '../icon';
17
18
  import { Portal } from '../internal/portal';
18
- import { Transition } from '../internal/transition';
19
19
  import { ROOT_DATA } from '../root/vars';
20
+ import { Transition } from '../transition';
20
21
  import { getVerticalSidePosition, mergeCS } from '../utils';
21
22
  import { TTANSITION_DURING_POPUP, WINDOW_SPACE } from '../vars';
22
- export const TimePicker = forwardRef((props, ref) => {
23
+ export function TimePicker(props) {
23
24
  var _a, _b;
24
- const _c = useComponentProps('TimePicker', props), { styleOverrides, styleProvider, formControl, model, defaultModel, visible: visibleProp, defaultVisible, placeholder, range = false, format = 'HH:mm:ss', order: orderProp = 'ascend', clearable: clearableProp = false, size: sizeProp, disabled: disabledProp = false, config, escClosable = true, inputRef, inputRender, onModelChange, onVisibleChange, onClear, afterVisibleChange } = _c, restProps = __rest(_c, ["styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "visible", "defaultVisible", "placeholder", "range", "format", "order", "clearable", "size", "disabled", "config", "escClosable", "inputRef", "inputRender", "onModelChange", "onVisibleChange", "onClear", "afterVisibleChange"]);
25
+ const _c = useComponentProps('TimePicker', props), { ref, styleOverrides, styleProvider, formControl, model, defaultModel, visible: visibleProp, defaultVisible, placeholder, range = false, format = 'HH:mm:ss', order: orderProp = 'ascend', clearable: clearableProp = false, size: sizeProp, disabled: disabledProp = false, config, escClosable = true, inputProps, onModelChange, onVisibleChange, onClear, afterVisibleChange } = _c, restProps = __rest(_c, ["ref", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "visible", "defaultVisible", "placeholder", "range", "format", "order", "clearable", "size", "disabled", "config", "escClosable", "inputProps", "onModelChange", "onVisibleChange", "onClear", "afterVisibleChange"]);
25
26
  const namespace = useNamespace();
26
27
  const styled = useStyled(CLASSES, { 'time-picker': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['time-picker'], 'time-picker-popup': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['time-picker-popup'] }, styleOverrides);
27
- const sheet = useJSS();
28
28
  const { t } = useTranslation();
29
29
  const forceUpdate = useForceUpdate();
30
30
  const async = useAsync();
@@ -34,8 +34,6 @@ export const TimePicker = forwardRef((props, ref) => {
34
34
  const inputLeftRef = useRef(null);
35
35
  const inputRightRef = useRef(null);
36
36
  const indicatorRef = useRef(null);
37
- const combineInputLeftRef = useForkRef(inputLeftRef, inputRef === null || inputRef === void 0 ? void 0 : inputRef[0]);
38
- const combineInputRightRef = useForkRef(inputRightRef, inputRef === null || inputRef === void 0 ? void 0 : inputRef[1]);
39
37
  const panelRef = useRef(null);
40
38
  const dataRef = useRef({
41
39
  latestFocused: 'start',
@@ -106,7 +104,6 @@ export const TimePicker = forwardRef((props, ref) => {
106
104
  const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
107
105
  const maxZIndex = useMaxIndex(visible);
108
106
  const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${maxZIndex})`;
109
- const transformOrigin = useRef();
110
107
  const updatePosition = useEventCallback(() => {
111
108
  if (visible && boxRef.current && popupRef.current) {
112
109
  const height = popupRef.current.offsetHeight;
@@ -116,16 +113,10 @@ export const TimePicker = forwardRef((props, ref) => {
116
113
  placement: 'bottom-left',
117
114
  inWindow: WINDOW_SPACE,
118
115
  });
119
- transformOrigin.current = position.transformOrigin;
120
- if (sheet.classes.position) {
121
- popupRef.current.classList.toggle(sheet.classes.position, false);
122
- }
123
- sheet.replaceRule('position', {
124
- top: position.top,
125
- left: position.left,
126
- maxWidth,
127
- });
128
- popupRef.current.classList.toggle(sheet.classes.position, true);
116
+ popupRef.current.style.setProperty(`--popup-down-transform-origin`, position.transformOrigin);
117
+ popupRef.current.style.top = position.top + 'px';
118
+ popupRef.current.style.left = position.left + 'px';
119
+ popupRef.current.style.maxWidth = maxWidth + 'px';
129
120
  }
130
121
  });
131
122
  useContainerScrolling(boxRef, updatePosition, !visible);
@@ -135,7 +126,7 @@ export const TimePicker = forwardRef((props, ref) => {
135
126
  useImperativeHandle(ref, () => ({
136
127
  updatePosition,
137
128
  }), [updatePosition]);
138
- useEffect(() => {
129
+ useIsomorphicLayoutEffect(() => {
139
130
  if (boxRef.current && indicatorRef.current) {
140
131
  let focus = false;
141
132
  const boxRect = boxRef.current.getBoundingClientRect();
@@ -190,8 +181,16 @@ export const TimePicker = forwardRef((props, ref) => {
190
181
  const inputNode = (isLeft) => {
191
182
  const index = isLeft ? 0 : 1;
192
183
  const value = isLeft ? valueLeft : valueRight;
193
- const render = inputRender === null || inputRender === void 0 ? void 0 : inputRender[index];
194
- const node = (_jsx(BaseInput, Object.assign({}, styled('time-picker__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: isLeft ? combineInputLeftRef : combineInputRightRef, type: "text", autoComplete: "off", value: inputValue[index], size: 10, placeholder: isLeft ? placeholderLeft : placeholderRight, disabled: disabled, onValueChange: (val) => {
184
+ const inputRef = isLeft ? inputLeftRef : inputRightRef;
185
+ return (_jsx(BaseInput, Object.assign({}, inputProps === null || inputProps === void 0 ? void 0 : inputProps[index], styled('time-picker__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: (instance) => {
186
+ var _a;
187
+ inputRef.current = instance;
188
+ const ret = setRef((_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.ref, instance);
189
+ return () => {
190
+ inputRef.current = null;
191
+ ret();
192
+ };
193
+ }, type: "text", autoComplete: "off", value: inputValue[index], size: 10, placeholder: isLeft ? placeholderLeft : placeholderRight, disabled: disabled, onValueChange: (val) => {
195
194
  var _a;
196
195
  forceUpdate();
197
196
  dataRef.current.inputValue[index] = val;
@@ -201,6 +200,8 @@ export const TimePicker = forwardRef((props, ref) => {
201
200
  (_a = panelRef.current) === null || _a === void 0 ? void 0 : _a.call(panelRef, date);
202
201
  }
203
202
  }, onKeyDown: (e) => {
203
+ var _a, _b;
204
+ (_b = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.onKeyDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
204
205
  if (e.code === 'Escape') {
205
206
  if (visible && escClosable) {
206
207
  e.stopPropagation();
@@ -213,24 +214,26 @@ export const TimePicker = forwardRef((props, ref) => {
213
214
  const time = dayjs(inputValue[index], format).toDate();
214
215
  handleEnter(time);
215
216
  }
216
- }, onFocus: () => {
217
- var _a, _b, _c;
218
- (_b = (_a = dataRef.current).clearTid) === null || _b === void 0 ? void 0 : _b.call(_a);
217
+ }, onFocus: (e) => {
218
+ var _a, _b, _c, _d, _e;
219
+ (_b = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, e);
220
+ (_d = (_c = dataRef.current).clearTid) === null || _d === void 0 ? void 0 : _d.call(_c);
219
221
  setFocused((draft) => {
220
222
  draft.fill(false);
221
223
  draft[isLeft ? 0 : 1] = true;
222
224
  });
223
225
  dataRef.current.inputValue = [undefined, undefined];
224
226
  if (visible && range && value) {
225
- (_c = panelRef.current) === null || _c === void 0 ? void 0 : _c.call(panelRef, value);
227
+ (_e = panelRef.current) === null || _e === void 0 ? void 0 : _e.call(panelRef, value);
226
228
  }
227
- }, onBlur: () => {
229
+ }, onBlur: (e) => {
230
+ var _a, _b;
231
+ (_b = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, e);
228
232
  dataRef.current.clearTid = async.setTimeout(() => {
229
233
  setFocused([false, false]);
230
234
  changeVisible(false);
231
235
  }, 20);
232
236
  } })));
233
- return render ? render(node) : node;
234
237
  };
235
238
  const preventBlur = (e) => {
236
239
  if ((document.activeElement === inputLeftRef.current || document.activeElement === inputRightRef.current) &&
@@ -246,7 +249,12 @@ export const TimePicker = forwardRef((props, ref) => {
246
249
  }), {
247
250
  className: restProps.className,
248
251
  style: restProps.style,
249
- }), designProps, { ref: boxRef, onMouseDown: (e) => {
252
+ }), designProps, { ref: (instance) => {
253
+ boxRef.current = instance;
254
+ return () => {
255
+ boxRef.current = null;
256
+ };
257
+ }, onMouseDown: (e) => {
250
258
  var _a;
251
259
  (_a = restProps.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
252
260
  preventBlur(e);
@@ -261,7 +269,12 @@ export const TimePicker = forwardRef((props, ref) => {
261
269
  (_b = inputLeftRef.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
262
270
  }
263
271
  changeVisible(true);
264
- }, children: [inputNode(true), range && (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({}, styled('time-picker__indicator'), { ref: indicatorRef })), _jsx("div", Object.assign({}, styled('time-picker__separator'), { children: _jsx(Icon, { children: _jsx(SwapHorizOutlined, {}) }) })), inputNode(false)] })), clearable && (_jsx("div", Object.assign({}, styled('time-picker__clear'), { role: "button", "aria-label": t('Clear'), onClick: (e) => {
272
+ }, children: [inputNode(true), range && (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({}, styled('time-picker__indicator'), { ref: (instance) => {
273
+ indicatorRef.current = instance;
274
+ return () => {
275
+ indicatorRef.current = null;
276
+ };
277
+ } })), _jsx("div", Object.assign({}, styled('time-picker__separator'), { children: _jsx(Icon, { children: _jsx(SwapHorizOutlined, {}) }) })), inputNode(false)] })), clearable && (_jsx("div", Object.assign({}, styled('time-picker__clear'), { role: "button", "aria-label": t('Clear'), onClick: (e) => {
265
278
  e.stopPropagation();
266
279
  dataRef.current.inputValue = [undefined, undefined];
267
280
  _changeValue(null);
@@ -276,7 +289,23 @@ export const TimePicker = forwardRef((props, ref) => {
276
289
  document.body.appendChild(el);
277
290
  }
278
291
  return el;
279
- }, children: _jsx(Transition, { enter: visible, during: TTANSITION_DURING_POPUP, afterRender: () => {
292
+ }, children: _jsx(Transition, { enter: visible, name: `${namespace}-popup-down`, duration: TTANSITION_DURING_POPUP, onSkipEnter: () => {
293
+ updatePosition();
294
+ const cb = () => {
295
+ var _a;
296
+ const value = focused[0] ? valueLeft : valueRight;
297
+ if (value) {
298
+ (_a = panelRef.current) === null || _a === void 0 ? void 0 : _a.call(panelRef, value);
299
+ }
300
+ };
301
+ if (range) {
302
+ cb();
303
+ }
304
+ else if (!dataRef.current.onceVisible) {
305
+ dataRef.current.onceVisible = true;
306
+ cb();
307
+ }
308
+ }, onBeforeEnter: () => {
280
309
  updatePosition();
281
310
  const cb = () => {
282
311
  var _a;
@@ -292,48 +321,33 @@ export const TimePicker = forwardRef((props, ref) => {
292
321
  dataRef.current.onceVisible = true;
293
322
  cb();
294
323
  }
295
- }, afterEnter: () => {
324
+ }, onAfterEnter: () => {
296
325
  afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
297
- }, afterLeave: () => {
326
+ }, onAfterLeave: () => {
298
327
  afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
299
- }, children: (state) => {
300
- let transitionStyle = {};
301
- switch (state) {
302
- case 'enter':
303
- transitionStyle = { transform: 'scaleY(0.7)', opacity: 0 };
304
- break;
305
- case 'entering':
306
- transitionStyle = {
307
- transition: ['transform', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING_POPUP}ms ease-out`).join(', '),
308
- transformOrigin: transformOrigin.current,
309
- };
310
- break;
311
- case 'leaving':
312
- transitionStyle = {
313
- transform: 'scaleY(0.7)',
314
- opacity: 0,
315
- transition: ['transform', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING_POPUP}ms ease-in`).join(', '),
316
- transformOrigin: transformOrigin.current,
317
- };
318
- break;
319
- case 'leaved':
320
- transitionStyle = { display: 'none' };
321
- break;
322
- default:
323
- break;
324
- }
325
- return (_jsxs("div", Object.assign({}, mergeCS(styled('time-picker-popup'), {
326
- style: Object.assign({ zIndex }, transitionStyle),
327
- }), { ref: popupRef, onMouseDown: (e) => {
328
- preventBlur(e);
329
- }, onMouseUp: (e) => {
330
- preventBlur(e);
331
- }, children: [_jsx(TimePickerPanel, { ref: panelRef, styled: styled, time: dataRef.current.latestFocused === 'start' ? valueLeft : valueRight, format: format, config: config ? (...args) => config(...args, dataRef.current.latestFocused, [valueLeft, valueRight]) : undefined, onTimeChange: (time) => {
332
- changeValue(time);
333
- } }), _jsx("div", Object.assign({}, styled('time-picker__footer'), { children: _jsx(Button, { pattern: "link", onClick: () => {
334
- const now = new Date();
335
- changeValue(now);
336
- handleEnter(now);
337
- }, children: t('TimePicker', 'Now') }) }))] })));
338
- } }) })] }));
339
- });
328
+ }, children: (transitionRef, leaved) => (_jsxs("div", Object.assign({}, mergeCS(styled('time-picker-popup'), {
329
+ style: Object.assign({ zIndex }, (leaved ? { display: 'none' } : undefined)),
330
+ }), { ref: (instance) => {
331
+ popupRef.current = instance;
332
+ transitionRef(instance);
333
+ return () => {
334
+ popupRef.current = null;
335
+ transitionRef(null);
336
+ };
337
+ }, onMouseDown: (e) => {
338
+ preventBlur(e);
339
+ }, onMouseUp: (e) => {
340
+ preventBlur(e);
341
+ }, children: [_jsx(TimePickerPanel, { ref: (instance) => {
342
+ panelRef.current = instance;
343
+ return () => {
344
+ panelRef.current = null;
345
+ };
346
+ }, styled: styled, time: dataRef.current.latestFocused === 'start' ? valueLeft : valueRight, format: format, config: config ? (...args) => config(...args, dataRef.current.latestFocused, [valueLeft, valueRight]) : undefined, onTimeChange: (time) => {
347
+ changeValue(time);
348
+ } }), _jsx("div", Object.assign({}, styled('time-picker__footer'), { children: _jsx(Button, { pattern: "link", onClick: () => {
349
+ const now = new Date();
350
+ changeValue(now);
351
+ handleEnter(now);
352
+ }, children: t('TimePicker', 'Now') }) }))] }))) }) })] }));
353
+ }
@@ -2,6 +2,7 @@
2
2
  import type { Styled } from '../../hooks/useStyled';
3
3
  import type { CLASSES } from '../vars';
4
4
  interface TimePickerPanelProps {
5
+ ref?: React.Ref<(date: Date) => void>;
5
6
  styled: Styled<typeof CLASSES>;
6
7
  time: Date | null;
7
8
  format: string;
@@ -12,5 +13,5 @@ interface TimePickerPanelProps {
12
13
  inDatePicker?: boolean;
13
14
  onTimeChange: (time: Date) => void;
14
15
  }
15
- export declare const TimePickerPanel: import("react").ForwardRefExoticComponent<TimePickerPanelProps & import("react").RefAttributes<(date: Date) => void>>;
16
+ export declare function TimePickerPanel(props: TimePickerPanelProps): React.ReactElement | null;
16
17
  export {};