next-recomponents 2.0.32 → 2.0.33
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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +55 -58
- package/dist/index.mjs +159 -162
- package/package.json +1 -1
- package/src/modal/index.tsx +22 -11
- package/src/pop/index.tsx +44 -59
package/dist/index.d.mts
CHANGED
|
@@ -232,12 +232,12 @@ type PopupColor = "white" | "primary" | "secondary" | "info" | "danger" | "warni
|
|
|
232
232
|
|
|
233
233
|
declare function usePopup(): {
|
|
234
234
|
alert: (message: string, color?: PopupColor) => Promise<void>;
|
|
235
|
-
confirm:
|
|
236
|
-
prompt:
|
|
235
|
+
confirm: typeof confirm;
|
|
236
|
+
prompt: typeof prompt;
|
|
237
237
|
modal: (message: ReactNode, color?: PopupColor, icons?: boolean, full?: boolean) => Promise<void>;
|
|
238
|
-
PopupComponent: react_jsx_runtime.JSX.Element | null;
|
|
239
238
|
close: (confirmed: boolean, value?: string) => void;
|
|
240
239
|
updateMessage: (message: ReactNode) => void;
|
|
240
|
+
PopupComponent: () => react_jsx_runtime.JSX.Element | null;
|
|
241
241
|
};
|
|
242
242
|
|
|
243
243
|
export { Alert, Button, Container, DocumentViewer, Form, Input, Modal, MyCalendar, Pre, Select, Table, Table3, type TableButtonProps, type TableButtonProps as TableEventProps, TextArea, regularExpresions, useDates, useExcel, useFormValues, usePopup, useResources };
|
package/dist/index.d.ts
CHANGED
|
@@ -232,12 +232,12 @@ type PopupColor = "white" | "primary" | "secondary" | "info" | "danger" | "warni
|
|
|
232
232
|
|
|
233
233
|
declare function usePopup(): {
|
|
234
234
|
alert: (message: string, color?: PopupColor) => Promise<void>;
|
|
235
|
-
confirm:
|
|
236
|
-
prompt:
|
|
235
|
+
confirm: typeof confirm;
|
|
236
|
+
prompt: typeof prompt;
|
|
237
237
|
modal: (message: ReactNode, color?: PopupColor, icons?: boolean, full?: boolean) => Promise<void>;
|
|
238
|
-
PopupComponent: react_jsx_runtime.JSX.Element | null;
|
|
239
238
|
close: (confirmed: boolean, value?: string) => void;
|
|
240
239
|
updateMessage: (message: ReactNode) => void;
|
|
240
|
+
PopupComponent: () => react_jsx_runtime.JSX.Element | null;
|
|
241
241
|
};
|
|
242
242
|
|
|
243
243
|
export { Alert, Button, Container, DocumentViewer, Form, Input, Modal, MyCalendar, Pre, Select, Table, Table3, type TableButtonProps, type TableButtonProps as TableEventProps, TextArea, regularExpresions, useDates, useExcel, useFormValues, usePopup, useResources };
|
package/dist/index.js
CHANGED
|
@@ -36958,7 +36958,7 @@ var import_react10 = require("react");
|
|
|
36958
36958
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
36959
36959
|
function PopupActions({
|
|
36960
36960
|
type,
|
|
36961
|
-
confirm,
|
|
36961
|
+
confirm: confirm2,
|
|
36962
36962
|
focusRing,
|
|
36963
36963
|
onConfirm,
|
|
36964
36964
|
onCancel
|
|
@@ -36977,7 +36977,7 @@ function PopupActions({
|
|
|
36977
36977
|
"button",
|
|
36978
36978
|
{
|
|
36979
36979
|
onClick: onConfirm,
|
|
36980
|
-
className: `px-5 py-2 rounded-lg text-sm font-semibold text-white ${
|
|
36980
|
+
className: `px-5 py-2 rounded-lg text-sm font-semibold text-white ${confirm2} transition focus:outline-none focus:ring-2 ${focusRing}`,
|
|
36981
36981
|
children: "Aceptar"
|
|
36982
36982
|
}
|
|
36983
36983
|
)
|
|
@@ -37193,16 +37193,18 @@ var INITIAL_STATE = {
|
|
|
37193
37193
|
inputValue: "",
|
|
37194
37194
|
color: "primary",
|
|
37195
37195
|
icons: true,
|
|
37196
|
-
full: false
|
|
37196
|
+
full: false,
|
|
37197
|
+
message: null
|
|
37197
37198
|
};
|
|
37198
37199
|
function usePopup() {
|
|
37199
37200
|
const [popup, setPopup] = (0, import_react10.useState)(INITIAL_STATE);
|
|
37200
|
-
const messageRef = (0, import_react10.useRef)(null);
|
|
37201
37201
|
const open = (0, import_react10.useCallback)(
|
|
37202
37202
|
(partial) => {
|
|
37203
|
-
|
|
37204
|
-
|
|
37205
|
-
|
|
37203
|
+
setPopup({
|
|
37204
|
+
...partial,
|
|
37205
|
+
visible: true,
|
|
37206
|
+
inputValue: ""
|
|
37207
|
+
});
|
|
37206
37208
|
},
|
|
37207
37209
|
[]
|
|
37208
37210
|
);
|
|
@@ -37211,9 +37213,19 @@ function usePopup() {
|
|
|
37211
37213
|
var _a, _b;
|
|
37212
37214
|
if (confirmed) (_a = prev.onConfirm) == null ? void 0 : _a.call(prev, value);
|
|
37213
37215
|
else (_b = prev.onCancel) == null ? void 0 : _b.call(prev);
|
|
37214
|
-
return {
|
|
37216
|
+
return {
|
|
37217
|
+
...prev,
|
|
37218
|
+
visible: false,
|
|
37219
|
+
inputValue: ""
|
|
37220
|
+
};
|
|
37215
37221
|
});
|
|
37216
37222
|
}, []);
|
|
37223
|
+
const updateMessage = (0, import_react10.useCallback)((message) => {
|
|
37224
|
+
setPopup((prev) => ({
|
|
37225
|
+
...prev,
|
|
37226
|
+
message
|
|
37227
|
+
}));
|
|
37228
|
+
}, []);
|
|
37217
37229
|
const alert2 = (0, import_react10.useCallback)(
|
|
37218
37230
|
(message, color = "primary") => new Promise(
|
|
37219
37231
|
(resolve) => open({
|
|
@@ -37221,7 +37233,9 @@ function usePopup() {
|
|
|
37221
37233
|
message,
|
|
37222
37234
|
color,
|
|
37223
37235
|
onConfirm: () => resolve(),
|
|
37224
|
-
onCancel: () => resolve()
|
|
37236
|
+
onCancel: () => resolve(),
|
|
37237
|
+
icons: true,
|
|
37238
|
+
full: false
|
|
37225
37239
|
})
|
|
37226
37240
|
),
|
|
37227
37241
|
[open]
|
|
@@ -37232,58 +37246,36 @@ function usePopup() {
|
|
|
37232
37246
|
type: "modal",
|
|
37233
37247
|
message,
|
|
37234
37248
|
color,
|
|
37235
|
-
onConfirm: () => resolve(),
|
|
37236
|
-
onCancel: () => resolve(),
|
|
37237
37249
|
icons,
|
|
37238
|
-
full
|
|
37239
|
-
|
|
37240
|
-
|
|
37241
|
-
[open]
|
|
37242
|
-
);
|
|
37243
|
-
const confirm = (0, import_react10.useCallback)(
|
|
37244
|
-
(message, color = "primary") => new Promise(
|
|
37245
|
-
(resolve) => open({
|
|
37246
|
-
type: "confirm",
|
|
37247
|
-
message,
|
|
37248
|
-
color,
|
|
37249
|
-
onConfirm: () => resolve(true),
|
|
37250
|
-
onCancel: () => resolve(false)
|
|
37251
|
-
})
|
|
37252
|
-
),
|
|
37253
|
-
[open]
|
|
37254
|
-
);
|
|
37255
|
-
const prompt = (0, import_react10.useCallback)(
|
|
37256
|
-
(message, color = "primary") => new Promise(
|
|
37257
|
-
(resolve) => open({
|
|
37258
|
-
type: "prompt",
|
|
37259
|
-
message,
|
|
37260
|
-
color,
|
|
37261
|
-
onConfirm: (value) => resolve(value != null ? value : ""),
|
|
37262
|
-
onCancel: () => resolve(null)
|
|
37250
|
+
full,
|
|
37251
|
+
onConfirm: () => resolve(),
|
|
37252
|
+
onCancel: () => resolve()
|
|
37263
37253
|
})
|
|
37264
37254
|
),
|
|
37265
37255
|
[open]
|
|
37266
37256
|
);
|
|
37267
|
-
const
|
|
37268
|
-
|
|
37269
|
-
|
|
37270
|
-
|
|
37271
|
-
|
|
37272
|
-
|
|
37273
|
-
|
|
37274
|
-
|
|
37275
|
-
|
|
37276
|
-
|
|
37277
|
-
|
|
37278
|
-
|
|
37257
|
+
const PopupComponent = () => {
|
|
37258
|
+
if (!popup.visible) return null;
|
|
37259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
37260
|
+
PopupOverlay,
|
|
37261
|
+
{
|
|
37262
|
+
popup,
|
|
37263
|
+
onClose: close,
|
|
37264
|
+
onInputChange: (v) => setPopup((prev) => ({
|
|
37265
|
+
...prev,
|
|
37266
|
+
inputValue: v
|
|
37267
|
+
}))
|
|
37268
|
+
}
|
|
37269
|
+
);
|
|
37270
|
+
};
|
|
37279
37271
|
return {
|
|
37280
37272
|
alert: alert2,
|
|
37281
37273
|
confirm,
|
|
37282
37274
|
prompt,
|
|
37283
37275
|
modal,
|
|
37284
|
-
PopupComponent,
|
|
37285
37276
|
close,
|
|
37286
|
-
updateMessage
|
|
37277
|
+
updateMessage,
|
|
37278
|
+
PopupComponent
|
|
37287
37279
|
};
|
|
37288
37280
|
}
|
|
37289
37281
|
|
|
@@ -37297,20 +37289,25 @@ function Modal({
|
|
|
37297
37289
|
}) {
|
|
37298
37290
|
const pop = usePopup();
|
|
37299
37291
|
const hide = () => pop.close(false);
|
|
37300
|
-
const
|
|
37301
|
-
|
|
37302
|
-
|
|
37292
|
+
const content = (0, import_react11.useMemo)(() => {
|
|
37293
|
+
return (0, import_react11.cloneElement)(children, {
|
|
37294
|
+
hide,
|
|
37295
|
+
key: crypto.randomUUID()
|
|
37296
|
+
});
|
|
37303
37297
|
}, [children]);
|
|
37298
|
+
(0, import_react11.useEffect)(() => {
|
|
37299
|
+
pop.updateMessage(content);
|
|
37300
|
+
}, [content]);
|
|
37304
37301
|
const props = button == null ? void 0 : button.props;
|
|
37305
|
-
const
|
|
37302
|
+
const originalOnClick = props == null ? void 0 : props.onClick;
|
|
37306
37303
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
37307
37304
|
(0, import_react11.cloneElement)(button, {
|
|
37308
|
-
onClick: (e) => {
|
|
37309
|
-
|
|
37310
|
-
pop.modal(
|
|
37305
|
+
onClick: async (e) => {
|
|
37306
|
+
originalOnClick == null ? void 0 : originalOnClick(e);
|
|
37307
|
+
await pop.modal(content, color, false, true);
|
|
37311
37308
|
}
|
|
37312
37309
|
}),
|
|
37313
|
-
pop.PopupComponent
|
|
37310
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(pop.PopupComponent, {})
|
|
37314
37311
|
] });
|
|
37315
37312
|
}
|
|
37316
37313
|
|
package/dist/index.mjs
CHANGED
|
@@ -36935,16 +36935,16 @@ function Select({
|
|
|
36935
36935
|
}
|
|
36936
36936
|
|
|
36937
36937
|
// src/modal/index.tsx
|
|
36938
|
-
import { cloneElement as cloneElement2, useEffect as useEffect6 } from "react";
|
|
36938
|
+
import { cloneElement as cloneElement2, useEffect as useEffect6, useMemo as useMemo4 } from "react";
|
|
36939
36939
|
|
|
36940
36940
|
// src/pop/index.tsx
|
|
36941
|
-
import { useState as useState9, useCallback
|
|
36941
|
+
import { useState as useState9, useCallback } from "react";
|
|
36942
36942
|
|
|
36943
36943
|
// src/pop/actions.tsx
|
|
36944
36944
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
36945
36945
|
function PopupActions({
|
|
36946
36946
|
type,
|
|
36947
|
-
confirm,
|
|
36947
|
+
confirm: confirm2,
|
|
36948
36948
|
focusRing,
|
|
36949
36949
|
onConfirm,
|
|
36950
36950
|
onCancel
|
|
@@ -36963,7 +36963,7 @@ function PopupActions({
|
|
|
36963
36963
|
"button",
|
|
36964
36964
|
{
|
|
36965
36965
|
onClick: onConfirm,
|
|
36966
|
-
className: `px-5 py-2 rounded-lg text-sm font-semibold text-white ${
|
|
36966
|
+
className: `px-5 py-2 rounded-lg text-sm font-semibold text-white ${confirm2} transition focus:outline-none focus:ring-2 ${focusRing}`,
|
|
36967
36967
|
children: "Aceptar"
|
|
36968
36968
|
}
|
|
36969
36969
|
)
|
|
@@ -37179,16 +37179,18 @@ var INITIAL_STATE = {
|
|
|
37179
37179
|
inputValue: "",
|
|
37180
37180
|
color: "primary",
|
|
37181
37181
|
icons: true,
|
|
37182
|
-
full: false
|
|
37182
|
+
full: false,
|
|
37183
|
+
message: null
|
|
37183
37184
|
};
|
|
37184
37185
|
function usePopup() {
|
|
37185
37186
|
const [popup, setPopup] = useState9(INITIAL_STATE);
|
|
37186
|
-
const messageRef = useRef3(null);
|
|
37187
37187
|
const open = useCallback(
|
|
37188
37188
|
(partial) => {
|
|
37189
|
-
|
|
37190
|
-
|
|
37191
|
-
|
|
37189
|
+
setPopup({
|
|
37190
|
+
...partial,
|
|
37191
|
+
visible: true,
|
|
37192
|
+
inputValue: ""
|
|
37193
|
+
});
|
|
37192
37194
|
},
|
|
37193
37195
|
[]
|
|
37194
37196
|
);
|
|
@@ -37197,9 +37199,19 @@ function usePopup() {
|
|
|
37197
37199
|
var _a, _b;
|
|
37198
37200
|
if (confirmed) (_a = prev.onConfirm) == null ? void 0 : _a.call(prev, value);
|
|
37199
37201
|
else (_b = prev.onCancel) == null ? void 0 : _b.call(prev);
|
|
37200
|
-
return {
|
|
37202
|
+
return {
|
|
37203
|
+
...prev,
|
|
37204
|
+
visible: false,
|
|
37205
|
+
inputValue: ""
|
|
37206
|
+
};
|
|
37201
37207
|
});
|
|
37202
37208
|
}, []);
|
|
37209
|
+
const updateMessage = useCallback((message) => {
|
|
37210
|
+
setPopup((prev) => ({
|
|
37211
|
+
...prev,
|
|
37212
|
+
message
|
|
37213
|
+
}));
|
|
37214
|
+
}, []);
|
|
37203
37215
|
const alert2 = useCallback(
|
|
37204
37216
|
(message, color = "primary") => new Promise(
|
|
37205
37217
|
(resolve) => open({
|
|
@@ -37207,7 +37219,9 @@ function usePopup() {
|
|
|
37207
37219
|
message,
|
|
37208
37220
|
color,
|
|
37209
37221
|
onConfirm: () => resolve(),
|
|
37210
|
-
onCancel: () => resolve()
|
|
37222
|
+
onCancel: () => resolve(),
|
|
37223
|
+
icons: true,
|
|
37224
|
+
full: false
|
|
37211
37225
|
})
|
|
37212
37226
|
),
|
|
37213
37227
|
[open]
|
|
@@ -37218,63 +37232,41 @@ function usePopup() {
|
|
|
37218
37232
|
type: "modal",
|
|
37219
37233
|
message,
|
|
37220
37234
|
color,
|
|
37221
|
-
onConfirm: () => resolve(),
|
|
37222
|
-
onCancel: () => resolve(),
|
|
37223
37235
|
icons,
|
|
37224
|
-
full
|
|
37225
|
-
|
|
37226
|
-
|
|
37227
|
-
[open]
|
|
37228
|
-
);
|
|
37229
|
-
const confirm = useCallback(
|
|
37230
|
-
(message, color = "primary") => new Promise(
|
|
37231
|
-
(resolve) => open({
|
|
37232
|
-
type: "confirm",
|
|
37233
|
-
message,
|
|
37234
|
-
color,
|
|
37235
|
-
onConfirm: () => resolve(true),
|
|
37236
|
-
onCancel: () => resolve(false)
|
|
37237
|
-
})
|
|
37238
|
-
),
|
|
37239
|
-
[open]
|
|
37240
|
-
);
|
|
37241
|
-
const prompt = useCallback(
|
|
37242
|
-
(message, color = "primary") => new Promise(
|
|
37243
|
-
(resolve) => open({
|
|
37244
|
-
type: "prompt",
|
|
37245
|
-
message,
|
|
37246
|
-
color,
|
|
37247
|
-
onConfirm: (value) => resolve(value != null ? value : ""),
|
|
37248
|
-
onCancel: () => resolve(null)
|
|
37236
|
+
full,
|
|
37237
|
+
onConfirm: () => resolve(),
|
|
37238
|
+
onCancel: () => resolve()
|
|
37249
37239
|
})
|
|
37250
37240
|
),
|
|
37251
37241
|
[open]
|
|
37252
37242
|
);
|
|
37253
|
-
const
|
|
37254
|
-
|
|
37255
|
-
|
|
37256
|
-
|
|
37257
|
-
|
|
37258
|
-
|
|
37259
|
-
|
|
37260
|
-
|
|
37261
|
-
|
|
37262
|
-
|
|
37263
|
-
|
|
37264
|
-
|
|
37243
|
+
const PopupComponent = () => {
|
|
37244
|
+
if (!popup.visible) return null;
|
|
37245
|
+
return /* @__PURE__ */ jsx15(
|
|
37246
|
+
PopupOverlay,
|
|
37247
|
+
{
|
|
37248
|
+
popup,
|
|
37249
|
+
onClose: close,
|
|
37250
|
+
onInputChange: (v) => setPopup((prev) => ({
|
|
37251
|
+
...prev,
|
|
37252
|
+
inputValue: v
|
|
37253
|
+
}))
|
|
37254
|
+
}
|
|
37255
|
+
);
|
|
37256
|
+
};
|
|
37265
37257
|
return {
|
|
37266
37258
|
alert: alert2,
|
|
37267
37259
|
confirm,
|
|
37268
37260
|
prompt,
|
|
37269
37261
|
modal,
|
|
37270
|
-
PopupComponent,
|
|
37271
37262
|
close,
|
|
37272
|
-
updateMessage
|
|
37263
|
+
updateMessage,
|
|
37264
|
+
PopupComponent
|
|
37273
37265
|
};
|
|
37274
37266
|
}
|
|
37275
37267
|
|
|
37276
37268
|
// src/modal/index.tsx
|
|
37277
|
-
import { Fragment as Fragment2, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
37269
|
+
import { Fragment as Fragment2, jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
37278
37270
|
function Modal({
|
|
37279
37271
|
button,
|
|
37280
37272
|
children,
|
|
@@ -37283,28 +37275,33 @@ function Modal({
|
|
|
37283
37275
|
}) {
|
|
37284
37276
|
const pop = usePopup();
|
|
37285
37277
|
const hide = () => pop.close(false);
|
|
37286
|
-
const
|
|
37287
|
-
|
|
37288
|
-
|
|
37278
|
+
const content = useMemo4(() => {
|
|
37279
|
+
return cloneElement2(children, {
|
|
37280
|
+
hide,
|
|
37281
|
+
key: crypto.randomUUID()
|
|
37282
|
+
});
|
|
37289
37283
|
}, [children]);
|
|
37284
|
+
useEffect6(() => {
|
|
37285
|
+
pop.updateMessage(content);
|
|
37286
|
+
}, [content]);
|
|
37290
37287
|
const props = button == null ? void 0 : button.props;
|
|
37291
|
-
const
|
|
37288
|
+
const originalOnClick = props == null ? void 0 : props.onClick;
|
|
37292
37289
|
return /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
37293
37290
|
cloneElement2(button, {
|
|
37294
|
-
onClick: (e) => {
|
|
37295
|
-
|
|
37296
|
-
pop.modal(
|
|
37291
|
+
onClick: async (e) => {
|
|
37292
|
+
originalOnClick == null ? void 0 : originalOnClick(e);
|
|
37293
|
+
await pop.modal(content, color, false, true);
|
|
37297
37294
|
}
|
|
37298
37295
|
}),
|
|
37299
|
-
pop.PopupComponent
|
|
37296
|
+
/* @__PURE__ */ jsx16(pop.PopupComponent, {})
|
|
37300
37297
|
] });
|
|
37301
37298
|
}
|
|
37302
37299
|
|
|
37303
37300
|
// src/pre/index.tsx
|
|
37304
|
-
import { jsx as
|
|
37301
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
37305
37302
|
var Pre = ({ data }) => {
|
|
37306
37303
|
const formatted = JSON.stringify(data, null, 2);
|
|
37307
|
-
return /* @__PURE__ */
|
|
37304
|
+
return /* @__PURE__ */ jsx17(
|
|
37308
37305
|
"pre",
|
|
37309
37306
|
{
|
|
37310
37307
|
style: {
|
|
@@ -37355,9 +37352,9 @@ import {
|
|
|
37355
37352
|
import DatePicker from "react-datepicker";
|
|
37356
37353
|
|
|
37357
37354
|
// src/calendar/calendar.icon.tsx
|
|
37358
|
-
import { jsx as
|
|
37355
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
37359
37356
|
function CalendarIcon() {
|
|
37360
|
-
return /* @__PURE__ */
|
|
37357
|
+
return /* @__PURE__ */ jsx18(
|
|
37361
37358
|
"svg",
|
|
37362
37359
|
{
|
|
37363
37360
|
stroke: "currentColor",
|
|
@@ -37367,14 +37364,14 @@ function CalendarIcon() {
|
|
|
37367
37364
|
height: "20px",
|
|
37368
37365
|
width: "20px",
|
|
37369
37366
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37370
|
-
children: /* @__PURE__ */
|
|
37367
|
+
children: /* @__PURE__ */ jsx18("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" })
|
|
37371
37368
|
}
|
|
37372
37369
|
);
|
|
37373
37370
|
}
|
|
37374
37371
|
|
|
37375
37372
|
// src/calendar/index.tsx
|
|
37376
37373
|
import { Dialog as Dialog2 } from "@mui/material";
|
|
37377
|
-
import { jsx as
|
|
37374
|
+
import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
37378
37375
|
function MyCalendar({
|
|
37379
37376
|
enabledDates,
|
|
37380
37377
|
onChange,
|
|
@@ -37410,15 +37407,15 @@ function MyCalendar({
|
|
|
37410
37407
|
/* @__PURE__ */ jsxs11("div", { className: "font-bold", children: [
|
|
37411
37408
|
label,
|
|
37412
37409
|
" ",
|
|
37413
|
-
(otherProps == null ? void 0 : otherProps.required) && /* @__PURE__ */
|
|
37410
|
+
(otherProps == null ? void 0 : otherProps.required) && /* @__PURE__ */ jsx19("span", { className: "text-red-500", children: "*" })
|
|
37414
37411
|
] }),
|
|
37415
|
-
/* @__PURE__ */
|
|
37412
|
+
/* @__PURE__ */ jsx19("div", { children: /* @__PURE__ */ jsxs11(
|
|
37416
37413
|
"div",
|
|
37417
37414
|
{
|
|
37418
37415
|
className: "cursor-pointer flex items-center justify-center",
|
|
37419
37416
|
onClick: (e) => setOpen(true),
|
|
37420
37417
|
children: [
|
|
37421
|
-
/* @__PURE__ */
|
|
37418
|
+
/* @__PURE__ */ jsx19(
|
|
37422
37419
|
"input",
|
|
37423
37420
|
{
|
|
37424
37421
|
...otherProps,
|
|
@@ -37433,13 +37430,13 @@ function MyCalendar({
|
|
|
37433
37430
|
readOnly: true
|
|
37434
37431
|
}
|
|
37435
37432
|
),
|
|
37436
|
-
/* @__PURE__ */
|
|
37433
|
+
/* @__PURE__ */ jsx19("div", { className: "absolute", style: { right: "10px" }, children: /* @__PURE__ */ jsx19(CalendarIcon, {}) })
|
|
37437
37434
|
]
|
|
37438
37435
|
}
|
|
37439
37436
|
) })
|
|
37440
37437
|
] }),
|
|
37441
37438
|
/* @__PURE__ */ jsxs11(Dialog2, { open, children: [
|
|
37442
|
-
/* @__PURE__ */
|
|
37439
|
+
/* @__PURE__ */ jsx19("div", { className: "flex justify-end p-5 font-bold", children: /* @__PURE__ */ jsx19(
|
|
37443
37440
|
"button",
|
|
37444
37441
|
{
|
|
37445
37442
|
className: " border-lg w-[20px] bg-red-500 text-white shadow rounded",
|
|
@@ -37447,7 +37444,7 @@ function MyCalendar({
|
|
|
37447
37444
|
children: "x"
|
|
37448
37445
|
}
|
|
37449
37446
|
) }),
|
|
37450
|
-
/* @__PURE__ */
|
|
37447
|
+
/* @__PURE__ */ jsx19("div", { className: " w-[300px] flex items-start justify-center h-[300px] p-5", children: /* @__PURE__ */ jsx19(
|
|
37451
37448
|
DatePicker,
|
|
37452
37449
|
{
|
|
37453
37450
|
inline: true,
|
|
@@ -37461,9 +37458,9 @@ function MyCalendar({
|
|
|
37461
37458
|
}
|
|
37462
37459
|
|
|
37463
37460
|
// src/doc-viewer/icon.tsx
|
|
37464
|
-
import { jsx as
|
|
37461
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
37465
37462
|
function Icon() {
|
|
37466
|
-
return /* @__PURE__ */
|
|
37463
|
+
return /* @__PURE__ */ jsx20(
|
|
37467
37464
|
"svg",
|
|
37468
37465
|
{
|
|
37469
37466
|
stroke: "currentColor",
|
|
@@ -37473,13 +37470,13 @@ function Icon() {
|
|
|
37473
37470
|
height: "200px",
|
|
37474
37471
|
width: "200px",
|
|
37475
37472
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37476
|
-
children: /* @__PURE__ */
|
|
37473
|
+
children: /* @__PURE__ */ jsx20("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" })
|
|
37477
37474
|
}
|
|
37478
37475
|
);
|
|
37479
37476
|
}
|
|
37480
37477
|
|
|
37481
37478
|
// src/doc-viewer/index.tsx
|
|
37482
|
-
import { jsx as
|
|
37479
|
+
import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
37483
37480
|
function DocumentViewer({ item }) {
|
|
37484
37481
|
const { url, name, contentType, width = "100%", height = "100%" } = item;
|
|
37485
37482
|
const isImage = contentType.startsWith("image/");
|
|
@@ -37490,8 +37487,8 @@ function DocumentViewer({ item }) {
|
|
|
37490
37487
|
)}&embedded=true` : url;
|
|
37491
37488
|
return /* @__PURE__ */ jsxs12("div", { className: "border shadow rounded p-2 h-[100%]", children: [
|
|
37492
37489
|
/* @__PURE__ */ jsxs12("div", { className: "mb-1 flex justify-between ", children: [
|
|
37493
|
-
/* @__PURE__ */
|
|
37494
|
-
/* @__PURE__ */
|
|
37490
|
+
/* @__PURE__ */ jsx21("h3", { className: "font-bold", children: name }),
|
|
37491
|
+
/* @__PURE__ */ jsx21(
|
|
37495
37492
|
"a",
|
|
37496
37493
|
{
|
|
37497
37494
|
href: url,
|
|
@@ -37503,7 +37500,7 @@ function DocumentViewer({ item }) {
|
|
|
37503
37500
|
}
|
|
37504
37501
|
)
|
|
37505
37502
|
] }),
|
|
37506
|
-
isImage ? /* @__PURE__ */
|
|
37503
|
+
isImage ? /* @__PURE__ */ jsx21(
|
|
37507
37504
|
"img",
|
|
37508
37505
|
{
|
|
37509
37506
|
src: url,
|
|
@@ -37516,7 +37513,7 @@ function DocumentViewer({ item }) {
|
|
|
37516
37513
|
display: "block"
|
|
37517
37514
|
}
|
|
37518
37515
|
}
|
|
37519
|
-
) : isGoogleDocCompatible ? /* @__PURE__ */
|
|
37516
|
+
) : isGoogleDocCompatible ? /* @__PURE__ */ jsx21(
|
|
37520
37517
|
"iframe",
|
|
37521
37518
|
{
|
|
37522
37519
|
title: name,
|
|
@@ -37524,7 +37521,7 @@ function DocumentViewer({ item }) {
|
|
|
37524
37521
|
style: { width, height, border: "none" },
|
|
37525
37522
|
allowFullScreen: true
|
|
37526
37523
|
}
|
|
37527
|
-
) : /* @__PURE__ */
|
|
37524
|
+
) : /* @__PURE__ */ jsx21(
|
|
37528
37525
|
"div",
|
|
37529
37526
|
{
|
|
37530
37527
|
style: {
|
|
@@ -37534,7 +37531,7 @@ function DocumentViewer({ item }) {
|
|
|
37534
37531
|
objectFit: "cover",
|
|
37535
37532
|
display: "block"
|
|
37536
37533
|
},
|
|
37537
|
-
children: /* @__PURE__ */
|
|
37534
|
+
children: /* @__PURE__ */ jsx21(Icon, {})
|
|
37538
37535
|
}
|
|
37539
37536
|
)
|
|
37540
37537
|
] });
|
|
@@ -37543,19 +37540,19 @@ function DocumentViewer({ item }) {
|
|
|
37543
37540
|
// src/table3/index.tsx
|
|
37544
37541
|
import React9, {
|
|
37545
37542
|
useEffect as useEffect9,
|
|
37546
|
-
useMemo as
|
|
37543
|
+
useMemo as useMemo7,
|
|
37547
37544
|
useReducer as useReducer2,
|
|
37548
|
-
useRef as
|
|
37545
|
+
useRef as useRef4,
|
|
37549
37546
|
useState as useState13
|
|
37550
37547
|
} from "react";
|
|
37551
37548
|
|
|
37552
37549
|
// src/table3/filter.tsx
|
|
37553
|
-
import { useEffect as useEffect8, useMemo as
|
|
37550
|
+
import { useEffect as useEffect8, useMemo as useMemo5, useState as useState11 } from "react";
|
|
37554
37551
|
|
|
37555
37552
|
// src/table3/filters.tsx
|
|
37556
|
-
import { jsx as
|
|
37553
|
+
import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
37557
37554
|
function FilterOffIcon() {
|
|
37558
|
-
return /* @__PURE__ */
|
|
37555
|
+
return /* @__PURE__ */ jsx22(
|
|
37559
37556
|
"svg",
|
|
37560
37557
|
{
|
|
37561
37558
|
stroke: "currentColor",
|
|
@@ -37565,12 +37562,12 @@ function FilterOffIcon() {
|
|
|
37565
37562
|
height: "20px",
|
|
37566
37563
|
width: "20px",
|
|
37567
37564
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37568
|
-
children: /* @__PURE__ */
|
|
37565
|
+
children: /* @__PURE__ */ jsx22("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" })
|
|
37569
37566
|
}
|
|
37570
37567
|
);
|
|
37571
37568
|
}
|
|
37572
37569
|
function OrderDesc() {
|
|
37573
|
-
return /* @__PURE__ */
|
|
37570
|
+
return /* @__PURE__ */ jsx22(
|
|
37574
37571
|
"svg",
|
|
37575
37572
|
{
|
|
37576
37573
|
stroke: "currentColor",
|
|
@@ -37580,12 +37577,12 @@ function OrderDesc() {
|
|
|
37580
37577
|
height: "20px",
|
|
37581
37578
|
width: "20px",
|
|
37582
37579
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37583
|
-
children: /* @__PURE__ */
|
|
37580
|
+
children: /* @__PURE__ */ jsx22("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" })
|
|
37584
37581
|
}
|
|
37585
37582
|
);
|
|
37586
37583
|
}
|
|
37587
37584
|
function OrderAsc() {
|
|
37588
|
-
return /* @__PURE__ */
|
|
37585
|
+
return /* @__PURE__ */ jsx22(
|
|
37589
37586
|
"svg",
|
|
37590
37587
|
{
|
|
37591
37588
|
stroke: "currentColor",
|
|
@@ -37595,12 +37592,12 @@ function OrderAsc() {
|
|
|
37595
37592
|
height: "20px",
|
|
37596
37593
|
width: "20px",
|
|
37597
37594
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37598
|
-
children: /* @__PURE__ */
|
|
37595
|
+
children: /* @__PURE__ */ jsx22("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" })
|
|
37599
37596
|
}
|
|
37600
37597
|
);
|
|
37601
37598
|
}
|
|
37602
37599
|
function EditIcon2() {
|
|
37603
|
-
return /* @__PURE__ */
|
|
37600
|
+
return /* @__PURE__ */ jsx22(
|
|
37604
37601
|
"svg",
|
|
37605
37602
|
{
|
|
37606
37603
|
stroke: "currentColor",
|
|
@@ -37610,7 +37607,7 @@ function EditIcon2() {
|
|
|
37610
37607
|
height: "20px",
|
|
37611
37608
|
width: "20px",
|
|
37612
37609
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37613
|
-
children: /* @__PURE__ */
|
|
37610
|
+
children: /* @__PURE__ */ jsx22("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" })
|
|
37614
37611
|
}
|
|
37615
37612
|
);
|
|
37616
37613
|
}
|
|
@@ -37626,14 +37623,14 @@ function SaveIcon() {
|
|
|
37626
37623
|
width: "20px",
|
|
37627
37624
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37628
37625
|
children: [
|
|
37629
|
-
/* @__PURE__ */
|
|
37630
|
-
/* @__PURE__ */
|
|
37626
|
+
/* @__PURE__ */ jsx22("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" }),
|
|
37627
|
+
/* @__PURE__ */ jsx22("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" })
|
|
37631
37628
|
]
|
|
37632
37629
|
}
|
|
37633
37630
|
);
|
|
37634
37631
|
}
|
|
37635
37632
|
function ExcelIcon() {
|
|
37636
|
-
return /* @__PURE__ */
|
|
37633
|
+
return /* @__PURE__ */ jsx22(
|
|
37637
37634
|
"svg",
|
|
37638
37635
|
{
|
|
37639
37636
|
stroke: "currentColor",
|
|
@@ -37643,13 +37640,13 @@ function ExcelIcon() {
|
|
|
37643
37640
|
height: "20px",
|
|
37644
37641
|
width: "20px",
|
|
37645
37642
|
xmlns: "http://www.w3.org/2000/svg",
|
|
37646
|
-
children: /* @__PURE__ */
|
|
37643
|
+
children: /* @__PURE__ */ jsx22("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" })
|
|
37647
37644
|
}
|
|
37648
37645
|
);
|
|
37649
37646
|
}
|
|
37650
37647
|
|
|
37651
37648
|
// src/table3/filter.tsx
|
|
37652
|
-
import { jsx as
|
|
37649
|
+
import { jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
37653
37650
|
function Filter({
|
|
37654
37651
|
h,
|
|
37655
37652
|
objectData,
|
|
@@ -37662,12 +37659,12 @@ function Filter({
|
|
|
37662
37659
|
}) {
|
|
37663
37660
|
const [visible, setVisible] = useState11(false);
|
|
37664
37661
|
const [text, setText] = useState11("");
|
|
37665
|
-
const items =
|
|
37662
|
+
const items = useMemo5(
|
|
37666
37663
|
() => [...new Set(Object.values(objectData).map((o) => o[h]))],
|
|
37667
37664
|
[objectData]
|
|
37668
37665
|
);
|
|
37669
37666
|
const [selected, setSelected] = useState11(items);
|
|
37670
|
-
const itemsFiltered =
|
|
37667
|
+
const itemsFiltered = useMemo5(
|
|
37671
37668
|
() => items.sort((a, b) => `${a}`.localeCompare(b)).filter((item) => {
|
|
37672
37669
|
if (!text) return true;
|
|
37673
37670
|
return `${item}`.toLowerCase().includes(text.toLowerCase());
|
|
@@ -37711,7 +37708,7 @@ function Filter({
|
|
|
37711
37708
|
}
|
|
37712
37709
|
}, [data]);
|
|
37713
37710
|
return /* @__PURE__ */ jsxs14("th", { className: "cursor-pointer", children: [
|
|
37714
|
-
/* @__PURE__ */
|
|
37711
|
+
/* @__PURE__ */ jsx23("div", { className: "relative", children: visible && /* @__PURE__ */ jsx23(
|
|
37715
37712
|
"div",
|
|
37716
37713
|
{
|
|
37717
37714
|
className: " w-full h-screen top-0 left-0 fixed ",
|
|
@@ -37732,13 +37729,13 @@ function Filter({
|
|
|
37732
37729
|
onClick: (e) => setVisible(!visible),
|
|
37733
37730
|
children: [
|
|
37734
37731
|
sort && //
|
|
37735
|
-
Object.keys(sort)[0] == h && ((sort == null ? void 0 : sort[h]) == "asc" ? /* @__PURE__ */
|
|
37736
|
-
/* @__PURE__ */
|
|
37737
|
-
selected.length < items.length && /* @__PURE__ */
|
|
37732
|
+
Object.keys(sort)[0] == h && ((sort == null ? void 0 : sort[h]) == "asc" ? /* @__PURE__ */ jsx23("div", { className: "text-green-300", children: /* @__PURE__ */ jsx23(OrderAsc, {}) }) : (sort == null ? void 0 : sort[h]) == "desc" && /* @__PURE__ */ jsx23("div", { className: "text-green-300", children: /* @__PURE__ */ jsx23(OrderDesc, {}) })),
|
|
37733
|
+
/* @__PURE__ */ jsx23("div", { children: h }),
|
|
37734
|
+
selected.length < items.length && /* @__PURE__ */ jsx23("div", { className: "text-red-500 ", children: /* @__PURE__ */ jsx23(FilterOffIcon, {}) })
|
|
37738
37735
|
]
|
|
37739
37736
|
}
|
|
37740
37737
|
),
|
|
37741
|
-
visible && /* @__PURE__ */
|
|
37738
|
+
visible && /* @__PURE__ */ jsx23(
|
|
37742
37739
|
"div",
|
|
37743
37740
|
{
|
|
37744
37741
|
className: "border shadow rounded bg-white p-1 absolute left-0 text-black",
|
|
@@ -37761,7 +37758,7 @@ function Filter({
|
|
|
37761
37758
|
},
|
|
37762
37759
|
className: "flex items-center gap-2 border p-1 hover:bg-blue-100",
|
|
37763
37760
|
children: [
|
|
37764
|
-
/* @__PURE__ */
|
|
37761
|
+
/* @__PURE__ */ jsx23(OrderAsc, {}),
|
|
37765
37762
|
" Ordenar de la A a la Z"
|
|
37766
37763
|
]
|
|
37767
37764
|
}
|
|
@@ -37783,7 +37780,7 @@ function Filter({
|
|
|
37783
37780
|
},
|
|
37784
37781
|
className: "flex items-center gap-2 border p-1 hover:bg-blue-100",
|
|
37785
37782
|
children: [
|
|
37786
|
-
/* @__PURE__ */
|
|
37783
|
+
/* @__PURE__ */ jsx23(OrderDesc, {}),
|
|
37787
37784
|
"Ordenar de la Z a la A"
|
|
37788
37785
|
]
|
|
37789
37786
|
}
|
|
@@ -37797,11 +37794,11 @@ function Filter({
|
|
|
37797
37794
|
},
|
|
37798
37795
|
children: [
|
|
37799
37796
|
"Borrar Filtro",
|
|
37800
|
-
/* @__PURE__ */
|
|
37797
|
+
/* @__PURE__ */ jsx23("div", { className: "text-white ", children: /* @__PURE__ */ jsx23(FilterOffIcon, {}) })
|
|
37801
37798
|
]
|
|
37802
37799
|
}
|
|
37803
37800
|
),
|
|
37804
|
-
/* @__PURE__ */
|
|
37801
|
+
/* @__PURE__ */ jsx23("div", { className: "", children: /* @__PURE__ */ jsx23(
|
|
37805
37802
|
"input",
|
|
37806
37803
|
{
|
|
37807
37804
|
className: "border shadow rounded p-2 w-full",
|
|
@@ -37820,8 +37817,8 @@ function Filter({
|
|
|
37820
37817
|
}
|
|
37821
37818
|
}
|
|
37822
37819
|
) }),
|
|
37823
|
-
/* @__PURE__ */
|
|
37824
|
-
/* @__PURE__ */
|
|
37820
|
+
/* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsxs14("label", { className: "flex gap-1 cursor-pointer px-1", children: [
|
|
37821
|
+
/* @__PURE__ */ jsx23(
|
|
37825
37822
|
"input",
|
|
37826
37823
|
{
|
|
37827
37824
|
type: "checkbox",
|
|
@@ -37837,9 +37834,9 @@ function Filter({
|
|
|
37837
37834
|
),
|
|
37838
37835
|
"(Seleccionar Todo)"
|
|
37839
37836
|
] }) }),
|
|
37840
|
-
/* @__PURE__ */
|
|
37841
|
-
return /* @__PURE__ */
|
|
37842
|
-
/* @__PURE__ */
|
|
37837
|
+
/* @__PURE__ */ jsx23("div", { className: "overflow-auto flex gap-1 flex-col p-1 border shadow rounded h-[300px]", children: itemsFiltered.map((item) => {
|
|
37838
|
+
return /* @__PURE__ */ jsx23("div", { className: "hover:bg-gray-100 ", children: /* @__PURE__ */ jsxs14("label", { className: "flex gap-1 cursor-pointer truncate", children: [
|
|
37839
|
+
/* @__PURE__ */ jsx23(
|
|
37843
37840
|
"input",
|
|
37844
37841
|
{
|
|
37845
37842
|
type: "checkbox",
|
|
@@ -37861,7 +37858,7 @@ function Filter({
|
|
|
37861
37858
|
] }) }, item);
|
|
37862
37859
|
}) }),
|
|
37863
37860
|
/* @__PURE__ */ jsxs14("div", { className: "flex justify-between px-1", children: [
|
|
37864
|
-
/* @__PURE__ */
|
|
37861
|
+
/* @__PURE__ */ jsx23(
|
|
37865
37862
|
"button",
|
|
37866
37863
|
{
|
|
37867
37864
|
className: "p-1 shadow rounded border bg-red-500 text-white",
|
|
@@ -37872,7 +37869,7 @@ function Filter({
|
|
|
37872
37869
|
children: "Cancelar"
|
|
37873
37870
|
}
|
|
37874
37871
|
),
|
|
37875
|
-
/* @__PURE__ */
|
|
37872
|
+
/* @__PURE__ */ jsx23(
|
|
37876
37873
|
"button",
|
|
37877
37874
|
{
|
|
37878
37875
|
className: "p-1 shadow rounded border bg-blue-500 text-white",
|
|
@@ -37891,7 +37888,7 @@ function Filter({
|
|
|
37891
37888
|
}
|
|
37892
37889
|
|
|
37893
37890
|
// src/table3/head.tsx
|
|
37894
|
-
import { jsx as
|
|
37891
|
+
import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
37895
37892
|
function TableHead({
|
|
37896
37893
|
headers,
|
|
37897
37894
|
selectItems,
|
|
@@ -37906,9 +37903,9 @@ function TableHead({
|
|
|
37906
37903
|
sort,
|
|
37907
37904
|
setSort
|
|
37908
37905
|
}) {
|
|
37909
|
-
return /* @__PURE__ */
|
|
37910
|
-
modal && /* @__PURE__ */
|
|
37911
|
-
selectItems && /* @__PURE__ */
|
|
37906
|
+
return /* @__PURE__ */ jsx24("thead", { children: /* @__PURE__ */ jsxs15("tr", { className: "bg-blue-500 text-white font-bold", children: [
|
|
37907
|
+
modal && /* @__PURE__ */ jsx24("th", { children: "-" }),
|
|
37908
|
+
selectItems && /* @__PURE__ */ jsx24("th", { children: /* @__PURE__ */ jsx24(
|
|
37912
37909
|
"input",
|
|
37913
37910
|
{
|
|
37914
37911
|
className: "m-2",
|
|
@@ -37936,7 +37933,7 @@ function TableHead({
|
|
|
37936
37933
|
) }),
|
|
37937
37934
|
Object.values(headers).map((h) => {
|
|
37938
37935
|
if (h.startsWith("_")) return null;
|
|
37939
|
-
return /* @__PURE__ */
|
|
37936
|
+
return /* @__PURE__ */ jsx24(
|
|
37940
37937
|
Filter,
|
|
37941
37938
|
{
|
|
37942
37939
|
objectData,
|
|
@@ -37959,7 +37956,7 @@ import { useState as useState12 } from "react";
|
|
|
37959
37956
|
|
|
37960
37957
|
// src/table3/tr.tsx
|
|
37961
37958
|
import React7 from "react";
|
|
37962
|
-
import { jsx as
|
|
37959
|
+
import { jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
37963
37960
|
function TR({
|
|
37964
37961
|
handlers,
|
|
37965
37962
|
setObjectData,
|
|
@@ -37987,7 +37984,7 @@ function TR({
|
|
|
37987
37984
|
setSelected(selected == index ? -1 : index);
|
|
37988
37985
|
},
|
|
37989
37986
|
children: [
|
|
37990
|
-
modal && /* @__PURE__ */
|
|
37987
|
+
modal && /* @__PURE__ */ jsx25("th", { className: "border", children: /* @__PURE__ */ jsx25(
|
|
37991
37988
|
"button",
|
|
37992
37989
|
{
|
|
37993
37990
|
className: "p-1 border shadow-rounded bg-blue-500 rounded text-white",
|
|
@@ -37996,10 +37993,10 @@ function TR({
|
|
|
37996
37993
|
(_a = modalRef.current) == null ? void 0 : _a.showModal();
|
|
37997
37994
|
setDialogRow(row);
|
|
37998
37995
|
},
|
|
37999
|
-
children: /* @__PURE__ */
|
|
37996
|
+
children: /* @__PURE__ */ jsx25(EditIcon2, {})
|
|
38000
37997
|
}
|
|
38001
37998
|
) }),
|
|
38002
|
-
selectItems && /* @__PURE__ */
|
|
37999
|
+
selectItems && /* @__PURE__ */ jsx25("th", { className: "border", children: /* @__PURE__ */ jsx25(
|
|
38003
38000
|
"input",
|
|
38004
38001
|
{
|
|
38005
38002
|
type: "checkbox",
|
|
@@ -38067,13 +38064,13 @@ function TR({
|
|
|
38067
38064
|
return acc;
|
|
38068
38065
|
}, {})
|
|
38069
38066
|
});
|
|
38070
|
-
return /* @__PURE__ */
|
|
38067
|
+
return /* @__PURE__ */ jsx25("td", { className: `text-black `, children: cloned }, h);
|
|
38071
38068
|
}
|
|
38072
|
-
return symbols && (symbols == null ? void 0 : symbols[h]) ? /* @__PURE__ */
|
|
38069
|
+
return symbols && (symbols == null ? void 0 : symbols[h]) ? /* @__PURE__ */ jsx25("td", { className: `text-center border max-w-[${colSize}px] `, children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1 w-full", children: [
|
|
38073
38070
|
symbols[h],
|
|
38074
38071
|
" ",
|
|
38075
38072
|
row[h]
|
|
38076
|
-
] }) }, h) : /* @__PURE__ */
|
|
38073
|
+
] }) }, h) : /* @__PURE__ */ jsx25("td", { className: `text-center border max-w-[${colSize}px]`, children: row[h] }, h);
|
|
38077
38074
|
})
|
|
38078
38075
|
]
|
|
38079
38076
|
},
|
|
@@ -38082,7 +38079,7 @@ function TR({
|
|
|
38082
38079
|
}
|
|
38083
38080
|
|
|
38084
38081
|
// src/table3/body.tsx
|
|
38085
|
-
import { jsx as
|
|
38082
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
38086
38083
|
function TableBody({
|
|
38087
38084
|
objectData,
|
|
38088
38085
|
setObjectData,
|
|
@@ -38126,7 +38123,7 @@ function TableBody({
|
|
|
38126
38123
|
return key >= start && key < end;
|
|
38127
38124
|
}).map(([id, k], index) => {
|
|
38128
38125
|
const row = objectData[id];
|
|
38129
|
-
return /* @__PURE__ */
|
|
38126
|
+
return /* @__PURE__ */ jsx26(
|
|
38130
38127
|
TR,
|
|
38131
38128
|
{
|
|
38132
38129
|
...{
|
|
@@ -38151,11 +38148,11 @@ function TableBody({
|
|
|
38151
38148
|
id
|
|
38152
38149
|
);
|
|
38153
38150
|
});
|
|
38154
|
-
return /* @__PURE__ */
|
|
38151
|
+
return /* @__PURE__ */ jsx26("tbody", { children: sorted });
|
|
38155
38152
|
}
|
|
38156
38153
|
|
|
38157
38154
|
// src/table3/panel.tsx
|
|
38158
|
-
import { jsx as
|
|
38155
|
+
import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
38159
38156
|
function Panel({
|
|
38160
38157
|
page,
|
|
38161
38158
|
setPage,
|
|
@@ -38177,7 +38174,7 @@ function Panel({
|
|
|
38177
38174
|
},
|
|
38178
38175
|
children: [
|
|
38179
38176
|
" ",
|
|
38180
|
-
/* @__PURE__ */
|
|
38177
|
+
/* @__PURE__ */ jsx27(SaveIcon, {}),
|
|
38181
38178
|
"Guardar"
|
|
38182
38179
|
]
|
|
38183
38180
|
}
|
|
@@ -38196,22 +38193,22 @@ function Panel({
|
|
|
38196
38193
|
);
|
|
38197
38194
|
},
|
|
38198
38195
|
children: [
|
|
38199
|
-
/* @__PURE__ */
|
|
38196
|
+
/* @__PURE__ */ jsx27(ExcelIcon, {}),
|
|
38200
38197
|
"Exportar"
|
|
38201
38198
|
]
|
|
38202
38199
|
}
|
|
38203
38200
|
)
|
|
38204
38201
|
] }),
|
|
38205
38202
|
maxItems !== Infinity && /* @__PURE__ */ jsxs17("div", { className: "flex gap-2 items-center text-2xl", children: [
|
|
38206
|
-
/* @__PURE__ */
|
|
38207
|
-
/* @__PURE__ */
|
|
38203
|
+
/* @__PURE__ */ jsx27("button", { onClick: () => setPage(1), disabled: page === 1, children: "\u23EE" }),
|
|
38204
|
+
/* @__PURE__ */ jsx27("button", { onClick: () => setPage(page - 1), disabled: page === 1, children: "\u25C0" }),
|
|
38208
38205
|
/* @__PURE__ */ jsxs17("span", { className: "text-sm", children: [
|
|
38209
38206
|
"P\xE1gina ",
|
|
38210
38207
|
page,
|
|
38211
38208
|
" / ",
|
|
38212
38209
|
totalPages
|
|
38213
38210
|
] }),
|
|
38214
|
-
/* @__PURE__ */
|
|
38211
|
+
/* @__PURE__ */ jsx27(
|
|
38215
38212
|
"button",
|
|
38216
38213
|
{
|
|
38217
38214
|
onClick: () => setPage(page + 1),
|
|
@@ -38219,7 +38216,7 @@ function Panel({
|
|
|
38219
38216
|
children: "\u25B6"
|
|
38220
38217
|
}
|
|
38221
38218
|
),
|
|
38222
|
-
/* @__PURE__ */
|
|
38219
|
+
/* @__PURE__ */ jsx27(
|
|
38223
38220
|
"button",
|
|
38224
38221
|
{
|
|
38225
38222
|
onClick: () => setPage(totalPages),
|
|
@@ -38232,7 +38229,7 @@ function Panel({
|
|
|
38232
38229
|
}
|
|
38233
38230
|
|
|
38234
38231
|
// src/table3/footer.tsx
|
|
38235
|
-
import { jsx as
|
|
38232
|
+
import { jsx as jsx28, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
38236
38233
|
function TableFooter({
|
|
38237
38234
|
objectData,
|
|
38238
38235
|
headers,
|
|
@@ -38257,9 +38254,9 @@ function TableFooter({
|
|
|
38257
38254
|
return null;
|
|
38258
38255
|
}
|
|
38259
38256
|
}
|
|
38260
|
-
return footer && /* @__PURE__ */
|
|
38261
|
-
selectItems && /* @__PURE__ */
|
|
38262
|
-
modal && /* @__PURE__ */
|
|
38257
|
+
return footer && /* @__PURE__ */ jsx28("tfoot", { children: /* @__PURE__ */ jsxs18("tr", { className: "bg-blue-500 text-white", children: [
|
|
38258
|
+
selectItems && /* @__PURE__ */ jsx28("th", {}),
|
|
38259
|
+
modal && /* @__PURE__ */ jsx28("th", {}),
|
|
38263
38260
|
headers.map((header) => {
|
|
38264
38261
|
if (header.startsWith("_")) {
|
|
38265
38262
|
return null;
|
|
@@ -38268,16 +38265,16 @@ function TableFooter({
|
|
|
38268
38265
|
symbols[header],
|
|
38269
38266
|
" ",
|
|
38270
38267
|
operacion(footer[header], header)
|
|
38271
|
-
] }, header) : /* @__PURE__ */
|
|
38268
|
+
] }, header) : /* @__PURE__ */ jsx28("th", { children: operacion(footer[header], header) }, header);
|
|
38272
38269
|
}
|
|
38273
|
-
return /* @__PURE__ */
|
|
38270
|
+
return /* @__PURE__ */ jsx28("th", {}, header);
|
|
38274
38271
|
})
|
|
38275
38272
|
] }) });
|
|
38276
38273
|
}
|
|
38277
38274
|
|
|
38278
38275
|
// src/table3/dialog.tsx
|
|
38279
|
-
import React8, { useMemo as
|
|
38280
|
-
import { jsx as
|
|
38276
|
+
import React8, { useMemo as useMemo6 } from "react";
|
|
38277
|
+
import { jsx as jsx29, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
38281
38278
|
function Dialog3({
|
|
38282
38279
|
modalRef,
|
|
38283
38280
|
children,
|
|
@@ -38293,7 +38290,7 @@ function Dialog3({
|
|
|
38293
38290
|
var _a;
|
|
38294
38291
|
return (_a = modalRef.current) == null ? void 0 : _a.close();
|
|
38295
38292
|
};
|
|
38296
|
-
const clonedModal =
|
|
38293
|
+
const clonedModal = useMemo6(() => {
|
|
38297
38294
|
if (dialogRow && React8.isValidElement(children)) {
|
|
38298
38295
|
return React8.cloneElement(children, {
|
|
38299
38296
|
key: JSON.stringify(dialogRow),
|
|
@@ -38312,8 +38309,8 @@ function Dialog3({
|
|
|
38312
38309
|
className: "p-6 rounded-xl shadow-2xl backdrop:bg-black/50 w-[100%] h-screen",
|
|
38313
38310
|
children: [
|
|
38314
38311
|
/* @__PURE__ */ jsxs19("div", { className: "flex justify-between items-center mb-4", children: [
|
|
38315
|
-
/* @__PURE__ */
|
|
38316
|
-
/* @__PURE__ */
|
|
38312
|
+
/* @__PURE__ */ jsx29("div", {}),
|
|
38313
|
+
/* @__PURE__ */ jsx29(
|
|
38317
38314
|
"button",
|
|
38318
38315
|
{
|
|
38319
38316
|
onClick: () => {
|
|
@@ -38325,7 +38322,7 @@ function Dialog3({
|
|
|
38325
38322
|
}
|
|
38326
38323
|
)
|
|
38327
38324
|
] }),
|
|
38328
|
-
/* @__PURE__ */
|
|
38325
|
+
/* @__PURE__ */ jsx29("div", { className: "text-gray-700", children: clonedModal })
|
|
38329
38326
|
]
|
|
38330
38327
|
}
|
|
38331
38328
|
);
|
|
@@ -38333,7 +38330,7 @@ function Dialog3({
|
|
|
38333
38330
|
var dialog_default = Dialog3;
|
|
38334
38331
|
|
|
38335
38332
|
// src/table3/index.tsx
|
|
38336
|
-
import { jsx as
|
|
38333
|
+
import { jsx as jsx30, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
38337
38334
|
function Table3({
|
|
38338
38335
|
data,
|
|
38339
38336
|
selectItems,
|
|
@@ -38396,7 +38393,7 @@ function Table3({
|
|
|
38396
38393
|
setObjectData(data);
|
|
38397
38394
|
setPage(1);
|
|
38398
38395
|
}, [data]);
|
|
38399
|
-
const headers =
|
|
38396
|
+
const headers = useMemo7(() => {
|
|
38400
38397
|
if (!objectData) return [];
|
|
38401
38398
|
return [
|
|
38402
38399
|
...new Set(
|
|
@@ -38404,12 +38401,12 @@ function Table3({
|
|
|
38404
38401
|
)
|
|
38405
38402
|
];
|
|
38406
38403
|
}, [objectData]);
|
|
38407
|
-
const totalPages =
|
|
38404
|
+
const totalPages = useMemo7(() => {
|
|
38408
38405
|
if (!objectData) return 0;
|
|
38409
38406
|
return maxItems ? Math.ceil(Object.keys(objectData).length / maxItems) : 1;
|
|
38410
38407
|
}, [objectData, maxItems]);
|
|
38411
38408
|
const [sort, setSort] = useState13(sortBy);
|
|
38412
|
-
const modalRef =
|
|
38409
|
+
const modalRef = useRef4(null);
|
|
38413
38410
|
const [dialogRow, setDialogRow] = useState13({});
|
|
38414
38411
|
const context = {
|
|
38415
38412
|
objectData,
|
|
@@ -38446,7 +38443,7 @@ function Table3({
|
|
|
38446
38443
|
const style = (props == null ? void 0 : props.style) ? { ...props.style, tableLayout: "fixed" } : { tableLayout: "fixed" };
|
|
38447
38444
|
if (!objectData) return null;
|
|
38448
38445
|
return /* @__PURE__ */ jsxs20("div", { className: "border shadow rounded m-1 p-1 bg-white", children: [
|
|
38449
|
-
modal && /* @__PURE__ */
|
|
38446
|
+
modal && /* @__PURE__ */ jsx30(
|
|
38450
38447
|
dialog_default,
|
|
38451
38448
|
{
|
|
38452
38449
|
modalRef,
|
|
@@ -38456,12 +38453,12 @@ function Table3({
|
|
|
38456
38453
|
children: modal
|
|
38457
38454
|
}
|
|
38458
38455
|
),
|
|
38459
|
-
header && /* @__PURE__ */
|
|
38460
|
-
/* @__PURE__ */
|
|
38456
|
+
header && /* @__PURE__ */ jsx30("div", { className: "font-bold text-2xl py-5 px-2 bg-blue-50", children: header }),
|
|
38457
|
+
/* @__PURE__ */ jsx30(Panel, { ...context }),
|
|
38461
38458
|
/* @__PURE__ */ jsxs20("table", { ...props, style, children: [
|
|
38462
|
-
/* @__PURE__ */
|
|
38463
|
-
/* @__PURE__ */
|
|
38464
|
-
/* @__PURE__ */
|
|
38459
|
+
/* @__PURE__ */ jsx30(TableHead, { ...context }),
|
|
38460
|
+
/* @__PURE__ */ jsx30(TableBody, { ...context }),
|
|
38461
|
+
/* @__PURE__ */ jsx30(TableFooter, { ...context })
|
|
38465
38462
|
] })
|
|
38466
38463
|
] });
|
|
38467
38464
|
}
|
package/package.json
CHANGED
package/src/modal/index.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { ReactElement, cloneElement, useEffect, useMemo } from "react";
|
|
4
|
+
|
|
3
5
|
import usePopup from "../pop";
|
|
4
6
|
|
|
5
7
|
export type PopupColor =
|
|
@@ -25,27 +27,36 @@ export default function Modal({
|
|
|
25
27
|
title?: string;
|
|
26
28
|
}) {
|
|
27
29
|
const pop = usePopup();
|
|
30
|
+
|
|
28
31
|
const hide = () => pop.close(false);
|
|
29
32
|
|
|
30
|
-
//
|
|
31
|
-
const
|
|
33
|
+
// key dinámica para forzar remount cuando cambie el children
|
|
34
|
+
const content = useMemo(() => {
|
|
35
|
+
return cloneElement(children, {
|
|
36
|
+
hide,
|
|
37
|
+
key: crypto.randomUUID(),
|
|
38
|
+
});
|
|
39
|
+
}, [children]);
|
|
32
40
|
|
|
41
|
+
// actualizar SOLO si el modal está abierto
|
|
33
42
|
useEffect(() => {
|
|
34
|
-
pop.updateMessage(
|
|
35
|
-
}, [
|
|
43
|
+
pop.updateMessage(content);
|
|
44
|
+
}, [content]);
|
|
36
45
|
|
|
37
46
|
const props = button?.props;
|
|
38
|
-
const
|
|
47
|
+
const originalOnClick = props?.onClick;
|
|
39
48
|
|
|
40
49
|
return (
|
|
41
50
|
<>
|
|
42
51
|
{cloneElement(button, {
|
|
43
|
-
onClick: (e) => {
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
onClick: async (e) => {
|
|
53
|
+
originalOnClick?.(e as any);
|
|
54
|
+
|
|
55
|
+
await pop.modal(content, color, false, true);
|
|
46
56
|
},
|
|
47
57
|
})}
|
|
48
|
-
|
|
58
|
+
|
|
59
|
+
<pop.PopupComponent />
|
|
49
60
|
</>
|
|
50
61
|
);
|
|
51
62
|
}
|
package/src/pop/index.tsx
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
// usePopup.ts - Solución definitiva
|
|
2
1
|
"use client";
|
|
3
2
|
|
|
4
|
-
import { useState, useCallback,
|
|
3
|
+
import { useState, useCallback, type ReactNode } from "react";
|
|
5
4
|
import { PopupColor, PopupState } from "./types";
|
|
6
5
|
import { PopupOverlay } from "./overlay";
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const INITIAL_STATE: PopupStateWithoutMessage = {
|
|
7
|
+
const INITIAL_STATE: PopupState = {
|
|
11
8
|
type: "alert",
|
|
12
9
|
visible: false,
|
|
13
10
|
inputValue: "",
|
|
14
11
|
color: "primary",
|
|
15
12
|
icons: true,
|
|
16
13
|
full: false,
|
|
14
|
+
message: null,
|
|
17
15
|
};
|
|
18
16
|
|
|
19
17
|
export default function usePopup() {
|
|
20
|
-
const [popup, setPopup] = useState<
|
|
21
|
-
// El message vive FUERA del estado para no quedar congelado
|
|
22
|
-
const messageRef = useRef<ReactNode>(null);
|
|
18
|
+
const [popup, setPopup] = useState<PopupState>(INITIAL_STATE);
|
|
23
19
|
|
|
24
20
|
const open = useCallback(
|
|
25
21
|
(partial: Omit<PopupState, "visible" | "inputValue">) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
setPopup({
|
|
23
|
+
...partial,
|
|
24
|
+
visible: true,
|
|
25
|
+
inputValue: "",
|
|
26
|
+
});
|
|
29
27
|
},
|
|
30
28
|
[],
|
|
31
29
|
);
|
|
@@ -34,10 +32,22 @@ export default function usePopup() {
|
|
|
34
32
|
setPopup((prev) => {
|
|
35
33
|
if (confirmed) prev.onConfirm?.(value);
|
|
36
34
|
else prev.onCancel?.();
|
|
37
|
-
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
...prev,
|
|
38
|
+
visible: false,
|
|
39
|
+
inputValue: "",
|
|
40
|
+
};
|
|
38
41
|
});
|
|
39
42
|
}, []);
|
|
40
43
|
|
|
44
|
+
const updateMessage = useCallback((message: ReactNode) => {
|
|
45
|
+
setPopup((prev) => ({
|
|
46
|
+
...prev,
|
|
47
|
+
message,
|
|
48
|
+
}));
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
41
51
|
const alert = useCallback(
|
|
42
52
|
(message: string, color: PopupColor = "primary"): Promise<void> =>
|
|
43
53
|
new Promise((resolve) =>
|
|
@@ -47,6 +57,8 @@ export default function usePopup() {
|
|
|
47
57
|
color,
|
|
48
58
|
onConfirm: () => resolve(),
|
|
49
59
|
onCancel: () => resolve(),
|
|
60
|
+
icons: true,
|
|
61
|
+
full: false,
|
|
50
62
|
}),
|
|
51
63
|
),
|
|
52
64
|
[open],
|
|
@@ -56,74 +68,47 @@ export default function usePopup() {
|
|
|
56
68
|
(
|
|
57
69
|
message: ReactNode,
|
|
58
70
|
color: PopupColor = "primary",
|
|
59
|
-
icons
|
|
60
|
-
full
|
|
71
|
+
icons = false,
|
|
72
|
+
full = false,
|
|
61
73
|
): Promise<void> =>
|
|
62
74
|
new Promise((resolve) =>
|
|
63
75
|
open({
|
|
64
76
|
type: "modal",
|
|
65
77
|
message,
|
|
66
78
|
color,
|
|
67
|
-
onConfirm: () => resolve(),
|
|
68
|
-
onCancel: () => resolve(),
|
|
69
79
|
icons,
|
|
70
80
|
full,
|
|
81
|
+
onConfirm: () => resolve(),
|
|
82
|
+
onCancel: () => resolve(),
|
|
71
83
|
}),
|
|
72
84
|
),
|
|
73
85
|
[open],
|
|
74
86
|
);
|
|
75
87
|
|
|
76
|
-
const
|
|
77
|
-
(
|
|
78
|
-
new Promise((resolve) =>
|
|
79
|
-
open({
|
|
80
|
-
type: "confirm",
|
|
81
|
-
message,
|
|
82
|
-
color,
|
|
83
|
-
onConfirm: () => resolve(true),
|
|
84
|
-
onCancel: () => resolve(false),
|
|
85
|
-
}),
|
|
86
|
-
),
|
|
87
|
-
[open],
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const prompt = useCallback(
|
|
91
|
-
(message: string, color: PopupColor = "primary"): Promise<string | null> =>
|
|
92
|
-
new Promise((resolve) =>
|
|
93
|
-
open({
|
|
94
|
-
type: "prompt",
|
|
95
|
-
message,
|
|
96
|
-
color,
|
|
97
|
-
onConfirm: (value) => resolve(value ?? ""),
|
|
98
|
-
onCancel: () => resolve(null),
|
|
99
|
-
}),
|
|
100
|
-
),
|
|
101
|
-
[open],
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
// ✅ Actualiza la ref en cada render cuando el modal está abierto
|
|
105
|
-
// Esto permite que cambios en el children del padre se reflejen
|
|
106
|
-
const updateMessage = useCallback((message: ReactNode) => {
|
|
107
|
-
messageRef.current = message;
|
|
108
|
-
// Fuerza re-render del PopupComponent
|
|
109
|
-
setPopup((prev) => ({ ...prev }));
|
|
110
|
-
}, []);
|
|
88
|
+
const PopupComponent = () => {
|
|
89
|
+
if (!popup.visible) return null;
|
|
111
90
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
91
|
+
return (
|
|
92
|
+
<PopupOverlay
|
|
93
|
+
popup={popup}
|
|
94
|
+
onClose={close}
|
|
95
|
+
onInputChange={(v) =>
|
|
96
|
+
setPopup((prev) => ({
|
|
97
|
+
...prev,
|
|
98
|
+
inputValue: v,
|
|
99
|
+
}))
|
|
100
|
+
}
|
|
101
|
+
/>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
119
104
|
|
|
120
105
|
return {
|
|
121
106
|
alert,
|
|
122
107
|
confirm,
|
|
123
108
|
prompt,
|
|
124
109
|
modal,
|
|
125
|
-
PopupComponent,
|
|
126
110
|
close,
|
|
127
111
|
updateMessage,
|
|
112
|
+
PopupComponent,
|
|
128
113
|
};
|
|
129
114
|
}
|