@star-insure/sdk 3.2.9 → 3.2.11
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 +58 -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 +58 -8
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/misc/index.d.ts +1 -0
- package/package.json +4 -3
- package/src/components/filter/Action.tsx +59 -13
- package/src/types/misc/index.ts +1 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TPageHeaderAction } from "../../types";
|
|
3
|
-
export default function Action({ title, href, as, target, type, onClick }: TPageHeaderAction): JSX.Element;
|
|
3
|
+
export default function Action({ title, href, as, target, type, onClick, shortcutKey }: TPageHeaderAction): JSX.Element;
|
|
@@ -13,6 +13,7 @@ var react$1 = require('@headlessui/react');
|
|
|
13
13
|
var cn = _interopDefault(require('classnames'));
|
|
14
14
|
var lodash = require('lodash');
|
|
15
15
|
var hi2 = require('react-icons/hi2');
|
|
16
|
+
var reactTooltip = require('react-tooltip');
|
|
16
17
|
var Select = _interopDefault(require('react-select'));
|
|
17
18
|
var core = require('@inertiajs/core');
|
|
18
19
|
|
|
@@ -2414,38 +2415,87 @@ function Action(_ref) {
|
|
|
2414
2415
|
target = _ref$target === void 0 ? '_self' : _ref$target,
|
|
2415
2416
|
type = _ref.type,
|
|
2416
2417
|
_ref$onClick = _ref.onClick,
|
|
2417
|
-
_onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick
|
|
2418
|
+
_onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
2419
|
+
shortcutKey = _ref.shortcutKey;
|
|
2418
2420
|
|
|
2419
|
-
var className = 'bg-white rounded-full font-bold px-4 py-1.5 text-sm whitespace-nowrap hover:bg-gray-100 hover:border-gray-
|
|
2421
|
+
var className = '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';
|
|
2422
|
+
var tooltipId = "action-" + title;
|
|
2423
|
+
var tooltipContent = shortcutKey ? "Ctrl + " + shortcutKey : undefined;
|
|
2424
|
+
|
|
2425
|
+
function runAction() {
|
|
2426
|
+
if (as === 'Link' && href) {
|
|
2427
|
+
return react.router.get(href);
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
if (as === 'a' && href) {
|
|
2431
|
+
return window.location.href = href;
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
_onClick();
|
|
2435
|
+
}
|
|
2436
|
+
React__default.useEffect(function () {
|
|
2437
|
+
if (typeof window === 'undefined') return;
|
|
2438
|
+
if (!shortcutKey) return;
|
|
2439
|
+
|
|
2440
|
+
var listener = function listener(e) {
|
|
2441
|
+
// Check if Ctrl (Windows) or Cmd (Mac) key is pressed
|
|
2442
|
+
var isCtrlOrCmdPressed = e.ctrlKey || e.metaKey;
|
|
2443
|
+
|
|
2444
|
+
if (e.key === shortcutKey && isCtrlOrCmdPressed) {
|
|
2445
|
+
e.preventDefault();
|
|
2446
|
+
runAction();
|
|
2447
|
+
}
|
|
2448
|
+
};
|
|
2449
|
+
|
|
2450
|
+
window.addEventListener('keydown', listener);
|
|
2451
|
+
return function () {
|
|
2452
|
+
window.removeEventListener('keydown', listener);
|
|
2453
|
+
};
|
|
2454
|
+
}, [shortcutKey]);
|
|
2420
2455
|
|
|
2421
2456
|
if (as === 'Link' && href) {
|
|
2422
|
-
return React__default.createElement(
|
|
2457
|
+
return React__default.createElement(React__default.Fragment, null, tooltipContent && React__default.createElement(reactTooltip.Tooltip, {
|
|
2458
|
+
id: tooltipId,
|
|
2459
|
+
className: "z-10"
|
|
2460
|
+
}), React__default.createElement(react.Link, {
|
|
2461
|
+
"data-tooltip-id": tooltipId,
|
|
2462
|
+
"data-tooltip-content": tooltipContent,
|
|
2423
2463
|
className: className,
|
|
2424
2464
|
href: href,
|
|
2425
2465
|
onClick: function onClick() {
|
|
2426
2466
|
return _onClick();
|
|
2427
2467
|
}
|
|
2428
|
-
}, title);
|
|
2468
|
+
}, title));
|
|
2429
2469
|
}
|
|
2430
2470
|
|
|
2431
2471
|
if (as === 'a' && href) {
|
|
2432
|
-
return React__default.createElement(
|
|
2472
|
+
return React__default.createElement(React__default.Fragment, null, tooltipContent && React__default.createElement(reactTooltip.Tooltip, {
|
|
2473
|
+
id: tooltipId,
|
|
2474
|
+
className: "z-10"
|
|
2475
|
+
}), React__default.createElement("a", {
|
|
2476
|
+
"data-tooltip-id": tooltipId,
|
|
2477
|
+
"data-tooltip-content": tooltipContent,
|
|
2433
2478
|
className: className,
|
|
2434
2479
|
target: target,
|
|
2435
2480
|
href: href,
|
|
2436
2481
|
onClick: function onClick() {
|
|
2437
2482
|
return _onClick();
|
|
2438
2483
|
}
|
|
2439
|
-
}, title);
|
|
2484
|
+
}, title));
|
|
2440
2485
|
}
|
|
2441
2486
|
|
|
2442
|
-
return React__default.createElement(
|
|
2487
|
+
return React__default.createElement(React__default.Fragment, null, tooltipContent && React__default.createElement(reactTooltip.Tooltip, {
|
|
2488
|
+
id: tooltipId,
|
|
2489
|
+
className: "z-10"
|
|
2490
|
+
}), React__default.createElement("button", {
|
|
2491
|
+
"data-tooltip-id": tooltipId,
|
|
2492
|
+
"data-tooltip-content": tooltipContent,
|
|
2443
2493
|
className: className,
|
|
2444
2494
|
type: type,
|
|
2445
2495
|
onClick: function onClick() {
|
|
2446
2496
|
return _onClick();
|
|
2447
2497
|
}
|
|
2448
|
-
}, title);
|
|
2498
|
+
}, title));
|
|
2449
2499
|
}
|
|
2450
2500
|
|
|
2451
2501
|
function Dropdown(_ref) {
|