@star-insure/sdk 4.3.4 → 4.4.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.
- package/dist/components/filter/Action.d.ts +1 -1
- package/dist/sdk.cjs.development.js +62 -8
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +62 -8
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/misc/index.d.ts +9 -0
- package/package.json +1 -1
- package/src/components/filter/Action.tsx +50 -1
- package/src/components/forms/DateOfBirthField.tsx +16 -4
- package/src/types/misc/index.ts +10 -0
|
@@ -27,6 +27,15 @@ export declare type TPageHeaderAction = {
|
|
|
27
27
|
type?: 'button' | 'submit';
|
|
28
28
|
hidden?: boolean;
|
|
29
29
|
shortcutKey?: string;
|
|
30
|
+
actions?: TPageHeaderInnerAction[];
|
|
31
|
+
};
|
|
32
|
+
export declare type TPageHeaderInnerAction = {
|
|
33
|
+
title: string;
|
|
34
|
+
as?: 'button' | 'a' | 'Link';
|
|
35
|
+
href?: string;
|
|
36
|
+
target?: '_self' | '_blank';
|
|
37
|
+
onClick?: Function;
|
|
38
|
+
hidden?: boolean;
|
|
30
39
|
};
|
|
31
40
|
export declare type Environment = 'production' | 'staging' | 'testing' | 'local';
|
|
32
41
|
export declare type Breadcrumb = {
|
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": "4.
|
|
5
|
+
"version": "4.4.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -2,14 +2,26 @@ import React from "react";
|
|
|
2
2
|
import { Tooltip } from 'react-tooltip';
|
|
3
3
|
import { Link, router } from "@inertiajs/react";
|
|
4
4
|
import { TPageHeaderAction } from "../../types";
|
|
5
|
+
import {useClickOutside} from "../../lib";
|
|
5
6
|
|
|
6
|
-
export default function Action({ title, href, as = 'Link', target = '_self', type, onClick = () => {}, shortcutKey }: TPageHeaderAction) {
|
|
7
|
+
export default function Action({ title, href, as = 'Link', target = '_self', type, onClick = () => {}, shortcutKey, actions }: TPageHeaderAction) {
|
|
7
8
|
const className =
|
|
8
9
|
'bg-white rounded-full font-bold px-4 py-1.5 text-sm whitespace-nowrap hover:bg-gray-100 hover:border-gray-400 transition-colors border border-gray-300';
|
|
9
10
|
|
|
10
11
|
const tooltipId = `action-${title}`;
|
|
11
12
|
const tooltipContent = shortcutKey ? `Ctrl + ${shortcutKey}` : undefined;
|
|
12
13
|
|
|
14
|
+
const actionButtonRef = React.useRef(null);
|
|
15
|
+
const isActionsButton = actions && actions.length > 0;
|
|
16
|
+
const actionsButtonClassName = 'relative cursor-pointer ' + className;
|
|
17
|
+
const [isInnerActionVisible, setIsInnerActionVisible] = React.useState(false);
|
|
18
|
+
|
|
19
|
+
const toggleActionsMenu = () => {
|
|
20
|
+
setIsInnerActionVisible(!isInnerActionVisible);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
useClickOutside(actionButtonRef, () => setIsInnerActionVisible(false));
|
|
24
|
+
|
|
13
25
|
function runAction() {
|
|
14
26
|
if (as === 'Link' && href) {
|
|
15
27
|
return router.get(href);
|
|
@@ -47,6 +59,43 @@ export default function Action({ title, href, as = 'Link', target = '_self', typ
|
|
|
47
59
|
};
|
|
48
60
|
}, [shortcutKey]);
|
|
49
61
|
|
|
62
|
+
if (isActionsButton) {
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
{tooltipContent && <Tooltip id={tooltipId} className="z-10" />}
|
|
66
|
+
<div
|
|
67
|
+
ref={actionButtonRef}
|
|
68
|
+
data-tooltip-id={tooltipId}
|
|
69
|
+
data-tooltip-content={tooltipContent}
|
|
70
|
+
className={actionsButtonClassName}
|
|
71
|
+
onClick={toggleActionsMenu}>
|
|
72
|
+
{title}
|
|
73
|
+
{isInnerActionVisible && (
|
|
74
|
+
<div className="absolute top-[120%] right-[-20%] z-10">
|
|
75
|
+
<div className="flex flex-col gap-2 bg-white rounded-lg shadow-xl p-3">
|
|
76
|
+
{actions && actions.map((action, index) => {
|
|
77
|
+
if (action.hidden) return null;
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Action
|
|
81
|
+
key={index}
|
|
82
|
+
title={action.title}
|
|
83
|
+
as={action.as}
|
|
84
|
+
href={action.href}
|
|
85
|
+
target={action.target}
|
|
86
|
+
onClick={action.onClick}
|
|
87
|
+
type={'button'}
|
|
88
|
+
/>
|
|
89
|
+
);
|
|
90
|
+
})}
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
50
99
|
if (as === 'Link' && href) {
|
|
51
100
|
return (
|
|
52
101
|
<>
|
|
@@ -69,16 +69,26 @@ export default function DateOfBirthField({
|
|
|
69
69
|
const isValidDate =
|
|
70
70
|
year && month && day && !isNaN(Date.parse(`${year}-${month}-${day}`));
|
|
71
71
|
|
|
72
|
+
const styleReq = {
|
|
73
|
+
backgroundPosition: 'top 10px right 3px, center right 10px',
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const style = {
|
|
77
|
+
backgroundPosition: 'right 0.5rem center',
|
|
78
|
+
paddingRight: '1.5rem'
|
|
79
|
+
}
|
|
80
|
+
|
|
72
81
|
return (
|
|
73
82
|
<span className="flex flex-col gap-2">
|
|
74
|
-
<span className="flex
|
|
83
|
+
<span className="flex w-full border border-gray-300 rounded-lg bg-white">
|
|
75
84
|
<select
|
|
76
85
|
name={`${name}_day`}
|
|
77
86
|
id={`${id}_day`}
|
|
78
87
|
value={day}
|
|
79
|
-
className="flex-grow focus:outline-none border-0"
|
|
88
|
+
className="flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2"
|
|
80
89
|
onChange={handleChange}
|
|
81
90
|
required={isRequired}
|
|
91
|
+
style={isRequired ? styleReq : style}
|
|
82
92
|
>
|
|
83
93
|
<option value="">Day</option>
|
|
84
94
|
{dayOptions.map(option => (
|
|
@@ -91,9 +101,10 @@ export default function DateOfBirthField({
|
|
|
91
101
|
name={`${name}_month`}
|
|
92
102
|
id={`${id}_month`}
|
|
93
103
|
value={month}
|
|
94
|
-
className="flex-grow focus:outline-none border-0"
|
|
104
|
+
className="flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2"
|
|
95
105
|
onChange={handleChange}
|
|
96
106
|
required={isRequired}
|
|
107
|
+
style={isRequired ? styleReq : style}
|
|
97
108
|
>
|
|
98
109
|
<option value="">Month</option>
|
|
99
110
|
{monthOptions.map(option => (
|
|
@@ -106,9 +117,10 @@ export default function DateOfBirthField({
|
|
|
106
117
|
name={`${name}_year`}
|
|
107
118
|
id={`${id}_year`}
|
|
108
119
|
value={year}
|
|
109
|
-
className="flex-grow focus:outline-none border-0"
|
|
120
|
+
className="flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2"
|
|
110
121
|
onChange={handleChange}
|
|
111
122
|
required={isRequired}
|
|
123
|
+
style={isRequired ? styleReq : style}
|
|
112
124
|
>
|
|
113
125
|
<option value="">Year</option>
|
|
114
126
|
{yearOptions.map(option => (
|
package/src/types/misc/index.ts
CHANGED
|
@@ -32,6 +32,16 @@ export type TPageHeaderAction = {
|
|
|
32
32
|
type?: 'button' | 'submit';
|
|
33
33
|
hidden?: boolean;
|
|
34
34
|
shortcutKey?: string;
|
|
35
|
+
actions?: TPageHeaderInnerAction[];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type TPageHeaderInnerAction = {
|
|
39
|
+
title: string;
|
|
40
|
+
as?: 'button' | 'a' | 'Link';
|
|
41
|
+
href?: string;
|
|
42
|
+
target?: '_self' | '_blank';
|
|
43
|
+
onClick?: Function;
|
|
44
|
+
hidden?: boolean;
|
|
35
45
|
};
|
|
36
46
|
|
|
37
47
|
export type Environment = 'production' | 'staging' | 'testing' | 'local';
|