@kaushalparajuli/react-crud-ui 1.0.0 → 1.0.2

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.
package/dist/index.js CHANGED
@@ -2878,7 +2878,7 @@ const Yr = ie("X", [
2878
2878
  size: "default"
2879
2879
  }
2880
2880
  }
2881
- ), ue = l.forwardRef(
2881
+ ), ce = l.forwardRef(
2882
2882
  ({ className: e, variant: t, size: r, asChild: n = !1, loading: o = !1, children: s, disabled: i, ...a }, c) => /* @__PURE__ */ M(
2883
2883
  n ? Nd : "button",
2884
2884
  {
@@ -2893,7 +2893,7 @@ const Yr = ie("X", [
2893
2893
  }
2894
2894
  )
2895
2895
  );
2896
- ue.displayName = "Button";
2896
+ ce.displayName = "Button";
2897
2897
  const bt = l.forwardRef(({ className: e, ...t }, r) => /* @__PURE__ */ d(
2898
2898
  "div",
2899
2899
  {
@@ -12016,7 +12016,7 @@ const od = ({
12016
12016
  ] }),
12017
12017
  /* @__PURE__ */ M("div", { className: "flex items-center gap-1", children: [
12018
12018
  /* @__PURE__ */ M(
12019
- ue,
12019
+ ce,
12020
12020
  {
12021
12021
  variant: "outline",
12022
12022
  size: "icon",
@@ -12030,7 +12030,7 @@ const od = ({
12030
12030
  }
12031
12031
  ),
12032
12032
  /* @__PURE__ */ M(
12033
- ue,
12033
+ ce,
12034
12034
  {
12035
12035
  variant: "outline",
12036
12036
  size: "icon",
@@ -12044,7 +12044,7 @@ const od = ({
12044
12044
  }
12045
12045
  ),
12046
12046
  /* @__PURE__ */ d("div", { className: "flex items-center gap-1", children: v().map((h, y) => h === "..." ? /* @__PURE__ */ d("span", { className: "px-2 text-muted-foreground", children: "..." }, `ellipsis-${y}`) : /* @__PURE__ */ d(
12047
- ue,
12047
+ ce,
12048
12048
  {
12049
12049
  variant: e === h ? "default" : "outline",
12050
12050
  size: "icon",
@@ -12055,7 +12055,7 @@ const od = ({
12055
12055
  h
12056
12056
  )) }),
12057
12057
  /* @__PURE__ */ M(
12058
- ue,
12058
+ ce,
12059
12059
  {
12060
12060
  variant: "outline",
12061
12061
  size: "icon",
@@ -12069,7 +12069,7 @@ const od = ({
12069
12069
  }
12070
12070
  ),
12071
12071
  /* @__PURE__ */ M(
12072
- ue,
12072
+ ce,
12073
12073
  {
12074
12074
  variant: "outline",
12075
12075
  size: "icon",
@@ -12177,22 +12177,19 @@ const Dx = l.forwardRef(({
12177
12177
  disabled: n,
12178
12178
  className: o,
12179
12179
  ...s
12180
- }, i) => {
12181
- const a = require("../ui/button").Button;
12182
- return /* @__PURE__ */ d(
12183
- a,
12184
- {
12185
- ref: i,
12186
- disabled: n || e,
12187
- className: o,
12188
- ...s,
12189
- children: e ? /* @__PURE__ */ M(Re, { children: [
12190
- /* @__PURE__ */ d($t, { className: "mr-2 h-4 w-4 animate-spin" }),
12191
- t || "Loading..."
12192
- ] }) : r
12193
- }
12194
- );
12195
- });
12180
+ }, i) => /* @__PURE__ */ d(
12181
+ ce,
12182
+ {
12183
+ ref: i,
12184
+ disabled: n || e,
12185
+ className: o,
12186
+ ...s,
12187
+ children: e ? /* @__PURE__ */ M(Re, { children: [
12188
+ /* @__PURE__ */ d($t, { className: "mr-2 h-4 w-4 animate-spin" }),
12189
+ t || "Loading..."
12190
+ ] }) : r
12191
+ }
12192
+ ));
12196
12193
  Dx.displayName = "LoadingButton";
12197
12194
  const yr = ({
12198
12195
  icon: e = bs,
@@ -12239,7 +12236,7 @@ const yr = ({
12239
12236
  /* @__PURE__ */ d("h3", { className: "text-lg font-semibold mb-2", children: m }),
12240
12237
  /* @__PURE__ */ d("p", { className: "text-sm text-muted-foreground mb-6 max-w-sm", children: g }),
12241
12238
  c,
12242
- (n || s) && /* @__PURE__ */ d(ue, { onClick: s, children: o || "Take Action" })
12239
+ (n || s) && /* @__PURE__ */ d(ce, { onClick: s, children: o || "Take Action" })
12243
12240
  ]
12244
12241
  }
12245
12242
  );
@@ -12256,7 +12253,7 @@ const sd = ({
12256
12253
  title: `No results for "${e}"`,
12257
12254
  description: "Try searching with different keywords or check your filters.",
12258
12255
  className: r,
12259
- children: t && /* @__PURE__ */ d(ue, { variant: "outline", onClick: t, children: "Clear Search" })
12256
+ children: t && /* @__PURE__ */ d(ce, { variant: "outline", onClick: t, children: "Clear Search" })
12260
12257
  }
12261
12258
  );
12262
12259
  sd.displayName = "SearchEmptyState";
@@ -12347,11 +12344,11 @@ const id = ({
12347
12344
  size: "sm",
12348
12345
  className: p,
12349
12346
  footer: /* @__PURE__ */ M("div", { className: "flex gap-2 justify-end", children: [
12350
- /* @__PURE__ */ d(ue, { variant: "outline", onClick: () => {
12347
+ /* @__PURE__ */ d(ce, { variant: "outline", onClick: () => {
12351
12348
  n == null || n(), t == null || t(!1);
12352
12349
  }, disabled: u, children: a }),
12353
12350
  /* @__PURE__ */ d(
12354
- ue,
12351
+ ce,
12355
12352
  {
12356
12353
  variant: c === "destructive" ? "destructive" : "default",
12357
12354
  onClick: async () => {
@@ -12412,7 +12409,7 @@ const $x = ({
12412
12409
  /* @__PURE__ */ d("div", { className: "py-4", children: s }),
12413
12410
  /* @__PURE__ */ M(Ho, { children: [
12414
12411
  /* @__PURE__ */ d(
12415
- ue,
12412
+ ce,
12416
12413
  {
12417
12414
  type: "button",
12418
12415
  variant: "outline",
@@ -12421,7 +12418,7 @@ const $x = ({
12421
12418
  children: a
12422
12419
  }
12423
12420
  ),
12424
- /* @__PURE__ */ d(ue, { type: "submit", disabled: c, children: c ? "Saving..." : i })
12421
+ /* @__PURE__ */ d(ce, { type: "submit", disabled: c, children: c ? "Saving..." : i })
12425
12422
  ] })
12426
12423
  ] })
12427
12424
  }
@@ -12503,7 +12500,7 @@ const ad = ({
12503
12500
  if (!P || P.length === 0) return null;
12504
12501
  const Z = P.filter((G) => G.hidden ? typeof G.hidden == "function" ? !G.hidden(W) : !G.hidden : !0);
12505
12502
  return Z.length === 0 ? null : /* @__PURE__ */ M(Zw, { children: [
12506
- /* @__PURE__ */ d(Qw, { asChild: !0, children: /* @__PURE__ */ M(ue, { variant: "ghost", size: "icon", className: "h-8 w-8", children: [
12503
+ /* @__PURE__ */ d(Qw, { asChild: !0, children: /* @__PURE__ */ M(ce, { variant: "ghost", size: "icon", className: "h-8 w-8", children: [
12507
12504
  /* @__PURE__ */ d(Rf, { className: "h-4 w-4" }),
12508
12505
  /* @__PURE__ */ d("span", { className: "sr-only", children: "Open menu" })
12509
12506
  ] }) }),
@@ -12531,7 +12528,7 @@ const ad = ({
12531
12528
  ] })
12532
12529
  ] });
12533
12530
  };
12534
- return /* @__PURE__ */ M("div", { className: D("w-full", T), ...Y, children: [
12531
+ return /* @__PURE__ */ M("div", { className: D("w-full", T), children: [
12535
12532
  (h || S.length > 0) && /* @__PURE__ */ M("div", { className: "flex items-center justify-between gap-4 mb-4", children: [
12536
12533
  h && /* @__PURE__ */ M("div", { className: "relative max-w-sm", children: [
12537
12534
  /* @__PURE__ */ d(mo, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" }),
@@ -12559,7 +12556,7 @@ const ad = ({
12559
12556
  S.length,
12560
12557
  " row(s) selected",
12561
12558
  /* @__PURE__ */ d(
12562
- ue,
12559
+ ce,
12563
12560
  {
12564
12561
  variant: "ghost",
12565
12562
  size: "sm",
@@ -12768,7 +12765,7 @@ const Lx = ({
12768
12765
  }
12769
12766
  }, Ye = () => ne ? /* @__PURE__ */ M("div", { className: "flex items-center gap-2", children: [
12770
12767
  y && b.length > 0 && L.length > 0 && /* @__PURE__ */ d(Re, { children: L.map((Ce, We) => /* @__PURE__ */ M(
12771
- ue,
12768
+ ce,
12772
12769
  {
12773
12770
  variant: Ce.variant || "outline",
12774
12771
  size: "sm",
@@ -12784,12 +12781,12 @@ const Lx = ({
12784
12781
  },
12785
12782
  Ce.label || We
12786
12783
  )) }),
12787
- $ && /* @__PURE__ */ M(ue, { variant: "outline", size: "sm", onClick: $, children: [
12784
+ $ && /* @__PURE__ */ M(ce, { variant: "outline", size: "sm", onClick: $, children: [
12788
12785
  /* @__PURE__ */ d(Nf, { className: "mr-2 h-4 w-4" }),
12789
12786
  Q
12790
12787
  ] }),
12791
12788
  _ && /* @__PURE__ */ M(
12792
- ue,
12789
+ ce,
12793
12790
  {
12794
12791
  variant: "outline",
12795
12792
  size: "sm",
@@ -12801,7 +12798,7 @@ const Lx = ({
12801
12798
  ]
12802
12799
  }
12803
12800
  ),
12804
- x && /* @__PURE__ */ M(ue, { size: "sm", onClick: x, children: [
12801
+ x && /* @__PURE__ */ M(ce, { size: "sm", onClick: x, children: [
12805
12802
  /* @__PURE__ */ d(Af, { className: "mr-2 h-4 w-4" }),
12806
12803
  B
12807
12804
  ] })
@@ -12834,8 +12831,7 @@ const Lx = ({
12834
12831
  emptyTitle: `No ${O}s found`,
12835
12832
  emptyDescription: `Create your first ${O} to get started.`,
12836
12833
  emptyAction: x ? `Create ${O}` : void 0,
12837
- onEmptyAction: x,
12838
- ...q
12834
+ onEmptyAction: x
12839
12835
  }
12840
12836
  ),
12841
12837
  /* @__PURE__ */ d(
@@ -13362,12 +13358,12 @@ function sS(e = {}) {
13362
13358
  if (!t.disabled) {
13363
13359
  if (!A || K) {
13364
13360
  (p.isDirty || f.isDirty) && (ee = r.isDirty, r.isDirty = ae.isDirty = T(), F = ee !== ae.isDirty);
13365
- const ce = ft(X(o, C), N);
13366
- ee = !!X(r.dirtyFields, C), ce ? we(r.dirtyFields, C) : le(r.dirtyFields, C, !0), ae.dirtyFields = r.dirtyFields, F = F || (p.dirtyFields || f.dirtyFields) && ee !== !ce;
13361
+ const ue = ft(X(o, C), N);
13362
+ ee = !!X(r.dirtyFields, C), ue ? we(r.dirtyFields, C) : le(r.dirtyFields, C, !0), ae.dirtyFields = r.dirtyFields, F = F || (p.dirtyFields || f.dirtyFields) && ee !== !ue;
13367
13363
  }
13368
13364
  if (A) {
13369
- const ce = X(r.touchedFields, C);
13370
- ce || (le(r.touchedFields, C, A), ae.touchedFields = r.touchedFields, F = F || (p.touchedFields || f.touchedFields) && ce !== A);
13365
+ const ue = X(r.touchedFields, C);
13366
+ ue || (le(r.touchedFields, C, A), ae.touchedFields = r.touchedFields, F = F || (p.touchedFields || f.touchedFields) && ue !== A);
13371
13367
  }
13372
13368
  F && H && m.state.next(ae);
13373
13369
  }
@@ -13408,10 +13404,10 @@ function sS(e = {}) {
13408
13404
  if (H) {
13409
13405
  const { _f: F, ...ee } = H;
13410
13406
  if (F) {
13411
- const ae = a.array.has(F.name), ce = H._f && Zx(H._f);
13412
- ce && p.validatingFields && y([F.name], !0);
13407
+ const ae = a.array.has(F.name), ue = H._f && Zx(H._f);
13408
+ ue && p.validatingFields && y([F.name], !0);
13413
13409
  const Le = await li(H, a.disabled, s, g, t.shouldUseNativeValidation && !N, ae);
13414
- if (ce && p.validatingFields && y([F.name]), Le[F.name] && (A.valid = !1, N))
13410
+ if (ue && p.validatingFields && y([F.name]), Le[F.name] && (A.valid = !1, N))
13415
13411
  break;
13416
13412
  !N && (X(Le, F.name) ? ae ? nS(r.errors, Le, F.name) : le(r.errors, F.name, Le[F.name]) : we(r.errors, F.name));
13417
13413
  }
@@ -13464,11 +13460,11 @@ function sS(e = {}) {
13464
13460
  i.mount = !0;
13465
13461
  const N = C.target;
13466
13462
  let A = N.name, K = !0;
13467
- const H = X(n, A), F = (ce) => {
13468
- K = Number.isNaN(ce) || xt(ce) && isNaN(ce.getTime()) || ft(ce, X(s, A, ce));
13463
+ const H = X(n, A), F = (ue) => {
13464
+ K = Number.isNaN(ue) || xt(ue) && isNaN(ue.getTime()) || ft(ue, X(s, A, ue));
13469
13465
  }, ee = ni(t.mode), ae = ni(t.reValidateMode);
13470
13466
  if (H) {
13471
- let ce, Le;
13467
+ let ue, Le;
13472
13468
  const wr = N.type ? ri(H._f) : Fx(C), lt = C.type === Zs.BLUR || C.type === Zs.FOCUS_OUT, vd = !Qx(H._f) && !t.resolver && !X(r.errors, A) && !H._f.deps || tS(lt, X(r.touchedFields, A), r.isSubmitted, ae, ee), _n = si(A, a, lt);
13473
13469
  le(s, A, wr), lt ? (!N || !N.readOnly) && (H._f.onBlur && H._f.onBlur(C), c && c(0)) : H._f.onChange && H._f.onChange(C);
13474
13470
  const Pn = E(A, wr, lt), yd = !Ae(Pn) || _n;
@@ -13482,11 +13478,11 @@ function sS(e = {}) {
13482
13478
  const { errors: ds } = await _([A]);
13483
13479
  if (F(wr), K) {
13484
13480
  const bd = ii(r.errors, n, A), fs = ii(ds, n, bd.name || A);
13485
- ce = fs.error, A = fs.name, Le = Ae(ds);
13481
+ ue = fs.error, A = fs.name, Le = Ae(ds);
13486
13482
  }
13487
13483
  } else
13488
- y([A], !0), ce = (await li(H, a.disabled, s, g, t.shouldUseNativeValidation))[A], y([A]), F(wr), K && (ce ? Le = !1 : (p.isValid || f.isValid) && (Le = await k(n, !0)));
13489
- K && (H._f.deps && (!Array.isArray(H._f.deps) || H._f.deps.length > 0) && O(H._f.deps), P(A, Le, ce, Pn));
13484
+ y([A], !0), ue = (await li(H, a.disabled, s, g, t.shouldUseNativeValidation))[A], y([A]), F(wr), K && (ue ? Le = !1 : (p.isValid || f.isValid) && (Le = await k(n, !0)));
13485
+ K && (H._f.deps && (!Array.isArray(H._f.deps) || H._f.deps.length > 0) && O(H._f.deps), P(A, Le, ue, Pn));
13490
13486
  }
13491
13487
  }, I = (C, N) => {
13492
13488
  if (X(r.errors, N) && C.focus)
@@ -13522,9 +13518,9 @@ function sS(e = {}) {
13522
13518
  errors: C ? r.errors : {}
13523
13519
  });
13524
13520
  }, fe = (C, N, A) => {
13525
- const K = (X(n, C, { _f: {} })._f || {}).ref, H = X(r.errors, C) || {}, { ref: F, message: ee, type: ae, ...ce } = H;
13521
+ const K = (X(n, C, { _f: {} })._f || {}).ref, H = X(r.errors, C) || {}, { ref: F, message: ee, type: ae, ...ue } = H;
13526
13522
  le(r.errors, C, {
13527
- ...ce,
13523
+ ...ue,
13528
13524
  ...N,
13529
13525
  ref: K
13530
13526
  }), m.state.next({
@@ -13591,7 +13587,7 @@ function sS(e = {}) {
13591
13587
  if (H) {
13592
13588
  Z(C, N), A = X(n, C);
13593
13589
  const F = ge(H.value) && H.querySelectorAll && H.querySelectorAll("input,select,textarea")[0] || H, ee = Gx(F), ae = A._f.refs || [];
13594
- if (ee ? ae.find((ce) => ce === F) : F === A._f.ref)
13590
+ if (ee ? ae.find((ue) => ue === F) : F === A._f.ref)
13595
13591
  return;
13596
13592
  le(n, C, {
13597
13593
  _f: {
@@ -13667,9 +13663,9 @@ function sS(e = {}) {
13667
13663
  for (const ee of a.mount) {
13668
13664
  const ae = X(n, ee);
13669
13665
  if (ae && ae._f) {
13670
- const ce = Array.isArray(ae._f.refs) ? ae._f.refs[0] : ae._f.ref;
13671
- if (zr(ce)) {
13672
- const Le = ce.closest("form");
13666
+ const ue = Array.isArray(ae._f.refs) ? ae._f.refs[0] : ae._f.ref;
13667
+ if (zr(ue)) {
13668
+ const Le = ue.closest("form");
13673
13669
  if (Le) {
13674
13670
  Le.reset();
13675
13671
  break;
@@ -14101,7 +14097,7 @@ const dS = ({
14101
14097
  }) }),
14102
14098
  y && /* @__PURE__ */ M("div", { className: "flex items-center justify-end gap-2 mt-6 pt-4 border-t", children: [
14103
14099
  o && /* @__PURE__ */ M(
14104
- ue,
14100
+ ce,
14105
14101
  {
14106
14102
  type: "button",
14107
14103
  variant: "outline",
@@ -14114,7 +14110,7 @@ const dS = ({
14114
14110
  }
14115
14111
  ),
14116
14112
  /* @__PURE__ */ d(
14117
- ue,
14113
+ ce,
14118
14114
  {
14119
14115
  type: "submit",
14120
14116
  disabled: c || a,
@@ -14131,7 +14127,7 @@ const dS = ({
14131
14127
  ] });
14132
14128
  return h && (u || p || b) ? /* @__PURE__ */ M(bt, { className: w, ...x, children: [
14133
14129
  /* @__PURE__ */ d(qr, { children: /* @__PURE__ */ M("div", { className: "flex items-center gap-4", children: [
14134
- b && s && /* @__PURE__ */ d(ue, { variant: "ghost", size: "icon", onClick: s, children: /* @__PURE__ */ d(Pr, { className: "h-4 w-4" }) }),
14130
+ b && s && /* @__PURE__ */ d(ce, { variant: "ghost", size: "icon", onClick: s, children: /* @__PURE__ */ d(Pr, { className: "h-4 w-4" }) }),
14135
14131
  /* @__PURE__ */ M("div", { children: [
14136
14132
  u && /* @__PURE__ */ d(Xr, { children: u }),
14137
14133
  p && /* @__PURE__ */ d(Zr, { children: p })
@@ -14254,7 +14250,7 @@ const fS = ({
14254
14250
  if (r)
14255
14251
  return /* @__PURE__ */ d(bt, { className: y, children: /* @__PURE__ */ M(wt, { className: "py-12 text-center", children: [
14256
14252
  /* @__PURE__ */ d("p", { className: "text-destructive", children: r.message || "An error occurred" }),
14257
- o && /* @__PURE__ */ M(ue, { variant: "outline", onClick: o, className: "mt-4", children: [
14253
+ o && /* @__PURE__ */ M(ce, { variant: "outline", onClick: o, className: "mt-4", children: [
14258
14254
  /* @__PURE__ */ d(Pr, { className: "mr-2 h-4 w-4" }),
14259
14255
  f
14260
14256
  ] })
@@ -14266,7 +14262,7 @@ const fS = ({
14266
14262
  m,
14267
14263
  " found"
14268
14264
  ] }),
14269
- o && /* @__PURE__ */ M(ue, { variant: "outline", onClick: o, className: "mt-4", children: [
14265
+ o && /* @__PURE__ */ M(ce, { variant: "outline", onClick: o, className: "mt-4", children: [
14270
14266
  /* @__PURE__ */ d(Pr, { className: "mr-2 h-4 w-4" }),
14271
14267
  f
14272
14268
  ] })
@@ -14319,19 +14315,19 @@ const fS = ({
14319
14315
  /* @__PURE__ */ M(bt, { className: y, ...b, children: [
14320
14316
  g && /* @__PURE__ */ M(qr, { className: "flex flex-row items-center justify-between space-y-0 pb-4", children: [
14321
14317
  /* @__PURE__ */ M("div", { className: "flex items-center gap-4", children: [
14322
- o && /* @__PURE__ */ d(ue, { variant: "ghost", size: "icon", onClick: o, children: /* @__PURE__ */ d(Pr, { className: "h-4 w-4" }) }),
14318
+ o && /* @__PURE__ */ d(ce, { variant: "ghost", size: "icon", onClick: o, children: /* @__PURE__ */ d(Pr, { className: "h-4 w-4" }) }),
14323
14319
  /* @__PURE__ */ M("div", { children: [
14324
14320
  a && /* @__PURE__ */ d(Xr, { children: a }),
14325
14321
  c && /* @__PURE__ */ d(Zr, { children: c })
14326
14322
  ] })
14327
14323
  ] }),
14328
14324
  /* @__PURE__ */ M("div", { className: "flex items-center gap-2", children: [
14329
- s && /* @__PURE__ */ M(ue, { variant: "outline", onClick: () => s(e), children: [
14325
+ s && /* @__PURE__ */ M(ce, { variant: "outline", onClick: () => s(e), children: [
14330
14326
  /* @__PURE__ */ d(Ei, { className: "mr-2 h-4 w-4" }),
14331
14327
  u
14332
14328
  ] }),
14333
14329
  i && /* @__PURE__ */ M(
14334
- ue,
14330
+ ce,
14335
14331
  {
14336
14332
  variant: "destructive",
14337
14333
  onClick: () => x(!0),
@@ -14604,7 +14600,7 @@ export {
14604
14600
  zy as AvatarFallback,
14605
14601
  jy as AvatarImage,
14606
14602
  xr as Badge,
14607
- ue as Button,
14603
+ ce as Button,
14608
14604
  bt as Card,
14609
14605
  wt as CardContent,
14610
14606
  Zr as CardDescription,