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