@cagatayfdn/flora-components 0.0.131 → 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,157 +1,159 @@
1
1
  import { j as t } from "../../jsx-runtime-BcAkpsdy.js";
2
- import ae, { useState as E, useEffect as se } from "react";
2
+ import ae, { useState as F, useEffect as se } from "react";
3
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";
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
8
  import oe from "../Loading/Loading.js";
9
9
  import le from "../ScrollContainer/ScrollContainer.js";
10
- import D from "./TableHeader.js";
10
+ import G from "./TableHeader.js";
11
11
  import ie from "./TableSort.js";
12
12
  import de from "../Icon/index.js";
13
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";
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
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;
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;
22
22
  }
23
23
  var ge = /* @__PURE__ */ function() {
24
- function o(s, n) {
25
- this.xf = n, this.f = s;
24
+ function o(a, n) {
25
+ this.xf = n, this.f = a;
26
26
  }
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;
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
29
  }, o;
30
- }(), je = /* @__PURE__ */ V(function(s, n) {
31
- return new ge(s, n);
30
+ }(), je = /* @__PURE__ */ U(function(a, n) {
31
+ return new ge(a, n);
32
32
  });
33
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)) : (
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)) : (
39
39
  // else
40
- ue(o, s)
40
+ ue(o, a)
41
41
  );
42
42
  })
43
43
  );
44
44
  const Oe = (o) => {
45
45
  const {
46
- columns: s = [],
46
+ columns: a = [],
47
47
  dataSource: n = [],
48
- totalCount: l,
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,
70
- customHeader: L,
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)
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)
86
86
  )));
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(
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(
90
92
  "td",
91
93
  {
92
94
  width: r.width,
93
- onClick: (b) => {
94
- r != null && r.onClick && (r == null || r.onClick(b, a, r, c));
95
+ onClick: (p) => {
96
+ r != null && r.onClick && (r == null || r.onClick(p, s, r, i));
95
97
  },
96
- className: C(r.className, r.tdClassName),
97
- children: r.render ? r.render(a[r.dataIndex], a) : a[r.dataIndex]
98
+ className: w(r.className, r.tdClassName),
99
+ children: r.render ? r.render(s[r.dataIndex], s) : s[r.dataIndex]
98
100
  },
99
- `col-${c}`
101
+ `col-${i}`
100
102
  ));
101
103
  return se(() => {
102
- i && i(H.filter((e) => !h(e, u)));
103
- }, [d, u]), /* @__PURE__ */ t.jsxs(
104
+ c && c(T.filter((e) => !x(e, g)));
105
+ }, [h, g]), /* @__PURE__ */ t.jsxs(
104
106
  "div",
105
107
  {
106
108
  "data-testid": "table-container",
107
- className: C(p.wrapper, W, {
108
- [p[`${j}`]]: j
109
+ className: w(f.wrapper, X, {
110
+ [f[`${m}`]]: m
109
111
  }),
110
112
  children: [
111
- B && /* @__PURE__ */ t.jsx(
112
- D,
113
+ K && /* @__PURE__ */ t.jsx(
114
+ G,
113
115
  {
114
- title: X,
115
- showItemsText: v,
116
- actionOnChange: N,
117
- pageSize: y,
118
- pageSizeOnChange: R,
119
- pagerOnChange: S,
120
- pagerVisible: k,
121
- totalCount: l,
122
- currentPage: f
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
123
125
  }
124
126
  ),
125
- /* @__PURE__ */ t.jsxs("div", { className: p.tableWrap, children: [
126
- q && /* @__PURE__ */ t.jsx(
127
+ /* @__PURE__ */ t.jsxs("div", { className: f.tableWrap, children: [
128
+ J && /* @__PURE__ */ t.jsx(
127
129
  oe,
128
130
  {
129
- wrapperClass: p.tableLoading,
130
- appearance: j === F.LIGHT ? O.LIGHT : O.DARK
131
+ wrapperClass: f.tableLoading,
132
+ appearance: m === O.LIGHT ? z.LIGHT : z.DARK
131
133
  }
132
134
  ),
133
- L && L,
134
- /* @__PURE__ */ t.jsx(le, { className: Y || p.scrollWrap, children: /* @__PURE__ */ t.jsxs(
135
+ H && H,
136
+ /* @__PURE__ */ t.jsx(le, { className: Z || f.scrollWrap, children: /* @__PURE__ */ t.jsxs(
135
137
  "table",
136
138
  {
137
139
  "data-testid": "table-content",
138
- className: C(p.table, U, {
139
- [p.fixed]: Q
140
+ className: w(f.table, W, {
141
+ [f.fixed]: Y
140
142
  }),
141
143
  children: [
142
144
  /* @__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,
145
+ l && /* @__PURE__ */ t.jsx("th", { className: "w-[48px]" }),
146
+ j && /* @__PURE__ */ t.jsx("th", { className: "w-[26px]", children: /* @__PURE__ */ t.jsx(
147
+ D,
146
148
  {
147
149
  name: "selectAll",
148
150
  isDisabled: n.length === 0,
149
- checked: n.length > 0 && n.length === d.length,
150
- onChange: Z
151
+ checked: n.length > 0 && n.length === h.length,
152
+ onChange: I
151
153
  }
152
154
  ) }),
153
- s == null ? void 0 : s.map((e, a) => {
154
- var r, c;
155
+ a == null ? void 0 : a.map((e, s) => {
156
+ var r, i;
155
157
  return e.sortable ? /* @__PURE__ */ t.jsx(
156
158
  "th",
157
159
  {
@@ -162,35 +164,35 @@ const Oe = (o) => {
162
164
  ie,
163
165
  {
164
166
  title: (r = e.title) == null ? void 0 : r.toString().toLocaleUpperCase(),
165
- onClick: (b, re) => {
166
- var A;
167
- return (A = e == null ? void 0 : e.onSort) == null ? void 0 : A.call(e, b, re);
167
+ onClick: (p, b) => {
168
+ var E;
169
+ return (E = e == null ? void 0 : e.onSort) == null ? void 0 : E.call(e, p, b);
168
170
  }
169
171
  }
170
172
  )
171
173
  },
172
- `table-header-${a}`
174
+ `table-header-${s}`
173
175
  ) : /* @__PURE__ */ t.jsx(
174
176
  "th",
175
177
  {
176
178
  "data-testid": "table-head-item",
177
179
  style: { width: e.width },
178
180
  className: e.className,
179
- children: typeof e.title == "string" || e.title instanceof String ? (c = e.title) == null ? void 0 : c.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
180
182
  },
181
- `table-header-${a}`
183
+ `table-header-${s}`
182
184
  );
183
185
  })
184
186
  ] }) }),
185
- /* @__PURE__ */ t.jsx("tbody", { "data-testid": "table-body", children: n.length > 0 ? n.map((e, a) => {
186
- const r = h(a, T);
187
+ /* @__PURE__ */ t.jsx("tbody", { "data-testid": "table-body", children: n.length > 0 ? n.map((e, s) => {
188
+ const r = x(s, $);
187
189
  return /* @__PURE__ */ t.jsxs(ae.Fragment, { children: [
188
190
  /* @__PURE__ */ t.jsxs("tr", { children: [
189
- x && /* @__PURE__ */ t.jsx(
191
+ l && /* @__PURE__ */ t.jsx(
190
192
  "td",
191
193
  {
192
194
  className: "text-center cursor-pointer pr-[0]!",
193
- onClick: () => ee(a),
195
+ onClick: () => te(s, e),
194
196
  children: /* @__PURE__ */ t.jsx(
195
197
  "span",
196
198
  {
@@ -203,30 +205,30 @@ const Oe = (o) => {
203
205
  )
204
206
  }
205
207
  ),
206
- g && /* @__PURE__ */ t.jsx("td", { children: /* @__PURE__ */ t.jsx(
207
- z,
208
+ j && /* @__PURE__ */ t.jsx("td", { children: /* @__PURE__ */ t.jsx(
209
+ D,
208
210
  {
209
- checked: h(e, d),
210
- name: `select-${a}`,
211
- onChange: (c) => I(c, e),
212
- isDisabled: h(e, u)
211
+ checked: x(e, h),
212
+ name: `select-${s}`,
213
+ onChange: (i) => ee(i, e),
214
+ isDisabled: x(e, g)
213
215
  }
214
216
  ) }),
215
- _ ? _(s, e) : te(s, e)
217
+ R ? R(a, e) : re(a, e)
216
218
  ] }),
217
- x && r && /* @__PURE__ */ t.jsx("tr", { children: /* @__PURE__ */ t.jsx(
219
+ l && r && /* @__PURE__ */ t.jsx("tr", { children: /* @__PURE__ */ t.jsx(
218
220
  "td",
219
221
  {
220
- colSpan: s.length + (g ? 1 : 0) + (x ? 1 : 0),
222
+ colSpan: a.length + (j ? 1 : 0) + (l ? 1 : 0),
221
223
  className: "p-0 border-0",
222
- children: x.expandedRowRender(e)
224
+ children: l.expandedRowRender(e)
223
225
  }
224
226
  ) })
225
- ] }, `row-${a}`);
227
+ ] }, `row-${s}`);
226
228
  }) : /* @__PURE__ */ t.jsx("tr", { children: /* @__PURE__ */ t.jsx(
227
229
  "td",
228
230
  {
229
- colSpan: s.length + (g ? 1 : 0) + (x ? 1 : 0),
231
+ colSpan: a.length + (j ? 1 : 0) + (l ? 1 : 0),
230
232
  children: /* @__PURE__ */ t.jsx(ne, {})
231
233
  }
232
234
  ) }) })
@@ -234,22 +236,22 @@ const Oe = (o) => {
234
236
  }
235
237
  ) })
236
238
  ] }),
237
- J && /* @__PURE__ */ t.jsx(
238
- D,
239
+ M && /* @__PURE__ */ t.jsx(
240
+ G,
239
241
  {
240
242
  className: "mt-0",
241
- showItemsText: v,
242
- actionOnChange: N,
243
- pageSize: y,
244
- pageSizeOnChange: R,
245
- pagerOnChange: S,
246
- pagerVisible: k,
247
- pageSizeVisible: M,
248
- totalCount: l,
249
- customItem: P,
250
- headerLeftItem: K,
251
- currentPage: f,
252
- appearance: j
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
253
255
  }
254
256
  )
255
257
  ]
package/dist/index.d.mts CHANGED
@@ -499,6 +499,7 @@ export declare interface EventProps<T = HTMLElement> {
499
499
  declare type ExpandableType = {
500
500
  expandedRowRender: (record: any) => ReactNode;
501
501
  rowExpandable?: (record: any) => boolean;
502
+ onExpand?: (expanded: boolean, record: any) => void;
502
503
  };
503
504
 
504
505
  export declare const FileUpload: React_2.ForwardRefExoticComponent<{
package/dist/index.d.ts CHANGED
@@ -499,6 +499,7 @@ export declare interface EventProps<T = HTMLElement> {
499
499
  declare type ExpandableType = {
500
500
  expandedRowRender: (record: any) => ReactNode;
501
501
  rowExpandable?: (record: any) => boolean;
502
+ onExpand?: (expanded: boolean, record: any) => void;
502
503
  };
503
504
 
504
505
  export declare const FileUpload: React_2.ForwardRefExoticComponent<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cagatayfdn/flora-components",
3
- "version": "0.0.131",
3
+ "version": "0.0.132",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",