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.
- package/dist/component/forms/IconButton.d.ts +3 -2
- package/dist/component/forms/LoadingButton.d.ts +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/component/forms/IconButton.tsx +39 -26
- package/src/component/forms/LoadingButton.tsx +43 -17
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export function LoadingButton({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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;
|