@payglocal_ui/flux-ui 0.2.3 → 0.2.4

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/index.cjs CHANGED
@@ -3856,6 +3856,7 @@ function DataTable({
3856
3856
  rowKey,
3857
3857
  rowCta,
3858
3858
  rowAction,
3859
+ onRowClick,
3859
3860
  density = "default",
3860
3861
  tableLayout = "fixed",
3861
3862
  theadClassName,
@@ -3888,6 +3889,12 @@ function DataTable({
3888
3889
  const footerPad = comfortable ? "px-5 py-4" : compact ? "px-4 py-2.5" : "px-4 py-3.5";
3889
3890
  const headText = comfortable ? "text-[12px] font-medium text-muted-foreground tracking-normal" : compact ? "text-[11px] font-semibold text-muted-foreground" : "text-[11px] font-semibold text-foreground/75 dark:text-foreground/85";
3890
3891
  const actionGutter = comfortable ? 20 : compact ? 12 : 16;
3892
+ const ROW_CLICK_IGNORE = 'button, a, input, select, textarea, label, [role="button"], [role="link"], [role="checkbox"], [role="menuitem"], [role="menu"], [role="dialog"], [data-row-click-ignore]';
3893
+ const isRowClickTarget = (target, rowEl) => {
3894
+ if (!(target instanceof Element)) return false;
3895
+ const interactive = target.closest(ROW_CLICK_IGNORE);
3896
+ return !(interactive && rowEl.contains(interactive));
3897
+ };
3891
3898
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
3892
3899
  "div",
3893
3900
  {
@@ -3985,8 +3992,23 @@ function DataTable({
3985
3992
  comfortable && "min-h-[56px]",
3986
3993
  compact && "min-h-[44px]",
3987
3994
  "hover:bg-muted/40 dark:hover:bg-muted/25",
3988
- hasAction && "hover:shadow-[0_1px_0_rgba(0,0,0,0.04)] dark:hover:shadow-none"
3995
+ hasAction && "hover:shadow-[0_1px_0_rgba(0,0,0,0.04)] dark:hover:shadow-none",
3996
+ // Clickable rows read as clickable, and show a focus ring
3997
+ // when reached by keyboard. `focus-visible` only, so a
3998
+ // mouse click does not leave a ring behind on the row.
3999
+ onRowClick && "cursor-pointer focus-visible:outline-none focus-visible:bg-muted/40 dark:focus-visible:bg-muted/25"
3989
4000
  ),
4001
+ tabIndex: onRowClick ? 0 : void 0,
4002
+ onClick: onRowClick ? (e) => {
4003
+ if (!isRowClickTarget(e.target, e.currentTarget)) return;
4004
+ onRowClick(row, i);
4005
+ } : void 0,
4006
+ onKeyDown: onRowClick ? (e) => {
4007
+ if (e.key !== "Enter" && e.key !== " ") return;
4008
+ if (e.target !== e.currentTarget) return;
4009
+ e.preventDefault();
4010
+ onRowClick(row, i);
4011
+ } : void 0,
3990
4012
  children: [
3991
4013
  columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
3992
4014
  "td",