@cagatayfdn/flora-components 0.0.130 → 0.0.131

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