@cagatayfdn/flora-components 0.0.130 → 0.0.132

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,215 +1,257 @@
1
- import { j as s } from "../../jsx-runtime-BcAkpsdy.js";
2
- import { useState as Z, useEffect as I } from "react";
3
- import ee from "../NoResult/NoResult.js";
4
- import { c as j } from "../../index-BHf7G3IG.js";
5
- import { s as c } from "../../Table.module-DUqpZOLt.js";
6
- import { ThemeAppearance as T, AppearanceSpinner as $ } from "../../enums/appearance.js";
7
- import A from "../Checkbox/Checkbox.js";
8
- import te from "../Loading/Loading.js";
9
- import re from "../ScrollContainer/ScrollContainer.js";
10
- import O from "./TableHeader.js";
11
- import ae from "./TableSort.js";
12
- import { i as u } from "../../includes-8YTFrx85.js";
13
- import { _ as D, k as se } from "../../keys-B0bo5Q7o.js";
14
- import { _ as R, a as ne, b as ie } from "../../_reduce-DsUCMz4O.js";
15
- import { _ as le } from "../../Select-BE_y91ZN.js";
16
- function de(i, t) {
17
- for (var a = 0, l = t.length, h = []; a < l; )
18
- i(t[a]) && (h[h.length] = t[a]), a += 1;
19
- return h;
1
+ import { j as t } from "../../jsx-runtime-BcAkpsdy.js";
2
+ import ae, { useState as F, useEffect as se } from "react";
3
+ import ne from "../NoResult/NoResult.js";
4
+ import { c as w } from "../../index-BHf7G3IG.js";
5
+ import { s as f } from "../../Table.module-DUqpZOLt.js";
6
+ import { ThemeAppearance as O, AppearanceSpinner as z } from "../../enums/appearance.js";
7
+ import D from "../Checkbox/Checkbox.js";
8
+ import oe from "../Loading/Loading.js";
9
+ import le from "../ScrollContainer/ScrollContainer.js";
10
+ import G from "./TableHeader.js";
11
+ import ie from "./TableSort.js";
12
+ import de from "../Icon/index.js";
13
+ import { Icons as ce } from "../../assets/icons/icons.js";
14
+ import { i as x } from "../../includes-8YTFrx85.js";
15
+ import { _ as U, k as he } from "../../keys-B0bo5Q7o.js";
16
+ import { _ as V, a as pe, b as fe } from "../../_reduce-DsUCMz4O.js";
17
+ import { _ as xe } from "../../Select-BE_y91ZN.js";
18
+ function ue(o, a) {
19
+ for (var n = 0, d = a.length, u = []; n < d; )
20
+ o(a[n]) && (u[u.length] = a[n]), n += 1;
21
+ return u;
20
22
  }
21
- var oe = /* @__PURE__ */ function() {
22
- function i(t, a) {
23
- this.xf = a, this.f = t;
23
+ var ge = /* @__PURE__ */ function() {
24
+ function o(a, n) {
25
+ this.xf = n, this.f = a;
24
26
  }
25
- return i.prototype["@@transducer/init"] = R.init, i.prototype["@@transducer/result"] = R.result, i.prototype["@@transducer/step"] = function(t, a) {
26
- return this.f(a) ? this.xf["@@transducer/step"](t, a) : t;
27
- }, i;
28
- }(), ce = /* @__PURE__ */ D(function(t, a) {
29
- return new oe(t, a);
27
+ return o.prototype["@@transducer/init"] = V.init, o.prototype["@@transducer/result"] = V.result, o.prototype["@@transducer/step"] = function(a, n) {
28
+ return this.f(n) ? this.xf["@@transducer/step"](a, n) : a;
29
+ }, o;
30
+ }(), je = /* @__PURE__ */ U(function(a, n) {
31
+ return new ge(a, n);
30
32
  });
31
- const he = ce;
32
- var z = /* @__PURE__ */ D(
33
- /* @__PURE__ */ ne(["filter"], he, function(i, t) {
34
- return le(t) ? ie(function(a, l) {
35
- return i(t[l]) && (a[l] = t[l]), a;
36
- }, {}, se(t)) : (
33
+ const me = je;
34
+ var N = /* @__PURE__ */ U(
35
+ /* @__PURE__ */ pe(["filter"], me, function(o, a) {
36
+ return xe(a) ? fe(function(n, d) {
37
+ return o(a[d]) && (n[d] = a[d]), n;
38
+ }, {}, he(a)) : (
37
39
  // else
38
- de(i, t)
40
+ ue(o, a)
39
41
  );
40
42
  })
41
43
  );
42
- const Le = (i) => {
44
+ const Oe = (o) => {
43
45
  const {
44
- columns: t = [],
45
- dataSource: a = [],
46
- totalCount: l,
47
- currentPage: h,
48
- className: F,
49
- wrapperClass: G,
50
- title: V,
51
- rowSelection: C = !1,
52
- actionOnChange: m,
53
- rowSelectionChange: d,
54
- pagerVisible: w,
55
- pagerOnChange: k,
56
- columnRenderer: N,
57
- pageSizeOnChange: S,
58
- pageSize: _,
59
- headerVisible: E = !0,
60
- headerLeftItem: U,
61
- customFooterItem: W,
62
- isLoading: X = !1,
63
- footerAction: B = !0,
64
- pageSizeVisible: K = !0,
65
- appearance: x = T.LIGHT,
66
- fixedHeader: P,
67
- showItemsText: y,
68
- customHeader: L,
69
- selectedItems: v = [],
70
- scrollClass: q,
71
- disabledItems: p = []
72
- } = i, [o, g] = Z(v), J = (e) => {
73
- d && (e.target.checked ? (g(
74
- a.filter((n) => !u(n, p))
75
- ), d(
76
- a.filter((n) => !u(n, p))
77
- )) : (g([]), d([])));
78
- }, M = (e, n) => {
79
- d && (e.target.checked ? (g([...o, n]), d([...o, n])) : (g(
80
- z((r) => r.pk !== n.pk, o)
81
- ), d(
82
- z((r) => r.pk !== n.pk, o)
46
+ columns: a = [],
47
+ dataSource: n = [],
48
+ totalCount: d,
49
+ currentPage: u,
50
+ className: W,
51
+ wrapperClass: X,
52
+ title: B,
53
+ rowSelection: j = !1,
54
+ actionOnChange: k,
55
+ rowSelectionChange: c,
56
+ pagerVisible: S,
57
+ pagerOnChange: _,
58
+ columnRenderer: R,
59
+ pageSizeOnChange: y,
60
+ pageSize: v,
61
+ headerVisible: K = !0,
62
+ headerLeftItem: P,
63
+ customFooterItem: q,
64
+ isLoading: J = !1,
65
+ footerAction: M = !0,
66
+ pageSizeVisible: Q = !0,
67
+ appearance: m = O.LIGHT,
68
+ fixedHeader: Y,
69
+ showItemsText: L,
70
+ customHeader: H,
71
+ selectedItems: T = [],
72
+ scrollClass: Z,
73
+ disabledItems: g = [],
74
+ expandable: l
75
+ } = o, [h, C] = F(T), [$, A] = F([]), I = (e) => {
76
+ c && (e.target.checked ? (C(
77
+ n.filter((s) => !x(s, g))
78
+ ), c(
79
+ n.filter((s) => !x(s, g))
80
+ )) : (C([]), c([])));
81
+ }, ee = (e, s) => {
82
+ c && (e.target.checked ? (C([...h, s]), c([...h, s])) : (C(
83
+ N((r) => r.pk !== s.pk, h)
84
+ ), c(
85
+ N((r) => r.pk !== s.pk, h)
83
86
  )));
84
- }, Q = (e, n) => e == null ? void 0 : e.map((r, f) => /* @__PURE__ */ s.jsx(
87
+ }, te = (e, s) => {
88
+ var i;
89
+ const r = x(e, $);
90
+ A(r ? (p) => N((b) => b !== e, p) : (p) => [...p, e]), (i = l == null ? void 0 : l.onExpand) == null || i.call(l, !r, s);
91
+ }, re = (e, s) => e == null ? void 0 : e.map((r, i) => /* @__PURE__ */ t.jsx(
85
92
  "td",
86
93
  {
87
94
  width: r.width,
88
- onClick: (b) => {
89
- r != null && r.onClick && (r == null || r.onClick(b, n, r, f));
95
+ onClick: (p) => {
96
+ r != null && r.onClick && (r == null || r.onClick(p, s, r, i));
90
97
  },
91
- className: j(r.className, r.tdClassName),
92
- children: r.render ? r.render(n[r.dataIndex], n) : n[r.dataIndex]
98
+ className: w(r.className, r.tdClassName),
99
+ children: r.render ? r.render(s[r.dataIndex], s) : s[r.dataIndex]
93
100
  },
94
- `col-${f}`
101
+ `col-${i}`
95
102
  ));
96
- return I(() => {
97
- d && d(
98
- v.filter((e) => !u(e, p))
99
- );
100
- }, [o, p]), /* @__PURE__ */ s.jsxs(
103
+ return se(() => {
104
+ c && c(T.filter((e) => !x(e, g)));
105
+ }, [h, g]), /* @__PURE__ */ t.jsxs(
101
106
  "div",
102
107
  {
103
108
  "data-testid": "table-container",
104
- className: j(c.wrapper, G, {
105
- [c[`${x}`]]: x
109
+ className: w(f.wrapper, X, {
110
+ [f[`${m}`]]: m
106
111
  }),
107
112
  children: [
108
- E && /* @__PURE__ */ s.jsx(
109
- O,
113
+ K && /* @__PURE__ */ t.jsx(
114
+ G,
110
115
  {
111
- title: V,
112
- showItemsText: y,
113
- actionOnChange: m,
114
- pageSize: _,
115
- pageSizeOnChange: S,
116
- pagerOnChange: k,
117
- pagerVisible: w,
118
- totalCount: l,
119
- currentPage: h
116
+ title: B,
117
+ showItemsText: L,
118
+ actionOnChange: k,
119
+ pageSize: v,
120
+ pageSizeOnChange: y,
121
+ pagerOnChange: _,
122
+ pagerVisible: S,
123
+ totalCount: d,
124
+ currentPage: u
120
125
  }
121
126
  ),
122
- /* @__PURE__ */ s.jsxs("div", { className: c.tableWrap, children: [
123
- X && /* @__PURE__ */ s.jsx(
124
- te,
127
+ /* @__PURE__ */ t.jsxs("div", { className: f.tableWrap, children: [
128
+ J && /* @__PURE__ */ t.jsx(
129
+ oe,
125
130
  {
126
- wrapperClass: c.tableLoading,
127
- appearance: x === T.LIGHT ? $.LIGHT : $.DARK
131
+ wrapperClass: f.tableLoading,
132
+ appearance: m === O.LIGHT ? z.LIGHT : z.DARK
128
133
  }
129
134
  ),
130
- L && L,
131
- /* @__PURE__ */ s.jsx(re, { className: q || c.scrollWrap, children: /* @__PURE__ */ s.jsxs(
135
+ H && H,
136
+ /* @__PURE__ */ t.jsx(le, { className: Z || f.scrollWrap, children: /* @__PURE__ */ t.jsxs(
132
137
  "table",
133
138
  {
134
139
  "data-testid": "table-content",
135
- className: j(c.table, F, {
136
- [c.fixed]: P
140
+ className: w(f.table, W, {
141
+ [f.fixed]: Y
137
142
  }),
138
143
  children: [
139
- /* @__PURE__ */ s.jsx("thead", { "data-testid": "table-head", children: /* @__PURE__ */ s.jsxs("tr", { "data-testid": "table-row", children: [
140
- C && /* @__PURE__ */ s.jsx("th", { style: { width: 26 }, children: /* @__PURE__ */ s.jsx(
141
- A,
144
+ /* @__PURE__ */ t.jsx("thead", { "data-testid": "table-head", children: /* @__PURE__ */ t.jsxs("tr", { "data-testid": "table-row", children: [
145
+ l && /* @__PURE__ */ t.jsx("th", { className: "w-[48px]" }),
146
+ j && /* @__PURE__ */ t.jsx("th", { className: "w-[26px]", children: /* @__PURE__ */ t.jsx(
147
+ D,
142
148
  {
143
149
  name: "selectAll",
144
- isDisabled: a.length === 0,
145
- checked: a.length > 0 && a.length === o.length,
146
- onChange: J
150
+ isDisabled: n.length === 0,
151
+ checked: n.length > 0 && n.length === h.length,
152
+ onChange: I
147
153
  }
148
154
  ) }),
149
- t == null ? void 0 : t.map((e, n) => {
150
- var r, f;
151
- return e.sortable ? /* @__PURE__ */ s.jsx(
155
+ a == null ? void 0 : a.map((e, s) => {
156
+ var r, i;
157
+ return e.sortable ? /* @__PURE__ */ t.jsx(
152
158
  "th",
153
159
  {
154
160
  "data-testid": "table-head-item",
155
161
  style: { width: e.width },
156
162
  className: e.className,
157
- children: /* @__PURE__ */ s.jsx(
158
- ae,
163
+ children: /* @__PURE__ */ t.jsx(
164
+ ie,
159
165
  {
160
166
  title: (r = e.title) == null ? void 0 : r.toString().toLocaleUpperCase(),
161
- onClick: (b, Y) => {
162
- var H;
163
- return (H = e == null ? void 0 : e.onSort) == null ? void 0 : H.call(e, b, Y);
167
+ onClick: (p, b) => {
168
+ var E;
169
+ return (E = e == null ? void 0 : e.onSort) == null ? void 0 : E.call(e, p, b);
164
170
  }
165
171
  }
166
172
  )
167
173
  },
168
- `table-header-${n}`
169
- ) : /* @__PURE__ */ s.jsx(
174
+ `table-header-${s}`
175
+ ) : /* @__PURE__ */ t.jsx(
170
176
  "th",
171
177
  {
172
178
  "data-testid": "table-head-item",
173
179
  style: { width: e.width },
174
180
  className: e.className,
175
- children: typeof e.title == "string" || e.title instanceof String ? (f = e.title) == null ? void 0 : f.toString().toLocaleUpperCase() : e.title
181
+ children: typeof e.title == "string" || e.title instanceof String ? (i = e.title) == null ? void 0 : i.toString().toLocaleUpperCase() : e.title
176
182
  },
177
- `table-header-${n}`
183
+ `table-header-${s}`
178
184
  );
179
185
  })
180
186
  ] }) }),
181
- /* @__PURE__ */ s.jsx("tbody", { "data-testid": "table-body", children: a.length > 0 ? a.map((e, n) => /* @__PURE__ */ s.jsxs("tr", { children: [
182
- C && /* @__PURE__ */ s.jsx("td", { children: /* @__PURE__ */ s.jsx(
183
- A,
184
- {
185
- checked: u(e, o),
186
- name: `select-${n}`,
187
- onChange: (r) => M(r, e),
188
- isDisabled: u(e, p)
189
- }
190
- ) }),
191
- N ? N(t, e) : Q(t, e)
192
- ] }, `row-${n}`)) : /* @__PURE__ */ s.jsx("tr", { children: /* @__PURE__ */ s.jsx("td", { colSpan: t.length + 1, children: /* @__PURE__ */ s.jsx(ee, {}) }) }) })
187
+ /* @__PURE__ */ t.jsx("tbody", { "data-testid": "table-body", children: n.length > 0 ? n.map((e, s) => {
188
+ const r = x(s, $);
189
+ return /* @__PURE__ */ t.jsxs(ae.Fragment, { children: [
190
+ /* @__PURE__ */ t.jsxs("tr", { children: [
191
+ l && /* @__PURE__ */ t.jsx(
192
+ "td",
193
+ {
194
+ className: "text-center cursor-pointer pr-[0]!",
195
+ onClick: () => te(s, e),
196
+ children: /* @__PURE__ */ t.jsx(
197
+ "span",
198
+ {
199
+ className: "inline-block transition-transform duration-200",
200
+ style: {
201
+ transform: r ? "rotate(90deg)" : "rotate(0deg)"
202
+ },
203
+ children: /* @__PURE__ */ t.jsx(de, { name: ce.ChevronRight })
204
+ }
205
+ )
206
+ }
207
+ ),
208
+ j && /* @__PURE__ */ t.jsx("td", { children: /* @__PURE__ */ t.jsx(
209
+ D,
210
+ {
211
+ checked: x(e, h),
212
+ name: `select-${s}`,
213
+ onChange: (i) => ee(i, e),
214
+ isDisabled: x(e, g)
215
+ }
216
+ ) }),
217
+ R ? R(a, e) : re(a, e)
218
+ ] }),
219
+ l && r && /* @__PURE__ */ t.jsx("tr", { children: /* @__PURE__ */ t.jsx(
220
+ "td",
221
+ {
222
+ colSpan: a.length + (j ? 1 : 0) + (l ? 1 : 0),
223
+ className: "p-0 border-0",
224
+ children: l.expandedRowRender(e)
225
+ }
226
+ ) })
227
+ ] }, `row-${s}`);
228
+ }) : /* @__PURE__ */ t.jsx("tr", { children: /* @__PURE__ */ t.jsx(
229
+ "td",
230
+ {
231
+ colSpan: a.length + (j ? 1 : 0) + (l ? 1 : 0),
232
+ children: /* @__PURE__ */ t.jsx(ne, {})
233
+ }
234
+ ) }) })
193
235
  ]
194
236
  }
195
237
  ) })
196
238
  ] }),
197
- B && /* @__PURE__ */ s.jsx(
198
- O,
239
+ M && /* @__PURE__ */ t.jsx(
240
+ G,
199
241
  {
200
242
  className: "mt-0",
201
- showItemsText: y,
202
- actionOnChange: m,
203
- pageSize: _,
204
- pageSizeOnChange: S,
205
- pagerOnChange: k,
206
- pagerVisible: w,
207
- pageSizeVisible: K,
208
- totalCount: l,
209
- customItem: W,
210
- headerLeftItem: U,
211
- currentPage: h,
212
- appearance: x
243
+ showItemsText: L,
244
+ actionOnChange: k,
245
+ pageSize: v,
246
+ pageSizeOnChange: y,
247
+ pagerOnChange: _,
248
+ pagerVisible: S,
249
+ pageSizeVisible: Q,
250
+ totalCount: d,
251
+ customItem: q,
252
+ headerLeftItem: P,
253
+ currentPage: u,
254
+ appearance: m
213
255
  }
214
256
  )
215
257
  ]
@@ -217,5 +259,5 @@ const Le = (i) => {
217
259
  );
218
260
  };
219
261
  export {
220
- Le as default
262
+ Oe as default
221
263
  };
package/dist/index.d.mts CHANGED
@@ -496,6 +496,12 @@ export declare interface EventProps<T = HTMLElement> {
496
496
  onInvalid?: (e: React.FormEvent<T>) => void;
497
497
  }
498
498
 
499
+ declare type ExpandableType = {
500
+ expandedRowRender: (record: any) => ReactNode;
501
+ rowExpandable?: (record: any) => boolean;
502
+ onExpand?: (expanded: boolean, record: any) => void;
503
+ };
504
+
499
505
  export declare const FileUpload: React_2.ForwardRefExoticComponent<{
500
506
  type?: "number" | "email" | "search" | "text" | "url" | "tel" | "password" | "hidden" | undefined;
501
507
  id?: string | undefined;
@@ -1316,6 +1322,7 @@ export declare type TableProps = {
1316
1322
  fixedHeader?: boolean;
1317
1323
  customHeader?: ReactNode;
1318
1324
  scrollClass?: string;
1325
+ expandable?: ExpandableType;
1319
1326
  } & TableHeaderProps;
1320
1327
 
1321
1328
  export declare const TableSort: (props: TableSortProps) => JSX_2.Element;
package/dist/index.d.ts CHANGED
@@ -496,6 +496,12 @@ export declare interface EventProps<T = HTMLElement> {
496
496
  onInvalid?: (e: React.FormEvent<T>) => void;
497
497
  }
498
498
 
499
+ declare type ExpandableType = {
500
+ expandedRowRender: (record: any) => ReactNode;
501
+ rowExpandable?: (record: any) => boolean;
502
+ onExpand?: (expanded: boolean, record: any) => void;
503
+ };
504
+
499
505
  export declare const FileUpload: React_2.ForwardRefExoticComponent<{
500
506
  type?: "number" | "email" | "search" | "text" | "url" | "tel" | "password" | "hidden" | undefined;
501
507
  id?: string | undefined;
@@ -1316,6 +1322,7 @@ export declare type TableProps = {
1316
1322
  fixedHeader?: boolean;
1317
1323
  customHeader?: ReactNode;
1318
1324
  scrollClass?: string;
1325
+ expandable?: ExpandableType;
1319
1326
  } & TableHeaderProps;
1320
1327
 
1321
1328
  export declare const TableSort: (props: TableSortProps) => JSX_2.Element;