next-recomponents 2.0.34 → 2.0.36
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +23 -29
- package/dist/index.mjs +129 -135
- package/package.json +1 -1
- package/src/container/index.tsx +19 -15
- package/src/modal/index.tsx +12 -8
- package/src/pop/index.tsx +20 -10
package/dist/index.d.mts
CHANGED
|
@@ -235,7 +235,7 @@ declare function usePopup(): {
|
|
|
235
235
|
confirm: (message: string, color?: PopupColor) => Promise<boolean>;
|
|
236
236
|
prompt: (message: string, color?: PopupColor) => Promise<string | null>;
|
|
237
237
|
modal: (message: ReactNode, color?: PopupColor, icons?: boolean, full?: boolean) => Promise<void>;
|
|
238
|
-
PopupComponent:
|
|
238
|
+
PopupComponent: react_jsx_runtime.JSX.Element | null;
|
|
239
239
|
close: (confirmed: boolean, value?: string) => void;
|
|
240
240
|
updateMessage: (message: ReactNode) => void;
|
|
241
241
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -235,7 +235,7 @@ declare function usePopup(): {
|
|
|
235
235
|
confirm: (message: string, color?: PopupColor) => Promise<boolean>;
|
|
236
236
|
prompt: (message: string, color?: PopupColor) => Promise<string | null>;
|
|
237
237
|
modal: (message: ReactNode, color?: PopupColor, icons?: boolean, full?: boolean) => Promise<void>;
|
|
238
|
-
PopupComponent:
|
|
238
|
+
PopupComponent: react_jsx_runtime.JSX.Element | null;
|
|
239
239
|
close: (confirmed: boolean, value?: string) => void;
|
|
240
240
|
updateMessage: (message: ReactNode) => void;
|
|
241
241
|
};
|
package/dist/index.js
CHANGED
|
@@ -3668,19 +3668,8 @@ function Container({
|
|
|
3668
3668
|
expandedFooter = false,
|
|
3669
3669
|
expandedMenu = false
|
|
3670
3670
|
}) {
|
|
3671
|
-
const [isSidebarOpen, setIsSidebarOpen] = (0, import_react2.useState)(
|
|
3671
|
+
const [isSidebarOpen, setIsSidebarOpen] = (0, import_react2.useState)(false);
|
|
3672
3672
|
const [isFooterOpen, setIsFooterOpen] = (0, import_react2.useState)(expandedFooter);
|
|
3673
|
-
const handleClick = (state) => {
|
|
3674
|
-
window.localStorage.setItem("isSidebarOpen", JSON.stringify(state));
|
|
3675
|
-
};
|
|
3676
|
-
(0, import_react2.useEffect)(() => {
|
|
3677
|
-
if (typeof window !== "undefined") {
|
|
3678
|
-
const storedSidebarState = window.localStorage.getItem("isSidebarOpen");
|
|
3679
|
-
if (storedSidebarState && window.innerWidth >= 768) {
|
|
3680
|
-
setIsSidebarOpen(JSON.parse(storedSidebarState));
|
|
3681
|
-
}
|
|
3682
|
-
}
|
|
3683
|
-
}, []);
|
|
3684
3673
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col h-screen", children: [
|
|
3685
3674
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("header", { className: "", children: [
|
|
3686
3675
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "bg-blue-600 text-white p-4 flex justify-between items-center shadow-md", children: [
|
|
@@ -3689,7 +3678,6 @@ function Container({
|
|
|
3689
3678
|
{
|
|
3690
3679
|
onClick: () => {
|
|
3691
3680
|
setIsSidebarOpen(!isSidebarOpen);
|
|
3692
|
-
handleClick(!isSidebarOpen);
|
|
3693
3681
|
},
|
|
3694
3682
|
className: "bg-blue-600 text-white px-2 py-1 rounded-r",
|
|
3695
3683
|
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MenuIcon, {})
|
|
@@ -3728,6 +3716,10 @@ function Container({
|
|
|
3728
3716
|
className: `bg-blue-500 text-white overflow-y-auto fixed md:static top-0 left-0 h-full z-50 md:z-auto transition-all duration-300 ease-in-out
|
|
3729
3717
|
${isSidebarOpen ? "w-full md:w-[250px]" : "w-0 md:w-[60px]"}
|
|
3730
3718
|
`,
|
|
3719
|
+
onMouseEnter: (e) => {
|
|
3720
|
+
setIsSidebarOpen(true);
|
|
3721
|
+
},
|
|
3722
|
+
onMouseLeave: (e) => setIsSidebarOpen(false),
|
|
3731
3723
|
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "p-4 ", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("ul", { className: "space-y-3", children: [
|
|
3732
3724
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3733
3725
|
"li",
|
|
@@ -3735,7 +3727,6 @@ function Container({
|
|
|
3735
3727
|
className: "p-2 md:hidden flex items-center justify-between font-bold",
|
|
3736
3728
|
onClick: (e) => {
|
|
3737
3729
|
setIsSidebarOpen(false);
|
|
3738
|
-
handleClick(false);
|
|
3739
3730
|
},
|
|
3740
3731
|
children: [
|
|
3741
3732
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MenuIcon, {}),
|
|
@@ -3771,7 +3762,6 @@ function Container({
|
|
|
3771
3762
|
className: "fixed inset-0 bg-black bg-opacity-40 z-40",
|
|
3772
3763
|
onClick: () => {
|
|
3773
3764
|
setIsSidebarOpen(false);
|
|
3774
|
-
handleClick(false);
|
|
3775
3765
|
}
|
|
3776
3766
|
}
|
|
3777
3767
|
),
|
|
@@ -37268,17 +37258,14 @@ function usePopup() {
|
|
|
37268
37258
|
messageRef.current = message;
|
|
37269
37259
|
setPopup((prev) => ({ ...prev }));
|
|
37270
37260
|
}, []);
|
|
37271
|
-
const PopupComponent = (0,
|
|
37272
|
-
|
|
37273
|
-
|
|
37274
|
-
|
|
37275
|
-
|
|
37276
|
-
|
|
37277
|
-
|
|
37278
|
-
|
|
37279
|
-
}
|
|
37280
|
-
);
|
|
37281
|
-
}, [popup, close]);
|
|
37261
|
+
const PopupComponent = popup.visible ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
37262
|
+
PopupOverlay,
|
|
37263
|
+
{
|
|
37264
|
+
popup: { ...popup, message: messageRef.current },
|
|
37265
|
+
onClose: close,
|
|
37266
|
+
onInputChange: (v) => setPopup((prev) => ({ ...prev, inputValue: v }))
|
|
37267
|
+
}
|
|
37268
|
+
) : null;
|
|
37282
37269
|
return {
|
|
37283
37270
|
alert: alert2,
|
|
37284
37271
|
confirm,
|
|
@@ -37299,17 +37286,24 @@ function Modal({
|
|
|
37299
37286
|
title
|
|
37300
37287
|
}) {
|
|
37301
37288
|
const pop = usePopup();
|
|
37302
|
-
const hide = (
|
|
37289
|
+
const hide = () => pop.close(false);
|
|
37290
|
+
const childrenWithHide = (0, import_react11.useMemo)(
|
|
37291
|
+
() => (0, import_react11.cloneElement)(children, { hide }),
|
|
37292
|
+
[children]
|
|
37293
|
+
);
|
|
37294
|
+
(0, import_react11.useEffect)(() => {
|
|
37295
|
+
pop.updateMessage(childrenWithHide);
|
|
37296
|
+
}, [childrenWithHide]);
|
|
37303
37297
|
const props = button == null ? void 0 : button.props;
|
|
37304
37298
|
const onClick = props == null ? void 0 : props.onClick;
|
|
37305
37299
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
37306
37300
|
(0, import_react11.cloneElement)(button, {
|
|
37307
37301
|
onClick: (e) => {
|
|
37308
37302
|
onClick == null ? void 0 : onClick(e);
|
|
37309
|
-
pop.modal(
|
|
37303
|
+
pop.modal(childrenWithHide, color, false, true);
|
|
37310
37304
|
}
|
|
37311
37305
|
}),
|
|
37312
|
-
|
|
37306
|
+
pop.PopupComponent
|
|
37313
37307
|
] });
|
|
37314
37308
|
}
|
|
37315
37309
|
|
package/dist/index.mjs
CHANGED
|
@@ -3561,7 +3561,7 @@ function Button({
|
|
|
3561
3561
|
}
|
|
3562
3562
|
|
|
3563
3563
|
// src/container/index.tsx
|
|
3564
|
-
import {
|
|
3564
|
+
import { useState as useState2 } from "react";
|
|
3565
3565
|
|
|
3566
3566
|
// src/container/icons.tsx
|
|
3567
3567
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -3643,19 +3643,8 @@ function Container({
|
|
|
3643
3643
|
expandedFooter = false,
|
|
3644
3644
|
expandedMenu = false
|
|
3645
3645
|
}) {
|
|
3646
|
-
const [isSidebarOpen, setIsSidebarOpen] = useState2(
|
|
3646
|
+
const [isSidebarOpen, setIsSidebarOpen] = useState2(false);
|
|
3647
3647
|
const [isFooterOpen, setIsFooterOpen] = useState2(expandedFooter);
|
|
3648
|
-
const handleClick = (state) => {
|
|
3649
|
-
window.localStorage.setItem("isSidebarOpen", JSON.stringify(state));
|
|
3650
|
-
};
|
|
3651
|
-
useEffect(() => {
|
|
3652
|
-
if (typeof window !== "undefined") {
|
|
3653
|
-
const storedSidebarState = window.localStorage.getItem("isSidebarOpen");
|
|
3654
|
-
if (storedSidebarState && window.innerWidth >= 768) {
|
|
3655
|
-
setIsSidebarOpen(JSON.parse(storedSidebarState));
|
|
3656
|
-
}
|
|
3657
|
-
}
|
|
3658
|
-
}, []);
|
|
3659
3648
|
return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col h-screen", children: [
|
|
3660
3649
|
/* @__PURE__ */ jsxs2("header", { className: "", children: [
|
|
3661
3650
|
/* @__PURE__ */ jsxs2("div", { className: "bg-blue-600 text-white p-4 flex justify-between items-center shadow-md", children: [
|
|
@@ -3664,7 +3653,6 @@ function Container({
|
|
|
3664
3653
|
{
|
|
3665
3654
|
onClick: () => {
|
|
3666
3655
|
setIsSidebarOpen(!isSidebarOpen);
|
|
3667
|
-
handleClick(!isSidebarOpen);
|
|
3668
3656
|
},
|
|
3669
3657
|
className: "bg-blue-600 text-white px-2 py-1 rounded-r",
|
|
3670
3658
|
children: /* @__PURE__ */ jsx3(MenuIcon, {})
|
|
@@ -3703,6 +3691,10 @@ function Container({
|
|
|
3703
3691
|
className: `bg-blue-500 text-white overflow-y-auto fixed md:static top-0 left-0 h-full z-50 md:z-auto transition-all duration-300 ease-in-out
|
|
3704
3692
|
${isSidebarOpen ? "w-full md:w-[250px]" : "w-0 md:w-[60px]"}
|
|
3705
3693
|
`,
|
|
3694
|
+
onMouseEnter: (e) => {
|
|
3695
|
+
setIsSidebarOpen(true);
|
|
3696
|
+
},
|
|
3697
|
+
onMouseLeave: (e) => setIsSidebarOpen(false),
|
|
3706
3698
|
children: /* @__PURE__ */ jsx3("div", { className: "p-4 ", children: /* @__PURE__ */ jsxs2("ul", { className: "space-y-3", children: [
|
|
3707
3699
|
/* @__PURE__ */ jsxs2(
|
|
3708
3700
|
"li",
|
|
@@ -3710,7 +3702,6 @@ function Container({
|
|
|
3710
3702
|
className: "p-2 md:hidden flex items-center justify-between font-bold",
|
|
3711
3703
|
onClick: (e) => {
|
|
3712
3704
|
setIsSidebarOpen(false);
|
|
3713
|
-
handleClick(false);
|
|
3714
3705
|
},
|
|
3715
3706
|
children: [
|
|
3716
3707
|
/* @__PURE__ */ jsx3(MenuIcon, {}),
|
|
@@ -3746,7 +3737,6 @@ function Container({
|
|
|
3746
3737
|
className: "fixed inset-0 bg-black bg-opacity-40 z-40",
|
|
3747
3738
|
onClick: () => {
|
|
3748
3739
|
setIsSidebarOpen(false);
|
|
3749
|
-
handleClick(false);
|
|
3750
3740
|
}
|
|
3751
3741
|
}
|
|
3752
3742
|
),
|
|
@@ -36935,7 +36925,7 @@ function Select({
|
|
|
36935
36925
|
}
|
|
36936
36926
|
|
|
36937
36927
|
// src/modal/index.tsx
|
|
36938
|
-
import { cloneElement as cloneElement2,
|
|
36928
|
+
import { cloneElement as cloneElement2, useEffect as useEffect6, useMemo as useMemo4 } from "react";
|
|
36939
36929
|
|
|
36940
36930
|
// src/pop/index.tsx
|
|
36941
36931
|
import { useState as useState9, useCallback, useRef as useRef3 } from "react";
|
|
@@ -37254,17 +37244,14 @@ function usePopup() {
|
|
|
37254
37244
|
messageRef.current = message;
|
|
37255
37245
|
setPopup((prev) => ({ ...prev }));
|
|
37256
37246
|
}, []);
|
|
37257
|
-
const PopupComponent =
|
|
37258
|
-
|
|
37259
|
-
|
|
37260
|
-
|
|
37261
|
-
|
|
37262
|
-
|
|
37263
|
-
|
|
37264
|
-
|
|
37265
|
-
}
|
|
37266
|
-
);
|
|
37267
|
-
}, [popup, close]);
|
|
37247
|
+
const PopupComponent = popup.visible ? /* @__PURE__ */ jsx15(
|
|
37248
|
+
PopupOverlay,
|
|
37249
|
+
{
|
|
37250
|
+
popup: { ...popup, message: messageRef.current },
|
|
37251
|
+
onClose: close,
|
|
37252
|
+
onInputChange: (v) => setPopup((prev) => ({ ...prev, inputValue: v }))
|
|
37253
|
+
}
|
|
37254
|
+
) : null;
|
|
37268
37255
|
return {
|
|
37269
37256
|
alert: alert2,
|
|
37270
37257
|
confirm,
|
|
@@ -37277,7 +37264,7 @@ function usePopup() {
|
|
|
37277
37264
|
}
|
|
37278
37265
|
|
|
37279
37266
|
// src/modal/index.tsx
|
|
37280
|
-
import { Fragment as Fragment2,
|
|
37267
|
+
import { Fragment as Fragment2, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
37281
37268
|
function Modal({
|
|
37282
37269
|
button,
|
|
37283
37270
|
children,
|
|
@@ -37285,25 +37272,32 @@ function Modal({
|
|
|
37285
37272
|
title
|
|
37286
37273
|
}) {
|
|
37287
37274
|
const pop = usePopup();
|
|
37288
|
-
const hide =
|
|
37275
|
+
const hide = () => pop.close(false);
|
|
37276
|
+
const childrenWithHide = useMemo4(
|
|
37277
|
+
() => cloneElement2(children, { hide }),
|
|
37278
|
+
[children]
|
|
37279
|
+
);
|
|
37280
|
+
useEffect6(() => {
|
|
37281
|
+
pop.updateMessage(childrenWithHide);
|
|
37282
|
+
}, [childrenWithHide]);
|
|
37289
37283
|
const props = button == null ? void 0 : button.props;
|
|
37290
37284
|
const onClick = props == null ? void 0 : props.onClick;
|
|
37291
37285
|
return /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
37292
37286
|
cloneElement2(button, {
|
|
37293
37287
|
onClick: (e) => {
|
|
37294
37288
|
onClick == null ? void 0 : onClick(e);
|
|
37295
|
-
pop.modal(
|
|
37289
|
+
pop.modal(childrenWithHide, color, false, true);
|
|
37296
37290
|
}
|
|
37297
37291
|
}),
|
|
37298
|
-
|
|
37292
|
+
pop.PopupComponent
|
|
37299
37293
|
] });
|
|
37300
37294
|
}
|
|
37301
37295
|
|
|
37302
37296
|
// src/pre/index.tsx
|
|
37303
|
-
import { jsx as
|
|
37297
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
37304
37298
|
var Pre = ({ data }) => {
|
|
37305
37299
|
const formatted = JSON.stringify(data, null, 2);
|
|
37306
|
-
return /* @__PURE__ */
|
|
37300
|
+
return /* @__PURE__ */ jsx16(
|
|
37307
37301
|
"pre",
|
|
37308
37302
|
{
|
|
37309
37303
|
style: {
|
|
@@ -37354,9 +37348,9 @@ import {
|
|
|
37354
37348
|
import DatePicker from "react-datepicker";
|
|
37355
37349
|
|
|
37356
37350
|
// src/calendar/calendar.icon.tsx
|
|
37357
|
-
import { jsx as
|
|
37351
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
37358
37352
|
function CalendarIcon() {
|
|
37359
|
-
return /* @__PURE__ */
|
|
37353
|
+
return /* @__PURE__ */ jsx17(
|
|
37360
37354
|
"svg",
|
|
37361
37355
|
{
|
|
37362
37356
|
stroke: "currentColor",
|
|
@@ -37366,14 +37360,14 @@ function CalendarIcon() {
|
|
|
37366
37360
|
height: "20px",
|
|
37367
37361
|
width: "20px",
|
|
37368
37362
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37369
|
-
children: /* @__PURE__ */
|
|
37363
|
+
children: /* @__PURE__ */ jsx17("path", { d: "M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z" })
|
|
37370
37364
|
}
|
|
37371
37365
|
);
|
|
37372
37366
|
}
|
|
37373
37367
|
|
|
37374
37368
|
// src/calendar/index.tsx
|
|
37375
37369
|
import { Dialog as Dialog2 } from "@mui/material";
|
|
37376
|
-
import { jsx as
|
|
37370
|
+
import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
37377
37371
|
function MyCalendar({
|
|
37378
37372
|
enabledDates,
|
|
37379
37373
|
onChange,
|
|
@@ -37409,15 +37403,15 @@ function MyCalendar({
|
|
|
37409
37403
|
/* @__PURE__ */ jsxs11("div", { className: "font-bold", children: [
|
|
37410
37404
|
label,
|
|
37411
37405
|
" ",
|
|
37412
|
-
(otherProps == null ? void 0 : otherProps.required) && /* @__PURE__ */
|
|
37406
|
+
(otherProps == null ? void 0 : otherProps.required) && /* @__PURE__ */ jsx18("span", { className: "text-red-500", children: "*" })
|
|
37413
37407
|
] }),
|
|
37414
|
-
/* @__PURE__ */
|
|
37408
|
+
/* @__PURE__ */ jsx18("div", { children: /* @__PURE__ */ jsxs11(
|
|
37415
37409
|
"div",
|
|
37416
37410
|
{
|
|
37417
37411
|
className: "cursor-pointer flex items-center justify-center",
|
|
37418
37412
|
onClick: (e) => setOpen(true),
|
|
37419
37413
|
children: [
|
|
37420
|
-
/* @__PURE__ */
|
|
37414
|
+
/* @__PURE__ */ jsx18(
|
|
37421
37415
|
"input",
|
|
37422
37416
|
{
|
|
37423
37417
|
...otherProps,
|
|
@@ -37432,13 +37426,13 @@ function MyCalendar({
|
|
|
37432
37426
|
readOnly: true
|
|
37433
37427
|
}
|
|
37434
37428
|
),
|
|
37435
|
-
/* @__PURE__ */
|
|
37429
|
+
/* @__PURE__ */ jsx18("div", { className: "absolute", style: { right: "10px" }, children: /* @__PURE__ */ jsx18(CalendarIcon, {}) })
|
|
37436
37430
|
]
|
|
37437
37431
|
}
|
|
37438
37432
|
) })
|
|
37439
37433
|
] }),
|
|
37440
37434
|
/* @__PURE__ */ jsxs11(Dialog2, { open, children: [
|
|
37441
|
-
/* @__PURE__ */
|
|
37435
|
+
/* @__PURE__ */ jsx18("div", { className: "flex justify-end p-5 font-bold", children: /* @__PURE__ */ jsx18(
|
|
37442
37436
|
"button",
|
|
37443
37437
|
{
|
|
37444
37438
|
className: " border-lg w-[20px] bg-red-500 text-white shadow rounded",
|
|
@@ -37446,7 +37440,7 @@ function MyCalendar({
|
|
|
37446
37440
|
children: "x"
|
|
37447
37441
|
}
|
|
37448
37442
|
) }),
|
|
37449
|
-
/* @__PURE__ */
|
|
37443
|
+
/* @__PURE__ */ jsx18("div", { className: " w-[300px] flex items-start justify-center h-[300px] p-5", children: /* @__PURE__ */ jsx18(
|
|
37450
37444
|
DatePicker,
|
|
37451
37445
|
{
|
|
37452
37446
|
inline: true,
|
|
@@ -37460,9 +37454,9 @@ function MyCalendar({
|
|
|
37460
37454
|
}
|
|
37461
37455
|
|
|
37462
37456
|
// src/doc-viewer/icon.tsx
|
|
37463
|
-
import { jsx as
|
|
37457
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
37464
37458
|
function Icon() {
|
|
37465
|
-
return /* @__PURE__ */
|
|
37459
|
+
return /* @__PURE__ */ jsx19(
|
|
37466
37460
|
"svg",
|
|
37467
37461
|
{
|
|
37468
37462
|
stroke: "currentColor",
|
|
@@ -37472,13 +37466,13 @@ function Icon() {
|
|
|
37472
37466
|
height: "200px",
|
|
37473
37467
|
width: "200px",
|
|
37474
37468
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37475
|
-
children: /* @__PURE__ */
|
|
37469
|
+
children: /* @__PURE__ */ jsx19("path", { d: "M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40v88a6,6,0,0,0,12,0V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216a2,2,0,0,1-2,2H176a6,6,0,0,0,0,12h24a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM108,130a50,50,0,0,0-46.66,32H60a34,34,0,0,0,0,68h48a50,50,0,0,0,0-100Zm0,88H60a22,22,0,0,1-1.65-43.94c-.06.47-.1.93-.15,1.4a6,6,0,1,0,12,1.08A38.57,38.57,0,0,1,71.3,170a5.71,5.71,0,0,0,.24-.86A38,38,0,1,1,108,218Z" })
|
|
37476
37470
|
}
|
|
37477
37471
|
);
|
|
37478
37472
|
}
|
|
37479
37473
|
|
|
37480
37474
|
// src/doc-viewer/index.tsx
|
|
37481
|
-
import { jsx as
|
|
37475
|
+
import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
37482
37476
|
function DocumentViewer({ item }) {
|
|
37483
37477
|
const { url, name, contentType, width = "100%", height = "100%" } = item;
|
|
37484
37478
|
const isImage = contentType.startsWith("image/");
|
|
@@ -37489,8 +37483,8 @@ function DocumentViewer({ item }) {
|
|
|
37489
37483
|
)}&embedded=true` : url;
|
|
37490
37484
|
return /* @__PURE__ */ jsxs12("div", { className: "border shadow rounded p-2 h-[100%]", children: [
|
|
37491
37485
|
/* @__PURE__ */ jsxs12("div", { className: "mb-1 flex justify-between ", children: [
|
|
37492
|
-
/* @__PURE__ */
|
|
37493
|
-
/* @__PURE__ */
|
|
37486
|
+
/* @__PURE__ */ jsx20("h3", { className: "font-bold", children: name }),
|
|
37487
|
+
/* @__PURE__ */ jsx20(
|
|
37494
37488
|
"a",
|
|
37495
37489
|
{
|
|
37496
37490
|
href: url,
|
|
@@ -37502,7 +37496,7 @@ function DocumentViewer({ item }) {
|
|
|
37502
37496
|
}
|
|
37503
37497
|
)
|
|
37504
37498
|
] }),
|
|
37505
|
-
isImage ? /* @__PURE__ */
|
|
37499
|
+
isImage ? /* @__PURE__ */ jsx20(
|
|
37506
37500
|
"img",
|
|
37507
37501
|
{
|
|
37508
37502
|
src: url,
|
|
@@ -37515,7 +37509,7 @@ function DocumentViewer({ item }) {
|
|
|
37515
37509
|
display: "block"
|
|
37516
37510
|
}
|
|
37517
37511
|
}
|
|
37518
|
-
) : isGoogleDocCompatible ? /* @__PURE__ */
|
|
37512
|
+
) : isGoogleDocCompatible ? /* @__PURE__ */ jsx20(
|
|
37519
37513
|
"iframe",
|
|
37520
37514
|
{
|
|
37521
37515
|
title: name,
|
|
@@ -37523,7 +37517,7 @@ function DocumentViewer({ item }) {
|
|
|
37523
37517
|
style: { width, height, border: "none" },
|
|
37524
37518
|
allowFullScreen: true
|
|
37525
37519
|
}
|
|
37526
|
-
) : /* @__PURE__ */
|
|
37520
|
+
) : /* @__PURE__ */ jsx20(
|
|
37527
37521
|
"div",
|
|
37528
37522
|
{
|
|
37529
37523
|
style: {
|
|
@@ -37533,7 +37527,7 @@ function DocumentViewer({ item }) {
|
|
|
37533
37527
|
objectFit: "cover",
|
|
37534
37528
|
display: "block"
|
|
37535
37529
|
},
|
|
37536
|
-
children: /* @__PURE__ */
|
|
37530
|
+
children: /* @__PURE__ */ jsx20(Icon, {})
|
|
37537
37531
|
}
|
|
37538
37532
|
)
|
|
37539
37533
|
] });
|
|
@@ -37541,20 +37535,20 @@ function DocumentViewer({ item }) {
|
|
|
37541
37535
|
|
|
37542
37536
|
// src/table3/index.tsx
|
|
37543
37537
|
import React9, {
|
|
37544
|
-
useEffect as
|
|
37545
|
-
useMemo as
|
|
37538
|
+
useEffect as useEffect9,
|
|
37539
|
+
useMemo as useMemo7,
|
|
37546
37540
|
useReducer as useReducer2,
|
|
37547
37541
|
useRef as useRef5,
|
|
37548
37542
|
useState as useState13
|
|
37549
37543
|
} from "react";
|
|
37550
37544
|
|
|
37551
37545
|
// src/table3/filter.tsx
|
|
37552
|
-
import { useEffect as
|
|
37546
|
+
import { useEffect as useEffect8, useMemo as useMemo5, useState as useState11 } from "react";
|
|
37553
37547
|
|
|
37554
37548
|
// src/table3/filters.tsx
|
|
37555
|
-
import { jsx as
|
|
37549
|
+
import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
37556
37550
|
function FilterOffIcon() {
|
|
37557
|
-
return /* @__PURE__ */
|
|
37551
|
+
return /* @__PURE__ */ jsx21(
|
|
37558
37552
|
"svg",
|
|
37559
37553
|
{
|
|
37560
37554
|
stroke: "currentColor",
|
|
@@ -37564,12 +37558,12 @@ function FilterOffIcon() {
|
|
|
37564
37558
|
height: "20px",
|
|
37565
37559
|
width: "20px",
|
|
37566
37560
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37567
|
-
children: /* @__PURE__ */
|
|
37561
|
+
children: /* @__PURE__ */ jsx21("path", { d: "M6.92893 0.514648L21.0711 14.6568L19.6569 16.071L15.834 12.2486L14 14.9999V21.9999H10V14.9999L4 5.99993H3V3.99993L7.585 3.99965L5.51472 1.92886L6.92893 0.514648ZM21 3.99993V5.99993H20L18.085 8.87193L13.213 3.99993H21Z" })
|
|
37568
37562
|
}
|
|
37569
37563
|
);
|
|
37570
37564
|
}
|
|
37571
37565
|
function OrderDesc() {
|
|
37572
|
-
return /* @__PURE__ */
|
|
37566
|
+
return /* @__PURE__ */ jsx21(
|
|
37573
37567
|
"svg",
|
|
37574
37568
|
{
|
|
37575
37569
|
stroke: "currentColor",
|
|
@@ -37579,12 +37573,12 @@ function OrderDesc() {
|
|
|
37579
37573
|
height: "20px",
|
|
37580
37574
|
width: "20px",
|
|
37581
37575
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37582
|
-
children: /* @__PURE__ */
|
|
37576
|
+
children: /* @__PURE__ */ jsx21("path", { d: "M176 352h-48V48a16 16 0 0 0-16-16H80a16 16 0 0 0-16 16v304H16c-14.19 0-21.36 17.24-11.29 27.31l80 96a16 16 0 0 0 22.62 0l80-96C197.35 369.26 190.22 352 176 352zm112-128h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16h-56l61.26-70.45A32 32 0 0 0 432 65.63V48a16 16 0 0 0-16-16H288a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h56l-61.26 70.45A32 32 0 0 0 272 190.37V208a16 16 0 0 0 16 16zm159.06 234.62l-59.27-160A16 16 0 0 0 372.72 288h-41.44a16 16 0 0 0-15.07 10.62l-59.27 160A16 16 0 0 0 272 480h24.83a16 16 0 0 0 15.23-11.08l4.42-12.92h71l4.41 12.92A16 16 0 0 0 407.16 480H432a16 16 0 0 0 15.06-21.38zM335.61 400L352 352l16.39 48z" })
|
|
37583
37577
|
}
|
|
37584
37578
|
);
|
|
37585
37579
|
}
|
|
37586
37580
|
function OrderAsc() {
|
|
37587
|
-
return /* @__PURE__ */
|
|
37581
|
+
return /* @__PURE__ */ jsx21(
|
|
37588
37582
|
"svg",
|
|
37589
37583
|
{
|
|
37590
37584
|
stroke: "currentColor",
|
|
@@ -37594,12 +37588,12 @@ function OrderAsc() {
|
|
|
37594
37588
|
height: "20px",
|
|
37595
37589
|
width: "20px",
|
|
37596
37590
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37597
|
-
children: /* @__PURE__ */
|
|
37591
|
+
children: /* @__PURE__ */ jsx21("path", { d: "M176 352h-48V48a16 16 0 0 0-16-16H80a16 16 0 0 0-16 16v304H16c-14.19 0-21.36 17.24-11.29 27.31l80 96a16 16 0 0 0 22.62 0l80-96C197.35 369.26 190.22 352 176 352zm240-64H288a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h56l-61.26 70.45A32 32 0 0 0 272 446.37V464a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16h-56l61.26-70.45A32 32 0 0 0 432 321.63V304a16 16 0 0 0-16-16zm31.06-85.38l-59.27-160A16 16 0 0 0 372.72 32h-41.44a16 16 0 0 0-15.07 10.62l-59.27 160A16 16 0 0 0 272 224h24.83a16 16 0 0 0 15.23-11.08l4.42-12.92h71l4.41 12.92A16 16 0 0 0 407.16 224H432a16 16 0 0 0 15.06-21.38zM335.61 144L352 96l16.39 48z" })
|
|
37598
37592
|
}
|
|
37599
37593
|
);
|
|
37600
37594
|
}
|
|
37601
37595
|
function EditIcon2() {
|
|
37602
|
-
return /* @__PURE__ */
|
|
37596
|
+
return /* @__PURE__ */ jsx21(
|
|
37603
37597
|
"svg",
|
|
37604
37598
|
{
|
|
37605
37599
|
stroke: "currentColor",
|
|
@@ -37609,7 +37603,7 @@ function EditIcon2() {
|
|
|
37609
37603
|
height: "20px",
|
|
37610
37604
|
width: "20px",
|
|
37611
37605
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37612
|
-
children: /* @__PURE__ */
|
|
37606
|
+
children: /* @__PURE__ */ jsx21("path", { d: "M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z" })
|
|
37613
37607
|
}
|
|
37614
37608
|
);
|
|
37615
37609
|
}
|
|
@@ -37625,14 +37619,14 @@ function SaveIcon() {
|
|
|
37625
37619
|
width: "20px",
|
|
37626
37620
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37627
37621
|
children: [
|
|
37628
|
-
/* @__PURE__ */
|
|
37629
|
-
/* @__PURE__ */
|
|
37622
|
+
/* @__PURE__ */ jsx21("path", { d: "M272 64h-16c-4.4 0-8 3.6-8 8v72c0 4.4 7.6 8 12 8h12c4.4 0 8-3.6 8-8V72c0-4.4-3.6-8-8-8z" }),
|
|
37623
|
+
/* @__PURE__ */ jsx21("path", { d: "M433.9 130.1L382 78.2c-9-9-21.3-14.2-34.1-14.2h-28c-8.8 0-16 7.3-16 16.2v80c0 8.8-7.2 16-16 16H160c-8.8 0-16-7.2-16-16v-80c0-8.8-7.2-16.2-16-16.2H96c-17.6 0-32 14.4-32 32v320c0 17.6 14.4 32 32 32h320c17.6 0 32-14.4 32-32V164c0-12.7-5.1-24.9-14.1-33.9zM322 400.1c0 8.8-8 16-17.8 16H143.8c-9.8 0-17.8-7.2-17.8-16v-96c0-8.8 8-16 17.8-16h160.4c9.8 0 17.8 7.2 17.8 16v96z" })
|
|
37630
37624
|
]
|
|
37631
37625
|
}
|
|
37632
37626
|
);
|
|
37633
37627
|
}
|
|
37634
37628
|
function ExcelIcon() {
|
|
37635
|
-
return /* @__PURE__ */
|
|
37629
|
+
return /* @__PURE__ */ jsx21(
|
|
37636
37630
|
"svg",
|
|
37637
37631
|
{
|
|
37638
37632
|
stroke: "currentColor",
|
|
@@ -37642,13 +37636,13 @@ function ExcelIcon() {
|
|
|
37642
37636
|
height: "20px",
|
|
37643
37637
|
width: "20px",
|
|
37644
37638
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37645
|
-
children: /* @__PURE__ */
|
|
37639
|
+
children: /* @__PURE__ */ jsx21("path", { d: "M2.85858 2.87732L15.4293 1.0815C15.7027 1.04245 15.9559 1.2324 15.995 1.50577C15.9983 1.52919 16 1.55282 16 1.57648V22.4235C16 22.6996 15.7761 22.9235 15.5 22.9235C15.4763 22.9235 15.4527 22.9218 15.4293 22.9184L2.85858 21.1226C2.36593 21.0522 2 20.6303 2 20.1327V3.86727C2 3.36962 2.36593 2.9477 2.85858 2.87732ZM17 2.99997H21C21.5523 2.99997 22 3.44769 22 3.99997V20C22 20.5523 21.5523 21 21 21H17V2.99997ZM10.2 12L13 7.99997H10.6L9 10.2857L7.39999 7.99997H5L7.8 12L5 16H7.39999L9 13.7143L10.6 16H13L10.2 12Z" })
|
|
37646
37640
|
}
|
|
37647
37641
|
);
|
|
37648
37642
|
}
|
|
37649
37643
|
|
|
37650
37644
|
// src/table3/filter.tsx
|
|
37651
|
-
import { jsx as
|
|
37645
|
+
import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
37652
37646
|
function Filter({
|
|
37653
37647
|
h,
|
|
37654
37648
|
objectData,
|
|
@@ -37661,12 +37655,12 @@ function Filter({
|
|
|
37661
37655
|
}) {
|
|
37662
37656
|
const [visible, setVisible] = useState11(false);
|
|
37663
37657
|
const [text, setText] = useState11("");
|
|
37664
|
-
const items =
|
|
37658
|
+
const items = useMemo5(
|
|
37665
37659
|
() => [...new Set(Object.values(objectData).map((o) => o[h]))],
|
|
37666
37660
|
[objectData]
|
|
37667
37661
|
);
|
|
37668
37662
|
const [selected, setSelected] = useState11(items);
|
|
37669
|
-
const itemsFiltered =
|
|
37663
|
+
const itemsFiltered = useMemo5(
|
|
37670
37664
|
() => items.sort((a, b) => `${a}`.localeCompare(b)).filter((item) => {
|
|
37671
37665
|
if (!text) return true;
|
|
37672
37666
|
return `${item}`.toLowerCase().includes(text.toLowerCase());
|
|
@@ -37703,14 +37697,14 @@ function Filter({
|
|
|
37703
37697
|
const hidden = Object.values(objectData).filter(
|
|
37704
37698
|
(d) => d._visible === false
|
|
37705
37699
|
);
|
|
37706
|
-
|
|
37700
|
+
useEffect8(() => {
|
|
37707
37701
|
if (data.length != Object.values(objectData).map((o) => (o == null ? void 0 : o._id) || (o == null ? void 0 : o.id)).length) {
|
|
37708
37702
|
const news = [...new Set(data.map((o) => o[h]))];
|
|
37709
37703
|
setSelected(news);
|
|
37710
37704
|
}
|
|
37711
37705
|
}, [data]);
|
|
37712
37706
|
return /* @__PURE__ */ jsxs14("th", { className: "cursor-pointer", children: [
|
|
37713
|
-
/* @__PURE__ */
|
|
37707
|
+
/* @__PURE__ */ jsx22("div", { className: "relative", children: visible && /* @__PURE__ */ jsx22(
|
|
37714
37708
|
"div",
|
|
37715
37709
|
{
|
|
37716
37710
|
className: " w-full h-screen top-0 left-0 fixed ",
|
|
@@ -37731,13 +37725,13 @@ function Filter({
|
|
|
37731
37725
|
onClick: (e) => setVisible(!visible),
|
|
37732
37726
|
children: [
|
|
37733
37727
|
sort && //
|
|
37734
|
-
Object.keys(sort)[0] == h && ((sort == null ? void 0 : sort[h]) == "asc" ? /* @__PURE__ */
|
|
37735
|
-
/* @__PURE__ */
|
|
37736
|
-
selected.length < items.length && /* @__PURE__ */
|
|
37728
|
+
Object.keys(sort)[0] == h && ((sort == null ? void 0 : sort[h]) == "asc" ? /* @__PURE__ */ jsx22("div", { className: "text-green-300", children: /* @__PURE__ */ jsx22(OrderAsc, {}) }) : (sort == null ? void 0 : sort[h]) == "desc" && /* @__PURE__ */ jsx22("div", { className: "text-green-300", children: /* @__PURE__ */ jsx22(OrderDesc, {}) })),
|
|
37729
|
+
/* @__PURE__ */ jsx22("div", { children: h }),
|
|
37730
|
+
selected.length < items.length && /* @__PURE__ */ jsx22("div", { className: "text-red-500 ", children: /* @__PURE__ */ jsx22(FilterOffIcon, {}) })
|
|
37737
37731
|
]
|
|
37738
37732
|
}
|
|
37739
37733
|
),
|
|
37740
|
-
visible && /* @__PURE__ */
|
|
37734
|
+
visible && /* @__PURE__ */ jsx22(
|
|
37741
37735
|
"div",
|
|
37742
37736
|
{
|
|
37743
37737
|
className: "border shadow rounded bg-white p-1 absolute left-0 text-black",
|
|
@@ -37760,7 +37754,7 @@ function Filter({
|
|
|
37760
37754
|
},
|
|
37761
37755
|
className: "flex items-center gap-2 border p-1 hover:bg-blue-100",
|
|
37762
37756
|
children: [
|
|
37763
|
-
/* @__PURE__ */
|
|
37757
|
+
/* @__PURE__ */ jsx22(OrderAsc, {}),
|
|
37764
37758
|
" Ordenar de la A a la Z"
|
|
37765
37759
|
]
|
|
37766
37760
|
}
|
|
@@ -37782,7 +37776,7 @@ function Filter({
|
|
|
37782
37776
|
},
|
|
37783
37777
|
className: "flex items-center gap-2 border p-1 hover:bg-blue-100",
|
|
37784
37778
|
children: [
|
|
37785
|
-
/* @__PURE__ */
|
|
37779
|
+
/* @__PURE__ */ jsx22(OrderDesc, {}),
|
|
37786
37780
|
"Ordenar de la Z a la A"
|
|
37787
37781
|
]
|
|
37788
37782
|
}
|
|
@@ -37796,11 +37790,11 @@ function Filter({
|
|
|
37796
37790
|
},
|
|
37797
37791
|
children: [
|
|
37798
37792
|
"Borrar Filtro",
|
|
37799
|
-
/* @__PURE__ */
|
|
37793
|
+
/* @__PURE__ */ jsx22("div", { className: "text-white ", children: /* @__PURE__ */ jsx22(FilterOffIcon, {}) })
|
|
37800
37794
|
]
|
|
37801
37795
|
}
|
|
37802
37796
|
),
|
|
37803
|
-
/* @__PURE__ */
|
|
37797
|
+
/* @__PURE__ */ jsx22("div", { className: "", children: /* @__PURE__ */ jsx22(
|
|
37804
37798
|
"input",
|
|
37805
37799
|
{
|
|
37806
37800
|
className: "border shadow rounded p-2 w-full",
|
|
@@ -37819,8 +37813,8 @@ function Filter({
|
|
|
37819
37813
|
}
|
|
37820
37814
|
}
|
|
37821
37815
|
) }),
|
|
37822
|
-
/* @__PURE__ */
|
|
37823
|
-
/* @__PURE__ */
|
|
37816
|
+
/* @__PURE__ */ jsx22("div", { children: /* @__PURE__ */ jsxs14("label", { className: "flex gap-1 cursor-pointer px-1", children: [
|
|
37817
|
+
/* @__PURE__ */ jsx22(
|
|
37824
37818
|
"input",
|
|
37825
37819
|
{
|
|
37826
37820
|
type: "checkbox",
|
|
@@ -37836,9 +37830,9 @@ function Filter({
|
|
|
37836
37830
|
),
|
|
37837
37831
|
"(Seleccionar Todo)"
|
|
37838
37832
|
] }) }),
|
|
37839
|
-
/* @__PURE__ */
|
|
37840
|
-
return /* @__PURE__ */
|
|
37841
|
-
/* @__PURE__ */
|
|
37833
|
+
/* @__PURE__ */ jsx22("div", { className: "overflow-auto flex gap-1 flex-col p-1 border shadow rounded h-[300px]", children: itemsFiltered.map((item) => {
|
|
37834
|
+
return /* @__PURE__ */ jsx22("div", { className: "hover:bg-gray-100 ", children: /* @__PURE__ */ jsxs14("label", { className: "flex gap-1 cursor-pointer truncate", children: [
|
|
37835
|
+
/* @__PURE__ */ jsx22(
|
|
37842
37836
|
"input",
|
|
37843
37837
|
{
|
|
37844
37838
|
type: "checkbox",
|
|
@@ -37860,7 +37854,7 @@ function Filter({
|
|
|
37860
37854
|
] }) }, item);
|
|
37861
37855
|
}) }),
|
|
37862
37856
|
/* @__PURE__ */ jsxs14("div", { className: "flex justify-between px-1", children: [
|
|
37863
|
-
/* @__PURE__ */
|
|
37857
|
+
/* @__PURE__ */ jsx22(
|
|
37864
37858
|
"button",
|
|
37865
37859
|
{
|
|
37866
37860
|
className: "p-1 shadow rounded border bg-red-500 text-white",
|
|
@@ -37871,7 +37865,7 @@ function Filter({
|
|
|
37871
37865
|
children: "Cancelar"
|
|
37872
37866
|
}
|
|
37873
37867
|
),
|
|
37874
|
-
/* @__PURE__ */
|
|
37868
|
+
/* @__PURE__ */ jsx22(
|
|
37875
37869
|
"button",
|
|
37876
37870
|
{
|
|
37877
37871
|
className: "p-1 shadow rounded border bg-blue-500 text-white",
|
|
@@ -37890,7 +37884,7 @@ function Filter({
|
|
|
37890
37884
|
}
|
|
37891
37885
|
|
|
37892
37886
|
// src/table3/head.tsx
|
|
37893
|
-
import { jsx as
|
|
37887
|
+
import { jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
37894
37888
|
function TableHead({
|
|
37895
37889
|
headers,
|
|
37896
37890
|
selectItems,
|
|
@@ -37905,9 +37899,9 @@ function TableHead({
|
|
|
37905
37899
|
sort,
|
|
37906
37900
|
setSort
|
|
37907
37901
|
}) {
|
|
37908
|
-
return /* @__PURE__ */
|
|
37909
|
-
modal && /* @__PURE__ */
|
|
37910
|
-
selectItems && /* @__PURE__ */
|
|
37902
|
+
return /* @__PURE__ */ jsx23("thead", { children: /* @__PURE__ */ jsxs15("tr", { className: "bg-blue-500 text-white font-bold", children: [
|
|
37903
|
+
modal && /* @__PURE__ */ jsx23("th", { children: "-" }),
|
|
37904
|
+
selectItems && /* @__PURE__ */ jsx23("th", { children: /* @__PURE__ */ jsx23(
|
|
37911
37905
|
"input",
|
|
37912
37906
|
{
|
|
37913
37907
|
className: "m-2",
|
|
@@ -37935,7 +37929,7 @@ function TableHead({
|
|
|
37935
37929
|
) }),
|
|
37936
37930
|
Object.values(headers).map((h) => {
|
|
37937
37931
|
if (h.startsWith("_")) return null;
|
|
37938
|
-
return /* @__PURE__ */
|
|
37932
|
+
return /* @__PURE__ */ jsx23(
|
|
37939
37933
|
Filter,
|
|
37940
37934
|
{
|
|
37941
37935
|
objectData,
|
|
@@ -37958,7 +37952,7 @@ import { useState as useState12 } from "react";
|
|
|
37958
37952
|
|
|
37959
37953
|
// src/table3/tr.tsx
|
|
37960
37954
|
import React7 from "react";
|
|
37961
|
-
import { jsx as
|
|
37955
|
+
import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
37962
37956
|
function TR({
|
|
37963
37957
|
handlers,
|
|
37964
37958
|
setObjectData,
|
|
@@ -37986,7 +37980,7 @@ function TR({
|
|
|
37986
37980
|
setSelected(selected == index ? -1 : index);
|
|
37987
37981
|
},
|
|
37988
37982
|
children: [
|
|
37989
|
-
modal && /* @__PURE__ */
|
|
37983
|
+
modal && /* @__PURE__ */ jsx24("th", { className: "border", children: /* @__PURE__ */ jsx24(
|
|
37990
37984
|
"button",
|
|
37991
37985
|
{
|
|
37992
37986
|
className: "p-1 border shadow-rounded bg-blue-500 rounded text-white",
|
|
@@ -37995,10 +37989,10 @@ function TR({
|
|
|
37995
37989
|
(_a = modalRef.current) == null ? void 0 : _a.showModal();
|
|
37996
37990
|
setDialogRow(row);
|
|
37997
37991
|
},
|
|
37998
|
-
children: /* @__PURE__ */
|
|
37992
|
+
children: /* @__PURE__ */ jsx24(EditIcon2, {})
|
|
37999
37993
|
}
|
|
38000
37994
|
) }),
|
|
38001
|
-
selectItems && /* @__PURE__ */
|
|
37995
|
+
selectItems && /* @__PURE__ */ jsx24("th", { className: "border", children: /* @__PURE__ */ jsx24(
|
|
38002
37996
|
"input",
|
|
38003
37997
|
{
|
|
38004
37998
|
type: "checkbox",
|
|
@@ -38066,13 +38060,13 @@ function TR({
|
|
|
38066
38060
|
return acc;
|
|
38067
38061
|
}, {})
|
|
38068
38062
|
});
|
|
38069
|
-
return /* @__PURE__ */
|
|
38063
|
+
return /* @__PURE__ */ jsx24("td", { className: `text-black `, children: cloned }, h);
|
|
38070
38064
|
}
|
|
38071
|
-
return symbols && (symbols == null ? void 0 : symbols[h]) ? /* @__PURE__ */
|
|
38065
|
+
return symbols && (symbols == null ? void 0 : symbols[h]) ? /* @__PURE__ */ jsx24("td", { className: `text-center border max-w-[${colSize}px] `, children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1 w-full", children: [
|
|
38072
38066
|
symbols[h],
|
|
38073
38067
|
" ",
|
|
38074
38068
|
row[h]
|
|
38075
|
-
] }) }, h) : /* @__PURE__ */
|
|
38069
|
+
] }) }, h) : /* @__PURE__ */ jsx24("td", { className: `text-center border max-w-[${colSize}px]`, children: row[h] }, h);
|
|
38076
38070
|
})
|
|
38077
38071
|
]
|
|
38078
38072
|
},
|
|
@@ -38081,7 +38075,7 @@ function TR({
|
|
|
38081
38075
|
}
|
|
38082
38076
|
|
|
38083
38077
|
// src/table3/body.tsx
|
|
38084
|
-
import { jsx as
|
|
38078
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
38085
38079
|
function TableBody({
|
|
38086
38080
|
objectData,
|
|
38087
38081
|
setObjectData,
|
|
@@ -38125,7 +38119,7 @@ function TableBody({
|
|
|
38125
38119
|
return key >= start && key < end;
|
|
38126
38120
|
}).map(([id, k], index) => {
|
|
38127
38121
|
const row = objectData[id];
|
|
38128
|
-
return /* @__PURE__ */
|
|
38122
|
+
return /* @__PURE__ */ jsx25(
|
|
38129
38123
|
TR,
|
|
38130
38124
|
{
|
|
38131
38125
|
...{
|
|
@@ -38150,11 +38144,11 @@ function TableBody({
|
|
|
38150
38144
|
id
|
|
38151
38145
|
);
|
|
38152
38146
|
});
|
|
38153
|
-
return /* @__PURE__ */
|
|
38147
|
+
return /* @__PURE__ */ jsx25("tbody", { children: sorted });
|
|
38154
38148
|
}
|
|
38155
38149
|
|
|
38156
38150
|
// src/table3/panel.tsx
|
|
38157
|
-
import { jsx as
|
|
38151
|
+
import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
38158
38152
|
function Panel({
|
|
38159
38153
|
page,
|
|
38160
38154
|
setPage,
|
|
@@ -38176,7 +38170,7 @@ function Panel({
|
|
|
38176
38170
|
},
|
|
38177
38171
|
children: [
|
|
38178
38172
|
" ",
|
|
38179
|
-
/* @__PURE__ */
|
|
38173
|
+
/* @__PURE__ */ jsx26(SaveIcon, {}),
|
|
38180
38174
|
"Guardar"
|
|
38181
38175
|
]
|
|
38182
38176
|
}
|
|
@@ -38195,22 +38189,22 @@ function Panel({
|
|
|
38195
38189
|
);
|
|
38196
38190
|
},
|
|
38197
38191
|
children: [
|
|
38198
|
-
/* @__PURE__ */
|
|
38192
|
+
/* @__PURE__ */ jsx26(ExcelIcon, {}),
|
|
38199
38193
|
"Exportar"
|
|
38200
38194
|
]
|
|
38201
38195
|
}
|
|
38202
38196
|
)
|
|
38203
38197
|
] }),
|
|
38204
38198
|
maxItems !== Infinity && /* @__PURE__ */ jsxs17("div", { className: "flex gap-2 items-center text-2xl", children: [
|
|
38205
|
-
/* @__PURE__ */
|
|
38206
|
-
/* @__PURE__ */
|
|
38199
|
+
/* @__PURE__ */ jsx26("button", { onClick: () => setPage(1), disabled: page === 1, children: "\u23EE" }),
|
|
38200
|
+
/* @__PURE__ */ jsx26("button", { onClick: () => setPage(page - 1), disabled: page === 1, children: "\u25C0" }),
|
|
38207
38201
|
/* @__PURE__ */ jsxs17("span", { className: "text-sm", children: [
|
|
38208
38202
|
"P\xE1gina ",
|
|
38209
38203
|
page,
|
|
38210
38204
|
" / ",
|
|
38211
38205
|
totalPages
|
|
38212
38206
|
] }),
|
|
38213
|
-
/* @__PURE__ */
|
|
38207
|
+
/* @__PURE__ */ jsx26(
|
|
38214
38208
|
"button",
|
|
38215
38209
|
{
|
|
38216
38210
|
onClick: () => setPage(page + 1),
|
|
@@ -38218,7 +38212,7 @@ function Panel({
|
|
|
38218
38212
|
children: "\u25B6"
|
|
38219
38213
|
}
|
|
38220
38214
|
),
|
|
38221
|
-
/* @__PURE__ */
|
|
38215
|
+
/* @__PURE__ */ jsx26(
|
|
38222
38216
|
"button",
|
|
38223
38217
|
{
|
|
38224
38218
|
onClick: () => setPage(totalPages),
|
|
@@ -38231,7 +38225,7 @@ function Panel({
|
|
|
38231
38225
|
}
|
|
38232
38226
|
|
|
38233
38227
|
// src/table3/footer.tsx
|
|
38234
|
-
import { jsx as
|
|
38228
|
+
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
38235
38229
|
function TableFooter({
|
|
38236
38230
|
objectData,
|
|
38237
38231
|
headers,
|
|
@@ -38256,9 +38250,9 @@ function TableFooter({
|
|
|
38256
38250
|
return null;
|
|
38257
38251
|
}
|
|
38258
38252
|
}
|
|
38259
|
-
return footer && /* @__PURE__ */
|
|
38260
|
-
selectItems && /* @__PURE__ */
|
|
38261
|
-
modal && /* @__PURE__ */
|
|
38253
|
+
return footer && /* @__PURE__ */ jsx27("tfoot", { children: /* @__PURE__ */ jsxs18("tr", { className: "bg-blue-500 text-white", children: [
|
|
38254
|
+
selectItems && /* @__PURE__ */ jsx27("th", {}),
|
|
38255
|
+
modal && /* @__PURE__ */ jsx27("th", {}),
|
|
38262
38256
|
headers.map((header) => {
|
|
38263
38257
|
if (header.startsWith("_")) {
|
|
38264
38258
|
return null;
|
|
@@ -38267,16 +38261,16 @@ function TableFooter({
|
|
|
38267
38261
|
symbols[header],
|
|
38268
38262
|
" ",
|
|
38269
38263
|
operacion(footer[header], header)
|
|
38270
|
-
] }, header) : /* @__PURE__ */
|
|
38264
|
+
] }, header) : /* @__PURE__ */ jsx27("th", { children: operacion(footer[header], header) }, header);
|
|
38271
38265
|
}
|
|
38272
|
-
return /* @__PURE__ */
|
|
38266
|
+
return /* @__PURE__ */ jsx27("th", {}, header);
|
|
38273
38267
|
})
|
|
38274
38268
|
] }) });
|
|
38275
38269
|
}
|
|
38276
38270
|
|
|
38277
38271
|
// src/table3/dialog.tsx
|
|
38278
|
-
import React8, { useMemo as
|
|
38279
|
-
import { jsx as
|
|
38272
|
+
import React8, { useMemo as useMemo6 } from "react";
|
|
38273
|
+
import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
38280
38274
|
function Dialog3({
|
|
38281
38275
|
modalRef,
|
|
38282
38276
|
children,
|
|
@@ -38292,7 +38286,7 @@ function Dialog3({
|
|
|
38292
38286
|
var _a;
|
|
38293
38287
|
return (_a = modalRef.current) == null ? void 0 : _a.close();
|
|
38294
38288
|
};
|
|
38295
|
-
const clonedModal =
|
|
38289
|
+
const clonedModal = useMemo6(() => {
|
|
38296
38290
|
if (dialogRow && React8.isValidElement(children)) {
|
|
38297
38291
|
return React8.cloneElement(children, {
|
|
38298
38292
|
key: JSON.stringify(dialogRow),
|
|
@@ -38311,8 +38305,8 @@ function Dialog3({
|
|
|
38311
38305
|
className: "p-6 rounded-xl shadow-2xl backdrop:bg-black/50 w-[100%] h-screen",
|
|
38312
38306
|
children: [
|
|
38313
38307
|
/* @__PURE__ */ jsxs19("div", { className: "flex justify-between items-center mb-4", children: [
|
|
38314
|
-
/* @__PURE__ */
|
|
38315
|
-
/* @__PURE__ */
|
|
38308
|
+
/* @__PURE__ */ jsx28("div", {}),
|
|
38309
|
+
/* @__PURE__ */ jsx28(
|
|
38316
38310
|
"button",
|
|
38317
38311
|
{
|
|
38318
38312
|
onClick: () => {
|
|
@@ -38324,7 +38318,7 @@ function Dialog3({
|
|
|
38324
38318
|
}
|
|
38325
38319
|
)
|
|
38326
38320
|
] }),
|
|
38327
|
-
/* @__PURE__ */
|
|
38321
|
+
/* @__PURE__ */ jsx28("div", { className: "text-gray-700", children: clonedModal })
|
|
38328
38322
|
]
|
|
38329
38323
|
}
|
|
38330
38324
|
);
|
|
@@ -38332,7 +38326,7 @@ function Dialog3({
|
|
|
38332
38326
|
var dialog_default = Dialog3;
|
|
38333
38327
|
|
|
38334
38328
|
// src/table3/index.tsx
|
|
38335
|
-
import { jsx as
|
|
38329
|
+
import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
38336
38330
|
function Table3({
|
|
38337
38331
|
data,
|
|
38338
38332
|
selectItems,
|
|
@@ -38391,11 +38385,11 @@ function Table3({
|
|
|
38391
38385
|
}
|
|
38392
38386
|
}
|
|
38393
38387
|
const [objectData, setObjectData] = useReducer2(dataReducer, null);
|
|
38394
|
-
|
|
38388
|
+
useEffect9(() => {
|
|
38395
38389
|
setObjectData(data);
|
|
38396
38390
|
setPage(1);
|
|
38397
38391
|
}, [data]);
|
|
38398
|
-
const headers =
|
|
38392
|
+
const headers = useMemo7(() => {
|
|
38399
38393
|
if (!objectData) return [];
|
|
38400
38394
|
return [
|
|
38401
38395
|
...new Set(
|
|
@@ -38403,7 +38397,7 @@ function Table3({
|
|
|
38403
38397
|
)
|
|
38404
38398
|
];
|
|
38405
38399
|
}, [objectData]);
|
|
38406
|
-
const totalPages =
|
|
38400
|
+
const totalPages = useMemo7(() => {
|
|
38407
38401
|
if (!objectData) return 0;
|
|
38408
38402
|
return maxItems ? Math.ceil(Object.keys(objectData).length / maxItems) : 1;
|
|
38409
38403
|
}, [objectData, maxItems]);
|
|
@@ -38436,7 +38430,7 @@ function Table3({
|
|
|
38436
38430
|
setSort,
|
|
38437
38431
|
...props
|
|
38438
38432
|
};
|
|
38439
|
-
|
|
38433
|
+
useEffect9(() => {
|
|
38440
38434
|
if ((dialogRow == null ? void 0 : dialogRow.id) || (dialogRow == null ? void 0 : dialogRow._id)) {
|
|
38441
38435
|
const newDialogRow = objectData[dialogRow == null ? void 0 : dialogRow.id] || objectData[dialogRow == null ? void 0 : dialogRow._id];
|
|
38442
38436
|
setDialogRow(newDialogRow);
|
|
@@ -38445,7 +38439,7 @@ function Table3({
|
|
|
38445
38439
|
const style = (props == null ? void 0 : props.style) ? { ...props.style, tableLayout: "fixed" } : { tableLayout: "fixed" };
|
|
38446
38440
|
if (!objectData) return null;
|
|
38447
38441
|
return /* @__PURE__ */ jsxs20("div", { className: "border shadow rounded m-1 p-1 bg-white", children: [
|
|
38448
|
-
modal && /* @__PURE__ */
|
|
38442
|
+
modal && /* @__PURE__ */ jsx29(
|
|
38449
38443
|
dialog_default,
|
|
38450
38444
|
{
|
|
38451
38445
|
modalRef,
|
|
@@ -38455,12 +38449,12 @@ function Table3({
|
|
|
38455
38449
|
children: modal
|
|
38456
38450
|
}
|
|
38457
38451
|
),
|
|
38458
|
-
header && /* @__PURE__ */
|
|
38459
|
-
/* @__PURE__ */
|
|
38452
|
+
header && /* @__PURE__ */ jsx29("div", { className: "font-bold text-2xl py-5 px-2 bg-blue-50", children: header }),
|
|
38453
|
+
/* @__PURE__ */ jsx29(Panel, { ...context }),
|
|
38460
38454
|
/* @__PURE__ */ jsxs20("table", { ...props, style, children: [
|
|
38461
|
-
/* @__PURE__ */
|
|
38462
|
-
/* @__PURE__ */
|
|
38463
|
-
/* @__PURE__ */
|
|
38455
|
+
/* @__PURE__ */ jsx29(TableHead, { ...context }),
|
|
38456
|
+
/* @__PURE__ */ jsx29(TableBody, { ...context }),
|
|
38457
|
+
/* @__PURE__ */ jsx29(TableFooter, { ...context })
|
|
38464
38458
|
] })
|
|
38465
38459
|
] });
|
|
38466
38460
|
}
|
package/package.json
CHANGED
package/src/container/index.tsx
CHANGED
|
@@ -26,19 +26,19 @@ export default function Container({
|
|
|
26
26
|
expandedMenu?: boolean;
|
|
27
27
|
expandedFooter?: boolean;
|
|
28
28
|
}) {
|
|
29
|
-
const [isSidebarOpen, setIsSidebarOpen] = useState(
|
|
29
|
+
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
|
|
30
30
|
const [isFooterOpen, setIsFooterOpen] = useState(expandedFooter);
|
|
31
|
-
const handleClick = (state: boolean) => {
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}, []);
|
|
31
|
+
// const handleClick = (state: boolean) => {
|
|
32
|
+
// window.localStorage.setItem("isSidebarOpen", JSON.stringify(state));
|
|
33
|
+
// };
|
|
34
|
+
// useEffect(() => {
|
|
35
|
+
// if (typeof window !== "undefined") {
|
|
36
|
+
// const storedSidebarState = window.localStorage.getItem("isSidebarOpen");
|
|
37
|
+
// if (storedSidebarState && window.innerWidth >= 768) {
|
|
38
|
+
// setIsSidebarOpen(JSON.parse(storedSidebarState));
|
|
39
|
+
// }
|
|
40
|
+
// }
|
|
41
|
+
// }, []);
|
|
42
42
|
return (
|
|
43
43
|
<div className="flex flex-col h-screen">
|
|
44
44
|
{/* Header */}
|
|
@@ -47,7 +47,7 @@ export default function Container({
|
|
|
47
47
|
<button
|
|
48
48
|
onClick={() => {
|
|
49
49
|
setIsSidebarOpen(!isSidebarOpen);
|
|
50
|
-
handleClick(!isSidebarOpen);
|
|
50
|
+
// handleClick(!isSidebarOpen);
|
|
51
51
|
}}
|
|
52
52
|
className="bg-blue-600 text-white px-2 py-1 rounded-r"
|
|
53
53
|
>
|
|
@@ -90,6 +90,10 @@ export default function Container({
|
|
|
90
90
|
className={`bg-blue-500 text-white overflow-y-auto fixed md:static top-0 left-0 h-full z-50 md:z-auto transition-all duration-300 ease-in-out
|
|
91
91
|
${isSidebarOpen ? "w-full md:w-[250px]" : "w-0 md:w-[60px]"}
|
|
92
92
|
`}
|
|
93
|
+
onMouseEnter={(e) => {
|
|
94
|
+
setIsSidebarOpen(true);
|
|
95
|
+
}}
|
|
96
|
+
onMouseLeave={(e) => setIsSidebarOpen(false)}
|
|
93
97
|
>
|
|
94
98
|
<div className="p-4 ">
|
|
95
99
|
{
|
|
@@ -101,7 +105,7 @@ export default function Container({
|
|
|
101
105
|
}
|
|
102
106
|
onClick={(e) => {
|
|
103
107
|
setIsSidebarOpen(false);
|
|
104
|
-
handleClick(false);
|
|
108
|
+
// handleClick(false);
|
|
105
109
|
}}
|
|
106
110
|
>
|
|
107
111
|
<MenuIcon /> {appName}
|
|
@@ -152,7 +156,7 @@ export default function Container({
|
|
|
152
156
|
className="fixed inset-0 bg-black bg-opacity-40 z-40"
|
|
153
157
|
onClick={() => {
|
|
154
158
|
setIsSidebarOpen(false);
|
|
155
|
-
handleClick(false);
|
|
159
|
+
// handleClick(false);
|
|
156
160
|
}}
|
|
157
161
|
/>
|
|
158
162
|
)}
|
package/src/modal/index.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import React, { ReactElement, cloneElement, useCallback } from "react";
|
|
1
|
+
import React, { ReactElement, cloneElement, useEffect, useMemo } from "react";
|
|
3
2
|
import usePopup from "../pop";
|
|
4
3
|
|
|
5
4
|
export type PopupColor =
|
|
@@ -25,8 +24,16 @@ export default function Modal({
|
|
|
25
24
|
title?: string;
|
|
26
25
|
}) {
|
|
27
26
|
const pop = usePopup();
|
|
27
|
+
const hide = () => pop.close(false);
|
|
28
28
|
|
|
29
|
-
const
|
|
29
|
+
const childrenWithHide = useMemo(
|
|
30
|
+
() => cloneElement(children, { hide }),
|
|
31
|
+
[children],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
pop.updateMessage(childrenWithHide);
|
|
36
|
+
}, [childrenWithHide]);
|
|
30
37
|
|
|
31
38
|
const props = button?.props;
|
|
32
39
|
const onClick = props?.onClick;
|
|
@@ -36,13 +43,10 @@ export default function Modal({
|
|
|
36
43
|
{cloneElement(button, {
|
|
37
44
|
onClick: (e) => {
|
|
38
45
|
onClick?.(e as any);
|
|
39
|
-
|
|
40
|
-
pop.modal(cloneElement(children, { hide }), color, false, true);
|
|
46
|
+
pop.modal(childrenWithHide, color, false, true);
|
|
41
47
|
},
|
|
42
48
|
})}
|
|
43
|
-
|
|
44
|
-
{/* ✅ Componente, no elemento JSX */}
|
|
45
|
-
<pop.PopupComponent />
|
|
49
|
+
{pop.PopupComponent}
|
|
46
50
|
</>
|
|
47
51
|
);
|
|
48
52
|
}
|
package/src/pop/index.tsx
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// usePopup.ts - Solución definitiva
|
|
2
2
|
"use client";
|
|
3
|
+
|
|
3
4
|
import { useState, useCallback, useRef, type ReactNode } from "react";
|
|
4
5
|
import { PopupColor, PopupState } from "./types";
|
|
5
6
|
import { PopupOverlay } from "./overlay";
|
|
7
|
+
|
|
6
8
|
type PopupStateWithoutMessage = Omit<PopupState, "message">;
|
|
9
|
+
|
|
7
10
|
const INITIAL_STATE: PopupStateWithoutMessage = {
|
|
8
11
|
type: "alert",
|
|
9
12
|
visible: false,
|
|
@@ -12,10 +15,12 @@ const INITIAL_STATE: PopupStateWithoutMessage = {
|
|
|
12
15
|
icons: true,
|
|
13
16
|
full: false,
|
|
14
17
|
};
|
|
18
|
+
|
|
15
19
|
export default function usePopup() {
|
|
16
20
|
const [popup, setPopup] = useState<PopupStateWithoutMessage>(INITIAL_STATE);
|
|
17
21
|
// El message vive FUERA del estado para no quedar congelado
|
|
18
22
|
const messageRef = useRef<ReactNode>(null);
|
|
23
|
+
|
|
19
24
|
const open = useCallback(
|
|
20
25
|
(partial: Omit<PopupState, "visible" | "inputValue">) => {
|
|
21
26
|
const { message, ...rest } = partial;
|
|
@@ -24,6 +29,7 @@ export default function usePopup() {
|
|
|
24
29
|
},
|
|
25
30
|
[],
|
|
26
31
|
);
|
|
32
|
+
|
|
27
33
|
const close = useCallback((confirmed: boolean, value?: string) => {
|
|
28
34
|
setPopup((prev) => {
|
|
29
35
|
if (confirmed) prev.onConfirm?.(value);
|
|
@@ -31,6 +37,7 @@ export default function usePopup() {
|
|
|
31
37
|
return { ...prev, visible: false, inputValue: "" };
|
|
32
38
|
});
|
|
33
39
|
}, []);
|
|
40
|
+
|
|
34
41
|
const alert = useCallback(
|
|
35
42
|
(message: string, color: PopupColor = "primary"): Promise<void> =>
|
|
36
43
|
new Promise((resolve) =>
|
|
@@ -44,6 +51,7 @@ export default function usePopup() {
|
|
|
44
51
|
),
|
|
45
52
|
[open],
|
|
46
53
|
);
|
|
54
|
+
|
|
47
55
|
const modal = useCallback(
|
|
48
56
|
(
|
|
49
57
|
message: ReactNode,
|
|
@@ -64,6 +72,7 @@ export default function usePopup() {
|
|
|
64
72
|
),
|
|
65
73
|
[open],
|
|
66
74
|
);
|
|
75
|
+
|
|
67
76
|
const confirm = useCallback(
|
|
68
77
|
(message: string, color: PopupColor = "primary"): Promise<boolean> =>
|
|
69
78
|
new Promise((resolve) =>
|
|
@@ -77,6 +86,7 @@ export default function usePopup() {
|
|
|
77
86
|
),
|
|
78
87
|
[open],
|
|
79
88
|
);
|
|
89
|
+
|
|
80
90
|
const prompt = useCallback(
|
|
81
91
|
(message: string, color: PopupColor = "primary"): Promise<string | null> =>
|
|
82
92
|
new Promise((resolve) =>
|
|
@@ -90,6 +100,7 @@ export default function usePopup() {
|
|
|
90
100
|
),
|
|
91
101
|
[open],
|
|
92
102
|
);
|
|
103
|
+
|
|
93
104
|
// ✅ Actualiza la ref en cada render cuando el modal está abierto
|
|
94
105
|
// Esto permite que cambios en el children del padre se reflejen
|
|
95
106
|
const updateMessage = useCallback((message: ReactNode) => {
|
|
@@ -97,16 +108,15 @@ export default function usePopup() {
|
|
|
97
108
|
// Fuerza re-render del PopupComponent
|
|
98
109
|
setPopup((prev) => ({ ...prev }));
|
|
99
110
|
}, []);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}, [popup, close]); // messageRef no necesita estar aquí, es mutable
|
|
111
|
+
|
|
112
|
+
const PopupComponent = popup.visible ? (
|
|
113
|
+
<PopupOverlay
|
|
114
|
+
popup={{ ...popup, message: messageRef.current }}
|
|
115
|
+
onClose={close}
|
|
116
|
+
onInputChange={(v) => setPopup((prev) => ({ ...prev, inputValue: v }))}
|
|
117
|
+
/>
|
|
118
|
+
) : null;
|
|
119
|
+
|
|
110
120
|
return {
|
|
111
121
|
alert,
|
|
112
122
|
confirm,
|