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