@propellerads/table 5.1.1 → 6.0.1

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.d.ts CHANGED
@@ -1,22 +1,116 @@
1
- import React, { FunctionComponent } from 'react';
2
- import { TableState } from 'react-table';
3
- import { DefaultObject, FOOTER_PLACEMENT, TableProps } from './types';
4
- export declare const defaultProps: {
5
- hasDefaultPagination: boolean;
6
- isLoading: boolean;
7
- footerPlacement: FOOTER_PLACEMENT[];
8
- loadingMessage: string;
9
- labelPerPage: string;
10
- parentElementId: string;
11
- tableContentId: string;
12
- showLoadingState: boolean;
13
- initialState: Partial<TableState<Record<string, unknown>>>;
14
- LoadingCellComponent: React.FunctionComponent<Record<string, unknown>>;
15
- getRowPreProps: () => DefaultObject;
16
- isEnableRowSelect: (_original?: Record<string, unknown> | undefined) => boolean;
17
- selectColumnProps: {};
18
- noDataMessage: string;
19
- };
20
- declare type DefaultProps = Readonly<typeof defaultProps>;
21
- declare const Table: FunctionComponent<TableProps & DefaultProps>;
22
- export { Table };
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as styled_components_dist_types from 'styled-components/dist/types';
3
+ import * as styled_components from 'styled-components';
4
+ import * as react from 'react';
5
+ import { CSSProperties, ComponentPropsWithoutRef, ReactNode, ComponentType, ReactElement } from 'react';
6
+ import { RowData, Cell, HeaderGroup, Header, ColumnDef, Row, TableState, VisibilityState, SortingState } from '@tanstack/react-table';
7
+ export { SortingState, VisibilityState } from '@tanstack/react-table';
8
+
9
+ declare module '@tanstack/react-table' {
10
+ interface ColumnMeta<TData extends RowData, TValue> {
11
+ align?: CSSProperties['textAlign'];
12
+ }
13
+ }
14
+ type DefaultObject = Record<string, unknown>;
15
+ type LoadingState<TData extends DefaultObject = DefaultObject> = {
16
+ loadingColumns?: ColumnDef<TData>[];
17
+ loadingData: TData[];
18
+ };
19
+ type RowPreProps = ComponentPropsWithoutRef<'div'> & {
20
+ isDelimiterTd?: boolean;
21
+ };
22
+ declare const FooterPlacement: {
23
+ readonly Top: "top";
24
+ readonly Bottom: "bottom";
25
+ };
26
+ type FooterPlacement = (typeof FooterPlacement)[keyof typeof FooterPlacement];
27
+ type PaginationProps = {
28
+ paginationAmount?: ReactNode;
29
+ parentElementId: string;
30
+ labelPerPage?: string;
31
+ pageSizes?: Array<string | number>;
32
+ pageIndex: number;
33
+ perPage: number;
34
+ totalPages: number;
35
+ totalItems: number;
36
+ canNextPage: boolean;
37
+ canPreviousPage: boolean;
38
+ nextPageHandler: () => void;
39
+ previousPageHandler: () => void;
40
+ setPageSize: (size: number) => void;
41
+ gotoPage: (page: number) => void;
42
+ };
43
+ type ControlledPagination = {
44
+ paginationAmount?: ReactNode;
45
+ pageSize: number;
46
+ pageIndex: number;
47
+ pageCount: number;
48
+ };
49
+ type HeaderGroupPropsGetter<TData extends DefaultObject = DefaultObject> = (headerGroup: HeaderGroup<TData>) => ComponentPropsWithoutRef<'div'>;
50
+ type HeaderPropsGetter<TData extends DefaultObject = DefaultObject> = (header: Header<TData, unknown>) => ComponentPropsWithoutRef<'div'>;
51
+ type RowPropsGetter<TData extends DefaultObject = DefaultObject> = (row: Row<TData>) => ComponentPropsWithoutRef<'div'>;
52
+ type CellPropsGetter<TData extends DefaultObject = DefaultObject> = (cell: Cell<TData, unknown>) => ComponentPropsWithoutRef<'div'>;
53
+ type SelectColumnProps<TData extends DefaultObject = DefaultObject> = Pick<ColumnDef<TData>, 'size' | 'minSize' | 'maxSize' | 'meta' | 'enableHiding'>;
54
+ type TableProps<TData extends DefaultObject = DefaultObject> = {
55
+ columns: ColumnDef<TData>[];
56
+ data: TData[];
57
+ totalItems?: number;
58
+ PaginationComponent?: ComponentType<PaginationProps>;
59
+ initialState?: Partial<TableState> & {
60
+ columnVisibility?: VisibilityState;
61
+ };
62
+ fetchData?: (params: {
63
+ pageIndex: number;
64
+ pageSize: number;
65
+ }) => void;
66
+ onSortedChange?: (sorting: SortingState) => void;
67
+ isLoading?: boolean;
68
+ footerPlacement?: FooterPlacement[];
69
+ hasDefaultPagination?: boolean;
70
+ onSelectRowsChange?: (rows: TData[]) => void;
71
+ controlledPagination?: ControlledPagination;
72
+ loadingMessage?: string;
73
+ labelPerPage?: string;
74
+ parentElementId?: string;
75
+ tableContentId?: string;
76
+ getRowPreProps?: (row: Row<TData>) => RowPreProps;
77
+ getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string;
78
+ getSubRows?: (originalRow: TData, index: number) => TData[] | undefined;
79
+ getTableProps?: () => ComponentPropsWithoutRef<'div'>;
80
+ getHeaderGroupProps?: HeaderGroupPropsGetter<TData>;
81
+ getHeaderProps?: HeaderPropsGetter<TData>;
82
+ getRowProps?: RowPropsGetter<TData>;
83
+ getCellProps?: CellPropsGetter<TData>;
84
+ getFooterProps?: HeaderPropsGetter<TData>;
85
+ getFooterGroupProps?: HeaderGroupPropsGetter<TData>;
86
+ showLoadingState?: boolean;
87
+ LoadingCellComponent?: ComponentType;
88
+ noDataMessage?: ReactNode;
89
+ rowSubComponent?: (row: Row<TData>) => ReactElement;
90
+ isEnableRowSelect?: (original: TData) => boolean;
91
+ selectColumnProps?: Partial<SelectColumnProps<TData>>;
92
+ };
93
+ type StandardColumn<TData extends DefaultObject = DefaultObject> = ColumnDef<TData>;
94
+ type StandardRow<TData extends DefaultObject = DefaultObject> = Row<TData>;
95
+ type StandardCell<TData extends DefaultObject = DefaultObject> = Cell<TData, unknown>;
96
+
97
+ type TableRowData = DefaultObject & RowData;
98
+ declare const defaultProps: {
99
+ hasDefaultPagination: boolean;
100
+ isLoading: boolean;
101
+ footerPlacement: never[];
102
+ loadingMessage: string;
103
+ labelPerPage: string;
104
+ parentElementId: string;
105
+ tableContentId: string;
106
+ showLoadingState: boolean;
107
+ LoadingCellComponent: styled_components_dist_types.IStyledComponentBase<"web", styled_components.FastOmit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
108
+ getRowPreProps: () => RowPreProps;
109
+ isEnableRowSelect: () => boolean;
110
+ selectColumnProps: {};
111
+ noDataMessage: string;
112
+ };
113
+ declare const Table: <TData extends TableRowData = DefaultObject>({ columns, data, totalItems, fetchData, controlledPagination, initialState, isLoading, loadingMessage, labelPerPage, footerPlacement, onSortedChange, hasDefaultPagination, onSelectRowsChange, parentElementId, tableContentId, LoadingCellComponent, PaginationComponent, getRowPreProps, getRowId, getSubRows, getTableProps, getHeaderGroupProps, getHeaderProps, getRowProps, getCellProps, getFooterProps, getFooterGroupProps, showLoadingState, noDataMessage, rowSubComponent, isEnableRowSelect, selectColumnProps, }: TableProps<TData>) => react_jsx_runtime.JSX.Element;
114
+
115
+ export { Table as default, defaultProps };
116
+ export type { CellPropsGetter, ControlledPagination, DefaultObject, HeaderGroupPropsGetter, HeaderPropsGetter, LoadingState, PaginationProps, RowPreProps, RowPropsGetter, SelectColumnProps, StandardCell, StandardColumn, StandardRow, TableProps };
package/dist/index.js CHANGED
@@ -1,8 +1,494 @@
1
+ import { ArrowDown as e, ArrowUp as t, Color as n, Size as r } from "@propellerads/icon";
2
+ import i from "@propellerads/input-checkbox";
3
+ import { Fragment as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
4
+ import { flexRender as u, getCoreRowModel as ee, getExpandedRowModel as te, getPaginationRowModel as ne, getSortedRowModel as re, useReactTable as ie } from "@tanstack/react-table";
5
+ import d, { css as f, keyframes as p } from "styled-components";
6
+ import { black as m, fontNormal as ae, gray80 as h, gray95 as g, spacing as _, white as v } from "@propellerads/stylevariables";
7
+ import { jsx as y, jsxs as b } from "react/jsx-runtime";
8
+ //#region src/propsGetter.tsx
9
+ var x = (e) => e.column.columnDef.meta?.align, oe = (e) => e.column.columnDef.meta?.align, S = p`
10
+ from {
11
+ background-position-x: 0;
12
+ }
13
+ 50% {
14
+ background-position-x: 100%;
15
+ }
16
+ 100% {
17
+ background-position-x: 0;
18
+ }
19
+ `, se = d.div`
20
+ display: block;
21
+ position: absolute;
22
+ left: 0;
23
+ right: 0;
24
+ top: 0;
25
+ bottom: 0;
26
+ background: rgba(255, 255, 255, 0.8);
27
+ transition: all 0.3s ease;
28
+ z-index: -1;
29
+ opacity: 0;
30
+ pointer-events: none;
1
31
 
2
- 'use strict'
32
+ ${({ $isLoading: e }) => e && f`
33
+ opacity: 1;
34
+ z-index: 2;
35
+ pointer-events: all;
36
+ `}
37
+ `, ce = d.div`
38
+ position: absolute;
39
+ display: block;
40
+ text-align: center;
41
+ width: 100%;
42
+ top: 50%;
43
+ left: 0;
44
+ color: rgba(0, 0, 0, 0.6);
45
+ transform: translateY(-52%);
46
+ transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
47
+ `, le = d.div`
48
+ position: relative;
49
+ overflow: hidden;
3
50
 
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./table.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./table.cjs.development.js')
8
- }
51
+ &::before {
52
+ bottom: 10px;
53
+ content: '';
54
+ opacity: 0;
55
+ pointer-events: none;
56
+ position: absolute;
57
+ width: 10px;
58
+ height: 100%;
59
+ top: 0;
60
+ left: -10px;
61
+ box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.2);
62
+ transition: 0.3s opacity;
63
+ }
64
+
65
+ &::after {
66
+ bottom: 10px;
67
+ content: '';
68
+ opacity: 0;
69
+ pointer-events: none;
70
+ width: 10px;
71
+ height: 100%;
72
+ position: absolute;
73
+ top: 0;
74
+ right: -10px;
75
+ box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.2);
76
+ transition: 0.3s opacity;
77
+ }
78
+
79
+ &.shadow_left {
80
+ &::before {
81
+ opacity: 1 !important;
82
+ }
83
+ }
84
+
85
+ &.shadow_right {
86
+ &::after {
87
+ opacity: 1 !important;
88
+ }
89
+ }
90
+ `, ue = d.div`
91
+ font-size: ${ae}px;
92
+ position: relative;
93
+ display: flex;
94
+ flex-direction: column;
95
+ border: 0;
96
+ `, de = d.div`
97
+ display: block;
98
+ max-width: 100%;
99
+ overflow-x: scroll;
100
+ overflow-y: hidden;
101
+ `, fe = d.div`
102
+ flex: auto 1;
103
+ display: flex;
104
+ flex-direction: column;
105
+ align-items: stretch;
106
+ border-collapse: collapse;
107
+ `, C = d.div`
108
+ display: inline-flex;
109
+ `, w = d.div`
110
+ flex: 0 0 ${({ $size: e }) => e ?? 50}px;
111
+ width: ${({ $size: e }) => e ?? 50}px;
112
+ white-space: nowrap;
113
+ text-overflow: ellipsis;
114
+ line-height: 1.3rem;
115
+ padding: 7px 4px;
116
+ overflow: hidden;
117
+ transition: width 0.3s ease 0s, min-width, padding, opacity;
118
+
119
+ ${({ $align: e }) => e && f`
120
+ text-align: ${e};
121
+ `}
122
+ `, T = d.div`
123
+ width: 100%;
124
+ height: ${_ * 4}px;
125
+ background: linear-gradient(to left, ${g}, ${v}, ${g});
126
+ background-size: 200% 200%;
127
+ animation: ${S} 1.6s linear infinite;
128
+ `, E = d.div`
129
+ flex: 0 0 ${({ $size: e }) => e ?? 50}px;
130
+ width: ${({ $size: e }) => e ?? 50}px;
131
+ padding: 0 4px;
132
+ line-height: normal;
133
+ position: relative;
134
+ transition: box-shadow 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0s;
135
+ color: rgb(0, 0, 0);
136
+ font-weight: 500;
137
+ outline: none;
138
+
139
+ ${({ $align: e }) => e && f`
140
+ text-align: ${e};
141
+ `}
142
+ `, pe = d.div`
143
+ flex: 1 0 auto;
144
+ display: flex;
145
+ flex-direction: column;
146
+ user-select: none;
147
+
148
+ ${E}, ${w} {
149
+ padding: 0 4px;
150
+ line-height: normal;
151
+ position: relative;
152
+ transition: box-shadow 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
153
+ color: ${m};
154
+ font-weight: 500;
155
+ outline: none;
156
+ }
157
+ `, D = d.div`
158
+ display: flex;
159
+ flex: 1 0 auto;
160
+ box-shadow: inset 0 -1px 0 0 ${g};
161
+ min-width: 100%;
162
+ width: max-content;
163
+ `, O = d.div`
164
+ display: flex;
165
+ flex: 1 0 auto;
166
+ padding: 0;
167
+ align-items: center;
168
+ `, me = d.div`
169
+ border-top: 1px solid ${h};
170
+ margin-top: ${_ * 2}px;
171
+ min-width: 100%;
172
+ width: max-content;
173
+ `, k = d.div`
174
+ background: ${g};
175
+ flex: 1 0 auto;
176
+ display: flex;
177
+ flex-direction: column;
178
+ `, A = d.div`
179
+ display: inline-block;
180
+ position: absolute;
181
+ right: 5px;
182
+ top: 0;
183
+ z-index: 1;
184
+ touch-action: none;
185
+
186
+ &:after {
187
+ content: '↔';
188
+ position: absolute;
189
+ right: 0;
190
+ top: 0;
191
+ }
192
+ `, j = {
193
+ Top: "top",
194
+ Bottom: "bottom"
195
+ }, he = (e, t, n, r, i) => ({
196
+ loadingColumns: s(() => e && t ? r.map((e) => ({
197
+ ...e,
198
+ cell: () => /* @__PURE__ */ y(i, {})
199
+ })) : [], [
200
+ r,
201
+ t,
202
+ e
203
+ ]),
204
+ loadingData: s(() => {
205
+ if (e && t && r && r.length > 0) {
206
+ let e = {}, t = [];
207
+ for (let t = 0; t < r.length; t += 1) e[`empty_${t}`] = "";
208
+ for (let r = 0; r < n; r += 1) t.push(e);
209
+ return t;
210
+ }
211
+ return [];
212
+ }, [
213
+ r,
214
+ t,
215
+ n,
216
+ e
217
+ ])
218
+ }), M = {
219
+ Left: "shadow_left",
220
+ Right: "shadow_right"
221
+ }, N = (e, t) => {
222
+ let { classList: n } = e;
223
+ n.remove(M.Left, M.Right), n.add(...t);
224
+ }, P = (e, t) => {
225
+ if (!e || !t) return;
226
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = [], a = Math.floor(n.left), o = Math.floor(n.right), s = Math.floor(r.left), c = Math.floor(r.right);
227
+ a < s && i.push(M.Left), o > c && i.push(M.Right), N(t, i);
228
+ }, ge = (e, t) => {
229
+ o(() => {
230
+ let n = !1, r = () => {
231
+ n ||= (window.requestAnimationFrame(() => {
232
+ P(e.current, t.current), n = !1;
233
+ }), !0);
234
+ };
235
+ return P(e.current, t.current), e?.current?.addEventListener("mousewheel", r), window.addEventListener("resize", r), () => {
236
+ e?.current?.removeEventListener("mousewheel", r), window.removeEventListener("resize", r);
237
+ };
238
+ }, [e.current, t.current]);
239
+ }, F = () => !0, I = {}, L = () => ({}), _e = (e) => {
240
+ let { subRows: t } = e;
241
+ if (Array.isArray(t)) return t;
242
+ }, R = {
243
+ hasDefaultPagination: !1,
244
+ isLoading: !1,
245
+ footerPlacement: [],
246
+ loadingMessage: "loading...",
247
+ labelPerPage: "Show rows",
248
+ parentElementId: "parent-element",
249
+ tableContentId: "",
250
+ showLoadingState: !1,
251
+ LoadingCellComponent: T,
252
+ getRowPreProps: L,
253
+ isEnableRowSelect: F,
254
+ selectColumnProps: I,
255
+ noDataMessage: ""
256
+ }, ve = 0, z = 10, ye = (i) => {
257
+ let a = i.column.getIsSorted(), o = u(i.column.columnDef.header, i.getContext());
258
+ return a === "desc" ? /* @__PURE__ */ b(C, { children: [o, /* @__PURE__ */ y(t, {
259
+ size: r.Small,
260
+ color: n.GrayDark
261
+ })] }) : a === "asc" ? /* @__PURE__ */ b(C, { children: [o, /* @__PURE__ */ y(e, {
262
+ size: r.Small,
263
+ color: n.GrayDark
264
+ })] }) : o;
265
+ }, be = (e) => e.column.getCanResize() ? /* @__PURE__ */ y(A, {
266
+ onMouseDown: e.getResizeHandler(),
267
+ onTouchStart: e.getResizeHandler(),
268
+ onClick: (e) => {
269
+ e.preventDefault(), e.stopPropagation();
270
+ }
271
+ }) : null, B = ({ columns: e, data: t, totalItems: n, fetchData: r, controlledPagination: d, initialState: f, isLoading: p = R.isLoading, loadingMessage: m = R.loadingMessage, labelPerPage: ae = R.labelPerPage, footerPlacement: h = R.footerPlacement, onSortedChange: g, hasDefaultPagination: _ = R.hasDefaultPagination, onSelectRowsChange: v, parentElementId: S = R.parentElementId, tableContentId: C = R.tableContentId, LoadingCellComponent: T = R.LoadingCellComponent, PaginationComponent: A, getRowPreProps: M = L, getRowId: N, getSubRows: P = _e, getTableProps: F, getHeaderGroupProps: I, getHeaderProps: B, getRowProps: V, getCellProps: H, getFooterProps: U, getFooterGroupProps: W, showLoadingState: G = R.showLoadingState, noDataMessage: xe = R.noDataMessage, rowSubComponent: K, isEnableRowSelect: q = R.isEnableRowSelect, selectColumnProps: Se = R.selectColumnProps }) => {
272
+ let J = s(() => e, [e]), Y = G && p, X = !Y && typeof v == "function", Ce = typeof g == "function", Z = !!(r && d && Object.keys(d).length > 0);
273
+ if (_ && Z) throw Error("You have to pass either hasDefaultPagination true boolean prop or pass fetchData callback and controlledPagination data");
274
+ if (Z && d?.pageCount === void 0) throw Error("You have to pass pageCount in controlledPagination data");
275
+ let [we, Te] = l([]), [Ee, De] = l({}), [Oe, ke] = l({
276
+ pageIndex: ve,
277
+ pageSize: z
278
+ }), [Ae, je] = l(f?.columnVisibility ?? {});
279
+ o(() => {
280
+ f?.columnVisibility && je(f.columnVisibility);
281
+ }, [f?.columnVisibility]);
282
+ let Q = s(() => ({
283
+ id: "selection",
284
+ enableSorting: !1,
285
+ header: ({ table: e }) => {
286
+ let t = e.getRowModel().rows.map((e) => e.original).filter(q).length === 0;
287
+ return /* @__PURE__ */ y(i, {
288
+ elementId: "all",
289
+ onChange: e.toggleAllPageRowsSelected,
290
+ isChecked: e.getIsAllPageRowsSelected(),
291
+ isDisabled: t
292
+ });
293
+ },
294
+ cell: ({ row: e }) => {
295
+ let t = q(e.original);
296
+ return /* @__PURE__ */ y(i, {
297
+ elementId: e.id,
298
+ onChange: e.toggleSelected,
299
+ isDisabled: !t,
300
+ isChecked: t && e.getIsSelected()
301
+ });
302
+ },
303
+ ...Se
304
+ }), [q, Se]), { loadingColumns: Me, loadingData: Ne } = he(G, p, Z ? d?.pageSize ?? z : Oe.pageSize, J, T), Pe = s(() => {
305
+ let e = Y ? Me ?? [] : J;
306
+ return X ? [Q, ...e] : e;
307
+ }, [
308
+ Y,
309
+ Me,
310
+ J,
311
+ X,
312
+ Q
313
+ ]), Fe = Y ? Ne : t, Ie = Z && d ? {
314
+ pageIndex: d.pageIndex,
315
+ pageSize: d.pageSize
316
+ } : Oe, $ = ie({
317
+ columns: Pe,
318
+ data: Fe,
319
+ getCoreRowModel: ee(),
320
+ getSortedRowModel: re(),
321
+ getExpandedRowModel: te(),
322
+ ..._ || Z ? { getPaginationRowModel: ne() } : {},
323
+ enableRowSelection: X ? (e) => q(e.original) : !1,
324
+ getRowCanExpand: (e) => !Y && (!!K || e.subRows.length > 0),
325
+ getRowId: N,
326
+ getSubRows: P,
327
+ state: {
328
+ sorting: we,
329
+ rowSelection: Ee,
330
+ pagination: Ie,
331
+ columnVisibility: Ae
332
+ },
333
+ onSortingChange: Te,
334
+ onRowSelectionChange: De,
335
+ onPaginationChange: Z ? void 0 : ke,
336
+ onColumnVisibilityChange: je,
337
+ manualSorting: Ce,
338
+ manualPagination: Z ? !0 : void 0,
339
+ pageCount: Z ? d?.pageCount : void 0,
340
+ enableSortingRemoval: !1,
341
+ enableMultiSort: !1,
342
+ enableColumnResizing: !0,
343
+ columnResizeMode: "onChange",
344
+ defaultColumn: { enableResizing: !1 }
345
+ }), Le = c(null), Re = c(null);
346
+ ge(Le, Re), o(() => {
347
+ if (X) {
348
+ let e = $.getSelectedRowModel().flatRows.map((e) => e.original).filter(q);
349
+ v?.(e);
350
+ }
351
+ }, [Ee, X]);
352
+ let ze = null;
353
+ if (Z || _) {
354
+ let { pageIndex: e, pageSize: i } = $.getState().pagination, a = {
355
+ setPageSize: $.setPageSize,
356
+ gotoPage: $.setPageIndex,
357
+ canNextPage: $.getCanNextPage(),
358
+ canPreviousPage: $.getCanPreviousPage(),
359
+ parentElementId: S,
360
+ labelPerPage: ae,
361
+ pageIndex: e,
362
+ previousPageHandler: $.previousPage,
363
+ nextPageHandler: $.nextPage,
364
+ totalPages: $.getPageCount(),
365
+ perPage: i,
366
+ totalItems: n ?? t.length
367
+ };
368
+ Z && d && (a.canNextPage = d.pageIndex + 1 !== a.totalPages, a.canPreviousPage = d.pageIndex !== 0, a.pageIndex = d.pageIndex, a.perPage = d.pageSize, a.setPageSize = (e) => {
369
+ r?.({
370
+ pageIndex: d.pageIndex,
371
+ pageSize: e
372
+ });
373
+ }, a.gotoPage = (e) => {
374
+ r?.({
375
+ pageIndex: e,
376
+ pageSize: d.pageSize
377
+ });
378
+ }, a.nextPageHandler = () => {
379
+ r?.({
380
+ pageIndex: d.pageIndex + 1,
381
+ pageSize: d.pageSize
382
+ });
383
+ }, a.previousPageHandler = () => {
384
+ r?.({
385
+ pageIndex: d.pageIndex - 1,
386
+ pageSize: d.pageSize
387
+ });
388
+ }, d.paginationAmount && (a.paginationAmount = d.paginationAmount)), ze = A ? /* @__PURE__ */ y(A, { ...a }) : null;
389
+ }
390
+ let Be = (e) => {
391
+ if (!e.column.getCanSort()) return;
392
+ let t = e.column.getIsSorted(), n = [{
393
+ id: e.column.id,
394
+ desc: t !== "desc"
395
+ }];
396
+ Ce && g?.(n), Te(n);
397
+ }, Ve = $.getHeaderGroups(), He = $.getFooterGroups(), Ue = $.getRowModel().rows;
398
+ return /* @__PURE__ */ b(ue, {
399
+ className: "table-root",
400
+ children: [
401
+ /* @__PURE__ */ y(se, {
402
+ $isLoading: !G && p,
403
+ className: "table-loading",
404
+ children: /* @__PURE__ */ y(ce, { children: m })
405
+ }),
406
+ /* @__PURE__ */ y(le, {
407
+ ref: Re,
408
+ className: "table-wrapper",
409
+ children: /* @__PURE__ */ y(de, {
410
+ id: C,
411
+ className: "table-content",
412
+ children: /* @__PURE__ */ b(fe, {
413
+ ...F?.(),
414
+ ref: Le,
415
+ children: [
416
+ /* @__PURE__ */ y(pe, {
417
+ className: "table-head",
418
+ "data-role": "table-head",
419
+ children: Ve.map((e) => /* @__PURE__ */ y(O, {
420
+ ...I?.(e),
421
+ children: e.headers.map((e) => /* @__PURE__ */ b(E, {
422
+ $size: e.getSize(),
423
+ onClick: () => Be(e),
424
+ ...B?.(e),
425
+ children: [e.isPlaceholder ? null : ye(e), be(e)]
426
+ }, e.id))
427
+ }, e.id))
428
+ }),
429
+ h.includes(j.Top) && /* @__PURE__ */ y(k, {
430
+ className: "table-footer-top",
431
+ "data-role": "table-footer-top",
432
+ children: He.map((e) => /* @__PURE__ */ y(O, {
433
+ ...W?.(e),
434
+ children: e.headers.map((e) => /* @__PURE__ */ y(w, {
435
+ $size: e.getSize(),
436
+ $align: x(e),
437
+ ...U?.(e),
438
+ children: e.isPlaceholder ? null : u(e.column.columnDef.footer, e.getContext())
439
+ }, e.id))
440
+ }, e.id))
441
+ }),
442
+ /* @__PURE__ */ y(me, {
443
+ className: "table-body",
444
+ "data-role": "table-body",
445
+ children: Ue.map((e) => {
446
+ let { isDelimiterTd: t } = Y ? L() : M(e);
447
+ if (t) {
448
+ let t = e.getVisibleCells()[0];
449
+ return t ? /* @__PURE__ */ b(a, { children: [/* @__PURE__ */ y(D, { children: /* @__PURE__ */ y(O, {
450
+ ...Y ? void 0 : V?.(e),
451
+ children: /* @__PURE__ */ y(w, {
452
+ style: { flex: "1 0 0%" },
453
+ ...Y ? void 0 : H?.(t),
454
+ children: /* @__PURE__ */ y("strong", { children: u(t.column.columnDef.cell, t.getContext()) })
455
+ })
456
+ }) }), !Y && e.getIsExpanded() && K && K(e)] }, `group_${e.index}`) : null;
457
+ }
458
+ return /* @__PURE__ */ b(a, { children: [/* @__PURE__ */ y(D, { children: /* @__PURE__ */ y(O, {
459
+ ...Y ? void 0 : V?.(e),
460
+ children: e.getVisibleCells().map((e) => /* @__PURE__ */ y(w, {
461
+ $size: e.column.getSize(),
462
+ $align: oe(e),
463
+ ...Y ? void 0 : H?.(e),
464
+ children: u(e.column.columnDef.cell, e.getContext())
465
+ }, e.id))
466
+ }) }), !Y && e.getIsExpanded() && K && K(e)] }, `group_${e.index}`);
467
+ })
468
+ }),
469
+ h.includes(j.Bottom) && /* @__PURE__ */ y(k, {
470
+ className: "table-footer-bottom",
471
+ "data-role": "table-footer-bottom",
472
+ children: He.map((e) => /* @__PURE__ */ y(O, {
473
+ ...W?.(e),
474
+ children: e.headers.map((e) => /* @__PURE__ */ y(w, {
475
+ $size: e.getSize(),
476
+ $align: x(e),
477
+ ...U?.(e),
478
+ children: e.isPlaceholder ? null : u(e.column.columnDef.footer, e.getContext())
479
+ }, e.id))
480
+ }, e.id))
481
+ })
482
+ ]
483
+ })
484
+ })
485
+ }),
486
+ !p && !t.length && xe,
487
+ ze
488
+ ]
489
+ });
490
+ };
491
+ //#endregion
492
+ export { B as default, R as defaultProps };
493
+
494
+ //# sourceMappingURL=index.js.map