@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
package/fab/FabButton.js CHANGED
@@ -1,23 +1,50 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { setRef } from '@laser-ui/utils';
3
4
  import AddOutlined from '@material-design-icons/svg/outlined/add.svg?react';
4
- import { forwardRef } from 'react';
5
- import { BUTTON_CLASSES } from './vars';
5
+ import { use } from 'react';
6
+ import { BUTTON_CLASSES, FabBacktopContext, FabContext, FabListContext } from './vars';
7
+ import { CircularProgress } from '../circular-progress';
6
8
  import { useComponentProps, useStyled } from '../hooks';
7
9
  import { Icon } from '../icon';
8
- import { CircularProgress } from '../internal/circular-progress';
9
10
  import { mergeCS } from '../utils';
10
- export const FabButton = forwardRef((props, ref) => {
11
+ export function FabButton(props) {
11
12
  var _a;
12
- const _b = useComponentProps('FabButton', props), { children, styleOverrides, styleProvider, pattern = 'primary', theme = 'primary', loading = false, shape, _expand = false, _action = false } = _b, restProps = __rest(_b, ["children", "styleOverrides", "styleProvider", "pattern", "theme", "loading", "shape", "_expand", "_action"]);
13
+ const _b = useComponentProps('FabButton', props), { ref, children, styleOverrides, styleProvider, pattern = 'primary', theme = 'primary', loading = false, shape } = _b, restProps = __rest(_b, ["ref", "children", "styleOverrides", "styleProvider", "pattern", "theme", "loading", "shape"]);
13
14
  const styled = useStyled(BUTTON_CLASSES, { 'fab-button': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['fab-button'] }, styleOverrides);
15
+ const fabContext = use(FabContext);
16
+ const fabListContext = use(FabListContext);
17
+ const fabBacktopContext = use(FabBacktopContext);
14
18
  return (_jsxs("button", Object.assign({}, restProps, mergeCS(styled('fab-button', `fab-button.t-${theme}`, `fab-button--${pattern}`, {
15
- 'fab-button.is-expand': _expand,
19
+ 'fab-button.is-expand': fabContext && fabContext.expand,
16
20
  'fab-button.is-loading': loading,
17
- 'fab-button--in-actions': _action,
21
+ 'fab-button--in-actions': fabListContext,
18
22
  [`fab-button--${shape}`]: shape,
19
23
  }), {
20
24
  className: restProps.className,
21
- style: restProps.style,
22
- }), { ref: ref, type: (_a = restProps.type) !== null && _a !== void 0 ? _a : 'button', children: [_jsx(Icon, Object.assign({}, styled('fab-button__icon'), { children: _jsx(AddOutlined, {}) })), _jsx("div", Object.assign({}, styled('fab-button__content'), { children: loading ? (_jsx(Icon, { children: _jsx(CircularProgress, {}) })) : (children) }))] })));
23
- });
25
+ style: Object.assign(Object.assign(Object.assign({}, restProps.style), (fabListContext ? { animationDelay: `${fabListContext.index * 33}ms` } : undefined)), (fabBacktopContext && fabBacktopContext.leaved ? { display: 'none' } : undefined)),
26
+ }), { ref: (instance) => {
27
+ const ret = setRef(ref, instance);
28
+ if (fabBacktopContext) {
29
+ fabBacktopContext.ref(instance);
30
+ }
31
+ return () => {
32
+ ret();
33
+ if (fabBacktopContext) {
34
+ fabBacktopContext.ref(null);
35
+ }
36
+ };
37
+ }, type: (_a = restProps.type) !== null && _a !== void 0 ? _a : 'button', onClick: (e) => {
38
+ var _a;
39
+ (_a = restProps.onClick) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
40
+ if (fabContext) {
41
+ fabContext.onClick();
42
+ }
43
+ if (fabListContext) {
44
+ fabListContext.onClick();
45
+ }
46
+ if (fabBacktopContext) {
47
+ fabBacktopContext.onClick();
48
+ }
49
+ }, children: [_jsx(Icon, Object.assign({}, styled('fab-button__icon'), { children: _jsx(AddOutlined, {}) })), _jsx("div", Object.assign({}, styled('fab-button__content'), { children: loading ? (_jsx(Icon, { children: _jsx(CircularProgress, {}) })) : (children) }))] })));
50
+ }
package/fab/types.d.ts CHANGED
@@ -4,16 +4,20 @@ import type { BaseProps } from '../types';
4
4
  import type { RefExtra } from '@laser-ui/hooks/useRefExtra';
5
5
  export {};
6
6
  export interface FabProps extends BaseProps<'fab', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
7
- children: React.ReactElement;
7
+ children?: React.ReactNode;
8
8
  expand?: boolean;
9
9
  defaultExpand?: boolean;
10
10
  list?: {
11
11
  placement: 'top' | 'right' | 'bottom' | 'left';
12
- actions: React.ReactElement[];
12
+ actions: (React.ReactNode | {
13
+ id: React.Key;
14
+ action: React.ReactNode;
15
+ })[];
13
16
  }[];
14
17
  onExpandChange?: (expand: boolean) => void;
15
18
  }
16
19
  export interface FabButtonProps extends BaseProps<'fab-button', typeof BUTTON_CLASSES>, React.ButtonHTMLAttributes<HTMLButtonElement> {
20
+ ref?: React.Ref<HTMLButtonElement>;
17
21
  pattern?: 'primary' | 'secondary' | 'outline' | 'dashed' | 'text' | 'link';
18
22
  theme?: 'primary' | 'success' | 'warning' | 'danger';
19
23
  loading?: boolean;
package/fab/vars.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const CLASSES: {
2
3
  fab: string;
3
4
  fab__actions: string;
@@ -26,3 +27,16 @@ export declare const BUTTON_CLASSES: {
26
27
  'fab-button__icon': string;
27
28
  'fab-button__content': string;
28
29
  };
30
+ export declare const FabContext: import("react").Context<{
31
+ expand: boolean;
32
+ onClick: () => void;
33
+ } | undefined>;
34
+ export declare const FabListContext: import("react").Context<{
35
+ index: number;
36
+ onClick: () => void;
37
+ } | undefined>;
38
+ export declare const FabBacktopContext: import("react").Context<{
39
+ ref: React.RefCallback<HTMLElement | null>;
40
+ leaved: boolean;
41
+ onClick: () => void;
42
+ } | undefined>;
package/fab/vars.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createContext } from 'react';
1
2
  export const CLASSES = {
2
3
  fab: '^fab',
3
4
  fab__actions: '^fab__actions',
@@ -26,3 +27,6 @@ export const BUTTON_CLASSES = {
26
27
  'fab-button__icon': '^fab-button__icon',
27
28
  'fab-button__content': '^fab-button__content',
28
29
  };
30
+ export const FabContext = createContext(undefined);
31
+ export const FabListContext = createContext(undefined);
32
+ export const FabBacktopContext = createContext(undefined);
package/form/Form.d.ts CHANGED
@@ -2,6 +2,6 @@
2
2
  import type { FormProps } from './types';
3
3
  import { FormItem } from './FormItem';
4
4
  export declare const Form: {
5
- (props: FormProps): JSX.Element | null;
5
+ (props: FormProps): React.ReactElement | null;
6
6
  Item: typeof FormItem;
7
7
  };
package/form/Form.js CHANGED
@@ -24,7 +24,12 @@ export const Form = (props) => {
24
24
  return (_jsx("form", Object.assign({}, restProps, mergeCS(styled('form', `form--${size}`), {
25
25
  className: restProps.className,
26
26
  style: restProps.style,
27
- }), { ref: formRef, onSubmit: (e) => {
27
+ }), { ref: (instance) => {
28
+ formRef.current = instance;
29
+ return () => {
30
+ formRef.current = null;
31
+ };
32
+ }, onSubmit: (e) => {
28
33
  var _a;
29
34
  (_a = restProps.onSubmit) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
30
35
  e.preventDefault();
@@ -33,7 +38,7 @@ export const Form = (props) => {
33
38
  var _a;
34
39
  (_a = restProps.onReset) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
35
40
  e.preventDefault();
36
- }, children: _jsx(ConfigProvider, { context: { componentSize: size }, children: _jsx(FormContext.Provider, { value: {
41
+ }, children: _jsx(ConfigProvider, { context: { componentSize: size }, children: _jsx(FormContext, { value: {
37
42
  vertical,
38
43
  labelWidth: labelWidth !== null && labelWidth !== void 0 ? labelWidth : (vertical ? undefined : 'auto'),
39
44
  labelWrap: isUndefined(labelWidth) ? false : labelWrap,
@@ -2,4 +2,4 @@
2
2
  import type { FormErrors, FormItemProps } from './types';
3
3
  export declare function FormItem<T extends {
4
4
  [index: string]: FormErrors;
5
- }>(props: FormItemProps<T>): JSX.Element | null;
5
+ }>(props: FormItemProps<T>): React.ReactElement | null;
package/form/FormItem.js CHANGED
@@ -6,13 +6,13 @@ import CheckCircleFilled from '@material-design-icons/svg/filled/check_circle.sv
6
6
  import ErrorFilled from '@material-design-icons/svg/filled/error.svg?react';
7
7
  import HelpOutlineOutlined from '@material-design-icons/svg/outlined/help_outline.svg?react';
8
8
  import { isBoolean, isFunction, isNull, isNumber, isString, isUndefined } from 'lodash';
9
- import { useContext, useEffect, useId, useRef } from 'react';
9
+ import { use, useEffect, useId, useRef } from 'react';
10
10
  import { FormError } from './internal/FormError';
11
11
  import { Validators } from './model/validators';
12
12
  import { CLASSES, FormContext, FormGroupContext } from './vars';
13
- import { useComponentProps, useStyled, useTranslation } from '../hooks';
13
+ import { CircularProgress } from '../circular-progress';
14
+ import { useComponentProps, useNamespace, useStyled, useTranslation } from '../hooks';
14
15
  import { Icon } from '../icon';
15
- import { CircularProgress } from '../internal/circular-progress';
16
16
  import { Tooltip } from '../tooltip';
17
17
  import { mergeCS } from '../utils';
18
18
  const ValidateState = {
@@ -24,11 +24,12 @@ const ValidateState = {
24
24
  };
25
25
  export function FormItem(props) {
26
26
  const _a = useComponentProps('FormItem', props), { children, styleOverrides, styleProvider, formControls, label, labelWidth: labelWidthProp, labelWrap: labelWrapProp, labelExtra: labelExtraProp, labelFor, required: requiredProp } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "formControls", "label", "labelWidth", "labelWrap", "labelExtra", "labelFor", "required"]);
27
+ const namespace = useNamespace();
27
28
  const styled = useStyled(CLASSES, { form: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.form }, styleOverrides);
28
29
  const { t } = useTranslation();
29
30
  const forceUpdate = useForceUpdate();
30
- const formContext = useContext(FormContext);
31
- const formGroupContext = useContext(FormGroupContext);
31
+ const formContext = use(FormContext);
32
+ const formGroupContext = use(FormGroupContext);
32
33
  const divRef = useRef(null);
33
34
  const uniqueId = useId();
34
35
  const getErrorId = (controlName) => `${controlName}-error-${uniqueId}`;
@@ -83,9 +84,8 @@ export function FormItem(props) {
83
84
  }
84
85
  return false;
85
86
  })();
86
- const errorsRef = useRef([]);
87
- const validateState = (() => {
88
- const errors = [];
87
+ const [validateState, currentErrors] = (() => {
88
+ const currentErrors = [];
89
89
  let validateState = ValidateState.Empty;
90
90
  Object.entries(formControls !== null && formControls !== void 0 ? formControls : {}).forEach(([controlName, formErrors]) => {
91
91
  const { control } = formControlProviders[controlName];
@@ -116,11 +116,11 @@ export function FormItem(props) {
116
116
  let hasError = false;
117
117
  if (control.invalid && control.errors) {
118
118
  if (isString(formErrors)) {
119
- errors.push({ key: controlName, controlName, message: formErrors, invalid: 'error' });
119
+ currentErrors.push({ key: controlName, controlName, message: formErrors, invalid: 'error' });
120
120
  hasError = true;
121
121
  }
122
122
  else if (Object.keys(formErrors).length === 2 && 'message' in formErrors && 'invalid' in formErrors) {
123
- errors.push(Object.assign({ key: controlName, controlName }, formErrors));
123
+ currentErrors.push(Object.assign({ key: controlName, controlName }, formErrors));
124
124
  if (formErrors.invalid === 'error') {
125
125
  hasError = true;
126
126
  }
@@ -129,11 +129,11 @@ export function FormItem(props) {
129
129
  for (const key of Object.keys(control.errors)) {
130
130
  if (key in formErrors) {
131
131
  if (isString(formErrors[key])) {
132
- errors.push({ key: `${controlName}-${key}`, controlName, message: formErrors[key], invalid: 'error' });
132
+ currentErrors.push({ key: `${controlName}-${key}`, controlName, message: formErrors[key], invalid: 'error' });
133
133
  hasError = true;
134
134
  }
135
135
  else {
136
- errors.push(Object.assign({ key: `${controlName}-${key}`, controlName }, formErrors[key]));
136
+ currentErrors.push(Object.assign({ key: `${controlName}-${key}`, controlName }, formErrors[key]));
137
137
  if (formErrors[key].invalid === 'error') {
138
138
  hasError = true;
139
139
  }
@@ -152,27 +152,35 @@ export function FormItem(props) {
152
152
  }
153
153
  }
154
154
  });
155
+ return [validateState, currentErrors];
156
+ })();
157
+ const errorsSaved = useRef(currentErrors);
158
+ {
155
159
  const newErrors = [];
156
- errorsRef.current.forEach((err) => {
157
- const index = errors.findIndex((e) => e.key === err.key);
160
+ errorsSaved.current.forEach((err) => {
161
+ const index = currentErrors.findIndex((e) => e.key === err.key);
158
162
  newErrors.push(Object.assign(err, { hidden: index === -1 }));
159
163
  if (index !== -1) {
160
- errors.splice(index, 1);
164
+ currentErrors.splice(index, 1);
161
165
  }
162
166
  });
163
- errorsRef.current = newErrors.concat(errors);
164
- return validateState;
165
- })();
167
+ errorsSaved.current = newErrors.concat(currentErrors);
168
+ }
166
169
  const labelExtra = (() => {
167
- var _a;
168
170
  if (labelExtraProp) {
169
- return isString(labelExtraProp) ? (_jsx(Tooltip, { title: labelExtraProp, children: _jsx(Icon, { children: _jsx(HelpOutlineOutlined, {}) }) })) : (_jsx(Tooltip, { title: labelExtraProp.title, children: (_a = labelExtraProp.icon) !== null && _a !== void 0 ? _a : (_jsx(Icon, { children: _jsx(HelpOutlineOutlined, {}) })) }));
171
+ const { title, icon } = isString(labelExtraProp) ? { title: labelExtraProp, icon: undefined } : labelExtraProp;
172
+ return (_jsx(Tooltip, { title: title, children: (tooltipProps) => (_jsx("div", Object.assign({}, tooltipProps, { children: icon !== null && icon !== void 0 ? icon : (_jsx(Icon, { children: _jsx(HelpOutlineOutlined, {}) })) }))) }));
170
173
  }
171
174
  })();
172
175
  return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('form__item'), {
173
176
  className: restProps.className,
174
177
  style: restProps.style,
175
- }), { ref: divRef, children: _jsxs("div", Object.assign({}, styled('form__item-container'), { children: [labelWidth !== 0 && (_jsx("div", Object.assign({}, mergeCS(styled('form__item-label-wrapper'), {
178
+ }), { ref: (instance) => {
179
+ divRef.current = instance;
180
+ return () => {
181
+ divRef.current = null;
182
+ };
183
+ }, children: _jsxs("div", Object.assign({}, styled('form__item-container'), { children: [labelWidth !== 0 && (_jsx("div", Object.assign({}, mergeCS(styled('form__item-label-wrapper'), {
176
184
  style: { width: formContext.vertical ? undefined : labelWidth === 'auto' ? 'var(--label-width)' : labelWidth },
177
185
  }), { children: label && (_jsxs("label", Object.assign({}, styled('form__item-label', {
178
186
  'form__item-label--wrap': labelWrap,
@@ -188,7 +196,7 @@ export function FormItem(props) {
188
196
  },
189
197
  }), { children: [_jsx("div", Object.assign({}, styled('form__item-control'), { children: isFunction(children) ? children(formControlProviders) : children })), _jsx("div", Object.assign({}, styled('form__error-container'), { children: (() => {
190
198
  const errorsMap = new Map();
191
- errorsRef.current.forEach((err) => {
199
+ errorsSaved.current.forEach((err) => {
192
200
  if (errorsMap.has(err.controlName)) {
193
201
  errorsMap.get(err.controlName).push(err);
194
202
  }
@@ -200,8 +208,11 @@ export function FormItem(props) {
200
208
  for (const [controlName, errors] of errorsMap) {
201
209
  const id = getErrorId(controlName);
202
210
  formControlProviders[controlName].inputAria['aria-describedby'] = id;
203
- nodes.push(_jsx("div", { id: id, children: errors.map((error) => (_jsx(FormError, { styled: styled, visible: !error.hidden, message: error.message, invalid: error.invalid, afterLeave: () => {
204
- errorsRef.current = errorsRef.current.filter((err) => err.key !== error.key);
211
+ nodes.push(_jsx("div", { id: id, children: errors.map((error) => (_jsx(FormError, { namespace: namespace, styled: styled, visible: !error.hidden, message: error.message, invalid: error.invalid, onAfterLeave: () => {
212
+ const index = errorsSaved.current.findIndex((e) => e.key === error.key);
213
+ if (index !== -1) {
214
+ errorsSaved.current.splice(index, 1);
215
+ }
205
216
  } }, error.key))) }, controlName));
206
217
  }
207
218
  return nodes;
@@ -2,11 +2,12 @@
2
2
  import type { Styled } from '../../hooks/useStyled';
3
3
  import type { CLASSES } from '../vars';
4
4
  interface FormErrorProps {
5
+ namespace: string;
5
6
  styled: Styled<typeof CLASSES>;
6
7
  visible: boolean;
7
8
  message: string;
8
9
  invalid: 'warning' | 'error';
9
- afterLeave: () => void;
10
+ onAfterLeave: () => void;
10
11
  }
11
- export declare function FormError(props: FormErrorProps): JSX.Element | null;
12
+ export declare function FormError(props: FormErrorProps): React.ReactElement | null;
12
13
  export {};
@@ -1,24 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { CollapseTransition } from '../../internal/transition';
2
+ import { CollapseTransition } from '../../transition';
3
3
  import { mergeCS } from '../../utils';
4
4
  import { TTANSITION_DURING_FAST } from '../../vars';
5
5
  export function FormError(props) {
6
- const { styled, visible, message, invalid, afterLeave } = props;
7
- return (_jsx(CollapseTransition, { originalSize: {
8
- height: 'auto',
9
- }, collapsedSize: {
10
- height: 0,
11
- }, enter: visible, during: TTANSITION_DURING_FAST, styles: {
12
- enter: { opacity: 0 },
13
- entering: {
14
- transition: ['height', 'padding', 'margin', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING_FAST}ms linear`).join(', '),
15
- },
16
- leaving: {
17
- opacity: 0,
18
- transition: ['height', 'padding', 'margin', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING_FAST}ms linear`).join(', '),
19
- },
20
- leaved: { display: 'none' },
21
- }, skipFirstTransition: false, afterLeave: afterLeave, children: (ref, collapseStyle) => (_jsx("div", Object.assign({}, mergeCS(styled('form__error', `form__error--${invalid}`), {
22
- style: collapseStyle,
23
- }), { ref: ref, title: message, children: message }))) }));
6
+ const { namespace, styled, visible, message, invalid, onAfterLeave } = props;
7
+ return (_jsx(CollapseTransition, { height: 0, enter: visible, name: `${namespace}-form-error`, duration: TTANSITION_DURING_FAST, skipFirstTransition: false, onAfterLeave: onAfterLeave, children: (transitionRef, leaved) => (_jsx("div", Object.assign({}, mergeCS(styled('form__error', `form__error--${invalid}`), {
8
+ style: Object.assign({}, (leaved ? { display: 'none' } : undefined)),
9
+ }), { ref: (instance) => {
10
+ transitionRef(instance);
11
+ return () => {
12
+ transitionRef(null);
13
+ };
14
+ }, title: message, children: message }))) }));
24
15
  }
package/hooks/index.d.ts CHANGED
@@ -4,13 +4,11 @@ export { useControlled } from './useControlled';
4
4
  export { useDesign } from './useDesign';
5
5
  export { useDialogService } from './useDialogService';
6
6
  export { useFocusVisible } from './useFocusVisible';
7
- export { useJSS } from './useJSS';
8
7
  export { useLayout } from './useLayout';
9
8
  export { useLockScroll } from './useLockScroll';
10
9
  export { useMaxIndex } from './useMaxIndex';
11
10
  export { useNamespace } from './useNamespace';
12
11
  export { useNestedPopup } from './useNestedPopup';
13
- export { useNextTick } from './useNextTick';
14
12
  export { useScopedProps } from './useScopedProps';
15
13
  export { useStyled } from './useStyled';
16
14
  export { useTranslation } from './useTranslation';
package/hooks/index.js CHANGED
@@ -4,13 +4,11 @@ export { useControlled } from './useControlled';
4
4
  export { useDesign } from './useDesign';
5
5
  export { useDialogService } from './useDialogService';
6
6
  export { useFocusVisible } from './useFocusVisible';
7
- export { useJSS } from './useJSS';
8
7
  export { useLayout } from './useLayout';
9
8
  export { useLockScroll } from './useLockScroll';
10
9
  export { useMaxIndex } from './useMaxIndex';
11
10
  export { useNamespace } from './useNamespace';
12
11
  export { useNestedPopup } from './useNestedPopup';
13
- export { useNextTick } from './useNextTick';
14
12
  export { useScopedProps } from './useScopedProps';
15
13
  export { useStyled } from './useStyled';
16
14
  export { useTranslation } from './useTranslation';
@@ -1,9 +1,9 @@
1
1
  import { isUndefined } from 'lodash';
2
- import { useContext } from 'react';
2
+ import { use } from 'react';
3
3
  import { LContext } from '../context';
4
4
  export function useComponentProps(component, props) {
5
5
  var _a;
6
- const context = useContext(LContext);
6
+ const context = use(LContext);
7
7
  const defaultProps = (_a = context.componentDefaultProps[component]) !== null && _a !== void 0 ? _a : {};
8
8
  const definedProps = {};
9
9
  Object.keys(props).forEach((key) => {
@@ -1,2 +1,9 @@
1
- import type { CloneHTMLElement } from '../types';
2
- export declare function useFocusVisible(isValidCode: (code: string) => boolean): [boolean, CloneHTMLElement];
1
+ /// <reference types="react" />
2
+ export declare function useFocusVisible(isValidCode: (code: string) => boolean): [
3
+ boolean,
4
+ {
5
+ onFocus: React.FocusEventHandler<HTMLElement>;
6
+ onBlur: React.FocusEventHandler<HTMLElement>;
7
+ onKeyDown: React.KeyboardEventHandler<HTMLElement>;
8
+ }
9
+ ];
@@ -1,5 +1,5 @@
1
1
  import { useAsync, useEvent, useRefExtra } from '@laser-ui/hooks';
2
- import { cloneElement, useRef, useState } from 'react';
2
+ import { useRef, useState } from 'react';
3
3
  export function useFocusVisible(isValidCode) {
4
4
  const windowRef = useRefExtra(() => window);
5
5
  const async = useAsync();
@@ -13,26 +13,20 @@ export function useFocusVisible(isValidCode) {
13
13
  });
14
14
  return [
15
15
  focusVisible,
16
- (el) => cloneElement(el, {
17
- onFocus: (e) => {
18
- var _a, _b;
19
- (_b = (_a = el.props).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, e);
16
+ {
17
+ onFocus: () => {
20
18
  if (hadKeyboardEvent.current) {
21
19
  setFocusVisible(true);
22
20
  }
23
21
  },
24
- onBlur: (e) => {
25
- var _a, _b;
26
- (_b = (_a = el.props).onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, e);
22
+ onBlur: () => {
27
23
  setFocusVisible(false);
28
24
  },
29
25
  onKeyDown: (e) => {
30
- var _a, _b;
31
- (_b = (_a = el.props).onKeyDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
32
26
  if (isValidCode(e.code)) {
33
27
  setFocusVisible(true);
34
28
  }
35
29
  },
36
- }),
30
+ },
37
31
  ];
38
32
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  export declare function useLayout(): {
3
- pageScrollRef: import("react").RefObject<HTMLElement>;
4
- contentResizeRef: import("react").RefObject<HTMLElement>;
3
+ pageScrollRef: import("react").RefObject<HTMLElement | null>;
4
+ contentResizeRef: import("react").RefObject<HTMLElement | null>;
5
5
  };
@@ -1,9 +1,9 @@
1
1
  import { useRefExtra } from '@laser-ui/hooks';
2
- import { useContext } from 'react';
2
+ import { use } from 'react';
3
3
  import { LContext } from '../context';
4
4
  export function useLayout() {
5
5
  var _a, _b;
6
- const context = useContext(LContext);
6
+ const context = use(LContext);
7
7
  const pageScrollRef = useRefExtra((_a = context.layoutPageScrollEl) !== null && _a !== void 0 ? _a : (() => null));
8
8
  const contentResizeRef = useRefExtra((_b = context.layoutContentResizeEl) !== null && _b !== void 0 ? _b : (() => null));
9
9
  return { pageScrollRef, contentResizeRef };
@@ -1,6 +1,6 @@
1
- import { useContext } from 'react';
1
+ import { use } from 'react';
2
2
  import { LContext } from '../context';
3
3
  export function useNamespace() {
4
- const context = useContext(LContext);
4
+ const context = use(LContext);
5
5
  return context.namespace;
6
6
  }
@@ -5,7 +5,7 @@ interface PopupId<ID> {
5
5
  visible: boolean;
6
6
  }
7
7
  export declare function useNestedPopup<ID>(): {
8
- popupIdsRef: import("react").MutableRefObject<PopupId<ID>[]>;
8
+ popupIdsRef: import("react").RefObject<PopupId<ID>[]>;
9
9
  setPopupIds: (value: PopupId<ID>[] | DraftFunction<PopupId<ID>[]>) => void;
10
10
  addPopupId: (id: ID) => void;
11
11
  removePopupId: (id: ID) => void;
@@ -1,7 +1,7 @@
1
- import { useContext } from 'react';
1
+ import { use } from 'react';
2
2
  import { LContext } from '../context';
3
3
  export function useScopedProps(props) {
4
4
  var _a, _b;
5
- const context = useContext(LContext);
5
+ const context = use(LContext);
6
6
  return { size: (_b = (_a = props.size) !== null && _a !== void 0 ? _a : context.componentSize) !== null && _b !== void 0 ? _b : 'medium', disabled: props.disabled || context.componentDisabled };
7
7
  }
@@ -1,8 +1,8 @@
1
1
  import { isString, isUndefined } from 'lodash';
2
- import { useContext, useRef } from 'react';
2
+ import { use, useRef } from 'react';
3
3
  import { LContext } from '../context';
4
4
  export function useStyled(classes, styleProvider, styleOverrides) {
5
- const context = useContext(LContext);
5
+ const context = use(LContext);
6
6
  const classRoot = {};
7
7
  Object.keys(styleProvider).forEach((key) => {
8
8
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -1,8 +1,8 @@
1
1
  import { get } from 'lodash';
2
- import { useContext } from 'react';
2
+ import { use } from 'react';
3
3
  import { RootContext } from '../root/vars';
4
4
  export function useTranslation() {
5
- const context = useContext(RootContext);
5
+ const context = use(RootContext);
6
6
  const lang = context.i18nLang;
7
7
  return {
8
8
  t: (...path) => {
package/icon/Icon.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { IconProps } from './types';
3
- export declare function Icon(props: IconProps): JSX.Element | null;
3
+ export declare function Icon(props: IconProps): React.ReactElement | null;
package/icon/Icon.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { isArray, isNumber, isUndefined } from 'lodash';
4
- import { cloneElement } from 'react';
5
4
  import { CLASSES } from './vars';
6
5
  import { useComponentProps, useNamespace, useStyled } from '../hooks';
7
6
  import { mergeCS } from '../utils';
@@ -14,8 +13,12 @@ export function Icon(props) {
14
13
  return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('icon', { [`icon.t-${theme}`]: theme }), {
15
14
  className: restProps.className,
16
15
  style: restProps.style,
17
- }), { children: cloneElement(children, Object.assign(Object.assign({}, children.props), { style: Object.assign(Object.assign({}, children.props.style), { transform: isUndefined(rotate) ? (_a = children.props.style) === null || _a === void 0 ? void 0 : _a.transform : `rotate(${rotate}deg)`, animation: spin
16
+ }), { children: _jsx("div", { style: {
17
+ width,
18
+ height,
19
+ transform: isUndefined(rotate) ? (_a = children.props.style) === null || _a === void 0 ? void 0 : _a.transform : `rotate(${rotate}deg)`,
20
+ animation: spin
18
21
  ? `${namespace}-spin ${spinSpeed}${isNumber(spinSpeed) ? 's' : ''} linear infinite`
19
- : (_b = children.props.style) === null || _b === void 0 ? void 0 : _b.animation }), fill: 'currentColor', width,
20
- height })) })));
22
+ : (_b = children.props.style) === null || _b === void 0 ? void 0 : _b.animation,
23
+ }, children: children }) })));
21
24
  }
package/image/Image.d.ts CHANGED
@@ -4,7 +4,7 @@ import { ImageAction } from './ImageAction';
4
4
  import { ImageLoader } from './ImageLoader';
5
5
  import { ImagePreview } from './ImagePreview';
6
6
  export declare const Image: {
7
- (props: ImageProps): JSX.Element | null;
7
+ (props: ImageProps): React.ReactElement | null;
8
8
  Loader: typeof ImageLoader;
9
9
  Action: typeof ImageAction;
10
10
  Preview: typeof ImagePreview;
package/image/Image.js CHANGED
@@ -2,7 +2,8 @@ import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useForceUpdate } from '@laser-ui/hooks';
4
4
  import { checkNodeExist } from '@laser-ui/utils';
5
- import { Children, useRef } from 'react';
5
+ import { has } from 'lodash';
6
+ import { Fragment, useRef } from 'react';
6
7
  import { ImageAction } from './ImageAction';
7
8
  import { ImageLoader } from './ImageLoader';
8
9
  import { ImagePreview } from './ImagePreview';
@@ -25,7 +26,10 @@ export const Image = (props) => {
25
26
  return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('image'), {
26
27
  className: restProps.className,
27
28
  style: restProps.style,
28
- }), { children: [dataRef.current.isLoading && checkNodeExist(loading) && loading, dataRef.current.isError && checkNodeExist(error) && error, actions && _jsx("div", Object.assign({}, styled('image__actions'), { children: Children.map(actions, (action) => action) })), _jsx("img", Object.assign({}, imgProps, mergeCS(styled('image__img'), {
29
+ }), { children: [dataRef.current.isLoading && checkNodeExist(loading) && loading, dataRef.current.isError && checkNodeExist(error) && error, actions && (_jsx("div", Object.assign({}, styled('image__actions'), { children: actions.map((node, index) => {
30
+ const { id, action } = (has(node, ['id', 'action']) ? node : { id: index, action: node });
31
+ return _jsx(Fragment, { children: action }, id);
32
+ }) }))), _jsx("img", Object.assign({}, imgProps, mergeCS(styled('image__img'), {
29
33
  className: imgProps === null || imgProps === void 0 ? void 0 : imgProps.className,
30
34
  style: Object.assign(Object.assign({}, imgProps === null || imgProps === void 0 ? void 0 : imgProps.style), { display: (dataRef.current.isLoading && loading) || (dataRef.current.isError && error) ? 'none' : undefined }),
31
35
  }), { onLoadStart: (e) => {
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { ImageActionProps } from './types';
3
- export declare const ImageAction: import("react").ForwardRefExoticComponent<ImageActionProps & import("react").RefAttributes<HTMLButtonElement>>;
3
+ export declare function ImageAction(props: ImageActionProps): React.ReactElement | null;
@@ -1,15 +1,14 @@
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 ImageAction = forwardRef((props, ref) => {
6
+ export function ImageAction(props) {
8
7
  var _a;
9
- const _b = useComponentProps('ImageAction', props), { children, styleOverrides, styleProvider } = _b, restProps = __rest(_b, ["children", "styleOverrides", "styleProvider"]);
8
+ const _b = useComponentProps('ImageAction', props), { ref, children, styleOverrides, styleProvider } = _b, restProps = __rest(_b, ["ref", "children", "styleOverrides", "styleProvider"]);
10
9
  const styled = useStyled(CLASSES, { image: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.image }, styleOverrides);
11
10
  return (_jsx("button", Object.assign({}, restProps, mergeCS(styled('image__action'), {
12
11
  className: restProps.className,
13
12
  style: restProps.style,
14
13
  }), { ref: ref, type: (_a = restProps['type']) !== null && _a !== void 0 ? _a : 'button', children: children })));
15
- });
14
+ }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { ImageLoaderProps } from './types';
3
3
  export declare const ImageLoader: {
4
- (props: ImageLoaderProps): JSX.Element | null;
4
+ (props: ImageLoaderProps): React.ReactElement | null;
5
5
  KEYS: (keyof HTMLImageElement)[];
6
6
  };