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.mjs
CHANGED
|
@@ -3862,98 +3862,97 @@ function Input({
|
|
|
3862
3862
|
className,
|
|
3863
3863
|
regex,
|
|
3864
3864
|
invalidMessage = "Valor no v\xE1lido",
|
|
3865
|
+
icon = null,
|
|
3865
3866
|
...props
|
|
3866
3867
|
}) {
|
|
3867
3868
|
const value = `${(props == null ? void 0 : props.value) || ""}`;
|
|
3868
3869
|
const isValid = !regex ? true : regex.test(value);
|
|
3869
3870
|
const isPassword = props.type === "password";
|
|
3870
3871
|
const [showPassword, setShowPassword] = useState4(false);
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3872
|
+
const svg = icon;
|
|
3873
|
+
return /* @__PURE__ */ jsxs4("div", { className: "w-full relative", children: [
|
|
3874
|
+
/* @__PURE__ */ jsxs4("div", { className: "relative flex items-center border rounded bg-white pr-1 mb-5", children: [
|
|
3875
|
+
/* @__PURE__ */ jsx5(
|
|
3876
|
+
"input",
|
|
3877
|
+
{
|
|
3878
|
+
...props,
|
|
3879
|
+
type: isPassword && showPassword ? "text" : props.type,
|
|
3880
|
+
className: [
|
|
3881
|
+
"flex p-2 w-full bg-transparent pt-4",
|
|
3882
|
+
isPassword && "pr-10",
|
|
3883
|
+
value !== "" && !isValid && "bg-red-200 text-black",
|
|
3884
|
+
value !== "" && isValid && "bg-green-200 text-black",
|
|
3885
|
+
className
|
|
3886
|
+
].filter(Boolean).join(" ")
|
|
3887
|
+
}
|
|
3888
|
+
),
|
|
3889
|
+
/* @__PURE__ */ jsxs4("label", { className: "absolute -top-2.5 left-2 text-xs font-bold bg-white px-1", children: [
|
|
3874
3890
|
label,
|
|
3875
|
-
" ",
|
|
3876
|
-
(props == null ? void 0 : props.required) && /* @__PURE__ */ jsx5("span", { className: "text-red-500", children: "*" })
|
|
3891
|
+
(props == null ? void 0 : props.required) && /* @__PURE__ */ jsx5("span", { className: "text-red-500 ml-1", children: "*" })
|
|
3877
3892
|
] }),
|
|
3878
|
-
/* @__PURE__ */
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3893
|
+
isPassword ? /* @__PURE__ */ jsx5(
|
|
3894
|
+
"button",
|
|
3895
|
+
{
|
|
3896
|
+
type: "button",
|
|
3897
|
+
onClick: () => setShowPassword((prev) => !prev),
|
|
3898
|
+
className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-800 focus:outline-none",
|
|
3899
|
+
"aria-label": showPassword ? "Ocultar contrase\xF1a" : "Mostrar contrase\xF1a",
|
|
3900
|
+
children: showPassword ? (
|
|
3901
|
+
// Ojo cerrado (ocultar)
|
|
3902
|
+
/* @__PURE__ */ jsx5(
|
|
3903
|
+
"svg",
|
|
3904
|
+
{
|
|
3905
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3906
|
+
className: "h-5 w-5",
|
|
3907
|
+
fill: "none",
|
|
3908
|
+
viewBox: "0 0 24 24",
|
|
3909
|
+
stroke: "currentColor",
|
|
3910
|
+
children: /* @__PURE__ */ jsx5(
|
|
3911
|
+
"path",
|
|
3912
|
+
{
|
|
3913
|
+
strokeLinecap: "round",
|
|
3914
|
+
strokeLinejoin: "round",
|
|
3915
|
+
strokeWidth: 2,
|
|
3916
|
+
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"
|
|
3917
|
+
}
|
|
3918
|
+
)
|
|
3919
|
+
}
|
|
3920
|
+
)
|
|
3921
|
+
) : (
|
|
3922
|
+
// Ojo abierto (mostrar)
|
|
3923
|
+
/* @__PURE__ */ jsxs4(
|
|
3924
|
+
"svg",
|
|
3925
|
+
{
|
|
3926
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3927
|
+
className: "h-5 w-5",
|
|
3928
|
+
fill: "none",
|
|
3929
|
+
viewBox: "0 0 24 24",
|
|
3930
|
+
stroke: "currentColor",
|
|
3931
|
+
children: [
|
|
3932
|
+
/* @__PURE__ */ jsx5(
|
|
3911
3933
|
"path",
|
|
3912
3934
|
{
|
|
3913
3935
|
strokeLinecap: "round",
|
|
3914
3936
|
strokeLinejoin: "round",
|
|
3915
3937
|
strokeWidth: 2,
|
|
3916
|
-
d: "
|
|
3938
|
+
d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
3939
|
+
}
|
|
3940
|
+
),
|
|
3941
|
+
/* @__PURE__ */ jsx5(
|
|
3942
|
+
"path",
|
|
3943
|
+
{
|
|
3944
|
+
strokeLinecap: "round",
|
|
3945
|
+
strokeLinejoin: "round",
|
|
3946
|
+
strokeWidth: 2,
|
|
3947
|
+
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"
|
|
3917
3948
|
}
|
|
3918
3949
|
)
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
) : (
|
|
3922
|
-
// Ojo abierto (mostrar)
|
|
3923
|
-
/* @__PURE__ */ jsxs4(
|
|
3924
|
-
"svg",
|
|
3925
|
-
{
|
|
3926
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3927
|
-
className: "h-5 w-5",
|
|
3928
|
-
fill: "none",
|
|
3929
|
-
viewBox: "0 0 24 24",
|
|
3930
|
-
stroke: "currentColor",
|
|
3931
|
-
children: [
|
|
3932
|
-
/* @__PURE__ */ jsx5(
|
|
3933
|
-
"path",
|
|
3934
|
-
{
|
|
3935
|
-
strokeLinecap: "round",
|
|
3936
|
-
strokeLinejoin: "round",
|
|
3937
|
-
strokeWidth: 2,
|
|
3938
|
-
d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
3939
|
-
}
|
|
3940
|
-
),
|
|
3941
|
-
/* @__PURE__ */ jsx5(
|
|
3942
|
-
"path",
|
|
3943
|
-
{
|
|
3944
|
-
strokeLinecap: "round",
|
|
3945
|
-
strokeLinejoin: "round",
|
|
3946
|
-
strokeWidth: 2,
|
|
3947
|
-
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"
|
|
3948
|
-
}
|
|
3949
|
-
)
|
|
3950
|
-
]
|
|
3951
|
-
}
|
|
3952
|
-
)
|
|
3950
|
+
]
|
|
3951
|
+
}
|
|
3953
3952
|
)
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
] })
|
|
3953
|
+
)
|
|
3954
|
+
}
|
|
3955
|
+
) : /* @__PURE__ */ jsx5("i", { className: "absulute right-[12px] text-[#3a7bd5] ", children: svg })
|
|
3957
3956
|
] }),
|
|
3958
3957
|
!isValid && value !== "" && /* @__PURE__ */ jsx5("div", { className: "text-red-800 invalid", children: invalidMessage })
|
|
3959
3958
|
] });
|
|
@@ -36160,35 +36159,32 @@ function TextArea({
|
|
|
36160
36159
|
...props
|
|
36161
36160
|
}) {
|
|
36162
36161
|
const [value, setValue] = useState6((props == null ? void 0 : props.value) || "");
|
|
36163
|
-
return /* @__PURE__ */ jsx7("div", { className: "w-full", children: /* @__PURE__ */ jsxs6("
|
|
36164
|
-
/* @__PURE__ */
|
|
36162
|
+
return /* @__PURE__ */ jsx7("div", { className: "w-full relative mb-5", children: /* @__PURE__ */ jsxs6("div", { className: "relative flex items-center border rounded bg-white ", children: [
|
|
36163
|
+
/* @__PURE__ */ jsx7(
|
|
36164
|
+
"textarea",
|
|
36165
|
+
{
|
|
36166
|
+
...props,
|
|
36167
|
+
className: ["p-1 w-full transparent", className].join(" "),
|
|
36168
|
+
value,
|
|
36169
|
+
onChange: (e) => {
|
|
36170
|
+
if (maxLength) {
|
|
36171
|
+
e.target.value = e.target.value.slice(0, maxLength);
|
|
36172
|
+
}
|
|
36173
|
+
setValue(e.target.value);
|
|
36174
|
+
onChange == null ? void 0 : onChange(e);
|
|
36175
|
+
}
|
|
36176
|
+
}
|
|
36177
|
+
),
|
|
36178
|
+
" ",
|
|
36179
|
+
/* @__PURE__ */ jsxs6("label", { className: "absolute -top-2.5 left-2 text-xs font-bold bg-white px-1", children: [
|
|
36165
36180
|
label,
|
|
36166
36181
|
" ",
|
|
36167
36182
|
(props == null ? void 0 : props.required) && /* @__PURE__ */ jsx7("span", { className: "text-red-500", children: "*" })
|
|
36168
36183
|
] }),
|
|
36169
|
-
/* @__PURE__ */ jsxs6("div", { children: [
|
|
36170
|
-
|
|
36171
|
-
|
|
36172
|
-
|
|
36173
|
-
...props,
|
|
36174
|
-
className: ["p-1 w-full rounded border shadow", className].join(
|
|
36175
|
-
" "
|
|
36176
|
-
),
|
|
36177
|
-
value,
|
|
36178
|
-
onChange: (e) => {
|
|
36179
|
-
if (maxLength) {
|
|
36180
|
-
e.target.value = e.target.value.slice(0, maxLength);
|
|
36181
|
-
}
|
|
36182
|
-
setValue(e.target.value);
|
|
36183
|
-
onChange == null ? void 0 : onChange(e);
|
|
36184
|
-
}
|
|
36185
|
-
}
|
|
36186
|
-
),
|
|
36187
|
-
maxLength && /* @__PURE__ */ jsxs6("div", { className: " text-xs text-gray text-right", children: [
|
|
36188
|
-
value.length,
|
|
36189
|
-
" / ",
|
|
36190
|
-
maxLength
|
|
36191
|
-
] })
|
|
36184
|
+
maxLength && /* @__PURE__ */ jsxs6("div", { className: " text-xs text-gray text-right", children: [
|
|
36185
|
+
value.length,
|
|
36186
|
+
" / ",
|
|
36187
|
+
maxLength
|
|
36192
36188
|
] })
|
|
36193
36189
|
] }) });
|
|
36194
36190
|
}
|
|
@@ -36389,152 +36385,140 @@ function useResources({
|
|
|
36389
36385
|
return error;
|
|
36390
36386
|
}
|
|
36391
36387
|
};
|
|
36392
|
-
const mergeDataArray = (existingData, newItem, matchId) => {
|
|
36393
|
-
if (!existingData) return [newItem];
|
|
36394
|
-
const index = existingData.findIndex((d) => (d == null ? void 0 : d.id) == matchId);
|
|
36395
|
-
if (index >= 0) {
|
|
36396
|
-
return existingData.map(
|
|
36397
|
-
(d, i) => i === index ? newItem : d
|
|
36398
|
-
);
|
|
36399
|
-
}
|
|
36400
|
-
return [newItem, ...existingData];
|
|
36401
|
-
};
|
|
36402
36388
|
const bodyCreateFunc = async (data) => {
|
|
36403
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
36389
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
36404
36390
|
const options = {
|
|
36405
36391
|
method: "POST",
|
|
36406
36392
|
url: `${baseURI}/${key}`,
|
|
36407
36393
|
data: Array.isArray(data) ? [...data] : { ...data },
|
|
36408
36394
|
headers: { Authorization: token }
|
|
36409
36395
|
};
|
|
36410
|
-
const newInfo = {
|
|
36411
|
-
|
|
36412
|
-
|
|
36413
|
-
...info[key],
|
|
36414
|
-
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36415
|
-
state: "loading",
|
|
36416
|
-
errorMessage: ""
|
|
36417
|
-
}
|
|
36418
|
-
};
|
|
36396
|
+
const newInfo = { ...info };
|
|
36397
|
+
newInfo[key].state = "loading";
|
|
36398
|
+
newInfo[key].errorMessage = "";
|
|
36419
36399
|
setInfo(newInfo);
|
|
36420
36400
|
try {
|
|
36421
36401
|
const consulta = await axios.request(options);
|
|
36422
36402
|
const d = consulta.data;
|
|
36423
|
-
|
|
36403
|
+
newInfo[key].state = "success";
|
|
36404
|
+
newInfo[key].errorMessage = "";
|
|
36424
36405
|
if (Array.isArray(data)) {
|
|
36425
|
-
|
|
36426
|
-
|
|
36427
|
-
|
|
36406
|
+
for (let datum of data) {
|
|
36407
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36408
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (datum == null ? void 0 : datum.id)
|
|
36409
|
+
);
|
|
36410
|
+
if (index >= 0) {
|
|
36411
|
+
newInfo[key].data[index] = d;
|
|
36412
|
+
} else {
|
|
36413
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
36414
|
+
newInfo[key].data.unshift(d);
|
|
36415
|
+
} else {
|
|
36416
|
+
newInfo[key].data = [d];
|
|
36417
|
+
}
|
|
36418
|
+
}
|
|
36428
36419
|
}
|
|
36429
|
-
|
|
36420
|
+
newInfo[key].data = newInfo[key].data.flat();
|
|
36430
36421
|
} else {
|
|
36431
|
-
|
|
36432
|
-
|
|
36433
|
-
|
|
36434
|
-
data == null ? void 0 : data.id
|
|
36422
|
+
newInfo[key].selectedItem = d;
|
|
36423
|
+
const index = (_e2 = (_d2 = newInfo[key]) == null ? void 0 : _d2.data) == null ? void 0 : _e2.findIndex(
|
|
36424
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (data == null ? void 0 : data.id)
|
|
36435
36425
|
);
|
|
36436
|
-
|
|
36437
|
-
|
|
36438
|
-
|
|
36439
|
-
|
|
36440
|
-
|
|
36441
|
-
|
|
36442
|
-
|
|
36443
|
-
|
|
36444
|
-
data: updatedData
|
|
36426
|
+
if (index >= 0) {
|
|
36427
|
+
newInfo[key].data[index] = d;
|
|
36428
|
+
} else {
|
|
36429
|
+
if ((_f2 = newInfo[key]) == null ? void 0 : _f2.data) {
|
|
36430
|
+
newInfo[key].data.unshift(d);
|
|
36431
|
+
} else {
|
|
36432
|
+
newInfo[key].data = [d];
|
|
36433
|
+
}
|
|
36445
36434
|
}
|
|
36446
|
-
}
|
|
36435
|
+
}
|
|
36436
|
+
setInfo({ ...newInfo });
|
|
36447
36437
|
return d;
|
|
36448
36438
|
} catch (error) {
|
|
36449
36439
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36440
|
+
newInfo[key].state = "error";
|
|
36441
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36450
36442
|
if (error.status == 403) {
|
|
36451
|
-
onError == null ? void 0 : onError({ error, errorMessage: item == null ? void 0 : item.meaning });
|
|
36443
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36452
36444
|
}
|
|
36453
|
-
setInfo({
|
|
36454
|
-
...newInfo,
|
|
36455
|
-
[key]: {
|
|
36456
|
-
...newInfo[key],
|
|
36457
|
-
state: "error",
|
|
36458
|
-
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36459
|
-
}
|
|
36460
|
-
});
|
|
36445
|
+
setInfo({ ...newInfo });
|
|
36461
36446
|
return error;
|
|
36462
36447
|
}
|
|
36463
36448
|
};
|
|
36464
36449
|
const formCreateFunc = async (data) => {
|
|
36465
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
36466
|
-
const
|
|
36467
|
-
|
|
36468
|
-
|
|
36469
|
-
for (const [k, v] of Object.entries(item)) {
|
|
36470
|
-
formData.append(`${k}[${i}]`, v);
|
|
36471
|
-
}
|
|
36472
|
-
});
|
|
36473
|
-
} else {
|
|
36474
|
-
for (const [k, v] of Object.entries(data)) {
|
|
36475
|
-
formData.append(k, v);
|
|
36476
|
-
}
|
|
36477
|
-
}
|
|
36478
|
-
const options = {
|
|
36479
|
-
method: "POST",
|
|
36480
|
-
url: `${baseURI}/${key}`,
|
|
36481
|
-
data: formData,
|
|
36482
|
-
headers: {
|
|
36483
|
-
Authorization: token,
|
|
36484
|
-
"Content-Type": "multipart/form-data"
|
|
36485
|
-
}
|
|
36486
|
-
};
|
|
36487
|
-
const newInfo = {
|
|
36488
|
-
...info,
|
|
36489
|
-
[key]: {
|
|
36490
|
-
...info[key],
|
|
36491
|
-
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36492
|
-
state: "loading",
|
|
36493
|
-
errorMessage: ""
|
|
36494
|
-
}
|
|
36495
|
-
};
|
|
36450
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
36451
|
+
const newInfo = { ...info };
|
|
36452
|
+
newInfo[key].state = "loading";
|
|
36453
|
+
newInfo[key].errorMessage = "";
|
|
36496
36454
|
setInfo(newInfo);
|
|
36497
36455
|
try {
|
|
36456
|
+
const formData = new FormData();
|
|
36457
|
+
if (Array.isArray(data)) {
|
|
36458
|
+
data.forEach((item, i) => {
|
|
36459
|
+
for (const [k, v] of Object.entries(item)) {
|
|
36460
|
+
formData.append(`${k}[${i}]`, v);
|
|
36461
|
+
}
|
|
36462
|
+
});
|
|
36463
|
+
} else {
|
|
36464
|
+
for (const [k, v] of Object.entries(data)) {
|
|
36465
|
+
formData.append(k, v);
|
|
36466
|
+
}
|
|
36467
|
+
}
|
|
36468
|
+
const options = {
|
|
36469
|
+
method: "POST",
|
|
36470
|
+
url: `${baseURI}/${key}`,
|
|
36471
|
+
data: formData,
|
|
36472
|
+
headers: {
|
|
36473
|
+
Authorization: token,
|
|
36474
|
+
"Content-Type": "multipart/form-data"
|
|
36475
|
+
}
|
|
36476
|
+
};
|
|
36498
36477
|
const consulta = await axios.request(options);
|
|
36499
36478
|
const d = consulta.data;
|
|
36500
|
-
|
|
36479
|
+
newInfo[key].state = "success";
|
|
36480
|
+
newInfo[key].errorMessage = "";
|
|
36501
36481
|
if (Array.isArray(data)) {
|
|
36502
|
-
|
|
36503
|
-
|
|
36504
|
-
|
|
36482
|
+
for (let datum of data) {
|
|
36483
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36484
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (datum == null ? void 0 : datum.id)
|
|
36485
|
+
);
|
|
36486
|
+
if (index >= 0) {
|
|
36487
|
+
newInfo[key].data[index] = d;
|
|
36488
|
+
} else {
|
|
36489
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
36490
|
+
newInfo[key].data.unshift(d);
|
|
36491
|
+
} else {
|
|
36492
|
+
newInfo[key].data = [d];
|
|
36493
|
+
}
|
|
36494
|
+
}
|
|
36505
36495
|
}
|
|
36506
|
-
|
|
36496
|
+
newInfo[key].data = newInfo[key].data.flat();
|
|
36507
36497
|
} else {
|
|
36508
|
-
|
|
36509
|
-
|
|
36510
|
-
|
|
36511
|
-
data == null ? void 0 : data.id
|
|
36498
|
+
newInfo[key].selectedItem = d;
|
|
36499
|
+
const index = (_e2 = (_d2 = newInfo[key]) == null ? void 0 : _d2.data) == null ? void 0 : _e2.findIndex(
|
|
36500
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (data == null ? void 0 : data.id)
|
|
36512
36501
|
);
|
|
36513
|
-
|
|
36514
|
-
|
|
36515
|
-
|
|
36516
|
-
|
|
36517
|
-
|
|
36518
|
-
|
|
36519
|
-
|
|
36520
|
-
|
|
36521
|
-
data: updatedData
|
|
36502
|
+
if (index >= 0) {
|
|
36503
|
+
newInfo[key].data[index] = d;
|
|
36504
|
+
} else {
|
|
36505
|
+
if ((_f2 = newInfo[key]) == null ? void 0 : _f2.data) {
|
|
36506
|
+
newInfo[key].data.unshift(d);
|
|
36507
|
+
} else {
|
|
36508
|
+
newInfo[key].data = [d];
|
|
36509
|
+
}
|
|
36522
36510
|
}
|
|
36523
|
-
}
|
|
36511
|
+
}
|
|
36512
|
+
setInfo({ ...newInfo });
|
|
36524
36513
|
return d;
|
|
36525
36514
|
} catch (error) {
|
|
36526
36515
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36516
|
+
newInfo[key].state = "error";
|
|
36517
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36527
36518
|
if (error.status == 403) {
|
|
36528
|
-
onError == null ? void 0 : onError({ error, errorMessage: item == null ? void 0 : item.meaning });
|
|
36519
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36529
36520
|
}
|
|
36530
|
-
setInfo({
|
|
36531
|
-
...newInfo,
|
|
36532
|
-
[key]: {
|
|
36533
|
-
...newInfo[key],
|
|
36534
|
-
state: "error",
|
|
36535
|
-
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36536
|
-
}
|
|
36537
|
-
});
|
|
36521
|
+
setInfo({ ...newInfo });
|
|
36538
36522
|
return error;
|
|
36539
36523
|
}
|
|
36540
36524
|
};
|
|
@@ -36553,107 +36537,81 @@ function useResources({
|
|
|
36553
36537
|
return await bodyCreateFunc(data);
|
|
36554
36538
|
},
|
|
36555
36539
|
update: async (id, data) => {
|
|
36556
|
-
var _a2, _b2, _c2
|
|
36540
|
+
var _a2, _b2, _c2;
|
|
36557
36541
|
const options = {
|
|
36558
36542
|
method: "PATCH",
|
|
36559
36543
|
url: `${baseURI}/${key}/${id}`,
|
|
36560
36544
|
data: Array.isArray(data) ? [...data] : { ...data },
|
|
36561
36545
|
headers: { Authorization: token }
|
|
36562
36546
|
};
|
|
36563
|
-
const newInfo = {
|
|
36564
|
-
|
|
36565
|
-
|
|
36566
|
-
...info[key],
|
|
36567
|
-
// ✅ copia superficial del key
|
|
36568
|
-
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36569
|
-
// ✅ copia del array
|
|
36570
|
-
state: "loading",
|
|
36571
|
-
errorMessage: ""
|
|
36572
|
-
}
|
|
36573
|
-
};
|
|
36547
|
+
const newInfo = { ...info };
|
|
36548
|
+
newInfo[key].state = "loading";
|
|
36549
|
+
newInfo[key].errorMessage = "";
|
|
36574
36550
|
setInfo(newInfo);
|
|
36575
36551
|
try {
|
|
36576
36552
|
const consulta = await axios.request(options);
|
|
36577
36553
|
const d = consulta.data;
|
|
36578
|
-
|
|
36579
|
-
|
|
36554
|
+
newInfo[key].state = "success";
|
|
36555
|
+
newInfo[key].errorMessage = "";
|
|
36556
|
+
newInfo[key].selectedItem = { ...newInfo[key].selectedItem, ...d };
|
|
36557
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36558
|
+
(d2) => (d2 == null ? void 0 : d2.id) == id
|
|
36580
36559
|
);
|
|
36581
|
-
|
|
36582
|
-
|
|
36583
|
-
|
|
36584
|
-
|
|
36585
|
-
|
|
36586
|
-
|
|
36587
|
-
|
|
36588
|
-
state: "success",
|
|
36589
|
-
errorMessage: "",
|
|
36590
|
-
selectedItem: { ...newInfo[key].selectedItem, ...d },
|
|
36591
|
-
data: updatedData
|
|
36560
|
+
if (index >= 0) {
|
|
36561
|
+
newInfo[key].data[index] = { ...newInfo[key].data[index], ...d };
|
|
36562
|
+
} else {
|
|
36563
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
36564
|
+
newInfo[key].data.unshift(d);
|
|
36565
|
+
} else {
|
|
36566
|
+
newInfo[key].data = [d];
|
|
36592
36567
|
}
|
|
36593
|
-
}
|
|
36594
|
-
setInfo(
|
|
36568
|
+
}
|
|
36569
|
+
setInfo({ ...newInfo });
|
|
36595
36570
|
return d;
|
|
36596
36571
|
} catch (error) {
|
|
36597
36572
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36598
|
-
|
|
36599
|
-
|
|
36600
|
-
[key]: {
|
|
36601
|
-
...newInfo[key],
|
|
36602
|
-
state: "error",
|
|
36603
|
-
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36604
|
-
}
|
|
36605
|
-
});
|
|
36573
|
+
newInfo[key].state = "error";
|
|
36574
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36606
36575
|
if (error.status == 403) {
|
|
36607
36576
|
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36608
36577
|
}
|
|
36578
|
+
setInfo({ ...newInfo });
|
|
36609
36579
|
return error;
|
|
36610
36580
|
}
|
|
36611
36581
|
},
|
|
36612
36582
|
remove: async (id) => {
|
|
36613
|
-
var _a2, _b2
|
|
36583
|
+
var _a2, _b2;
|
|
36614
36584
|
const options = {
|
|
36615
36585
|
method: "DELETE",
|
|
36616
36586
|
url: `${baseURI}/${key}/${id}`,
|
|
36617
36587
|
headers: { Authorization: token }
|
|
36618
36588
|
};
|
|
36619
|
-
const newInfo = {
|
|
36620
|
-
|
|
36621
|
-
|
|
36622
|
-
...info[key],
|
|
36623
|
-
data: [...(_b2 = (_a2 = info[key]) == null ? void 0 : _a2.data) != null ? _b2 : []],
|
|
36624
|
-
state: "loading",
|
|
36625
|
-
errorMessage: ""
|
|
36626
|
-
}
|
|
36627
|
-
};
|
|
36589
|
+
const newInfo = { ...info };
|
|
36590
|
+
newInfo[key].state = "loading";
|
|
36591
|
+
newInfo[key].errorMessage = "";
|
|
36628
36592
|
setInfo(newInfo);
|
|
36629
36593
|
try {
|
|
36630
36594
|
const consulta = await axios.request(options);
|
|
36631
36595
|
const d = consulta.data;
|
|
36632
|
-
|
|
36633
|
-
|
|
36634
|
-
|
|
36635
|
-
|
|
36636
|
-
|
|
36637
|
-
|
|
36638
|
-
|
|
36639
|
-
|
|
36640
|
-
|
|
36641
|
-
|
|
36642
|
-
});
|
|
36596
|
+
newInfo[key].state = "success";
|
|
36597
|
+
newInfo[key].errorMessage = "";
|
|
36598
|
+
newInfo[key].selectedItem = d;
|
|
36599
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36600
|
+
(d2) => (d2 == null ? void 0 : d2.id) == id
|
|
36601
|
+
);
|
|
36602
|
+
if (index >= 0) {
|
|
36603
|
+
newInfo[key].data.splice(index, 1);
|
|
36604
|
+
}
|
|
36605
|
+
setInfo({ ...newInfo });
|
|
36643
36606
|
return d.data;
|
|
36644
36607
|
} catch (error) {
|
|
36645
36608
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36609
|
+
newInfo[key].state = "error";
|
|
36610
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36646
36611
|
if (error.status == 403) {
|
|
36647
|
-
onError == null ? void 0 : onError({ error, errorMessage: item == null ? void 0 : item.meaning });
|
|
36612
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36648
36613
|
}
|
|
36649
|
-
setInfo({
|
|
36650
|
-
...newInfo,
|
|
36651
|
-
[key]: {
|
|
36652
|
-
...newInfo[key],
|
|
36653
|
-
state: "error",
|
|
36654
|
-
errorMessage: (item == null ? void 0 : item.meaning) || error.message
|
|
36655
|
-
}
|
|
36656
|
-
});
|
|
36614
|
+
setInfo({ ...newInfo });
|
|
36657
36615
|
return error;
|
|
36658
36616
|
}
|
|
36659
36617
|
},
|
|
@@ -36842,23 +36800,15 @@ function Select({
|
|
|
36842
36800
|
}
|
|
36843
36801
|
}
|
|
36844
36802
|
}, [isOpen]);
|
|
36845
|
-
return /* @__PURE__ */ jsxs7("div", { ref: containerRef, className: "w-full", children: [
|
|
36846
|
-
|
|
36847
|
-
label,
|
|
36848
|
-
" ",
|
|
36849
|
-
(props == null ? void 0 : props.required) && /* @__PURE__ */ jsx10("span", { className: "text-red-500", children: "*" })
|
|
36850
|
-
] }),
|
|
36851
|
-
/* @__PURE__ */ jsxs7("div", { className: "relative", children: [
|
|
36803
|
+
return /* @__PURE__ */ jsxs7("div", { ref: containerRef, className: "w-full relative mb-5", children: [
|
|
36804
|
+
/* @__PURE__ */ jsxs7("div", { className: "relative flex items-center border rounded bg-white", children: [
|
|
36852
36805
|
/* @__PURE__ */ jsx10(
|
|
36853
36806
|
"input",
|
|
36854
36807
|
{
|
|
36855
36808
|
autoComplete: "off",
|
|
36856
36809
|
ref: inputRef,
|
|
36857
36810
|
...props,
|
|
36858
|
-
className: [
|
|
36859
|
-
"p-2 w-full rounded border shadow",
|
|
36860
|
-
props == null ? void 0 : props.className
|
|
36861
|
-
].join(" "),
|
|
36811
|
+
className: ["p-2 w-full transparent", props == null ? void 0 : props.className].join(" "),
|
|
36862
36812
|
value: inputValue,
|
|
36863
36813
|
onBlur: (e) => {
|
|
36864
36814
|
setTimeout(() => {
|
|
@@ -36888,6 +36838,11 @@ function Select({
|
|
|
36888
36838
|
onKeyDown: handleKeyDown
|
|
36889
36839
|
}
|
|
36890
36840
|
),
|
|
36841
|
+
label && /* @__PURE__ */ jsxs7("label", { className: "absolute -top-2.5 left-2 text-xs font-bold bg-white px-1", children: [
|
|
36842
|
+
label,
|
|
36843
|
+
" ",
|
|
36844
|
+
(props == null ? void 0 : props.required) && /* @__PURE__ */ jsx10("span", { className: "text-red-500", children: "*" })
|
|
36845
|
+
] }),
|
|
36891
36846
|
!isOpen && /* @__PURE__ */ jsx10("div", { className: "absolute top-0 right-0 flex flex-col justify-center items-center px-2 py-2 font-bold", children: /* @__PURE__ */ jsx10(SelectIcon, {}) }),
|
|
36892
36847
|
isOpen && inputValue != "" && /* @__PURE__ */ jsx10(
|
|
36893
36848
|
"button",
|
|
@@ -36911,7 +36866,7 @@ function Select({
|
|
|
36911
36866
|
"div",
|
|
36912
36867
|
{
|
|
36913
36868
|
style: { zIndex: 9999999999 },
|
|
36914
|
-
className: `absolute w-full border rounded shadow bg-white z-10 max-h-100 overflow-y-auto ${openUpwards ? "bottom-full mb-1" : "mt-1"}`,
|
|
36869
|
+
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"}`,
|
|
36915
36870
|
children: filtered.map((opt, index) => /* @__PURE__ */ jsx10(
|
|
36916
36871
|
"div",
|
|
36917
36872
|
{
|
|
@@ -37118,13 +37073,6 @@ function PopupOverlay({
|
|
|
37118
37073
|
{
|
|
37119
37074
|
className: "fixed inset-0 flex items-center justify-center z-[1000] ",
|
|
37120
37075
|
style: { background: "rgba(15,23,42,0.45)", backdropFilter: "blur(2px)" },
|
|
37121
|
-
onClick: (e) => {
|
|
37122
|
-
var _a;
|
|
37123
|
-
if (e.target === e.currentTarget) {
|
|
37124
|
-
onClose(false);
|
|
37125
|
-
(_a = popup.onCancel) == null ? void 0 : _a.call(popup);
|
|
37126
|
-
}
|
|
37127
|
-
},
|
|
37128
37076
|
children: [
|
|
37129
37077
|
/* @__PURE__ */ jsx14("style", { children: `
|
|
37130
37078
|
@keyframes fadeInScale {
|