@star-insure/sdk 6.0.15 → 6.0.17
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/package.json +1 -1
- package/src/components/common/Button.tsx +66 -64
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@star-insure/sdk",
|
|
3
3
|
"description": "The SDK for Star Insure client apps with shared helper functions and TypeScript definitions.",
|
|
4
4
|
"author": "alexclark_nz",
|
|
5
|
-
"version": "6.0.
|
|
5
|
+
"version": "6.0.17",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -2,79 +2,81 @@ import React from 'react';
|
|
|
2
2
|
import { Link } from '@inertiajs/react';
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
className?: string;
|
|
6
|
+
href?: string;
|
|
7
|
+
target?: '_blank' | '_self';
|
|
8
|
+
onClick?: Function;
|
|
9
|
+
type?: 'button' | 'submit';
|
|
10
|
+
status?: 'primary' | 'danger' | 'warning' | 'info' | 'default';
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
as?: 'link' | 'button' | 'a';
|
|
14
|
+
small?: boolean;
|
|
15
|
+
form?: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export default function Button({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
className,
|
|
20
|
+
href,
|
|
21
|
+
target,
|
|
22
|
+
onClick,
|
|
23
|
+
type,
|
|
24
|
+
children,
|
|
25
|
+
status = 'default',
|
|
26
|
+
disabled = false,
|
|
27
|
+
as,
|
|
28
|
+
small = false,
|
|
29
|
+
form,
|
|
28
30
|
}: Props) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const baseClasses = small
|
|
32
|
+
? 'font-bold text-sm inline-flex items-center gap-3 justify-center text-white text-center px-3 py-1 rounded min-w-[80px] transition-all hover:brightness-110'
|
|
33
|
+
: 'font-black inline-flex items-center gap-3 justify-center text-white text-center px-5 py-2 rounded-md min-w-[120px] transition-all hover:brightness-110';
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const statusClass =
|
|
36
|
+
(status === 'primary' && 'bg-accent') ||
|
|
37
|
+
(status === 'danger' && 'bg-red-500') ||
|
|
38
|
+
(status === 'warning' && 'bg-yellow-400') ||
|
|
39
|
+
(status === 'info' && 'bg-blue-400') ||
|
|
40
|
+
'bg-gray-600';
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
const classes = `${className ?? ''} ${baseClasses} ${statusClass}`;
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (type) {
|
|
56
|
-
return (
|
|
57
|
-
<button className={classes} type={type ?? 'button'} disabled={disabled}>
|
|
58
|
-
{children}
|
|
59
|
-
</button>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
44
|
+
if (onClick) {
|
|
45
|
+
return (
|
|
46
|
+
<button
|
|
47
|
+
className={classes}
|
|
48
|
+
type={type ?? 'button'}
|
|
49
|
+
onClick={(e: React.MouseEvent) => onClick(e)}
|
|
50
|
+
disabled={disabled}
|
|
51
|
+
>
|
|
52
|
+
{children}
|
|
53
|
+
</button>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
);
|
|
57
|
+
if (type) {
|
|
58
|
+
return (
|
|
59
|
+
<button form={form} className={classes} type={type ?? 'button'} disabled={disabled}>
|
|
60
|
+
{children}
|
|
61
|
+
</button>
|
|
62
|
+
);
|
|
70
63
|
}
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
65
|
+
if (href) {
|
|
66
|
+
if (href.includes('http') || target === '_blank' || as === 'a') {
|
|
67
|
+
return (
|
|
68
|
+
<a href={href} target={target ?? '_self'} className={classes}>
|
|
69
|
+
{children}
|
|
70
|
+
</a>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Link href={href} className={classes}>
|
|
76
|
+
{children}
|
|
77
|
+
</Link>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
return <p className="text-red-500 text-sm">[Invalid button]</p>;
|
|
80
82
|
}
|