@payglocal_ui/flux-ui 0.2.2 → 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
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -3855,6 +3856,7 @@ function DataTable({
3855
3856
  rowKey,
3856
3857
  rowCta,
3857
3858
  rowAction,
3859
+ onRowClick,
3858
3860
  density = "default",
3859
3861
  tableLayout = "fixed",
3860
3862
  theadClassName,
@@ -3887,6 +3889,12 @@ function DataTable({
3887
3889
  const footerPad = comfortable ? "px-5 py-4" : compact ? "px-4 py-2.5" : "px-4 py-3.5";
3888
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";
3889
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
+ };
3890
3898
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
3891
3899
  "div",
3892
3900
  {
@@ -3984,8 +3992,23 @@ function DataTable({
3984
3992
  comfortable && "min-h-[56px]",
3985
3993
  compact && "min-h-[44px]",
3986
3994
  "hover:bg-muted/40 dark:hover:bg-muted/25",
3987
- 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"
3988
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,
3989
4012
  children: [
3990
4013
  columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
3991
4014
  "td",