@payfit/unity-components 2.65.27 → 2.66.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/README.md CHANGED
@@ -19,5 +19,6 @@ Add an emoji below:
19
19
  - 🦄
20
20
  - 🏰
21
21
  - 🐧
22
+ - 🦉
22
23
 
23
24
  In some cases, the library is not published properly, which fails publish for payslip-template.
@@ -1,9 +1,9 @@
1
- import { default as React, ReactNode } from 'react';
2
- import { Row, RowData, Table as TableType } from '@tanstack/react-table';
1
+ import { ReactNode, default as React } from 'react';
2
+ import { ReactTable as TableType, Row, RowData, TableFeatures } from '@tanstack/react-table';
3
3
  import { TablePaginationProps } from '../table/parts/TablePagination.js';
4
4
  import { TableProps, TableRootProps } from '../table/Table.js';
5
5
  declare module '@tanstack/react-table' {
6
- interface ColumnMeta<TData extends RowData, TValue> {
6
+ interface ColumnMeta<TFeatures, TData extends RowData, TValue> {
7
7
  /**
8
8
  * Marks the cell as a row header. When true, the cell renders as `<th scope="row">` instead of `<td>`.
9
9
  * Use this for the first column that identifies each row (e.g., ID, name). Important for accessibility.
@@ -100,9 +100,9 @@ export interface DataTablePaginationOptions {
100
100
  */
101
101
  labels?: DataTablePaginationLabels;
102
102
  }
103
- export interface DataTableProps<TData> extends Omit<TableRootProps, 'children'>, Omit<TableProps, 'children'> {
103
+ export interface DataTableProps<TFeatures extends TableFeatures, TData extends RowData> extends Omit<TableRootProps, 'children'>, Omit<TableProps, 'children'> {
104
104
  /** The table instance from @tanstack/react-table */
105
- table: TableType<TData>;
105
+ table: TableType<TFeatures, TData>;
106
106
  /**
107
107
  * Optional loading state
108
108
  * @default false
@@ -129,18 +129,8 @@ export interface DataTableProps<TData> extends Omit<TableRootProps, 'children'>,
129
129
  */
130
130
  errorState?: React.ReactNode;
131
131
  /**
132
- * Pagination customization options, including page size options and labels
133
- * @default {
134
- * pageSizeOptions: [
135
- * { value: '10', label: '10' },
136
- * { value: '50', label: '50' },
137
- * { value: '100', label: '100' },
138
- * { value: '200', label: '200' },
139
- * ],
140
- * labels: {
141
- * itemLabel: 'unity:component:table:pagination:item',
142
- * },
143
- * }
132
+ * Optional pagination customization options, including page size options and labels.
133
+ * The pagination footer is rendered automatically when the table includes `rowPaginationFeature`.
144
134
  */
145
135
  pagination?: DataTablePaginationOptions;
146
136
  /**
@@ -166,7 +156,7 @@ export interface DataTableProps<TData> extends Omit<TableRootProps, 'children'>,
166
156
  * Render function for table rows
167
157
  * @param row - The row data of a given row in the table
168
158
  */
169
- children: (row: Row<TData>) => React.ReactNode;
159
+ children: (row: Row<TFeatures, TData>) => React.ReactNode;
170
160
  /**
171
161
  * Optional callback fired when the button is clicked in the error state.
172
162
  * Used to navigate away or retry when data loading fails.
@@ -228,14 +218,19 @@ export interface DataTableProps<TData> extends Omit<TableRootProps, 'children'>,
228
218
  * @example
229
219
  * ```tsx
230
220
  * import { DataTableRoot, DataTable, DataTableBulkActions, TableRow, TableCell } from '@payfit/unity-components'
231
- * import { flexRender, useReactTable, getCoreRowModel, getPaginationRowModel, createColumnHelper } from '@tanstack/react-table'
221
+ * import { createColumnHelper, createPaginatedRowModel, flexRender, stockFeatures, tableFeatures, useTable, type StockFeatures } from '@tanstack/react-table'
232
222
  * import { useState, useMemo } from 'react'
233
223
  *
224
+ * const features = tableFeatures({
225
+ * ...stockFeatures,
226
+ * paginatedRowModel: createPaginatedRowModel(),
227
+ * })
228
+ *
234
229
  * function EmployeeTable() {
235
230
  * const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 })
236
231
  * const [rowSelection, setRowSelection] = useState({})
237
232
  *
238
- * const columnHelper = createColumnHelper<Employee>()
233
+ * const columnHelper = createColumnHelper<StockFeatures, Employee>()
239
234
  *
240
235
  * // Define columns with optional width control for fixed layout
241
236
  * const columns = useMemo(() => [
@@ -258,15 +253,14 @@ export interface DataTableProps<TData> extends Omit<TableRootProps, 'children'>,
258
253
  * })
259
254
  * ], [])
260
255
  *
261
- * const table = useReactTable({
256
+ * const table = useTable({
257
+ * features,
262
258
  * data: employees,
263
259
  * columns,
264
260
  * getRowId: (row) => row.id,
265
261
  * state: { pagination, rowSelection },
266
262
  * onPaginationChange: setPagination,
267
263
  * onRowSelectionChange: setRowSelection,
268
- * getCoreRowModel: getCoreRowModel(),
269
- * getPaginationRowModel: getPaginationRowModel(),
270
264
  * enableRowSelection: true,
271
265
  * enableMultiRowSelection: true,
272
266
  * })
@@ -297,12 +291,13 @@ export interface DataTableProps<TData> extends Omit<TableRootProps, 'children'>,
297
291
  * @remarks
298
292
  * - For bulk actions, use DataTableBulkActions component alongside DataTable within DataTableRoot
299
293
  * - DataTableBulkActions provides the F6 keyboard shortcut for accessibility
294
+ * - Configure `rowPaginationFeature` on the Tanstack table instance to render the Unity pagination footer automatically; use the `pagination` prop only to customize it
300
295
  * - **Layout modes**: Use `layout="auto"` (default) for content-driven columns with scrolling, or `layout="fixed"` for predictable widths that fit the container
301
296
  * - **Setting column widths**: Add `headerClassName` to column meta with width classes (e.g., `'uy:w-[200px]'`, `'uy:w-1/3'`)
302
297
  * - **Fixed layout best practices**: Set explicit widths on column headers and use truncation for overflow content
303
298
  * - [API](https://unity-components.payfit.io/?path=/docs/data-datatable--docs) • [Demo](https://unity-components.payfit.io/?path=/docs/data-datatable--docs)
304
299
  */
305
- declare function DataTable<TData extends object>({ table, isLoading, error, emptyState, loadingState, errorState, pagination, minRows, maxRows, onPageChange: onPaginationChange, onPageHover: onPaginationPageHover, onPageSizeChange: onPaginationSizeChange, children, enableVirtualization, estimatedRowHeight, overscan, onErrorButtonPress, onNoDataButtonPress, noDataDescription, onNoSearchResultsButtonPress, ...rest }: DataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
300
+ declare function DataTable<TFeatures extends TableFeatures, TData extends RowData>({ table, isLoading, error, emptyState, loadingState, errorState, pagination, minRows, maxRows, onPageChange: onPaginationChange, onPageHover: onPaginationPageHover, onPageSizeChange: onPaginationSizeChange, children, enableVirtualization, estimatedRowHeight, overscan, onErrorButtonPress, onNoDataButtonPress, noDataDescription, onNoSearchResultsButtonPress, ...rest }: DataTableProps<TFeatures, TData>): import("react/jsx-runtime").JSX.Element;
306
301
  declare namespace DataTable {
307
302
  var displayName: string;
308
303
  }
@@ -1,102 +1,125 @@
1
1
  import { CircularIconButton as e } from "../icon-button/CircularIconButton.js";
2
- import { TableBody as t } from "../table/parts/TableBody.js";
3
- import { TableColumnHeader as n } from "../table/parts/TableColumnHeader.js";
4
- import { TableEmptyStateError as r, TableEmptyStateLoading as i, TableEmptyStateNoData as a, TableNoSearchResults as o } from "../table/parts/TableEmptyState.js";
5
- import { TableHeader as s } from "../table/parts/TableHeader.js";
6
- import { TablePagination as c } from "../table/parts/TablePagination.js";
7
- import { Table as l, TableRoot as u } from "../table/Table.js";
8
- import { ColumnSortHeader as d } from "./parts/ColumnSortHeader.js";
9
- import { useEffect as f, useRef as p } from "react";
10
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
11
- import { useId as _ } from "react-aria/useId";
12
- import { flexRender as v } from "@tanstack/react-table";
2
+ import { TablePagination as t } from "../table/parts/TablePagination.js";
3
+ import { Table as n, TableRoot as r } from "../table/Table.js";
4
+ import { TableBody as i } from "../table/parts/TableBody.js";
5
+ import { TableColumnHeader as a } from "../table/parts/TableColumnHeader.js";
6
+ import { TableEmptyStateError as o, TableEmptyStateLoading as s, TableEmptyStateNoData as c, TableNoSearchResults as l } from "../table/parts/TableEmptyState.js";
7
+ import { TableHeader as u } from "../table/parts/TableHeader.js";
8
+ import { getPaginationTable as d } from "./DataTablePagination.js";
9
+ import { ColumnSortHeader as f, isSortableHeader as p } from "./parts/ColumnSortHeader.js";
10
+ import { useMemo as m, useRef as h } from "react";
11
+ import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
12
+ import { useId as y } from "react-aria/useId";
13
+ import { flexRender as b } from "@tanstack/react-table";
14
+ import { useSelector as x } from "@tanstack/react-store";
13
15
  //#region src/components/data-table/DataTable.tsx
14
- var y = ({ children: t, columnNameId: n, helperText: r }) => r === void 0 ? /* @__PURE__ */ h(m, { children: t }) : /* @__PURE__ */ g("div", {
16
+ var S = ({ children: t, columnNameId: n, helperText: r }) => r === void 0 ? /* @__PURE__ */ _(g, { children: t }) : /* @__PURE__ */ v("div", {
15
17
  className: "uy:flex uy:gap-50 uy:items-center",
16
- children: [t, /* @__PURE__ */ h(e, {
18
+ children: [t, /* @__PURE__ */ _(e, {
17
19
  "aria-labelledby": n,
18
20
  icon: "QuestionOutlined",
19
21
  title: r,
20
22
  color: "content.neutral.lowest"
21
23
  })]
22
- });
23
- function b({ table: e, isLoading: m, error: b, emptyState: x, loadingState: S, errorState: C, pagination: w, minRows: T, maxRows: E, onPageChange: D, onPageHover: O, onPageSizeChange: k, children: A, enableVirtualization: j, estimatedRowHeight: M, overscan: N, onErrorButtonPress: P, onNoDataButtonPress: F, noDataDescription: I, onNoSearchResultsButtonPress: L, ...R }) {
24
- let z = p(null), B = _(), { pageIndex: V, pageSize: H } = e.getState().pagination;
25
- f(() => {
26
- z.current?.scrollToTop();
27
- }, [V, H]);
28
- let U = {
29
- label: R.label,
30
- description: R.description,
31
- isHorizontalScrollEnabled: R.isHorizontalScrollEnabled,
32
- layout: R.layout
24
+ }), C = ({ table: e, tableRef: n, pagination: r, onPageChange: i, onPageHover: a, onPageSizeChange: o }) => {
25
+ let s = e.atoms.pagination, { pageIndex: c, pageSize: l } = x(m(() => ({
26
+ get: () => s.get(),
27
+ subscribe: (e) => s.subscribe((t) => {
28
+ n.current?.scrollToTop(), e(t);
29
+ })
30
+ }), [s, n]));
31
+ return e.getPageCount() <= 0 ? null : /* @__PURE__ */ _(t, {
32
+ pageCount: e.getPageCount(),
33
+ rowCount: e.getRowCount(),
34
+ currentPage: c + 1,
35
+ rowsPerPage: l,
36
+ pageSizeOptions: r.pageSizeOptions,
37
+ onPageChange: (t, n, r) => {
38
+ e.setPageIndex(t - 1), i?.(t - 1, n, r);
39
+ },
40
+ onPageHover: (e) => {
41
+ a?.(e);
42
+ },
43
+ onPageSizeChange: (t) => {
44
+ e.setPageSize(t), o?.(t);
45
+ },
46
+ itemLabel: r.labels?.itemLabel
47
+ });
48
+ };
49
+ function w({ table: e, isLoading: t, error: m, emptyState: g, loadingState: x, errorState: w, pagination: T, minRows: E, maxRows: D, onPageChange: O, onPageHover: k, onPageSizeChange: A, children: j, enableVirtualization: M, estimatedRowHeight: N, overscan: P, onErrorButtonPress: F, onNoDataButtonPress: I, noDataDescription: L, onNoSearchResultsButtonPress: R, ...z }) {
50
+ let B = h(null), V = y(), H = d(e), U = {
51
+ label: z.label,
52
+ description: z.description,
53
+ isHorizontalScrollEnabled: z.isHorizontalScrollEnabled,
54
+ layout: z.layout
33
55
  }, W = () => {
34
- if (m) return S ?? /* @__PURE__ */ h(i, {});
35
- if (b) return C ?? /* @__PURE__ */ h(r, { onButtonPress: P });
56
+ if (t) return x ?? /* @__PURE__ */ _(s, {});
57
+ if (m) return w ?? /* @__PURE__ */ _(o, { onButtonPress: F });
36
58
  }, G = () => {
37
- let t = e.getState(), n = t.globalFilter !== void 0 && t.globalFilter !== "", r = t.columnFilters !== void 0 && t.columnFilters.length > 0;
59
+ let t = e.state, n = t.globalFilter !== void 0 && t.globalFilter !== "", r = t.columnFilters !== void 0 && t.columnFilters.length > 0;
38
60
  return n || r;
39
- }, K = () => m || b ? W() : e.getRowModel().rows.length === 0 ? G() && L ? /* @__PURE__ */ h(o, { onButtonPress: L }) : x ?? /* @__PURE__ */ h(a, {
40
- onButtonPress: F,
41
- description: I
42
- }) : x;
43
- return /* @__PURE__ */ g(u, {
44
- minRows: T,
45
- maxRows: E,
46
- children: [/* @__PURE__ */ g(l, {
47
- ref: z,
61
+ }, K = () => t || m ? W() : e.getRowModel().rows.length === 0 ? G() && R ? /* @__PURE__ */ _(l, { onButtonPress: R }) : g ?? /* @__PURE__ */ _(c, {
62
+ onButtonPress: I,
63
+ description: L
64
+ }) : g;
65
+ return /* @__PURE__ */ v(r, {
66
+ minRows: E,
67
+ maxRows: D,
68
+ children: [/* @__PURE__ */ v(n, {
69
+ ref: B,
48
70
  ...U,
49
- enableVirtualization: j,
50
- estimatedRowHeight: M,
51
- overscan: N,
52
- children: [/* @__PURE__ */ h(s, { children: e.getHeaderGroups().map((t) => t.headers.map((t) => {
53
- let r = `${B}-column-name-${t.column.columnDef.id}`;
54
- return /* @__PURE__ */ h(n, {
55
- isFocusable: t.column.columnDef.meta?.isFocusable,
56
- className: t.column.columnDef.meta?.headerClassName,
57
- children: e.getRowModel().rows.length > 0 && t.column.getCanSort() ? /* @__PURE__ */ h(d, {
58
- header: t,
59
- children: /* @__PURE__ */ h(y, {
60
- columnNameId: r,
61
- helperText: t.column.columnDef.meta?.helperText,
62
- children: /* @__PURE__ */ h("span", {
63
- id: r,
64
- children: v(t.column.columnDef.header, t.getContext())
71
+ enableVirtualization: M,
72
+ estimatedRowHeight: N,
73
+ overscan: P,
74
+ children: [/* @__PURE__ */ _(u, { children: e.getHeaderGroups().map((t) => {
75
+ let n = 0;
76
+ return /* @__PURE__ */ _("tr", { children: t.headers.map((r) => {
77
+ let i = n;
78
+ if (n += r.colSpan, r.rowSpan === 0) return null;
79
+ let o = !r.isPlaceholder || r.rowSpan > 1, s = `${V}-column-name-${r.column.id}`, c = r.column.columnDef.meta, l = p(r);
80
+ return /* @__PURE__ */ _(a, {
81
+ colIndex: i,
82
+ rowIndex: t.depth,
83
+ colSpan: r.colSpan,
84
+ rowSpan: r.rowSpan,
85
+ scope: r.colSpan > 1 ? "colgroup" : "col",
86
+ isFocusable: c?.isFocusable,
87
+ className: c?.headerClassName,
88
+ children: o && e.getRowModel().rows.length > 0 && l ? /* @__PURE__ */ _(f, {
89
+ header: r,
90
+ children: /* @__PURE__ */ _(S, {
91
+ columnNameId: s,
92
+ helperText: c?.helperText,
93
+ children: /* @__PURE__ */ _("span", {
94
+ id: s,
95
+ children: b(r.column.columnDef.header, r.getContext())
96
+ })
97
+ })
98
+ }) : o ? /* @__PURE__ */ _(S, {
99
+ columnNameId: s,
100
+ helperText: c?.helperText,
101
+ children: /* @__PURE__ */ _("span", {
102
+ id: s,
103
+ children: b(r.column.columnDef.header, r.getContext())
65
104
  })
66
- })
67
- }) : /* @__PURE__ */ h(y, {
68
- columnNameId: r,
69
- helperText: t.column.columnDef.meta?.helperText,
70
- children: /* @__PURE__ */ h("span", {
71
- id: r,
72
- children: v(t.column.columnDef.header, t.getContext())
73
- })
74
- })
75
- }, t.id);
76
- })) }), /* @__PURE__ */ h(t, {
105
+ }) : null
106
+ }, r.id);
107
+ }) }, t.id);
108
+ }) }), /* @__PURE__ */ _(i, {
77
109
  renderEmptyState: K,
78
110
  renderDataState: W,
79
- children: !m && !b && e.getRowModel().rows.map(A)
111
+ children: !t && !m && e.getRowModel().rows.map(j)
80
112
  })]
81
- }), e.getPageCount() > 0 && /* @__PURE__ */ h(c, {
82
- pageCount: e.getPageCount(),
83
- rowCount: e.getRowCount(),
84
- currentPage: V + 1,
85
- rowsPerPage: H,
86
- pageSizeOptions: w?.pageSizeOptions,
87
- onPageChange: (t, n, r) => {
88
- e.setPageIndex(t - 1), D?.(t - 1, n, r);
89
- },
90
- onPageHover: (e) => {
91
- O?.(e);
92
- },
93
- onPageSizeChange: (t) => {
94
- e.setPageSize(t), k?.(t);
95
- },
96
- itemLabel: w?.labels?.itemLabel
113
+ }), H !== void 0 && /* @__PURE__ */ _(C, {
114
+ table: H,
115
+ tableRef: B,
116
+ pagination: T ?? {},
117
+ onPageChange: O,
118
+ onPageHover: k,
119
+ onPageSizeChange: A
97
120
  })]
98
121
  });
99
122
  }
100
- b.displayName = "DataTable";
123
+ w.displayName = "DataTable";
101
124
  //#endregion
102
- export { b as DataTable };
125
+ export { w as DataTable };
@@ -0,0 +1,22 @@
1
+ import { ReactTable as TableType, RowData, TableFeatures } from '@tanstack/react-table';
2
+ type SelectionSource<T> = {
3
+ get: () => T;
4
+ subscribe: (listener: (value: T) => void) => {
5
+ unsubscribe: () => void;
6
+ };
7
+ };
8
+ type PaginationState = {
9
+ pageIndex: number;
10
+ pageSize: number;
11
+ };
12
+ export type PaginationCapableTable<TFeatures extends TableFeatures, TData extends RowData> = TableType<TFeatures, TData> & {
13
+ atoms: TableType<TFeatures, TData>['atoms'] & {
14
+ pagination: SelectionSource<PaginationState>;
15
+ };
16
+ getPageCount: () => number;
17
+ getRowCount: () => number;
18
+ setPageIndex: (pageIndex: number) => void;
19
+ setPageSize: (pageSize: number) => void;
20
+ };
21
+ export declare const getPaginationTable: <TFeatures extends TableFeatures, TData extends RowData>(table: TableType<TFeatures, TData>) => PaginationCapableTable<TFeatures, TData> | undefined;
22
+ export {};
@@ -0,0 +1,6 @@
1
+ //#region src/components/data-table/DataTablePagination.ts
2
+ var e = (e) => {
3
+ if (e.options.features.rowPaginationFeature !== void 0) return e;
4
+ };
5
+ //#endregion
6
+ export { e as getPaginationTable };
@@ -0,0 +1,15 @@
1
+ import { Employee } from './employee-data.js';
2
+ /**
3
+ * Creates optimized checkbox column with stable handlers to prevent unnecessary re-renders
4
+ */
5
+ export declare const createCheckboxColumn: () => import('@tanstack/react-table').DisplayColumnDef<import('@tanstack/react-table').StockFeatures, Employee, unknown>;
6
+ export declare const employeeColumns: import('@tanstack/react-table').ColumnDef<import('@tanstack/react-table').StockFeatures, Employee, any>[] & [import('@tanstack/react-table').AccessorKeyColumnDef<import('@tanstack/react-table').StockFeatures, Employee, string>, import('@tanstack/react-table').AccessorKeyColumnDef<import('@tanstack/react-table').StockFeatures, Employee, "Full-time" | "Part-time" | "Freelance" | "Contractor">, import('@tanstack/react-table').AccessorKeyColumnDef<import('@tanstack/react-table').StockFeatures, Employee, {
7
+ name: string;
8
+ position: string;
9
+ team: string;
10
+ } | null>, import('@tanstack/react-table').AccessorKeyColumnDef<import('@tanstack/react-table').StockFeatures, Employee, "active" | "inactive" | "onboarding" | "offboarding" | "retired">];
11
+ export declare const employeeColumnsWithCheckbox: import('@tanstack/react-table').ColumnDef<import('@tanstack/react-table').StockFeatures, Employee, any>[] & [import('@tanstack/react-table').DisplayColumnDef<import('@tanstack/react-table').StockFeatures, Employee, unknown>, ...(import('@tanstack/react-table').ColumnDef<import('@tanstack/react-table').StockFeatures, Employee, any> & (import('@tanstack/react-table').AccessorKeyColumnDef<import('@tanstack/react-table').StockFeatures, Employee, string> | import('@tanstack/react-table').AccessorKeyColumnDef<import('@tanstack/react-table').StockFeatures, Employee, "Full-time" | "Part-time" | "Freelance" | "Contractor"> | import('@tanstack/react-table').AccessorKeyColumnDef<import('@tanstack/react-table').StockFeatures, Employee, {
12
+ name: string;
13
+ position: string;
14
+ team: string;
15
+ } | null> | import('@tanstack/react-table').AccessorKeyColumnDef<import('@tanstack/react-table').StockFeatures, Employee, "active" | "inactive" | "onboarding" | "offboarding" | "retired">))[]];
@@ -1,7 +1,142 @@
1
1
  import { Employee } from './employee-data.js';
2
+ export declare const employeeTableFeatures: {
3
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
4
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
5
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
6
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
7
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
8
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
9
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
10
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
11
+ };
2
12
  /**
3
13
  * Creates optimized checkbox column with stable handlers to prevent unnecessary re-renders
4
14
  */
5
- export declare const createCheckboxColumn: () => import('@tanstack/react-table').DisplayColumnDef<Employee, unknown>;
6
- export declare const employeeColumns: (import('@tanstack/react-table').AccessorKeyColumnDefBase<Employee, string> & Partial<import('@tanstack/react-table').IdIdentifier<Employee, string>>)[];
7
- export declare const employeeColumnsWithCheckbox: ((import('@tanstack/react-table').AccessorKeyColumnDefBase<Employee, string> & Partial<import('@tanstack/react-table').IdIdentifier<Employee, string>>) | import('@tanstack/react-table').DisplayColumnDef<Employee, unknown>)[];
15
+ export declare const createCheckboxColumn: () => import('@tanstack/react-table').DisplayColumnDef<{
16
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
17
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
18
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
19
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
20
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
21
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
22
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
23
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
24
+ }, Employee, unknown>;
25
+ export declare const employeeColumns: import('@tanstack/react-table').ColumnDef<{
26
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
27
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
28
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
29
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
30
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
31
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
32
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
33
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
34
+ }, Employee, any>[] & [import('@tanstack/react-table').AccessorKeyColumnDef<{
35
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
36
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
37
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
38
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
39
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
40
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
41
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
42
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
43
+ }, Employee, string>, import('@tanstack/react-table').AccessorKeyColumnDef<{
44
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
45
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
46
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
47
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
48
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
49
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
50
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
51
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
52
+ }, Employee, "Full-time" | "Part-time" | "Freelance" | "Contractor">, import('@tanstack/react-table').AccessorKeyColumnDef<{
53
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
54
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
55
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
56
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
57
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
58
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
59
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
60
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
61
+ }, Employee, {
62
+ name: string;
63
+ position: string;
64
+ team: string;
65
+ } | null>, import('@tanstack/react-table').AccessorKeyColumnDef<{
66
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
67
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
68
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
69
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
70
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
71
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
72
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
73
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
74
+ }, Employee, "active" | "inactive" | "onboarding" | "offboarding" | "retired">];
75
+ export declare const employeeColumnsWithCheckbox: import('@tanstack/react-table').ColumnDef<{
76
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
77
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
78
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
79
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
80
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
81
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
82
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
83
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
84
+ }, Employee, any>[] & [import('@tanstack/react-table').DisplayColumnDef<{
85
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
86
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
87
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
88
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
89
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
90
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
91
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
92
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
93
+ }, Employee, unknown>, ...(import('@tanstack/react-table').ColumnDef<{
94
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
95
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
96
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
97
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
98
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
99
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
100
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
101
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
102
+ }, Employee, any> & (import('@tanstack/react-table').AccessorKeyColumnDef<{
103
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
104
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
105
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
106
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
107
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
108
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
109
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
110
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
111
+ }, Employee, string> | import('@tanstack/react-table').AccessorKeyColumnDef<{
112
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
113
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
114
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
115
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
116
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
117
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
118
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
119
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
120
+ }, Employee, "Full-time" | "Part-time" | "Freelance" | "Contractor"> | import('@tanstack/react-table').AccessorKeyColumnDef<{
121
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
122
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
123
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
124
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
125
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
126
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
127
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
128
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
129
+ }, Employee, {
130
+ name: string;
131
+ position: string;
132
+ team: string;
133
+ } | null> | import('@tanstack/react-table').AccessorKeyColumnDef<{
134
+ columnFilteringFeature: import('@tanstack/react-table').TableFeature;
135
+ columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
136
+ filteredRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
137
+ paginatedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
138
+ rowPaginationFeature: import('@tanstack/react-table').TableFeature;
139
+ rowSelectionFeature: import('@tanstack/react-table').TableFeature;
140
+ rowSortingFeature: import('@tanstack/react-table').TableFeature;
141
+ sortedRowModel: (table: import('@tanstack/react-table').Table<any, any>) => () => import('@tanstack/react-table').RowModel<any, any>;
142
+ }, Employee, "active" | "inactive" | "onboarding" | "offboarding" | "retired">))[]];
@@ -1,10 +1,14 @@
1
- import { Header } from '@tanstack/react-table';
1
+ import { Column_RowSorting, Header, RowData, TableFeatures } from '@tanstack/react-table';
2
2
  import { ActionableProps } from '../../actionable/Actionable.js';
3
- export interface ColumnSortHeaderProps<TData, TValue> extends ActionableProps {
4
- header: Header<TData, TValue>;
3
+ type SortableHeader<TFeatures extends TableFeatures, TData extends RowData, TValue> = Header<TFeatures, TData, TValue> & {
4
+ column: Header<TFeatures, TData, TValue>['column'] & Pick<Column_RowSorting<TFeatures, TData>, 'getCanSort' | 'getIsSorted' | 'getToggleSortingHandler'>;
5
+ };
6
+ declare function isSortableHeader<TFeatures extends TableFeatures, TData extends RowData, TValue>(header: Header<TFeatures, TData, TValue>): header is SortableHeader<TFeatures, TData, TValue>;
7
+ export interface ColumnSortHeaderProps<TFeatures extends TableFeatures, TData extends RowData, TValue> extends ActionableProps {
8
+ header: SortableHeader<TFeatures, TData, TValue>;
5
9
  }
6
- declare function ColumnSortHeader<TData, TValue>({ children, header, ...props }: ColumnSortHeaderProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
10
+ declare function ColumnSortHeader<TFeatures extends TableFeatures, TData extends RowData, TValue>({ children, header, ...props }: ColumnSortHeaderProps<TFeatures, TData, TValue>): import("react/jsx-runtime").JSX.Element;
7
11
  declare namespace ColumnSortHeader {
8
12
  var displayName: string;
9
13
  }
10
- export { ColumnSortHeader };
14
+ export { ColumnSortHeader, isSortableHeader };
@@ -3,23 +3,29 @@ import { Icon as t } from "../../icon/Icon.js";
3
3
  import "react";
4
4
  import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
5
5
  //#region src/components/data-table/parts/ColumnSortHeader.tsx
6
- function a({ children: a, header: o, ...s }) {
6
+ function a(e) {
7
+ return "getCanSort" in e.column && typeof e.column.getCanSort == "function" && e.column.getCanSort();
8
+ }
9
+ function o({ children: a, header: o, ...s }) {
7
10
  return /* @__PURE__ */ r(e, {
8
11
  ...s,
9
12
  className: "uy:flex uy:items-center uy:gap-50",
10
- onPress: () => {
11
- o.column.getCanSort() && o.column.toggleSorting();
13
+ onPress: (e) => {
14
+ o.column.getToggleSortingHandler()?.(e);
12
15
  },
13
- children: ({ isHovered: e }) => /* @__PURE__ */ i(n, { children: [a, o.column.getCanSort() && (o.column.getIsSorted() || e) ? /* @__PURE__ */ r(t, {
14
- src: o.column.getIsSorted() === "asc" ? "ArrowUpOutlined" : "ArrowDownOutlined",
15
- role: "presentation",
16
- size: 20
17
- }) : /* @__PURE__ */ r("span", {
18
- "aria-hidden": "true",
19
- className: "uy:size-250 uy:block"
20
- })] })
16
+ children: ({ isHovered: e }) => {
17
+ let s = o.column.getIsSorted();
18
+ return /* @__PURE__ */ i(n, { children: [a, o.column.getCanSort() && (s || e) ? /* @__PURE__ */ r(t, {
19
+ src: s === "asc" ? "ArrowUpOutlined" : "ArrowDownOutlined",
20
+ role: "presentation",
21
+ size: 20
22
+ }) : /* @__PURE__ */ r("span", {
23
+ "aria-hidden": "true",
24
+ className: "uy:size-250 uy:block"
25
+ })] });
26
+ }
21
27
  });
22
28
  }
23
- a.displayName = "ColumnSortHeader";
29
+ o.displayName = "ColumnSortHeader";
24
30
  //#endregion
25
- export { a as ColumnSortHeader };
31
+ export { o as ColumnSortHeader, a as isSortableHeader };