@eztrak/shared 0.15.1 → 0.15.3

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.
@@ -319,6 +319,11 @@ interface PopupCellRendererProps<TRow = unknown> {
319
319
  placement?: TippyProps["placement"];
320
320
  /** Default `"Row actions"`. */
321
321
  ariaLabel?: string;
322
+ /**
323
+ * When true, the menu opens on hover and closes on leave.
324
+ * Default `false` (click to open).
325
+ */
326
+ openOnHover?: boolean;
322
327
  tippyProps?: Omit<Partial<TippyProps>, "children" | "content" | "visible" | "placement">;
323
328
  }
324
329
 
@@ -329,7 +334,7 @@ interface PopupCellRendererProps<TRow = unknown> {
329
334
  * `import "tippy.js/dist/tippy.css"`
330
335
  * `import "tippy.js/themes/light.css"`
331
336
  */
332
- declare function PopupCellRenderer<TRow = unknown>({ dropDownContent, actionIcon: ActionIcon, title, className, hideTitle, params, onAction, placement, tippyProps, ariaLabel, }: PopupCellRendererProps<TRow>): react.JSX.Element;
337
+ declare function PopupCellRenderer<TRow = unknown>({ dropDownContent, actionIcon: ActionIcon, title, className, hideTitle, params, onAction, placement, tippyProps, ariaLabel, openOnHover, }: PopupCellRendererProps<TRow>): react.JSX.Element;
333
338
 
334
339
  type RowActionPresetName = "edit" | "delete" | "view" | "notes" | "history" | "download" | "archive" | "resolve";
335
340
  type RowActionsMode = "menu" | "inline";
@@ -405,6 +410,11 @@ interface RowActionsProps<TRow = unknown> {
405
410
  triggerAriaLabel?: string;
406
411
  hasPermission?: (permission: string) => boolean;
407
412
  placement?: TippyProps["placement"];
413
+ /**
414
+ * When true, the menu opens on hover and closes on leave.
415
+ * Default `false` (click to open).
416
+ */
417
+ openOnHover?: boolean;
408
418
  tippyProps?: PopupCellRendererProps<TRow>["tippyProps"];
409
419
  /** Override default `Fa*` preset icons/labels for this instance. */
410
420
  presets?: Partial<Record<RowActionPresetName, Partial<RowActionPreset>>>;
@@ -469,7 +479,7 @@ interface RowActionPreset {
469
479
  iconClassName?: string;
470
480
  }
471
481
 
472
- declare function RowActions<TRow = unknown>({ actions, data, mode, actionIcon, className, menuClassName, itemClassName, itemIconClassName, itemLabelClassName, iconSize, triggerTooltip, triggerAriaLabel, hasPermission, placement, tippyProps, presets, confirmFn, tooltipPlacement, tooltipDelayShow, tooltipDelayHide, tooltipClassName, tooltipStyle, renderItem, renderMenu, renderTrigger, }: RowActionsProps<TRow>): react.JSX.Element | null;
482
+ declare function RowActions<TRow = unknown>({ actions, data, mode, actionIcon, className, menuClassName, itemClassName, itemIconClassName, itemLabelClassName, iconSize, triggerTooltip, triggerAriaLabel, hasPermission, placement, openOnHover, tippyProps, presets, confirmFn, tooltipPlacement, tooltipDelayShow, tooltipDelayHide, tooltipClassName, tooltipStyle, renderItem, renderMenu, renderTrigger, }: RowActionsProps<TRow>): react.JSX.Element | null;
473
483
 
474
484
  declare function ActionMenuItem({ label, icon: Icon, iconSize, iconClassName, labelClassName, tooltip, tooltipPlacement, tooltipDelayShow, tooltipDelayHide, tooltipClassName, tooltipStyle, disabled, danger, highlight, showLabel, className, onClick, }: ActionMenuItemProps): react.JSX.Element;
475
485
 
@@ -1758,23 +1758,34 @@ function PopupCellRenderer({
1758
1758
  onAction,
1759
1759
  placement = "bottom-end",
1760
1760
  tippyProps,
1761
- ariaLabel = "Row actions"
1761
+ ariaLabel = "Row actions",
1762
+ openOnHover = false
1762
1763
  }) {
1763
1764
  const [visible, setVisible] = (0, import_react7.useState)(false);
1765
+ const instanceRef = (0, import_react7.useRef)(null);
1764
1766
  const show = () => setVisible(true);
1765
- const hide = () => setVisible(false);
1767
+ const hide = () => {
1768
+ setVisible(false);
1769
+ instanceRef.current?.hide();
1770
+ };
1766
1771
  const rowData = params?.data;
1767
1772
  const handleAction = (actionType, actionRowData) => {
1768
1773
  onAction?.(actionType, actionRowData ?? rowData, hide);
1769
1774
  hide();
1770
1775
  };
1771
1776
  const content = typeof dropDownContent === "function" ? dropDownContent(handleAction) : dropDownContent;
1777
+ const hoverOrClickProps = openOnHover ? {
1778
+ trigger: "mouseenter",
1779
+ delay: [0, 150],
1780
+ hideOnClick: false
1781
+ } : {
1782
+ visible,
1783
+ onClickOutside: hide
1784
+ };
1772
1785
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex h-full", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1773
1786
  import_react8.default,
1774
1787
  {
1775
1788
  content,
1776
- visible,
1777
- onClickOutside: hide,
1778
1789
  allowHTML: true,
1779
1790
  arrow: false,
1780
1791
  appendTo: () => document.body,
@@ -1784,12 +1795,16 @@ function PopupCellRenderer({
1784
1795
  theme: "light",
1785
1796
  maxWidth: "none",
1786
1797
  offset: [0, 5],
1798
+ onCreate: (instance) => {
1799
+ instanceRef.current = instance;
1800
+ },
1801
+ ...hoverOrClickProps,
1787
1802
  ...tippyProps,
1788
1803
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1789
1804
  "button",
1790
1805
  {
1791
1806
  type: "button",
1792
- onClick: visible ? hide : show,
1807
+ onClick: openOnHover ? void 0 : visible ? hide : show,
1793
1808
  className: cn(
1794
1809
  "flex items-center justify-center gap-2 rounded-full text-gray-500 hover:text-gray-800",
1795
1810
  className
@@ -1974,6 +1989,7 @@ function RowActions({
1974
1989
  triggerAriaLabel = "Row actions",
1975
1990
  hasPermission,
1976
1991
  placement = "bottom-end",
1992
+ openOnHover = false,
1977
1993
  tippyProps,
1978
1994
  presets,
1979
1995
  confirmFn = confirmationAlert,
@@ -2088,6 +2104,7 @@ function RowActions({
2088
2104
  hideTitle: true,
2089
2105
  className,
2090
2106
  placement,
2107
+ openOnHover,
2091
2108
  tippyProps,
2092
2109
  ariaLabel: triggerAriaLabel,
2093
2110
  dropDownContent: (handleAction) => buildMenu(() => handleAction("close"))