@konstructio/ui 0.1.2-alpha.16 → 0.1.2-alpha.18
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,16 +1,16 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { cn as
|
|
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
|
|
1
|
+
import { jsx as r, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as E } from "react";
|
|
3
|
+
import { cn as m } from "../../utils/index.js";
|
|
4
|
+
import { TableProvider as H } from "./contexts/table.provider.js";
|
|
5
|
+
import { Filter as I } from "./components/Filter/Filter.js";
|
|
6
|
+
import { Header as K } from "./components/Header/Header.js";
|
|
7
|
+
import { Body as M } from "./components/Body/Body.js";
|
|
8
|
+
import { Pagination as k } from "./components/Pagination/Pagination.js";
|
|
9
|
+
import { TruncateText as q } from "./components/TruncateText/TruncateText.js";
|
|
10
|
+
import { Actions as C } from "./components/Actions/Actions.js";
|
|
11
11
|
const F = ({
|
|
12
|
-
id:
|
|
13
|
-
ariaLabel:
|
|
12
|
+
id: n,
|
|
13
|
+
ariaLabel: c,
|
|
14
14
|
columns: d,
|
|
15
15
|
data: f,
|
|
16
16
|
totalItems: p = -1 / 0,
|
|
@@ -23,97 +23,98 @@ const F = ({
|
|
|
23
23
|
fetchData: A,
|
|
24
24
|
queryOptions: v,
|
|
25
25
|
// Pagination
|
|
26
|
-
showPagination:
|
|
27
|
-
showTotalItems:
|
|
28
|
-
showDropdownPagination:
|
|
29
|
-
showDotPagination:
|
|
30
|
-
showFormPagination:
|
|
31
|
-
pageSizes:
|
|
26
|
+
showPagination: g,
|
|
27
|
+
showTotalItems: i,
|
|
28
|
+
showDropdownPagination: a,
|
|
29
|
+
showDotPagination: l,
|
|
30
|
+
showFormPagination: t,
|
|
31
|
+
pageSizes: y,
|
|
32
32
|
// Filter
|
|
33
|
-
showFilter:
|
|
34
|
-
showFilterInput:
|
|
33
|
+
showFilter: z = !1,
|
|
34
|
+
showFilterInput: V,
|
|
35
35
|
filterSearchPlaceholder: j = "",
|
|
36
36
|
multiSelectFilter: w,
|
|
37
37
|
filterActions: B,
|
|
38
|
-
showResetButton:
|
|
38
|
+
showResetButton: P = !0
|
|
39
39
|
}) => {
|
|
40
|
-
const
|
|
41
|
-
() =>
|
|
42
|
-
o,
|
|
40
|
+
const e = E(
|
|
41
|
+
() => g || [
|
|
43
42
|
i,
|
|
44
43
|
a,
|
|
45
|
-
l
|
|
44
|
+
l,
|
|
45
|
+
t
|
|
46
46
|
].some(Boolean),
|
|
47
47
|
[]
|
|
48
48
|
);
|
|
49
49
|
return /* @__PURE__ */ r(
|
|
50
|
-
|
|
50
|
+
H,
|
|
51
51
|
{
|
|
52
|
-
id:
|
|
52
|
+
id: n,
|
|
53
53
|
columns: d,
|
|
54
54
|
data: f,
|
|
55
55
|
fetchData: A,
|
|
56
56
|
totalItems: p,
|
|
57
57
|
queryOptions: v,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
isPaginationEnabled: e,
|
|
59
|
+
children: /* @__PURE__ */ s("section", { className: u, children: [
|
|
60
|
+
z && /* @__PURE__ */ r(
|
|
61
|
+
I,
|
|
61
62
|
{
|
|
62
63
|
actions: B,
|
|
63
64
|
multiSelectFilter: w,
|
|
64
65
|
placeholder: j,
|
|
65
|
-
showFilterInput:
|
|
66
|
-
showResetButton:
|
|
66
|
+
showFilterInput: V,
|
|
67
|
+
showResetButton: P
|
|
67
68
|
}
|
|
68
69
|
),
|
|
69
70
|
/* @__PURE__ */ r(
|
|
70
71
|
"div",
|
|
71
72
|
{
|
|
72
|
-
className:
|
|
73
|
+
className: m(
|
|
73
74
|
"shadow rounded-t-lg",
|
|
74
75
|
{
|
|
75
|
-
"overflow-hidden rounded-lg": !
|
|
76
|
+
"overflow-hidden rounded-lg": !e
|
|
76
77
|
},
|
|
77
78
|
x
|
|
78
79
|
),
|
|
79
|
-
children: /* @__PURE__ */
|
|
80
|
+
children: /* @__PURE__ */ s(
|
|
80
81
|
"table",
|
|
81
82
|
{
|
|
82
|
-
className:
|
|
83
|
-
"aria-label":
|
|
83
|
+
className: m("w-full border-collapse", h),
|
|
84
|
+
"aria-label": c,
|
|
84
85
|
children: [
|
|
85
86
|
/* @__PURE__ */ r(
|
|
86
|
-
|
|
87
|
+
K,
|
|
87
88
|
{
|
|
88
89
|
className: N,
|
|
89
90
|
classNameArrows: T,
|
|
90
91
|
classNameActiveArrows: b
|
|
91
92
|
}
|
|
92
93
|
),
|
|
93
|
-
/* @__PURE__ */ r(
|
|
94
|
+
/* @__PURE__ */ r(M, {})
|
|
94
95
|
]
|
|
95
96
|
}
|
|
96
97
|
)
|
|
97
98
|
}
|
|
98
99
|
),
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
e && /* @__PURE__ */ r(
|
|
101
|
+
k,
|
|
101
102
|
{
|
|
102
|
-
showTotalItems:
|
|
103
|
-
showDropdownPagination:
|
|
104
|
-
showDotPagination:
|
|
105
|
-
showFormPagination:
|
|
106
|
-
pageSizes:
|
|
103
|
+
showTotalItems: i,
|
|
104
|
+
showDropdownPagination: a,
|
|
105
|
+
showDotPagination: l,
|
|
106
|
+
showFormPagination: t,
|
|
107
|
+
pageSizes: y
|
|
107
108
|
}
|
|
108
109
|
)
|
|
109
110
|
] })
|
|
110
111
|
}
|
|
111
112
|
);
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
}, o = F;
|
|
114
|
+
o.displayName = "KonstructVirtualizedTable";
|
|
115
|
+
o.TruncateText = q;
|
|
116
|
+
o.Actions = C;
|
|
116
117
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
q as TruncateText,
|
|
119
|
+
o as VirtualizedTable
|
|
119
120
|
};
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as z } from "react/jsx-runtime";
|
|
2
2
|
import { useQuery as _ } from "@tanstack/react-query";
|
|
3
|
-
import { u as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { TableContext as
|
|
3
|
+
import { u as k, g as A, a as D } from "../../../index-Dx2grAuN.js";
|
|
4
|
+
import { useState as o, useMemo as Q, useCallback as c } from "react";
|
|
5
|
+
import { TableContext as $ } from "./table.context.js";
|
|
6
6
|
import { DEFAULT_PAGE_SIZE as G } from "../constants/pagination.js";
|
|
7
|
-
const
|
|
7
|
+
const N = ({
|
|
8
8
|
children: S,
|
|
9
9
|
id: r,
|
|
10
|
-
data:
|
|
11
|
-
columns:
|
|
12
|
-
totalItems:
|
|
13
|
-
|
|
14
|
-
queryOptions: M = {}
|
|
10
|
+
data: g = [],
|
|
11
|
+
columns: d = [],
|
|
12
|
+
totalItems: y,
|
|
13
|
+
isPaginationEnabled: b,
|
|
14
|
+
queryOptions: M = {},
|
|
15
|
+
fetchData: m
|
|
15
16
|
}) => {
|
|
16
|
-
const [
|
|
17
|
-
() => Math.ceil(
|
|
18
|
-
[
|
|
19
|
-
), [a,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
],
|
|
17
|
+
const [f, h] = o([]), [i, p] = o(0), [n, C] = o(), [s, P] = o(G), [l, w] = o(y), O = Q(
|
|
18
|
+
() => Math.ceil(l / s),
|
|
19
|
+
[l, s]
|
|
20
|
+
), [a, T] = o({}), F = () => {
|
|
21
|
+
const e = typeof r == "string" || typeof r == "number" ? [r] : r;
|
|
22
|
+
return b && e.push(i, s), n && e.push(n), Object.entries(a).forEach(([t, u]) => {
|
|
23
|
+
e.push(`${t}:${u.join(",")}`);
|
|
24
|
+
}), e;
|
|
25
|
+
}, { data: R, isLoading: j, isFetching: x } = _({
|
|
26
|
+
queryKey: F(),
|
|
27
27
|
refetchOnMount: !1,
|
|
28
28
|
refetchOnWindowFocus: !1,
|
|
29
|
-
initialData:
|
|
30
|
-
queryFn:
|
|
31
|
-
page: Math.max(
|
|
32
|
-
pageSize:
|
|
33
|
-
termOfSearch:
|
|
29
|
+
initialData: g,
|
|
30
|
+
queryFn: async () => m ? m({
|
|
31
|
+
page: Math.max(i + 1, 1),
|
|
32
|
+
pageSize: s,
|
|
33
|
+
termOfSearch: n,
|
|
34
34
|
...Object.keys(a).length > 0 ? a : {}
|
|
35
|
-
}).then(({ data: e, totalItemsCount:
|
|
35
|
+
}).then(({ data: e, totalItemsCount: t }) => (t && w(t), e)) : g ?? [],
|
|
36
36
|
...M
|
|
37
|
-
}),
|
|
38
|
-
C(e),
|
|
39
|
-
}, []),
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
...
|
|
43
|
-
[
|
|
37
|
+
}), E = c((e) => {
|
|
38
|
+
C(e), p(0);
|
|
39
|
+
}, []), I = c((e, t) => {
|
|
40
|
+
const u = e.toLowerCase().replace(/\s+/g, "_");
|
|
41
|
+
T((v) => ({
|
|
42
|
+
...v,
|
|
43
|
+
[u]: t
|
|
44
44
|
}));
|
|
45
|
-
}, []),
|
|
46
|
-
(e) =>
|
|
45
|
+
}, []), K = c((e) => p(e), []), L = c(
|
|
46
|
+
(e) => P(e),
|
|
47
47
|
[]
|
|
48
|
-
),
|
|
49
|
-
data:
|
|
50
|
-
columns:
|
|
48
|
+
), q = k({
|
|
49
|
+
data: R,
|
|
50
|
+
columns: d,
|
|
51
51
|
state: {
|
|
52
|
-
sorting:
|
|
52
|
+
sorting: f
|
|
53
53
|
},
|
|
54
|
-
onSortingChange:
|
|
55
|
-
getCoreRowModel:
|
|
56
|
-
getSortedRowModel:
|
|
54
|
+
onSortingChange: h,
|
|
55
|
+
getCoreRowModel: D(),
|
|
56
|
+
getSortedRowModel: A()
|
|
57
57
|
});
|
|
58
|
-
return /* @__PURE__ */
|
|
59
|
-
|
|
58
|
+
return /* @__PURE__ */ z(
|
|
59
|
+
$.Provider,
|
|
60
60
|
{
|
|
61
61
|
value: {
|
|
62
|
-
sortedData:
|
|
63
|
-
table:
|
|
64
|
-
tableFetching:
|
|
65
|
-
tableLoading:
|
|
66
|
-
totalItems:
|
|
67
|
-
termOfSearch:
|
|
68
|
-
page:
|
|
62
|
+
sortedData: f,
|
|
63
|
+
table: q,
|
|
64
|
+
tableFetching: x,
|
|
65
|
+
tableLoading: j,
|
|
66
|
+
totalItems: l,
|
|
67
|
+
termOfSearch: n,
|
|
68
|
+
page: i,
|
|
69
69
|
multiselectSelected: a,
|
|
70
|
-
pageSize:
|
|
71
|
-
totalPages:
|
|
72
|
-
handlePage:
|
|
73
|
-
onPageSize:
|
|
74
|
-
onChangeTermOfSearch:
|
|
75
|
-
onSorting:
|
|
76
|
-
onSelectMultiselect:
|
|
70
|
+
pageSize: s,
|
|
71
|
+
totalPages: O,
|
|
72
|
+
handlePage: K,
|
|
73
|
+
onPageSize: L,
|
|
74
|
+
onChangeTermOfSearch: E,
|
|
75
|
+
onSorting: h,
|
|
76
|
+
onSelectMultiselect: I
|
|
77
77
|
},
|
|
78
78
|
children: S
|
|
79
79
|
}
|
|
80
80
|
);
|
|
81
81
|
};
|
|
82
82
|
export {
|
|
83
|
-
|
|
83
|
+
N as TableProvider
|
|
84
84
|
};
|
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.17",
|
|
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.18",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|