@laser-ui/components 1.6.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/accordion/Accordion.d.ts +1 -1
  3. package/accordion/Accordion.js +13 -25
  4. package/accordion/types.d.ts +1 -0
  5. package/affix/Affix.d.ts +2 -2
  6. package/affix/Affix.js +27 -32
  7. package/affix/types.d.ts +7 -2
  8. package/alert/Alert.d.ts +1 -1
  9. package/alert/Alert.js +12 -21
  10. package/anchor/Anchor.d.ts +2 -4
  11. package/anchor/Anchor.js +34 -26
  12. package/anchor/types.d.ts +1 -0
  13. package/avatar/Avatar.d.ts +1 -1
  14. package/avatar/Avatar.js +9 -3
  15. package/badge/Badge.d.ts +1 -1
  16. package/badge/Badge.js +22 -41
  17. package/badge/BadgeText.js +12 -26
  18. package/badge/internal/BadgeNumber.d.ts +2 -2
  19. package/badge/internal/BadgeNumber.js +34 -24
  20. package/base-input/BaseInput.d.ts +1 -2
  21. package/base-input/BaseInput.js +4 -4
  22. package/base-input/types.d.ts +1 -0
  23. package/breadcrumb/Breadcrumb.d.ts +1 -1
  24. package/button/Button.d.ts +1 -2
  25. package/button/Button.js +18 -22
  26. package/button/types.d.ts +1 -0
  27. package/card/Card.d.ts +1 -1
  28. package/card/CardAction.d.ts +1 -1
  29. package/card/CardAction.js +3 -4
  30. package/card/CardActions.d.ts +1 -1
  31. package/card/CardActions.js +7 -3
  32. package/card/CardContent.d.ts +1 -1
  33. package/card/CardHeader.d.ts +1 -1
  34. package/card/types.d.ts +5 -1
  35. package/cascader/Cascader.d.ts +2 -4
  36. package/cascader/Cascader.js +217 -214
  37. package/cascader/internal/CascaderPanel.d.ts +2 -2
  38. package/cascader/internal/CascaderPanel.js +21 -7
  39. package/cascader/internal/CascaderSearchPanel.d.ts +2 -2
  40. package/cascader/internal/CascaderSearchPanel.js +15 -6
  41. package/cascader/types.d.ts +3 -3
  42. package/checkbox/Checkbox.d.ts +1 -1
  43. package/checkbox/Checkbox.js +4 -5
  44. package/checkbox/CheckboxGroup.d.ts +1 -1
  45. package/checkbox/CheckboxGroup.js +8 -7
  46. package/checkbox/types.d.ts +14 -4
  47. package/{internal/circular-progress → circular-progress}/CircularProgress.d.ts +1 -1
  48. package/{internal/circular-progress → circular-progress}/CircularProgress.js +2 -2
  49. package/compose/Compose.d.ts +1 -1
  50. package/compose/ComposeItem.d.ts +1 -1
  51. package/config-provider/ConfigProvider.d.ts +1 -1
  52. package/config-provider/ConfigProvider.js +3 -3
  53. package/date-picker/DatePicker.d.ts +2 -2
  54. package/date-picker/DatePicker.js +116 -98
  55. package/date-picker/internal/DatePickerPanel.d.ts +2 -1
  56. package/date-picker/internal/DatePickerPanel.js +4 -4
  57. package/date-picker/types.d.ts +3 -3
  58. package/dialog-service.d.ts +9 -6
  59. package/dialog-service.js +50 -26
  60. package/drawer/Drawer.d.ts +1 -1
  61. package/drawer/Drawer.js +83 -92
  62. package/drawer/DrawerFooter.d.ts +1 -1
  63. package/drawer/DrawerFooter.js +12 -9
  64. package/drawer/DrawerHeader.d.ts +1 -1
  65. package/drawer/DrawerHeader.js +10 -7
  66. package/drawer/types.d.ts +9 -2
  67. package/drawer/vars.d.ts +5 -1
  68. package/drawer/vars.js +1 -1
  69. package/dropdown/Dropdown.d.ts +2 -4
  70. package/dropdown/Dropdown.js +83 -104
  71. package/dropdown/internal/DropdownGroup.d.ts +1 -1
  72. package/dropdown/internal/DropdownItem.d.ts +1 -1
  73. package/dropdown/internal/DropdownSub.d.ts +2 -1
  74. package/dropdown/internal/DropdownSub.js +26 -49
  75. package/dropdown/types.d.ts +15 -2
  76. package/empty/Empty.d.ts +1 -1
  77. package/fab/Fab.d.ts +1 -1
  78. package/fab/Fab.js +19 -14
  79. package/fab/FabBacktop.d.ts +1 -1
  80. package/fab/FabBacktop.js +24 -31
  81. package/fab/FabButton.d.ts +1 -1
  82. package/fab/FabButton.js +37 -10
  83. package/fab/types.d.ts +6 -2
  84. package/fab/vars.d.ts +14 -0
  85. package/fab/vars.js +4 -0
  86. package/form/Form.d.ts +1 -1
  87. package/form/Form.js +7 -2
  88. package/form/FormItem.d.ts +1 -1
  89. package/form/FormItem.js +35 -24
  90. package/form/internal/FormError.d.ts +3 -2
  91. package/form/internal/FormError.js +10 -19
  92. package/hooks/index.d.ts +0 -2
  93. package/hooks/index.js +0 -2
  94. package/hooks/useComponentProps.js +2 -2
  95. package/hooks/useFocusVisible.d.ts +9 -2
  96. package/hooks/useFocusVisible.js +5 -11
  97. package/hooks/useLayout.d.ts +2 -2
  98. package/hooks/useLayout.js +2 -2
  99. package/hooks/useNamespace.js +2 -2
  100. package/hooks/useNestedPopup.d.ts +1 -1
  101. package/hooks/useScopedProps.js +2 -2
  102. package/hooks/useStyled.js +2 -2
  103. package/hooks/useTranslation.js +2 -2
  104. package/icon/Icon.d.ts +1 -1
  105. package/icon/Icon.js +7 -4
  106. package/image/Image.d.ts +1 -1
  107. package/image/Image.js +6 -2
  108. package/image/ImageAction.d.ts +1 -1
  109. package/image/ImageAction.js +3 -4
  110. package/image/ImageLoader.d.ts +1 -1
  111. package/image/ImagePreview.d.ts +1 -1
  112. package/image/ImagePreview.js +95 -110
  113. package/image/types.d.ts +6 -2
  114. package/input/Input.d.ts +1 -1
  115. package/input/Input.js +12 -8
  116. package/input/InputNumber.js +49 -40
  117. package/input/types.d.ts +3 -5
  118. package/internal/lazy-loading/LazyLoading.d.ts +3 -0
  119. package/internal/lazy-loading/LazyLoading.js +9 -0
  120. package/internal/lazy-loading/index.d.ts +2 -0
  121. package/internal/lazy-loading/index.js +1 -0
  122. package/internal/lazy-loading/types.d.ts +7 -0
  123. package/internal/popup/Popup.d.ts +1 -1
  124. package/internal/popup/Popup.js +40 -68
  125. package/internal/popup/types.d.ts +13 -6
  126. package/internal/portal/Portal.d.ts +1 -1
  127. package/internal/portal/Portal.js +12 -6
  128. package/internal/portal/types.d.ts +3 -2
  129. package/mask/Mask.d.ts +3 -0
  130. package/mask/Mask.js +31 -0
  131. package/menu/Menu.d.ts +2 -4
  132. package/menu/Menu.js +37 -42
  133. package/menu/internal/MenuGroup.d.ts +1 -1
  134. package/menu/internal/MenuItem.d.ts +1 -1
  135. package/menu/internal/MenuItem.js +14 -10
  136. package/menu/internal/MenuSub.d.ts +2 -1
  137. package/menu/internal/MenuSub.js +43 -70
  138. package/menu/types.d.ts +1 -0
  139. package/modal/Modal.d.ts +1 -1
  140. package/modal/Modal.js +77 -80
  141. package/modal/ModalAlert.d.ts +1 -1
  142. package/modal/ModalFooter.d.ts +1 -1
  143. package/modal/ModalFooter.js +12 -9
  144. package/modal/ModalHeader.d.ts +1 -1
  145. package/modal/ModalHeader.js +10 -7
  146. package/modal/types.d.ts +9 -2
  147. package/modal/vars.d.ts +5 -0
  148. package/modal/vars.js +2 -0
  149. package/notification/Notification.d.ts +1 -1
  150. package/notification/Notification.js +44 -71
  151. package/notification/types.d.ts +1 -0
  152. package/package.json +2 -2
  153. package/pagination/Pagination.d.ts +1 -1
  154. package/pagination/Pagination.js +9 -6
  155. package/popover/Popover.d.ts +2 -2
  156. package/popover/Popover.js +82 -118
  157. package/popover/PopoverFooter.d.ts +1 -1
  158. package/popover/PopoverFooter.js +12 -9
  159. package/popover/PopoverHeader.d.ts +1 -1
  160. package/popover/PopoverHeader.js +10 -7
  161. package/popover/types.d.ts +18 -4
  162. package/popover/vars.d.ts +5 -0
  163. package/popover/vars.js +2 -0
  164. package/progress/Progress.d.ts +1 -1
  165. package/radio/Radio.d.ts +1 -1
  166. package/radio/Radio.js +18 -13
  167. package/radio/RadioGroup.d.ts +1 -1
  168. package/radio/RadioGroup.js +12 -7
  169. package/radio/types.d.ts +16 -4
  170. package/radio/vars.d.ts +6 -0
  171. package/radio/vars.js +2 -0
  172. package/rating/Rating.d.ts +1 -1
  173. package/rating/internal/RatingStar.d.ts +1 -1
  174. package/rating/internal/RatingStar.js +23 -21
  175. package/root/Root.d.ts +1 -1
  176. package/root/Root.js +1 -1
  177. package/select/Select.d.ts +2 -4
  178. package/select/Select.js +245 -243
  179. package/select/types.d.ts +3 -3
  180. package/separator/Separator.d.ts +1 -1
  181. package/skeleton/Skeleton.d.ts +1 -1
  182. package/slider/Slider.d.ts +1 -1
  183. package/slider/Slider.js +54 -34
  184. package/slider/types.d.ts +2 -3
  185. package/slides/Slides.d.ts +1 -1
  186. package/slides/Slides.js +8 -3
  187. package/spinner/Spinner.d.ts +1 -1
  188. package/spinner/Spinner.js +27 -29
  189. package/stepper/Stepper.d.ts +1 -1
  190. package/stepper/Stepper.js +9 -16
  191. package/switch/Switch.js +33 -24
  192. package/switch/types.d.ts +2 -3
  193. package/table/Table.d.ts +1 -1
  194. package/table/Table.js +14 -10
  195. package/table/TableEmpty.d.ts +1 -1
  196. package/table/TableEmpty.js +9 -3
  197. package/table/TableExpand.d.ts +1 -1
  198. package/table/TableFilter.d.ts +1 -1
  199. package/table/TableFilter.js +1 -1
  200. package/table/TableTd.d.ts +1 -1
  201. package/table/TableTh.d.ts +1 -1
  202. package/table/TableThAction.d.ts +1 -1
  203. package/table/TableThAction.js +3 -4
  204. package/table/internal/TableCell.d.ts +1 -1
  205. package/table/internal/TableCell.js +13 -5
  206. package/table/types.d.ts +9 -2
  207. package/tabs/Tabs.d.ts +2 -4
  208. package/tabs/Tabs.js +41 -25
  209. package/tabs/types.d.ts +1 -0
  210. package/tag/Tag.d.ts +1 -1
  211. package/textarea/Textarea.d.ts +1 -1
  212. package/textarea/Textarea.js +15 -8
  213. package/textarea/types.d.ts +1 -0
  214. package/time-picker/TimePicker.d.ts +2 -2
  215. package/time-picker/TimePicker.js +89 -75
  216. package/time-picker/internal/TimePickerPanel.d.ts +2 -1
  217. package/time-picker/internal/TimePickerPanel.js +22 -7
  218. package/time-picker/types.d.ts +3 -3
  219. package/timeline/Timeline.d.ts +1 -1
  220. package/toast/Toast.d.ts +1 -1
  221. package/toast/Toast.js +44 -72
  222. package/toast/types.d.ts +1 -0
  223. package/tooltip/Tooltip.d.ts +2 -2
  224. package/tooltip/Tooltip.js +50 -74
  225. package/tooltip/types.d.ts +10 -2
  226. package/transfer/Transfer.d.ts +1 -1
  227. package/transfer/internal/TransferPanel.d.ts +1 -1
  228. package/transfer/internal/TransferPanel.js +7 -2
  229. package/{internal/transition → transition}/CollapseTransition.d.ts +1 -1
  230. package/transition/CollapseTransition.js +65 -0
  231. package/transition/Transition.d.ts +3 -0
  232. package/transition/Transition.js +148 -0
  233. package/transition/types.d.ts +29 -0
  234. package/tree/Tree.d.ts +1 -1
  235. package/tree/Tree.js +19 -7
  236. package/tree/internal/TreePanel.d.ts +2 -2
  237. package/tree/internal/TreePanel.js +32 -26
  238. package/tree-select/TreeSelect.d.ts +2 -4
  239. package/tree-select/TreeSelect.js +216 -213
  240. package/tree-select/internal/TreeSelectSearchPanel.d.ts +2 -2
  241. package/tree-select/internal/TreeSelectSearchPanel.js +15 -6
  242. package/tree-select/types.d.ts +3 -3
  243. package/types.d.ts +1 -1
  244. package/upload/Upload.d.ts +1 -3
  245. package/upload/Upload.js +41 -50
  246. package/upload/UploadAction.d.ts +1 -1
  247. package/upload/UploadAction.js +19 -16
  248. package/upload/UploadButton.d.ts +1 -1
  249. package/upload/UploadButton.js +16 -12
  250. package/upload/UploadList.d.ts +1 -1
  251. package/upload/UploadList.js +52 -47
  252. package/upload/UploadPicture.d.ts +1 -1
  253. package/upload/UploadPicture.js +47 -53
  254. package/upload/UploadPictureList.d.ts +1 -1
  255. package/upload/UploadPictureList.js +52 -47
  256. package/upload/UploadPreviewAction.d.ts +1 -1
  257. package/upload/UploadPreviewAction.js +15 -14
  258. package/upload/hooks.d.ts +2 -0
  259. package/upload/types.d.ts +27 -6
  260. package/upload/vars.d.ts +11 -0
  261. package/upload/vars.js +3 -0
  262. package/virtual-scroll/VirtualScroll.d.ts +2 -4
  263. package/virtual-scroll/VirtualScroll.js +13 -21
  264. package/virtual-scroll/types.d.ts +2 -1
  265. package/wave/Wave.d.ts +3 -0
  266. package/{internal/wave → wave}/Wave.js +6 -6
  267. package/{internal/wave → wave}/types.d.ts +1 -0
  268. package/wave/types.js +1 -0
  269. package/hooks/useJSS.d.ts +0 -1
  270. package/hooks/useJSS.js +0 -15
  271. package/hooks/useNextTick.d.ts +0 -2
  272. package/internal/mask/Mask.d.ts +0 -3
  273. package/internal/mask/Mask.js +0 -36
  274. package/internal/transition/CollapseTransition.js +0 -101
  275. package/internal/transition/Transition.d.ts +0 -3
  276. package/internal/transition/Transition.js +0 -87
  277. package/internal/transition/types.d.ts +0 -33
  278. package/internal/wave/Wave.d.ts +0 -3
  279. /package/{internal/circular-progress → circular-progress}/index.d.ts +0 -0
  280. /package/{internal/circular-progress → circular-progress}/index.js +0 -0
  281. /package/{internal/circular-progress → circular-progress}/vars.d.ts +0 -0
  282. /package/{internal/circular-progress → circular-progress}/vars.js +0 -0
  283. /package/internal/{mask → lazy-loading}/types.js +0 -0
  284. /package/{internal/mask → mask}/index.d.ts +0 -0
  285. /package/{internal/mask → mask}/index.js +0 -0
  286. /package/{internal/mask → mask}/types.d.ts +0 -0
  287. /package/{internal/transition → mask}/types.js +0 -0
  288. /package/{internal/mask → mask}/vars.d.ts +0 -0
  289. /package/{internal/mask → mask}/vars.js +0 -0
  290. /package/{internal/transition → transition}/index.d.ts +0 -0
  291. /package/{internal/transition → transition}/index.js +0 -0
  292. /package/{internal/wave → transition}/types.js +0 -0
  293. /package/{hooks/useNextTick.js → upload/hooks.js} +0 -0
  294. /package/{internal/wave → wave}/index.d.ts +0 -0
  295. /package/{internal/wave → wave}/index.js +0 -0
  296. /package/{internal/wave → wave}/vars.d.ts +0 -0
  297. /package/{internal/wave → wave}/vars.js +0 -0
@@ -1,37 +1,47 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createElement as _createElement } from "react";
3
- import { useEffect, useRef, useState } from 'react';
3
+ import { useAsync, useIsomorphicLayoutEffect } from '@laser-ui/hooks';
4
+ import { useRef, useState } from 'react';
4
5
  export function BadgeNumber(props) {
5
- const { styled, value, valueDown } = props;
6
+ const { styled, value, num } = props;
7
+ const async = useAsync();
6
8
  const containerRef = useRef(null);
7
- const dataRef = useRef({
8
- prevValue: value,
9
- });
9
+ const prevValue = useRef(value);
10
+ const prevNum = useRef(num);
10
11
  const [nums, setNums] = useState([value]);
11
- useEffect(() => {
12
- if (containerRef.current && dataRef.current.prevValue !== value) {
13
- let newNums = Array.from({ length: 10 }).map((_, i) => i);
14
- if (valueDown) {
15
- newNums = newNums.concat(Array.from({ length: dataRef.current.prevValue + 1 }).map((_, i) => i));
16
- newNums = newNums.slice(newNums.length - 10, newNums.length);
12
+ useIsomorphicLayoutEffect(() => {
13
+ if (containerRef.current && num !== prevNum.current) {
14
+ let prevNums = Array.from({ length: 10 }).map((_, i) => i);
15
+ if (num < prevNum.current) {
16
+ prevNums = prevNums.concat(Array.from({ length: prevValue.current + 1 }).map((_, i) => i));
17
+ prevNums = prevNums.slice(prevNums.length - 10, prevNums.length);
17
18
  containerRef.current.style.cssText = 'transform:translateY(-900%);transition:none;';
18
19
  }
19
20
  else {
20
- newNums = Array.from({ length: 10 - dataRef.current.prevValue })
21
- .map((_, i) => dataRef.current.prevValue + i)
22
- .concat(newNums);
23
- newNums = newNums.slice(0, 10);
21
+ prevNums = Array.from({ length: 10 - prevValue.current })
22
+ .map((_, i) => prevValue.current + i)
23
+ .concat(prevNums);
24
+ prevNums = prevNums.slice(0, 10);
24
25
  containerRef.current.style.cssText = 'transform:translateY(0);transition:none;';
25
26
  }
26
- dataRef.current.prevValue = value;
27
- setNums(newNums);
28
- }
29
- }, [value, valueDown]);
30
- useEffect(() => {
31
- if (containerRef.current) {
32
- containerRef.current.style.cssText = `transform:translateY(-${nums.findIndex((n) => n === value) * 100}%); `;
27
+ async.setAfterPainted(() => {
28
+ if (containerRef.current) {
29
+ containerRef.current.style.cssText = `transform:translateY(-${prevNums.findIndex((n) => n === value) * 100}%); `;
30
+ }
31
+ });
32
+ setNums(prevNums);
33
33
  }
34
+ prevValue.current = value;
35
+ prevNum.current = num;
36
+ return () => {
37
+ async.clearAll();
38
+ };
34
39
  // eslint-disable-next-line react-hooks/exhaustive-deps
35
- }, [nums]);
36
- return (_jsx("div", Object.assign({}, styled('badge__number-container'), { ref: containerRef, children: nums.map((n, i) => (_createElement("span", Object.assign({}, styled('badge__number'), { key: i }), n))) })));
40
+ }, [num]);
41
+ return (_jsx("div", Object.assign({}, styled('badge__number-container'), { ref: (instance) => {
42
+ containerRef.current = instance;
43
+ return () => {
44
+ containerRef.current = null;
45
+ };
46
+ }, children: nums.map((n, i) => (_createElement("span", Object.assign({}, styled('badge__number'), { key: i }), n))) })));
37
47
  }
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { BaseInputProps } from './types';
3
- export declare const BaseInput: import("react").ForwardRefExoticComponent<BaseInputProps & import("react").RefAttributes<HTMLInputElement>>;
2
+ export declare function BaseInput(props: BaseInputProps): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,9 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { isString } from 'lodash';
4
- import { forwardRef, useState } from 'react';
5
- export const BaseInput = forwardRef((props, ref) => {
6
- const { value, onValueChange } = props, restProps = __rest(props, ["value", "onValueChange"]);
4
+ import { useState } from 'react';
5
+ export function BaseInput(props) {
6
+ const { ref, value, onValueChange } = props, restProps = __rest(props, ["ref", "value", "onValueChange"]);
7
7
  const [composing, setComposing] = useState();
8
8
  return (_jsx("input", Object.assign({}, restProps, { ref: ref, value: isString(composing) ? composing : value, onCompositionStart: (e) => {
9
9
  var _a;
@@ -24,4 +24,4 @@ export const BaseInput = forwardRef((props, ref) => {
24
24
  onValueChange(e.currentTarget.value);
25
25
  }
26
26
  } })));
27
- });
27
+ }
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export {};
3
3
  export interface BaseInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
+ ref?: React.Ref<HTMLInputElement>;
4
5
  onValueChange: (val: string) => void;
5
6
  }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { BreadcrumbItem, BreadcrumbProps } from './types';
3
- export declare function Breadcrumb<ID extends React.Key, T extends BreadcrumbItem<ID>>(props: BreadcrumbProps<ID, T>): JSX.Element | null;
3
+ export declare function Breadcrumb<ID extends React.Key, T extends BreadcrumbItem<ID>>(props: BreadcrumbProps<ID, T>): React.ReactElement | null;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { ButtonProps } from './types';
3
- export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
2
+ export declare function Button(props: ButtonProps): import("react/jsx-runtime").JSX.Element;
package/button/Button.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { checkNodeExist } from '@laser-ui/utils';
4
- import { forwardRef, useRef } from 'react';
4
+ import { useRef } from 'react';
5
5
  import { CLASSES } from './vars';
6
+ import { CircularProgress } from '../circular-progress';
6
7
  import { useComponentProps, useDesign, useScopedProps, useStyled } from '../hooks';
7
8
  import { Icon } from '../icon';
8
- import { CircularProgress } from '../internal/circular-progress';
9
- import { CollapseTransition } from '../internal/transition';
10
- import { Wave } from '../internal/wave';
9
+ import { CollapseTransition } from '../transition';
11
10
  import { mergeCS } from '../utils';
12
11
  import { TTANSITION_DURING_SLOW } from '../vars';
13
- export const Button = forwardRef((props, ref) => {
12
+ import { Wave } from '../wave';
13
+ export function Button(props) {
14
14
  var _a;
15
- const _b = useComponentProps('Button', props), { children, styleOverrides, styleProvider, pattern = 'primary', theme = 'primary', loading = false, shape, block = false, size: sizeProp, icon, iconRight = false } = _b, restProps = __rest(_b, ["children", "styleOverrides", "styleProvider", "pattern", "theme", "loading", "shape", "block", "size", "icon", "iconRight"]);
15
+ const _b = useComponentProps('Button', props), { ref, children, styleOverrides, styleProvider, pattern = 'primary', theme = 'primary', loading = false, shape, block = false, size: sizeProp, icon, iconRight = false } = _b, restProps = __rest(_b, ["ref", "children", "styleOverrides", "styleProvider", "pattern", "theme", "loading", "shape", "block", "size", "icon", "iconRight"]);
16
16
  const styled = useStyled(CLASSES, { button: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.button }, styleOverrides);
17
17
  const waveRef = useRef(null);
18
18
  const { size, disabled } = useScopedProps({ size: sizeProp, disabled: restProps.disabled || loading });
@@ -32,19 +32,15 @@ export const Button = forwardRef((props, ref) => {
32
32
  if (['primary', 'secondary', 'outline', 'dashed'].includes(pattern)) {
33
33
  (_b = waveRef.current) === null || _b === void 0 ? void 0 : _b.call(waveRef);
34
34
  }
35
- }, children: [_jsx(Wave, { ref: waveRef, color: "var(--color)" }), checkNodeExist(icon) ? (_jsx("div", Object.assign({}, styled('button__icon'), { children: loading ? (_jsx(Icon, { children: _jsx(CircularProgress, {}) })) : (icon) }))) : (_jsx(CollapseTransition, { originalSize: {
36
- width: '',
37
- }, collapsedSize: {
38
- width: 0,
39
- }, enter: loading, during: TTANSITION_DURING_SLOW, styles: {
40
- entering: {
41
- transition: ['width', 'padding', 'margin'].map((attr) => `${attr} ${TTANSITION_DURING_SLOW}ms linear`).join(', '),
42
- },
43
- leaving: {
44
- transition: ['width', 'padding', 'margin'].map((attr) => `${attr} ${TTANSITION_DURING_SLOW}ms linear`).join(', '),
45
- },
46
- leaved: { display: 'none' },
47
- }, destroyWhenLeaved: true, children: (loadingRef, collapseStyle) => (_jsx("div", Object.assign({}, mergeCS(styled('button__icon'), {
48
- style: collapseStyle,
49
- }), { ref: loadingRef, children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) }))) })), _jsx("div", { children: children })] })));
50
- });
35
+ }, children: [_jsx(Wave, { ref: (instance) => {
36
+ waveRef.current = instance;
37
+ return () => {
38
+ waveRef.current = null;
39
+ };
40
+ }, color: "var(--color)" }), checkNodeExist(icon) ? (_jsx("div", Object.assign({}, styled('button__icon'), { children: loading ? (_jsx(Icon, { children: _jsx(CircularProgress, {}) })) : (icon) }))) : (_jsx(CollapseTransition, { enter: loading, duration: TTANSITION_DURING_SLOW, children: (transitionRef, leaved) => leaved ? null : (_jsx("div", { ref: (instance) => {
41
+ transitionRef(instance);
42
+ return () => {
43
+ transitionRef(null);
44
+ };
45
+ }, style: { '--collapse-duration': TTANSITION_DURING_SLOW + 'ms' }, children: _jsx("div", Object.assign({}, styled('button__icon'), { children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) })) })) })), _jsx("div", { children: children })] })));
46
+ }
package/button/types.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { CLASSES } from './vars';
3
3
  import type { BaseProps, Size } from '../types';
4
4
  export {};
5
5
  export interface ButtonProps extends BaseProps<'button', typeof CLASSES>, React.ButtonHTMLAttributes<HTMLButtonElement> {
6
+ ref?: React.Ref<HTMLButtonElement>;
6
7
  pattern?: 'primary' | 'secondary' | 'outline' | 'dashed' | 'text' | 'link';
7
8
  theme?: 'primary' | 'success' | 'warning' | 'danger';
8
9
  loading?: boolean;
package/card/Card.d.ts CHANGED
@@ -5,7 +5,7 @@ import { CardActions } from './CardActions';
5
5
  import { CardContent } from './CardContent';
6
6
  import { CardHeader } from './CardHeader';
7
7
  export declare const Card: {
8
- (props: CardProps): JSX.Element | null;
8
+ (props: CardProps): React.ReactElement | null;
9
9
  Header: typeof CardHeader;
10
10
  Content: typeof CardContent;
11
11
  Actions: typeof CardActions;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { CardActionProps } from './types';
3
- export declare const CardAction: import("react").ForwardRefExoticComponent<CardActionProps & import("react").RefAttributes<HTMLDivElement>>;
3
+ export declare function CardAction(props: CardActionProps): React.ReactElement | null;
@@ -1,12 +1,11 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { forwardRef } from 'react';
4
3
  import { CLASSES } from './vars';
5
4
  import { useComponentProps, useStyled } from '../hooks';
6
5
  import { mergeCS } from '../utils';
7
- export const CardAction = forwardRef((props, ref) => {
6
+ export function CardAction(props) {
8
7
  var _a, _b;
9
- const _c = useComponentProps('CardAction', props), { styleOverrides, styleProvider, children, disabled = false } = _c, restProps = __rest(_c, ["styleOverrides", "styleProvider", "children", "disabled"]);
8
+ const _c = useComponentProps('CardAction', props), { ref, styleOverrides, styleProvider, children, disabled = false } = _c, restProps = __rest(_c, ["ref", "styleOverrides", "styleProvider", "children", "disabled"]);
10
9
  const styled = useStyled(CLASSES, { card: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.card }, styleOverrides);
11
10
  return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('card__action', {
12
11
  'card__action.is-disabled': disabled,
@@ -14,4 +13,4 @@ export const CardAction = forwardRef((props, ref) => {
14
13
  className: restProps.className,
15
14
  style: restProps.style,
16
15
  }), { ref: ref, role: (_a = restProps['role']) !== null && _a !== void 0 ? _a : 'button', tabIndex: (_b = restProps['tabIndex']) !== null && _b !== void 0 ? _b : (disabled ? -1 : 0), children: children })));
17
- });
16
+ }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { CardActionsProps } from './types';
3
- export declare function CardActions(props: CardActionsProps): JSX.Element | null;
3
+ export declare function CardActions(props: CardActionsProps): React.ReactElement | null;
@@ -1,6 +1,7 @@
1
1
  import { __rest } from "tslib";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Children } from 'react';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { has } from 'lodash';
4
+ import { Fragment } from 'react';
4
5
  import { CLASSES } from './vars';
5
6
  import { useComponentProps, useStyled } from '../hooks';
6
7
  import { Separator } from '../separator';
@@ -11,5 +12,8 @@ export function CardActions(props) {
11
12
  return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('card__actions'), {
12
13
  className: restProps.className,
13
14
  style: restProps.style,
14
- }), { children: Children.map(actions, (action, index) => (_jsxs(_Fragment, { children: [action, index !== actions.length - 1 && _jsx(Separator, { style: { margin: 8 }, vertical: true })] }))) })));
15
+ }), { children: actions.map((node, index) => {
16
+ const { id, action } = (has(node, ['id', 'action']) ? node : { id: index, action: node });
17
+ return (_jsxs(Fragment, { children: [action, index !== actions.length - 1 && _jsx(Separator, { style: { margin: 8 }, vertical: true })] }, id));
18
+ }) })));
15
19
  }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { CardContentProps } from './types';
3
- export declare function CardContent(props: CardContentProps): JSX.Element | null;
3
+ export declare function CardContent(props: CardContentProps): React.ReactElement | null;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { CardHeaderProps } from './types';
3
- export declare function CardHeader(props: CardHeaderProps): JSX.Element | null;
3
+ export declare function CardHeader(props: CardHeaderProps): React.ReactElement | null;
package/card/types.d.ts CHANGED
@@ -11,8 +11,12 @@ export interface CardHeaderProps extends BaseProps<'card', typeof CLASSES>, Reac
11
11
  export interface CardContentProps extends BaseProps<'card', typeof CLASSES>, React.HTMLAttributes<HTMLDivElement> {
12
12
  }
13
13
  export interface CardActionsProps extends BaseProps<'card', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
14
- actions: React.ReactNode[];
14
+ actions: (React.ReactNode | {
15
+ id: React.Key;
16
+ action: React.ReactNode;
17
+ })[];
15
18
  }
16
19
  export interface CardActionProps extends BaseProps<'card', typeof CLASSES>, React.HTMLAttributes<HTMLDivElement> {
20
+ ref?: React.Ref<HTMLDivElement>;
17
21
  disabled?: boolean;
18
22
  }
@@ -1,5 +1,3 @@
1
1
  /// <reference types="react" />
2
- import type { CascaderItem, CascaderProps, CascaderRef } from './types';
3
- declare function CascaderFC<V extends React.Key, T extends CascaderItem<V>>(props: CascaderProps<V, T>, ref: React.ForwardedRef<CascaderRef>): JSX.Element | null;
4
- export declare const Cascader: <ID extends React.Key, T extends CascaderItem<ID>>(props: CascaderProps<ID, T> & React.RefAttributes<CascaderRef>) => ReturnType<typeof CascaderFC>;
5
- export {};
2
+ import type { CascaderItem, CascaderProps } from './types';
3
+ export declare function Cascader<V extends React.Key, T extends CascaderItem<V>>(props: CascaderProps<V, T>): React.ReactElement | null;