fintech-component-library 3.2.0 → 3.3.0

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,149 +1,149 @@
1
- import * as T from "react";
2
- import ae from "react";
3
- var D = { exports: {} }, Y = {};
4
- var Z;
5
- function se() {
6
- if (Z) return Y;
7
- Z = 1;
8
- var s = /* @__PURE__ */ Symbol.for("react.transitional.element"), p = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function E(_, f, d) {
10
- var g = null;
11
- if (d !== void 0 && (g = "" + d), f.key !== void 0 && (g = "" + f.key), "key" in f) {
12
- d = {};
13
- for (var y in f)
14
- y !== "key" && (d[y] = f[y]);
15
- } else d = f;
16
- return f = d.ref, {
17
- $$typeof: s,
18
- type: _,
19
- key: g,
20
- ref: f !== void 0 ? f : null,
21
- props: d
1
+ import * as m from "react";
2
+ import oe from "react";
3
+ var q = { exports: {} }, $ = {};
4
+ var ee;
5
+ function le() {
6
+ if (ee) return $;
7
+ ee = 1;
8
+ var c = /* @__PURE__ */ Symbol.for("react.transitional.element"), d = /* @__PURE__ */ Symbol.for("react.fragment");
9
+ function w(N, x, y) {
10
+ var E = null;
11
+ if (y !== void 0 && (E = "" + y), x.key !== void 0 && (E = "" + x.key), "key" in x) {
12
+ y = {};
13
+ for (var _ in x)
14
+ _ !== "key" && (y[_] = x[_]);
15
+ } else y = x;
16
+ return x = y.ref, {
17
+ $$typeof: c,
18
+ type: N,
19
+ key: E,
20
+ ref: x !== void 0 ? x : null,
21
+ props: y
22
22
  };
23
23
  }
24
- return Y.Fragment = p, Y.jsx = E, Y.jsxs = E, Y;
24
+ return $.Fragment = d, $.jsx = w, $.jsxs = w, $;
25
25
  }
26
- var I = {};
27
- var Q;
28
- function oe() {
29
- return Q || (Q = 1, process.env.NODE_ENV !== "production" && (function() {
30
- function s(e) {
26
+ var Y = {};
27
+ var te;
28
+ function ce() {
29
+ return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
30
+ function c(e) {
31
31
  if (e == null) return null;
32
32
  if (typeof e == "function")
33
- return e.$$typeof === l ? null : e.displayName || e.name || null;
33
+ return e.$$typeof === u ? null : e.displayName || e.name || null;
34
34
  if (typeof e == "string") return e;
35
35
  switch (e) {
36
- case N:
36
+ case h:
37
37
  return "Fragment";
38
- case O:
38
+ case j:
39
39
  return "Profiler";
40
- case F:
40
+ case p:
41
41
  return "StrictMode";
42
- case P:
42
+ case A:
43
43
  return "Suspense";
44
- case r:
44
+ case t:
45
45
  return "SuspenseList";
46
- case m:
46
+ case i:
47
47
  return "Activity";
48
48
  }
49
49
  if (typeof e == "object")
50
50
  switch (typeof e.tag == "number" && console.error(
51
51
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
52
52
  ), e.$$typeof) {
53
- case v:
53
+ case s:
54
54
  return "Portal";
55
- case S:
55
+ case O:
56
56
  return e.displayName || "Context";
57
- case x:
57
+ case C:
58
58
  return (e._context.displayName || "Context") + ".Consumer";
59
- case $:
60
- var n = e.render;
61
- return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
- case t:
63
- return n = e.displayName || null, n !== null ? n : s(e.type) || "Memo";
64
- case c:
65
- n = e._payload, e = e._init;
59
+ case F:
60
+ var l = e.render;
61
+ return e = e.displayName, e || (e = l.displayName || l.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
+ case o:
63
+ return l = e.displayName || null, l !== null ? l : c(e.type) || "Memo";
64
+ case a:
65
+ l = e._payload, e = e._init;
66
66
  try {
67
- return s(e(n));
67
+ return c(e(l));
68
68
  } catch {
69
69
  }
70
70
  }
71
71
  return null;
72
72
  }
73
- function p(e) {
73
+ function d(e) {
74
74
  return "" + e;
75
75
  }
76
- function E(e) {
76
+ function w(e) {
77
77
  try {
78
- p(e);
79
- var n = !1;
78
+ d(e);
79
+ var l = !1;
80
80
  } catch {
81
- n = !0;
81
+ l = !0;
82
82
  }
83
- if (n) {
84
- n = console;
85
- var o = n.error, u = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
- return o.call(
87
- n,
83
+ if (l) {
84
+ l = console;
85
+ var f = l.error, g = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
+ return f.call(
87
+ l,
88
88
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- u
90
- ), p(e);
89
+ g
90
+ ), d(e);
91
91
  }
92
92
  }
93
- function _(e) {
94
- if (e === N) return "<>";
95
- if (typeof e == "object" && e !== null && e.$$typeof === c)
93
+ function N(e) {
94
+ if (e === h) return "<>";
95
+ if (typeof e == "object" && e !== null && e.$$typeof === a)
96
96
  return "<...>";
97
97
  try {
98
- var n = s(e);
99
- return n ? "<" + n + ">" : "<...>";
98
+ var l = c(e);
99
+ return l ? "<" + l + ">" : "<...>";
100
100
  } catch {
101
101
  return "<...>";
102
102
  }
103
103
  }
104
- function f() {
105
- var e = z.A;
104
+ function x() {
105
+ var e = D.A;
106
106
  return e === null ? null : e.getOwner();
107
107
  }
108
- function d() {
108
+ function y() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
- function g(e) {
112
- if (U.call(e, "key")) {
113
- var n = Object.getOwnPropertyDescriptor(e, "key").get;
114
- if (n && n.isReactWarning) return !1;
111
+ function E(e) {
112
+ if (B.call(e, "key")) {
113
+ var l = Object.getOwnPropertyDescriptor(e, "key").get;
114
+ if (l && l.isReactWarning) return !1;
115
115
  }
116
116
  return e.key !== void 0;
117
117
  }
118
- function y(e, n) {
119
- function o() {
120
- V || (V = !0, console.error(
118
+ function _(e, l) {
119
+ function f() {
120
+ W || (W = !0, console.error(
121
121
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
122
- n
122
+ l
123
123
  ));
124
124
  }
125
- o.isReactWarning = !0, Object.defineProperty(e, "key", {
126
- get: o,
125
+ f.isReactWarning = !0, Object.defineProperty(e, "key", {
126
+ get: f,
127
127
  configurable: !0
128
128
  });
129
129
  }
130
- function k() {
131
- var e = s(this.type);
132
- return J[e] || (J[e] = !0, console.error(
130
+ function T() {
131
+ var e = c(this.type);
132
+ return I[e] || (I[e] = !0, console.error(
133
133
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
134
134
  )), e = this.props.ref, e !== void 0 ? e : null;
135
135
  }
136
- function C(e, n, o, u, B, W) {
137
- var i = o.ref;
136
+ function k(e, l, f, g, U, J) {
137
+ var v = f.ref;
138
138
  return e = {
139
- $$typeof: w,
139
+ $$typeof: P,
140
140
  type: e,
141
- key: n,
142
- props: o,
143
- _owner: u
144
- }, (i !== void 0 ? i : null) !== null ? Object.defineProperty(e, "ref", {
141
+ key: l,
142
+ props: f,
143
+ _owner: g
144
+ }, (v !== void 0 ? v : null) !== null ? Object.defineProperty(e, "ref", {
145
145
  enumerable: !1,
146
- get: k
146
+ get: T
147
147
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
148
148
  configurable: !1,
149
149
  enumerable: !1,
@@ -158,109 +158,109 @@ function oe() {
158
158
  configurable: !1,
159
159
  enumerable: !1,
160
160
  writable: !0,
161
- value: B
161
+ value: U
162
162
  }), Object.defineProperty(e, "_debugTask", {
163
163
  configurable: !1,
164
164
  enumerable: !1,
165
165
  writable: !0,
166
- value: W
166
+ value: J
167
167
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
168
168
  }
169
- function b(e, n, o, u, B, W) {
170
- var i = n.children;
171
- if (i !== void 0)
172
- if (u)
173
- if (te(i)) {
174
- for (u = 0; u < i.length; u++)
175
- j(i[u]);
176
- Object.freeze && Object.freeze(i);
169
+ function n(e, l, f, g, U, J) {
170
+ var v = l.children;
171
+ if (v !== void 0)
172
+ if (g)
173
+ if (L(v)) {
174
+ for (g = 0; g < v.length; g++)
175
+ R(v[g]);
176
+ Object.freeze && Object.freeze(v);
177
177
  } else
178
178
  console.error(
179
179
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
180
  );
181
- else j(i);
182
- if (U.call(n, "key")) {
183
- i = s(e);
184
- var A = Object.keys(n).filter(function(ne) {
181
+ else R(v);
182
+ if (B.call(l, "key")) {
183
+ v = c(e);
184
+ var z = Object.keys(l).filter(function(ne) {
185
185
  return ne !== "key";
186
186
  });
187
- u = 0 < A.length ? "{key: someKey, " + A.join(": ..., ") + ": ...}" : "{key: someKey}", H[i + u] || (A = 0 < A.length ? "{" + A.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ g = 0 < z.length ? "{key: someKey, " + z.join(": ..., ") + ": ...}" : "{key: someKey}", K[v + g] || (z = 0 < z.length ? "{" + z.join(": ..., ") + ": ...}" : "{}", console.error(
188
188
  `A props object containing a "key" prop is being spread into JSX:
189
189
  let props = %s;
190
190
  <%s {...props} />
191
191
  React keys must be passed directly to JSX without using spread:
192
192
  let props = %s;
193
193
  <%s key={someKey} {...props} />`,
194
- u,
195
- i,
196
- A,
197
- i
198
- ), H[i + u] = !0);
194
+ g,
195
+ v,
196
+ z,
197
+ v
198
+ ), K[v + g] = !0);
199
199
  }
200
- if (i = null, o !== void 0 && (E(o), i = "" + o), g(n) && (E(n.key), i = "" + n.key), "key" in n) {
201
- o = {};
202
- for (var L in n)
203
- L !== "key" && (o[L] = n[L]);
204
- } else o = n;
205
- return i && y(
206
- o,
200
+ if (v = null, f !== void 0 && (w(f), v = "" + f), E(l) && (w(l.key), v = "" + l.key), "key" in l) {
201
+ f = {};
202
+ for (var G in l)
203
+ G !== "key" && (f[G] = l[G]);
204
+ } else f = l;
205
+ return v && _(
206
+ f,
207
207
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
208
- ), C(
208
+ ), k(
209
209
  e,
210
- i,
211
- o,
212
- f(),
213
- B,
214
- W
210
+ v,
211
+ f,
212
+ x(),
213
+ U,
214
+ J
215
215
  );
216
216
  }
217
- function j(e) {
218
- R(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === c && (e._payload.status === "fulfilled" ? R(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
219
- }
220
217
  function R(e) {
221
- return typeof e == "object" && e !== null && e.$$typeof === w;
218
+ S(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === a && (e._payload.status === "fulfilled" ? S(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
219
+ }
220
+ function S(e) {
221
+ return typeof e == "object" && e !== null && e.$$typeof === P;
222
222
  }
223
- var h = ae, w = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.portal"), N = /* @__PURE__ */ Symbol.for("react.fragment"), F = /* @__PURE__ */ Symbol.for("react.strict_mode"), O = /* @__PURE__ */ Symbol.for("react.profiler"), x = /* @__PURE__ */ Symbol.for("react.consumer"), S = /* @__PURE__ */ Symbol.for("react.context"), $ = /* @__PURE__ */ Symbol.for("react.forward_ref"), P = /* @__PURE__ */ Symbol.for("react.suspense"), r = /* @__PURE__ */ Symbol.for("react.suspense_list"), t = /* @__PURE__ */ Symbol.for("react.memo"), c = /* @__PURE__ */ Symbol.for("react.lazy"), m = /* @__PURE__ */ Symbol.for("react.activity"), l = /* @__PURE__ */ Symbol.for("react.client.reference"), z = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, te = Array.isArray, M = console.createTask ? console.createTask : function() {
223
+ var b = oe, P = /* @__PURE__ */ Symbol.for("react.transitional.element"), s = /* @__PURE__ */ Symbol.for("react.portal"), h = /* @__PURE__ */ Symbol.for("react.fragment"), p = /* @__PURE__ */ Symbol.for("react.strict_mode"), j = /* @__PURE__ */ Symbol.for("react.profiler"), C = /* @__PURE__ */ Symbol.for("react.consumer"), O = /* @__PURE__ */ Symbol.for("react.context"), F = /* @__PURE__ */ Symbol.for("react.forward_ref"), A = /* @__PURE__ */ Symbol.for("react.suspense"), t = /* @__PURE__ */ Symbol.for("react.suspense_list"), o = /* @__PURE__ */ Symbol.for("react.memo"), a = /* @__PURE__ */ Symbol.for("react.lazy"), i = /* @__PURE__ */ Symbol.for("react.activity"), u = /* @__PURE__ */ Symbol.for("react.client.reference"), D = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, L = Array.isArray, M = console.createTask ? console.createTask : function() {
224
224
  return null;
225
225
  };
226
- h = {
226
+ b = {
227
227
  react_stack_bottom_frame: function(e) {
228
228
  return e();
229
229
  }
230
230
  };
231
- var V, J = {}, G = h.react_stack_bottom_frame.bind(
232
- h,
233
- d
234
- )(), X = M(_(d)), H = {};
235
- I.Fragment = N, I.jsx = function(e, n, o) {
236
- var u = 1e4 > z.recentlyCreatedOwnerStacks++;
237
- return b(
231
+ var W, I = {}, Z = b.react_stack_bottom_frame.bind(
232
+ b,
233
+ y
234
+ )(), Q = M(N(y)), K = {};
235
+ Y.Fragment = h, Y.jsx = function(e, l, f) {
236
+ var g = 1e4 > D.recentlyCreatedOwnerStacks++;
237
+ return n(
238
238
  e,
239
- n,
240
- o,
239
+ l,
240
+ f,
241
241
  !1,
242
- u ? Error("react-stack-top-frame") : G,
243
- u ? M(_(e)) : X
242
+ g ? Error("react-stack-top-frame") : Z,
243
+ g ? M(N(e)) : Q
244
244
  );
245
- }, I.jsxs = function(e, n, o) {
246
- var u = 1e4 > z.recentlyCreatedOwnerStacks++;
247
- return b(
245
+ }, Y.jsxs = function(e, l, f) {
246
+ var g = 1e4 > D.recentlyCreatedOwnerStacks++;
247
+ return n(
248
248
  e,
249
- n,
250
- o,
249
+ l,
250
+ f,
251
251
  !0,
252
- u ? Error("react-stack-top-frame") : G,
253
- u ? M(_(e)) : X
252
+ g ? Error("react-stack-top-frame") : Z,
253
+ g ? M(N(e)) : Q
254
254
  );
255
255
  };
256
- })()), I;
256
+ })()), Y;
257
257
  }
258
- var K;
259
- function ce() {
260
- return K || (K = 1, process.env.NODE_ENV === "production" ? D.exports = se() : D.exports = oe()), D.exports;
258
+ var re;
259
+ function ie() {
260
+ return re || (re = 1, process.env.NODE_ENV === "production" ? q.exports = le() : q.exports = ce()), q.exports;
261
261
  }
262
- var a = ce();
263
- const le = {
262
+ var r = ie();
263
+ const ue = {
264
264
  baseClasses: "inline-flex items-center justify-center font-medium rounded-md transition-colors duration-200 gap-2",
265
265
  focusRing: "focus:outline-none focus:ring-2 focus:ring-offset-2",
266
266
  variants: {
@@ -276,7 +276,7 @@ const le = {
276
276
  md: "px-4 py-2 text-base",
277
277
  lg: "px-6 py-3 text-lg"
278
278
  }
279
- }, ue = T.createContext(le), ie = () => T.useContext(ue), me = (...s) => s.filter(Boolean).join(" "), fe = () => /* @__PURE__ */ a.jsxs(
279
+ }, de = m.createContext(ue), me = () => m.useContext(de), xe = (...c) => c.filter(Boolean).join(" "), pe = () => /* @__PURE__ */ r.jsxs(
280
280
  "svg",
281
281
  {
282
282
  className: "animate-spin h-4 w-4 text-current",
@@ -284,7 +284,7 @@ const le = {
284
284
  role: "presentation",
285
285
  "aria-hidden": "true",
286
286
  children: [
287
- /* @__PURE__ */ a.jsx(
287
+ /* @__PURE__ */ r.jsx(
288
288
  "circle",
289
289
  {
290
290
  className: "opacity-25",
@@ -296,7 +296,7 @@ const le = {
296
296
  fill: "none"
297
297
  }
298
298
  ),
299
- /* @__PURE__ */ a.jsx(
299
+ /* @__PURE__ */ r.jsx(
300
300
  "path",
301
301
  {
302
302
  className: "opacity-75",
@@ -306,204 +306,204 @@ const le = {
306
306
  )
307
307
  ]
308
308
  }
309
- ), re = T.forwardRef(
309
+ ), X = m.forwardRef(
310
310
  ({
311
- children: s,
312
- variant: p = "primary",
313
- size: E = "md",
314
- disabled: _ = !1,
315
- className: f = "",
316
- type: d = "button",
317
- iconLeft: g,
318
- iconRight: y,
319
- isLoading: k = !1,
320
- loadingText: C,
321
- fullWidth: b = !1,
322
- as: j,
323
- ...R
324
- }, h) => {
325
- const w = j || "button", v = ie(), N = v.variants[p] ?? v.variants.primary ?? "", F = v.sizes[E] ?? v.sizes.md ?? "", O = v.focusRing ?? "", x = _ || k, S = w === "button" || !j, $ = me(
326
- v.baseClasses,
327
- O,
328
- N,
329
- F,
330
- b && "w-full",
331
- x && "opacity-50 cursor-not-allowed",
332
- f
333
- ), P = C ?? (typeof s == "string" ? s : "Loading..."), r = () => k ? /* @__PURE__ */ a.jsxs("span", { className: "inline-flex items-center gap-2", children: [
334
- /* @__PURE__ */ a.jsx(fe, {}),
335
- P && /* @__PURE__ */ a.jsx("span", { children: P })
336
- ] }) : /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
337
- g && /* @__PURE__ */ a.jsx("span", { className: "inline-flex items-center", children: g }),
338
- s && /* @__PURE__ */ a.jsx("span", { children: s }),
339
- y && /* @__PURE__ */ a.jsx("span", { className: "inline-flex items-center", children: y })
340
- ] }), t = {
341
- className: $,
342
- "aria-busy": k || void 0,
343
- "aria-disabled": !S && x ? !0 : void 0,
344
- ...R
311
+ children: c,
312
+ variant: d = "primary",
313
+ size: w = "md",
314
+ disabled: N = !1,
315
+ className: x = "",
316
+ type: y = "button",
317
+ iconLeft: E,
318
+ iconRight: _,
319
+ isLoading: T = !1,
320
+ loadingText: k,
321
+ fullWidth: n = !1,
322
+ as: R,
323
+ ...S
324
+ }, b) => {
325
+ const P = R || "button", s = me(), h = s.variants[d] ?? s.variants.primary ?? "", p = s.sizes[w] ?? s.sizes.md ?? "", j = s.focusRing ?? "", C = N || T, O = P === "button" || !R, F = xe(
326
+ s.baseClasses,
327
+ j,
328
+ h,
329
+ p,
330
+ n && "w-full",
331
+ C && "opacity-50 cursor-not-allowed",
332
+ x
333
+ ), A = k ?? (typeof c == "string" ? c : "Loading..."), t = () => T ? /* @__PURE__ */ r.jsxs("span", { className: "inline-flex items-center gap-2", children: [
334
+ /* @__PURE__ */ r.jsx(pe, {}),
335
+ A && /* @__PURE__ */ r.jsx("span", { children: A })
336
+ ] }) : /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
337
+ E && /* @__PURE__ */ r.jsx("span", { className: "inline-flex items-center", children: E }),
338
+ c && /* @__PURE__ */ r.jsx("span", { children: c }),
339
+ _ && /* @__PURE__ */ r.jsx("span", { className: "inline-flex items-center", children: _ })
340
+ ] }), o = {
341
+ className: F,
342
+ "aria-busy": T || void 0,
343
+ "aria-disabled": !O && C ? !0 : void 0,
344
+ ...S
345
345
  };
346
- if (S)
347
- return /* @__PURE__ */ a.jsx(
346
+ if (O)
347
+ return /* @__PURE__ */ r.jsx(
348
348
  "button",
349
349
  {
350
- type: d,
351
- disabled: x,
352
- ref: h,
353
- ...t,
354
- children: r()
350
+ type: y,
351
+ disabled: C,
352
+ ref: b,
353
+ ...o,
354
+ children: t()
355
355
  }
356
356
  );
357
- const c = {
358
- role: t.role ?? "button",
359
- tabIndex: t.tabIndex ?? 0,
360
- onClick: x ? void 0 : t.onClick,
361
- ...t
357
+ const a = {
358
+ role: o.role ?? "button",
359
+ tabIndex: o.tabIndex ?? 0,
360
+ onClick: C ? void 0 : o.onClick,
361
+ ...o
362
362
  };
363
- return /* @__PURE__ */ a.jsx(w, { ref: h, ...c, children: r() });
363
+ return /* @__PURE__ */ r.jsx(P, { ref: b, ...a, children: t() });
364
364
  }
365
365
  );
366
- re.displayName = "Button";
367
- const q = "block w-full rounded-md border border-slate-300 bg-white px-3 py-2 text-sm text-slate-900 placeholder-slate-400 shadow-sm focus:border-primary focus:ring-primary", ee = (s, p) => typeof p < "u" ? p : s.type === "checkbox" ? !1 : "", de = ({
368
- fields: s,
369
- initialValues: p,
370
- onSubmit: E,
371
- onChange: _,
372
- submitLabel: f = "Submit",
373
- className: d = "",
374
- layout: g = "vertical",
375
- submitButtonProps: y,
376
- actions: k,
377
- disabled: C = !1
366
+ X.displayName = "Button";
367
+ const H = "block w-full rounded-md border border-slate-300 bg-white px-3 py-2 text-sm text-slate-900 placeholder-slate-400 shadow-sm focus:border-primary focus:ring-primary", se = (c, d) => typeof d < "u" ? d : c.type === "checkbox" ? !1 : "", fe = ({
368
+ fields: c,
369
+ initialValues: d,
370
+ onSubmit: w,
371
+ onChange: N,
372
+ submitLabel: x = "Submit",
373
+ className: y = "",
374
+ layout: E = "vertical",
375
+ submitButtonProps: _,
376
+ actions: T,
377
+ disabled: k = !1
378
378
  }) => {
379
- const [b, j] = T.useState(() => s.reduce((r, t) => (r[t.name] = ee(t, p?.[t.name]), r), {})), [R, h] = T.useState({}), [w, v] = T.useState(!1), N = g === "horizontal" ? "grid gap-6 md:grid-cols-2" : "flex flex-col gap-6", F = T.useCallback(() => {
380
- j(
381
- s.reduce((r, t) => (r[t.name] = ee(t, p?.[t.name]), r), {})
382
- ), h({});
383
- }, [s, p]), O = T.useCallback(
384
- (r, t) => {
385
- if (r.required && (r.type === "checkbox" ? t !== !0 : t === "" || t === void 0))
386
- return `${r.label} is required.`;
387
- if (r.validate)
388
- return r.validate(t, b);
379
+ const [n, R] = m.useState(() => c.reduce((t, o) => (t[o.name] = se(o, d?.[o.name]), t), {})), [S, b] = m.useState({}), [P, s] = m.useState(!1), h = E === "horizontal" ? "grid gap-6 md:grid-cols-2" : "flex flex-col gap-6", p = m.useCallback(() => {
380
+ R(
381
+ c.reduce((t, o) => (t[o.name] = se(o, d?.[o.name]), t), {})
382
+ ), b({});
383
+ }, [c, d]), j = m.useCallback(
384
+ (t, o) => {
385
+ if (t.required && (t.type === "checkbox" ? o !== !0 : o === "" || o === void 0))
386
+ return `${t.label} is required.`;
387
+ if (t.validate)
388
+ return t.validate(o, n);
389
389
  },
390
- [b]
391
- ), x = (r, t) => {
392
- j((c) => {
393
- const m = { ...c, [r]: t };
394
- return _?.(m), m;
390
+ [n]
391
+ ), C = (t, o) => {
392
+ R((a) => {
393
+ const i = { ...a, [t]: o };
394
+ return N?.(i), i;
395
395
  });
396
- }, S = (r) => {
397
- const t = O(r, b[r.name]);
398
- h((c) => ({ ...c, [r.name]: t }));
399
- }, $ = async (r) => {
400
- r.preventDefault();
401
- const t = s.reduce(
402
- (m, l) => (m[l.name] = O(l, b[l.name]), m),
396
+ }, O = (t) => {
397
+ const o = j(t, n[t.name]);
398
+ b((a) => ({ ...a, [t.name]: o }));
399
+ }, F = async (t) => {
400
+ t.preventDefault();
401
+ const o = c.reduce(
402
+ (i, u) => (i[u.name] = j(u, n[u.name]), i),
403
403
  {}
404
404
  );
405
- if (h(t), !Object.values(t).some(Boolean))
405
+ if (b(o), !Object.values(o).some(Boolean))
406
406
  try {
407
- v(!0), await Promise.resolve(E(b, { reset: F }));
407
+ s(!0), await Promise.resolve(w(n, { reset: p }));
408
408
  } finally {
409
- v(!1);
409
+ s(!1);
410
410
  }
411
- }, P = (r, t, c) => {
412
- if (r.component)
413
- return r.component({
414
- field: r,
415
- value: t,
416
- error: R[r.name],
417
- id: c,
418
- onChange: (l) => x(r.name, l),
419
- onBlur: () => S(r)
411
+ }, A = (t, o, a) => {
412
+ if (t.component)
413
+ return t.component({
414
+ field: t,
415
+ value: o,
416
+ error: S[t.name],
417
+ id: a,
418
+ onChange: (u) => C(t.name, u),
419
+ onBlur: () => O(t)
420
420
  });
421
- const m = {
422
- id: c,
423
- name: r.name,
424
- onBlur: () => S(r),
425
- disabled: C,
426
- "aria-invalid": R[r.name] ? "true" : void 0,
427
- "aria-describedby": R[r.name] ? `${c}-error` : r.helperText ? `${c}-helper` : void 0
421
+ const i = {
422
+ id: a,
423
+ name: t.name,
424
+ onBlur: () => O(t),
425
+ disabled: k,
426
+ "aria-invalid": S[t.name] ? "true" : void 0,
427
+ "aria-describedby": S[t.name] ? `${a}-error` : t.helperText ? `${a}-helper` : void 0
428
428
  };
429
- return r.type === "textarea" ? /* @__PURE__ */ a.jsx(
429
+ return t.type === "textarea" ? /* @__PURE__ */ r.jsx(
430
430
  "textarea",
431
431
  {
432
- ...m,
433
- className: q,
434
- placeholder: r.placeholder,
435
- value: t ?? "",
436
- onChange: (l) => x(r.name, l.target.value),
432
+ ...i,
433
+ className: H,
434
+ placeholder: t.placeholder,
435
+ value: o ?? "",
436
+ onChange: (u) => C(t.name, u.target.value),
437
437
  rows: 4
438
438
  }
439
- ) : r.type === "select" ? /* @__PURE__ */ a.jsxs(
439
+ ) : t.type === "select" ? /* @__PURE__ */ r.jsxs(
440
440
  "select",
441
441
  {
442
- ...m,
443
- className: q,
444
- value: t ?? "",
445
- onChange: (l) => x(r.name, l.target.value),
442
+ ...i,
443
+ className: H,
444
+ value: o ?? "",
445
+ onChange: (u) => C(t.name, u.target.value),
446
446
  children: [
447
- /* @__PURE__ */ a.jsx("option", { value: "", disabled: !0, children: r.placeholder ?? "Select an option" }),
448
- r.options?.map((l) => /* @__PURE__ */ a.jsx("option", { value: l.value, children: l.label }, l.value))
447
+ /* @__PURE__ */ r.jsx("option", { value: "", disabled: !0, children: t.placeholder ?? "Select an option" }),
448
+ t.options?.map((u) => /* @__PURE__ */ r.jsx("option", { value: u.value, children: u.label }, u.value))
449
449
  ]
450
450
  }
451
- ) : r.type === "checkbox" ? /* @__PURE__ */ a.jsxs("div", { className: "flex items-center gap-2", children: [
452
- /* @__PURE__ */ a.jsx(
451
+ ) : t.type === "checkbox" ? /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2", children: [
452
+ /* @__PURE__ */ r.jsx(
453
453
  "input",
454
454
  {
455
- ...m,
455
+ ...i,
456
456
  type: "checkbox",
457
- checked: !!t,
458
- onChange: (l) => x(r.name, l.target.checked),
457
+ checked: !!o,
458
+ onChange: (u) => C(t.name, u.target.checked),
459
459
  className: "h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"
460
460
  }
461
461
  ),
462
- /* @__PURE__ */ a.jsx("label", { htmlFor: c, className: "text-sm text-slate-700 font-medium", children: r.label })
463
- ] }) : /* @__PURE__ */ a.jsx(
462
+ /* @__PURE__ */ r.jsx("label", { htmlFor: a, className: "text-sm text-slate-700 font-medium", children: t.label })
463
+ ] }) : /* @__PURE__ */ r.jsx(
464
464
  "input",
465
465
  {
466
- ...m,
467
- type: r.type,
468
- className: q,
469
- placeholder: r.placeholder,
470
- value: t ?? "",
471
- onChange: (l) => x(r.name, l.target.value)
466
+ ...i,
467
+ type: t.type,
468
+ className: H,
469
+ placeholder: t.placeholder,
470
+ value: o ?? "",
471
+ onChange: (u) => C(t.name, u.target.value)
472
472
  }
473
473
  );
474
474
  };
475
- return /* @__PURE__ */ a.jsxs(
475
+ return /* @__PURE__ */ r.jsxs(
476
476
  "form",
477
477
  {
478
- className: `rounded-xl border border-slate-200 bg-white p-6 shadow-sm ${d}`,
479
- onSubmit: $,
478
+ className: `rounded-xl border border-slate-200 bg-white p-6 shadow-sm ${y}`,
479
+ onSubmit: F,
480
480
  noValidate: !0,
481
481
  children: [
482
- /* @__PURE__ */ a.jsx("div", { className: N, children: s.map((r) => {
483
- const t = `form-${r.name}`, c = b[r.name], m = R[r.name];
484
- return /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col gap-2", children: [
485
- r.type !== "checkbox" && /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col gap-1", children: [
486
- /* @__PURE__ */ a.jsxs("label", { htmlFor: t, className: "text-sm font-medium text-slate-700", children: [
487
- r.label,
488
- r.required && /* @__PURE__ */ a.jsx("span", { className: "text-danger", children: "*" })
482
+ /* @__PURE__ */ r.jsx("div", { className: h, children: c.map((t) => {
483
+ const o = `form-${t.name}`, a = n[t.name], i = S[t.name];
484
+ return /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col gap-2", children: [
485
+ t.type !== "checkbox" && /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col gap-1", children: [
486
+ /* @__PURE__ */ r.jsxs("label", { htmlFor: o, className: "text-sm font-medium text-slate-700", children: [
487
+ t.label,
488
+ t.required && /* @__PURE__ */ r.jsx("span", { className: "text-danger", children: "*" })
489
489
  ] }),
490
- r.description && /* @__PURE__ */ a.jsx("p", { className: "text-xs text-slate-500", children: r.description })
490
+ t.description && /* @__PURE__ */ r.jsx("p", { className: "text-xs text-slate-500", children: t.description })
491
491
  ] }),
492
- P(r, c, t),
493
- r.helperText && !m && r.type !== "checkbox" && /* @__PURE__ */ a.jsx("p", { id: `${t}-helper`, className: "text-xs text-slate-500", children: r.helperText }),
494
- m && /* @__PURE__ */ a.jsx("p", { id: `${t}-error`, className: "text-xs text-danger", children: m })
495
- ] }, r.name);
492
+ A(t, a, o),
493
+ t.helperText && !i && t.type !== "checkbox" && /* @__PURE__ */ r.jsx("p", { id: `${o}-helper`, className: "text-xs text-slate-500", children: t.helperText }),
494
+ i && /* @__PURE__ */ r.jsx("p", { id: `${o}-error`, className: "text-xs text-danger", children: i })
495
+ ] }, t.name);
496
496
  }) }),
497
- /* @__PURE__ */ a.jsxs("div", { className: "mt-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
498
- k,
499
- /* @__PURE__ */ a.jsx(
500
- re,
497
+ /* @__PURE__ */ r.jsxs("div", { className: "mt-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
498
+ T,
499
+ /* @__PURE__ */ r.jsx(
500
+ X,
501
501
  {
502
502
  type: "submit",
503
- isLoading: w,
504
- disabled: C,
505
- ...y,
506
- children: f
503
+ isLoading: P,
504
+ disabled: k,
505
+ ..._,
506
+ children: x
507
507
  }
508
508
  )
509
509
  ] })
@@ -511,8 +511,274 @@ const q = "block w-full rounded-md border border-slate-300 bg-white px-3 py-2 te
511
511
  }
512
512
  );
513
513
  };
514
- de.displayName = "Form";
514
+ fe.displayName = "Form";
515
+ const he = (c, d) => {
516
+ if (!d) return !0;
517
+ const w = d.toLowerCase();
518
+ return Object.values(c ?? {}).some(
519
+ (N) => String(N ?? "").toLowerCase().includes(w)
520
+ );
521
+ };
522
+ function be({
523
+ data: c,
524
+ columns: d,
525
+ initialPageSize: w,
526
+ globalFilter: N
527
+ }) {
528
+ const [x, y] = m.useState(void 0), [E, _] = m.useState(""), [T, k] = m.useState(0), [n, R] = m.useState(w), [S, b] = m.useState(
529
+ () => d.reduce((a, i) => (a[i.id] = i.width, a), {})
530
+ ), P = N ?? he, s = m.useMemo(() => E ? c.filter((a) => P(a, E)) : c, [c, P, E]), h = m.useMemo(() => {
531
+ if (!x) return s;
532
+ const a = d.find((D) => D.id === x.columnId);
533
+ if (!a) return s;
534
+ const i = a.accessor, u = x.direction === "asc" ? 1 : -1;
535
+ return [...s].sort((D, B) => {
536
+ const L = (I) => typeof i == "function" ? i(I) : I[i], M = L(D), W = L(B);
537
+ return M === W ? 0 : M == null ? -1 * u : W == null ? 1 * u : M > W ? u : -u;
538
+ });
539
+ }, [s, x, d]), p = h.length, j = Math.max(1, Math.ceil(p / n)), C = m.useMemo(() => {
540
+ const a = T * n;
541
+ return h.slice(a, a + n);
542
+ }, [T, n, h]), O = m.useCallback(
543
+ (a) => {
544
+ y((i) => {
545
+ if (i?.columnId === a) {
546
+ const u = i.direction === "asc" ? "desc" : "asc";
547
+ return { columnId: a, direction: u };
548
+ }
549
+ return { columnId: a, direction: "asc" };
550
+ });
551
+ },
552
+ []
553
+ ), F = m.useCallback((a) => {
554
+ R(a), k(0);
555
+ }, []), A = m.useCallback((a, i) => {
556
+ b((u) => ({
557
+ ...u,
558
+ [a]: Math.max(i, 64)
559
+ }));
560
+ }, []), t = m.useCallback(() => {
561
+ k((a) => Math.min(a + 1, j - 1));
562
+ }, [j]), o = m.useCallback(() => {
563
+ k((a) => Math.max(a - 1, 0));
564
+ }, []);
565
+ return {
566
+ sort: x,
567
+ filterValue: E,
568
+ pageIndex: T,
569
+ pageSize: n,
570
+ columnWidths: S,
571
+ paginatedData: C,
572
+ totalRows: p,
573
+ pageCount: j,
574
+ setSort: O,
575
+ setFilterValue: (a) => {
576
+ _(a), k(0);
577
+ },
578
+ setPageIndex: k,
579
+ setPageSize: F,
580
+ setColumnWidth: A,
581
+ nextPage: t,
582
+ previousPage: o
583
+ };
584
+ }
585
+ const V = (...c) => c.filter(Boolean).join(" "), ae = {
586
+ left: "text-left",
587
+ center: "text-center",
588
+ right: "text-right"
589
+ }, ge = ({
590
+ data: c,
591
+ columns: d,
592
+ pageSizeOptions: w = [10, 25, 50],
593
+ initialPageSize: N = w[0] ?? 10,
594
+ globalFilter: x,
595
+ stickyHeader: y = !0,
596
+ className: E,
597
+ emptyMessage: _ = "No data to display.",
598
+ renderToolbar: T,
599
+ rowKey: k
600
+ }) => {
601
+ const n = be({
602
+ data: c,
603
+ columns: d,
604
+ initialPageSize: N,
605
+ globalFilter: x
606
+ }), [R, S] = m.useState(null), b = m.useRef(null);
607
+ m.useEffect(() => {
608
+ if (!R) return;
609
+ const s = (p) => {
610
+ if (b.current == null) {
611
+ b.current = p.clientX;
612
+ return;
613
+ }
614
+ const j = p.clientX - b.current;
615
+ b.current = p.clientX, n.setColumnWidth(
616
+ R,
617
+ (n.columnWidths[R] ?? 0) + j
618
+ );
619
+ }, h = () => {
620
+ S(null), b.current = null;
621
+ };
622
+ return window.addEventListener("mousemove", s), window.addEventListener("mouseup", h), () => {
623
+ window.removeEventListener("mousemove", s), window.removeEventListener("mouseup", h);
624
+ };
625
+ }, [R, n]);
626
+ const P = T?.({
627
+ filterValue: n.filterValue,
628
+ setFilterValue: n.setFilterValue
629
+ }) ?? /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
630
+ /* @__PURE__ */ r.jsx(
631
+ "input",
632
+ {
633
+ type: "search",
634
+ placeholder: "Filter rows...",
635
+ value: n.filterValue,
636
+ onChange: (s) => n.setFilterValue(s.target.value),
637
+ className: "w-full max-w-sm rounded-md border border-slate-300 px-3 py-2 text-sm focus:border-primary focus:ring-primary"
638
+ }
639
+ ),
640
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2 text-sm text-slate-500", children: [
641
+ "Showing ",
642
+ n.paginatedData.length,
643
+ " of ",
644
+ n.totalRows,
645
+ " rows"
646
+ ] })
647
+ ] });
648
+ return /* @__PURE__ */ r.jsxs("div", { className: V("flex flex-col gap-4", E), children: [
649
+ P,
650
+ /* @__PURE__ */ r.jsx("div", { className: "relative", children: /* @__PURE__ */ r.jsx("div", { className: "overflow-auto rounded-xl border border-slate-200 shadow-sm", children: /* @__PURE__ */ r.jsxs("table", { className: "min-w-full border-collapse", role: "grid", children: [
651
+ /* @__PURE__ */ r.jsx(
652
+ "thead",
653
+ {
654
+ className: V(
655
+ "bg-slate-50 text-left text-xs font-semibold uppercase text-slate-500",
656
+ y && "sticky top-0 z-10"
657
+ ),
658
+ children: /* @__PURE__ */ r.jsx("tr", { children: d.map((s) => {
659
+ const h = n.sort?.columnId === s.id, p = h ? n.sort?.direction === "asc" ? "ascending" : "descending" : "none", j = n.columnWidths[s.id];
660
+ return /* @__PURE__ */ r.jsxs(
661
+ "th",
662
+ {
663
+ scope: "col",
664
+ "aria-sort": p,
665
+ style: j ? { width: j, minWidth: s.minWidth, maxWidth: s.maxWidth } : {
666
+ minWidth: s.minWidth,
667
+ maxWidth: s.maxWidth
668
+ },
669
+ className: V(
670
+ "group relative select-none border-b border-slate-200 px-4 py-3 text-sm font-semibold text-slate-600",
671
+ s.align ? ae[s.align] : "text-left",
672
+ s.sticky && "sticky left-0 bg-slate-50"
673
+ ),
674
+ children: [
675
+ /* @__PURE__ */ r.jsxs(
676
+ "button",
677
+ {
678
+ type: "button",
679
+ className: V(
680
+ "inline-flex items-center gap-1 text-inherit",
681
+ s.sortable && "cursor-pointer"
682
+ ),
683
+ onClick: () => s.sortable && n.setSort(s.id),
684
+ "aria-label": s.sortable ? `Sort by ${s.id}` : void 0,
685
+ children: [
686
+ s.header,
687
+ s.sortable && /* @__PURE__ */ r.jsx("span", { className: "text-xs text-slate-400", children: h ? n.sort?.direction === "asc" ? "▲" : "▼" : "⇅" })
688
+ ]
689
+ }
690
+ ),
691
+ /* @__PURE__ */ r.jsx(
692
+ "span",
693
+ {
694
+ role: "separator",
695
+ className: "absolute right-0 top-0 h-full w-1 cursor-col-resize opacity-0 transition group-hover:opacity-100",
696
+ onMouseDown: () => S(s.id)
697
+ }
698
+ )
699
+ ]
700
+ },
701
+ s.id
702
+ );
703
+ }) })
704
+ }
705
+ ),
706
+ /* @__PURE__ */ r.jsx("tbody", { className: "bg-white text-sm text-slate-700", children: n.paginatedData.length === 0 ? /* @__PURE__ */ r.jsx("tr", { children: /* @__PURE__ */ r.jsx(
707
+ "td",
708
+ {
709
+ className: "px-4 py-6 text-center text-slate-500",
710
+ colSpan: d.length,
711
+ children: _
712
+ }
713
+ ) }) : n.paginatedData.map((s, h) => /* @__PURE__ */ r.jsx(
714
+ "tr",
715
+ {
716
+ className: "border-b border-slate-100 last:border-0 odd:bg-white even:bg-slate-50/30",
717
+ children: d.map((p) => {
718
+ const j = typeof p.accessor == "function" ? p.accessor(s) : s[p.accessor];
719
+ return /* @__PURE__ */ r.jsx(
720
+ "td",
721
+ {
722
+ className: V(
723
+ "px-4 py-3 align-middle",
724
+ p.align ? ae[p.align] : "text-left"
725
+ ),
726
+ children: p.cell ? p.cell({ value: j, row: s, rowIndex: h }) : String(j ?? "—")
727
+ },
728
+ p.id
729
+ );
730
+ })
731
+ },
732
+ k?.(s, h) ?? h
733
+ )) })
734
+ ] }) }) }),
735
+ /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col gap-3 border-t border-slate-200 pt-4 text-sm text-slate-600 sm:flex-row sm:items-center sm:justify-between", children: [
736
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2", children: [
737
+ /* @__PURE__ */ r.jsx("span", { children: "Rows per page" }),
738
+ /* @__PURE__ */ r.jsx(
739
+ "select",
740
+ {
741
+ value: n.pageSize,
742
+ onChange: (s) => n.setPageSize(Number(s.target.value)),
743
+ className: "rounded-md border border-slate-300 px-2 py-1 text-sm",
744
+ children: w.map((s) => /* @__PURE__ */ r.jsx("option", { value: s, children: s }, s))
745
+ }
746
+ )
747
+ ] }),
748
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2", children: [
749
+ /* @__PURE__ */ r.jsx(
750
+ X,
751
+ {
752
+ variant: "secondary",
753
+ size: "sm",
754
+ onClick: n.previousPage,
755
+ disabled: n.pageIndex === 0,
756
+ children: "Previous"
757
+ }
758
+ ),
759
+ /* @__PURE__ */ r.jsxs("span", { className: "px-2 text-xs font-medium", children: [
760
+ "Page ",
761
+ n.pageIndex + 1,
762
+ " of ",
763
+ n.pageCount
764
+ ] }),
765
+ /* @__PURE__ */ r.jsx(
766
+ X,
767
+ {
768
+ variant: "secondary",
769
+ size: "sm",
770
+ onClick: n.nextPage,
771
+ disabled: n.pageIndex + 1 >= n.pageCount,
772
+ children: "Next"
773
+ }
774
+ )
775
+ ] })
776
+ ] })
777
+ ] });
778
+ };
779
+ ge.displayName = "DataTable";
515
780
  export {
516
- re as Button,
517
- de as Form
781
+ X as Button,
782
+ ge as DataTable,
783
+ fe as Form
518
784
  };