@konstructio/ui 0.1.2-alpha.66 → 0.1.2-alpha.67

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.
@@ -4,7 +4,7 @@ import { cn as d } from "../../../../../../utils/index.js";
4
4
  import { calendarMonthTitleVariants as f } from "../../CalendarPanel.variants.js";
5
5
  import { createDayPickerClassNames as h, SINGLE_MONTH_WIDTH as p } from "../../constants/index.js";
6
6
  import { getMonthName as M } from "../../../../utils/validation.js";
7
- import { D as y } from "../../../../../../DayPicker-PUEUVAST.js";
7
+ import { D as y } from "../../../../../../DayPicker-CaeUXRCF.js";
8
8
  const N = (e) => `${M(e.getMonth())} ${e.getFullYear()}`, g = ({
9
9
  month: e,
10
10
  range: a,
@@ -3,7 +3,7 @@ import { useState as h, useCallback as f } from "react";
3
3
  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
- import { D as k } from "../../DayPicker-PUEUVAST.js";
6
+ import { D as k } from "../../DayPicker-CaeUXRCF.js";
7
7
  import { C as g } from "../../chevron-left-BHBf-gQY.js";
8
8
  import { C as w } from "../../chevron-right-DvXGOiS_.js";
9
9
  const y = ({
@@ -5,6 +5,11 @@ import { Props as ActionProps } from './components/Actions/Actions.types';
5
5
  type VirtualizedTableCompound = (<TData extends RowData>(props: Props<TData>) => JSX.Element) & {
6
6
  TruncateText: typeof TruncateText;
7
7
  Actions: <TData extends RowData>(props: ActionProps<TData>) => JSX.Element | null;
8
+ Events: {
9
+ sendExpandRowEvent: (tableId: string, rowId: string) => void;
10
+ sendCollapseRowEvent: (tableId: string, rowId: string) => void;
11
+ sendToggleRowEvent: (tableId: string, rowId: string) => void;
12
+ };
8
13
  displayName?: string;
9
14
  };
10
15
  declare const VirtualizedTable: VirtualizedTableCompound;
@@ -1,63 +1,64 @@
1
- import { jsx as r, jsxs as s } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as n } from "react/jsx-runtime";
2
2
  import { useMemo as U } from "react";
3
- import { cn as c } from "../../utils/index.js";
4
- import { TableProvider as X } from "./contexts/table.provider.js";
5
- import { Filter as Y } from "./components/Filter/Filter.js";
6
- import { WrapperBody as Z } from "./components/WrapperBody/WrapperBody.js";
7
- import { Header as _ } from "./components/Header/Header.js";
8
- import { Body as $ } from "./components/Body/Body.js";
9
- import { Pagination as D } from "./components/Pagination/Pagination.js";
10
- import { TruncateText as L } from "./components/TruncateText/TruncateText.js";
11
- import { Actions as rr } from "./components/Actions/Actions.js";
12
- const er = ({
13
- id: n,
3
+ import { cn as s } from "../../utils/index.js";
4
+ import { sendToggleRowEvent as X, sendCollapseRowEvent as Y, sendExpandRowEvent as Z } from "./events/index.js";
5
+ import { TableProvider as _ } from "./contexts/table.provider.js";
6
+ import { Filter as $ } from "./components/Filter/Filter.js";
7
+ import { WrapperBody as D } from "./components/WrapperBody/WrapperBody.js";
8
+ import { Header as L } from "./components/Header/Header.js";
9
+ import { Body as rr } from "./components/Body/Body.js";
10
+ import { Pagination as er } from "./components/Pagination/Pagination.js";
11
+ import { TruncateText as or } from "./components/TruncateText/TruncateText.js";
12
+ import { Actions as ar } from "./components/Actions/Actions.js";
13
+ const tr = ({
14
+ id: c,
14
15
  ariaLabel: p,
15
16
  columns: d,
16
17
  data: f,
17
18
  totalItems: u = -1 / 0,
18
19
  className: b,
19
20
  classNameHeaderActiveArrows: T,
20
- classNameHeaderArrows: N,
21
+ classNameHeaderArrows: v,
21
22
  classNameHeaderTable: x,
22
- classNameTable: A,
23
- classNameWrapperTable: y,
23
+ classNameTable: E,
24
+ classNameWrapperTable: N,
24
25
  isLoading: a,
25
- getRowId: h,
26
- fetchData: z,
27
- queryOptions: B,
26
+ getRowId: w,
27
+ fetchData: A,
28
+ queryOptions: y,
28
29
  // Pagination
29
- showPagination: V,
30
+ showPagination: h,
30
31
  showTotalItems: t,
31
32
  showDropdownPagination: i,
32
33
  showDotPagination: l,
33
34
  showFormPagination: m,
34
- pageSizes: j,
35
+ pageSizes: z,
35
36
  // Filter
36
- showFilter: k = !1,
37
- showFilterInput: v,
38
- filterSearchPlaceholder: w = "",
39
- multiSelectFilter: P,
40
- filterActions: E,
41
- showResetButton: H = !0,
42
- resetButtonClassName: I,
37
+ showFilter: B = !1,
38
+ showFilterInput: R,
39
+ filterSearchPlaceholder: V = "",
40
+ multiSelectFilter: g,
41
+ filterActions: j,
42
+ showResetButton: k = !0,
43
+ resetButtonClassName: P,
43
44
  // Hover row
44
- enableHoverRow: K,
45
- classNameHoverRow: M,
45
+ enableHoverRow: C,
46
+ classNameHoverRow: H,
46
47
  // Expandable rows
47
- enableExpandedRow: W,
48
- expandedState: g,
49
- defaultExpanded: q,
50
- classNameExpandedRow: C,
51
- classNameExpandedCell: F,
52
- classNameExpandedContent: G,
53
- classNameExpandedHeader: J,
54
- classNameActiveExpandedRow: O,
55
- onExpandedChange: Q,
56
- renderExpandedRow: R,
48
+ enableExpandedRow: I,
49
+ expandedState: K,
50
+ defaultExpanded: M,
51
+ classNameExpandedRow: W,
52
+ classNameExpandedCell: q,
53
+ classNameExpandedContent: F,
54
+ classNameExpandedHeader: G,
55
+ classNameActiveExpandedRow: J,
56
+ onExpandedChange: O,
57
+ renderExpandedRow: Q,
57
58
  keepExpandColumnVisible: S
58
59
  }) => {
59
60
  const e = U(
60
- () => V || [
61
+ () => h || [
61
62
  t,
62
63
  i,
63
64
  l,
@@ -66,90 +67,95 @@ const er = ({
66
67
  []
67
68
  );
68
69
  return /* @__PURE__ */ r(
69
- X,
70
+ _,
70
71
  {
71
- id: n,
72
+ id: c,
72
73
  columns: d,
73
74
  data: f,
74
- getRowId: h,
75
- fetchData: z,
75
+ getRowId: w,
76
+ fetchData: A,
76
77
  totalItems: u,
77
- queryOptions: B,
78
+ queryOptions: y,
78
79
  isPaginationEnabled: e,
79
- enableExpandedRow: W,
80
- expandedState: g,
81
- onExpandedChange: Q,
82
- defaultExpanded: q,
83
- classNameExpandedRow: C,
84
- classNameExpandedCell: F,
85
- classNameExpandedContent: G,
86
- classNameExpandedHeader: J,
87
- classNameActiveExpandedRow: O,
88
- enableHoverRow: K,
89
- classNameHoverRow: M,
90
- renderExpandedRow: R,
80
+ enableExpandedRow: I,
81
+ expandedState: K,
82
+ onExpandedChange: O,
83
+ defaultExpanded: M,
84
+ classNameExpandedRow: W,
85
+ classNameExpandedCell: q,
86
+ classNameExpandedContent: F,
87
+ classNameExpandedHeader: G,
88
+ classNameActiveExpandedRow: J,
89
+ enableHoverRow: C,
90
+ classNameHoverRow: H,
91
+ renderExpandedRow: Q,
91
92
  keepExpandColumnVisible: S,
92
- children: /* @__PURE__ */ s("section", { className: c("w-full min-w-fit", b), children: [
93
- k && /* @__PURE__ */ r(
94
- Y,
93
+ children: /* @__PURE__ */ n("section", { className: s("w-full min-w-fit", b), children: [
94
+ B && /* @__PURE__ */ r(
95
+ $,
95
96
  {
96
- actions: E,
97
- multiSelectFilter: P,
98
- placeholder: w,
99
- showFilterInput: v,
100
- showResetButton: H,
101
- resetButtonClassName: I
97
+ actions: j,
98
+ multiSelectFilter: g,
99
+ placeholder: V,
100
+ showFilterInput: R,
101
+ showResetButton: k,
102
+ resetButtonClassName: P
102
103
  }
103
104
  ),
104
105
  /* @__PURE__ */ r(
105
- Z,
106
+ D,
106
107
  {
107
108
  showPagination: e,
108
- classNameWrapperTable: y,
109
+ classNameWrapperTable: N,
109
110
  isLoading: a,
110
- children: /* @__PURE__ */ s(
111
+ children: /* @__PURE__ */ n(
111
112
  "table",
112
113
  {
113
- className: c(
114
+ className: s(
114
115
  "w-full border-collapse table-auto",
115
116
  "dark:border-separate dark:border-spacing-0",
116
- A
117
+ E
117
118
  ),
118
119
  "aria-label": p,
119
120
  children: [
120
121
  /* @__PURE__ */ r(
121
- _,
122
+ L,
122
123
  {
123
124
  className: x,
124
- classNameArrows: N,
125
+ classNameArrows: v,
125
126
  classNameActiveArrows: T
126
127
  }
127
128
  ),
128
- /* @__PURE__ */ r($, { isLoading: a, showPagination: e })
129
+ /* @__PURE__ */ r(rr, { isLoading: a, showPagination: e })
129
130
  ]
130
131
  }
131
132
  )
132
133
  }
133
134
  ),
134
135
  e && /* @__PURE__ */ r(
135
- D,
136
+ er,
136
137
  {
137
138
  showTotalItems: t,
138
139
  showDropdownPagination: i,
139
140
  showDotPagination: l,
140
141
  showFormPagination: m,
141
- pageSizes: j,
142
+ pageSizes: z,
142
143
  isLoading: a
143
144
  }
144
145
  )
145
146
  ] })
146
147
  }
147
148
  );
148
- }, o = er;
149
+ }, o = tr;
149
150
  o.displayName = "KonstructVirtualizedTable";
150
- o.TruncateText = L;
151
- o.Actions = rr;
151
+ o.TruncateText = or;
152
+ o.Actions = ar;
153
+ o.Events = {
154
+ sendExpandRowEvent: Z,
155
+ sendCollapseRowEvent: Y,
156
+ sendToggleRowEvent: X
157
+ };
152
158
  export {
153
- L as TruncateText,
159
+ or as TruncateText,
154
160
  o as VirtualizedTable
155
161
  };
@@ -1,63 +1,65 @@
1
- import { jsx as a, jsxs as S } from "react/jsx-runtime";
2
- import { f as j } from "../../../../index-CSWGJT-v.js";
1
+ import { jsx as a, jsxs as A } from "react/jsx-runtime";
2
+ import { f as B } from "../../../../index-CSWGJT-v.js";
3
3
  import { Fragment as H } from "react";
4
4
  import { Skeleton as M } from "../Skeleton/Skeleton.js";
5
- import { cn as s } from "../../../../utils/index.js";
6
- import { ExpandableRow as A } from "../ExpandableRow/ExpandableRow.js";
7
- import { useTableContext as B } from "../../contexts/table.hook.js";
8
- const J = ({
9
- isLoading: f,
5
+ import { cn as l } from "../../../../utils/index.js";
6
+ import { ExpandableRow as O } from "../ExpandableRow/ExpandableRow.js";
7
+ import { useTableContext as V } from "../../contexts/table.hook.js";
8
+ const U = ({
9
+ isLoading: g,
10
10
  showPagination: t
11
11
  }) => {
12
12
  const {
13
- table: b,
14
- pageSize: u,
15
- tableFetching: h,
16
- enableExpandedRow: w,
17
- classNameExpandedRow: N,
18
- classNameExpandedCell: R,
19
- classNameExpandedContent: k,
13
+ table: i,
14
+ pageSize: h,
15
+ tableFetching: w,
16
+ enableExpandedRow: N,
17
+ classNameExpandedRow: R,
18
+ classNameExpandedCell: k,
19
+ classNameExpandedContent: E,
20
20
  enableHoverRow: p,
21
- classNameHoverRow: E,
21
+ classNameHoverRow: C,
22
22
  classNameActiveExpandedRow: v,
23
- renderExpandedRow: i
24
- } = B();
25
- if (f || h)
26
- return /* @__PURE__ */ a(M, { numberOfRows: u, table: b });
27
- const o = b.getRowModel().rows ?? [];
23
+ renderExpandedRow: b,
24
+ isBorderOnAdjacentCell: D,
25
+ isExpandColumnVisible: y
26
+ } = V();
27
+ if (g || w)
28
+ return /* @__PURE__ */ a(M, { numberOfRows: h, table: i });
29
+ const d = i.getRowModel().rows ?? [];
28
30
  return /* @__PURE__ */ a(
29
31
  "tbody",
30
32
  {
31
- className: s(
33
+ className: l(
32
34
  "text-slate-800",
33
35
  "text-sm",
34
36
  "font-normal",
35
37
  "relative",
36
38
  "dark:border-x"
37
39
  ),
38
- children: o.map((g, l) => {
39
- const { id: n, original: m, getVisibleCells: y } = g, { meta: d = {} } = m, c = y(), e = w && g.getIsExpanded(), C = !!d.expandedRow || !!i;
40
- return /* @__PURE__ */ S(H, { children: [
40
+ children: d.map((x, s) => {
41
+ const { id: m, original: c, getVisibleCells: j } = x, { meta: o = {} } = c, n = j(), e = N && x.getIsExpanded(), z = !!o.expandedRow || !!b, u = n[0]?.column.id !== "__expand" || y ? 0 : D ? 1 : null;
42
+ return /* @__PURE__ */ A(H, { children: [
41
43
  /* @__PURE__ */ a(
42
44
  "tr",
43
45
  {
44
- className: s(
46
+ className: l(
45
47
  { "group/row": p },
46
48
  "border-b",
47
49
  "border-b-gray-200",
48
50
  "dark:text-metal-50",
49
51
  "dark:border-b-metal-700",
50
52
  "bg-transparent",
51
- d.className
53
+ o.className
52
54
  ),
53
- "data-row-id": n,
54
- ...d.attributes ?? {},
55
- children: c.map(({ id: D, column: r, getContext: z }, x) => {
56
- const F = typeof r.columnDef.meta?.className == "function" ? r.columnDef.meta?.className(m) : r.columnDef.meta?.className;
55
+ "data-row-id": m,
56
+ ...o.attributes ?? {},
57
+ children: n.map(({ id: F, column: r, getContext: S }, f) => {
58
+ const _ = typeof r.columnDef.meta?.className == "function" ? r.columnDef.meta?.className(c) : r.columnDef.meta?.className;
57
59
  return /* @__PURE__ */ a(
58
60
  "td",
59
61
  {
60
- className: s(
62
+ className: l(
61
63
  "px-4",
62
64
  "py-1",
63
65
  "text-sm",
@@ -69,46 +71,46 @@ const J = ({
69
71
  "dark:last:border-r",
70
72
  {
71
73
  "group-hover/row:bg-zinc-100 dark:group-hover/row:bg-metal-800": p,
72
- [s(
74
+ [l(
73
75
  "bg-zinc-100 dark:bg-metal-800",
74
76
  v
75
77
  )]: !!e
76
78
  },
77
- E,
78
- F,
79
+ C,
80
+ _,
79
81
  {
80
- "first:rounded-bl-lg": l === o.length - 1 && x === 0 && !t && !e,
81
- "last:rounded-br-lg": l === o.length - 1 && x === c.length - 1 && !t && !e,
82
+ "rounded-bl-lg": s === d.length - 1 && u !== null && f === u && !t && !e,
83
+ "rounded-br-lg": s === d.length - 1 && f === n.length - 1 && !t && !e,
82
84
  "dark:[tr:last-child_&]:border-b": !t
83
85
  }
84
86
  ),
85
87
  "data-expanded": e ? !0 : void 0,
86
88
  ...r.columnDef.meta?.attributes ?? {},
87
- children: j(r.columnDef.cell, z())
89
+ children: B(r.columnDef.cell, S())
88
90
  },
89
- D
91
+ F
90
92
  );
91
93
  })
92
94
  }
93
95
  ),
94
- C && /* @__PURE__ */ a(
95
- A,
96
+ z && /* @__PURE__ */ a(
97
+ O,
96
98
  {
97
- classNameExpandedCell: R,
98
- classNameExpandedContent: k,
99
- classNameExpandedRow: N,
100
- colSpan: c.length,
101
- id: n,
99
+ classNameExpandedCell: k,
100
+ classNameExpandedContent: E,
101
+ classNameExpandedRow: R,
102
+ colSpan: n.length,
103
+ id: m,
102
104
  isExpanded: !!e,
103
- isLastRow: l === o.length - 1 && !t,
104
- children: d.expandedRow ?? i?.(m)
105
+ isLastRow: s === d.length - 1 && !t,
106
+ children: o.expandedRow ?? b?.(c)
105
107
  }
106
108
  )
107
- ] }, n);
109
+ ] }, m);
108
110
  })
109
111
  }
110
112
  );
111
113
  };
112
114
  export {
113
- J as Body
115
+ U as Body
114
116
  };
@@ -20,6 +20,8 @@ export type ContextType<TData extends RowData = RowData> = {
20
20
  classNameActiveExpandedRow?: string;
21
21
  enableHoverRow?: boolean;
22
22
  classNameHoverRow?: string;
23
+ isBorderOnAdjacentCell?: boolean;
24
+ isExpandColumnVisible?: boolean;
23
25
  renderExpandedRow?: (data: RowData) => ReactNode;
24
26
  handlePage: (newPage: number) => void;
25
27
  onPageSize: (newPageSize: number) => void;