@konstructio/ui 0.1.2-alpha.7 → 0.1.2-alpha.9

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,99 +1,113 @@
1
1
  import { jsx as r, jsxs as m } from "react/jsx-runtime";
2
- import { useMemo as V } from "react";
3
- import { cn as g } from "../../utils/index.js";
4
- import { TableProvider as j } from "./contexts/table.provider.js";
5
- import { Filter as w } from "./components/Filter/Filter.js";
6
- import { Header as y } from "./components/Header/Header.js";
7
- import { Body as B } from "./components/Body/Body.js";
8
- import { Pagination as H } from "./components/Pagination/Pagination.js";
9
- import { TruncateText as K } from "./components/TruncateText/TruncateText.js";
10
- import { Actions as M } from "./components/Actions/Actions.js";
11
- const P = ({
12
- id: s,
13
- ariaLabel: c,
2
+ import { useMemo as w } from "react";
3
+ import { cn as s } from "../../utils/index.js";
4
+ import { TableProvider as B } from "./contexts/table.provider.js";
5
+ import { Filter as H } from "./components/Filter/Filter.js";
6
+ import { Header as I } from "./components/Header/Header.js";
7
+ import { Body as K } from "./components/Body/Body.js";
8
+ import { Pagination as M } from "./components/Pagination/Pagination.js";
9
+ import { TruncateText as P } from "./components/TruncateText/TruncateText.js";
10
+ import { Actions as k } from "./components/Actions/Actions.js";
11
+ const q = ({
12
+ id: c,
13
+ ariaLabel: n,
14
14
  columns: d,
15
- data: n,
16
- totalItems: f,
17
- classNameHeaderTable: p,
18
- classNameHeaderArrows: u,
15
+ data: f,
16
+ totalItems: p = -1 / 0,
17
+ className: u,
19
18
  classNameHeaderActiveArrows: b,
20
- fetchData: T,
19
+ classNameHeaderArrows: T,
20
+ classNameHeaderTable: N,
21
+ classNameTable: h,
22
+ classNameWrapperTable: x,
23
+ fetchData: A,
21
24
  // Pagination
22
- showPagination: N,
25
+ showPagination: v,
23
26
  showTotalItems: o,
24
- showDropdownPagination: l,
25
- showDotPagination: a,
26
- showFormPagination: i,
27
- pageSizes: h,
27
+ showDropdownPagination: i,
28
+ showDotPagination: l,
29
+ showFormPagination: a,
30
+ pageSizes: y,
28
31
  // Filter
29
- showFilter: x = !1,
30
- showFilterInput: A,
31
- filterSearchPlaceholder: v = "",
32
- multiSelectFilter: z
32
+ showFilter: z = !1,
33
+ showFilterInput: V,
34
+ filterSearchPlaceholder: g = "",
35
+ multiSelectFilter: j
33
36
  }) => {
34
- const t = V(
35
- () => N || [
37
+ const t = w(
38
+ () => v || [
36
39
  o,
40
+ i,
37
41
  l,
38
- a,
39
- i
42
+ a
40
43
  ].some(Boolean),
41
44
  []
42
45
  );
43
46
  return /* @__PURE__ */ r(
44
- j,
47
+ B,
45
48
  {
46
- id: s,
49
+ id: c,
47
50
  columns: d,
48
- data: n,
49
- fetchData: T,
50
- totalItems: f,
51
- children: /* @__PURE__ */ m("section", { children: [
52
- x && /* @__PURE__ */ r(
53
- w,
51
+ data: f,
52
+ fetchData: A,
53
+ totalItems: p,
54
+ children: /* @__PURE__ */ m("section", { className: u, children: [
55
+ z && /* @__PURE__ */ r(
56
+ H,
54
57
  {
55
- placeholder: v,
56
- multiSelectFilter: z,
57
- showFilterInput: A
58
+ placeholder: g,
59
+ multiSelectFilter: j,
60
+ showFilterInput: V
58
61
  }
59
62
  ),
60
63
  /* @__PURE__ */ r(
61
64
  "div",
62
65
  {
63
- className: g("shadow rounded-t-lg", {
64
- "overflow-hidden rounded-lg": !t
65
- }),
66
- children: /* @__PURE__ */ m("table", { className: "w-full border-collapse", "aria-label": c, children: [
67
- /* @__PURE__ */ r(
68
- y,
69
- {
70
- className: p,
71
- classNameArrows: u,
72
- classNameActiveArrows: b
73
- }
74
- ),
75
- /* @__PURE__ */ r(B, {})
76
- ] })
66
+ className: s(
67
+ "shadow rounded-t-lg",
68
+ {
69
+ "overflow-hidden rounded-lg": !t
70
+ },
71
+ x
72
+ ),
73
+ children: /* @__PURE__ */ m(
74
+ "table",
75
+ {
76
+ className: s("w-full border-collapse", h),
77
+ "aria-label": n,
78
+ children: [
79
+ /* @__PURE__ */ r(
80
+ I,
81
+ {
82
+ className: N,
83
+ classNameArrows: T,
84
+ classNameActiveArrows: b
85
+ }
86
+ ),
87
+ /* @__PURE__ */ r(K, {})
88
+ ]
89
+ }
90
+ )
77
91
  }
78
92
  ),
79
93
  t && /* @__PURE__ */ r(
80
- H,
94
+ M,
81
95
  {
82
96
  showTotalItems: o,
83
- showDropdownPagination: l,
84
- showDotPagination: a,
85
- showFormPagination: i,
86
- pageSizes: h
97
+ showDropdownPagination: i,
98
+ showDotPagination: l,
99
+ showFormPagination: a,
100
+ pageSizes: y
87
101
  }
88
102
  )
89
103
  ] })
90
104
  }
91
105
  );
92
- }, e = P;
106
+ }, e = q;
93
107
  e.displayName = "KonstructVirtualizedTable";
94
- e.TruncateText = K;
95
- e.Actions = M;
108
+ e.TruncateText = P;
109
+ e.Actions = k;
96
110
  export {
97
- K as TruncateText,
111
+ P as TruncateText,
98
112
  e as VirtualizedTable
99
113
  };
@@ -1,49 +1,49 @@
1
1
  import { jsx as z } from "react/jsx-runtime";
2
2
  import { useQuery as E } from "@tanstack/react-query";
3
3
  import { u as _, g as j, a as k } from "../../../index-Dx2grAuN.js";
4
- import { useState as t, useMemo as q, useCallback as s } from "react";
4
+ import { useState as t, useMemo as q, useCallback as n } from "react";
5
5
  import { TableContext as A } from "./table.context.js";
6
6
  import { DEFAULT_PAGE_SIZE as K } from "../constants/pagination.js";
7
7
  const Z = ({
8
- children: u,
9
- id: d,
8
+ children: d,
9
+ id: u,
10
10
  data: S = [],
11
11
  columns: f = [],
12
12
  totalItems: h,
13
13
  fetchData: p
14
14
  }) => {
15
- const [i, g] = t([]), [n, m] = t(0), [r, C] = t(), [o, M] = t(K), [c, b] = t(h), P = q(
16
- () => Math.ceil(c / o),
17
- [c, o]
15
+ const [i, g] = t([]), [r, m] = t(0), [c, M] = t(), [o, C] = t(K), [l, b] = t(h), P = q(
16
+ () => Math.ceil(l / o),
17
+ [l, o]
18
18
  ), [a, w] = t({}), { data: y, isLoading: O, isFetching: T } = E({
19
19
  queryKey: [
20
- d,
21
- n,
22
- o,
20
+ u,
23
21
  r,
22
+ o,
23
+ c,
24
24
  JSON.stringify(a)
25
25
  ],
26
26
  refetchOnMount: !1,
27
27
  refetchOnWindowFocus: !1,
28
28
  initialData: S,
29
29
  queryFn: () => p({
30
- page: Math.max(n + 1, 1),
30
+ page: Math.max(r + 1, 1),
31
31
  pageSize: o,
32
- termOfSearch: r,
32
+ termOfSearch: c,
33
33
  ...Object.keys(a).length > 0 ? a : {}
34
- }).then(({ data: e, totalItemsCount: l }) => (b(l), e))
35
- }), F = s((e) => {
36
- C(e), m(0);
37
- }, []), I = s((e, l) => {
34
+ }).then(({ data: e, totalItemsCount: s }) => (s && b(s), e))
35
+ }), F = n((e) => {
36
+ M(e), m(0);
37
+ }, []), R = n((e, s) => {
38
38
  const L = e.toLowerCase().replace(/\s+/g, "_");
39
39
  w((v) => ({
40
40
  ...v,
41
- [L]: l
41
+ [L]: s
42
42
  }));
43
- }, []), R = s((e) => m(e), []), x = s(
44
- (e) => M(e),
43
+ }, []), x = n((e) => m(e), []), D = n(
44
+ (e) => C(e),
45
45
  []
46
- ), D = _({
46
+ ), I = _({
47
47
  data: y,
48
48
  columns: f,
49
49
  state: {
@@ -58,22 +58,22 @@ const Z = ({
58
58
  {
59
59
  value: {
60
60
  sortedData: i,
61
- table: D,
61
+ table: I,
62
62
  tableFetching: T,
63
63
  tableLoading: O,
64
- totalItems: c,
65
- termOfSearch: r,
66
- page: n,
64
+ totalItems: l,
65
+ termOfSearch: c,
66
+ page: r,
67
67
  multiselectSelected: a,
68
68
  pageSize: o,
69
69
  totalPages: P,
70
- handlePage: R,
71
- onPageSize: x,
70
+ handlePage: x,
71
+ onPageSize: D,
72
72
  onChangeTermOfSearch: F,
73
73
  onSorting: g,
74
- onSelectMultiselect: I
74
+ onSelectMultiselect: R
75
75
  },
76
- children: u
76
+ children: d
77
77
  }
78
78
  );
79
79
  };
package/dist/index.d.ts CHANGED
@@ -571,14 +571,16 @@ declare type Props_4<TData extends RowData_2> = VariantProps<typeof virtualizeTa
571
571
  ariaLabel?: string;
572
572
  columns: ColumnDef<TData, string>[];
573
573
  data: TData[];
574
- totalItems: number;
574
+ className?: string;
575
+ classNameHeaderActiveArrows?: string;
576
+ classNameHeaderArrows?: string;
577
+ classNameHeaderTable?: string;
578
+ classNameTable?: string;
579
+ classNameWrapperTable?: string;
575
580
  fetchData: (params: Record<string, string | number | string[] | number[] | undefined>) => Promise<{
576
581
  data: TData[];
577
- totalItemsCount: number;
582
+ totalItemsCount?: number;
578
583
  }>;
579
- classNameHeaderTable?: string;
580
- classNameHeaderArrows?: string;
581
- classNameHeaderActiveArrows?: string;
582
584
  } & ({
583
585
  showPagination: true;
584
586
  showTotalItems?: boolean;
@@ -586,6 +588,7 @@ declare type Props_4<TData extends RowData_2> = VariantProps<typeof virtualizeTa
586
588
  showDotPagination?: boolean;
587
589
  showFormPagination?: boolean;
588
590
  pageSizes?: number[] | string[];
591
+ totalItems: number;
589
592
  } | {
590
593
  showPagination?: false | undefined;
591
594
  showTotalItems?: never;
@@ -593,6 +596,7 @@ declare type Props_4<TData extends RowData_2> = VariantProps<typeof virtualizeTa
593
596
  showDotPagination?: never;
594
597
  showFormPagination?: never;
595
598
  pageSizes?: never;
599
+ totalItems?: never;
596
600
  }) & ({
597
601
  filterSearchPlaceholder?: string;
598
602
  multiSelectFilter?: MultiSelectFilter[];
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.6",
5
+ "version": "0.1.2-alpha.8",
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.7",
5
+ "version": "0.1.2-alpha.9",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",