@star-insure/sdk 4.3.5 → 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 +45 -1
- 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 +45 -1
- 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/types/misc/index.ts +10 -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, shortcutKey }: TPageHeaderAction): JSX.Element;
|
|
3
|
+
export default function Action({ title, href, as, target, type, onClick, shortcutKey, actions }: TPageHeaderAction): JSX.Element;
|
|
@@ -2602,11 +2602,27 @@ function Action(_ref) {
|
|
|
2602
2602
|
type = _ref.type,
|
|
2603
2603
|
_ref$onClick = _ref.onClick,
|
|
2604
2604
|
_onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
2605
|
-
shortcutKey = _ref.shortcutKey
|
|
2605
|
+
shortcutKey = _ref.shortcutKey,
|
|
2606
|
+
actions = _ref.actions;
|
|
2606
2607
|
|
|
2607
2608
|
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';
|
|
2608
2609
|
var tooltipId = "action-" + title;
|
|
2609
2610
|
var tooltipContent = shortcutKey ? "Ctrl + " + shortcutKey : undefined;
|
|
2611
|
+
var actionButtonRef = React__default.useRef(null);
|
|
2612
|
+
var isActionsButton = actions && actions.length > 0;
|
|
2613
|
+
var actionsButtonClassName = 'relative cursor-pointer ' + className;
|
|
2614
|
+
|
|
2615
|
+
var _React$useState = React__default.useState(false),
|
|
2616
|
+
isInnerActionVisible = _React$useState[0],
|
|
2617
|
+
setIsInnerActionVisible = _React$useState[1];
|
|
2618
|
+
|
|
2619
|
+
var toggleActionsMenu = function toggleActionsMenu() {
|
|
2620
|
+
setIsInnerActionVisible(!isInnerActionVisible);
|
|
2621
|
+
};
|
|
2622
|
+
|
|
2623
|
+
useClickOutside(actionButtonRef, function () {
|
|
2624
|
+
return setIsInnerActionVisible(false);
|
|
2625
|
+
});
|
|
2610
2626
|
|
|
2611
2627
|
function runAction() {
|
|
2612
2628
|
if (as === 'Link' && href) {
|
|
@@ -2642,6 +2658,34 @@ function Action(_ref) {
|
|
|
2642
2658
|
};
|
|
2643
2659
|
}, [shortcutKey]);
|
|
2644
2660
|
|
|
2661
|
+
if (isActionsButton) {
|
|
2662
|
+
return React__default.createElement(React__default.Fragment, null, tooltipContent && React__default.createElement(reactTooltip.Tooltip, {
|
|
2663
|
+
id: tooltipId,
|
|
2664
|
+
className: "z-10"
|
|
2665
|
+
}), React__default.createElement("div", {
|
|
2666
|
+
ref: actionButtonRef,
|
|
2667
|
+
"data-tooltip-id": tooltipId,
|
|
2668
|
+
"data-tooltip-content": tooltipContent,
|
|
2669
|
+
className: actionsButtonClassName,
|
|
2670
|
+
onClick: toggleActionsMenu
|
|
2671
|
+
}, title, isInnerActionVisible && React__default.createElement("div", {
|
|
2672
|
+
className: "absolute top-[120%] right-[-20%] z-10"
|
|
2673
|
+
}, React__default.createElement("div", {
|
|
2674
|
+
className: "flex flex-col gap-2 bg-white rounded-lg shadow-xl p-3"
|
|
2675
|
+
}, actions && actions.map(function (action, index) {
|
|
2676
|
+
if (action.hidden) return null;
|
|
2677
|
+
return React__default.createElement(Action, {
|
|
2678
|
+
key: index,
|
|
2679
|
+
title: action.title,
|
|
2680
|
+
as: action.as,
|
|
2681
|
+
href: action.href,
|
|
2682
|
+
target: action.target,
|
|
2683
|
+
onClick: action.onClick,
|
|
2684
|
+
type: 'button'
|
|
2685
|
+
});
|
|
2686
|
+
})))));
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2645
2689
|
if (as === 'Link' && href) {
|
|
2646
2690
|
return React__default.createElement(React__default.Fragment, null, tooltipContent && React__default.createElement(reactTooltip.Tooltip, {
|
|
2647
2691
|
id: tooltipId,
|