react-admin-crud-manager 1.0.15 → 1.0.16
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.cjs.js +11 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +128 -130
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -124,41 +124,39 @@ const Qe = ({
|
|
|
124
124
|
dropdownMaxHeight: m = ""
|
|
125
125
|
}) => {
|
|
126
126
|
var A;
|
|
127
|
-
const [u, x] = R(!1), [
|
|
128
|
-
let j = n || o;
|
|
129
|
-
const f = (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const z = f(N);
|
|
135
|
-
return p ? k.includes(z) : z === k;
|
|
127
|
+
const [u, x] = R(!1), [w, S] = R(""), [E, T] = R(!0), M = X(null), G = X(null);
|
|
128
|
+
let j = n || n === !1 ? n : o;
|
|
129
|
+
const f = (v) => v == null || v === "" ? "" : String(typeof v == "boolean" ? v : v ?? ""), N = p ? (j || []).map(f) : f(j), O = h.filter(
|
|
130
|
+
(v) => v.label.toLowerCase().includes(w.toLowerCase())
|
|
131
|
+
), D = (v) => {
|
|
132
|
+
const z = f(v);
|
|
133
|
+
return p ? N.includes(z) : z === N;
|
|
136
134
|
};
|
|
137
135
|
H(() => {
|
|
138
|
-
const
|
|
136
|
+
const v = (z) => {
|
|
139
137
|
M.current && !M.current.contains(z.target) && (x(!1), S(""));
|
|
140
138
|
};
|
|
141
|
-
return document.addEventListener("mousedown",
|
|
139
|
+
return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
|
|
142
140
|
}, []), H(() => {
|
|
143
141
|
if (u && M.current) {
|
|
144
|
-
const
|
|
142
|
+
const v = M.current.getBoundingClientRect(), Z = window.innerHeight - v.bottom;
|
|
145
143
|
T(Z < 200);
|
|
146
144
|
}
|
|
147
145
|
}, [u]), H(() => {
|
|
148
146
|
u && G.current && G.current.focus();
|
|
149
147
|
}, [u]);
|
|
150
|
-
const F = (
|
|
151
|
-
let z =
|
|
152
|
-
if (
|
|
153
|
-
const Z =
|
|
148
|
+
const F = (v) => {
|
|
149
|
+
let z = v;
|
|
150
|
+
if (v === "true" ? z = !0 : v === "false" && (z = !1), p) {
|
|
151
|
+
const Z = N.includes(f(v));
|
|
154
152
|
let W;
|
|
155
153
|
Z ? W = n.filter(
|
|
156
|
-
(re) => f(re) !== f(
|
|
154
|
+
(re) => f(re) !== f(v)
|
|
157
155
|
) : W = [...n || [], z], i(W);
|
|
158
156
|
} else
|
|
159
157
|
i(z), x(!1);
|
|
160
158
|
S("");
|
|
161
|
-
}, U = p ? h.filter((
|
|
159
|
+
}, U = p ? h.filter((v) => D(v.value)).map((v) => v.label).join(", ") : (A = h.find((v) => D(v.value))) == null ? void 0 : A.label;
|
|
162
160
|
return /* @__PURE__ */ c("div", { className: d || "col-span-12", children: [
|
|
163
161
|
/* @__PURE__ */ e(q, { label: L, required: b }),
|
|
164
162
|
/* @__PURE__ */ c("div", { className: `relative ${l}`, ref: M, children: [
|
|
@@ -206,8 +204,8 @@ const Qe = ({
|
|
|
206
204
|
{
|
|
207
205
|
ref: G,
|
|
208
206
|
type: "text",
|
|
209
|
-
value:
|
|
210
|
-
onChange: (
|
|
207
|
+
value: w,
|
|
208
|
+
onChange: (v) => S(v.target.value),
|
|
211
209
|
placeholder: "Search...",
|
|
212
210
|
className: "w-full pl-9 pr-3 py-2 text-sm border rounded-md bg-white dark:bg-gray-800 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none"
|
|
213
211
|
}
|
|
@@ -220,19 +218,19 @@ const Qe = ({
|
|
|
220
218
|
style: {
|
|
221
219
|
maxHeight: m || ""
|
|
222
220
|
},
|
|
223
|
-
children: O.length > 0 ? O.map((
|
|
221
|
+
children: O.length > 0 ? O.map((v) => /* @__PURE__ */ c(
|
|
224
222
|
"button",
|
|
225
223
|
{
|
|
226
224
|
type: "button",
|
|
227
|
-
onClick: () => F(String(
|
|
225
|
+
onClick: () => F(String(v.value)),
|
|
228
226
|
className: `w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-gray-100 dark:hover:bg-gray-600
|
|
229
|
-
${D(
|
|
227
|
+
${D(v.value) ? "bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300" : ""}`,
|
|
230
228
|
children: [
|
|
231
|
-
/* @__PURE__ */ e("span", { children:
|
|
232
|
-
p && D(
|
|
229
|
+
/* @__PURE__ */ e("span", { children: v.label }),
|
|
230
|
+
p && D(v.value) && /* @__PURE__ */ e(_e, { className: "w-4 h-4" })
|
|
233
231
|
]
|
|
234
232
|
},
|
|
235
|
-
String(
|
|
233
|
+
String(v.value)
|
|
236
234
|
)) : /* @__PURE__ */ e("div", { className: "px-3 py-2 text-sm text-gray-500 dark:text-gray-400", children: "No options found" })
|
|
237
235
|
}
|
|
238
236
|
)
|
|
@@ -550,33 +548,33 @@ function ea({
|
|
|
550
548
|
countriesList: b = !1,
|
|
551
549
|
defaultCountry: y = ""
|
|
552
550
|
}) {
|
|
553
|
-
const d = (
|
|
551
|
+
const d = (N) => me.find((O) => O.code == N), [p, m] = R(
|
|
554
552
|
d(y) || me[0]
|
|
555
|
-
), [u, x] = R(""), [
|
|
553
|
+
), [u, x] = R(""), [w, S] = R(!1), [E, T] = R(""), M = X();
|
|
556
554
|
H(() => {
|
|
557
555
|
if (typeof n == "string" && n.startsWith("+")) {
|
|
558
|
-
const
|
|
559
|
-
if (
|
|
560
|
-
m(
|
|
556
|
+
const N = me.filter((O) => n.startsWith("+" + O.phone)).sort((O, D) => D.phone.length - O.phone.length)[0];
|
|
557
|
+
if (N) {
|
|
558
|
+
m(N), x(n.replace("+" + N.phone, ""));
|
|
561
559
|
return;
|
|
562
560
|
}
|
|
563
561
|
}
|
|
564
562
|
x(n);
|
|
565
563
|
}, [n]);
|
|
566
|
-
const G = (
|
|
567
|
-
const O =
|
|
564
|
+
const G = (N) => {
|
|
565
|
+
const O = N.target.value.replace(/\D/g, "");
|
|
568
566
|
x(O), p && s && s("+" + p.phone + O);
|
|
569
|
-
}, j = (
|
|
570
|
-
m(
|
|
567
|
+
}, j = (N) => {
|
|
568
|
+
m(N), s && s("+" + N.phone + u), S(!1), T("");
|
|
571
569
|
};
|
|
572
570
|
H(() => {
|
|
573
|
-
const
|
|
571
|
+
const N = (O) => {
|
|
574
572
|
M.current && !M.current.contains(O.target) && S(!1);
|
|
575
573
|
};
|
|
576
|
-
return document.addEventListener("mousedown",
|
|
574
|
+
return document.addEventListener("mousedown", N), () => document.removeEventListener("mousedown", N);
|
|
577
575
|
}, []);
|
|
578
576
|
const f = me.filter(
|
|
579
|
-
(
|
|
577
|
+
(N) => N.label.toLowerCase().includes(E.toLowerCase()) || N.phone.includes(E)
|
|
580
578
|
);
|
|
581
579
|
return b ? /* @__PURE__ */ e($, { children: /* @__PURE__ */ c("div", { className: i || "col-span-12", children: [
|
|
582
580
|
/* @__PURE__ */ e(q, { label: h, required: r }),
|
|
@@ -585,7 +583,7 @@ function ea({
|
|
|
585
583
|
"div",
|
|
586
584
|
{
|
|
587
585
|
className: `h-[40px] flex items-center border rounded-md px-2 bg-white dark:bg-gray-700 transition-all
|
|
588
|
-
${
|
|
586
|
+
${w ? "ring-0.5 ring-blue-100 border-blue-300" : "border-gray-300 dark:border-gray-600"}
|
|
589
587
|
${l ? "opacity-60 cursor-not-allowed" : ""}`,
|
|
590
588
|
children: [
|
|
591
589
|
/* @__PURE__ */ c(
|
|
@@ -593,7 +591,7 @@ function ea({
|
|
|
593
591
|
{
|
|
594
592
|
type: "button",
|
|
595
593
|
disabled: l,
|
|
596
|
-
onClick: () => S(!
|
|
594
|
+
onClick: () => S(!w),
|
|
597
595
|
className: "flex items-center gap-1 pr-2 border-r border-gray-300 dark:border-gray-700 focus:outline-none",
|
|
598
596
|
children: [
|
|
599
597
|
p ? /* @__PURE__ */ e(
|
|
@@ -643,7 +641,7 @@ function ea({
|
|
|
643
641
|
]
|
|
644
642
|
}
|
|
645
643
|
),
|
|
646
|
-
|
|
644
|
+
w && /* @__PURE__ */ c("div", { className: "absolute top-full left-0 w-full mt-1 border border-gray-300 dark:border-gray-700 rounded-md bg-white dark:bg-gray-700 shadow-lg z-50 max-h-60 overflow-y-auto", children: [
|
|
647
645
|
L && /* @__PURE__ */ e("div", { className: "p-2 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ c("div", { className: "relative", children: [
|
|
648
646
|
/* @__PURE__ */ e(Re, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" }),
|
|
649
647
|
/* @__PURE__ */ e(
|
|
@@ -651,36 +649,36 @@ function ea({
|
|
|
651
649
|
{
|
|
652
650
|
type: "text",
|
|
653
651
|
value: E,
|
|
654
|
-
onChange: (
|
|
652
|
+
onChange: (N) => T(N.target.value),
|
|
655
653
|
placeholder: "Search country...",
|
|
656
654
|
className: "w-full pl-9 pr-3 py-2 text-sm border rounded-md bg-white dark:bg-gray-800 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none "
|
|
657
655
|
}
|
|
658
656
|
)
|
|
659
657
|
] }) }),
|
|
660
|
-
f.map((
|
|
658
|
+
f.map((N) => /* @__PURE__ */ c(
|
|
661
659
|
"button",
|
|
662
660
|
{
|
|
663
661
|
type: "button",
|
|
664
|
-
onClick: () => j(
|
|
662
|
+
onClick: () => j(N),
|
|
665
663
|
className: "w-full flex items-center gap-2 px-2 py-1 text-sm hover:bg-blue-50 dark:hover:bg-gray-700 text-gray-800 dark:text-gray-100",
|
|
666
664
|
children: [
|
|
667
665
|
/* @__PURE__ */ e(
|
|
668
666
|
"img",
|
|
669
667
|
{
|
|
670
|
-
src: `https://flagcdn.com/w20/${
|
|
671
|
-
alt:
|
|
668
|
+
src: `https://flagcdn.com/w20/${N.code.toLowerCase()}.png`,
|
|
669
|
+
alt: N.code,
|
|
672
670
|
className: "w-5 h-3 object-cover"
|
|
673
671
|
}
|
|
674
672
|
),
|
|
675
673
|
/* @__PURE__ */ c("span", { children: [
|
|
676
|
-
|
|
674
|
+
N.label,
|
|
677
675
|
" (+",
|
|
678
|
-
|
|
676
|
+
N.phone,
|
|
679
677
|
")"
|
|
680
678
|
] })
|
|
681
679
|
]
|
|
682
680
|
},
|
|
683
|
-
|
|
681
|
+
N.code
|
|
684
682
|
))
|
|
685
683
|
] })
|
|
686
684
|
] })
|
|
@@ -750,7 +748,7 @@ const aa = ({
|
|
|
750
748
|
b != null && b.preview && b.preview.startsWith("blob:") && URL.revokeObjectURL(b.preview), y(f), o == null || o(G);
|
|
751
749
|
}, x = (M) => {
|
|
752
750
|
M && M.stopPropagation(), b != null && b.preview && b.preview.startsWith("blob:") && URL.revokeObjectURL(b.preview), y(null), o == null || o(null), m.current && (m.current.value = "");
|
|
753
|
-
},
|
|
751
|
+
}, w = (M) => {
|
|
754
752
|
r && (M.preventDefault(), p(!0));
|
|
755
753
|
}, S = (M) => {
|
|
756
754
|
r && (M.preventDefault(), p(!1));
|
|
@@ -765,7 +763,7 @@ const aa = ({
|
|
|
765
763
|
"div",
|
|
766
764
|
{
|
|
767
765
|
className: `relative rounded-md p-2 transition-all ${d ? "border-2 border-dashed border-blue-500 bg-blue-50 dark:bg-blue-900/20" : "border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800"}`,
|
|
768
|
-
onDragOver:
|
|
766
|
+
onDragOver: w,
|
|
769
767
|
onDragLeave: S,
|
|
770
768
|
onDrop: E,
|
|
771
769
|
children: [
|
|
@@ -924,7 +922,7 @@ const ra = ({
|
|
|
924
922
|
menubar: m = !1,
|
|
925
923
|
fontFamily: u = "Inter, sans-serif",
|
|
926
924
|
initConfig: x = {},
|
|
927
|
-
imageUploadHandler:
|
|
925
|
+
imageUploadHandler: w
|
|
928
926
|
// ✅ Promise function passed from parent
|
|
929
927
|
}) => /* @__PURE__ */ c("div", { className: C, children: [
|
|
930
928
|
s && /* @__PURE__ */ e(q, { label: s, required: l }),
|
|
@@ -942,11 +940,11 @@ const ra = ({
|
|
|
942
940
|
statusbar: !0,
|
|
943
941
|
automatic_uploads: !0,
|
|
944
942
|
images_upload_handler: (M) => new Promise((G, j) => {
|
|
945
|
-
if (!
|
|
943
|
+
if (!w) {
|
|
946
944
|
G(`data:${M.blob().type};base64,${M.base64()}`);
|
|
947
945
|
return;
|
|
948
946
|
}
|
|
949
|
-
|
|
947
|
+
w(M).then((f) => {
|
|
950
948
|
f ? G(f) : j("Upload failed: No URL returned");
|
|
951
949
|
}).catch((f) => {
|
|
952
950
|
j(
|
|
@@ -1010,14 +1008,14 @@ const ra = ({
|
|
|
1010
1008
|
if (!b)
|
|
1011
1009
|
s(x ? u : "", h);
|
|
1012
1010
|
else {
|
|
1013
|
-
const
|
|
1011
|
+
const w = Array.isArray(i) ? [...i] : [];
|
|
1014
1012
|
if (x)
|
|
1015
|
-
|
|
1013
|
+
w.includes(u) || w.push(u);
|
|
1016
1014
|
else {
|
|
1017
|
-
const S =
|
|
1018
|
-
S > -1 &&
|
|
1015
|
+
const S = w.indexOf(u);
|
|
1016
|
+
S > -1 && w.splice(S, 1);
|
|
1019
1017
|
}
|
|
1020
|
-
s(
|
|
1018
|
+
s(w, h);
|
|
1021
1019
|
}
|
|
1022
1020
|
};
|
|
1023
1021
|
return y ? /* @__PURE__ */ e($, { children: /* @__PURE__ */ c("div", { className: `${C}`, children: [
|
|
@@ -1032,7 +1030,7 @@ const ra = ({
|
|
|
1032
1030
|
checked: d(u.value),
|
|
1033
1031
|
disabled: l || u.disabled,
|
|
1034
1032
|
required: r && x === 0,
|
|
1035
|
-
onChange: (
|
|
1033
|
+
onChange: (w) => m(u.value, w.target.checked),
|
|
1036
1034
|
className: `h-4 w-4 cursor-pointer text-blue-600 border-gray-300 rounded focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 ${L}`
|
|
1037
1035
|
},
|
|
1038
1036
|
h
|
|
@@ -1084,7 +1082,7 @@ const ra = ({
|
|
|
1084
1082
|
const [d, p] = R(null), [m, u] = R(!1), x = X(null);
|
|
1085
1083
|
H(() => {
|
|
1086
1084
|
if (!n) {
|
|
1087
|
-
|
|
1085
|
+
w(), p(null);
|
|
1088
1086
|
return;
|
|
1089
1087
|
}
|
|
1090
1088
|
if (n instanceof File) {
|
|
@@ -1094,15 +1092,15 @@ const ra = ({
|
|
|
1094
1092
|
};
|
|
1095
1093
|
} else typeof n == "string" ? p({ preview: n }) : n != null && n.preview && p(n);
|
|
1096
1094
|
}, [n]);
|
|
1097
|
-
const
|
|
1095
|
+
const w = () => {
|
|
1098
1096
|
d != null && d.preview && d.preview.startsWith("blob:") && URL.revokeObjectURL(d.preview);
|
|
1099
1097
|
}, S = (f) => {
|
|
1100
1098
|
if (!f || f.length === 0)
|
|
1101
1099
|
return;
|
|
1102
|
-
const
|
|
1103
|
-
|
|
1100
|
+
const N = f[0], O = URL.createObjectURL(N);
|
|
1101
|
+
w(), p({ file: N, preview: O }), o == null || o(N);
|
|
1104
1102
|
}, E = (f) => {
|
|
1105
|
-
f && f.stopPropagation(),
|
|
1103
|
+
f && f.stopPropagation(), w(), p(null), o == null || o(null), x.current && (x.current.value = "");
|
|
1106
1104
|
}, T = (f) => {
|
|
1107
1105
|
r && (f.preventDefault(), u(!0));
|
|
1108
1106
|
}, M = (f) => {
|
|
@@ -1194,7 +1192,7 @@ const ra = ({
|
|
|
1194
1192
|
required: m = !1,
|
|
1195
1193
|
minLength: u,
|
|
1196
1194
|
dragDrop: x,
|
|
1197
|
-
parentClass:
|
|
1195
|
+
parentClass: w,
|
|
1198
1196
|
countriesList: S,
|
|
1199
1197
|
defaultCountry: E,
|
|
1200
1198
|
multiple: T,
|
|
@@ -1202,7 +1200,7 @@ const ra = ({
|
|
|
1202
1200
|
editorKey: G,
|
|
1203
1201
|
fontFamily: j,
|
|
1204
1202
|
disabled: f,
|
|
1205
|
-
negativeNumberAllow:
|
|
1203
|
+
negativeNumberAllow: N,
|
|
1206
1204
|
defaultValue: O
|
|
1207
1205
|
} = h;
|
|
1208
1206
|
let D = n == null ? void 0 : n[i];
|
|
@@ -1224,7 +1222,7 @@ const ra = ({
|
|
|
1224
1222
|
label: s,
|
|
1225
1223
|
name: i,
|
|
1226
1224
|
disabled: f,
|
|
1227
|
-
parentClass:
|
|
1225
|
+
parentClass: w,
|
|
1228
1226
|
multiple: T,
|
|
1229
1227
|
dropdownMaxHeight: M
|
|
1230
1228
|
}
|
|
@@ -1239,7 +1237,7 @@ const ra = ({
|
|
|
1239
1237
|
value: D,
|
|
1240
1238
|
onChange: (A) => o(i, A),
|
|
1241
1239
|
required: m,
|
|
1242
|
-
parentClass:
|
|
1240
|
+
parentClass: w,
|
|
1243
1241
|
className: b || "",
|
|
1244
1242
|
multiSelect: T,
|
|
1245
1243
|
disabled: f
|
|
@@ -1257,7 +1255,7 @@ const ra = ({
|
|
|
1257
1255
|
required: m,
|
|
1258
1256
|
name: i,
|
|
1259
1257
|
disabled: f,
|
|
1260
|
-
parentClass:
|
|
1258
|
+
parentClass: w
|
|
1261
1259
|
}
|
|
1262
1260
|
);
|
|
1263
1261
|
case "phone":
|
|
@@ -1274,7 +1272,7 @@ const ra = ({
|
|
|
1274
1272
|
label: s,
|
|
1275
1273
|
name: i,
|
|
1276
1274
|
disabled: f,
|
|
1277
|
-
parentClass:
|
|
1275
|
+
parentClass: w
|
|
1278
1276
|
}
|
|
1279
1277
|
);
|
|
1280
1278
|
case "textarea":
|
|
@@ -1290,7 +1288,7 @@ const ra = ({
|
|
|
1290
1288
|
name: i,
|
|
1291
1289
|
label: s,
|
|
1292
1290
|
disabled: f,
|
|
1293
|
-
parentClass:
|
|
1291
|
+
parentClass: w
|
|
1294
1292
|
}
|
|
1295
1293
|
);
|
|
1296
1294
|
case "image":
|
|
@@ -1305,7 +1303,7 @@ const ra = ({
|
|
|
1305
1303
|
dragDrop: x,
|
|
1306
1304
|
label: s,
|
|
1307
1305
|
name: i,
|
|
1308
|
-
parentClass:
|
|
1306
|
+
parentClass: w
|
|
1309
1307
|
}
|
|
1310
1308
|
);
|
|
1311
1309
|
case "audio":
|
|
@@ -1320,7 +1318,7 @@ const ra = ({
|
|
|
1320
1318
|
dragDrop: x,
|
|
1321
1319
|
label: s,
|
|
1322
1320
|
name: i,
|
|
1323
|
-
parentClass:
|
|
1321
|
+
parentClass: w
|
|
1324
1322
|
}
|
|
1325
1323
|
);
|
|
1326
1324
|
case "tinyEditor":
|
|
@@ -1332,7 +1330,7 @@ const ra = ({
|
|
|
1332
1330
|
required: m,
|
|
1333
1331
|
placeholder: F,
|
|
1334
1332
|
label: s,
|
|
1335
|
-
parentClass:
|
|
1333
|
+
parentClass: w,
|
|
1336
1334
|
fontFamily: j,
|
|
1337
1335
|
editorKey: G,
|
|
1338
1336
|
disabled: f
|
|
@@ -1352,8 +1350,8 @@ const ra = ({
|
|
|
1352
1350
|
name: i,
|
|
1353
1351
|
minLength: u,
|
|
1354
1352
|
label: s,
|
|
1355
|
-
negativeNumberAllow:
|
|
1356
|
-
parentClass:
|
|
1353
|
+
negativeNumberAllow: N,
|
|
1354
|
+
parentClass: w,
|
|
1357
1355
|
disabled: f
|
|
1358
1356
|
}
|
|
1359
1357
|
);
|
|
@@ -1560,7 +1558,7 @@ const ra = ({
|
|
|
1560
1558
|
},
|
|
1561
1559
|
onFilterApply: y,
|
|
1562
1560
|
filterConfig: d = null
|
|
1563
|
-
} = h, [p, m] = R(""), [u, x] = R(null), [
|
|
1561
|
+
} = h, [p, m] = R(""), [u, x] = R(null), [w, S] = R([]), [E, T] = R({}), [M, G] = R(!1), [j, f] = R(null), [N, O] = R(!1), D = Me(() => !s.enabled || !p.trim() || s.useServerSideSearch ? n : Je(n, p, s.searchKeys || []), [n, p, s]), [F, U] = R(1), [A, v] = R((r == null ? void 0 : r.rows_per_page) || 50), [z, Z] = R(D.length || 0), W = r != null && r.useServerSidePagination ? r.total_pages : Math.ceil(D.length / A), re = Me(() => {
|
|
1564
1562
|
if (r.useServerSidePagination) return D;
|
|
1565
1563
|
const t = (F - 1) * A;
|
|
1566
1564
|
return D.slice(t, t + A);
|
|
@@ -1582,9 +1580,9 @@ const ra = ({
|
|
|
1582
1580
|
g.stopPropagation(), S(I);
|
|
1583
1581
|
const K = g.currentTarget;
|
|
1584
1582
|
se.current[t] = K;
|
|
1585
|
-
const _ = K.getBoundingClientRect(), J = 192, V = I.length * 40, ee = window.innerWidth,
|
|
1583
|
+
const _ = K.getBoundingClientRect(), J = 192, V = I.length * 40, ee = window.innerWidth, k = window.innerHeight, B = ee - _.right < J ? _.left - J + _.width : _.left, Y = k - _.bottom < V && _.top > V ? _.top - V - 2 : _.bottom + 2;
|
|
1586
1584
|
T({
|
|
1587
|
-
top: Math.max(8, Math.min(Y,
|
|
1585
|
+
top: Math.max(8, Math.min(Y, k - V - 8)),
|
|
1588
1586
|
left: Math.max(8, Math.min(B, ee - J - 8))
|
|
1589
1587
|
}), x(u === t ? null : t);
|
|
1590
1588
|
}, we = (t) => (F - 1) * A + t + 1, de = (t) => {
|
|
@@ -1676,7 +1674,7 @@ const ra = ({
|
|
|
1676
1674
|
};
|
|
1677
1675
|
return document.addEventListener("click", t), () => document.removeEventListener("click", t);
|
|
1678
1676
|
}, []), H(() => {
|
|
1679
|
-
r != null && r.rows_per_page && (r != null && r.useServerSidePagination) &&
|
|
1677
|
+
r != null && r.rows_per_page && (r != null && r.useServerSidePagination) && v((r == null ? void 0 : r.rows_per_page) || 50), r.current_page && U(r.current_page);
|
|
1680
1678
|
}, [
|
|
1681
1679
|
r.rows_per_page,
|
|
1682
1680
|
r == null ? void 0 : r.useServerSidePagination,
|
|
@@ -1765,7 +1763,7 @@ const ra = ({
|
|
|
1765
1763
|
value: A,
|
|
1766
1764
|
onChange: (t) => {
|
|
1767
1765
|
const g = Number(t.target.value);
|
|
1768
|
-
|
|
1766
|
+
v(g), U(1), r.useServerSidePagination && b((I) => ({
|
|
1769
1767
|
...I,
|
|
1770
1768
|
current_page: 1,
|
|
1771
1769
|
rows_per_page: g
|
|
@@ -1833,7 +1831,7 @@ const ra = ({
|
|
|
1833
1831
|
zIndex: 9999
|
|
1834
1832
|
},
|
|
1835
1833
|
className: "w-48 bg-white dark:bg-gray-700 rounded-md shadow-lg border border-gray-200 dark:border-gray-600",
|
|
1836
|
-
children:
|
|
1834
|
+
children: w.map((t, g) => /* @__PURE__ */ c(
|
|
1837
1835
|
"button",
|
|
1838
1836
|
{
|
|
1839
1837
|
onClick: (I) => xe(
|
|
@@ -1864,12 +1862,12 @@ const ra = ({
|
|
|
1864
1862
|
onApply: y
|
|
1865
1863
|
}
|
|
1866
1864
|
),
|
|
1867
|
-
|
|
1865
|
+
N && /* @__PURE__ */ e(
|
|
1868
1866
|
Ge,
|
|
1869
1867
|
{
|
|
1870
1868
|
src: j.src,
|
|
1871
1869
|
alt: j.alt,
|
|
1872
|
-
isOpen:
|
|
1870
|
+
isOpen: N,
|
|
1873
1871
|
setIsOpen: O
|
|
1874
1872
|
}
|
|
1875
1873
|
)
|
|
@@ -1895,7 +1893,7 @@ const ra = ({
|
|
|
1895
1893
|
selectedItem: x = null
|
|
1896
1894
|
}) => {
|
|
1897
1895
|
if (!h) return null;
|
|
1898
|
-
const
|
|
1896
|
+
const w = {
|
|
1899
1897
|
sm: "max-w-md",
|
|
1900
1898
|
md: "max-w-lg",
|
|
1901
1899
|
lg: "max-w-2xl",
|
|
@@ -1913,7 +1911,7 @@ const ra = ({
|
|
|
1913
1911
|
/* @__PURE__ */ c(
|
|
1914
1912
|
"div",
|
|
1915
1913
|
{
|
|
1916
|
-
className: `relative bg-white rounded-lg shadow-xl w-full ${
|
|
1914
|
+
className: `relative bg-white rounded-lg shadow-xl w-full ${w[l] || w.md} max-h-[90vh] flex flex-col dark:bg-gray-800`,
|
|
1917
1915
|
children: [
|
|
1918
1916
|
/* @__PURE__ */ c("div", { className: "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0", children: [
|
|
1919
1917
|
/* @__PURE__ */ c("div", { className: "flex items-center gap-1", children: [
|
|
@@ -1998,7 +1996,7 @@ function sa({ data: h, config: n }) {
|
|
|
1998
1996
|
l(d), C(!0);
|
|
1999
1997
|
}, b = ({ col: d }) => {
|
|
2000
1998
|
var E;
|
|
2001
|
-
let p = d == null ? void 0 : d.icon, m = d.label, u = h[d.key], x = d.type,
|
|
1999
|
+
let p = d == null ? void 0 : d.icon, m = d.label, u = h[d.key], x = d.type, w = d.variant || "outline", S = d.defaultColor;
|
|
2002
2000
|
if (x === "chip" && ((E = d.chipOptions) == null ? void 0 : E.length) > 0) {
|
|
2003
2001
|
let T = d == null ? void 0 : d.chipOptions.find((M) => M.value == u);
|
|
2004
2002
|
T && (u = T.label, S = T.color);
|
|
@@ -2016,7 +2014,7 @@ function sa({ data: h, config: n }) {
|
|
|
2016
2014
|
$e,
|
|
2017
2015
|
{
|
|
2018
2016
|
label: u,
|
|
2019
|
-
variant:
|
|
2017
|
+
variant: w,
|
|
2020
2018
|
color: S,
|
|
2021
2019
|
className: "mt-1"
|
|
2022
2020
|
}
|
|
@@ -2099,16 +2097,16 @@ const je = ({ config: h }) => {
|
|
|
2099
2097
|
tableConfig: s = {},
|
|
2100
2098
|
modalConfig: l = {},
|
|
2101
2099
|
filterConfig: r
|
|
2102
|
-
} = h, [C, L] = R(!0), [b, y] = R(!1), [d, p] = R([]), [m, u] = R(null), [x,
|
|
2100
|
+
} = h, [C, L] = R(!0), [b, y] = R(!1), [d, p] = R([]), [m, u] = R(null), [x, w] = R({
|
|
2103
2101
|
search: "",
|
|
2104
2102
|
rows_per_page: 50,
|
|
2105
2103
|
current_page: 1
|
|
2106
|
-
}), [S, E] = R({}), [T, M] = R(!1), [G, j] = R(!1), [f,
|
|
2107
|
-
|
|
2108
|
-
}, Z = async (
|
|
2104
|
+
}), [S, E] = R({}), [T, M] = R(!1), [G, j] = R(!1), [f, N] = R(!1), [O, D] = R(!1), [F, U] = R(!1), [A, v] = R(null), z = (k, P) => {
|
|
2105
|
+
k === "edit" ? (v(P), N(!0)) : k === "view" ? (v(P), U(!0)) : k === "delete" && (v(P), D(!0));
|
|
2106
|
+
}, Z = async (k, P, B = "", ae = "") => {
|
|
2109
2107
|
y(!0);
|
|
2110
2108
|
try {
|
|
2111
|
-
const Y = await (
|
|
2109
|
+
const Y = await (k == null ? void 0 : k());
|
|
2112
2110
|
(B || Y.message) && ke(B || Y.message, {
|
|
2113
2111
|
variant: "success"
|
|
2114
2112
|
}), P == null || P(Y);
|
|
@@ -2117,63 +2115,63 @@ const je = ({ config: h }) => {
|
|
|
2117
2115
|
} finally {
|
|
2118
2116
|
y(!1);
|
|
2119
2117
|
}
|
|
2120
|
-
}, W = (
|
|
2121
|
-
let P =
|
|
2118
|
+
}, W = (k) => {
|
|
2119
|
+
let P = k.newObject;
|
|
2122
2120
|
i ? (p((B) => [P, ...B]), u((B) => ({
|
|
2123
2121
|
...B,
|
|
2124
2122
|
current_page: 1
|
|
2125
|
-
}))) : (
|
|
2123
|
+
}))) : (w((B) => ({
|
|
2126
2124
|
...B,
|
|
2127
2125
|
current_page: 1
|
|
2128
2126
|
})), x.current_page == 1 && te()), j(!1);
|
|
2129
|
-
}, re = (
|
|
2130
|
-
let P =
|
|
2127
|
+
}, re = (k) => {
|
|
2128
|
+
let P = k.newObject, B = k.targetObject;
|
|
2131
2129
|
i ? p(
|
|
2132
2130
|
(ae) => ae.map(
|
|
2133
2131
|
(Y) => Y.id === B.id ? { ...Y, ...P } : Y
|
|
2134
2132
|
)
|
|
2135
|
-
) : te(),
|
|
2136
|
-
}, ne = (
|
|
2137
|
-
if (!
|
|
2138
|
-
D(!1),
|
|
2133
|
+
) : te(), N(!1);
|
|
2134
|
+
}, ne = (k) => {
|
|
2135
|
+
if (!k) {
|
|
2136
|
+
D(!1), v(null);
|
|
2139
2137
|
return;
|
|
2140
2138
|
}
|
|
2141
2139
|
i ? p(
|
|
2142
|
-
(P) => P.filter((B) => B.id !==
|
|
2143
|
-
) : d.length == 1 && x.current_page > 1 ?
|
|
2140
|
+
(P) => P.filter((B) => B.id !== k.targetObject.id)
|
|
2141
|
+
) : d.length == 1 && x.current_page > 1 ? w((P) => ({
|
|
2144
2142
|
...P,
|
|
2145
2143
|
current_page: P.current_page - 1
|
|
2146
|
-
})) : te(), D(!1),
|
|
2147
|
-
}, se = (
|
|
2144
|
+
})) : te(), D(!1), v(null);
|
|
2145
|
+
}, se = (k) => Z(
|
|
2148
2146
|
() => {
|
|
2149
2147
|
var P, B;
|
|
2150
|
-
return (B = (P = l == null ? void 0 : l.addModal) == null ? void 0 : P.handleSubmit) == null ? void 0 : B.call(P,
|
|
2148
|
+
return (B = (P = l == null ? void 0 : l.addModal) == null ? void 0 : P.handleSubmit) == null ? void 0 : B.call(P, k);
|
|
2151
2149
|
},
|
|
2152
2150
|
W
|
|
2153
|
-
), oe = (
|
|
2151
|
+
), oe = (k) => Z(
|
|
2154
2152
|
() => {
|
|
2155
2153
|
var P, B;
|
|
2156
|
-
return (B = (P = l == null ? void 0 : l.editModal) == null ? void 0 : P.handleSubmit) == null ? void 0 : B.call(P,
|
|
2154
|
+
return (B = (P = l == null ? void 0 : l.editModal) == null ? void 0 : P.handleSubmit) == null ? void 0 : B.call(P, k, A);
|
|
2157
2155
|
},
|
|
2158
2156
|
re
|
|
2159
2157
|
), te = async () => {
|
|
2160
|
-
L(!0), o == null || o({ ...x, ...S }).then((
|
|
2161
|
-
p(
|
|
2162
|
-
}).catch((
|
|
2163
|
-
ke(
|
|
2158
|
+
L(!0), o == null || o({ ...x, ...S }).then((k) => {
|
|
2159
|
+
p(k.data), u(k.pagination);
|
|
2160
|
+
}).catch((k) => {
|
|
2161
|
+
ke(k.message, { variant: "error" });
|
|
2164
2162
|
}).finally(() => {
|
|
2165
2163
|
L(!1);
|
|
2166
2164
|
});
|
|
2167
|
-
}, xe = (
|
|
2165
|
+
}, xe = (k) => {
|
|
2168
2166
|
var P;
|
|
2169
2167
|
E((B) => ({
|
|
2170
|
-
...
|
|
2168
|
+
...k
|
|
2171
2169
|
})), (P = s == null ? void 0 : s.filter) != null && P.useServerSideFilters && M((B) => !B);
|
|
2172
|
-
}, ve = (
|
|
2170
|
+
}, ve = (k, P) => k.filter(
|
|
2173
2171
|
(B) => Object.entries(P).every(([ae, Y]) => B[ae] === Y)
|
|
2174
2172
|
), we = Me(() => {
|
|
2175
|
-
var
|
|
2176
|
-
return (
|
|
2173
|
+
var k;
|
|
2174
|
+
return (k = s == null ? void 0 : s.filter) != null && k.useServerSideFilters ? d : ve(d, S);
|
|
2177
2175
|
}, [d, S]);
|
|
2178
2176
|
return H(() => {
|
|
2179
2177
|
te();
|
|
@@ -2191,12 +2189,12 @@ const je = ({ config: h }) => {
|
|
|
2191
2189
|
horizontal: "right"
|
|
2192
2190
|
},
|
|
2193
2191
|
autoHideDuration: 3e3,
|
|
2194
|
-
action: (
|
|
2192
|
+
action: (k) => /* @__PURE__ */ e(
|
|
2195
2193
|
"button",
|
|
2196
2194
|
{
|
|
2197
2195
|
onClick: () => {
|
|
2198
2196
|
window.dispatchEvent(
|
|
2199
|
-
new CustomEvent("closeSnackbar", { detail:
|
|
2197
|
+
new CustomEvent("closeSnackbar", { detail: k })
|
|
2200
2198
|
);
|
|
2201
2199
|
},
|
|
2202
2200
|
className: "p-1 hover:bg-white/20 rounded-full transition-colors duration-200 text-white flex items-center justify-center",
|
|
@@ -2232,7 +2230,7 @@ const je = ({ config: h }) => {
|
|
|
2232
2230
|
...m
|
|
2233
2231
|
},
|
|
2234
2232
|
data: we,
|
|
2235
|
-
setServerSidePaginationData:
|
|
2233
|
+
setServerSidePaginationData: w,
|
|
2236
2234
|
onMenuAction: z,
|
|
2237
2235
|
filterConfig: r,
|
|
2238
2236
|
onFilterApply: xe,
|
|
@@ -2251,8 +2249,8 @@ const je = ({ config: h }) => {
|
|
|
2251
2249
|
title: ((ie = l.addModal) == null ? void 0 : ie.title) || "Add New",
|
|
2252
2250
|
size: ((ce = l.addModal) == null ? void 0 : ce.size) || "md",
|
|
2253
2251
|
onFormSubmit: () => {
|
|
2254
|
-
var
|
|
2255
|
-
return (
|
|
2252
|
+
var k;
|
|
2253
|
+
return (k = document.querySelector("#addForm")) == null ? void 0 : k.requestSubmit();
|
|
2256
2254
|
},
|
|
2257
2255
|
loadingBtn: b,
|
|
2258
2256
|
actionButtons: l.addModal.actionButtons,
|
|
@@ -2273,14 +2271,14 @@ const je = ({ config: h }) => {
|
|
|
2273
2271
|
{
|
|
2274
2272
|
isOpen: f,
|
|
2275
2273
|
onClose: () => {
|
|
2276
|
-
b ||
|
|
2274
|
+
b || N(!1);
|
|
2277
2275
|
},
|
|
2278
2276
|
icon: (he = l.editModal) == null ? void 0 : he.icon,
|
|
2279
2277
|
title: ((ue = l.editModal) == null ? void 0 : ue.title) || "Edit",
|
|
2280
2278
|
size: ((be = l.editModal) == null ? void 0 : be.size) || "md",
|
|
2281
2279
|
onFormSubmit: () => {
|
|
2282
|
-
var
|
|
2283
|
-
return (
|
|
2280
|
+
var k;
|
|
2281
|
+
return (k = document.querySelector("#editForm")) == null ? void 0 : k.requestSubmit();
|
|
2284
2282
|
},
|
|
2285
2283
|
actionButtons: l.editModal.actionButtons,
|
|
2286
2284
|
loadingBtn: b,
|
|
@@ -2300,8 +2298,8 @@ const je = ({ config: h }) => {
|
|
|
2300
2298
|
fe,
|
|
2301
2299
|
{
|
|
2302
2300
|
isOpen: O,
|
|
2303
|
-
onClose: (
|
|
2304
|
-
ne(
|
|
2301
|
+
onClose: (k) => {
|
|
2302
|
+
ne(k);
|
|
2305
2303
|
},
|
|
2306
2304
|
icon: ((pe = l.deleteModal) == null ? void 0 : pe.icon) || /* @__PURE__ */ e(le, { icon: "ph:warning-bold", className: "w-6 h-6 text-red-500" }),
|
|
2307
2305
|
title: ((ge = l.deleteModal) == null ? void 0 : ge.title) || "Confirm Delete",
|
|
@@ -2321,7 +2319,7 @@ const je = ({ config: h }) => {
|
|
|
2321
2319
|
{
|
|
2322
2320
|
isOpen: F,
|
|
2323
2321
|
onClose: () => {
|
|
2324
|
-
U(!1),
|
|
2322
|
+
U(!1), v(null);
|
|
2325
2323
|
},
|
|
2326
2324
|
icon: (_ = l.viewModal) == null ? void 0 : _.icon,
|
|
2327
2325
|
title: ((J = l.viewModal) == null ? void 0 : J.title) || "View Details",
|