zavadil-react-common 2.1.12 → 2.1.13

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.
@@ -1,26 +1,39 @@
1
- import {Button} from "react-bootstrap";
2
- import {PropsWithChildren, ReactNode} from "react";
3
- import {ButtonVariant} from "react-bootstrap/types";
4
-
5
- export type IconButtonProps = {
6
- disabled?: boolean;
7
- onClick: () => any;
8
- size?: "sm" | "lg";
9
- icon?: ReactNode;
10
- variant?: ButtonVariant;
11
- };
12
-
13
- export function IconButton({disabled, variant, icon, size, children, onClick}: PropsWithChildren<IconButtonProps>) {
14
- return (
15
- <Button disabled={disabled === true} size={size} onClick={onClick} variant={variant}>
16
- <div className="d-flex align-items-center gap-2">
17
- {icon}
18
- {
19
- children && <div>{children}</div>
20
- }
21
- </div>
22
- </Button>
23
- );
24
- }
25
-
26
- export default IconButton;
1
+ import { Button } from "react-bootstrap";
2
+ import { PropsWithChildren, ReactNode } from "react";
3
+ import { ButtonVariant } from "react-bootstrap/types";
4
+
5
+ export type IconButtonProps = {
6
+ disabled?: boolean;
7
+ onClick?: () => any;
8
+ size?: "sm" | "lg";
9
+ icon?: ReactNode;
10
+ variant?: ButtonVariant;
11
+ type?: "submit" | "reset" | "button" | undefined;
12
+ };
13
+
14
+ export function IconButton({
15
+ disabled,
16
+ variant,
17
+ icon,
18
+ size,
19
+ children,
20
+ type,
21
+ onClick,
22
+ }: PropsWithChildren<IconButtonProps>) {
23
+ return (
24
+ <Button
25
+ disabled={disabled === true}
26
+ size={size}
27
+ onClick={onClick}
28
+ variant={variant}
29
+ type={type}
30
+ >
31
+ <div className="d-flex align-items-center gap-2">
32
+ {icon}
33
+ {children && <div>{children}</div>}
34
+ </div>
35
+ </Button>
36
+ );
37
+ }
38
+
39
+ export default IconButton;
@@ -1,17 +1,43 @@
1
- import {Spinner} from "react-bootstrap";
2
- import {PropsWithChildren} from "react";
3
- import {IconButton, IconButtonProps} from "./IconButton";
4
-
5
- export type ActiveButtonProps = IconButtonProps & {
6
- loading?: boolean;
7
- };
8
-
9
- export function LoadingButton({disabled, icon, loading, children, size, variant, onClick}: PropsWithChildren<ActiveButtonProps>) {
10
- return (
11
- (loading === true) ?
12
- <IconButton disabled={true} onClick={onClick} size={size} variant={variant} icon={<Spinner size="sm"/>}>{children}</IconButton>
13
- : <IconButton disabled={disabled} onClick={onClick} icon={icon} size={size} variant={variant}>{children}</IconButton>
14
- );
15
- }
16
-
17
- export default LoadingButton;
1
+ import { Spinner } from "react-bootstrap";
2
+ import { PropsWithChildren } from "react";
3
+ import { IconButton, IconButtonProps } from "./IconButton";
4
+
5
+ export type ActiveButtonProps = IconButtonProps & {
6
+ loading?: boolean;
7
+ };
8
+
9
+ export function LoadingButton({
10
+ disabled,
11
+ icon,
12
+ loading,
13
+ children,
14
+ size,
15
+ variant,
16
+ type,
17
+ onClick,
18
+ }: PropsWithChildren<ActiveButtonProps>) {
19
+ return loading === true ? (
20
+ <IconButton
21
+ disabled={true}
22
+ onClick={onClick}
23
+ size={size}
24
+ variant={variant}
25
+ type={type}
26
+ icon={<Spinner size="sm" />}
27
+ >
28
+ {children}
29
+ </IconButton>
30
+ ) : (
31
+ <IconButton
32
+ disabled={disabled}
33
+ onClick={onClick}
34
+ icon={icon}
35
+ size={size}
36
+ variant={variant}
37
+ >
38
+ {children}
39
+ </IconButton>
40
+ );
41
+ }
42
+
43
+ export default LoadingButton;