@star-insure/sdk 3.2.10 → 3.2.12

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": "3.2.10",
5
+ "version": "3.2.12",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -57,11 +57,11 @@
57
57
  "@types/uuid": "^8.3.4",
58
58
  "husky": "^8.0.1",
59
59
  "np": "^7.6.1",
60
+ "react": "^18.2.0",
60
61
  "size-limit": "^7.0.8",
61
62
  "tsdx": "^0.14.1",
62
63
  "tslib": "^2.4.0",
63
- "typescript": "^3.9.10",
64
- "react": "^18.2.0"
64
+ "typescript": "^3.9.10"
65
65
  },
66
66
  "dependencies": {
67
67
  "@headlessui/react": "^1.6.3",
@@ -72,6 +72,7 @@
72
72
  "react-dom": "^18.2.0",
73
73
  "react-icons": "^4.11.0",
74
74
  "react-select": "^5.8.0",
75
+ "react-tooltip": "^5.25.0",
75
76
  "uuid": "^9.0.0"
76
77
  },
77
78
  "peerDependencies": {
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { Tooltip } from 'react-tooltip';
2
3
  import { Link, router } from "@inertiajs/react";
3
4
  import { TPageHeaderAction } from "../../types";
4
5
 
@@ -6,6 +7,9 @@ export default function Action({ title, href, as = 'Link', target = '_self', typ
6
7
  const className =
7
8
  '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
 
10
+ const tooltipId = `action-${title}`;
11
+ const tooltipContent = shortcutKey ? `Ctrl + ${shortcutKey}` : undefined;
12
+
9
13
  function runAction() {
10
14
  if (as === 'Link' && href) {
11
15
  return router.get(href);
@@ -26,7 +30,11 @@ export default function Action({ title, href, as = 'Link', target = '_self', typ
26
30
  // Check if Ctrl (Windows) or Cmd (Mac) key is pressed
27
31
  const isCtrlOrCmdPressed = (e.ctrlKey || e.metaKey);
28
32
 
29
- if (e.key === shortcutKey && isCtrlOrCmdPressed) {
33
+ // Check if the focus is on an input element or inside a form
34
+ const isInInput = e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement;
35
+ const isInForm = (e.target instanceof Element && e.target.closest('form'));
36
+
37
+ if (isCtrlOrCmdPressed && !isInInput && !isInForm && e.key === shortcutKey) {
30
38
  e.preventDefault();
31
39
  runAction();
32
40
  }
@@ -41,23 +49,32 @@ export default function Action({ title, href, as = 'Link', target = '_self', typ
41
49
 
42
50
  if (as === 'Link' && href) {
43
51
  return (
44
- <Link className={className} href={href} onClick={() => onClick()}>
45
- {title}
46
- </Link>
52
+ <>
53
+ {tooltipContent && <Tooltip id={tooltipId} className="z-10" />}
54
+ <Link data-tooltip-id={tooltipId} data-tooltip-content={tooltipContent} className={className} href={href} onClick={() => onClick()}>
55
+ {title}
56
+ </Link>
57
+ </>
47
58
  );
48
59
  }
49
60
 
50
61
  if (as === 'a' && href) {
51
62
  return (
52
- <a className={className} target={target} href={href} onClick={() => onClick()}>
53
- {title}
54
- </a>
63
+ <>
64
+ {tooltipContent && <Tooltip id={tooltipId} className="z-10" />}
65
+ <a data-tooltip-id={tooltipId} data-tooltip-content={tooltipContent} className={className} target={target} href={href} onClick={() => onClick()}>
66
+ {title}
67
+ </a>
68
+ </>
55
69
  );
56
70
  }
57
71
 
58
72
  return (
59
- <button className={className} type={type} onClick={() => onClick()}>
60
- {title}
61
- </button>
73
+ <>
74
+ {tooltipContent && <Tooltip id={tooltipId} className="z-10" />}
75
+ <button data-tooltip-id={tooltipId} data-tooltip-content={tooltipContent} className={className} type={type} onClick={() => onClick()}>
76
+ {title}
77
+ </button>
78
+ </>
62
79
  );
63
80
  }