next-recomponents 2.0.1 → 2.0.2
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.js +363 -410
- package/dist/index.mjs +363 -410
- package/package.json +1 -1
- package/src/table/index.tsx +46 -29
- package/tsconfig.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,39 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __objRest = (source, exclude) => {
|
|
26
|
-
var target = {};
|
|
27
|
-
for (var prop in source)
|
|
28
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
if (source != null && __getOwnPropSymbols)
|
|
31
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
-
target[prop] = source[prop];
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
};
|
|
37
8
|
var __commonJS = (cb, mod) => function __require() {
|
|
38
9
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
39
10
|
};
|
|
@@ -1543,9 +1514,10 @@ var require_route_pattern_normalizer = __commonJS({
|
|
|
1543
1514
|
"prefix" in token && "suffix" in token && // Both prefix and suffix must be empty strings
|
|
1544
1515
|
// This is what causes the validation error in path-to-regexp
|
|
1545
1516
|
token.prefix === "" && token.suffix === "") {
|
|
1546
|
-
return
|
|
1517
|
+
return {
|
|
1518
|
+
...token,
|
|
1547
1519
|
prefix: "/"
|
|
1548
|
-
}
|
|
1520
|
+
};
|
|
1549
1521
|
}
|
|
1550
1522
|
return token;
|
|
1551
1523
|
});
|
|
@@ -1637,9 +1609,10 @@ var require_route_match_utils = __commonJS({
|
|
|
1637
1609
|
return (pathname) => {
|
|
1638
1610
|
const result = originalMatcher(pathname);
|
|
1639
1611
|
if (!result) return false;
|
|
1640
|
-
return
|
|
1612
|
+
return {
|
|
1613
|
+
...result,
|
|
1641
1614
|
params: (0, _routepatternnormalizer.stripParameterSeparators)(result.params)
|
|
1642
|
-
}
|
|
1615
|
+
};
|
|
1643
1616
|
};
|
|
1644
1617
|
}
|
|
1645
1618
|
function safeRouteMatcher(matcherFn) {
|
|
@@ -2003,7 +1976,8 @@ var require_constants = __commonJS({
|
|
|
2003
1976
|
*/
|
|
2004
1977
|
pagesDirNode: "pages-dir-node"
|
|
2005
1978
|
};
|
|
2006
|
-
var WEBPACK_LAYERS =
|
|
1979
|
+
var WEBPACK_LAYERS = {
|
|
1980
|
+
...WEBPACK_LAYERS_NAMES,
|
|
2007
1981
|
GROUP: {
|
|
2008
1982
|
builtinReact: [
|
|
2009
1983
|
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
@@ -2041,7 +2015,7 @@ var require_constants = __commonJS({
|
|
|
2041
2015
|
WEBPACK_LAYERS_NAMES.actionBrowser
|
|
2042
2016
|
]
|
|
2043
2017
|
}
|
|
2044
|
-
}
|
|
2018
|
+
};
|
|
2045
2019
|
var WEBPACK_RESOURCE_QUERIES = {
|
|
2046
2020
|
edgeSSREntry: "__next_edge_ssr_entry__",
|
|
2047
2021
|
metadata: "__next_metadata__",
|
|
@@ -2363,10 +2337,11 @@ var require_route_regex = __commonJS({
|
|
|
2363
2337
|
if (!options.excludeOptionalTrailingSlash) {
|
|
2364
2338
|
namedRegex += "(?:/)?";
|
|
2365
2339
|
}
|
|
2366
|
-
return
|
|
2340
|
+
return {
|
|
2341
|
+
...getRouteRegex(normalizedRoute, options),
|
|
2367
2342
|
namedRegex: "^" + namedRegex + "$",
|
|
2368
2343
|
routeKeys: result.routeKeys
|
|
2369
|
-
}
|
|
2344
|
+
};
|
|
2370
2345
|
}
|
|
2371
2346
|
function getNamedMiddlewareRegex(normalizedRoute, options) {
|
|
2372
2347
|
const { parameterizedRoute } = getParametrizedRoute(normalizedRoute, false, false);
|
|
@@ -3211,7 +3186,7 @@ var require_link = __commonJS({
|
|
|
3211
3186
|
}
|
|
3212
3187
|
var Link2 = /* @__PURE__ */ _react.default.forwardRef(function LinkComponent(props, forwardedRef) {
|
|
3213
3188
|
let children;
|
|
3214
|
-
const
|
|
3189
|
+
const { href: hrefProp, as: asProp, children: childrenProp, prefetch: prefetchProp = null, passHref, replace, shallow, scroll, locale, onClick, onNavigate, onMouseEnter: onMouseEnterProp, onTouchStart: onTouchStartProp, legacyBehavior = false, ...restProps } = props;
|
|
3215
3190
|
children = childrenProp;
|
|
3216
3191
|
if (legacyBehavior && (typeof children === "string" || typeof children === "number")) {
|
|
3217
3192
|
children = /* @__PURE__ */ (0, _jsxruntime.jsx)("a", {
|
|
@@ -3480,9 +3455,11 @@ var require_link = __commonJS({
|
|
|
3480
3455
|
}
|
|
3481
3456
|
return /* @__PURE__ */ _react.default.cloneElement(child, childProps);
|
|
3482
3457
|
}
|
|
3483
|
-
return /* @__PURE__ */ (0, _jsxruntime.jsx)("a",
|
|
3458
|
+
return /* @__PURE__ */ (0, _jsxruntime.jsx)("a", {
|
|
3459
|
+
...restProps,
|
|
3460
|
+
...childProps,
|
|
3484
3461
|
children
|
|
3485
|
-
})
|
|
3462
|
+
});
|
|
3486
3463
|
});
|
|
3487
3464
|
var LinkStatusContext = /* @__PURE__ */ (0, _react.createContext)({
|
|
3488
3465
|
// We do not support link status in the Pages Router, so we always return false
|
|
@@ -3545,63 +3522,53 @@ var catColor = {
|
|
|
3545
3522
|
|
|
3546
3523
|
// src/alert/index.tsx
|
|
3547
3524
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
3548
|
-
function Alert(
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
"color",
|
|
3554
|
-
"children"
|
|
3555
|
-
]);
|
|
3525
|
+
function Alert({
|
|
3526
|
+
color = "primary",
|
|
3527
|
+
children,
|
|
3528
|
+
...props
|
|
3529
|
+
}) {
|
|
3556
3530
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3557
3531
|
"div",
|
|
3558
|
-
|
|
3559
|
-
className: [catColor[color], "p-2 rounded shadow border"].join(" ")
|
|
3560
|
-
|
|
3532
|
+
{
|
|
3533
|
+
className: [catColor[color], "p-2 rounded shadow border"].join(" "),
|
|
3534
|
+
...props,
|
|
3561
3535
|
children
|
|
3562
|
-
}
|
|
3536
|
+
}
|
|
3563
3537
|
);
|
|
3564
3538
|
}
|
|
3565
3539
|
|
|
3566
3540
|
// src/button/index.tsx
|
|
3567
3541
|
var import_react = require("react");
|
|
3568
3542
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
3569
|
-
function Button(
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
"className",
|
|
3580
|
-
"size",
|
|
3581
|
-
"color",
|
|
3582
|
-
"children",
|
|
3583
|
-
"icon",
|
|
3584
|
-
"disabled",
|
|
3585
|
-
"full"
|
|
3586
|
-
]);
|
|
3543
|
+
function Button({
|
|
3544
|
+
className,
|
|
3545
|
+
size = "small",
|
|
3546
|
+
color = "primary",
|
|
3547
|
+
children,
|
|
3548
|
+
icon,
|
|
3549
|
+
disabled,
|
|
3550
|
+
full = false,
|
|
3551
|
+
...props
|
|
3552
|
+
}) {
|
|
3587
3553
|
const [isLoading, setIsloading] = (0, import_react.useState)(false);
|
|
3588
3554
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
3589
3555
|
"button",
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3556
|
+
{
|
|
3557
|
+
...Object.assign(
|
|
3558
|
+
{},
|
|
3559
|
+
...Object.keys(props).map((prop) => {
|
|
3560
|
+
const originalHandler = props[prop];
|
|
3561
|
+
const newProp = { [prop]: originalHandler };
|
|
3562
|
+
if (prop.startsWith("on") && typeof originalHandler === "function") {
|
|
3563
|
+
newProp[prop] = async (e) => {
|
|
3564
|
+
setIsloading(true);
|
|
3565
|
+
originalHandler && await originalHandler(e);
|
|
3566
|
+
setIsloading(false);
|
|
3567
|
+
};
|
|
3568
|
+
}
|
|
3569
|
+
return newProp;
|
|
3570
|
+
})
|
|
3571
|
+
),
|
|
3605
3572
|
className: [
|
|
3606
3573
|
className,
|
|
3607
3574
|
"p-2 border shadow rounded flex gap-1 justify-center items-center",
|
|
@@ -3613,7 +3580,7 @@ function Button(_a) {
|
|
|
3613
3580
|
icon,
|
|
3614
3581
|
children
|
|
3615
3582
|
]
|
|
3616
|
-
}
|
|
3583
|
+
}
|
|
3617
3584
|
);
|
|
3618
3585
|
}
|
|
3619
3586
|
|
|
@@ -3839,30 +3806,24 @@ var import_react3 = __toESM(require("react"));
|
|
|
3839
3806
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
3840
3807
|
function useFormValues(initial) {
|
|
3841
3808
|
const reducer = (state, action) => {
|
|
3842
|
-
return
|
|
3809
|
+
return { ...state, ...action };
|
|
3843
3810
|
};
|
|
3844
3811
|
return (0, import_react3.useReducer)(reducer, initial);
|
|
3845
3812
|
}
|
|
3846
|
-
function Form(
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
"onSubmit",
|
|
3855
|
-
"state",
|
|
3856
|
-
"invalidMessage",
|
|
3857
|
-
"children",
|
|
3858
|
-
"loader"
|
|
3859
|
-
]);
|
|
3813
|
+
function Form({
|
|
3814
|
+
onSubmit,
|
|
3815
|
+
state,
|
|
3816
|
+
invalidMessage = "Existen valores inv\xE1lidos en el formulario",
|
|
3817
|
+
children,
|
|
3818
|
+
loader = "Loading...",
|
|
3819
|
+
...otherProps
|
|
3820
|
+
}) {
|
|
3860
3821
|
const [isLoading, setIsLoading] = (0, import_react3.useState)(false);
|
|
3861
3822
|
const ref = (0, import_react3.useRef)(null);
|
|
3862
3823
|
const [hvalues, setHValues] = state || (0, import_react3.useState)({});
|
|
3863
3824
|
(0, import_react3.useEffect)(() => {
|
|
3864
3825
|
if (ref == null ? void 0 : ref.current) {
|
|
3865
|
-
const newValues =
|
|
3826
|
+
const newValues = { ...hvalues };
|
|
3866
3827
|
const formData = new FormData(ref.current);
|
|
3867
3828
|
for (let [k, v] of formData.entries()) {
|
|
3868
3829
|
if (!newValues[k]) {
|
|
@@ -3875,8 +3836,8 @@ function Form(_a) {
|
|
|
3875
3836
|
}
|
|
3876
3837
|
}, [state, ref]);
|
|
3877
3838
|
function hasErrors() {
|
|
3878
|
-
var
|
|
3879
|
-
const hasInvalids = (
|
|
3839
|
+
var _a;
|
|
3840
|
+
const hasInvalids = (_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.querySelectorAll(".invalid");
|
|
3880
3841
|
if (hasInvalids && (hasInvalids == null ? void 0 : hasInvalids.length) > 0) {
|
|
3881
3842
|
return true;
|
|
3882
3843
|
}
|
|
@@ -3884,7 +3845,8 @@ function Form(_a) {
|
|
|
3884
3845
|
}
|
|
3885
3846
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3886
3847
|
"form",
|
|
3887
|
-
|
|
3848
|
+
{
|
|
3849
|
+
...otherProps,
|
|
3888
3850
|
ref,
|
|
3889
3851
|
onSubmit: async (e) => {
|
|
3890
3852
|
e.preventDefault();
|
|
@@ -3894,19 +3856,19 @@ function Form(_a) {
|
|
|
3894
3856
|
}
|
|
3895
3857
|
if (onSubmit) {
|
|
3896
3858
|
setIsLoading(true);
|
|
3897
|
-
await onSubmit(
|
|
3859
|
+
await onSubmit({ ...e, values: hvalues });
|
|
3898
3860
|
setIsLoading(false);
|
|
3899
3861
|
}
|
|
3900
3862
|
},
|
|
3901
3863
|
children: [
|
|
3902
3864
|
import_react3.default.Children.map(children, (child) => {
|
|
3903
3865
|
if (import_react3.default.isValidElement(child)) {
|
|
3904
|
-
const props = (child == null ? void 0 : child.props) ?
|
|
3866
|
+
const props = (child == null ? void 0 : child.props) ? { ...child.props } : {};
|
|
3905
3867
|
try {
|
|
3906
3868
|
return import_react3.default.cloneElement(child, {
|
|
3907
3869
|
value: hvalues[props.name] || "",
|
|
3908
3870
|
onChange: (e) => {
|
|
3909
|
-
setHValues(
|
|
3871
|
+
setHValues({ ...hvalues, [props.name]: e.target.value });
|
|
3910
3872
|
(props == null ? void 0 : props.onChange) && props.onChange(e);
|
|
3911
3873
|
}
|
|
3912
3874
|
});
|
|
@@ -3918,24 +3880,19 @@ function Form(_a) {
|
|
|
3918
3880
|
}),
|
|
3919
3881
|
isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "fixed top-0 left-0 w-full h-screen flex items-center justify-center bg-white bg-opacity-50", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: loader }) })
|
|
3920
3882
|
]
|
|
3921
|
-
}
|
|
3883
|
+
}
|
|
3922
3884
|
);
|
|
3923
3885
|
}
|
|
3924
3886
|
|
|
3925
3887
|
// src/input/index.tsx
|
|
3926
3888
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3927
|
-
function Input(
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
"label",
|
|
3935
|
-
"className",
|
|
3936
|
-
"regex",
|
|
3937
|
-
"invalidMessage"
|
|
3938
|
-
]);
|
|
3889
|
+
function Input({
|
|
3890
|
+
label,
|
|
3891
|
+
className,
|
|
3892
|
+
regex,
|
|
3893
|
+
invalidMessage = "Valor no v\xE1lido",
|
|
3894
|
+
...props
|
|
3895
|
+
}) {
|
|
3939
3896
|
const value = `${(props == null ? void 0 : props.value) || ""}`;
|
|
3940
3897
|
const isValid = !regex ? true : regex.test(value);
|
|
3941
3898
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w-full", children: [
|
|
@@ -3947,14 +3904,15 @@ function Input(_a) {
|
|
|
3947
3904
|
] }),
|
|
3948
3905
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3949
3906
|
"input",
|
|
3950
|
-
|
|
3907
|
+
{
|
|
3908
|
+
...props,
|
|
3951
3909
|
className: [
|
|
3952
3910
|
"p-2 w-full rounded border shadow",
|
|
3953
3911
|
value != "" && !isValid && "bg-red-200 text-black",
|
|
3954
3912
|
value != "" && isValid && "bg-green-200 text-black",
|
|
3955
3913
|
className
|
|
3956
3914
|
].join(" ")
|
|
3957
|
-
}
|
|
3915
|
+
}
|
|
3958
3916
|
) })
|
|
3959
3917
|
] }),
|
|
3960
3918
|
!isValid && value != "" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-red-800 invalid", children: invalidMessage })
|
|
@@ -35739,7 +35697,7 @@ var import_material2 = require("@mui/material");
|
|
|
35739
35697
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
35740
35698
|
function Table(props) {
|
|
35741
35699
|
if (Array.isArray(props.data)) {
|
|
35742
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(IHTable,
|
|
35700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(IHTable, { ...props });
|
|
35743
35701
|
} else {
|
|
35744
35702
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: " bg-white border shadow rounded p-1", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("table", { className: "rounded", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tbody", { children: Object.keys(props.data).map((k) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("tr", { className: "border-b ", children: [
|
|
35745
35703
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("th", { className: "font-bold p-3 text-right", children: k }),
|
|
@@ -35777,7 +35735,7 @@ function IHTable({
|
|
|
35777
35735
|
buttons,
|
|
35778
35736
|
exportName,
|
|
35779
35737
|
modal,
|
|
35780
|
-
height =
|
|
35738
|
+
height = 600,
|
|
35781
35739
|
width = "100%",
|
|
35782
35740
|
header,
|
|
35783
35741
|
hideColumns = [],
|
|
@@ -35785,7 +35743,7 @@ function IHTable({
|
|
|
35785
35743
|
}) {
|
|
35786
35744
|
const [open, setOpen] = (0, import_react4.useState)(false);
|
|
35787
35745
|
if (modal) {
|
|
35788
|
-
buttons =
|
|
35746
|
+
buttons = { ...buttons, Modal: "" };
|
|
35789
35747
|
}
|
|
35790
35748
|
const handleOpen = () => setOpen(true);
|
|
35791
35749
|
const handleClose = () => {
|
|
@@ -35810,13 +35768,14 @@ function IHTable({
|
|
|
35810
35768
|
editable: editableFields == null ? void 0 : editableFields.includes(key),
|
|
35811
35769
|
type: typeof rows[0][key] === "number" ? "number" : "string",
|
|
35812
35770
|
renderCell: (buttons == null ? void 0 : buttons[key]) ? (params) => {
|
|
35813
|
-
var _a;
|
|
35771
|
+
var _a, _b;
|
|
35814
35772
|
return import_react4.default.cloneElement(buttons[key], {
|
|
35815
|
-
|
|
35773
|
+
className: ((_a = params == null ? void 0 : params.className) != null ? _a : "") + " m-auto text-xs ",
|
|
35774
|
+
children: (_b = params == null ? void 0 : params.row) == null ? void 0 : _b[key],
|
|
35816
35775
|
onClick: (e) => {
|
|
35817
|
-
var _a2,
|
|
35776
|
+
var _a2, _b2;
|
|
35818
35777
|
e.row = params == null ? void 0 : params.row;
|
|
35819
|
-
if ((
|
|
35778
|
+
if ((_b2 = (_a2 = buttons[key]) == null ? void 0 : _a2.props) == null ? void 0 : _b2.onClick) {
|
|
35820
35779
|
const newVal = buttons[key].props.onClick(e);
|
|
35821
35780
|
newVal && handleRowUpdate(newVal);
|
|
35822
35781
|
}
|
|
@@ -35887,32 +35846,23 @@ function IHTable({
|
|
|
35887
35846
|
zIndex: 999999999
|
|
35888
35847
|
},
|
|
35889
35848
|
children: [
|
|
35890
|
-
modal && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
35891
|
-
|
|
35892
|
-
|
|
35893
|
-
|
|
35894
|
-
|
|
35895
|
-
|
|
35896
|
-
|
|
35897
|
-
|
|
35898
|
-
|
|
35899
|
-
|
|
35900
|
-
|
|
35901
|
-
|
|
35902
|
-
|
|
35903
|
-
|
|
35904
|
-
|
|
35905
|
-
|
|
35906
|
-
|
|
35907
|
-
) }),
|
|
35908
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-4 m-auto p-5", children: selectedRows && Array.from(selectedRows == null ? void 0 : selectedRows.ids).length > 0 && import_react4.default.cloneElement(modal, {
|
|
35909
|
-
row: rows.find(
|
|
35910
|
-
(r) => Array.from(selectedRows == null ? void 0 : selectedRows.ids).includes(r.id)
|
|
35911
|
-
)
|
|
35912
|
-
}) })
|
|
35913
|
-
]
|
|
35914
|
-
}
|
|
35915
|
-
),
|
|
35849
|
+
modal && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_material2.Dialog, { open, onClose: handleClose, maxWidth: "xl", fullWidth: true, children: [
|
|
35850
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
35851
|
+
"button",
|
|
35852
|
+
{
|
|
35853
|
+
onClick: () => {
|
|
35854
|
+
handleClose();
|
|
35855
|
+
},
|
|
35856
|
+
className: "text-gray-500 hover:text-gray-800 text-xl font-bold p-5",
|
|
35857
|
+
children: "\xD7"
|
|
35858
|
+
}
|
|
35859
|
+
) }),
|
|
35860
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-4 m-auto p-5", children: selectedRows && Array.from(selectedRows == null ? void 0 : selectedRows.ids).length > 0 && import_react4.default.cloneElement(modal, {
|
|
35861
|
+
row: rows.find(
|
|
35862
|
+
(r) => Array.from(selectedRows == null ? void 0 : selectedRows.ids).includes(r.id)
|
|
35863
|
+
)
|
|
35864
|
+
}) })
|
|
35865
|
+
] }),
|
|
35916
35866
|
header && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "font-bold text-xl p-2 bg-blue-500 text-white border shadow rounded", children: header }),
|
|
35917
35867
|
(exportName || onSave || onSelect) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex gap-2 bg-gray-200 border shadow rounded p-2", children: [
|
|
35918
35868
|
exportName && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -35921,10 +35871,7 @@ function IHTable({
|
|
|
35921
35871
|
className: "bg-green-800 text-white",
|
|
35922
35872
|
onClick: (e) => {
|
|
35923
35873
|
excel.export(
|
|
35924
|
-
rows.map((
|
|
35925
|
-
var _b = _a, { _edited } = _b, r = __objRest(_b, ["_edited"]);
|
|
35926
|
-
return r;
|
|
35927
|
-
}),
|
|
35874
|
+
rows.map(({ _edited, ...r }) => r),
|
|
35928
35875
|
`${exportName}.xlsx`
|
|
35929
35876
|
);
|
|
35930
35877
|
},
|
|
@@ -35937,10 +35884,7 @@ function IHTable({
|
|
|
35937
35884
|
disabled: filtered.length == 0,
|
|
35938
35885
|
color: filtered.length == 0 ? "white" : "primary",
|
|
35939
35886
|
onClick: (e) => {
|
|
35940
|
-
onSelect == null ? void 0 : onSelect(filtered.map((
|
|
35941
|
-
var _b = _a, { _edited } = _b, r = __objRest(_b, ["_edited"]);
|
|
35942
|
-
return r;
|
|
35943
|
-
}));
|
|
35887
|
+
onSelect == null ? void 0 : onSelect(filtered.map(({ _edited, ...r }) => r));
|
|
35944
35888
|
},
|
|
35945
35889
|
children: "Guardar Selecci\xF3n"
|
|
35946
35890
|
}
|
|
@@ -35948,10 +35892,7 @@ function IHTable({
|
|
|
35948
35892
|
Button,
|
|
35949
35893
|
{
|
|
35950
35894
|
onClick: (e) => {
|
|
35951
|
-
onSave == null ? void 0 : onSave(rows.map((
|
|
35952
|
-
var _b = _a, { _edited } = _b, r = __objRest(_b, ["_edited"]);
|
|
35953
|
-
return r;
|
|
35954
|
-
}));
|
|
35895
|
+
onSave == null ? void 0 : onSave(rows.map(({ _edited, ...r }) => r));
|
|
35955
35896
|
},
|
|
35956
35897
|
children: "Guardar"
|
|
35957
35898
|
}
|
|
@@ -35965,7 +35906,6 @@ function IHTable({
|
|
|
35965
35906
|
checkboxSelection: Boolean(onSelect),
|
|
35966
35907
|
rowSelectionModel: selectedRows,
|
|
35967
35908
|
onRowSelectionModelChange: (newSelection) => {
|
|
35968
|
-
console.log(newSelection);
|
|
35969
35909
|
setSelectedRows(newSelection);
|
|
35970
35910
|
},
|
|
35971
35911
|
sx: {
|
|
@@ -35984,36 +35924,53 @@ function IHTable({
|
|
|
35984
35924
|
}
|
|
35985
35925
|
);
|
|
35986
35926
|
}
|
|
35987
|
-
function CustomFooter(
|
|
35988
|
-
|
|
35989
|
-
|
|
35990
|
-
|
|
35991
|
-
|
|
35992
|
-
|
|
35993
|
-
|
|
35994
|
-
|
|
35995
|
-
|
|
35996
|
-
|
|
35927
|
+
function CustomFooter({
|
|
35928
|
+
rows,
|
|
35929
|
+
footer
|
|
35930
|
+
}) {
|
|
35931
|
+
const entries = Object.entries(footer);
|
|
35932
|
+
if (!entries.length) return null;
|
|
35933
|
+
const compute = (key, type) => {
|
|
35934
|
+
const values = rows.map((r) => {
|
|
35935
|
+
var _a;
|
|
35936
|
+
return Number((_a = r[key]) != null ? _a : 0);
|
|
35937
|
+
}).filter((v) => !isNaN(v));
|
|
35938
|
+
if (type === "sum") return values.reduce((acc, v) => acc + v, 0);
|
|
35939
|
+
if (type === "avg")
|
|
35940
|
+
return values.length ? values.reduce((acc, v) => acc + v, 0) / values.length : 0;
|
|
35941
|
+
if (type === "count") return values.length;
|
|
35942
|
+
return 0;
|
|
35943
|
+
};
|
|
35944
|
+
const label = {
|
|
35945
|
+
sum: "Suma",
|
|
35946
|
+
avg: "Promedio",
|
|
35947
|
+
count: "Conteo"
|
|
35948
|
+
};
|
|
35949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex justify-end gap-6 px-4 py-2 bg-gray-100 border-t border-gray-300 text-sm font-semibold text-gray-700", children: entries.map(([key, type]) => {
|
|
35950
|
+
const value = compute(key, type);
|
|
35951
|
+
const formatted = type === "avg" ? value.toLocaleString(void 0, { maximumFractionDigits: 2 }) : value.toLocaleString();
|
|
35952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
35953
|
+
label[type],
|
|
35954
|
+
" de ",
|
|
35955
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-gray-900", children: key }),
|
|
35956
|
+
":",
|
|
35957
|
+
" ",
|
|
35958
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-blue-700", children: formatted })
|
|
35959
|
+
] }, key);
|
|
35997
35960
|
}) });
|
|
35998
35961
|
}
|
|
35999
35962
|
|
|
36000
35963
|
// src/text-area/index.tsx
|
|
36001
35964
|
var import_react5 = require("react");
|
|
36002
35965
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
36003
|
-
function TextArea(
|
|
36004
|
-
|
|
36005
|
-
|
|
36006
|
-
|
|
36007
|
-
|
|
36008
|
-
|
|
36009
|
-
|
|
36010
|
-
|
|
36011
|
-
"label",
|
|
36012
|
-
"className",
|
|
36013
|
-
"maxLength",
|
|
36014
|
-
"onChange",
|
|
36015
|
-
"children"
|
|
36016
|
-
]);
|
|
35966
|
+
function TextArea({
|
|
35967
|
+
label,
|
|
35968
|
+
className,
|
|
35969
|
+
maxLength,
|
|
35970
|
+
onChange,
|
|
35971
|
+
children = "",
|
|
35972
|
+
...props
|
|
35973
|
+
}) {
|
|
36017
35974
|
const [value, setValue] = (0, import_react5.useState)((props == null ? void 0 : props.value) || "");
|
|
36018
35975
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
36019
35976
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "font-bold ", children: [
|
|
@@ -36024,7 +35981,8 @@ function TextArea(_a) {
|
|
|
36024
35981
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
36025
35982
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
36026
35983
|
"textarea",
|
|
36027
|
-
|
|
35984
|
+
{
|
|
35985
|
+
...props,
|
|
36028
35986
|
className: ["p-1 w-full rounded border shadow", className].join(
|
|
36029
35987
|
" "
|
|
36030
35988
|
),
|
|
@@ -36036,7 +35994,7 @@ function TextArea(_a) {
|
|
|
36036
35994
|
setValue(e.target.value);
|
|
36037
35995
|
onChange == null ? void 0 : onChange(e);
|
|
36038
35996
|
}
|
|
36039
|
-
}
|
|
35997
|
+
}
|
|
36040
35998
|
),
|
|
36041
35999
|
maxLength && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: " text-xs text-gray text-right", children: [
|
|
36042
36000
|
value.length,
|
|
@@ -36148,7 +36106,8 @@ function useResources({
|
|
|
36148
36106
|
const [info, setInfo] = (0, import_react7.useState)(
|
|
36149
36107
|
Object.keys(endpoints).reduce((acc, key) => {
|
|
36150
36108
|
var _a, _b;
|
|
36151
|
-
const newAcc =
|
|
36109
|
+
const newAcc = {
|
|
36110
|
+
...acc,
|
|
36152
36111
|
[key]: {
|
|
36153
36112
|
loaded: false,
|
|
36154
36113
|
id: (_a = endpoints[key]) == null ? void 0 : _a.id,
|
|
@@ -36156,23 +36115,22 @@ function useResources({
|
|
|
36156
36115
|
data: [],
|
|
36157
36116
|
selectedItem: {}
|
|
36158
36117
|
}
|
|
36159
|
-
}
|
|
36118
|
+
};
|
|
36160
36119
|
return newAcc;
|
|
36161
36120
|
}, {})
|
|
36162
36121
|
);
|
|
36163
36122
|
const results = Object.keys(endpoints).reduce(
|
|
36164
36123
|
(acc, key) => {
|
|
36165
|
-
var _c, _d, _e, _f, _g
|
|
36124
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
36166
36125
|
const endpoint = endpoints[key];
|
|
36167
|
-
const showFunc = async (
|
|
36168
|
-
var _b = _a, { limit = 10, page = 1, merge = true } = _b, query = __objRest(_b, ["limit", "page", "merge"]);
|
|
36126
|
+
const showFunc = async ({ limit = 10, page = 1, merge = true, ...query }, autoLoad = false) => {
|
|
36169
36127
|
const options = {
|
|
36170
36128
|
method: "GET",
|
|
36171
36129
|
url: `${baseURI}/${key}`,
|
|
36172
|
-
params:
|
|
36130
|
+
params: { limit, page, ...query },
|
|
36173
36131
|
headers: { Authorization: token }
|
|
36174
36132
|
};
|
|
36175
|
-
const newInfo =
|
|
36133
|
+
const newInfo = { ...info };
|
|
36176
36134
|
newInfo[key].state = "loading";
|
|
36177
36135
|
newInfo[key].errorMessage = "";
|
|
36178
36136
|
newInfo[key].params = query;
|
|
@@ -36187,28 +36145,28 @@ function useResources({
|
|
|
36187
36145
|
newInfo[key].totalItems = d.totalItems;
|
|
36188
36146
|
newInfo[key].totalPages = d.totalPages;
|
|
36189
36147
|
newInfo[key].currentPage = d.currentPage;
|
|
36190
|
-
setInfo(
|
|
36148
|
+
setInfo({ ...newInfo });
|
|
36191
36149
|
return d.data;
|
|
36192
36150
|
} catch (error) {
|
|
36193
36151
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36194
36152
|
newInfo[key].state = "error";
|
|
36195
36153
|
newInfo[key].errorMessage = item == null ? void 0 : item.meaning;
|
|
36196
36154
|
if (error.status == 403) {
|
|
36197
|
-
onError == null ? void 0 : onError(
|
|
36155
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36198
36156
|
}
|
|
36199
|
-
setInfo(
|
|
36157
|
+
setInfo({ ...newInfo });
|
|
36200
36158
|
return error;
|
|
36201
36159
|
}
|
|
36202
36160
|
};
|
|
36203
36161
|
const findFunc = async (id, query) => {
|
|
36204
|
-
var
|
|
36162
|
+
var _a2, _b2, _c2;
|
|
36205
36163
|
const options = {
|
|
36206
36164
|
method: "GET",
|
|
36207
36165
|
url: `${baseURI}/${key}/${id}`,
|
|
36208
|
-
params:
|
|
36166
|
+
params: { ...query },
|
|
36209
36167
|
headers: { Authorization: token }
|
|
36210
36168
|
};
|
|
36211
|
-
const newInfo =
|
|
36169
|
+
const newInfo = { ...info };
|
|
36212
36170
|
newInfo[key].state = "loading";
|
|
36213
36171
|
newInfo[key].errorMessage = "";
|
|
36214
36172
|
newInfo[key].params = query;
|
|
@@ -36220,7 +36178,7 @@ function useResources({
|
|
|
36220
36178
|
newInfo[key].state = "success";
|
|
36221
36179
|
newInfo[key].errorMessage = "";
|
|
36222
36180
|
newInfo[key].selectedItem = d;
|
|
36223
|
-
const index = (
|
|
36181
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex((d2) => (d2 == null ? void 0 : d2.id) == id);
|
|
36224
36182
|
if (index >= 0) {
|
|
36225
36183
|
newInfo[key].data[index] = d;
|
|
36226
36184
|
} else {
|
|
@@ -36230,28 +36188,28 @@ function useResources({
|
|
|
36230
36188
|
newInfo[key].data = [d];
|
|
36231
36189
|
}
|
|
36232
36190
|
}
|
|
36233
|
-
setInfo(
|
|
36191
|
+
setInfo({ ...newInfo });
|
|
36234
36192
|
return d;
|
|
36235
36193
|
} catch (error) {
|
|
36236
36194
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36237
36195
|
newInfo[key].state = "error";
|
|
36238
36196
|
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36239
36197
|
if (error.status == 403) {
|
|
36240
|
-
onError == null ? void 0 : onError(
|
|
36198
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36241
36199
|
}
|
|
36242
|
-
setInfo(
|
|
36200
|
+
setInfo({ ...newInfo });
|
|
36243
36201
|
return error;
|
|
36244
36202
|
}
|
|
36245
36203
|
};
|
|
36246
36204
|
const bodyCreateFunc = async (data) => {
|
|
36247
|
-
var
|
|
36205
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
36248
36206
|
const options = {
|
|
36249
36207
|
method: "POST",
|
|
36250
36208
|
url: `${baseURI}/${key}`,
|
|
36251
|
-
data: Array.isArray(data) ? [...data] :
|
|
36209
|
+
data: Array.isArray(data) ? [...data] : { ...data },
|
|
36252
36210
|
headers: { Authorization: token }
|
|
36253
36211
|
};
|
|
36254
|
-
const newInfo =
|
|
36212
|
+
const newInfo = { ...info };
|
|
36255
36213
|
newInfo[key].state = "loading";
|
|
36256
36214
|
newInfo[key].errorMessage = "";
|
|
36257
36215
|
setInfo(newInfo);
|
|
@@ -36262,7 +36220,7 @@ function useResources({
|
|
|
36262
36220
|
newInfo[key].errorMessage = "";
|
|
36263
36221
|
if (Array.isArray(data)) {
|
|
36264
36222
|
for (let datum of data) {
|
|
36265
|
-
const index = (
|
|
36223
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36266
36224
|
(d2) => (d2 == null ? void 0 : d2.id) == (datum == null ? void 0 : datum.id)
|
|
36267
36225
|
);
|
|
36268
36226
|
if (index >= 0) {
|
|
@@ -36291,22 +36249,22 @@ function useResources({
|
|
|
36291
36249
|
}
|
|
36292
36250
|
}
|
|
36293
36251
|
}
|
|
36294
|
-
setInfo(
|
|
36252
|
+
setInfo({ ...newInfo });
|
|
36295
36253
|
return d;
|
|
36296
36254
|
} catch (error) {
|
|
36297
36255
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36298
36256
|
newInfo[key].state = "error";
|
|
36299
36257
|
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36300
36258
|
if (error.status == 403) {
|
|
36301
|
-
onError == null ? void 0 : onError(
|
|
36259
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36302
36260
|
}
|
|
36303
|
-
setInfo(
|
|
36261
|
+
setInfo({ ...newInfo });
|
|
36304
36262
|
return error;
|
|
36305
36263
|
}
|
|
36306
36264
|
};
|
|
36307
36265
|
const formCreateFunc = async (data) => {
|
|
36308
|
-
var
|
|
36309
|
-
const newInfo =
|
|
36266
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
36267
|
+
const newInfo = { ...info };
|
|
36310
36268
|
newInfo[key].state = "loading";
|
|
36311
36269
|
newInfo[key].errorMessage = "";
|
|
36312
36270
|
setInfo(newInfo);
|
|
@@ -36338,7 +36296,7 @@ function useResources({
|
|
|
36338
36296
|
newInfo[key].errorMessage = "";
|
|
36339
36297
|
if (Array.isArray(data)) {
|
|
36340
36298
|
for (let datum of data) {
|
|
36341
|
-
const index = (
|
|
36299
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36342
36300
|
(d2) => (d2 == null ? void 0 : d2.id) == (datum == null ? void 0 : datum.id)
|
|
36343
36301
|
);
|
|
36344
36302
|
if (index >= 0) {
|
|
@@ -36367,20 +36325,21 @@ function useResources({
|
|
|
36367
36325
|
}
|
|
36368
36326
|
}
|
|
36369
36327
|
}
|
|
36370
|
-
setInfo(
|
|
36328
|
+
setInfo({ ...newInfo });
|
|
36371
36329
|
return d;
|
|
36372
36330
|
} catch (error) {
|
|
36373
36331
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36374
36332
|
newInfo[key].state = "error";
|
|
36375
36333
|
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36376
36334
|
if (error.status == 403) {
|
|
36377
|
-
onError == null ? void 0 : onError(
|
|
36335
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36378
36336
|
}
|
|
36379
|
-
setInfo(
|
|
36337
|
+
setInfo({ ...newInfo });
|
|
36380
36338
|
return error;
|
|
36381
36339
|
}
|
|
36382
36340
|
};
|
|
36383
|
-
acc[key] =
|
|
36341
|
+
acc[key] = {
|
|
36342
|
+
...endpoint,
|
|
36384
36343
|
loaded: false,
|
|
36385
36344
|
show: showFunc,
|
|
36386
36345
|
find: findFunc,
|
|
@@ -36394,14 +36353,14 @@ function useResources({
|
|
|
36394
36353
|
return await bodyCreateFunc(data);
|
|
36395
36354
|
},
|
|
36396
36355
|
update: async (id, data) => {
|
|
36397
|
-
var
|
|
36356
|
+
var _a2, _b2, _c2;
|
|
36398
36357
|
const options = {
|
|
36399
36358
|
method: "PATCH",
|
|
36400
36359
|
url: `${baseURI}/${key}/${id}`,
|
|
36401
|
-
data: Array.isArray(data) ? [...data] :
|
|
36360
|
+
data: Array.isArray(data) ? [...data] : { ...data },
|
|
36402
36361
|
headers: { Authorization: token }
|
|
36403
36362
|
};
|
|
36404
|
-
const newInfo =
|
|
36363
|
+
const newInfo = { ...info };
|
|
36405
36364
|
newInfo[key].state = "loading";
|
|
36406
36365
|
newInfo[key].errorMessage = "";
|
|
36407
36366
|
setInfo(newInfo);
|
|
@@ -36410,12 +36369,12 @@ function useResources({
|
|
|
36410
36369
|
const d = consulta.data;
|
|
36411
36370
|
newInfo[key].state = "success";
|
|
36412
36371
|
newInfo[key].errorMessage = "";
|
|
36413
|
-
newInfo[key].selectedItem =
|
|
36414
|
-
const index = (
|
|
36372
|
+
newInfo[key].selectedItem = { ...newInfo[key].selectedItem, ...d };
|
|
36373
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36415
36374
|
(d2) => (d2 == null ? void 0 : d2.id) == id
|
|
36416
36375
|
);
|
|
36417
36376
|
if (index >= 0) {
|
|
36418
|
-
newInfo[key].data[index] =
|
|
36377
|
+
newInfo[key].data[index] = { ...newInfo[key].data[index], ...d };
|
|
36419
36378
|
} else {
|
|
36420
36379
|
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
36421
36380
|
newInfo[key].data.unshift(d);
|
|
@@ -36423,27 +36382,27 @@ function useResources({
|
|
|
36423
36382
|
newInfo[key].data = [d];
|
|
36424
36383
|
}
|
|
36425
36384
|
}
|
|
36426
|
-
setInfo(
|
|
36385
|
+
setInfo({ ...newInfo });
|
|
36427
36386
|
return d;
|
|
36428
36387
|
} catch (error) {
|
|
36429
36388
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36430
36389
|
newInfo[key].state = "error";
|
|
36431
36390
|
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36432
36391
|
if (error.status == 403) {
|
|
36433
|
-
onError == null ? void 0 : onError(
|
|
36392
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36434
36393
|
}
|
|
36435
|
-
setInfo(
|
|
36394
|
+
setInfo({ ...newInfo });
|
|
36436
36395
|
return error;
|
|
36437
36396
|
}
|
|
36438
36397
|
},
|
|
36439
36398
|
remove: async (id) => {
|
|
36440
|
-
var
|
|
36399
|
+
var _a2, _b2;
|
|
36441
36400
|
const options = {
|
|
36442
36401
|
method: "DELETE",
|
|
36443
36402
|
url: `${baseURI}/${key}/${id}`,
|
|
36444
36403
|
headers: { Authorization: token }
|
|
36445
36404
|
};
|
|
36446
|
-
const newInfo =
|
|
36405
|
+
const newInfo = { ...info };
|
|
36447
36406
|
newInfo[key].state = "loading";
|
|
36448
36407
|
newInfo[key].errorMessage = "";
|
|
36449
36408
|
setInfo(newInfo);
|
|
@@ -36453,32 +36412,32 @@ function useResources({
|
|
|
36453
36412
|
newInfo[key].state = "success";
|
|
36454
36413
|
newInfo[key].errorMessage = "";
|
|
36455
36414
|
newInfo[key].selectedItem = d;
|
|
36456
|
-
const index = (
|
|
36415
|
+
const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
|
|
36457
36416
|
(d2) => (d2 == null ? void 0 : d2.id) == id
|
|
36458
36417
|
);
|
|
36459
36418
|
if (index >= 0) {
|
|
36460
36419
|
newInfo[key].data.splice(index, 1);
|
|
36461
36420
|
}
|
|
36462
|
-
setInfo(
|
|
36421
|
+
setInfo({ ...newInfo });
|
|
36463
36422
|
return d.data;
|
|
36464
36423
|
} catch (error) {
|
|
36465
36424
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
36466
36425
|
newInfo[key].state = "error";
|
|
36467
36426
|
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
36468
36427
|
if (error.status == 403) {
|
|
36469
|
-
onError == null ? void 0 : onError(
|
|
36428
|
+
onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
|
|
36470
36429
|
}
|
|
36471
|
-
setInfo(
|
|
36430
|
+
setInfo({ ...newInfo });
|
|
36472
36431
|
return error;
|
|
36473
36432
|
}
|
|
36474
36433
|
},
|
|
36475
|
-
totalPages: (
|
|
36476
|
-
currentPage: (
|
|
36477
|
-
state: ((
|
|
36478
|
-
errorMessage: (
|
|
36479
|
-
params: (
|
|
36434
|
+
totalPages: (_a = info[key]) == null ? void 0 : _a.totalPages,
|
|
36435
|
+
currentPage: (_b = info[key]) == null ? void 0 : _b.currentPage,
|
|
36436
|
+
state: ((_c = info[key]) == null ? void 0 : _c.state) || "success",
|
|
36437
|
+
errorMessage: (_d = info[key]) == null ? void 0 : _d.errorMessage,
|
|
36438
|
+
params: (_e = info[key]) == null ? void 0 : _e.params,
|
|
36480
36439
|
setLoaded: () => {
|
|
36481
|
-
const newInfo =
|
|
36440
|
+
const newInfo = { ...info };
|
|
36482
36441
|
newInfo[key].loaded = true;
|
|
36483
36442
|
setInfo(newInfo);
|
|
36484
36443
|
},
|
|
@@ -36498,16 +36457,16 @@ function useResources({
|
|
|
36498
36457
|
currentPage = currentInfo.currentPage || currentPage + 1;
|
|
36499
36458
|
totalPages = currentInfo.totalPages || currentPage;
|
|
36500
36459
|
}
|
|
36501
|
-
const newInfo =
|
|
36460
|
+
const newInfo = { ...info };
|
|
36502
36461
|
newInfo[key].data = allData;
|
|
36503
36462
|
newInfo[key].currentPage = currentPage;
|
|
36504
36463
|
newInfo[key].totalPages = totalPages;
|
|
36505
36464
|
setInfo(newInfo);
|
|
36506
36465
|
return allData;
|
|
36507
36466
|
},
|
|
36508
|
-
data: ((
|
|
36509
|
-
selectedItem: ((
|
|
36510
|
-
}
|
|
36467
|
+
data: ((_f = info[key]) == null ? void 0 : _f.data) || [],
|
|
36468
|
+
selectedItem: ((_g = info[key]) == null ? void 0 : _g.selectedItem) || {}
|
|
36469
|
+
};
|
|
36511
36470
|
return acc;
|
|
36512
36471
|
},
|
|
36513
36472
|
{}
|
|
@@ -36574,18 +36533,13 @@ function CloseIcon() {
|
|
|
36574
36533
|
|
|
36575
36534
|
// src/select/index.tsx
|
|
36576
36535
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
36577
|
-
function Select(
|
|
36578
|
-
|
|
36579
|
-
|
|
36580
|
-
|
|
36581
|
-
|
|
36582
|
-
|
|
36583
|
-
|
|
36584
|
-
"label",
|
|
36585
|
-
"placeholder",
|
|
36586
|
-
"children",
|
|
36587
|
-
"strictMode"
|
|
36588
|
-
]);
|
|
36536
|
+
function Select({
|
|
36537
|
+
label,
|
|
36538
|
+
placeholder = "Selecciona...",
|
|
36539
|
+
children,
|
|
36540
|
+
strictMode = true,
|
|
36541
|
+
...props
|
|
36542
|
+
}) {
|
|
36589
36543
|
const [isOpen, setIsOpen] = (0, import_react8.useState)(false);
|
|
36590
36544
|
const [inputValue, setInputValue] = (0, import_react8.useState)("");
|
|
36591
36545
|
const [options, setOptions] = (0, import_react8.useState)(
|
|
@@ -36602,7 +36556,7 @@ function Select(_a) {
|
|
|
36602
36556
|
};
|
|
36603
36557
|
const normalize = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z]/g, "");
|
|
36604
36558
|
(0, import_react8.useEffect)(() => {
|
|
36605
|
-
var
|
|
36559
|
+
var _a;
|
|
36606
36560
|
const parsedOptions = import_react8.default.Children.toArray(children).filter((child) => {
|
|
36607
36561
|
return child.type === "option";
|
|
36608
36562
|
}).map((child) => {
|
|
@@ -36613,7 +36567,7 @@ function Select(_a) {
|
|
|
36613
36567
|
});
|
|
36614
36568
|
setOptions(parsedOptions);
|
|
36615
36569
|
setFiltered(parsedOptions);
|
|
36616
|
-
const value = (props == null ? void 0 : props.value) && ((
|
|
36570
|
+
const value = (props == null ? void 0 : props.value) && ((_a = parsedOptions.find((opt) => opt.value == props.value)) == null ? void 0 : _a.label);
|
|
36617
36571
|
setInputValue(value);
|
|
36618
36572
|
}, [children]);
|
|
36619
36573
|
(0, import_react8.useEffect)(() => {
|
|
@@ -36667,10 +36621,10 @@ function Select(_a) {
|
|
|
36667
36621
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "relative", children: [
|
|
36668
36622
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
36669
36623
|
"input",
|
|
36670
|
-
|
|
36624
|
+
{
|
|
36671
36625
|
autoComplete: "off",
|
|
36672
|
-
ref: inputRef
|
|
36673
|
-
|
|
36626
|
+
ref: inputRef,
|
|
36627
|
+
...props,
|
|
36674
36628
|
className: [
|
|
36675
36629
|
"p-2 w-full rounded border shadow",
|
|
36676
36630
|
props == null ? void 0 : props.className
|
|
@@ -36678,13 +36632,13 @@ function Select(_a) {
|
|
|
36678
36632
|
value: inputValue,
|
|
36679
36633
|
onBlur: (e) => {
|
|
36680
36634
|
setTimeout(() => {
|
|
36681
|
-
var
|
|
36635
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
36682
36636
|
const item = validOption(e.target.value);
|
|
36683
36637
|
if (!item) {
|
|
36684
36638
|
if (strictMode) {
|
|
36685
36639
|
e.target.value = "";
|
|
36686
36640
|
setInputValue("");
|
|
36687
|
-
(_c = (
|
|
36641
|
+
(_c = (_b = (_a = e.target) == null ? void 0 : _a.classList) == null ? void 0 : _b.remove) == null ? void 0 : _c.call(_b, "bg-green-200");
|
|
36688
36642
|
(_f = (_e = (_d = e.target) == null ? void 0 : _d.classList) == null ? void 0 : _e.add) == null ? void 0 : _f.call(_e, "bg-red-200");
|
|
36689
36643
|
return;
|
|
36690
36644
|
}
|
|
@@ -36702,18 +36656,18 @@ function Select(_a) {
|
|
|
36702
36656
|
placeholder,
|
|
36703
36657
|
onFocus: () => setIsOpen(true),
|
|
36704
36658
|
onKeyDown: handleKeyDown
|
|
36705
|
-
}
|
|
36659
|
+
}
|
|
36706
36660
|
),
|
|
36707
36661
|
!isOpen && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "absolute top-0 right-0 flex flex-col justify-center items-center px-2 py-2 font-bold", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectIcon, {}) }),
|
|
36708
36662
|
isOpen && inputValue != "" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
36709
36663
|
"button",
|
|
36710
36664
|
{
|
|
36711
36665
|
onClick: (e) => {
|
|
36712
|
-
var
|
|
36666
|
+
var _a, _b, _c, _d, _e, _f;
|
|
36713
36667
|
setIsOpen(true);
|
|
36714
36668
|
setInputValue("");
|
|
36715
36669
|
if ((inputRef == null ? void 0 : inputRef.current) && strictMode) {
|
|
36716
|
-
(_c = (
|
|
36670
|
+
(_c = (_b = (_a = inputRef.current) == null ? void 0 : _a.classList) == null ? void 0 : _b.remove) == null ? void 0 : _c.call(_b, "bg-green-200");
|
|
36717
36671
|
(_f = (_e = (_d = inputRef.current) == null ? void 0 : _d.classList) == null ? void 0 : _e.add) == null ? void 0 : _f.call(_e, "bg-red-200");
|
|
36718
36672
|
inputRef.current.focus();
|
|
36719
36673
|
}
|
|
@@ -36733,9 +36687,9 @@ function Select(_a) {
|
|
|
36733
36687
|
{
|
|
36734
36688
|
className: `p-2 cursor-pointer ${index === highlightedIndex ? "bg-blue-100" : "hover:bg-gray-100"}`,
|
|
36735
36689
|
onClick: () => {
|
|
36736
|
-
var
|
|
36690
|
+
var _a;
|
|
36737
36691
|
try {
|
|
36738
|
-
(
|
|
36692
|
+
(_a = props == null ? void 0 : props.onChange) == null ? void 0 : _a.call(props, {
|
|
36739
36693
|
target: { value: (opt == null ? void 0 : opt.value) || opt.label }
|
|
36740
36694
|
});
|
|
36741
36695
|
} catch (error) {
|
|
@@ -36814,13 +36768,14 @@ function Modal({ button, children, ref, title = "" }) {
|
|
|
36814
36768
|
import_react9.default.Children.map(button, (child) => {
|
|
36815
36769
|
if (import_react9.default.isValidElement(child)) {
|
|
36816
36770
|
const { type, props } = child;
|
|
36817
|
-
return import_react9.default.createElement(type,
|
|
36771
|
+
return import_react9.default.createElement(type, {
|
|
36772
|
+
...props,
|
|
36818
36773
|
onClick: (e) => {
|
|
36819
36774
|
var _a, _b;
|
|
36820
36775
|
show();
|
|
36821
36776
|
(_b = (_a = child.props) == null ? void 0 : _a.onClick) == null ? void 0 : _b.call(_a, e);
|
|
36822
36777
|
}
|
|
36823
|
-
})
|
|
36778
|
+
});
|
|
36824
36779
|
}
|
|
36825
36780
|
return child;
|
|
36826
36781
|
}),
|
|
@@ -36837,7 +36792,7 @@ function Modal({ button, children, ref, title = "" }) {
|
|
|
36837
36792
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex flex-col gap-3 pt-6", children: import_react9.default.Children.map(children, (child) => {
|
|
36838
36793
|
if (import_react9.default.isValidElement(child)) {
|
|
36839
36794
|
const { type, props } = child;
|
|
36840
|
-
return import_react9.default.createElement(type,
|
|
36795
|
+
return import_react9.default.createElement(type, { ...props, hide });
|
|
36841
36796
|
}
|
|
36842
36797
|
return child;
|
|
36843
36798
|
}) })
|
|
@@ -36918,22 +36873,15 @@ function CalendarIcon() {
|
|
|
36918
36873
|
// src/calendar/index.tsx
|
|
36919
36874
|
var import_material4 = require("@mui/material");
|
|
36920
36875
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
36921
|
-
function MyCalendar(
|
|
36922
|
-
|
|
36923
|
-
|
|
36924
|
-
|
|
36925
|
-
|
|
36926
|
-
|
|
36927
|
-
|
|
36928
|
-
|
|
36929
|
-
|
|
36930
|
-
"enabledDates",
|
|
36931
|
-
"onChange",
|
|
36932
|
-
"defaultValue",
|
|
36933
|
-
"className",
|
|
36934
|
-
"label",
|
|
36935
|
-
"value"
|
|
36936
|
-
]);
|
|
36876
|
+
function MyCalendar({
|
|
36877
|
+
enabledDates,
|
|
36878
|
+
onChange,
|
|
36879
|
+
defaultValue = "",
|
|
36880
|
+
className = "",
|
|
36881
|
+
label = "",
|
|
36882
|
+
value,
|
|
36883
|
+
...otherProps
|
|
36884
|
+
}) {
|
|
36937
36885
|
const [selectedDate, setSelectedDate] = (0, import_react10.useState)(null);
|
|
36938
36886
|
const [dateStr, setDateStr] = (0, import_react10.useState)(
|
|
36939
36887
|
defaultValue || value || ""
|
|
@@ -36970,7 +36918,8 @@ function MyCalendar(_a) {
|
|
|
36970
36918
|
children: [
|
|
36971
36919
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
36972
36920
|
"input",
|
|
36973
|
-
|
|
36921
|
+
{
|
|
36922
|
+
...otherProps,
|
|
36974
36923
|
className: [
|
|
36975
36924
|
"p-2 w-full rounded border shadow cursor-pointer",
|
|
36976
36925
|
className
|
|
@@ -36980,7 +36929,7 @@ function MyCalendar(_a) {
|
|
|
36980
36929
|
return;
|
|
36981
36930
|
},
|
|
36982
36931
|
readOnly: true
|
|
36983
|
-
}
|
|
36932
|
+
}
|
|
36984
36933
|
),
|
|
36985
36934
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "absolute", style: { right: "10px" }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CalendarIcon, {}) })
|
|
36986
36935
|
]
|
|
@@ -37291,13 +37240,14 @@ function Filter({
|
|
|
37291
37240
|
"div",
|
|
37292
37241
|
{
|
|
37293
37242
|
onClick: (e) => {
|
|
37294
|
-
const newSort =
|
|
37243
|
+
const newSort = { ...sort };
|
|
37295
37244
|
newSort[h] = "asc";
|
|
37296
|
-
const reorderedSort =
|
|
37297
|
-
[h]: "asc"
|
|
37298
|
-
|
|
37299
|
-
|
|
37300
|
-
|
|
37245
|
+
const reorderedSort = {
|
|
37246
|
+
[h]: "asc",
|
|
37247
|
+
...Object.fromEntries(
|
|
37248
|
+
Object.entries(newSort).filter(([key]) => key !== h)
|
|
37249
|
+
)
|
|
37250
|
+
};
|
|
37301
37251
|
setSort(reorderedSort);
|
|
37302
37252
|
setVisible(false);
|
|
37303
37253
|
},
|
|
@@ -37312,13 +37262,14 @@ function Filter({
|
|
|
37312
37262
|
"div",
|
|
37313
37263
|
{
|
|
37314
37264
|
onClick: (e) => {
|
|
37315
|
-
const newSort =
|
|
37265
|
+
const newSort = { ...sort };
|
|
37316
37266
|
newSort[h] = "desc";
|
|
37317
|
-
const reorderedSort =
|
|
37318
|
-
[h]: "desc"
|
|
37319
|
-
|
|
37320
|
-
|
|
37321
|
-
|
|
37267
|
+
const reorderedSort = {
|
|
37268
|
+
[h]: "desc",
|
|
37269
|
+
...Object.fromEntries(
|
|
37270
|
+
Object.entries(newSort).filter(([key]) => key !== h)
|
|
37271
|
+
)
|
|
37272
|
+
};
|
|
37322
37273
|
setSort(reorderedSort);
|
|
37323
37274
|
setVisible(false);
|
|
37324
37275
|
},
|
|
@@ -37561,45 +37512,53 @@ function TR({
|
|
|
37561
37512
|
return null;
|
|
37562
37513
|
} else if (handlers == null ? void 0 : handlers[h]) {
|
|
37563
37514
|
const original = handlers[h];
|
|
37564
|
-
const cloned = import_react12.default.cloneElement(original,
|
|
37515
|
+
const cloned = import_react12.default.cloneElement(original, {
|
|
37565
37516
|
// si es controlado por value → actualiza con row[h]
|
|
37566
37517
|
value: ((_a = original.props) == null ? void 0 : _a.value) !== void 0 ? row[h] : void 0,
|
|
37567
37518
|
// si usa children → actualiza con row[h] también
|
|
37568
|
-
children: ((_b = original.props) == null ? void 0 : _b.children) ? typeof original.props.children == "object" ? (_c = original.props) == null ? void 0 : _c.children : row == null ? void 0 : row[h] : null
|
|
37569
|
-
|
|
37570
|
-
|
|
37571
|
-
|
|
37572
|
-
|
|
37573
|
-
|
|
37574
|
-
|
|
37575
|
-
|
|
37576
|
-
|
|
37577
|
-
|
|
37578
|
-
|
|
37579
|
-
|
|
37580
|
-
|
|
37581
|
-
|
|
37582
|
-
|
|
37583
|
-
|
|
37584
|
-
|
|
37585
|
-
|
|
37586
|
-
|
|
37587
|
-
|
|
37588
|
-
|
|
37589
|
-
|
|
37590
|
-
|
|
37591
|
-
|
|
37592
|
-
|
|
37593
|
-
|
|
37594
|
-
|
|
37595
|
-
|
|
37596
|
-
|
|
37597
|
-
|
|
37598
|
-
|
|
37599
|
-
|
|
37600
|
-
|
|
37601
|
-
|
|
37602
|
-
|
|
37519
|
+
children: ((_b = original.props) == null ? void 0 : _b.children) ? typeof original.props.children == "object" ? (_c = original.props) == null ? void 0 : _c.children : row == null ? void 0 : row[h] : null,
|
|
37520
|
+
...original.props.hasOwnProperty("row") ? {
|
|
37521
|
+
row,
|
|
37522
|
+
updateRow: (finalResponse) => setObjectData({
|
|
37523
|
+
...(row == null ? void 0 : row._id) ? {
|
|
37524
|
+
_id: row == null ? void 0 : row._id,
|
|
37525
|
+
_updated: true,
|
|
37526
|
+
_visible: true
|
|
37527
|
+
} : {
|
|
37528
|
+
id: (row == null ? void 0 : row.id) || null,
|
|
37529
|
+
_updated: true,
|
|
37530
|
+
_visible: true
|
|
37531
|
+
},
|
|
37532
|
+
...finalResponse
|
|
37533
|
+
})
|
|
37534
|
+
} : {},
|
|
37535
|
+
...Object.keys({
|
|
37536
|
+
...original.props,
|
|
37537
|
+
onChange: (_d = original.props) == null ? void 0 : _d.onChange
|
|
37538
|
+
}).filter((action) => action.startsWith("on")).reduce((acc, action) => {
|
|
37539
|
+
acc[action] = (e) => {
|
|
37540
|
+
var _a2, _b2;
|
|
37541
|
+
e.row = row;
|
|
37542
|
+
const userResponse = ((_b2 = (_a2 = original.props) == null ? void 0 : _a2[action]) == null ? void 0 : _b2.call(_a2, e)) || {};
|
|
37543
|
+
const newObject = (row == null ? void 0 : row._id) ? {
|
|
37544
|
+
_id: row == null ? void 0 : row._id,
|
|
37545
|
+
[h]: e.target.value,
|
|
37546
|
+
_updated: true,
|
|
37547
|
+
_visible: true,
|
|
37548
|
+
...userResponse
|
|
37549
|
+
} : {
|
|
37550
|
+
id: (row == null ? void 0 : row.id) || null,
|
|
37551
|
+
[h]: e.target.value,
|
|
37552
|
+
_updated: true,
|
|
37553
|
+
_visible: true,
|
|
37554
|
+
...userResponse
|
|
37555
|
+
};
|
|
37556
|
+
const finalResponse = action == "onChange" && onChange ? onChange({ ...e, row: { ...e.row, ...newObject } }) : {};
|
|
37557
|
+
setObjectData({ ...newObject, ...finalResponse });
|
|
37558
|
+
};
|
|
37559
|
+
return acc;
|
|
37560
|
+
}, {})
|
|
37561
|
+
});
|
|
37603
37562
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { className: `text-black `, children: cloned }, h);
|
|
37604
37563
|
}
|
|
37605
37564
|
return symbols && (symbols == null ? void 0 : symbols[h]) ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { className: `text-center border max-w-[${colSize}px] `, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1 w-full", children: [
|
|
@@ -37661,24 +37620,26 @@ function TableBody({
|
|
|
37661
37620
|
const row = objectData[id];
|
|
37662
37621
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
37663
37622
|
TR,
|
|
37664
|
-
|
|
37665
|
-
|
|
37666
|
-
|
|
37667
|
-
|
|
37668
|
-
|
|
37669
|
-
|
|
37670
|
-
|
|
37671
|
-
|
|
37672
|
-
|
|
37673
|
-
|
|
37674
|
-
|
|
37675
|
-
|
|
37676
|
-
|
|
37677
|
-
|
|
37678
|
-
|
|
37679
|
-
|
|
37680
|
-
|
|
37681
|
-
|
|
37623
|
+
{
|
|
37624
|
+
...{
|
|
37625
|
+
headers,
|
|
37626
|
+
index,
|
|
37627
|
+
setObjectData,
|
|
37628
|
+
id,
|
|
37629
|
+
row,
|
|
37630
|
+
handlers,
|
|
37631
|
+
selectItems,
|
|
37632
|
+
colSizes,
|
|
37633
|
+
modal,
|
|
37634
|
+
modalRef,
|
|
37635
|
+
dialogRow,
|
|
37636
|
+
symbols,
|
|
37637
|
+
setDialogRow,
|
|
37638
|
+
setSelected,
|
|
37639
|
+
selected,
|
|
37640
|
+
onChange
|
|
37641
|
+
}
|
|
37642
|
+
},
|
|
37682
37643
|
id
|
|
37683
37644
|
);
|
|
37684
37645
|
});
|
|
@@ -37720,7 +37681,7 @@ function Panel({
|
|
|
37720
37681
|
onClick: (e) => {
|
|
37721
37682
|
excel.export(
|
|
37722
37683
|
Object.values(objectData).reverse().map((d) => {
|
|
37723
|
-
const
|
|
37684
|
+
const { _visible, _id, _selected, ...data } = d;
|
|
37724
37685
|
return data;
|
|
37725
37686
|
}),
|
|
37726
37687
|
exportName + ".xlsx"
|
|
@@ -37865,69 +37826,60 @@ var dialog_default = Dialog4;
|
|
|
37865
37826
|
|
|
37866
37827
|
// src/table3/index.tsx
|
|
37867
37828
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
37868
|
-
function Table3(
|
|
37869
|
-
|
|
37870
|
-
|
|
37871
|
-
|
|
37872
|
-
|
|
37873
|
-
|
|
37874
|
-
|
|
37875
|
-
|
|
37876
|
-
|
|
37877
|
-
|
|
37878
|
-
|
|
37879
|
-
|
|
37880
|
-
|
|
37881
|
-
|
|
37882
|
-
|
|
37883
|
-
"data",
|
|
37884
|
-
"selectItems",
|
|
37885
|
-
"maxItems",
|
|
37886
|
-
"onSave",
|
|
37887
|
-
"exportName",
|
|
37888
|
-
"colSizes",
|
|
37889
|
-
"modal",
|
|
37890
|
-
"header",
|
|
37891
|
-
"footer",
|
|
37892
|
-
"onChange",
|
|
37893
|
-
"symbols",
|
|
37894
|
-
"sortBy"
|
|
37895
|
-
]);
|
|
37829
|
+
function Table3({
|
|
37830
|
+
data,
|
|
37831
|
+
selectItems,
|
|
37832
|
+
maxItems = Infinity,
|
|
37833
|
+
onSave,
|
|
37834
|
+
exportName,
|
|
37835
|
+
colSizes,
|
|
37836
|
+
modal,
|
|
37837
|
+
header,
|
|
37838
|
+
footer,
|
|
37839
|
+
onChange,
|
|
37840
|
+
symbols,
|
|
37841
|
+
sortBy,
|
|
37842
|
+
...props
|
|
37843
|
+
}) {
|
|
37896
37844
|
const [handlers, setHandlers] = (0, import_react15.useState)({});
|
|
37897
37845
|
const [page, setPage] = (0, import_react15.useState)(1);
|
|
37898
37846
|
function dataReducer(a, b) {
|
|
37899
37847
|
if (b == null) return {};
|
|
37900
37848
|
if (Array.isArray(b)) {
|
|
37901
37849
|
const obj = b.reduce((acc, bb) => {
|
|
37902
|
-
var
|
|
37850
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
37903
37851
|
const id = (bb == null ? void 0 : bb.id) || (bb == null ? void 0 : bb._id);
|
|
37904
37852
|
if (!id) throw new Error("Se necesita el id o _id");
|
|
37905
|
-
const cc = ((
|
|
37853
|
+
const cc = ((_a = a == null ? void 0 : a[id]) == null ? void 0 : _a._updated) ? {
|
|
37854
|
+
...bb,
|
|
37855
|
+
...a == null ? void 0 : a[id],
|
|
37906
37856
|
_selected: bb == null ? void 0 : bb._selected,
|
|
37907
37857
|
_visible: (bb == null ? void 0 : bb._visible) == false ? false : true
|
|
37908
|
-
}
|
|
37858
|
+
} : {
|
|
37859
|
+
...a == null ? void 0 : a[id],
|
|
37860
|
+
...bb,
|
|
37909
37861
|
_selected: bb == null ? void 0 : bb._selected,
|
|
37910
37862
|
_visible: (bb == null ? void 0 : bb._visible) == false ? false : true
|
|
37911
|
-
}
|
|
37912
|
-
const newHandlers =
|
|
37863
|
+
};
|
|
37864
|
+
const newHandlers = { ...handlers };
|
|
37913
37865
|
for (let item in cc) {
|
|
37914
37866
|
const isReactComponent = import_react15.default.isValidElement(cc[item]);
|
|
37915
37867
|
if (isReactComponent) {
|
|
37916
37868
|
newHandlers[item] = cc[item];
|
|
37917
|
-
const value = ((_c = (
|
|
37869
|
+
const value = ((_c = (_b = cc[item]) == null ? void 0 : _b.props) == null ? void 0 : _c.value) || (typeof ((_e = (_d = cc[item]) == null ? void 0 : _d.props) == null ? void 0 : _e.children) !== "object" ? (_g = (_f = cc[item]) == null ? void 0 : _f.props) == null ? void 0 : _g.children : "");
|
|
37918
37870
|
cc[item] = value || "";
|
|
37919
37871
|
}
|
|
37920
37872
|
}
|
|
37921
37873
|
setHandlers(newHandlers);
|
|
37922
|
-
acc[id] =
|
|
37874
|
+
acc[id] = { ...bb, ...cc };
|
|
37923
37875
|
return acc;
|
|
37924
37876
|
}, {});
|
|
37925
37877
|
return obj;
|
|
37926
37878
|
} else {
|
|
37927
|
-
const newA =
|
|
37879
|
+
const newA = { ...a };
|
|
37928
37880
|
const id = (b == null ? void 0 : b.id) || (b == null ? void 0 : b._id);
|
|
37929
37881
|
if (!id) throw new Error("Se necesita el id o _id para actualizar");
|
|
37930
|
-
newA[id] =
|
|
37882
|
+
newA[id] = { ...newA[id], ...b };
|
|
37931
37883
|
return newA;
|
|
37932
37884
|
}
|
|
37933
37885
|
}
|
|
@@ -37951,7 +37903,7 @@ function Table3(_a) {
|
|
|
37951
37903
|
const [sort, setSort] = (0, import_react15.useState)(sortBy);
|
|
37952
37904
|
const modalRef = (0, import_react15.useRef)(null);
|
|
37953
37905
|
const [dialogRow, setDialogRow] = (0, import_react15.useState)({});
|
|
37954
|
-
const context =
|
|
37906
|
+
const context = {
|
|
37955
37907
|
objectData,
|
|
37956
37908
|
headers,
|
|
37957
37909
|
handlers,
|
|
@@ -37974,15 +37926,16 @@ function Table3(_a) {
|
|
|
37974
37926
|
data,
|
|
37975
37927
|
symbols,
|
|
37976
37928
|
sort,
|
|
37977
|
-
setSort
|
|
37978
|
-
|
|
37929
|
+
setSort,
|
|
37930
|
+
...props
|
|
37931
|
+
};
|
|
37979
37932
|
(0, import_react15.useEffect)(() => {
|
|
37980
37933
|
if ((dialogRow == null ? void 0 : dialogRow.id) || (dialogRow == null ? void 0 : dialogRow._id)) {
|
|
37981
37934
|
const newDialogRow = objectData[dialogRow == null ? void 0 : dialogRow.id] || objectData[dialogRow == null ? void 0 : dialogRow._id];
|
|
37982
37935
|
setDialogRow(newDialogRow);
|
|
37983
37936
|
}
|
|
37984
37937
|
}, [objectData]);
|
|
37985
|
-
const style = (props == null ? void 0 : props.style) ?
|
|
37938
|
+
const style = (props == null ? void 0 : props.style) ? { ...props.style, tableLayout: "fixed" } : { tableLayout: "fixed" };
|
|
37986
37939
|
if (!objectData) return null;
|
|
37987
37940
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "border shadow rounded m-1 p-1 bg-white", children: [
|
|
37988
37941
|
modal && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
@@ -37996,12 +37949,12 @@ function Table3(_a) {
|
|
|
37996
37949
|
}
|
|
37997
37950
|
),
|
|
37998
37951
|
header && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "font-bold text-2xl py-5 px-2 bg-blue-50", children: header }),
|
|
37999
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Panel,
|
|
38000
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("table",
|
|
38001
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TableHead,
|
|
38002
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TableBody,
|
|
38003
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TableFooter,
|
|
38004
|
-
] })
|
|
37952
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Panel, { ...context }),
|
|
37953
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("table", { ...props, style, children: [
|
|
37954
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TableHead, { ...context }),
|
|
37955
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TableBody, { ...context }),
|
|
37956
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TableFooter, { ...context })
|
|
37957
|
+
] })
|
|
38005
37958
|
] });
|
|
38006
37959
|
}
|
|
38007
37960
|
// Annotate the CommonJS export names for ESM import in node:
|