@star-insure/sdk 3.2.8 → 3.2.10

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.
@@ -26,6 +26,7 @@ export declare type TPageHeaderAction = {
26
26
  onClick?: Function;
27
27
  type?: 'button' | 'submit';
28
28
  hidden?: boolean;
29
+ shortcutKey?: string;
29
30
  };
30
31
  export declare type Environment = 'production' | 'staging' | 'testing' | 'local';
31
32
  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": "3.2.8",
5
+ "version": "3.2.10",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,10 +1,43 @@
1
- import { Link } from "@inertiajs/react";
2
- import { TPageHeaderAction } from "../../types";
3
1
  import React from "react";
2
+ import { Link, router } from "@inertiajs/react";
3
+ import { TPageHeaderAction } from "../../types";
4
4
 
5
- export default function Action({ title, href, as = 'Link', target = '_self', type, onClick = () => {} }: TPageHeaderAction) {
5
+ export default function Action({ title, href, as = 'Link', target = '_self', type, onClick = () => {}, shortcutKey }: TPageHeaderAction) {
6
6
  const className =
7
- 'bg-white rounded-full font-bold px-3 py-1.5 text-xs whitespace-nowrap hover:bg-gray-100 hover:border-gray-300 transition-colors border border-gray-200';
7
+ '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';
8
+
9
+ function runAction() {
10
+ if (as === 'Link' && href) {
11
+ return router.get(href);
12
+ }
13
+
14
+ if (as === 'a' && href) {
15
+ return window.location.href = href;
16
+ }
17
+
18
+ onClick();
19
+ };
20
+
21
+ React.useEffect(() => {
22
+ if (typeof window === 'undefined') return;
23
+ if (!shortcutKey) return;
24
+
25
+ const listener = (e: KeyboardEvent) => {
26
+ // Check if Ctrl (Windows) or Cmd (Mac) key is pressed
27
+ const isCtrlOrCmdPressed = (e.ctrlKey || e.metaKey);
28
+
29
+ if (e.key === shortcutKey && isCtrlOrCmdPressed) {
30
+ e.preventDefault();
31
+ runAction();
32
+ }
33
+ };
34
+
35
+ window.addEventListener('keydown', listener);
36
+
37
+ return () => {
38
+ window.removeEventListener('keydown', listener);
39
+ };
40
+ }, [shortcutKey]);
8
41
 
9
42
  if (as === 'Link' && href) {
10
43
  return (
@@ -156,7 +156,7 @@ export default function PageHeader({
156
156
  )}>
157
157
  {search && <SearchBar search={search} active={isSearchActive} onActive={setSearchActive} placeholder={`Search ${title}...`} focusSearchShortcut={focusSearchShortcut} />}
158
158
 
159
- {!isSearchActive && <h1 className="text-base font-bold">{title}</h1>}
159
+ {!isSearchActive && <h1 className="text-base font-black">{title}</h1>}
160
160
  </button>
161
161
 
162
162
  <div className="flex items-center ml-auto gap-2 h-full min-w-0 max-w-full">
@@ -31,6 +31,7 @@ export type TPageHeaderAction = {
31
31
  onClick?: Function;
32
32
  type?: 'button' | 'submit';
33
33
  hidden?: boolean;
34
+ shortcutKey?: string;
34
35
  };
35
36
 
36
37
  export type Environment = 'production' | 'staging' | 'testing' | 'local';