@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,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { SkeletonProps } from './types';
3
- export declare function Skeleton(props: SkeletonProps): JSX.Element | null;
3
+ export declare function Skeleton(props: SkeletonProps): React.ReactElement | null;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { SliderProps } from './types';
3
- export declare function Slider(props: SliderProps): JSX.Element | null;
3
+ export declare function Slider(props: SliderProps): React.ReactElement | null;
package/slider/Slider.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { createElement as _createElement } from "react";
4
- import { useEvent, useRefExtra } from '@laser-ui/hooks';
4
+ import { useEvent, useIsomorphicLayoutEffect, useRefExtra } from '@laser-ui/hooks';
5
5
  import { isArray, isNull, isNumber, toNumber } from 'lodash';
6
- import { useEffect, useRef, useState } from 'react';
6
+ import { useRef, useState } from 'react';
7
7
  import { CLASSES } from './vars';
8
8
  import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled } from '../hooks';
9
9
  import { Tooltip } from '../tooltip';
10
10
  import { mergeCS } from '../utils';
11
11
  export function Slider(props) {
12
- const _a = useComponentProps('Slider', props), { styleOverrides, styleProvider, formControl, model, defaultModel, max = 100, min = 0, step = 1, range = false, rangeMinDistance, rangeThumbDraggable = false, tooltip, customTooltip, marks, vertical = false, reverse = false, disabled: disabledProp = false, inputRef, inputRender, onModelChange } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "max", "min", "step", "range", "rangeMinDistance", "rangeThumbDraggable", "tooltip", "customTooltip", "marks", "vertical", "reverse", "disabled", "inputRef", "inputRender", "onModelChange"]);
12
+ const _a = useComponentProps('Slider', props), { styleOverrides, styleProvider, formControl, model, defaultModel, max = 100, min = 0, step = 1, range = false, rangeMinDistance, rangeThumbDraggable = false, tooltip, customTooltip, marks, vertical = false, reverse = false, disabled: disabledProp = false, inputProps, onModelChange } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "max", "min", "step", "range", "rangeMinDistance", "rangeThumbDraggable", "tooltip", "customTooltip", "marks", "vertical", "reverse", "disabled", "inputProps", "onModelChange"]);
13
13
  const styled = useStyled(CLASSES, { slider: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.slider }, styleOverrides);
14
14
  const sliderRef = useRef(null);
15
15
  const dotLeftRef = useRef(null);
@@ -163,7 +163,7 @@ export function Slider(props) {
163
163
  handle(true);
164
164
  }
165
165
  };
166
- useEffect(() => {
166
+ useIsomorphicLayoutEffect(() => {
167
167
  var _a, _b, _c, _d;
168
168
  if (thumbDraggingPoint) {
169
169
  (_a = tooltipLeftRef.current) === null || _a === void 0 ? void 0 : _a.updatePosition();
@@ -238,41 +238,56 @@ export function Slider(props) {
238
238
  return nodes;
239
239
  })();
240
240
  const getDotNode = (isLeft) => {
241
+ const index = isLeft ? 0 : 1;
241
242
  const value = isLeft ? valueLeft : valueRight;
242
- const render = (inputRender !== null && inputRender !== void 0 ? inputRender : [])[isLeft ? 0 : 1];
243
- const inputNode = (_jsx("input", Object.assign({}, styled('slider__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: isLeft ? inputRef === null || inputRef === void 0 ? void 0 : inputRef[0] : inputRef === null || inputRef === void 0 ? void 0 : inputRef[1], type: "range", value: value, max: max, min: min, step: step !== null && step !== void 0 ? step : undefined, disabled: disabled, "aria-orientation": vertical ? 'vertical' : 'horizontal', onChange: (e) => {
244
- const val = toNumber(e.currentTarget.value);
245
- if (range) {
246
- const index = isLeft ? 0 : 1;
247
- changeValue((draft) => {
248
- const offset = val - draft[index];
249
- const isAdd = offset > 0;
250
- draft[index] = val;
251
- if (isNumber(rangeMinDistance) && draft[1] - draft[0] < rangeMinDistance) {
252
- const _index = isLeft ? 1 : 0;
253
- draft[_index] = getValue(draft[_index] + offset, isAdd ? 'ceil' : 'floor');
254
- if (draft[1] - draft[0] < rangeMinDistance) {
255
- draft[index] = getValue(draft[_index] + (isAdd ? -rangeMinDistance : rangeMinDistance), isAdd ? 'floor' : 'ceil');
256
- }
257
- }
258
- });
259
- }
260
- else {
261
- changeValue(val);
262
- }
263
- }, onFocus: () => {
264
- setDotFocused(isLeft ? 'left' : 'right');
265
- }, onBlur: () => {
266
- setDotFocused(null);
267
- } })));
268
- return (_jsx(Tooltip, { ref: isLeft ? tooltipLeftRef : tooltipRightRef, visible: isLeft ? visibleLeft : visibleRight, title: customTooltip ? customTooltip(value) : value, placement: vertical ? 'right' : 'top', onVisibleChange: (visible) => {
243
+ return (_jsx(Tooltip, { ref: (instance) => {
244
+ const tooltipRef = isLeft ? tooltipLeftRef : tooltipRightRef;
245
+ tooltipRef.current = instance;
246
+ return () => {
247
+ tooltipRef.current = null;
248
+ };
249
+ }, visible: isLeft ? visibleLeft : visibleRight, title: customTooltip ? customTooltip(value) : value, placement: vertical ? 'right' : 'top', onVisibleChange: (visible) => {
269
250
  setDotVisible(visible ? (isLeft ? 'left' : 'right') : null);
270
- }, children: _jsx("div", Object.assign({}, mergeCS(styled('slider__input-wrapper'), {
251
+ }, children: (tooltipProps) => (_jsx("div", Object.assign({}, mergeCS(styled('slider__input-wrapper'), {
271
252
  style: {
272
253
  left: vertical ? undefined : `calc(${value} / ${max - min} * 100% - 7px)`,
273
254
  bottom: vertical ? `calc(${value} / ${max - min} * 100% - 7px)` : undefined,
274
255
  },
275
- }), { ref: isLeft ? dotLeftRef : dotRightRef, children: render ? render(inputNode) : inputNode })) }));
256
+ }), { ref: (instance) => {
257
+ const dotRef = isLeft ? dotLeftRef : dotRightRef;
258
+ dotRef.current = instance;
259
+ return () => {
260
+ dotRef.current = null;
261
+ };
262
+ } }, tooltipProps, { children: _jsx("input", Object.assign({}, inputProps === null || inputProps === void 0 ? void 0 : inputProps[index], styled('slider__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { type: "range", value: value, max: max, min: min, step: step !== null && step !== void 0 ? step : undefined, disabled: disabled, "aria-orientation": vertical ? 'vertical' : 'horizontal', onChange: (e) => {
263
+ const val = toNumber(e.currentTarget.value);
264
+ if (range) {
265
+ const index = isLeft ? 0 : 1;
266
+ changeValue((draft) => {
267
+ const offset = val - draft[index];
268
+ const isAdd = offset > 0;
269
+ draft[index] = val;
270
+ if (isNumber(rangeMinDistance) && draft[1] - draft[0] < rangeMinDistance) {
271
+ const _index = isLeft ? 1 : 0;
272
+ draft[_index] = getValue(draft[_index] + offset, isAdd ? 'ceil' : 'floor');
273
+ if (draft[1] - draft[0] < rangeMinDistance) {
274
+ draft[index] = getValue(draft[_index] + (isAdd ? -rangeMinDistance : rangeMinDistance), isAdd ? 'floor' : 'ceil');
275
+ }
276
+ }
277
+ });
278
+ }
279
+ else {
280
+ changeValue(val);
281
+ }
282
+ }, onFocus: (e) => {
283
+ var _a, _b;
284
+ (_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);
285
+ setDotFocused(isLeft ? 'left' : 'right');
286
+ }, onBlur: (e) => {
287
+ var _a, _b;
288
+ (_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);
289
+ setDotFocused(null);
290
+ } })) }))) }));
276
291
  };
277
292
  const preventBlur = (e) => {
278
293
  if (e.button === 0) {
@@ -285,7 +300,12 @@ export function Slider(props) {
285
300
  }), {
286
301
  className: restProps.className,
287
302
  style: restProps.style,
288
- }), designProps, { ref: sliderRef, onMouseDown: (e) => {
303
+ }), designProps, { ref: (instance) => {
304
+ sliderRef.current = instance;
305
+ return () => {
306
+ sliderRef.current = null;
307
+ };
308
+ }, onMouseDown: (e) => {
289
309
  var _a;
290
310
  (_a = restProps.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
291
311
  preventBlur(e);
package/slider/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { CLASSES } from './vars';
3
3
  import type { FormControlProvider } from '../form/types';
4
- import type { BaseProps, CloneHTMLElement } from '../types';
4
+ import type { BaseProps } from '../types';
5
5
  export {};
6
6
  export interface SliderProps extends BaseProps<'slider', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
7
7
  formControl?: FormControlProvider;
@@ -22,7 +22,6 @@ export interface SliderProps extends BaseProps<'slider', typeof CLASSES>, Omit<R
22
22
  vertical?: boolean;
23
23
  reverse?: boolean;
24
24
  disabled?: boolean;
25
- inputRef?: [React.ForwardedRef<HTMLInputElement>?, React.ForwardedRef<HTMLInputElement>?];
26
- inputRender?: [CloneHTMLElement?, CloneHTMLElement?];
25
+ inputProps?: [React.ComponentPropsWithRef<'input'>?, React.ComponentPropsWithRef<'input'>?];
27
26
  onModelChange?: (value: any) => void;
28
27
  }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { SlidesItem, SlidesProps } from './types';
3
- export declare function Slides<ID extends React.Key, T extends SlidesItem<ID>>(props: SlidesProps<ID, T>): JSX.Element | null;
3
+ export declare function Slides<ID extends React.Key, T extends SlidesItem<ID>>(props: SlidesProps<ID, T>): React.ReactElement | null;
package/slides/Slides.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { createElement as _createElement } from "react";
4
- import { useAsync, useEvent, useRefExtra } from '@laser-ui/hooks';
4
+ import { useAsync, useEvent, useIsomorphicLayoutEffect, useRefExtra } from '@laser-ui/hooks';
5
5
  import KeyboardArrowLeftOutlined from '@material-design-icons/svg/outlined/keyboard_arrow_left.svg?react';
6
6
  import KeyboardArrowRightOutlined from '@material-design-icons/svg/outlined/keyboard_arrow_right.svg?react';
7
7
  import { isBoolean, isNumber, isUndefined, nth } from 'lodash';
@@ -151,7 +151,7 @@ export function Slides(props) {
151
151
  setDragDistance(0);
152
152
  setDragOpacity(undefined);
153
153
  };
154
- useEffect(() => {
154
+ useIsomorphicLayoutEffect(() => {
155
155
  if (slidesRef.current) {
156
156
  let size = 0;
157
157
  const slideEls = slidesRef.current.querySelectorAll(`.${namespace}-slides__slide`);
@@ -212,7 +212,12 @@ export function Slides(props) {
212
212
  }), {
213
213
  className: restProps.className,
214
214
  style: restProps.style,
215
- }), { ref: slidesRef, onMouseEnter: (e) => {
215
+ }), { ref: (instance) => {
216
+ slidesRef.current = instance;
217
+ return () => {
218
+ slidesRef.current = null;
219
+ };
220
+ }, onMouseEnter: (e) => {
216
221
  var _a;
217
222
  (_a = restProps.onMouseEnter) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
218
223
  setMouseEnter(true);
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { SpinnerProps } from './types';
3
- export declare function Spinner(props: SpinnerProps): JSX.Element | null;
3
+ export declare function Spinner(props: SpinnerProps): React.ReactElement | null;
@@ -5,30 +5,28 @@ import { checkNodeExist } from '@laser-ui/utils';
5
5
  import { isNumber, isUndefined } from 'lodash';
6
6
  import { useEffect, useRef } from 'react';
7
7
  import { CLASSES } from './vars';
8
- import { useComponentProps, useStyled } from '../hooks';
8
+ import { CircularProgress } from '../circular-progress';
9
+ import { useComponentProps, useNamespace, useStyled } from '../hooks';
9
10
  import { Icon } from '../icon';
10
- import { CircularProgress } from '../internal/circular-progress';
11
- import { Transition } from '../internal/transition';
11
+ import { Transition } from '../transition';
12
12
  import { mergeCS } from '../utils';
13
13
  import { TTANSITION_DURING_BASE } from '../vars';
14
14
  export function Spinner(props) {
15
15
  const _a = useComponentProps('Spinner', props), { children, styleOverrides, styleProvider, visible: visibleProp, text, size = 28, delay, alone = false, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "visible", "text", "size", "delay", "alone", "afterVisibleChange"]);
16
+ const namespace = useNamespace();
16
17
  const styled = useStyled(CLASSES, { spinner: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.spinner }, styleOverrides);
17
18
  const async = useAsync();
18
19
  const forceUpdate = useForceUpdate();
19
20
  const spinnerRef = useRef(null);
20
- const containerRef = useRef(null);
21
- const dataRef = useRef({
22
- delayVisible: false,
23
- });
21
+ const delayVisible = useRef(false);
24
22
  if (visibleProp === false) {
25
- dataRef.current.delayVisible = false;
23
+ delayVisible.current = false;
26
24
  }
27
- const visible = isUndefined(delay) ? visibleProp : dataRef.current.delayVisible;
25
+ const visible = isUndefined(delay) ? visibleProp : delayVisible.current;
28
26
  useEffect(() => {
29
27
  if (isNumber(delay) && visibleProp) {
30
28
  const clearTid = async.setTimeout(() => {
31
- dataRef.current.delayVisible = true;
29
+ delayVisible.current = true;
32
30
  forceUpdate();
33
31
  }, delay);
34
32
  return () => {
@@ -36,31 +34,31 @@ export function Spinner(props) {
36
34
  };
37
35
  }
38
36
  }, [async, delay, forceUpdate, visibleProp]);
39
- const transitionStyles = {
40
- enter: { opacity: 0 },
41
- entering: {
42
- transition: ['opacity'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms linear`).join(', '),
43
- },
44
- leaving: {
45
- opacity: 0,
46
- transition: ['opacity'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms linear`).join(', '),
47
- },
48
- leaved: { display: 'none' },
49
- };
50
- return (_jsx(Transition, { enter: visible, during: TTANSITION_DURING_BASE, afterRender: () => {
51
- if (!alone && spinnerRef.current && containerRef.current) {
52
- containerRef.current.style.height = `${spinnerRef.current.offsetHeight}px`;
37
+ return (_jsx(Transition, { enter: visible, name: `${namespace}-fade`, duration: TTANSITION_DURING_BASE, onSkipEnter: () => {
38
+ if (spinnerRef.current) {
39
+ spinnerRef.current.style.setProperty('--spinner-container-height', `${spinnerRef.current.offsetHeight}px`);
53
40
  }
54
- }, destroyWhenLeaved: true, afterEnter: () => {
41
+ }, onBeforeEnter: () => {
42
+ if (spinnerRef.current) {
43
+ spinnerRef.current.style.setProperty('--spinner-container-height', `${spinnerRef.current.offsetHeight}px`);
44
+ }
45
+ }, onAfterEnter: () => {
55
46
  afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
56
- }, afterLeave: () => {
47
+ }, onAfterLeave: () => {
57
48
  afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
58
- }, children: (state) => (_jsx("div", Object.assign({}, restProps, mergeCS(styled('spinner', {
49
+ }, children: (transitionRef, leaved) => (_jsx("div", Object.assign({}, restProps, mergeCS(styled('spinner', {
59
50
  'spinner--alone': alone,
60
51
  }), {
61
52
  className: restProps.className,
62
- style: Object.assign(Object.assign({}, restProps.style), transitionStyles[state]),
63
- }), { ref: spinnerRef, children: _jsxs("div", Object.assign({}, styled('spinner__container'), { ref: containerRef, children: [children !== false && (_jsx("div", Object.assign({}, mergeCS(styled('spinner__icon'), {
53
+ style: Object.assign(Object.assign({}, restProps.style), (leaved ? { display: 'none' } : undefined)),
54
+ }), { ref: (instance) => {
55
+ spinnerRef.current = instance;
56
+ transitionRef(instance);
57
+ return () => {
58
+ spinnerRef.current = null;
59
+ transitionRef(null);
60
+ };
61
+ }, children: _jsxs("div", Object.assign({}, styled('spinner__container'), { children: [children !== false && (_jsx("div", Object.assign({}, mergeCS(styled('spinner__icon'), {
64
62
  style: { fontSize: size },
65
63
  }), { children: checkNodeExist(children) ? (children) : (_jsx(Icon, { children: _jsx(CircularProgress, {}) })) }))), checkNodeExist(text) && _jsx("div", Object.assign({}, styled('spinner__text'), { children: text }))] })) }))) }));
66
64
  }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { StepperItem, StepperProps } from './types';
3
- export declare function Stepper<T extends StepperItem>(props: StepperProps<T>): JSX.Element | null;
3
+ export declare function Stepper<T extends StepperItem>(props: StepperProps<T>): React.ReactElement | null;
@@ -8,8 +8,8 @@ import { isNumber, isUndefined } from 'lodash';
8
8
  import { CLASSES } from './vars';
9
9
  import { useComponentProps, useStyled } from '../hooks';
10
10
  import { Icon } from '../icon';
11
- import { CollapseTransition } from '../internal/transition';
12
11
  import { Progress } from '../progress';
12
+ import { CollapseTransition } from '../transition';
13
13
  import { mergeCS } from '../utils';
14
14
  import { TTANSITION_DURING_BASE } from '../vars';
15
15
  export function Stepper(props) {
@@ -68,20 +68,13 @@ export function Stepper(props) {
68
68
  }), { style: { width: dotSize, height: dotSize } }), { children: [itemDot === false ? null : checkNodeExist(itemDot) ? (itemDot) : itemState === 'error' ? (_jsx(Icon, { children: _jsx(CloseOutlined, {}) })) : isCompleted ? (_jsx(Icon, { children: _jsx(CheckOutlined, {}) })) : (itemStep), isProgress && (_jsx("div", Object.assign({}, styled('stepper__step-progress'), { children: _jsx(Progress, { percent: percent, pattern: "circle", state: "process", label: false, size: dotSize + 8, lineWidth: 4 }) })))] })), !labelBottom && titleNode, !vertical && separatoreNode] })),
69
69
  labelBottom && titleNode,
70
70
  vertical && separatoreNode,
71
- checkNodeExist(itemDescription) && (_jsx(CollapseTransition, { originalSize: {
72
- height: 'auto',
73
- }, collapsedSize: {
74
- height: 0,
75
- }, enter: !vertical || isActive, during: TTANSITION_DURING_BASE, styles: {
76
- entering: {
77
- transition: ['height', 'padding', 'margin'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms ease-out`).join(', '),
78
- },
79
- leaving: {
80
- transition: ['height', 'padding', 'margin'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms ease-in`).join(', '),
81
- },
82
- leaved: { display: 'none' },
83
- }, children: (descriptionRef, collapseStyle) => (_jsx("div", Object.assign({}, mergeCS(styled('stepper__step-description'), {
84
- style: Object.assign({ marginLeft: labelBottom ? undefined : `calc(${dotSize}px + 8px)` }, collapseStyle),
85
- }), { ref: descriptionRef, children: itemDescription }))) }))));
71
+ checkNodeExist(itemDescription) && (_jsx(CollapseTransition, { height: 0, enter: !vertical || isActive, duration: TTANSITION_DURING_BASE, children: (transitionRef, leaved) => (_jsx("div", { ref: (instance) => {
72
+ transitionRef(instance);
73
+ return () => {
74
+ transitionRef(null);
75
+ };
76
+ }, style: { display: leaved ? 'none' : undefined }, children: _jsx("div", Object.assign({}, mergeCS(styled('stepper__step-description'), {
77
+ style: { marginLeft: labelBottom ? undefined : `calc(${dotSize}px + 8px)` },
78
+ }), { children: itemDescription })) })) }))));
86
79
  }) })));
87
80
  }
package/switch/Switch.js CHANGED
@@ -2,34 +2,18 @@ import { __rest } from "tslib";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { checkNodeExist } from '@laser-ui/utils';
4
4
  import { CLASSES, TTANSITION_DURING } from './vars';
5
- import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled } from '../hooks';
5
+ import { CircularProgress } from '../circular-progress';
6
+ import { useComponentProps, useControlled, useDesign, useNamespace, useScopedProps, useStyled } from '../hooks';
6
7
  import { Icon } from '../icon';
7
- import { CircularProgress } from '../internal/circular-progress';
8
- import { Transition } from '../internal/transition';
8
+ import { Transition } from '../transition';
9
9
  import { mergeCS } from '../utils';
10
10
  export function Switch(props) {
11
- const _a = useComponentProps('Switch', props), { children, styleOverrides, styleProvider, formControl, model, defaultModel, stateContent, labelPlacement = 'right', size: sizeProp, loading = false, disabled: disabledProp = false, inputRef, inputRender, onModelChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "stateContent", "labelPlacement", "size", "loading", "disabled", "inputRef", "inputRender", "onModelChange"]);
11
+ const _a = useComponentProps('Switch', props), { children, styleOverrides, styleProvider, formControl, model, defaultModel, stateContent, labelPlacement = 'right', size: sizeProp, loading = false, disabled: disabledProp = false, inputProps, onModelChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "stateContent", "labelPlacement", "size", "loading", "disabled", "inputProps", "onModelChange"]);
12
+ const namespace = useNamespace();
12
13
  const styled = useStyled(CLASSES, { switch: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.switch }, styleOverrides);
13
14
  const [checked, changeChecked] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : false, model, onModelChange, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
14
15
  const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
15
16
  const designProps = useDesign({ compose: { active: checked, disabled } });
16
- const transitionStyles = {
17
- enter: { left: 2 },
18
- entering: {
19
- left: 'calc(100% - 20px)',
20
- transition: ['width', 'padding', 'margin', 'left'].map((attr) => `${attr} ${TTANSITION_DURING}ms linear`).join(', '),
21
- },
22
- entered: { right: 2 },
23
- leave: { right: 2 },
24
- leaving: {
25
- right: 'calc(100% - 20px)',
26
- transition: ['width', 'padding', 'margin', 'right'].map((attr) => `${attr} ${TTANSITION_DURING}ms linear`).join(', '),
27
- },
28
- leaved: { left: 2 },
29
- };
30
- const inputNode = (_jsx("input", Object.assign({}, styled('switch__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: inputRef, type: "checkbox", disabled: disabled, role: "switch", "aria-checked": checked, onChange: () => {
31
- changeChecked((draft) => !draft);
32
- } })));
33
17
  return (_jsxs("label", Object.assign({}, restProps, mergeCS(styled('switch', `switch--${size}`, {
34
18
  'switch--label-left': labelPlacement === 'left',
35
19
  'switch.is-checked': checked,
@@ -42,7 +26,32 @@ export function Switch(props) {
42
26
  style: { opacity: checked ? 1 : 0 },
43
27
  }), { children: stateContent[0] }))), checkNodeExist(stateContent[1]) && (_jsx("div", Object.assign({}, mergeCS(styled('switch__state-content'), {
44
28
  style: { opacity: checked ? 0 : 1 },
45
- }), { children: stateContent[1] })))] })), inputRender ? inputRender(inputNode) : inputNode, _jsx(Transition, { enter: checked, during: TTANSITION_DURING, children: (state) => (_jsx("div", Object.assign({}, mergeCS(styled('switch__state-dot'), {
46
- style: transitionStyles[state],
47
- }), { children: loading && (_jsx(Icon, { children: _jsx(CircularProgress, {}) })) }))) })] })), checkNodeExist(children) && _jsx("div", Object.assign({}, styled('switch__label'), { children: children }))] })));
29
+ }), { children: stateContent[1] })))] })), _jsx("input", Object.assign({}, inputProps, styled('switch__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { type: "checkbox", disabled: disabled, role: "switch", "aria-checked": checked, onChange: () => {
30
+ changeChecked((draft) => !draft);
31
+ } })), _jsx(Transition, { enter: checked, name: `${namespace}-switch`, duration: TTANSITION_DURING, onSkipEnter: (el) => {
32
+ if (el) {
33
+ el.style.left = '';
34
+ el.style.right = '2px';
35
+ }
36
+ }, onAfterEnter: (el) => {
37
+ if (el) {
38
+ el.style.left = '';
39
+ el.style.right = '2px';
40
+ }
41
+ }, onSkipLeave: (el) => {
42
+ if (el) {
43
+ el.style.left = '2px';
44
+ el.style.right = '';
45
+ }
46
+ }, onAfterLeave: (el) => {
47
+ if (el) {
48
+ el.style.left = '2px';
49
+ el.style.right = '';
50
+ }
51
+ }, children: (transitionRef) => (_jsx("div", Object.assign({}, styled('switch__state-dot'), { ref: (instance) => {
52
+ transitionRef(instance);
53
+ return () => {
54
+ transitionRef(null);
55
+ };
56
+ }, children: loading && (_jsx(Icon, { children: _jsx(CircularProgress, {}) })) }))) })] })), checkNodeExist(children) && _jsx("div", Object.assign({}, styled('switch__label'), { children: children }))] })));
48
57
  }
package/switch/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { CLASSES } from './vars';
3
3
  import type { FormControlProvider } from '../form/types';
4
- import type { BaseProps, CloneHTMLElement, Size } from '../types';
4
+ import type { BaseProps, Size } from '../types';
5
5
  export {};
6
6
  export interface SwitchProps extends BaseProps<'switch', typeof CLASSES>, React.LabelHTMLAttributes<HTMLLabelElement> {
7
7
  formControl?: FormControlProvider;
@@ -12,7 +12,6 @@ export interface SwitchProps extends BaseProps<'switch', typeof CLASSES>, React.
12
12
  size?: Size;
13
13
  loading?: boolean;
14
14
  disabled?: boolean;
15
- inputRef?: React.ForwardedRef<HTMLInputElement>;
16
- inputRender?: CloneHTMLElement;
15
+ inputProps?: React.ComponentPropsWithRef<'input'>;
17
16
  onModelChange?: (checked: boolean) => void;
18
17
  }
package/table/Table.d.ts CHANGED
@@ -7,7 +7,7 @@ import { TableTd } from './TableTd';
7
7
  import { TableTh } from './TableTh';
8
8
  import { TableThAction } from './TableThAction';
9
9
  export declare const Table: {
10
- (props: TableProps): JSX.Element | null;
10
+ (props: TableProps): React.ReactElement | null;
11
11
  Th: typeof TableTh;
12
12
  ThAction: typeof TableThAction;
13
13
  Td: typeof TableTd;
package/table/Table.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useAsync, useMount, useResize } from '@laser-ui/hooks';
3
+ import { useAsync, useIsomorphicLayoutEffect, useResize } from '@laser-ui/hooks';
4
4
  import { isSimpleArrayEqual } from '@laser-ui/utils';
5
5
  import { useMemo, useRef, useState } from 'react';
6
6
  import { TableEmpty } from './TableEmpty';
@@ -17,7 +17,8 @@ export const Table = (props) => {
17
17
  const styled = useStyled(CLASSES, { table: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.table }, styleOverrides);
18
18
  const async = useAsync();
19
19
  const divRef = useRef(null);
20
- const dataRef = useRef({});
20
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
21
+ const clearTid = useRef(() => { });
21
22
  const [fixed, setFixed] = useState([]);
22
23
  const handleFixed = () => {
23
24
  if (divRef.current) {
@@ -41,14 +42,12 @@ export const Table = (props) => {
41
42
  }
42
43
  }
43
44
  };
44
- useMount(() => {
45
+ useIsomorphicLayoutEffect(() => {
45
46
  handleFixed();
46
- });
47
+ }, []);
47
48
  useResize(divRef, () => {
48
- var _a, _b;
49
- (_b = (_a = dataRef.current).clearTid) === null || _b === void 0 ? void 0 : _b.call(_a);
50
- dataRef.current.clearTid = async.setTimeout(() => {
51
- dataRef.current.clearTid = undefined;
49
+ clearTid.current();
50
+ clearTid.current = async.setTimeout(() => {
52
51
  handleFixed();
53
52
  }, 100);
54
53
  });
@@ -58,11 +57,16 @@ export const Table = (props) => {
58
57
  }), {
59
58
  className: restProps.className,
60
59
  style: restProps.style,
61
- }), { ref: divRef, onScroll: (e) => {
60
+ }), { ref: (instance) => {
61
+ divRef.current = instance;
62
+ return () => {
63
+ divRef.current = null;
64
+ };
65
+ }, onScroll: (e) => {
62
66
  var _a;
63
67
  (_a = restProps.onScroll) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
64
68
  handleFixed();
65
- }, children: _jsx(TableContext.Provider, { value: context, children: children }) })));
69
+ }, children: _jsx(TableContext, { value: context, children: children }) })));
66
70
  };
67
71
  Table.Th = TableTh;
68
72
  Table.ThAction = TableThAction;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { TableEmptyProps } from './types';
3
- export declare function TableEmpty(props: TableEmptyProps): JSX.Element | null;
3
+ export declare function TableEmpty(props: TableEmptyProps): React.ReactElement | null;
@@ -1,8 +1,9 @@
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 { checkNodeExist } from '@laser-ui/utils';
4
5
  import { isUndefined } from 'lodash';
5
- import { useEffect, useRef } from 'react';
6
+ import { useRef } from 'react';
6
7
  import { CLASSES } from './vars';
7
8
  import { Empty } from '../empty';
8
9
  import { useComponentProps, useStyled } from '../hooks';
@@ -11,7 +12,7 @@ export function TableEmpty(props) {
11
12
  const _a = useComponentProps('TableEmpty', props), { children, styleOverrides, styleProvider, colSpan } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "colSpan"]);
12
13
  const styled = useStyled(CLASSES, { table: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.table }, styleOverrides);
13
14
  const tdRef = useRef(null);
14
- useEffect(() => {
15
+ useIsomorphicLayoutEffect(() => {
15
16
  var _a, _b;
16
17
  if (isUndefined(colSpan) && tdRef.current) {
17
18
  let tableEl = tdRef.current.parentElement;
@@ -33,5 +34,10 @@ export function TableEmpty(props) {
33
34
  return (_jsx("tr", Object.assign({}, restProps, mergeCS(styled('table__empty'), {
34
35
  className: restProps.className,
35
36
  style: restProps.style,
36
- }), { children: _jsx("td", { ref: tdRef, colSpan: colSpan, children: _jsx("div", Object.assign({}, styled('table__empty-content'), { children: checkNodeExist(children) ? children : _jsx(Empty, { image: Empty.SIMPLE_IMG }) })) }) })));
37
+ }), { children: _jsx("td", { ref: (instance) => {
38
+ tdRef.current = instance;
39
+ return () => {
40
+ tdRef.current = null;
41
+ };
42
+ }, colSpan: colSpan, children: _jsx("div", Object.assign({}, styled('table__empty-content'), { children: checkNodeExist(children) ? children : _jsx(Empty, { image: Empty.SIMPLE_IMG }) })) }) })));
37
43
  }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { TableExpandProps } from './types';
3
- export declare function TableExpand(props: TableExpandProps): JSX.Element | null;
3
+ export declare function TableExpand(props: TableExpandProps): React.ReactElement | null;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { TableFilterProps } from './types';
3
- export declare function TableFilter(props: TableFilterProps): JSX.Element | null;
3
+ export declare function TableFilter(props: TableFilterProps): React.ReactElement | null;
@@ -9,7 +9,7 @@ import { Icon } from '../icon';
9
9
  import { Input } from '../input';
10
10
  import { Popover } from '../popover';
11
11
  export function TableFilter(props) {
12
- const _a = useComponentProps('TableFilter', props), { children, styleOverrides, styleProvider, content, footer, visible, placement = 'bottom-right', placementFixed = false, escClosable = true, gap, inWindow = false, searchable = false, searchValue, modal = false, destroyAfterClose = true, zIndex, onVisibleChange, onSearch, onReset, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "content", "footer", "visible", "placement", "placementFixed", "escClosable", "gap", "inWindow", "searchable", "searchValue", "modal", "destroyAfterClose", "zIndex", "onVisibleChange", "onSearch", "onReset", "afterVisibleChange"]);
12
+ const _a = useComponentProps('TableFilter', props), { children, styleOverrides, styleProvider, content, footer, visible, placement = 'bottom-right', placementFixed = false, escClosable = true, gap, inWindow = false, searchable = false, searchValue, modal = false, destroyAfterClose = false, zIndex, onVisibleChange, onSearch, onReset, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "content", "footer", "visible", "placement", "placementFixed", "escClosable", "gap", "inWindow", "searchable", "searchValue", "modal", "destroyAfterClose", "zIndex", "onVisibleChange", "onSearch", "onReset", "afterVisibleChange"]);
13
13
  const styled = useStyled(CLASSES, { table: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.table }, styleOverrides);
14
14
  const { t } = useTranslation();
15
15
  return (_jsx(Popover, Object.assign({}, restProps, { children: children, content: _jsxs("div", Object.assign({}, styled('table__filter'), { children: [searchable && (_jsx(Input, { style: { display: 'flex' }, model: searchValue, prefix: _jsx(Icon, { children: _jsx(SearchOutlined, {}) }), placeholder: t('Search'), clearable: true, onModelChange: (value) => {
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { TableTdProps } from './types';
3
- export declare function TableTd(props: TableTdProps): JSX.Element | null;
3
+ export declare function TableTd(props: TableTdProps): React.ReactElement | null;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { TableThProps } from './types';
3
- export declare function TableTh(props: TableThProps): JSX.Element | null;
3
+ export declare function TableTh(props: TableThProps): React.ReactElement | null;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { TableThActionProps } from './types';
3
- export declare const TableThAction: import("react").ForwardRefExoticComponent<TableThActionProps & import("react").RefAttributes<HTMLDivElement>>;
3
+ export declare function TableThAction(props: TableThActionProps): 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 TableThAction = forwardRef((props, ref) => {
6
+ export function TableThAction(props) {
8
7
  var _a, _b;
9
- const _c = useComponentProps('TableThAction', props), { styleOverrides, styleProvider, children, active = false, disabled = false } = _c, restProps = __rest(_c, ["styleOverrides", "styleProvider", "children", "active", "disabled"]);
8
+ const _c = useComponentProps('TableThAction', props), { ref, styleOverrides, styleProvider, children, active = false, disabled = false } = _c, restProps = __rest(_c, ["ref", "styleOverrides", "styleProvider", "children", "active", "disabled"]);
10
9
  const styled = useStyled(CLASSES, { table: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.table }, styleOverrides);
11
10
  return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('table__th-action', {
12
11
  'table__th-action.is-active': active,
@@ -15,4 +14,4 @@ export const TableThAction = forwardRef((props, ref) => {
15
14
  className: restProps.className,
16
15
  style: restProps.style,
17
16
  }), { 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 })));
18
- });
17
+ }