@konstructio/ui 0.1.2-alpha.62 → 0.1.2-alpha.63

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.
@@ -0,0 +1,5 @@
1
+ import { c as e } from "./createLucideIcon-CP-mMPfa.js";
2
+ const o = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]], t = e("chevron-left", o);
3
+ export {
4
+ t as C
5
+ };
@@ -0,0 +1,5 @@
1
+ import { c as o } from "./createLucideIcon-CP-mMPfa.js";
2
+ const t = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], e = o("chevron-right", t);
3
+ export {
4
+ e as C
5
+ };
@@ -1,12 +1,13 @@
1
- import { jsx as o } from "react/jsx-runtime";
1
+ import { jsx as a } from "react/jsx-runtime";
2
2
  import { cn as e } from "../../../../../../utils/index.js";
3
- import { calendarNavButtonDisabledVariants as p, calendarNavButtonVariants as b } from "../../CalendarPanel.variants.js";
4
- import { C as v, a as N } from "../../../../../../chevron-right-SUh6si0f.js";
3
+ import { calendarNavButtonDisabledVariants as h, calendarNavButtonVariants as b } from "../../CalendarPanel.variants.js";
4
+ import { C as v } from "../../../../../../chevron-left-BHBf-gQY.js";
5
+ import { C as N } from "../../../../../../chevron-right-DvXGOiS_.js";
5
6
  const B = ({
6
7
  direction: n,
7
- onClick: s,
8
- disabled: i = !1,
9
- isAnimating: r = !1,
8
+ onClick: r,
9
+ disabled: s = !1,
10
+ isAnimating: i = !1,
10
11
  canNavigate: t = !0,
11
12
  hideWhenDisabled: l = !1,
12
13
  className: m,
@@ -14,23 +15,23 @@ const B = ({
14
15
  ariaLabel: u,
15
16
  size: c = "medium"
16
17
  }) => {
17
- const a = i || r || !t;
18
+ const o = s || i || !t;
18
19
  if (l && !t)
19
20
  return null;
20
- const f = n === "prev" ? v : N, h = c === "small" ? "w-4 h-4" : "w-5 h-5";
21
- return /* @__PURE__ */ o(
21
+ const f = n === "prev" ? v : N, p = c === "small" ? "w-4 h-4" : "w-5 h-5";
22
+ return /* @__PURE__ */ a(
22
23
  "button",
23
24
  {
24
25
  type: "button",
25
- onClick: s,
26
- disabled: a,
26
+ onClick: r,
27
+ disabled: o,
27
28
  className: e(
28
29
  b(),
29
30
  m,
30
- a && e(p(), d)
31
+ o && e(h(), d)
31
32
  ),
32
33
  "aria-label": u,
33
- children: /* @__PURE__ */ o(f, { className: h })
34
+ children: /* @__PURE__ */ a(f, { className: p })
34
35
  }
35
36
  );
36
37
  };
@@ -4,19 +4,20 @@ import { cn as t } from "../../utils/index.js";
4
4
  import { datePickerVariants as p } from "./DatePicker.variants.js";
5
5
  import '../../style.css';/* empty css */
6
6
  import { D as k } from "../../DayPicker-PUEUVAST.js";
7
- import { C as g, a as w } from "../../chevron-right-SUh6si0f.js";
7
+ import { C as g } from "../../chevron-left-BHBf-gQY.js";
8
+ import { C as w } from "../../chevron-right-DvXGOiS_.js";
8
9
  const y = ({
9
10
  className: l,
10
11
  showOutsideDays: n = !0,
11
12
  animate: d = !0,
12
13
  arrowClassName: s,
13
14
  monthsClassName: i,
14
- defaultSelected: u,
15
+ defaultSelected: m,
15
16
  onSelect: o,
16
- ...m
17
+ ...u
17
18
  }) => {
18
19
  const [c, x] = h(
19
- () => u
20
+ () => m
20
21
  ), b = f(
21
22
  (e) => {
22
23
  e && (x(e), o?.(e));
@@ -129,7 +130,7 @@ const y = ({
129
130
  components: {
130
131
  Chevron: ({ className: e, ...r }) => r.orientation === "left" ? /* @__PURE__ */ a(g, { className: t(e), ...r }) : /* @__PURE__ */ a(w, { className: t(e), ...r })
131
132
  },
132
- ...m
133
+ ...u
133
134
  }
134
135
  );
135
136
  };
@@ -1,15 +1,15 @@
1
1
  import { jsx as r, jsxs as s } from "react/jsx-runtime";
2
- import { useMemo as I } from "react";
2
+ import { useMemo as G } from "react";
3
3
  import { cn as c } 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 { WrapperBody as W } from "./components/WrapperBody/WrapperBody.js";
7
- import { Header as g } from "./components/Header/Header.js";
8
- import { Body as q } from "./components/Body/Body.js";
9
- import { Pagination as C } from "./components/Pagination/Pagination.js";
10
- import { TruncateText as F } from "./components/TruncateText/TruncateText.js";
11
- import { Actions as G } from "./components/Actions/Actions.js";
12
- const J = ({
4
+ import { TableProvider as J } from "./contexts/table.provider.js";
5
+ import { Filter as O } from "./components/Filter/Filter.js";
6
+ import { WrapperBody as Q } from "./components/WrapperBody/WrapperBody.js";
7
+ import { Header as R } from "./components/Header/Header.js";
8
+ import { Body as S } from "./components/Body/Body.js";
9
+ import { Pagination as U } from "./components/Pagination/Pagination.js";
10
+ import { TruncateText as X } from "./components/TruncateText/TruncateText.js";
11
+ import { Actions as Y } from "./components/Actions/Actions.js";
12
+ const Z = ({
13
13
  id: n,
14
14
  ariaLabel: p,
15
15
  columns: d,
@@ -38,9 +38,18 @@ const J = ({
38
38
  multiSelectFilter: w,
39
39
  filterActions: P,
40
40
  showResetButton: E = !0,
41
- resetButtonClassName: H
41
+ resetButtonClassName: H,
42
+ // Expandable rows
43
+ enableExpandedRow: I,
44
+ expandedState: K,
45
+ defaultExpanded: M,
46
+ classNameExpandedRow: W,
47
+ classNameExpandedCell: g,
48
+ classNameExpandedContent: q,
49
+ classNameExpandedHeader: C,
50
+ onExpandedChange: F
42
51
  }) => {
43
- const e = I(
52
+ const e = G(
44
53
  () => B || [
45
54
  t,
46
55
  i,
@@ -50,7 +59,7 @@ const J = ({
50
59
  []
51
60
  );
52
61
  return /* @__PURE__ */ r(
53
- K,
62
+ J,
54
63
  {
55
64
  id: n,
56
65
  columns: d,
@@ -59,9 +68,17 @@ const J = ({
59
68
  totalItems: u,
60
69
  queryOptions: z,
61
70
  isPaginationEnabled: e,
71
+ enableExpandedRow: I,
72
+ expandedState: K,
73
+ onExpandedChange: F,
74
+ defaultExpanded: M,
75
+ classNameExpandedRow: W,
76
+ classNameExpandedCell: g,
77
+ classNameExpandedContent: q,
78
+ classNameExpandedHeader: C,
62
79
  children: /* @__PURE__ */ s("section", { className: c("w-full min-w-fit", b), children: [
63
80
  j && /* @__PURE__ */ r(
64
- M,
81
+ O,
65
82
  {
66
83
  actions: P,
67
84
  multiSelectFilter: w,
@@ -72,7 +89,7 @@ const J = ({
72
89
  }
73
90
  ),
74
91
  /* @__PURE__ */ r(
75
- W,
92
+ Q,
76
93
  {
77
94
  showPagination: e,
78
95
  classNameWrapperTable: y,
@@ -88,21 +105,21 @@ const J = ({
88
105
  "aria-label": p,
89
106
  children: [
90
107
  /* @__PURE__ */ r(
91
- g,
108
+ R,
92
109
  {
93
110
  className: x,
94
111
  classNameArrows: N,
95
112
  classNameActiveArrows: T
96
113
  }
97
114
  ),
98
- /* @__PURE__ */ r(q, { isLoading: a, showPagination: e })
115
+ /* @__PURE__ */ r(S, { isLoading: a, showPagination: e })
99
116
  ]
100
117
  }
101
118
  )
102
119
  }
103
120
  ),
104
121
  e && /* @__PURE__ */ r(
105
- C,
122
+ U,
106
123
  {
107
124
  showTotalItems: t,
108
125
  showDropdownPagination: i,
@@ -115,11 +132,11 @@ const J = ({
115
132
  ] })
116
133
  }
117
134
  );
118
- }, o = J;
135
+ }, o = Z;
119
136
  o.displayName = "KonstructVirtualizedTable";
120
- o.TruncateText = F;
121
- o.Actions = G;
137
+ o.TruncateText = X;
138
+ o.Actions = Y;
122
139
  export {
123
- F as TruncateText,
140
+ X as TruncateText,
124
141
  o as VirtualizedTable
125
142
  };
@@ -1,5 +1,6 @@
1
- import { ColumnDef as ColumnDefPrimitive, RowData as RowDataPrimitive } from '@tanstack/react-table';
1
+ import { ColumnDef as ColumnDefPrimitive, ExpandedState, OnChangeFn, RowData as RowDataPrimitive } from '@tanstack/react-table';
2
2
  import { VariantProps } from 'class-variance-authority';
3
+ import { ReactNode } from 'react';
3
4
  import { virtualizeTableVariants } from './VirtualizedTable.variants';
4
5
  import { FilterAction, Option } from './components/Filter/Filter.types';
5
6
  import { UseQueryOptions } from '@tanstack/react-query';
@@ -16,6 +17,7 @@ declare module '@tanstack/react-table' {
16
17
  export interface RowMetadata {
17
18
  className?: string;
18
19
  attributes?: Record<string, string | number | boolean>;
20
+ expandedRow?: ReactNode;
19
21
  [key: string]: unknown;
20
22
  }
21
23
  export type RowDataWithMeta = Record<string, unknown> & {
@@ -105,4 +107,22 @@ export type Props<TData extends RowDataPrimitive> = VariantProps<typeof virtuali
105
107
  filterActions?: FilterAction[];
106
108
  showResetButton?: never;
107
109
  resetButtonClassName?: never;
110
+ }) & ({
111
+ enableExpandedRow: true;
112
+ expandedState?: ExpandedState;
113
+ defaultExpanded?: ExpandedState;
114
+ classNameExpandedRow?: string;
115
+ classNameExpandedCell?: string;
116
+ classNameExpandedContent?: string;
117
+ classNameExpandedHeader?: string;
118
+ onExpandedChange?: OnChangeFn<ExpandedState>;
119
+ } | {
120
+ enableExpandedRow?: false | undefined;
121
+ expandedState?: never;
122
+ defaultExpanded?: never;
123
+ classNameExpandedRow?: never;
124
+ classNameExpandedCell?: never;
125
+ classNameExpandedContent?: never;
126
+ classNameExpandedHeader?: never;
127
+ onExpandedChange?: never;
108
128
  });
@@ -1,77 +1,99 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { f as N } from "../../../../index-CSWGJT-v.js";
3
- import { Skeleton as h } from "../Skeleton/Skeleton.js";
4
- import { cn as s } from "../../../../utils/index.js";
5
- import { useTableContext as y } from "../../contexts/table.hook.js";
6
- const S = ({
7
- isLoading: f,
8
- showPagination: t
1
+ import { jsx as t, jsxs as D } from "react/jsx-runtime";
2
+ import { f as F } from "../../../../index-CSWGJT-v.js";
3
+ import { Fragment as S } from "react";
4
+ import { Skeleton as j } from "../Skeleton/Skeleton.js";
5
+ import { cn as l } from "../../../../utils/index.js";
6
+ import { ExpandableRow as M } from "../ExpandableRow/ExpandableRow.js";
7
+ import { useTableContext as v } from "../../contexts/table.hook.js";
8
+ const A = ({
9
+ isLoading: p,
10
+ showPagination: a
9
11
  }) => {
10
- const { table: o, pageSize: i, tableFetching: p } = y();
11
- if (f || p)
12
- return /* @__PURE__ */ r(h, { numberOfRows: i, table: o });
13
- const a = o.getRowModel().rows ?? [];
14
- return /* @__PURE__ */ r(
12
+ const {
13
+ table: n,
14
+ pageSize: f,
15
+ tableFetching: x,
16
+ enableExpandedRow: g,
17
+ classNameExpandedRow: u,
18
+ classNameExpandedCell: h,
19
+ classNameExpandedContent: N
20
+ } = v();
21
+ if (p || x)
22
+ return /* @__PURE__ */ t(j, { numberOfRows: f, table: n });
23
+ const d = n.getRowModel().rows ?? [];
24
+ return /* @__PURE__ */ t(
15
25
  "tbody",
16
26
  {
17
- className: s(
27
+ className: l(
18
28
  "text-slate-800",
19
29
  "text-sm",
20
30
  "font-normal",
21
31
  "relative",
22
32
  "dark:border-x"
23
33
  ),
24
- children: a.map(({ id: l, original: m, getVisibleCells: u }, d) => {
25
- const { meta: b = {} } = m, n = u();
26
- return /* @__PURE__ */ r(
27
- "tr",
28
- {
29
- className: s(
30
- "border-b",
31
- "border-b-gray-200",
32
- "dark:text-metal-50",
33
- "dark:border-b-metal-700",
34
- "last:border-b-transparent",
35
- "bg-transparent",
36
- b.className
37
- ),
38
- "data-row-id": l,
39
- ...b.attributes ?? {},
40
- children: n.map(({ id: k, column: e, getContext: g }, c) => {
41
- const x = typeof e.columnDef.meta?.className == "function" ? e.columnDef.meta?.className(m) : e.columnDef.meta?.className;
42
- return /* @__PURE__ */ r(
43
- "td",
44
- {
45
- className: s(
46
- "px-4",
47
- "py-1",
48
- "text-sm",
49
- "bg-white",
50
- "dark:bg-metal-900",
51
- "dark:border-t",
52
- "dark:border-metal-700",
53
- "dark:first:border-l",
54
- "dark:last:border-r",
55
- x,
56
- {
57
- "first:rounded-bl-lg": d === a.length - 1 && c === 0 && !t,
58
- "last:rounded-br-lg": d === a.length - 1 && c === n.length - 1 && !t,
59
- "dark:[tr:last-child_&]:border-b": !t
60
- }
61
- ),
62
- ...e.columnDef.meta?.attributes ?? {},
63
- children: N(e.columnDef.cell, g())
64
- },
65
- k
66
- );
67
- })
68
- },
69
- l
70
- );
34
+ children: d.map((m, c) => {
35
+ const { id: s, original: b, getVisibleCells: k } = m, { meta: r = {} } = b, o = k(), E = g && m.getIsExpanded(), R = !!r.expandedRow;
36
+ return /* @__PURE__ */ D(S, { children: [
37
+ /* @__PURE__ */ t(
38
+ "tr",
39
+ {
40
+ className: l(
41
+ "border-b",
42
+ "border-b-gray-200",
43
+ "dark:text-metal-50",
44
+ "dark:border-b-metal-700",
45
+ "bg-transparent",
46
+ r.className
47
+ ),
48
+ "data-row-id": s,
49
+ ...r.attributes ?? {},
50
+ children: o.map(({ id: w, column: e, getContext: y }, i) => {
51
+ const C = typeof e.columnDef.meta?.className == "function" ? e.columnDef.meta?.className(b) : e.columnDef.meta?.className;
52
+ return /* @__PURE__ */ t(
53
+ "td",
54
+ {
55
+ className: l(
56
+ "px-4",
57
+ "py-1",
58
+ "text-sm",
59
+ "bg-white",
60
+ "dark:bg-metal-900",
61
+ "dark:border-t",
62
+ "dark:border-metal-700",
63
+ "dark:first:border-l",
64
+ "dark:last:border-r",
65
+ C,
66
+ {
67
+ "first:rounded-bl-lg": c === d.length - 1 && i === 0 && !a,
68
+ "last:rounded-br-lg": c === d.length - 1 && i === o.length - 1 && !a,
69
+ "dark:[tr:last-child_&]:border-b": !a
70
+ }
71
+ ),
72
+ ...e.columnDef.meta?.attributes ?? {},
73
+ children: F(e.columnDef.cell, y())
74
+ },
75
+ w
76
+ );
77
+ })
78
+ }
79
+ ),
80
+ R && /* @__PURE__ */ t(
81
+ M,
82
+ {
83
+ classNameExpandedCell: h,
84
+ classNameExpandedContent: N,
85
+ classNameExpandedRow: u,
86
+ colSpan: o.length,
87
+ id: s,
88
+ isExpanded: !!E,
89
+ children: r.expandedRow
90
+ }
91
+ )
92
+ ] }, s);
71
93
  })
72
94
  }
73
95
  );
74
96
  };
75
97
  export {
76
- S as Body
98
+ A as Body
77
99
  };
@@ -1,8 +1,9 @@
1
- import { jsx as s, jsxs as h } from "react/jsx-runtime";
1
+ import { jsx as s, jsxs as m } from "react/jsx-runtime";
2
2
  import { memo as u } from "react";
3
3
  import { cn as p } from "../../../../utils/index.js";
4
- import { C as m, a as g } from "../../../../chevron-right-SUh6si0f.js";
5
- import { useTableContext as f } from "../../contexts/table.hook.js";
4
+ import { C as h } from "../../../../chevron-left-BHBf-gQY.js";
5
+ import { C as f } from "../../../../chevron-right-DvXGOiS_.js";
6
+ import { useTableContext as g } from "../../contexts/table.hook.js";
6
7
  const l = u(
7
8
  ({
8
9
  index: t,
@@ -32,7 +33,7 @@ const o = u(
32
33
  disabled: e,
33
34
  onClick: i
34
35
  }) => /* @__PURE__ */ s("li", { className: "flex items-center justify-center", children: /* @__PURE__ */ s("button", { onClick: i, disabled: e, children: /* @__PURE__ */ s(
35
- t === "left" ? m : g,
36
+ t === "left" ? h : f,
36
37
  {
37
38
  className: p("h-6 w-6 cursor-pointer", {
38
39
  "text-blue-600 dark:text-aurora-500": !e,
@@ -42,9 +43,9 @@ const o = u(
42
43
  ) }) })
43
44
  );
44
45
  o.displayName = "KonstructNavigationButton";
45
- const N = () => {
46
- const { totalPages: t, page: e, handlePage: i } = f();
47
- return /* @__PURE__ */ h("ul", { className: "flex items-center gap-2", children: [
46
+ const C = () => {
47
+ const { totalPages: t, page: e, handlePage: i } = g();
48
+ return /* @__PURE__ */ m("ul", { className: "flex items-center gap-2", children: [
48
49
  /* @__PURE__ */ s(
49
50
  o,
50
51
  {
@@ -164,5 +165,5 @@ const N = () => {
164
165
  ] });
165
166
  };
166
167
  export {
167
- N as DotPaginate
168
+ C as DotPaginate
168
169
  };
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { Props } from './ExpandableRow.types';
3
+ export declare const ExpandableRow: FC<Props>;
@@ -0,0 +1,41 @@
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { cn as d } from "../../../../utils/index.js";
3
+ const c = ({
4
+ children: e,
5
+ classNameExpandedCell: o,
6
+ classNameExpandedContent: t,
7
+ classNameExpandedRow: i,
8
+ colSpan: s,
9
+ id: l,
10
+ isExpanded: r
11
+ }) => /* @__PURE__ */ a("tr", { className: d(i), "data-expanded-row-id": l, children: /* @__PURE__ */ a(
12
+ "td",
13
+ {
14
+ colSpan: s,
15
+ className: d(
16
+ "bg-white p-0 dark:bg-metal-900 dark:border-x dark:border-t dark:border-b",
17
+ {
18
+ "border-t border-b border-gray-200": r,
19
+ "dark:border-metal-700": r,
20
+ "dark:border-transparent dark:transition-[border-color] dark:duration-300 dark:ease-in-out": !r
21
+ }
22
+ ),
23
+ children: /* @__PURE__ */ a(
24
+ "div",
25
+ {
26
+ className: d(
27
+ "grid transition-[grid-template-rows] duration-300 ease-in-out",
28
+ {
29
+ "grid-rows-[1fr]": r,
30
+ "grid-rows-[0fr]": !r
31
+ },
32
+ t
33
+ ),
34
+ children: /* @__PURE__ */ a("div", { className: "overflow-hidden", children: /* @__PURE__ */ a("div", { className: d("px-4 py-3", o), children: e }) })
35
+ }
36
+ )
37
+ }
38
+ ) });
39
+ export {
40
+ c as ExpandableRow
41
+ };
@@ -0,0 +1,9 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export type Props = PropsWithChildren<{
3
+ classNameExpandedCell?: string;
4
+ classNameExpandedContent?: string;
5
+ classNameExpandedRow?: string;
6
+ colSpan: number;
7
+ id: string;
8
+ isExpanded: boolean;
9
+ }>;
@@ -13,6 +13,10 @@ export type ContextType<TData extends RowData = RowData> = {
13
13
  multiselectSelected?: Record<string, string[]>;
14
14
  totalPages: number;
15
15
  isFirstLoad: boolean;
16
+ enableExpandedRow?: boolean;
17
+ classNameExpandedRow?: string;
18
+ classNameExpandedCell?: string;
19
+ classNameExpandedContent?: string;
16
20
  handlePage: (newPage: number) => void;
17
21
  onPageSize: (newPageSize: number) => void;
18
22
  onSorting: Dispatch<SetStateAction<SortingState>>;
@@ -1,17 +1,3 @@
1
- import { ColumnDef } from '@tanstack/react-table';
2
- import { PropsWithChildren } from 'react';
3
- import { RowData, Props as TableProps } from '../VirtualizedTable.types';
4
- type Props<TData extends RowData = RowData> = PropsWithChildren & {
5
- id: string | string[] | number | number[];
6
- data: TData[];
7
- columns: ColumnDef<TData, string>[];
8
- totalItems: number;
9
- queryOptions?: TableProps<TData>['queryOptions'];
10
- isPaginationEnabled?: boolean;
11
- fetchData?: (params: Record<string, string | number | string[] | number[] | undefined>) => Promise<{
12
- data: TData[];
13
- totalItemsCount?: number;
14
- }>;
15
- };
16
- export declare const TableProvider: <TData extends RowData = RowData>({ children, id, data: defaultData, columns, totalItems, isPaginationEnabled, queryOptions, fetchData, }: Props<TData>) => import("react/jsx-runtime").JSX.Element;
17
- export {};
1
+ import { RowData } from '../VirtualizedTable.types';
2
+ import { Props } from './table.types';
3
+ export declare const TableProvider: <TData extends RowData = RowData>({ children, classNameExpandedCell, classNameExpandedContent, classNameExpandedRow, classNameExpandedHeader, columns, data: defaultData, defaultExpanded, enableExpandedRow, expandedState, id, isPaginationEnabled, queryOptions, totalItems, fetchData, onExpandedChange, }: Props<TData>) => import("react/jsx-runtime").JSX.Element;