@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 +23 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/data-table.tsx +73 -1
package/dist/index.d.cts
CHANGED
|
@@ -789,6 +789,22 @@ interface DataTableProps<T> {
|
|
|
789
789
|
* flush with nothing trailing it. Takes precedence over `rowCta`.
|
|
790
790
|
*/
|
|
791
791
|
rowAction?: ReactNode | ((row: T, index: number) => ReactNode);
|
|
792
|
+
/**
|
|
793
|
+
* Makes the whole row a click target — the row itself opens a drawer, a
|
|
794
|
+
* detail page, whatever the table drills into — instead of that living in a
|
|
795
|
+
* per-cell wrapper or a hover-revealed button.
|
|
796
|
+
*
|
|
797
|
+
* The handler sits on the `<tr>`, so the entire row including cell padding
|
|
798
|
+
* and the empty space between columns is clickable, and the row gets
|
|
799
|
+
* `cursor-pointer` plus keyboard access (focusable, Enter / Space).
|
|
800
|
+
*
|
|
801
|
+
* Clicks that originate inside something interactive — a `<button>`, `<a>`,
|
|
802
|
+
* a form control, a Radix trigger, or anything marked
|
|
803
|
+
* `data-row-click-ignore` — do NOT fire this. Copy buttons, per-row menus
|
|
804
|
+
* and the `rowAction` overlay therefore keep doing only their own job
|
|
805
|
+
* without each having to stop propagation.
|
|
806
|
+
*/
|
|
807
|
+
onRowClick?: (row: T, index: number) => void;
|
|
792
808
|
/** Row / cell vertical rhythm and horizontal gutters */
|
|
793
809
|
density?: DataTableDensity;
|
|
794
810
|
/**
|
|
@@ -814,7 +830,7 @@ interface DataTableProps<T> {
|
|
|
814
830
|
/** With `density="compact"`, use tighter cell gutters (`pl-1.5 pr-2.5` vs `px-3`). Footer keeps normal horizontal padding. */
|
|
815
831
|
snug?: boolean;
|
|
816
832
|
}
|
|
817
|
-
declare function DataTable<T>({ columns, data, isLoading, skeletonRows, emptyTitle, emptyDescription, pageSize, page: controlledPage, onPageChange, totalRows, className, rowKey, rowCta, rowAction, density, tableLayout, theadClassName, headerStyle, footerSummary, footerCountLabels, snug, }: DataTableProps<T>): React$1.JSX.Element;
|
|
833
|
+
declare function DataTable<T>({ columns, data, isLoading, skeletonRows, emptyTitle, emptyDescription, pageSize, page: controlledPage, onPageChange, totalRows, className, rowKey, rowCta, rowAction, onRowClick, density, tableLayout, theadClassName, headerStyle, footerSummary, footerCountLabels, snug, }: DataTableProps<T>): React$1.JSX.Element;
|
|
818
834
|
|
|
819
835
|
interface EmptyStateProps {
|
|
820
836
|
icon?: LucideIcon;
|
package/dist/index.d.ts
CHANGED
|
@@ -789,6 +789,22 @@ interface DataTableProps<T> {
|
|
|
789
789
|
* flush with nothing trailing it. Takes precedence over `rowCta`.
|
|
790
790
|
*/
|
|
791
791
|
rowAction?: ReactNode | ((row: T, index: number) => ReactNode);
|
|
792
|
+
/**
|
|
793
|
+
* Makes the whole row a click target — the row itself opens a drawer, a
|
|
794
|
+
* detail page, whatever the table drills into — instead of that living in a
|
|
795
|
+
* per-cell wrapper or a hover-revealed button.
|
|
796
|
+
*
|
|
797
|
+
* The handler sits on the `<tr>`, so the entire row including cell padding
|
|
798
|
+
* and the empty space between columns is clickable, and the row gets
|
|
799
|
+
* `cursor-pointer` plus keyboard access (focusable, Enter / Space).
|
|
800
|
+
*
|
|
801
|
+
* Clicks that originate inside something interactive — a `<button>`, `<a>`,
|
|
802
|
+
* a form control, a Radix trigger, or anything marked
|
|
803
|
+
* `data-row-click-ignore` — do NOT fire this. Copy buttons, per-row menus
|
|
804
|
+
* and the `rowAction` overlay therefore keep doing only their own job
|
|
805
|
+
* without each having to stop propagation.
|
|
806
|
+
*/
|
|
807
|
+
onRowClick?: (row: T, index: number) => void;
|
|
792
808
|
/** Row / cell vertical rhythm and horizontal gutters */
|
|
793
809
|
density?: DataTableDensity;
|
|
794
810
|
/**
|
|
@@ -814,7 +830,7 @@ interface DataTableProps<T> {
|
|
|
814
830
|
/** With `density="compact"`, use tighter cell gutters (`pl-1.5 pr-2.5` vs `px-3`). Footer keeps normal horizontal padding. */
|
|
815
831
|
snug?: boolean;
|
|
816
832
|
}
|
|
817
|
-
declare function DataTable<T>({ columns, data, isLoading, skeletonRows, emptyTitle, emptyDescription, pageSize, page: controlledPage, onPageChange, totalRows, className, rowKey, rowCta, rowAction, density, tableLayout, theadClassName, headerStyle, footerSummary, footerCountLabels, snug, }: DataTableProps<T>): React$1.JSX.Element;
|
|
833
|
+
declare function DataTable<T>({ columns, data, isLoading, skeletonRows, emptyTitle, emptyDescription, pageSize, page: controlledPage, onPageChange, totalRows, className, rowKey, rowCta, rowAction, onRowClick, density, tableLayout, theadClassName, headerStyle, footerSummary, footerCountLabels, snug, }: DataTableProps<T>): React$1.JSX.Element;
|
|
818
834
|
|
|
819
835
|
interface EmptyStateProps {
|
|
820
836
|
icon?: LucideIcon;
|
package/dist/index.js
CHANGED
|
@@ -3608,6 +3608,7 @@ function DataTable({
|
|
|
3608
3608
|
rowKey,
|
|
3609
3609
|
rowCta,
|
|
3610
3610
|
rowAction,
|
|
3611
|
+
onRowClick,
|
|
3611
3612
|
density = "default",
|
|
3612
3613
|
tableLayout = "fixed",
|
|
3613
3614
|
theadClassName,
|
|
@@ -3640,6 +3641,12 @@ function DataTable({
|
|
|
3640
3641
|
const footerPad = comfortable ? "px-5 py-4" : compact ? "px-4 py-2.5" : "px-4 py-3.5";
|
|
3641
3642
|
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";
|
|
3642
3643
|
const actionGutter = comfortable ? 20 : compact ? 12 : 16;
|
|
3644
|
+
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]';
|
|
3645
|
+
const isRowClickTarget = (target, rowEl) => {
|
|
3646
|
+
if (!(target instanceof Element)) return false;
|
|
3647
|
+
const interactive = target.closest(ROW_CLICK_IGNORE);
|
|
3648
|
+
return !(interactive && rowEl.contains(interactive));
|
|
3649
|
+
};
|
|
3643
3650
|
return /* @__PURE__ */ jsxs30(
|
|
3644
3651
|
"div",
|
|
3645
3652
|
{
|
|
@@ -3737,8 +3744,23 @@ function DataTable({
|
|
|
3737
3744
|
comfortable && "min-h-[56px]",
|
|
3738
3745
|
compact && "min-h-[44px]",
|
|
3739
3746
|
"hover:bg-muted/40 dark:hover:bg-muted/25",
|
|
3740
|
-
hasAction && "hover:shadow-[0_1px_0_rgba(0,0,0,0.04)] dark:hover:shadow-none"
|
|
3747
|
+
hasAction && "hover:shadow-[0_1px_0_rgba(0,0,0,0.04)] dark:hover:shadow-none",
|
|
3748
|
+
// Clickable rows read as clickable, and show a focus ring
|
|
3749
|
+
// when reached by keyboard. `focus-visible` only, so a
|
|
3750
|
+
// mouse click does not leave a ring behind on the row.
|
|
3751
|
+
onRowClick && "cursor-pointer focus-visible:outline-none focus-visible:bg-muted/40 dark:focus-visible:bg-muted/25"
|
|
3741
3752
|
),
|
|
3753
|
+
tabIndex: onRowClick ? 0 : void 0,
|
|
3754
|
+
onClick: onRowClick ? (e) => {
|
|
3755
|
+
if (!isRowClickTarget(e.target, e.currentTarget)) return;
|
|
3756
|
+
onRowClick(row, i);
|
|
3757
|
+
} : void 0,
|
|
3758
|
+
onKeyDown: onRowClick ? (e) => {
|
|
3759
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
3760
|
+
if (e.target !== e.currentTarget) return;
|
|
3761
|
+
e.preventDefault();
|
|
3762
|
+
onRowClick(row, i);
|
|
3763
|
+
} : void 0,
|
|
3742
3764
|
children: [
|
|
3743
3765
|
columns.map((col) => /* @__PURE__ */ jsx49(
|
|
3744
3766
|
"td",
|