next-recomponents 2.0.38 → 2.0.40
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.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +240 -292
- package/dist/index.mjs +240 -292
- package/package.json +1 -1
- package/src/input/index.tsx +75 -73
- package/src/pop/overlay.tsx +6 -6
- package/src/select/index.tsx +9 -12
- package/src/text-area/index.tsx +26 -31
- package/src/use-resources/index.ts +136 -206
package/dist/index.js
CHANGED
|
@@ -3882,98 +3882,97 @@ function Input({
|
|
|
3882
3882
|
className,
|
|
3883
3883
|
regex,
|
|
3884
3884
|
invalidMessage = "Valor no v\xE1lido",
|
|
3885
|
+
icon = null,
|
|
3885
3886
|
...props
|
|
3886
3887
|
}) {
|
|
3887
3888
|
const value = `${(props == null ? void 0 : props.value) || ""}`;
|
|
3888
3889
|
const isValid = !regex ? true : regex.test(value);
|
|
3889
3890
|
const isPassword = props.type === "password";
|
|
3890
3891
|
const [showPassword, setShowPassword] = (0, import_react4.useState)(false);
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3892
|
+
const svg = icon;
|
|
3893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w-full relative", children: [
|
|
3894
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative flex items-center border rounded bg-white pr-1 mb-5", children: [
|
|
3895
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3896
|
+
"input",
|
|
3897
|
+
{
|
|
3898
|
+
...props,
|
|
3899
|
+
type: isPassword && showPassword ? "text" : props.type,
|
|
3900
|
+
className: [
|
|
3901
|
+
"flex p-2 w-full bg-transparent pt-4",
|
|
3902
|
+
isPassword && "pr-10",
|
|
3903
|
+
value !== "" && !isValid && "bg-red-200 text-black",
|
|
3904
|
+
value !== "" && isValid && "bg-green-200 text-black",
|
|
3905
|
+
className
|
|
3906
|
+
].filter(Boolean).join(" ")
|
|
3907
|
+
}
|
|
3908
|
+
),
|
|
3909
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "absolute -top-2.5 left-2 text-xs font-bold bg-white px-1", children: [
|
|
3894
3910
|
label,
|
|
3895
|
-
" ",
|
|
3896
|
-
(props == null ? void 0 : props.required) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-red-500", children: "*" })
|
|
3911
|
+
(props == null ? void 0 : props.required) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-red-500 ml-1", children: "*" })
|
|
3897
3912
|
] }),
|
|
3898
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3913
|
+
isPassword ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3914
|
+
"button",
|
|
3915
|
+
{
|
|
3916
|
+
type: "button",
|
|
3917
|
+
onClick: () => setShowPassword((prev) => !prev),
|
|
3918
|
+
className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-800 focus:outline-none",
|
|
3919
|
+
"aria-label": showPassword ? "Ocultar contrase\xF1a" : "Mostrar contrase\xF1a",
|
|
3920
|
+
children: showPassword ? (
|
|
3921
|
+
// Ojo cerrado (ocultar)
|
|
3922
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3923
|
+
"svg",
|
|
3924
|
+
{
|
|
3925
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3926
|
+
className: "h-5 w-5",
|
|
3927
|
+
fill: "none",
|
|
3928
|
+
viewBox: "0 0 24 24",
|
|
3929
|
+
stroke: "currentColor",
|
|
3930
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3931
|
+
"path",
|
|
3932
|
+
{
|
|
3933
|
+
strokeLinecap: "round",
|
|
3934
|
+
strokeLinejoin: "round",
|
|
3935
|
+
strokeWidth: 2,
|
|
3936
|
+
d: "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"
|
|
3937
|
+
}
|
|
3938
|
+
)
|
|
3939
|
+
}
|
|
3940
|
+
)
|
|
3941
|
+
) : (
|
|
3942
|
+
// Ojo abierto (mostrar)
|
|
3943
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3944
|
+
"svg",
|
|
3945
|
+
{
|
|
3946
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3947
|
+
className: "h-5 w-5",
|
|
3948
|
+
fill: "none",
|
|
3949
|
+
viewBox: "0 0 24 24",
|
|
3950
|
+
stroke: "currentColor",
|
|
3951
|
+
children: [
|
|
3952
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3931
3953
|
"path",
|
|
3932
3954
|
{
|
|
3933
3955
|
strokeLinecap: "round",
|
|
3934
3956
|
strokeLinejoin: "round",
|
|
3935
3957
|
strokeWidth: 2,
|
|
3936
|
-
d: "
|
|
3958
|
+
d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
3959
|
+
}
|
|
3960
|
+
),
|
|
3961
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3962
|
+
"path",
|
|
3963
|
+
{
|
|
3964
|
+
strokeLinecap: "round",
|
|
3965
|
+
strokeLinejoin: "round",
|
|
3966
|
+
strokeWidth: 2,
|
|
3967
|
+
d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
|
|
3937
3968
|
}
|
|
3938
3969
|
)
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
) : (
|
|
3942
|
-
// Ojo abierto (mostrar)
|
|
3943
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3944
|
-
"svg",
|
|
3945
|
-
{
|
|
3946
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3947
|
-
className: "h-5 w-5",
|
|
3948
|
-
fill: "none",
|
|
3949
|
-
viewBox: "0 0 24 24",
|
|
3950
|
-
stroke: "currentColor",
|
|
3951
|
-
children: [
|
|
3952
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3953
|
-
"path",
|
|
3954
|
-
{
|
|
3955
|
-
strokeLinecap: "round",
|
|
3956
|
-
strokeLinejoin: "round",
|
|
3957
|
-
strokeWidth: 2,
|
|
3958
|
-
d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
3959
|
-
}
|
|
3960
|
-
),
|
|
3961
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3962
|
-
"path",
|
|
3963
|
-
{
|
|
3964
|
-
strokeLinecap: "round",
|
|
3965
|
-
strokeLinejoin: "round",
|
|
3966
|
-
strokeWidth: 2,
|
|
3967
|
-
d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
|
|
3968
|
-
}
|
|
3969
|
-
)
|
|
3970
|
-
]
|
|
3971
|
-
}
|
|
3972
|
-
)
|
|
3970
|
+
]
|
|
3971
|
+
}
|
|
3973
3972
|
)
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
] })
|
|
3973
|
+
)
|
|
3974
|
+
}
|
|
3975
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: "absulute right-[12px] text-[#3a7bd5] ", children: svg })
|
|
3977
3976
|
] }),
|
|
3978
3977
|
!isValid && value !== "" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-red-800 invalid", children: invalidMessage })
|
|
3979
3978
|
] });
|
|
@@ -36178,35 +36177,32 @@ function TextArea({
|
|
|
36178
36177
|
...props
|
|
36179
36178
|
}) {
|
|
36180
36179
|
const [value, setValue] = (0, import_react6.useState)((props == null ? void 0 : props.value) || "");
|
|
36181
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("
|
|
36182
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.
|
|
36180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "w-full relative mb-5", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative flex items-center border rounded bg-white ", children: [
|
|
36181
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
36182
|
+
"textarea",
|
|
36183
|
+
{
|
|
36184
|
+
...props,
|
|
36185
|
+
className: ["p-1 w-full transparent", className].join(" "),
|
|
36186
|
+
value,
|
|
36187
|
+
onChange: (e) => {
|
|
36188
|
+
if (maxLength) {
|
|
36189
|
+
e.target.value = e.target.value.slice(0, maxLength);
|
|
36190
|
+
}
|
|
36191
|
+
setValue(e.target.value);
|
|
36192
|
+
onChange == null ? void 0 : onChange(e);
|
|
36193
|
+
}
|
|
36194
|
+
}
|
|
36195
|
+
),
|
|
36196
|
+
" ",
|
|
36197
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "absolute -top-2.5 left-2 text-xs font-bold bg-white px-1", children: [
|
|
36183
36198
|
label,
|
|
36184
36199
|
" ",
|
|
36185
36200
|
(props == null ? void 0 : props.required) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-red-500", children: "*" })
|
|
36186
36201
|
] }),
|
|
36187
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
36188
|
-
|
|
36189
|
-
|
|
36190
|
-
|
|
36191
|
-
...props,
|
|
36192
|
-
className: ["p-1 w-full rounded border shadow", className].join(
|
|
36193
|
-
" "
|
|
36194
|
-
),
|
|
36195
|
-
value,
|
|
36196
|
-
onChange: (e) => {
|
|
36197
|
-
if (maxLength) {
|
|
36198
|
-
e.target.value = e.target.value.slice(0, maxLength);
|
|
36199
|
-
}
|
|
36200
|
-
setValue(e.target.value);
|
|
36201
|
-
onChange == null ? void 0 : onChange(e);
|
|
36202
|
-
}
|
|
36203
|
-
}
|
|
36204
|
-
),
|
|
36205
|
-
maxLength && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: " text-xs text-gray text-right", children: [
|
|
36206
|
-
value.length,
|
|
36207
|
-
" / ",
|
|
36208
|
-
maxLength
|
|
36209
|
-
] })
|
|
36202
|
+
maxLength && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: " text-xs text-gray text-right", children: [
|
|
36203
|
+
value.length,
|
|
36204
|
+
" / ",
|
|
36205
|
+
maxLength
|
|
36210
36206
|
] })
|
|
36211
36207
|
] }) });
|
|
36212
36208
|
}
|
|
@@ -36407,152 +36403,140 @@ function useResources({
|
|
|
36407
36403
|
return error;
|
|
36408
36404
|
}
|
|
36409
36405
|
};
|
|
36410
|
-
const mergeDataArray = (existingData, newItem, matchId) => {
|
|
36411
|
-
if (!existingData) return [newItem];
|
|
36412
|
-
const index = existingData.findIndex((d) => (d == null ? void 0 : d.id) == matchId);
|
|
36413
|
-
if (index >= 0) {
|
|
36414
|
-
return existingData.map(
|
|
36415
|
-
(d, i) => i === index ? newItem : d
|
|
36416
|
-
);
|
|
36417
|
-
}
|
|
36418
|
-
return [newItem, ...existingData];
|
|
36419
|
-
};
|
|
36420
36406
|
const bodyCreateFunc = async (data) => {
|
|
36421
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
36407
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
36422
36408
|
const options = {
|
|
36423
36409
|
method: "POST",
|
|
36424
36410
|
url: `${baseURI}/${key}`,
|
|
36425
36411
|
data: Array.isArray(data) ? [...data] : { ...data },
|
|
36426
36412
|
headers: { Authorization: token }
|
|
36427
36413
|
};
|
|
36428
|
-
const newInfo = {
|
|
36429
|
-
|
|
36430
|
-
|
|
36431
|
-
...info[key],
|
|
36432
|
-
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36433
|
-
state: "loading",
|
|
36434
|
-
errorMessage: ""
|
|
36435
|
-
}
|
|
36436
|
-
};
|
|
36414
|
+
const newInfo = { ...info };
|
|
36415
|
+
newInfo[key].state = "loading";
|
|
36416
|
+
newInfo[key].errorMessage = "";
|
|
36437
36417
|
setInfo(newInfo);
|
|
36438
36418
|
try {
|
|
36439
36419
|
const consulta = await import_axios.default.request(options);
|
|
36440
36420
|
const d = consulta.data;
|
|
36441
|
-
|
|
36421
|
+
newInfo[key].state = "success";
|
|
36422
|
+
newInfo[key].errorMessage = "";
|
|
36442
36423
|
if (Array.isArray(data)) {
|
|
36443
|
-
|
|
36444
|
-
|
|
36445
|
-
|
|
36424
|
+
for (let datum of data) {
|
|
36425
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36426
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (datum == null ? void 0 : datum.id)
|
|
36427
|
+
);
|
|
36428
|
+
if (index >= 0) {
|
|
36429
|
+
newInfo[key].data[index] = d;
|
|
36430
|
+
} else {
|
|
36431
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
36432
|
+
newInfo[key].data.unshift(d);
|
|
36433
|
+
} else {
|
|
36434
|
+
newInfo[key].data = [d];
|
|
36435
|
+
}
|
|
36436
|
+
}
|
|
36446
36437
|
}
|
|
36447
|
-
|
|
36438
|
+
newInfo[key].data = newInfo[key].data.flat();
|
|
36448
36439
|
} else {
|
|
36449
|
-
|
|
36450
|
-
|
|
36451
|
-
|
|
36452
|
-
data == null ? void 0 : data.id
|
|
36440
|
+
newInfo[key].selectedItem = d;
|
|
36441
|
+
const index = (_e2 = (_d2 = newInfo[key]) == null ? void 0 : _d2.data) == null ? void 0 : _e2.findIndex(
|
|
36442
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (data == null ? void 0 : data.id)
|
|
36453
36443
|
);
|
|
36454
|
-
|
|
36455
|
-
|
|
36456
|
-
|
|
36457
|
-
|
|
36458
|
-
|
|
36459
|
-
|
|
36460
|
-
|
|
36461
|
-
|
|
36462
|
-
data: updatedData
|
|
36444
|
+
if (index >= 0) {
|
|
36445
|
+
newInfo[key].data[index] = d;
|
|
36446
|
+
} else {
|
|
36447
|
+
if ((_f2 = newInfo[key]) == null ? void 0 : _f2.data) {
|
|
36448
|
+
newInfo[key].data.unshift(d);
|
|
36449
|
+
} else {
|
|
36450
|
+
newInfo[key].data = [d];
|
|
36451
|
+
}
|
|
36463
36452
|
}
|
|
36464
|
-
}
|
|
36453
|
+
}
|
|
36454
|
+
setInfo({ ...newInfo });
|
|
36465
36455
|
return d;
|
|
36466
36456
|
} catch (error) {
|
|
36467
36457
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36458
|
+
newInfo[key].state = "error";
|
|
36459
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36468
36460
|
if (error.status == 403) {
|
|
36469
|
-
onError == null ? void 0 : onError({ error, errorMessage: item == null ? void 0 : item.meaning });
|
|
36461
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36470
36462
|
}
|
|
36471
|
-
setInfo({
|
|
36472
|
-
...newInfo,
|
|
36473
|
-
[key]: {
|
|
36474
|
-
...newInfo[key],
|
|
36475
|
-
state: "error",
|
|
36476
|
-
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36477
|
-
}
|
|
36478
|
-
});
|
|
36463
|
+
setInfo({ ...newInfo });
|
|
36479
36464
|
return error;
|
|
36480
36465
|
}
|
|
36481
36466
|
};
|
|
36482
36467
|
const formCreateFunc = async (data) => {
|
|
36483
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
36484
|
-
const
|
|
36485
|
-
|
|
36486
|
-
|
|
36487
|
-
for (const [k, v] of Object.entries(item)) {
|
|
36488
|
-
formData.append(`${k}[${i}]`, v);
|
|
36489
|
-
}
|
|
36490
|
-
});
|
|
36491
|
-
} else {
|
|
36492
|
-
for (const [k, v] of Object.entries(data)) {
|
|
36493
|
-
formData.append(k, v);
|
|
36494
|
-
}
|
|
36495
|
-
}
|
|
36496
|
-
const options = {
|
|
36497
|
-
method: "POST",
|
|
36498
|
-
url: `${baseURI}/${key}`,
|
|
36499
|
-
data: formData,
|
|
36500
|
-
headers: {
|
|
36501
|
-
Authorization: token,
|
|
36502
|
-
"Content-Type": "multipart/form-data"
|
|
36503
|
-
}
|
|
36504
|
-
};
|
|
36505
|
-
const newInfo = {
|
|
36506
|
-
...info,
|
|
36507
|
-
[key]: {
|
|
36508
|
-
...info[key],
|
|
36509
|
-
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36510
|
-
state: "loading",
|
|
36511
|
-
errorMessage: ""
|
|
36512
|
-
}
|
|
36513
|
-
};
|
|
36468
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
36469
|
+
const newInfo = { ...info };
|
|
36470
|
+
newInfo[key].state = "loading";
|
|
36471
|
+
newInfo[key].errorMessage = "";
|
|
36514
36472
|
setInfo(newInfo);
|
|
36515
36473
|
try {
|
|
36474
|
+
const formData = new FormData();
|
|
36475
|
+
if (Array.isArray(data)) {
|
|
36476
|
+
data.forEach((item, i) => {
|
|
36477
|
+
for (const [k, v] of Object.entries(item)) {
|
|
36478
|
+
formData.append(`${k}[${i}]`, v);
|
|
36479
|
+
}
|
|
36480
|
+
});
|
|
36481
|
+
} else {
|
|
36482
|
+
for (const [k, v] of Object.entries(data)) {
|
|
36483
|
+
formData.append(k, v);
|
|
36484
|
+
}
|
|
36485
|
+
}
|
|
36486
|
+
const options = {
|
|
36487
|
+
method: "POST",
|
|
36488
|
+
url: `${baseURI}/${key}`,
|
|
36489
|
+
data: formData,
|
|
36490
|
+
headers: {
|
|
36491
|
+
Authorization: token,
|
|
36492
|
+
"Content-Type": "multipart/form-data"
|
|
36493
|
+
}
|
|
36494
|
+
};
|
|
36516
36495
|
const consulta = await import_axios.default.request(options);
|
|
36517
36496
|
const d = consulta.data;
|
|
36518
|
-
|
|
36497
|
+
newInfo[key].state = "success";
|
|
36498
|
+
newInfo[key].errorMessage = "";
|
|
36519
36499
|
if (Array.isArray(data)) {
|
|
36520
|
-
|
|
36521
|
-
|
|
36522
|
-
|
|
36500
|
+
for (let datum of data) {
|
|
36501
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36502
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (datum == null ? void 0 : datum.id)
|
|
36503
|
+
);
|
|
36504
|
+
if (index >= 0) {
|
|
36505
|
+
newInfo[key].data[index] = d;
|
|
36506
|
+
} else {
|
|
36507
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
36508
|
+
newInfo[key].data.unshift(d);
|
|
36509
|
+
} else {
|
|
36510
|
+
newInfo[key].data = [d];
|
|
36511
|
+
}
|
|
36512
|
+
}
|
|
36523
36513
|
}
|
|
36524
|
-
|
|
36514
|
+
newInfo[key].data = newInfo[key].data.flat();
|
|
36525
36515
|
} else {
|
|
36526
|
-
|
|
36527
|
-
|
|
36528
|
-
|
|
36529
|
-
data == null ? void 0 : data.id
|
|
36516
|
+
newInfo[key].selectedItem = d;
|
|
36517
|
+
const index = (_e2 = (_d2 = newInfo[key]) == null ? void 0 : _d2.data) == null ? void 0 : _e2.findIndex(
|
|
36518
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (data == null ? void 0 : data.id)
|
|
36530
36519
|
);
|
|
36531
|
-
|
|
36532
|
-
|
|
36533
|
-
|
|
36534
|
-
|
|
36535
|
-
|
|
36536
|
-
|
|
36537
|
-
|
|
36538
|
-
|
|
36539
|
-
data: updatedData
|
|
36520
|
+
if (index >= 0) {
|
|
36521
|
+
newInfo[key].data[index] = d;
|
|
36522
|
+
} else {
|
|
36523
|
+
if ((_f2 = newInfo[key]) == null ? void 0 : _f2.data) {
|
|
36524
|
+
newInfo[key].data.unshift(d);
|
|
36525
|
+
} else {
|
|
36526
|
+
newInfo[key].data = [d];
|
|
36527
|
+
}
|
|
36540
36528
|
}
|
|
36541
|
-
}
|
|
36529
|
+
}
|
|
36530
|
+
setInfo({ ...newInfo });
|
|
36542
36531
|
return d;
|
|
36543
36532
|
} catch (error) {
|
|
36544
36533
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36534
|
+
newInfo[key].state = "error";
|
|
36535
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36545
36536
|
if (error.status == 403) {
|
|
36546
|
-
onError == null ? void 0 : onError({ error, errorMessage: item == null ? void 0 : item.meaning });
|
|
36537
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36547
36538
|
}
|
|
36548
|
-
setInfo({
|
|
36549
|
-
...newInfo,
|
|
36550
|
-
[key]: {
|
|
36551
|
-
...newInfo[key],
|
|
36552
|
-
state: "error",
|
|
36553
|
-
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36554
|
-
}
|
|
36555
|
-
});
|
|
36539
|
+
setInfo({ ...newInfo });
|
|
36556
36540
|
return error;
|
|
36557
36541
|
}
|
|
36558
36542
|
};
|
|
@@ -36571,107 +36555,81 @@ function useResources({
|
|
|
36571
36555
|
return await bodyCreateFunc(data);
|
|
36572
36556
|
},
|
|
36573
36557
|
update: async (id, data) => {
|
|
36574
|
-
var _a2, _b2, _c2
|
|
36558
|
+
var _a2, _b2, _c2;
|
|
36575
36559
|
const options = {
|
|
36576
36560
|
method: "PATCH",
|
|
36577
36561
|
url: `${baseURI}/${key}/${id}`,
|
|
36578
36562
|
data: Array.isArray(data) ? [...data] : { ...data },
|
|
36579
36563
|
headers: { Authorization: token }
|
|
36580
36564
|
};
|
|
36581
|
-
const newInfo = {
|
|
36582
|
-
|
|
36583
|
-
|
|
36584
|
-
...info[key],
|
|
36585
|
-
// ✅ copia superficial del key
|
|
36586
|
-
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36587
|
-
// ✅ copia del array
|
|
36588
|
-
state: "loading",
|
|
36589
|
-
errorMessage: ""
|
|
36590
|
-
}
|
|
36591
|
-
};
|
|
36565
|
+
const newInfo = { ...info };
|
|
36566
|
+
newInfo[key].state = "loading";
|
|
36567
|
+
newInfo[key].errorMessage = "";
|
|
36592
36568
|
setInfo(newInfo);
|
|
36593
36569
|
try {
|
|
36594
36570
|
const consulta = await import_axios.default.request(options);
|
|
36595
36571
|
const d = consulta.data;
|
|
36596
|
-
|
|
36597
|
-
|
|
36572
|
+
newInfo[key].state = "success";
|
|
36573
|
+
newInfo[key].errorMessage = "";
|
|
36574
|
+
newInfo[key].selectedItem = { ...newInfo[key].selectedItem, ...d };
|
|
36575
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36576
|
+
(d2) => (d2 == null ? void 0 : d2.id) == id
|
|
36598
36577
|
);
|
|
36599
|
-
|
|
36600
|
-
|
|
36601
|
-
|
|
36602
|
-
|
|
36603
|
-
|
|
36604
|
-
|
|
36605
|
-
|
|
36606
|
-
state: "success",
|
|
36607
|
-
errorMessage: "",
|
|
36608
|
-
selectedItem: { ...newInfo[key].selectedItem, ...d },
|
|
36609
|
-
data: updatedData
|
|
36578
|
+
if (index >= 0) {
|
|
36579
|
+
newInfo[key].data[index] = { ...newInfo[key].data[index], ...d };
|
|
36580
|
+
} else {
|
|
36581
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
36582
|
+
newInfo[key].data.unshift(d);
|
|
36583
|
+
} else {
|
|
36584
|
+
newInfo[key].data = [d];
|
|
36610
36585
|
}
|
|
36611
|
-
}
|
|
36612
|
-
setInfo(
|
|
36586
|
+
}
|
|
36587
|
+
setInfo({ ...newInfo });
|
|
36613
36588
|
return d;
|
|
36614
36589
|
} catch (error) {
|
|
36615
36590
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36616
|
-
|
|
36617
|
-
|
|
36618
|
-
[key]: {
|
|
36619
|
-
...newInfo[key],
|
|
36620
|
-
state: "error",
|
|
36621
|
-
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36622
|
-
}
|
|
36623
|
-
});
|
|
36591
|
+
newInfo[key].state = "error";
|
|
36592
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36624
36593
|
if (error.status == 403) {
|
|
36625
36594
|
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36626
36595
|
}
|
|
36596
|
+
setInfo({ ...newInfo });
|
|
36627
36597
|
return error;
|
|
36628
36598
|
}
|
|
36629
36599
|
},
|
|
36630
36600
|
remove: async (id) => {
|
|
36631
|
-
var _a2, _b2
|
|
36601
|
+
var _a2, _b2;
|
|
36632
36602
|
const options = {
|
|
36633
36603
|
method: "DELETE",
|
|
36634
36604
|
url: `${baseURI}/${key}/${id}`,
|
|
36635
36605
|
headers: { Authorization: token }
|
|
36636
36606
|
};
|
|
36637
|
-
const newInfo = {
|
|
36638
|
-
|
|
36639
|
-
|
|
36640
|
-
...info[key],
|
|
36641
|
-
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36642
|
-
state: "loading",
|
|
36643
|
-
errorMessage: ""
|
|
36644
|
-
}
|
|
36645
|
-
};
|
|
36607
|
+
const newInfo = { ...info };
|
|
36608
|
+
newInfo[key].state = "loading";
|
|
36609
|
+
newInfo[key].errorMessage = "";
|
|
36646
36610
|
setInfo(newInfo);
|
|
36647
36611
|
try {
|
|
36648
36612
|
const consulta = await import_axios.default.request(options);
|
|
36649
36613
|
const d = consulta.data;
|
|
36650
|
-
|
|
36651
|
-
|
|
36652
|
-
|
|
36653
|
-
|
|
36654
|
-
|
|
36655
|
-
|
|
36656
|
-
|
|
36657
|
-
|
|
36658
|
-
|
|
36659
|
-
|
|
36660
|
-
});
|
|
36614
|
+
newInfo[key].state = "success";
|
|
36615
|
+
newInfo[key].errorMessage = "";
|
|
36616
|
+
newInfo[key].selectedItem = d;
|
|
36617
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36618
|
+
(d2) => (d2 == null ? void 0 : d2.id) == id
|
|
36619
|
+
);
|
|
36620
|
+
if (index >= 0) {
|
|
36621
|
+
newInfo[key].data.splice(index, 1);
|
|
36622
|
+
}
|
|
36623
|
+
setInfo({ ...newInfo });
|
|
36661
36624
|
return d.data;
|
|
36662
36625
|
} catch (error) {
|
|
36663
36626
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36627
|
+
newInfo[key].state = "error";
|
|
36628
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36664
36629
|
if (error.status == 403) {
|
|
36665
|
-
onError == null ? void 0 : onError({ error, errorMessage: item == null ? void 0 : item.meaning });
|
|
36630
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36666
36631
|
}
|
|
36667
|
-
setInfo({
|
|
36668
|
-
...newInfo,
|
|
36669
|
-
[key]: {
|
|
36670
|
-
...newInfo[key],
|
|
36671
|
-
state: "error",
|
|
36672
|
-
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36673
|
-
}
|
|
36674
|
-
});
|
|
36632
|
+
setInfo({ ...newInfo });
|
|
36675
36633
|
return error;
|
|
36676
36634
|
}
|
|
36677
36635
|
},
|
|
@@ -36856,23 +36814,15 @@ function Select({
|
|
|
36856
36814
|
}
|
|
36857
36815
|
}
|
|
36858
36816
|
}, [isOpen]);
|
|
36859
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { ref: containerRef, className: "w-full", children: [
|
|
36860
|
-
|
|
36861
|
-
label,
|
|
36862
|
-
" ",
|
|
36863
|
-
(props == null ? void 0 : props.required) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-red-500", children: "*" })
|
|
36864
|
-
] }),
|
|
36865
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "relative", children: [
|
|
36817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { ref: containerRef, className: "w-full relative mb-5", children: [
|
|
36818
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "relative flex items-center border rounded bg-white", children: [
|
|
36866
36819
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
36867
36820
|
"input",
|
|
36868
36821
|
{
|
|
36869
36822
|
autoComplete: "off",
|
|
36870
36823
|
ref: inputRef,
|
|
36871
36824
|
...props,
|
|
36872
|
-
className: [
|
|
36873
|
-
"p-2 w-full rounded border shadow",
|
|
36874
|
-
props == null ? void 0 : props.className
|
|
36875
|
-
].join(" "),
|
|
36825
|
+
className: ["p-2 w-full transparent", props == null ? void 0 : props.className].join(" "),
|
|
36876
36826
|
value: inputValue,
|
|
36877
36827
|
onBlur: (e) => {
|
|
36878
36828
|
setTimeout(() => {
|
|
@@ -36902,6 +36852,11 @@ function Select({
|
|
|
36902
36852
|
onKeyDown: handleKeyDown
|
|
36903
36853
|
}
|
|
36904
36854
|
),
|
|
36855
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "absolute -top-2.5 left-2 text-xs font-bold bg-white px-1", children: [
|
|
36856
|
+
label,
|
|
36857
|
+
" ",
|
|
36858
|
+
(props == null ? void 0 : props.required) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-red-500", children: "*" })
|
|
36859
|
+
] }),
|
|
36905
36860
|
!isOpen && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "absolute top-0 right-0 flex flex-col justify-center items-center px-2 py-2 font-bold", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectIcon, {}) }),
|
|
36906
36861
|
isOpen && inputValue != "" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
36907
36862
|
"button",
|
|
@@ -36925,7 +36880,7 @@ function Select({
|
|
|
36925
36880
|
"div",
|
|
36926
36881
|
{
|
|
36927
36882
|
style: { zIndex: 9999999999 },
|
|
36928
|
-
className: `absolute w-full border rounded shadow bg-white z-10 max-h-100 overflow-y-auto ${openUpwards ? "bottom-full mb-1" : "mt-1"}`,
|
|
36883
|
+
className: `absolute w-full border rounded shadow bg-white z-10 max-h-100 top-10 overflow-y-auto ${openUpwards ? "bottom-full mb-1" : "mt-1"}`,
|
|
36929
36884
|
children: filtered.map((opt, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
36930
36885
|
"div",
|
|
36931
36886
|
{
|
|
@@ -37132,13 +37087,6 @@ function PopupOverlay({
|
|
|
37132
37087
|
{
|
|
37133
37088
|
className: "fixed inset-0 flex items-center justify-center z-[1000] ",
|
|
37134
37089
|
style: { background: "rgba(15,23,42,0.45)", backdropFilter: "blur(2px)" },
|
|
37135
|
-
onClick: (e) => {
|
|
37136
|
-
var _a;
|
|
37137
|
-
if (e.target === e.currentTarget) {
|
|
37138
|
-
onClose(false);
|
|
37139
|
-
(_a = popup.onCancel) == null ? void 0 : _a.call(popup);
|
|
37140
|
-
}
|
|
37141
|
-
},
|
|
37142
37090
|
children: [
|
|
37143
37091
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("style", { children: `
|
|
37144
37092
|
@keyframes fadeInScale {
|