@konstructio/ui 0.1.2-alpha.15 → 0.1.2-alpha.16
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.
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as r, jsxs as m } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as
|
|
2
|
+
import { useMemo as I } from "react";
|
|
3
3
|
import { cn as s } from "../../utils/index.js";
|
|
4
|
-
import { TableProvider as
|
|
5
|
-
import { Filter as
|
|
6
|
-
import { Header as
|
|
7
|
-
import { Body as
|
|
8
|
-
import { Pagination as
|
|
9
|
-
import { TruncateText as
|
|
10
|
-
import { Actions as
|
|
11
|
-
const
|
|
4
|
+
import { TableProvider as K } from "./contexts/table.provider.js";
|
|
5
|
+
import { Filter as M } from "./components/Filter/Filter.js";
|
|
6
|
+
import { Header as P } from "./components/Header/Header.js";
|
|
7
|
+
import { Body as k } from "./components/Body/Body.js";
|
|
8
|
+
import { Pagination as q } from "./components/Pagination/Pagination.js";
|
|
9
|
+
import { TruncateText as C } from "./components/TruncateText/TruncateText.js";
|
|
10
|
+
import { Actions as E } from "./components/Actions/Actions.js";
|
|
11
|
+
const F = ({
|
|
12
12
|
id: c,
|
|
13
13
|
ariaLabel: n,
|
|
14
14
|
columns: d,
|
|
@@ -21,23 +21,24 @@ const E = ({
|
|
|
21
21
|
classNameTable: h,
|
|
22
22
|
classNameWrapperTable: x,
|
|
23
23
|
fetchData: A,
|
|
24
|
+
queryOptions: v,
|
|
24
25
|
// Pagination
|
|
25
|
-
showPagination:
|
|
26
|
+
showPagination: y,
|
|
26
27
|
showTotalItems: o,
|
|
27
28
|
showDropdownPagination: i,
|
|
28
29
|
showDotPagination: a,
|
|
29
30
|
showFormPagination: l,
|
|
30
|
-
pageSizes:
|
|
31
|
+
pageSizes: z,
|
|
31
32
|
// Filter
|
|
32
|
-
showFilter:
|
|
33
|
-
showFilterInput:
|
|
34
|
-
filterSearchPlaceholder:
|
|
35
|
-
multiSelectFilter:
|
|
36
|
-
filterActions:
|
|
37
|
-
showResetButton:
|
|
33
|
+
showFilter: V = !1,
|
|
34
|
+
showFilterInput: g,
|
|
35
|
+
filterSearchPlaceholder: j = "",
|
|
36
|
+
multiSelectFilter: w,
|
|
37
|
+
filterActions: B,
|
|
38
|
+
showResetButton: H = !0
|
|
38
39
|
}) => {
|
|
39
|
-
const t =
|
|
40
|
-
() =>
|
|
40
|
+
const t = I(
|
|
41
|
+
() => y || [
|
|
41
42
|
o,
|
|
42
43
|
i,
|
|
43
44
|
a,
|
|
@@ -46,22 +47,23 @@ const E = ({
|
|
|
46
47
|
[]
|
|
47
48
|
);
|
|
48
49
|
return /* @__PURE__ */ r(
|
|
49
|
-
|
|
50
|
+
K,
|
|
50
51
|
{
|
|
51
52
|
id: c,
|
|
52
53
|
columns: d,
|
|
53
54
|
data: f,
|
|
54
55
|
fetchData: A,
|
|
55
56
|
totalItems: p,
|
|
57
|
+
queryOptions: v,
|
|
56
58
|
children: /* @__PURE__ */ m("section", { className: u, children: [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
V && /* @__PURE__ */ r(
|
|
60
|
+
M,
|
|
59
61
|
{
|
|
60
|
-
actions:
|
|
61
|
-
multiSelectFilter:
|
|
62
|
-
placeholder:
|
|
63
|
-
showFilterInput:
|
|
64
|
-
showResetButton:
|
|
62
|
+
actions: B,
|
|
63
|
+
multiSelectFilter: w,
|
|
64
|
+
placeholder: j,
|
|
65
|
+
showFilterInput: g,
|
|
66
|
+
showResetButton: H
|
|
65
67
|
}
|
|
66
68
|
),
|
|
67
69
|
/* @__PURE__ */ r(
|
|
@@ -81,37 +83,37 @@ const E = ({
|
|
|
81
83
|
"aria-label": n,
|
|
82
84
|
children: [
|
|
83
85
|
/* @__PURE__ */ r(
|
|
84
|
-
|
|
86
|
+
P,
|
|
85
87
|
{
|
|
86
88
|
className: N,
|
|
87
89
|
classNameArrows: T,
|
|
88
90
|
classNameActiveArrows: b
|
|
89
91
|
}
|
|
90
92
|
),
|
|
91
|
-
/* @__PURE__ */ r(
|
|
93
|
+
/* @__PURE__ */ r(k, {})
|
|
92
94
|
]
|
|
93
95
|
}
|
|
94
96
|
)
|
|
95
97
|
}
|
|
96
98
|
),
|
|
97
99
|
t && /* @__PURE__ */ r(
|
|
98
|
-
|
|
100
|
+
q,
|
|
99
101
|
{
|
|
100
102
|
showTotalItems: o,
|
|
101
103
|
showDropdownPagination: i,
|
|
102
104
|
showDotPagination: a,
|
|
103
105
|
showFormPagination: l,
|
|
104
|
-
pageSizes:
|
|
106
|
+
pageSizes: z
|
|
105
107
|
}
|
|
106
108
|
)
|
|
107
109
|
] })
|
|
108
110
|
}
|
|
109
111
|
);
|
|
110
|
-
}, e =
|
|
112
|
+
}, e = F;
|
|
111
113
|
e.displayName = "KonstructVirtualizedTable";
|
|
112
|
-
e.TruncateText =
|
|
113
|
-
e.Actions =
|
|
114
|
+
e.TruncateText = C;
|
|
115
|
+
e.Actions = E;
|
|
114
116
|
export {
|
|
115
|
-
|
|
117
|
+
C as TruncateText,
|
|
116
118
|
e as VirtualizedTable
|
|
117
119
|
};
|
|
@@ -1,82 +1,84 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { u as
|
|
4
|
-
import { useState as t, useMemo as
|
|
5
|
-
import { TableContext as
|
|
6
|
-
import { DEFAULT_PAGE_SIZE as
|
|
7
|
-
const
|
|
8
|
-
children:
|
|
9
|
-
id:
|
|
10
|
-
data:
|
|
11
|
-
columns:
|
|
12
|
-
totalItems:
|
|
13
|
-
fetchData:
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as _ } from "@tanstack/react-query";
|
|
3
|
+
import { u as j, g as k, a as q } from "../../../index-Dx2grAuN.js";
|
|
4
|
+
import { useState as t, useMemo as A, useCallback as n } from "react";
|
|
5
|
+
import { TableContext as K } from "./table.context.js";
|
|
6
|
+
import { DEFAULT_PAGE_SIZE as G } from "../constants/pagination.js";
|
|
7
|
+
const B = ({
|
|
8
|
+
children: S,
|
|
9
|
+
id: r,
|
|
10
|
+
data: f = [],
|
|
11
|
+
columns: h = [],
|
|
12
|
+
totalItems: p,
|
|
13
|
+
fetchData: g,
|
|
14
|
+
queryOptions: M = {}
|
|
14
15
|
}) => {
|
|
15
|
-
const [
|
|
16
|
-
() => Math.ceil(
|
|
17
|
-
[
|
|
18
|
-
), [a, w] = t({}), { data:
|
|
16
|
+
const [m, u] = t([]), [c, d] = t(0), [l, C] = t(), [o, b] = t(G), [i, y] = t(p), P = A(
|
|
17
|
+
() => Math.ceil(i / o),
|
|
18
|
+
[i, o]
|
|
19
|
+
), [a, w] = t({}), { data: O, isLoading: T, isFetching: F } = _({
|
|
19
20
|
queryKey: [
|
|
20
|
-
|
|
21
|
-
r,
|
|
22
|
-
o,
|
|
21
|
+
...typeof r == "string" ? [r] : r,
|
|
23
22
|
c,
|
|
23
|
+
o,
|
|
24
|
+
l,
|
|
24
25
|
JSON.stringify(a)
|
|
25
26
|
],
|
|
26
27
|
refetchOnMount: !1,
|
|
27
28
|
refetchOnWindowFocus: !1,
|
|
28
|
-
initialData:
|
|
29
|
-
queryFn: () =>
|
|
30
|
-
page: Math.max(
|
|
29
|
+
initialData: f,
|
|
30
|
+
queryFn: g ? () => g({
|
|
31
|
+
page: Math.max(c + 1, 1),
|
|
31
32
|
pageSize: o,
|
|
32
|
-
termOfSearch:
|
|
33
|
+
termOfSearch: l,
|
|
33
34
|
...Object.keys(a).length > 0 ? a : {}
|
|
34
|
-
}).then(({ data: e, totalItemsCount: s }) => (s &&
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
}).then(({ data: e, totalItemsCount: s }) => (s && y(s), e)) : void 0,
|
|
36
|
+
...M
|
|
37
|
+
}), R = n((e) => {
|
|
38
|
+
C(e), d(0);
|
|
39
|
+
}, []), v = n((e, s) => {
|
|
40
|
+
const z = e.toLowerCase().replace(/\s+/g, "_");
|
|
41
|
+
w((D) => ({
|
|
42
|
+
...D,
|
|
43
|
+
[z]: s
|
|
42
44
|
}));
|
|
43
|
-
}, []), x = n((e) =>
|
|
44
|
-
(e) =>
|
|
45
|
+
}, []), x = n((e) => d(e), []), I = n(
|
|
46
|
+
(e) => b(e),
|
|
45
47
|
[]
|
|
46
|
-
),
|
|
47
|
-
data:
|
|
48
|
-
columns:
|
|
48
|
+
), L = j({
|
|
49
|
+
data: O,
|
|
50
|
+
columns: h,
|
|
49
51
|
state: {
|
|
50
|
-
sorting:
|
|
52
|
+
sorting: m
|
|
51
53
|
},
|
|
52
|
-
onSortingChange:
|
|
53
|
-
getCoreRowModel:
|
|
54
|
-
getSortedRowModel:
|
|
54
|
+
onSortingChange: u,
|
|
55
|
+
getCoreRowModel: q(),
|
|
56
|
+
getSortedRowModel: k()
|
|
55
57
|
});
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
-
|
|
58
|
+
return /* @__PURE__ */ E(
|
|
59
|
+
K.Provider,
|
|
58
60
|
{
|
|
59
61
|
value: {
|
|
60
|
-
sortedData:
|
|
61
|
-
table:
|
|
62
|
-
tableFetching:
|
|
63
|
-
tableLoading:
|
|
64
|
-
totalItems:
|
|
65
|
-
termOfSearch:
|
|
66
|
-
page:
|
|
62
|
+
sortedData: m,
|
|
63
|
+
table: L,
|
|
64
|
+
tableFetching: F,
|
|
65
|
+
tableLoading: T,
|
|
66
|
+
totalItems: i,
|
|
67
|
+
termOfSearch: l,
|
|
68
|
+
page: c,
|
|
67
69
|
multiselectSelected: a,
|
|
68
70
|
pageSize: o,
|
|
69
71
|
totalPages: P,
|
|
70
72
|
handlePage: x,
|
|
71
|
-
onPageSize:
|
|
72
|
-
onChangeTermOfSearch:
|
|
73
|
-
onSorting:
|
|
74
|
-
onSelectMultiselect:
|
|
73
|
+
onPageSize: I,
|
|
74
|
+
onChangeTermOfSearch: R,
|
|
75
|
+
onSorting: u,
|
|
76
|
+
onSelectMultiselect: v
|
|
75
77
|
},
|
|
76
|
-
children:
|
|
78
|
+
children: S
|
|
77
79
|
}
|
|
78
80
|
);
|
|
79
81
|
};
|
|
80
82
|
export {
|
|
81
|
-
|
|
83
|
+
B as TableProvider
|
|
82
84
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { RefAttributes } from 'react';
|
|
|
23
23
|
import { RowData as RowData_2 } from '@tanstack/react-table';
|
|
24
24
|
import { SliderProps } from '@radix-ui/react-slider';
|
|
25
25
|
import { TabsContentProps } from '@radix-ui/react-tabs';
|
|
26
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
26
27
|
import { VariantProps } from 'class-variance-authority';
|
|
27
28
|
|
|
28
29
|
declare type Action<TData> = {
|
|
@@ -577,7 +578,7 @@ declare type Props_3<TData extends RowData> = CellContext<TData, string> & {
|
|
|
577
578
|
};
|
|
578
579
|
|
|
579
580
|
declare type Props_4<TData extends RowData_2> = VariantProps<typeof virtualizeTableVariants> & {
|
|
580
|
-
id: string;
|
|
581
|
+
id: string | string[];
|
|
581
582
|
ariaLabel?: string;
|
|
582
583
|
columns: ColumnDef_2<TData, string>[];
|
|
583
584
|
data: TData[];
|
|
@@ -587,7 +588,8 @@ declare type Props_4<TData extends RowData_2> = VariantProps<typeof virtualizeTa
|
|
|
587
588
|
classNameHeaderTable?: string;
|
|
588
589
|
classNameTable?: string;
|
|
589
590
|
classNameWrapperTable?: string;
|
|
590
|
-
|
|
591
|
+
queryOptions?: Omit<UseQueryOptions<any, any, any, any>, 'queryKey' | 'queryFn'>;
|
|
592
|
+
fetchData?: (params: Record<string, string | number | string[] | number[] | undefined>) => Promise<{
|
|
591
593
|
data: TData[];
|
|
592
594
|
totalItemsCount?: number;
|
|
593
595
|
}>;
|
package/dist/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.2-alpha.
|
|
5
|
+
"version": "0.1.2-alpha.15",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.2-alpha.
|
|
5
|
+
"version": "0.1.2-alpha.16",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|