@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 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.15",
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
- 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;
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
- className,
19
- href,
20
- target,
21
- onClick,
22
- type,
23
- children,
24
- status = 'default',
25
- disabled = false,
26
- as,
27
- small = false,
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
- const baseClasses = small
30
- ? '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'
31
- : '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';
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
- const statusClass =
34
- (status === 'primary' && 'bg-accent') ||
35
- (status === 'danger' && 'bg-red-500') ||
36
- (status === 'warning' && 'bg-yellow-400') ||
37
- (status === 'info' && 'bg-blue-400') ||
38
- 'bg-gray-600';
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
- const classes = `${className ?? ''} ${baseClasses} ${statusClass}`;
42
+ const classes = `${className ?? ''} ${baseClasses} ${statusClass}`;
41
43
 
42
- if (onClick) {
43
- return (
44
- <button
45
- className={classes}
46
- type={type ?? 'button'}
47
- onClick={(e: React.MouseEvent) => onClick(e)}
48
- disabled={disabled}
49
- >
50
- {children}
51
- </button>
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
- if (href) {
64
- if (href.includes('http') || target === '_blank' || as === 'a') {
65
- return (
66
- <a href={href} target={target ?? '_self'} className={classes}>
67
- {children}
68
- </a>
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
- return (
73
- <Link href={href} className={classes}>
74
- {children}
75
- </Link>
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
- return <p className="text-red-500 text-sm">[Invalid button]</p>;
81
+ return <p className="text-red-500 text-sm">[Invalid button]</p>;
80
82
  }