next-recomponents 2.0.28 → 2.0.30
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 +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +170 -95
- package/dist/index.mjs +127 -52
- package/package.json +1 -1
- package/src/input/index.tsx +66 -12
- package/src/table/index.tsx +33 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1, { DetailedHTMLProps, ButtonHTMLAttributes, ReactNode, Dispatch, SetStateAction, InputHTMLAttributes, TextareaHTMLAttributes, ReactElement, TableHTMLAttributes } from 'react';
|
|
3
|
+
import { React as React$2 } from 'next/dist/server/route-modules/app-page/vendored/rsc/entrypoints';
|
|
3
4
|
import { GridValidRowModel } from '@mui/x-data-grid';
|
|
4
5
|
|
|
5
6
|
interface Props$5 extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -46,10 +47,10 @@ interface Props$3 {
|
|
|
46
47
|
declare function useFormValues<T>(initial: Partial<T>): [Partial<T>, React$1.ActionDispatch<[action: Partial<T>]>];
|
|
47
48
|
declare function Form({ onSubmit, state, invalidMessage, children, loader, ...otherProps }: Props$3): react_jsx_runtime.JSX.Element;
|
|
48
49
|
|
|
49
|
-
interface InputProps extends
|
|
50
|
-
label: React.ReactNode;
|
|
50
|
+
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
51
|
+
label: React$2.ReactNode;
|
|
51
52
|
regex?: RegExp;
|
|
52
|
-
invalidMessage?: React.ReactNode;
|
|
53
|
+
invalidMessage?: React$2.ReactNode;
|
|
53
54
|
}
|
|
54
55
|
declare function Input({ label, className, regex, invalidMessage, ...props }: InputProps): react_jsx_runtime.JSX.Element;
|
|
55
56
|
|
|
@@ -111,6 +112,14 @@ interface TableProps {
|
|
|
111
112
|
* - "comfortable" → padding generoso, fácil de leer
|
|
112
113
|
*/
|
|
113
114
|
density?: GridDensity;
|
|
115
|
+
/**
|
|
116
|
+
* Cuando es true, el alto del contenedor se ajusta automáticamente
|
|
117
|
+
* al contenido de la tabla, eliminando el scroll vertical.
|
|
118
|
+
* Compatible con `wrapText` (filas de alto variable) y con
|
|
119
|
+
* cualquier valor de `density`. Cuando está activo, las props
|
|
120
|
+
* `height` y `HEIGHT_MAP` se ignoran.
|
|
121
|
+
*/
|
|
122
|
+
autoHeight?: boolean;
|
|
114
123
|
[key: string]: any;
|
|
115
124
|
}
|
|
116
125
|
declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1, { DetailedHTMLProps, ButtonHTMLAttributes, ReactNode, Dispatch, SetStateAction, InputHTMLAttributes, TextareaHTMLAttributes, ReactElement, TableHTMLAttributes } from 'react';
|
|
3
|
+
import { React as React$2 } from 'next/dist/server/route-modules/app-page/vendored/rsc/entrypoints';
|
|
3
4
|
import { GridValidRowModel } from '@mui/x-data-grid';
|
|
4
5
|
|
|
5
6
|
interface Props$5 extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -46,10 +47,10 @@ interface Props$3 {
|
|
|
46
47
|
declare function useFormValues<T>(initial: Partial<T>): [Partial<T>, React$1.ActionDispatch<[action: Partial<T>]>];
|
|
47
48
|
declare function Form({ onSubmit, state, invalidMessage, children, loader, ...otherProps }: Props$3): react_jsx_runtime.JSX.Element;
|
|
48
49
|
|
|
49
|
-
interface InputProps extends
|
|
50
|
-
label: React.ReactNode;
|
|
50
|
+
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
51
|
+
label: React$2.ReactNode;
|
|
51
52
|
regex?: RegExp;
|
|
52
|
-
invalidMessage?: React.ReactNode;
|
|
53
|
+
invalidMessage?: React$2.ReactNode;
|
|
53
54
|
}
|
|
54
55
|
declare function Input({ label, className, regex, invalidMessage, ...props }: InputProps): react_jsx_runtime.JSX.Element;
|
|
55
56
|
|
|
@@ -111,6 +112,14 @@ interface TableProps {
|
|
|
111
112
|
* - "comfortable" → padding generoso, fácil de leer
|
|
112
113
|
*/
|
|
113
114
|
density?: GridDensity;
|
|
115
|
+
/**
|
|
116
|
+
* Cuando es true, el alto del contenedor se ajusta automáticamente
|
|
117
|
+
* al contenido de la tabla, eliminando el scroll vertical.
|
|
118
|
+
* Compatible con `wrapText` (filas de alto variable) y con
|
|
119
|
+
* cualquier valor de `density`. Cuando está activo, las props
|
|
120
|
+
* `height` y `HEIGHT_MAP` se ignoran.
|
|
121
|
+
*/
|
|
122
|
+
autoHeight?: boolean;
|
|
114
123
|
[key: string]: any;
|
|
115
124
|
}
|
|
116
125
|
declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -3885,6 +3885,7 @@ function Form({
|
|
|
3885
3885
|
}
|
|
3886
3886
|
|
|
3887
3887
|
// src/input/index.tsx
|
|
3888
|
+
var import_react4 = require("react");
|
|
3888
3889
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3889
3890
|
function Input({
|
|
3890
3891
|
label,
|
|
@@ -3895,27 +3896,96 @@ function Input({
|
|
|
3895
3896
|
}) {
|
|
3896
3897
|
const value = `${(props == null ? void 0 : props.value) || ""}`;
|
|
3897
3898
|
const isValid = !regex ? true : regex.test(value);
|
|
3899
|
+
const isPassword = props.type === "password";
|
|
3900
|
+
const [showPassword, setShowPassword] = (0, import_react4.useState)(false);
|
|
3898
3901
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w-full", children: [
|
|
3899
3902
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
3900
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "font-bold
|
|
3903
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "font-bold", children: [
|
|
3901
3904
|
label,
|
|
3902
3905
|
" ",
|
|
3903
3906
|
(props == null ? void 0 : props.required) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-red-500", children: "*" })
|
|
3904
3907
|
] }),
|
|
3905
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3908
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative", children: [
|
|
3909
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3910
|
+
"input",
|
|
3911
|
+
{
|
|
3912
|
+
...props,
|
|
3913
|
+
type: isPassword && showPassword ? "text" : props.type,
|
|
3914
|
+
className: [
|
|
3915
|
+
"p-2 w-full rounded border shadow",
|
|
3916
|
+
isPassword && "pr-10",
|
|
3917
|
+
value !== "" && !isValid && "bg-red-200 text-black",
|
|
3918
|
+
value !== "" && isValid && "bg-green-200 text-black",
|
|
3919
|
+
className
|
|
3920
|
+
].filter(Boolean).join(" ")
|
|
3921
|
+
}
|
|
3922
|
+
),
|
|
3923
|
+
isPassword && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3924
|
+
"button",
|
|
3925
|
+
{
|
|
3926
|
+
type: "button",
|
|
3927
|
+
onClick: () => setShowPassword((prev) => !prev),
|
|
3928
|
+
className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-800 focus:outline-none",
|
|
3929
|
+
"aria-label": showPassword ? "Ocultar contrase\xF1a" : "Mostrar contrase\xF1a",
|
|
3930
|
+
children: showPassword ? (
|
|
3931
|
+
// Ojo cerrado (ocultar)
|
|
3932
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3933
|
+
"svg",
|
|
3934
|
+
{
|
|
3935
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3936
|
+
className: "h-5 w-5",
|
|
3937
|
+
fill: "none",
|
|
3938
|
+
viewBox: "0 0 24 24",
|
|
3939
|
+
stroke: "currentColor",
|
|
3940
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3941
|
+
"path",
|
|
3942
|
+
{
|
|
3943
|
+
strokeLinecap: "round",
|
|
3944
|
+
strokeLinejoin: "round",
|
|
3945
|
+
strokeWidth: 2,
|
|
3946
|
+
d: "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"
|
|
3947
|
+
}
|
|
3948
|
+
)
|
|
3949
|
+
}
|
|
3950
|
+
)
|
|
3951
|
+
) : (
|
|
3952
|
+
// Ojo abierto (mostrar)
|
|
3953
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3954
|
+
"svg",
|
|
3955
|
+
{
|
|
3956
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3957
|
+
className: "h-5 w-5",
|
|
3958
|
+
fill: "none",
|
|
3959
|
+
viewBox: "0 0 24 24",
|
|
3960
|
+
stroke: "currentColor",
|
|
3961
|
+
children: [
|
|
3962
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3963
|
+
"path",
|
|
3964
|
+
{
|
|
3965
|
+
strokeLinecap: "round",
|
|
3966
|
+
strokeLinejoin: "round",
|
|
3967
|
+
strokeWidth: 2,
|
|
3968
|
+
d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
3969
|
+
}
|
|
3970
|
+
),
|
|
3971
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3972
|
+
"path",
|
|
3973
|
+
{
|
|
3974
|
+
strokeLinecap: "round",
|
|
3975
|
+
strokeLinejoin: "round",
|
|
3976
|
+
strokeWidth: 2,
|
|
3977
|
+
d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
|
|
3978
|
+
}
|
|
3979
|
+
)
|
|
3980
|
+
]
|
|
3981
|
+
}
|
|
3982
|
+
)
|
|
3983
|
+
)
|
|
3984
|
+
}
|
|
3985
|
+
)
|
|
3986
|
+
] })
|
|
3917
3987
|
] }),
|
|
3918
|
-
!isValid && value
|
|
3988
|
+
!isValid && value !== "" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-red-800 invalid", children: invalidMessage })
|
|
3919
3989
|
] });
|
|
3920
3990
|
}
|
|
3921
3991
|
|
|
@@ -3930,7 +4000,7 @@ var regular_expresions_default = regularExpresions;
|
|
|
3930
4000
|
// src/table/index.tsx
|
|
3931
4001
|
var import_x_data_grid = require("@mui/x-data-grid");
|
|
3932
4002
|
var import_material = require("@mui/material");
|
|
3933
|
-
var
|
|
4003
|
+
var import_react5 = __toESM(require("react"));
|
|
3934
4004
|
|
|
3935
4005
|
// ../../node_modules/xlsx/xlsx.mjs
|
|
3936
4006
|
var XLSX = {};
|
|
@@ -35782,7 +35852,7 @@ function ModalDialog({ open, onClose, modal, selectedRow }) {
|
|
|
35782
35852
|
children: "\xD7"
|
|
35783
35853
|
}
|
|
35784
35854
|
) }),
|
|
35785
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-4 m-auto p-5", children: selectedRow &&
|
|
35855
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-4 m-auto p-5", children: selectedRow && import_react5.default.cloneElement(
|
|
35786
35856
|
modal,
|
|
35787
35857
|
{ row: selectedRow, hide: onClose }
|
|
35788
35858
|
) })
|
|
@@ -35832,7 +35902,7 @@ function useColumns(rows, currentCoin, options, colSize) {
|
|
|
35832
35902
|
handleRowUpdate,
|
|
35833
35903
|
onModalOpen
|
|
35834
35904
|
} = options;
|
|
35835
|
-
return (0,
|
|
35905
|
+
return (0, import_react5.useMemo)(() => {
|
|
35836
35906
|
if (!rows.length) return [];
|
|
35837
35907
|
const cols = Object.keys(rows[0]).filter((key) => !key.startsWith("_") && !hideColumns.includes(key)).map((key) => {
|
|
35838
35908
|
var _a, _b;
|
|
@@ -35884,7 +35954,7 @@ function useColumns(rows, currentCoin, options, colSize) {
|
|
|
35884
35954
|
renderCell: (buttons == null ? void 0 : buttons[key]) ? (params) => {
|
|
35885
35955
|
var _a2, _b2, _c;
|
|
35886
35956
|
const children = ((_a2 = buttons == null ? void 0 : buttons[key]) == null ? void 0 : _a2.type) == "input" ? null : (_b2 = params == null ? void 0 : params.row) == null ? void 0 : _b2[key];
|
|
35887
|
-
return
|
|
35957
|
+
return import_react5.default.cloneElement(buttons[key], {
|
|
35888
35958
|
className: `${(_c = params == null ? void 0 : params.className) != null ? _c : ""} m-auto text-xs`,
|
|
35889
35959
|
children,
|
|
35890
35960
|
row: params == null ? void 0 : params.row,
|
|
@@ -36014,21 +36084,22 @@ function IHTable({
|
|
|
36014
36084
|
rowHeight,
|
|
36015
36085
|
wrapText = false,
|
|
36016
36086
|
density = "standard",
|
|
36017
|
-
searchable = false
|
|
36087
|
+
searchable = false,
|
|
36088
|
+
autoHeight = false
|
|
36018
36089
|
}) {
|
|
36019
36090
|
var _a;
|
|
36020
36091
|
if (modal && onSelect)
|
|
36021
36092
|
throw new Error("Solo se puede usar modal o onSelect por separado");
|
|
36022
|
-
const [open, setOpen] = (0,
|
|
36023
|
-
const [rows, setRows] = (0,
|
|
36024
|
-
const [selectedRows, setSelectedRows] = (0,
|
|
36093
|
+
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
36094
|
+
const [rows, setRows] = (0, import_react5.useState)(data);
|
|
36095
|
+
const [selectedRows, setSelectedRows] = (0, import_react5.useState)({
|
|
36025
36096
|
type: "include",
|
|
36026
36097
|
ids: /* @__PURE__ */ new Set()
|
|
36027
36098
|
});
|
|
36028
|
-
const [modalRow, setModalRow] = (0,
|
|
36029
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
36099
|
+
const [modalRow, setModalRow] = (0, import_react5.useState)();
|
|
36100
|
+
const [searchQuery, setSearchQuery] = (0, import_react5.useState)("");
|
|
36030
36101
|
const resolvedButtons = modal ? { ...buttons, Modal: "" } : buttons;
|
|
36031
|
-
(0,
|
|
36102
|
+
(0, import_react5.useEffect)(() => {
|
|
36032
36103
|
setRows(data);
|
|
36033
36104
|
}, [data]);
|
|
36034
36105
|
const handleModalOpen = (row) => {
|
|
@@ -36049,7 +36120,7 @@ function IHTable({
|
|
|
36049
36120
|
);
|
|
36050
36121
|
return updated;
|
|
36051
36122
|
};
|
|
36052
|
-
const filteredRows = (0,
|
|
36123
|
+
const filteredRows = (0, import_react5.useMemo)(() => {
|
|
36053
36124
|
if ((selectedRows == null ? void 0 : selectedRows.type) === "exclude") {
|
|
36054
36125
|
return rows.filter((r) => !Array.from(selectedRows.ids).includes(r.id));
|
|
36055
36126
|
}
|
|
@@ -36058,7 +36129,7 @@ function IHTable({
|
|
|
36058
36129
|
}
|
|
36059
36130
|
return [];
|
|
36060
36131
|
}, [selectedRows, rows]);
|
|
36061
|
-
const displayRows = (0,
|
|
36132
|
+
const displayRows = (0, import_react5.useMemo)(
|
|
36062
36133
|
() => searchable ? rows.filter((r) => rowMatchesSearch(r, searchQuery)) : rows,
|
|
36063
36134
|
[rows, searchQuery, searchable]
|
|
36064
36135
|
);
|
|
@@ -36079,6 +36150,8 @@ function IHTable({
|
|
|
36079
36150
|
);
|
|
36080
36151
|
if (!rows.length) return null;
|
|
36081
36152
|
const rowHeightProps = wrapText ? { getRowHeight: () => "auto" } : rowHeight != null ? { rowHeight } : {};
|
|
36153
|
+
const containerHeight = autoHeight ? void 0 : (_a = HEIGHT_MAP[displayRows.length]) != null ? _a : height;
|
|
36154
|
+
const hideFooter = autoHeight || displayRows.length <= Object.keys(HEIGHT_MAP).length;
|
|
36082
36155
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "m-2", children: [
|
|
36083
36156
|
header && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "font-bold p-2 ", children: header }),
|
|
36084
36157
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex justify-between", children: [
|
|
@@ -36100,7 +36173,8 @@ function IHTable({
|
|
|
36100
36173
|
sx: {
|
|
36101
36174
|
display: "flex",
|
|
36102
36175
|
flexDirection: "column",
|
|
36103
|
-
|
|
36176
|
+
// undefined height lets the child DataGrid size itself freely
|
|
36177
|
+
height: containerHeight,
|
|
36104
36178
|
width,
|
|
36105
36179
|
zIndex: 999999999
|
|
36106
36180
|
},
|
|
@@ -36121,6 +36195,7 @@ function IHTable({
|
|
|
36121
36195
|
rows: displayRows,
|
|
36122
36196
|
columns,
|
|
36123
36197
|
density,
|
|
36198
|
+
autoHeight,
|
|
36124
36199
|
checkboxSelection: Boolean(onSelect),
|
|
36125
36200
|
rowSelectionModel: selectedRows,
|
|
36126
36201
|
onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
|
|
@@ -36162,7 +36237,7 @@ function IHTable({
|
|
|
36162
36237
|
editMode: "row",
|
|
36163
36238
|
processRowUpdate: handleRowUpdate,
|
|
36164
36239
|
pageSizeOptions: [5, 10],
|
|
36165
|
-
hideFooter
|
|
36240
|
+
hideFooter
|
|
36166
36241
|
}
|
|
36167
36242
|
)
|
|
36168
36243
|
]
|
|
@@ -36179,7 +36254,7 @@ function Table(props) {
|
|
|
36179
36254
|
}
|
|
36180
36255
|
|
|
36181
36256
|
// src/text-area/index.tsx
|
|
36182
|
-
var
|
|
36257
|
+
var import_react6 = require("react");
|
|
36183
36258
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
36184
36259
|
function TextArea({
|
|
36185
36260
|
label,
|
|
@@ -36189,7 +36264,7 @@ function TextArea({
|
|
|
36189
36264
|
children = "",
|
|
36190
36265
|
...props
|
|
36191
36266
|
}) {
|
|
36192
|
-
const [value, setValue] = (0,
|
|
36267
|
+
const [value, setValue] = (0, import_react6.useState)((props == null ? void 0 : props.value) || "");
|
|
36193
36268
|
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: [
|
|
36194
36269
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "font-bold ", children: [
|
|
36195
36270
|
label,
|
|
@@ -36224,12 +36299,12 @@ function TextArea({
|
|
|
36224
36299
|
}
|
|
36225
36300
|
|
|
36226
36301
|
// src/use-resources/index.ts
|
|
36227
|
-
var
|
|
36302
|
+
var import_react8 = require("react");
|
|
36228
36303
|
|
|
36229
36304
|
// src/use-resources/get.token.tsx
|
|
36230
|
-
var
|
|
36305
|
+
var import_react7 = require("react");
|
|
36231
36306
|
function useToken() {
|
|
36232
|
-
const token = (0,
|
|
36307
|
+
const token = (0, import_react7.useMemo)(() => {
|
|
36233
36308
|
if (typeof window != "undefined") {
|
|
36234
36309
|
const t = window.localStorage.getItem("token");
|
|
36235
36310
|
if (t) return t;
|
|
@@ -36321,7 +36396,7 @@ function useResources({
|
|
|
36321
36396
|
onError
|
|
36322
36397
|
}) {
|
|
36323
36398
|
const token = useToken();
|
|
36324
|
-
const [info, setInfo] = (0,
|
|
36399
|
+
const [info, setInfo] = (0, import_react8.useState)(
|
|
36325
36400
|
Object.keys(endpoints).reduce((acc, key) => {
|
|
36326
36401
|
var _a, _b;
|
|
36327
36402
|
const newAcc = {
|
|
@@ -36704,14 +36779,14 @@ function useResources({
|
|
|
36704
36779
|
}
|
|
36705
36780
|
}
|
|
36706
36781
|
}
|
|
36707
|
-
(0,
|
|
36782
|
+
(0, import_react8.useEffect)(() => {
|
|
36708
36783
|
doSome();
|
|
36709
36784
|
}, [JSON.stringify(Object.values(info).map((v) => v.loaded))]);
|
|
36710
36785
|
return results;
|
|
36711
36786
|
}
|
|
36712
36787
|
|
|
36713
36788
|
// src/select/index.tsx
|
|
36714
|
-
var
|
|
36789
|
+
var import_react9 = __toESM(require("react"));
|
|
36715
36790
|
|
|
36716
36791
|
// src/select/icon.tsx
|
|
36717
36792
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
@@ -36758,24 +36833,24 @@ function Select({
|
|
|
36758
36833
|
strictMode = true,
|
|
36759
36834
|
...props
|
|
36760
36835
|
}) {
|
|
36761
|
-
const [isOpen, setIsOpen] = (0,
|
|
36762
|
-
const [inputValue, setInputValue] = (0,
|
|
36763
|
-
const [options, setOptions] = (0,
|
|
36836
|
+
const [isOpen, setIsOpen] = (0, import_react9.useState)(false);
|
|
36837
|
+
const [inputValue, setInputValue] = (0, import_react9.useState)("");
|
|
36838
|
+
const [options, setOptions] = (0, import_react9.useState)(
|
|
36764
36839
|
[]
|
|
36765
36840
|
);
|
|
36766
|
-
const [filtered, setFiltered] = (0,
|
|
36841
|
+
const [filtered, setFiltered] = (0, import_react9.useState)(
|
|
36767
36842
|
[]
|
|
36768
36843
|
);
|
|
36769
|
-
const [hasEdition, setHasEdition] = (0,
|
|
36770
|
-
const [highlightedIndex, setHighlightedIndex] = (0,
|
|
36771
|
-
const inputRef = (0,
|
|
36844
|
+
const [hasEdition, setHasEdition] = (0, import_react9.useState)(false);
|
|
36845
|
+
const [highlightedIndex, setHighlightedIndex] = (0, import_react9.useState)(-1);
|
|
36846
|
+
const inputRef = (0, import_react9.useRef)(null);
|
|
36772
36847
|
const validOption = (value) => {
|
|
36773
36848
|
return options.find((opt) => opt.label == value);
|
|
36774
36849
|
};
|
|
36775
36850
|
const normalize = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z]/g, "");
|
|
36776
|
-
(0,
|
|
36851
|
+
(0, import_react9.useEffect)(() => {
|
|
36777
36852
|
var _a;
|
|
36778
|
-
const parsedOptions =
|
|
36853
|
+
const parsedOptions = import_react9.default.Children.toArray(children).filter((child) => {
|
|
36779
36854
|
return child.type === "option";
|
|
36780
36855
|
}).map((child) => {
|
|
36781
36856
|
return {
|
|
@@ -36788,7 +36863,7 @@ function Select({
|
|
|
36788
36863
|
const value = (props == null ? void 0 : props.value) && ((_a = parsedOptions.find((opt) => opt.value == props.value)) == null ? void 0 : _a.label);
|
|
36789
36864
|
setInputValue(value);
|
|
36790
36865
|
}, [children]);
|
|
36791
|
-
(0,
|
|
36866
|
+
(0, import_react9.useEffect)(() => {
|
|
36792
36867
|
const items = options.filter((opt) => {
|
|
36793
36868
|
if (!hasEdition) return true;
|
|
36794
36869
|
const normilizedLabel = normalize(`${opt == null ? void 0 : opt.label}`);
|
|
@@ -36816,9 +36891,9 @@ function Select({
|
|
|
36816
36891
|
setInputValue(opt.label);
|
|
36817
36892
|
setIsOpen(false);
|
|
36818
36893
|
};
|
|
36819
|
-
const containerRef = (0,
|
|
36820
|
-
const [openUpwards, setOpenUpwards] = (0,
|
|
36821
|
-
(0,
|
|
36894
|
+
const containerRef = (0, import_react9.useRef)(null);
|
|
36895
|
+
const [openUpwards, setOpenUpwards] = (0, import_react9.useState)(false);
|
|
36896
|
+
(0, import_react9.useEffect)(() => {
|
|
36822
36897
|
if (isOpen && containerRef.current) {
|
|
36823
36898
|
const rect = containerRef.current.getBoundingClientRect();
|
|
36824
36899
|
const spaceBelow = window.innerHeight - rect.bottom;
|
|
@@ -36951,10 +37026,10 @@ function Select({
|
|
|
36951
37026
|
}
|
|
36952
37027
|
|
|
36953
37028
|
// src/modal/index.tsx
|
|
36954
|
-
var
|
|
37029
|
+
var import_react11 = require("react");
|
|
36955
37030
|
|
|
36956
37031
|
// src/pop/index.tsx
|
|
36957
|
-
var
|
|
37032
|
+
var import_react10 = require("react");
|
|
36958
37033
|
|
|
36959
37034
|
// src/pop/actions.tsx
|
|
36960
37035
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
@@ -37198,9 +37273,9 @@ var INITIAL_STATE = {
|
|
|
37198
37273
|
full: false
|
|
37199
37274
|
};
|
|
37200
37275
|
function usePopup() {
|
|
37201
|
-
const [popup, setPopup] = (0,
|
|
37202
|
-
const messageRef = (0,
|
|
37203
|
-
const open = (0,
|
|
37276
|
+
const [popup, setPopup] = (0, import_react10.useState)(INITIAL_STATE);
|
|
37277
|
+
const messageRef = (0, import_react10.useRef)(null);
|
|
37278
|
+
const open = (0, import_react10.useCallback)(
|
|
37204
37279
|
(partial) => {
|
|
37205
37280
|
const { message, ...rest } = partial;
|
|
37206
37281
|
messageRef.current = message;
|
|
@@ -37208,7 +37283,7 @@ function usePopup() {
|
|
|
37208
37283
|
},
|
|
37209
37284
|
[]
|
|
37210
37285
|
);
|
|
37211
|
-
const close = (0,
|
|
37286
|
+
const close = (0, import_react10.useCallback)((confirmed, value) => {
|
|
37212
37287
|
setPopup((prev) => {
|
|
37213
37288
|
var _a, _b;
|
|
37214
37289
|
if (confirmed) (_a = prev.onConfirm) == null ? void 0 : _a.call(prev, value);
|
|
@@ -37216,7 +37291,7 @@ function usePopup() {
|
|
|
37216
37291
|
return { ...prev, visible: false, inputValue: "" };
|
|
37217
37292
|
});
|
|
37218
37293
|
}, []);
|
|
37219
|
-
const alert2 = (0,
|
|
37294
|
+
const alert2 = (0, import_react10.useCallback)(
|
|
37220
37295
|
(message, color = "primary") => new Promise(
|
|
37221
37296
|
(resolve) => open({
|
|
37222
37297
|
type: "alert",
|
|
@@ -37228,7 +37303,7 @@ function usePopup() {
|
|
|
37228
37303
|
),
|
|
37229
37304
|
[open]
|
|
37230
37305
|
);
|
|
37231
|
-
const modal = (0,
|
|
37306
|
+
const modal = (0, import_react10.useCallback)(
|
|
37232
37307
|
(message, color = "primary", icons = false, full = false) => new Promise(
|
|
37233
37308
|
(resolve) => open({
|
|
37234
37309
|
type: "modal",
|
|
@@ -37242,7 +37317,7 @@ function usePopup() {
|
|
|
37242
37317
|
),
|
|
37243
37318
|
[open]
|
|
37244
37319
|
);
|
|
37245
|
-
const confirm = (0,
|
|
37320
|
+
const confirm = (0, import_react10.useCallback)(
|
|
37246
37321
|
(message, color = "primary") => new Promise(
|
|
37247
37322
|
(resolve) => open({
|
|
37248
37323
|
type: "confirm",
|
|
@@ -37254,7 +37329,7 @@ function usePopup() {
|
|
|
37254
37329
|
),
|
|
37255
37330
|
[open]
|
|
37256
37331
|
);
|
|
37257
|
-
const prompt = (0,
|
|
37332
|
+
const prompt = (0, import_react10.useCallback)(
|
|
37258
37333
|
(message, color = "primary") => new Promise(
|
|
37259
37334
|
(resolve) => open({
|
|
37260
37335
|
type: "prompt",
|
|
@@ -37266,7 +37341,7 @@ function usePopup() {
|
|
|
37266
37341
|
),
|
|
37267
37342
|
[open]
|
|
37268
37343
|
);
|
|
37269
|
-
const updateMessage = (0,
|
|
37344
|
+
const updateMessage = (0, import_react10.useCallback)((message) => {
|
|
37270
37345
|
messageRef.current = message;
|
|
37271
37346
|
setPopup((prev) => ({ ...prev }));
|
|
37272
37347
|
}, []);
|
|
@@ -37299,14 +37374,14 @@ function Modal({
|
|
|
37299
37374
|
}) {
|
|
37300
37375
|
const pop = usePopup();
|
|
37301
37376
|
const hide = () => pop.close(false);
|
|
37302
|
-
const childrenWithHide = (0,
|
|
37303
|
-
(0,
|
|
37377
|
+
const childrenWithHide = (0, import_react11.cloneElement)(children, { hide });
|
|
37378
|
+
(0, import_react11.useEffect)(() => {
|
|
37304
37379
|
pop.updateMessage(childrenWithHide);
|
|
37305
37380
|
}, [children]);
|
|
37306
37381
|
const props = button == null ? void 0 : button.props;
|
|
37307
37382
|
const onClick = props == null ? void 0 : props.onClick;
|
|
37308
37383
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
37309
|
-
(0,
|
|
37384
|
+
(0, import_react11.cloneElement)(button, {
|
|
37310
37385
|
onClick: (e) => {
|
|
37311
37386
|
onClick == null ? void 0 : onClick(e);
|
|
37312
37387
|
pop.modal(childrenWithHide, color, false, true);
|
|
@@ -37365,7 +37440,7 @@ function useDates() {
|
|
|
37365
37440
|
}
|
|
37366
37441
|
|
|
37367
37442
|
// src/calendar/index.tsx
|
|
37368
|
-
var
|
|
37443
|
+
var import_react12 = require("react");
|
|
37369
37444
|
var import_react_datepicker = __toESM(require("react-datepicker"));
|
|
37370
37445
|
|
|
37371
37446
|
// src/calendar/calendar.icon.tsx
|
|
@@ -37398,11 +37473,11 @@ function MyCalendar({
|
|
|
37398
37473
|
value,
|
|
37399
37474
|
...otherProps
|
|
37400
37475
|
}) {
|
|
37401
|
-
const [selectedDate, setSelectedDate] = (0,
|
|
37402
|
-
const [dateStr, setDateStr] = (0,
|
|
37476
|
+
const [selectedDate, setSelectedDate] = (0, import_react12.useState)(null);
|
|
37477
|
+
const [dateStr, setDateStr] = (0, import_react12.useState)(
|
|
37403
37478
|
defaultValue || value || ""
|
|
37404
37479
|
);
|
|
37405
|
-
const [open, setOpen] = (0,
|
|
37480
|
+
const [open, setOpen] = (0, import_react12.useState)(false);
|
|
37406
37481
|
function handleChange(date) {
|
|
37407
37482
|
if (!date) return;
|
|
37408
37483
|
setSelectedDate(date);
|
|
@@ -37555,10 +37630,10 @@ function DocumentViewer({ item }) {
|
|
|
37555
37630
|
}
|
|
37556
37631
|
|
|
37557
37632
|
// src/table3/index.tsx
|
|
37558
|
-
var
|
|
37633
|
+
var import_react17 = __toESM(require("react"));
|
|
37559
37634
|
|
|
37560
37635
|
// src/table3/filter.tsx
|
|
37561
|
-
var
|
|
37636
|
+
var import_react13 = require("react");
|
|
37562
37637
|
|
|
37563
37638
|
// src/table3/filters.tsx
|
|
37564
37639
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
@@ -37668,14 +37743,14 @@ function Filter({
|
|
|
37668
37743
|
sort,
|
|
37669
37744
|
setSort
|
|
37670
37745
|
}) {
|
|
37671
|
-
const [visible, setVisible] = (0,
|
|
37672
|
-
const [text, setText] = (0,
|
|
37673
|
-
const items = (0,
|
|
37746
|
+
const [visible, setVisible] = (0, import_react13.useState)(false);
|
|
37747
|
+
const [text, setText] = (0, import_react13.useState)("");
|
|
37748
|
+
const items = (0, import_react13.useMemo)(
|
|
37674
37749
|
() => [...new Set(Object.values(objectData).map((o) => o[h]))],
|
|
37675
37750
|
[objectData]
|
|
37676
37751
|
);
|
|
37677
|
-
const [selected, setSelected] = (0,
|
|
37678
|
-
const itemsFiltered = (0,
|
|
37752
|
+
const [selected, setSelected] = (0, import_react13.useState)(items);
|
|
37753
|
+
const itemsFiltered = (0, import_react13.useMemo)(
|
|
37679
37754
|
() => items.sort((a, b) => `${a}`.localeCompare(b)).filter((item) => {
|
|
37680
37755
|
if (!text) return true;
|
|
37681
37756
|
return `${item}`.toLowerCase().includes(text.toLowerCase());
|
|
@@ -37712,7 +37787,7 @@ function Filter({
|
|
|
37712
37787
|
const hidden = Object.values(objectData).filter(
|
|
37713
37788
|
(d) => d._visible === false
|
|
37714
37789
|
);
|
|
37715
|
-
(0,
|
|
37790
|
+
(0, import_react13.useEffect)(() => {
|
|
37716
37791
|
if (data.length != Object.values(objectData).map((o) => (o == null ? void 0 : o._id) || (o == null ? void 0 : o.id)).length) {
|
|
37717
37792
|
const news = [...new Set(data.map((o) => o[h]))];
|
|
37718
37793
|
setSelected(news);
|
|
@@ -37963,10 +38038,10 @@ function TableHead({
|
|
|
37963
38038
|
}
|
|
37964
38039
|
|
|
37965
38040
|
// src/table3/body.tsx
|
|
37966
|
-
var
|
|
38041
|
+
var import_react15 = require("react");
|
|
37967
38042
|
|
|
37968
38043
|
// src/table3/tr.tsx
|
|
37969
|
-
var
|
|
38044
|
+
var import_react14 = __toESM(require("react"));
|
|
37970
38045
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
37971
38046
|
function TR({
|
|
37972
38047
|
handlers,
|
|
@@ -38028,7 +38103,7 @@ function TR({
|
|
|
38028
38103
|
return null;
|
|
38029
38104
|
} else if (handlers == null ? void 0 : handlers[h]) {
|
|
38030
38105
|
const original = handlers[h];
|
|
38031
|
-
const cloned =
|
|
38106
|
+
const cloned = import_react14.default.cloneElement(original, {
|
|
38032
38107
|
// si es controlado por value → actualiza con row[h]
|
|
38033
38108
|
value: ((_a = original.props) == null ? void 0 : _a.value) !== void 0 ? row[h] : void 0,
|
|
38034
38109
|
// si usa children → actualiza con row[h] también
|
|
@@ -38108,7 +38183,7 @@ function TableBody({
|
|
|
38108
38183
|
symbols,
|
|
38109
38184
|
sort
|
|
38110
38185
|
}) {
|
|
38111
|
-
const [selected, setSelected] = (0,
|
|
38186
|
+
const [selected, setSelected] = (0, import_react15.useState)(-1);
|
|
38112
38187
|
const sorted = Object.entries(objectData).sort(([, a], [, b]) => {
|
|
38113
38188
|
for (const [key, order] of Object.entries(
|
|
38114
38189
|
sort || { id: "desc", _id: "desc" }
|
|
@@ -38284,7 +38359,7 @@ function TableFooter({
|
|
|
38284
38359
|
}
|
|
38285
38360
|
|
|
38286
38361
|
// src/table3/dialog.tsx
|
|
38287
|
-
var
|
|
38362
|
+
var import_react16 = __toESM(require("react"));
|
|
38288
38363
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
38289
38364
|
function Dialog3({
|
|
38290
38365
|
modalRef,
|
|
@@ -38301,9 +38376,9 @@ function Dialog3({
|
|
|
38301
38376
|
var _a;
|
|
38302
38377
|
return (_a = modalRef.current) == null ? void 0 : _a.close();
|
|
38303
38378
|
};
|
|
38304
|
-
const clonedModal = (0,
|
|
38305
|
-
if (dialogRow &&
|
|
38306
|
-
return
|
|
38379
|
+
const clonedModal = (0, import_react16.useMemo)(() => {
|
|
38380
|
+
if (dialogRow && import_react16.default.isValidElement(children)) {
|
|
38381
|
+
return import_react16.default.cloneElement(children, {
|
|
38307
38382
|
key: JSON.stringify(dialogRow),
|
|
38308
38383
|
row: dialogRow,
|
|
38309
38384
|
show,
|
|
@@ -38357,8 +38432,8 @@ function Table3({
|
|
|
38357
38432
|
sortBy,
|
|
38358
38433
|
...props
|
|
38359
38434
|
}) {
|
|
38360
|
-
const [handlers, setHandlers] = (0,
|
|
38361
|
-
const [page, setPage] = (0,
|
|
38435
|
+
const [handlers, setHandlers] = (0, import_react17.useState)({});
|
|
38436
|
+
const [page, setPage] = (0, import_react17.useState)(1);
|
|
38362
38437
|
function dataReducer(a, b) {
|
|
38363
38438
|
if (b == null) return {};
|
|
38364
38439
|
if (Array.isArray(b)) {
|
|
@@ -38379,7 +38454,7 @@ function Table3({
|
|
|
38379
38454
|
};
|
|
38380
38455
|
const newHandlers = { ...handlers };
|
|
38381
38456
|
for (let item in cc) {
|
|
38382
|
-
const isReactComponent =
|
|
38457
|
+
const isReactComponent = import_react17.default.isValidElement(cc[item]);
|
|
38383
38458
|
if (isReactComponent) {
|
|
38384
38459
|
newHandlers[item] = cc[item];
|
|
38385
38460
|
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 : "");
|
|
@@ -38399,12 +38474,12 @@ function Table3({
|
|
|
38399
38474
|
return newA;
|
|
38400
38475
|
}
|
|
38401
38476
|
}
|
|
38402
|
-
const [objectData, setObjectData] = (0,
|
|
38403
|
-
(0,
|
|
38477
|
+
const [objectData, setObjectData] = (0, import_react17.useReducer)(dataReducer, null);
|
|
38478
|
+
(0, import_react17.useEffect)(() => {
|
|
38404
38479
|
setObjectData(data);
|
|
38405
38480
|
setPage(1);
|
|
38406
38481
|
}, [data]);
|
|
38407
|
-
const headers = (0,
|
|
38482
|
+
const headers = (0, import_react17.useMemo)(() => {
|
|
38408
38483
|
if (!objectData) return [];
|
|
38409
38484
|
return [
|
|
38410
38485
|
...new Set(
|
|
@@ -38412,13 +38487,13 @@ function Table3({
|
|
|
38412
38487
|
)
|
|
38413
38488
|
];
|
|
38414
38489
|
}, [objectData]);
|
|
38415
|
-
const totalPages = (0,
|
|
38490
|
+
const totalPages = (0, import_react17.useMemo)(() => {
|
|
38416
38491
|
if (!objectData) return 0;
|
|
38417
38492
|
return maxItems ? Math.ceil(Object.keys(objectData).length / maxItems) : 1;
|
|
38418
38493
|
}, [objectData, maxItems]);
|
|
38419
|
-
const [sort, setSort] = (0,
|
|
38420
|
-
const modalRef = (0,
|
|
38421
|
-
const [dialogRow, setDialogRow] = (0,
|
|
38494
|
+
const [sort, setSort] = (0, import_react17.useState)(sortBy);
|
|
38495
|
+
const modalRef = (0, import_react17.useRef)(null);
|
|
38496
|
+
const [dialogRow, setDialogRow] = (0, import_react17.useState)({});
|
|
38422
38497
|
const context = {
|
|
38423
38498
|
objectData,
|
|
38424
38499
|
headers,
|
|
@@ -38445,7 +38520,7 @@ function Table3({
|
|
|
38445
38520
|
setSort,
|
|
38446
38521
|
...props
|
|
38447
38522
|
};
|
|
38448
|
-
(0,
|
|
38523
|
+
(0, import_react17.useEffect)(() => {
|
|
38449
38524
|
if ((dialogRow == null ? void 0 : dialogRow.id) || (dialogRow == null ? void 0 : dialogRow._id)) {
|
|
38450
38525
|
const newDialogRow = objectData[dialogRow == null ? void 0 : dialogRow.id] || objectData[dialogRow == null ? void 0 : dialogRow._id];
|
|
38451
38526
|
setDialogRow(newDialogRow);
|
package/dist/index.mjs
CHANGED
|
@@ -3865,6 +3865,7 @@ function Form({
|
|
|
3865
3865
|
}
|
|
3866
3866
|
|
|
3867
3867
|
// src/input/index.tsx
|
|
3868
|
+
import { useState as useState4 } from "react";
|
|
3868
3869
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
3869
3870
|
function Input({
|
|
3870
3871
|
label,
|
|
@@ -3875,27 +3876,96 @@ function Input({
|
|
|
3875
3876
|
}) {
|
|
3876
3877
|
const value = `${(props == null ? void 0 : props.value) || ""}`;
|
|
3877
3878
|
const isValid = !regex ? true : regex.test(value);
|
|
3879
|
+
const isPassword = props.type === "password";
|
|
3880
|
+
const [showPassword, setShowPassword] = useState4(false);
|
|
3878
3881
|
return /* @__PURE__ */ jsxs4("div", { className: "w-full", children: [
|
|
3879
3882
|
/* @__PURE__ */ jsxs4("label", { className: "flex flex-col gap-1", children: [
|
|
3880
|
-
/* @__PURE__ */ jsxs4("div", { className: "font-bold
|
|
3883
|
+
/* @__PURE__ */ jsxs4("div", { className: "font-bold", children: [
|
|
3881
3884
|
label,
|
|
3882
3885
|
" ",
|
|
3883
3886
|
(props == null ? void 0 : props.required) && /* @__PURE__ */ jsx5("span", { className: "text-red-500", children: "*" })
|
|
3884
3887
|
] }),
|
|
3885
|
-
/* @__PURE__ */
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3888
|
+
/* @__PURE__ */ jsxs4("div", { className: "relative", children: [
|
|
3889
|
+
/* @__PURE__ */ jsx5(
|
|
3890
|
+
"input",
|
|
3891
|
+
{
|
|
3892
|
+
...props,
|
|
3893
|
+
type: isPassword && showPassword ? "text" : props.type,
|
|
3894
|
+
className: [
|
|
3895
|
+
"p-2 w-full rounded border shadow",
|
|
3896
|
+
isPassword && "pr-10",
|
|
3897
|
+
value !== "" && !isValid && "bg-red-200 text-black",
|
|
3898
|
+
value !== "" && isValid && "bg-green-200 text-black",
|
|
3899
|
+
className
|
|
3900
|
+
].filter(Boolean).join(" ")
|
|
3901
|
+
}
|
|
3902
|
+
),
|
|
3903
|
+
isPassword && /* @__PURE__ */ jsx5(
|
|
3904
|
+
"button",
|
|
3905
|
+
{
|
|
3906
|
+
type: "button",
|
|
3907
|
+
onClick: () => setShowPassword((prev) => !prev),
|
|
3908
|
+
className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-800 focus:outline-none",
|
|
3909
|
+
"aria-label": showPassword ? "Ocultar contrase\xF1a" : "Mostrar contrase\xF1a",
|
|
3910
|
+
children: showPassword ? (
|
|
3911
|
+
// Ojo cerrado (ocultar)
|
|
3912
|
+
/* @__PURE__ */ jsx5(
|
|
3913
|
+
"svg",
|
|
3914
|
+
{
|
|
3915
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3916
|
+
className: "h-5 w-5",
|
|
3917
|
+
fill: "none",
|
|
3918
|
+
viewBox: "0 0 24 24",
|
|
3919
|
+
stroke: "currentColor",
|
|
3920
|
+
children: /* @__PURE__ */ jsx5(
|
|
3921
|
+
"path",
|
|
3922
|
+
{
|
|
3923
|
+
strokeLinecap: "round",
|
|
3924
|
+
strokeLinejoin: "round",
|
|
3925
|
+
strokeWidth: 2,
|
|
3926
|
+
d: "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"
|
|
3927
|
+
}
|
|
3928
|
+
)
|
|
3929
|
+
}
|
|
3930
|
+
)
|
|
3931
|
+
) : (
|
|
3932
|
+
// Ojo abierto (mostrar)
|
|
3933
|
+
/* @__PURE__ */ jsxs4(
|
|
3934
|
+
"svg",
|
|
3935
|
+
{
|
|
3936
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3937
|
+
className: "h-5 w-5",
|
|
3938
|
+
fill: "none",
|
|
3939
|
+
viewBox: "0 0 24 24",
|
|
3940
|
+
stroke: "currentColor",
|
|
3941
|
+
children: [
|
|
3942
|
+
/* @__PURE__ */ jsx5(
|
|
3943
|
+
"path",
|
|
3944
|
+
{
|
|
3945
|
+
strokeLinecap: "round",
|
|
3946
|
+
strokeLinejoin: "round",
|
|
3947
|
+
strokeWidth: 2,
|
|
3948
|
+
d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
3949
|
+
}
|
|
3950
|
+
),
|
|
3951
|
+
/* @__PURE__ */ jsx5(
|
|
3952
|
+
"path",
|
|
3953
|
+
{
|
|
3954
|
+
strokeLinecap: "round",
|
|
3955
|
+
strokeLinejoin: "round",
|
|
3956
|
+
strokeWidth: 2,
|
|
3957
|
+
d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
|
|
3958
|
+
}
|
|
3959
|
+
)
|
|
3960
|
+
]
|
|
3961
|
+
}
|
|
3962
|
+
)
|
|
3963
|
+
)
|
|
3964
|
+
}
|
|
3965
|
+
)
|
|
3966
|
+
] })
|
|
3897
3967
|
] }),
|
|
3898
|
-
!isValid && value
|
|
3968
|
+
!isValid && value !== "" && /* @__PURE__ */ jsx5("div", { className: "text-red-800 invalid", children: invalidMessage })
|
|
3899
3969
|
] });
|
|
3900
3970
|
}
|
|
3901
3971
|
|
|
@@ -3910,7 +3980,7 @@ var regular_expresions_default = regularExpresions;
|
|
|
3910
3980
|
// src/table/index.tsx
|
|
3911
3981
|
import { DataGrid } from "@mui/x-data-grid";
|
|
3912
3982
|
import { Box, Dialog } from "@mui/material";
|
|
3913
|
-
import React3, { useEffect as useEffect3, useMemo, useState as
|
|
3983
|
+
import React3, { useEffect as useEffect3, useMemo, useState as useState5 } from "react";
|
|
3914
3984
|
|
|
3915
3985
|
// ../../node_modules/xlsx/xlsx.mjs
|
|
3916
3986
|
var XLSX = {};
|
|
@@ -35994,19 +36064,20 @@ function IHTable({
|
|
|
35994
36064
|
rowHeight,
|
|
35995
36065
|
wrapText = false,
|
|
35996
36066
|
density = "standard",
|
|
35997
|
-
searchable = false
|
|
36067
|
+
searchable = false,
|
|
36068
|
+
autoHeight = false
|
|
35998
36069
|
}) {
|
|
35999
36070
|
var _a;
|
|
36000
36071
|
if (modal && onSelect)
|
|
36001
36072
|
throw new Error("Solo se puede usar modal o onSelect por separado");
|
|
36002
|
-
const [open, setOpen] =
|
|
36003
|
-
const [rows, setRows] =
|
|
36004
|
-
const [selectedRows, setSelectedRows] =
|
|
36073
|
+
const [open, setOpen] = useState5(false);
|
|
36074
|
+
const [rows, setRows] = useState5(data);
|
|
36075
|
+
const [selectedRows, setSelectedRows] = useState5({
|
|
36005
36076
|
type: "include",
|
|
36006
36077
|
ids: /* @__PURE__ */ new Set()
|
|
36007
36078
|
});
|
|
36008
|
-
const [modalRow, setModalRow] =
|
|
36009
|
-
const [searchQuery, setSearchQuery] =
|
|
36079
|
+
const [modalRow, setModalRow] = useState5();
|
|
36080
|
+
const [searchQuery, setSearchQuery] = useState5("");
|
|
36010
36081
|
const resolvedButtons = modal ? { ...buttons, Modal: "" } : buttons;
|
|
36011
36082
|
useEffect3(() => {
|
|
36012
36083
|
setRows(data);
|
|
@@ -36059,6 +36130,8 @@ function IHTable({
|
|
|
36059
36130
|
);
|
|
36060
36131
|
if (!rows.length) return null;
|
|
36061
36132
|
const rowHeightProps = wrapText ? { getRowHeight: () => "auto" } : rowHeight != null ? { rowHeight } : {};
|
|
36133
|
+
const containerHeight = autoHeight ? void 0 : (_a = HEIGHT_MAP[displayRows.length]) != null ? _a : height;
|
|
36134
|
+
const hideFooter = autoHeight || displayRows.length <= Object.keys(HEIGHT_MAP).length;
|
|
36062
36135
|
return /* @__PURE__ */ jsxs5("div", { className: "m-2", children: [
|
|
36063
36136
|
header && /* @__PURE__ */ jsx6("div", { className: "font-bold p-2 ", children: header }),
|
|
36064
36137
|
/* @__PURE__ */ jsxs5("div", { className: "flex justify-between", children: [
|
|
@@ -36080,7 +36153,8 @@ function IHTable({
|
|
|
36080
36153
|
sx: {
|
|
36081
36154
|
display: "flex",
|
|
36082
36155
|
flexDirection: "column",
|
|
36083
|
-
|
|
36156
|
+
// undefined height lets the child DataGrid size itself freely
|
|
36157
|
+
height: containerHeight,
|
|
36084
36158
|
width,
|
|
36085
36159
|
zIndex: 999999999
|
|
36086
36160
|
},
|
|
@@ -36101,6 +36175,7 @@ function IHTable({
|
|
|
36101
36175
|
rows: displayRows,
|
|
36102
36176
|
columns,
|
|
36103
36177
|
density,
|
|
36178
|
+
autoHeight,
|
|
36104
36179
|
checkboxSelection: Boolean(onSelect),
|
|
36105
36180
|
rowSelectionModel: selectedRows,
|
|
36106
36181
|
onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
|
|
@@ -36142,7 +36217,7 @@ function IHTable({
|
|
|
36142
36217
|
editMode: "row",
|
|
36143
36218
|
processRowUpdate: handleRowUpdate,
|
|
36144
36219
|
pageSizeOptions: [5, 10],
|
|
36145
|
-
hideFooter
|
|
36220
|
+
hideFooter
|
|
36146
36221
|
}
|
|
36147
36222
|
)
|
|
36148
36223
|
]
|
|
@@ -36160,7 +36235,7 @@ function Table(props) {
|
|
|
36160
36235
|
|
|
36161
36236
|
// src/text-area/index.tsx
|
|
36162
36237
|
import {
|
|
36163
|
-
useState as
|
|
36238
|
+
useState as useState6
|
|
36164
36239
|
} from "react";
|
|
36165
36240
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
36166
36241
|
function TextArea({
|
|
@@ -36171,7 +36246,7 @@ function TextArea({
|
|
|
36171
36246
|
children = "",
|
|
36172
36247
|
...props
|
|
36173
36248
|
}) {
|
|
36174
|
-
const [value, setValue] =
|
|
36249
|
+
const [value, setValue] = useState6((props == null ? void 0 : props.value) || "");
|
|
36175
36250
|
return /* @__PURE__ */ jsx7("div", { className: "w-full", children: /* @__PURE__ */ jsxs6("label", { className: "flex flex-col gap-1", children: [
|
|
36176
36251
|
/* @__PURE__ */ jsxs6("div", { className: "font-bold ", children: [
|
|
36177
36252
|
label,
|
|
@@ -36206,7 +36281,7 @@ function TextArea({
|
|
|
36206
36281
|
}
|
|
36207
36282
|
|
|
36208
36283
|
// src/use-resources/index.ts
|
|
36209
|
-
import { useEffect as useEffect4, useState as
|
|
36284
|
+
import { useEffect as useEffect4, useState as useState7 } from "react";
|
|
36210
36285
|
|
|
36211
36286
|
// src/use-resources/get.token.tsx
|
|
36212
36287
|
import { useMemo as useMemo2 } from "react";
|
|
@@ -36303,7 +36378,7 @@ function useResources({
|
|
|
36303
36378
|
onError
|
|
36304
36379
|
}) {
|
|
36305
36380
|
const token = useToken();
|
|
36306
|
-
const [info, setInfo] =
|
|
36381
|
+
const [info, setInfo] = useState7(
|
|
36307
36382
|
Object.keys(endpoints).reduce((acc, key) => {
|
|
36308
36383
|
var _a, _b;
|
|
36309
36384
|
const newAcc = {
|
|
@@ -36696,7 +36771,7 @@ function useResources({
|
|
|
36696
36771
|
import React5, {
|
|
36697
36772
|
useEffect as useEffect5,
|
|
36698
36773
|
useRef as useRef3,
|
|
36699
|
-
useState as
|
|
36774
|
+
useState as useState8
|
|
36700
36775
|
} from "react";
|
|
36701
36776
|
|
|
36702
36777
|
// src/select/icon.tsx
|
|
@@ -36744,16 +36819,16 @@ function Select({
|
|
|
36744
36819
|
strictMode = true,
|
|
36745
36820
|
...props
|
|
36746
36821
|
}) {
|
|
36747
|
-
const [isOpen, setIsOpen] =
|
|
36748
|
-
const [inputValue, setInputValue] =
|
|
36749
|
-
const [options, setOptions] =
|
|
36822
|
+
const [isOpen, setIsOpen] = useState8(false);
|
|
36823
|
+
const [inputValue, setInputValue] = useState8("");
|
|
36824
|
+
const [options, setOptions] = useState8(
|
|
36750
36825
|
[]
|
|
36751
36826
|
);
|
|
36752
|
-
const [filtered, setFiltered] =
|
|
36827
|
+
const [filtered, setFiltered] = useState8(
|
|
36753
36828
|
[]
|
|
36754
36829
|
);
|
|
36755
|
-
const [hasEdition, setHasEdition] =
|
|
36756
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
36830
|
+
const [hasEdition, setHasEdition] = useState8(false);
|
|
36831
|
+
const [highlightedIndex, setHighlightedIndex] = useState8(-1);
|
|
36757
36832
|
const inputRef = useRef3(null);
|
|
36758
36833
|
const validOption = (value) => {
|
|
36759
36834
|
return options.find((opt) => opt.label == value);
|
|
@@ -36803,7 +36878,7 @@ function Select({
|
|
|
36803
36878
|
setIsOpen(false);
|
|
36804
36879
|
};
|
|
36805
36880
|
const containerRef = useRef3(null);
|
|
36806
|
-
const [openUpwards, setOpenUpwards] =
|
|
36881
|
+
const [openUpwards, setOpenUpwards] = useState8(false);
|
|
36807
36882
|
useEffect5(() => {
|
|
36808
36883
|
if (isOpen && containerRef.current) {
|
|
36809
36884
|
const rect = containerRef.current.getBoundingClientRect();
|
|
@@ -36940,7 +37015,7 @@ function Select({
|
|
|
36940
37015
|
import { cloneElement as cloneElement2, useEffect as useEffect6 } from "react";
|
|
36941
37016
|
|
|
36942
37017
|
// src/pop/index.tsx
|
|
36943
|
-
import { useState as
|
|
37018
|
+
import { useState as useState9, useCallback, useRef as useRef4 } from "react";
|
|
36944
37019
|
|
|
36945
37020
|
// src/pop/actions.tsx
|
|
36946
37021
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
@@ -37184,7 +37259,7 @@ var INITIAL_STATE = {
|
|
|
37184
37259
|
full: false
|
|
37185
37260
|
};
|
|
37186
37261
|
function usePopup() {
|
|
37187
|
-
const [popup, setPopup] =
|
|
37262
|
+
const [popup, setPopup] = useState9(INITIAL_STATE);
|
|
37188
37263
|
const messageRef = useRef4(null);
|
|
37189
37264
|
const open = useCallback(
|
|
37190
37265
|
(partial) => {
|
|
@@ -37352,7 +37427,7 @@ function useDates() {
|
|
|
37352
37427
|
|
|
37353
37428
|
// src/calendar/index.tsx
|
|
37354
37429
|
import {
|
|
37355
|
-
useState as
|
|
37430
|
+
useState as useState10
|
|
37356
37431
|
} from "react";
|
|
37357
37432
|
import DatePicker from "react-datepicker";
|
|
37358
37433
|
|
|
@@ -37386,11 +37461,11 @@ function MyCalendar({
|
|
|
37386
37461
|
value,
|
|
37387
37462
|
...otherProps
|
|
37388
37463
|
}) {
|
|
37389
|
-
const [selectedDate, setSelectedDate] =
|
|
37390
|
-
const [dateStr, setDateStr] =
|
|
37464
|
+
const [selectedDate, setSelectedDate] = useState10(null);
|
|
37465
|
+
const [dateStr, setDateStr] = useState10(
|
|
37391
37466
|
defaultValue || value || ""
|
|
37392
37467
|
);
|
|
37393
|
-
const [open, setOpen] =
|
|
37468
|
+
const [open, setOpen] = useState10(false);
|
|
37394
37469
|
function handleChange(date) {
|
|
37395
37470
|
if (!date) return;
|
|
37396
37471
|
setSelectedDate(date);
|
|
@@ -37548,11 +37623,11 @@ import React9, {
|
|
|
37548
37623
|
useMemo as useMemo6,
|
|
37549
37624
|
useReducer as useReducer2,
|
|
37550
37625
|
useRef as useRef6,
|
|
37551
|
-
useState as
|
|
37626
|
+
useState as useState13
|
|
37552
37627
|
} from "react";
|
|
37553
37628
|
|
|
37554
37629
|
// src/table3/filter.tsx
|
|
37555
|
-
import { useEffect as useEffect8, useMemo as useMemo4, useState as
|
|
37630
|
+
import { useEffect as useEffect8, useMemo as useMemo4, useState as useState11 } from "react";
|
|
37556
37631
|
|
|
37557
37632
|
// src/table3/filters.tsx
|
|
37558
37633
|
import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
@@ -37662,13 +37737,13 @@ function Filter({
|
|
|
37662
37737
|
sort,
|
|
37663
37738
|
setSort
|
|
37664
37739
|
}) {
|
|
37665
|
-
const [visible, setVisible] =
|
|
37666
|
-
const [text, setText] =
|
|
37740
|
+
const [visible, setVisible] = useState11(false);
|
|
37741
|
+
const [text, setText] = useState11("");
|
|
37667
37742
|
const items = useMemo4(
|
|
37668
37743
|
() => [...new Set(Object.values(objectData).map((o) => o[h]))],
|
|
37669
37744
|
[objectData]
|
|
37670
37745
|
);
|
|
37671
|
-
const [selected, setSelected] =
|
|
37746
|
+
const [selected, setSelected] = useState11(items);
|
|
37672
37747
|
const itemsFiltered = useMemo4(
|
|
37673
37748
|
() => items.sort((a, b) => `${a}`.localeCompare(b)).filter((item) => {
|
|
37674
37749
|
if (!text) return true;
|
|
@@ -37957,7 +38032,7 @@ function TableHead({
|
|
|
37957
38032
|
}
|
|
37958
38033
|
|
|
37959
38034
|
// src/table3/body.tsx
|
|
37960
|
-
import { useState as
|
|
38035
|
+
import { useState as useState12 } from "react";
|
|
37961
38036
|
|
|
37962
38037
|
// src/table3/tr.tsx
|
|
37963
38038
|
import React7 from "react";
|
|
@@ -38102,7 +38177,7 @@ function TableBody({
|
|
|
38102
38177
|
symbols,
|
|
38103
38178
|
sort
|
|
38104
38179
|
}) {
|
|
38105
|
-
const [selected, setSelected] =
|
|
38180
|
+
const [selected, setSelected] = useState12(-1);
|
|
38106
38181
|
const sorted = Object.entries(objectData).sort(([, a], [, b]) => {
|
|
38107
38182
|
for (const [key, order] of Object.entries(
|
|
38108
38183
|
sort || { id: "desc", _id: "desc" }
|
|
@@ -38351,8 +38426,8 @@ function Table3({
|
|
|
38351
38426
|
sortBy,
|
|
38352
38427
|
...props
|
|
38353
38428
|
}) {
|
|
38354
|
-
const [handlers, setHandlers] =
|
|
38355
|
-
const [page, setPage] =
|
|
38429
|
+
const [handlers, setHandlers] = useState13({});
|
|
38430
|
+
const [page, setPage] = useState13(1);
|
|
38356
38431
|
function dataReducer(a, b) {
|
|
38357
38432
|
if (b == null) return {};
|
|
38358
38433
|
if (Array.isArray(b)) {
|
|
@@ -38410,9 +38485,9 @@ function Table3({
|
|
|
38410
38485
|
if (!objectData) return 0;
|
|
38411
38486
|
return maxItems ? Math.ceil(Object.keys(objectData).length / maxItems) : 1;
|
|
38412
38487
|
}, [objectData, maxItems]);
|
|
38413
|
-
const [sort, setSort] =
|
|
38488
|
+
const [sort, setSort] = useState13(sortBy);
|
|
38414
38489
|
const modalRef = useRef6(null);
|
|
38415
|
-
const [dialogRow, setDialogRow] =
|
|
38490
|
+
const [dialogRow, setDialogRow] = useState13({});
|
|
38416
38491
|
const context = {
|
|
38417
38492
|
objectData,
|
|
38418
38493
|
headers,
|
package/package.json
CHANGED
package/src/input/index.tsx
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { React } from "next/dist/server/route-modules/app-page/vendored/rsc/entrypoints";
|
|
2
|
+
import { InputHTMLAttributes, useState } from "react";
|
|
2
3
|
|
|
3
|
-
interface InputProps
|
|
4
|
-
extends DetailedHTMLProps<
|
|
5
|
-
InputHTMLAttributes<HTMLInputElement>,
|
|
6
|
-
HTMLInputElement
|
|
7
|
-
> {
|
|
4
|
+
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
8
5
|
label: React.ReactNode;
|
|
9
6
|
regex?: RegExp;
|
|
10
7
|
invalidMessage?: React.ReactNode;
|
|
11
8
|
}
|
|
9
|
+
|
|
12
10
|
export default function Input({
|
|
13
11
|
label,
|
|
14
12
|
className,
|
|
@@ -18,26 +16,82 @@ export default function Input({
|
|
|
18
16
|
}: InputProps) {
|
|
19
17
|
const value = `${props?.value || ""}`;
|
|
20
18
|
const isValid = !regex ? true : regex.test(value);
|
|
19
|
+
const isPassword = props.type === "password";
|
|
20
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
23
|
<div className="w-full">
|
|
24
24
|
<label className="flex flex-col gap-1">
|
|
25
|
-
<div className="font-bold
|
|
25
|
+
<div className="font-bold">
|
|
26
26
|
{label} {props?.required && <span className="text-red-500">*</span>}
|
|
27
27
|
</div>
|
|
28
|
-
<div>
|
|
28
|
+
<div className="relative">
|
|
29
29
|
<input
|
|
30
30
|
{...props}
|
|
31
|
+
type={isPassword && showPassword ? "text" : props.type}
|
|
31
32
|
className={[
|
|
32
33
|
"p-2 w-full rounded border shadow",
|
|
33
|
-
|
|
34
|
-
value
|
|
34
|
+
isPassword && "pr-10",
|
|
35
|
+
value !== "" && !isValid && "bg-red-200 text-black",
|
|
36
|
+
value !== "" && isValid && "bg-green-200 text-black",
|
|
35
37
|
className,
|
|
36
|
-
]
|
|
38
|
+
]
|
|
39
|
+
.filter(Boolean)
|
|
40
|
+
.join(" ")}
|
|
37
41
|
/>
|
|
42
|
+
{isPassword && (
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
onClick={() => setShowPassword((prev) => !prev)}
|
|
46
|
+
className="absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-800 focus:outline-none"
|
|
47
|
+
aria-label={
|
|
48
|
+
showPassword ? "Ocultar contraseña" : "Mostrar contraseña"
|
|
49
|
+
}
|
|
50
|
+
>
|
|
51
|
+
{showPassword ? (
|
|
52
|
+
// Ojo cerrado (ocultar)
|
|
53
|
+
<svg
|
|
54
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
55
|
+
className="h-5 w-5"
|
|
56
|
+
fill="none"
|
|
57
|
+
viewBox="0 0 24 24"
|
|
58
|
+
stroke="currentColor"
|
|
59
|
+
>
|
|
60
|
+
<path
|
|
61
|
+
strokeLinecap="round"
|
|
62
|
+
strokeLinejoin="round"
|
|
63
|
+
strokeWidth={2}
|
|
64
|
+
d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"
|
|
65
|
+
/>
|
|
66
|
+
</svg>
|
|
67
|
+
) : (
|
|
68
|
+
// Ojo abierto (mostrar)
|
|
69
|
+
<svg
|
|
70
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
71
|
+
className="h-5 w-5"
|
|
72
|
+
fill="none"
|
|
73
|
+
viewBox="0 0 24 24"
|
|
74
|
+
stroke="currentColor"
|
|
75
|
+
>
|
|
76
|
+
<path
|
|
77
|
+
strokeLinecap="round"
|
|
78
|
+
strokeLinejoin="round"
|
|
79
|
+
strokeWidth={2}
|
|
80
|
+
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
81
|
+
/>
|
|
82
|
+
<path
|
|
83
|
+
strokeLinecap="round"
|
|
84
|
+
strokeLinejoin="round"
|
|
85
|
+
strokeWidth={2}
|
|
86
|
+
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
|
|
87
|
+
/>
|
|
88
|
+
</svg>
|
|
89
|
+
)}
|
|
90
|
+
</button>
|
|
91
|
+
)}
|
|
38
92
|
</div>
|
|
39
93
|
</label>
|
|
40
|
-
{!isValid && value
|
|
94
|
+
{!isValid && value !== "" && (
|
|
41
95
|
<div className="text-red-800 invalid">{invalidMessage}</div>
|
|
42
96
|
)}
|
|
43
97
|
</div>
|
package/src/table/index.tsx
CHANGED
|
@@ -70,6 +70,14 @@ interface TableProps {
|
|
|
70
70
|
* - "comfortable" → padding generoso, fácil de leer
|
|
71
71
|
*/
|
|
72
72
|
density?: GridDensity;
|
|
73
|
+
/**
|
|
74
|
+
* Cuando es true, el alto del contenedor se ajusta automáticamente
|
|
75
|
+
* al contenido de la tabla, eliminando el scroll vertical.
|
|
76
|
+
* Compatible con `wrapText` (filas de alto variable) y con
|
|
77
|
+
* cualquier valor de `density`. Cuando está activo, las props
|
|
78
|
+
* `height` y `HEIGHT_MAP` se ignoran.
|
|
79
|
+
*/
|
|
80
|
+
autoHeight?: boolean;
|
|
73
81
|
[key: string]: any;
|
|
74
82
|
}
|
|
75
83
|
|
|
@@ -500,6 +508,7 @@ function IHTable({
|
|
|
500
508
|
wrapText = false,
|
|
501
509
|
density = "standard",
|
|
502
510
|
searchable = false,
|
|
511
|
+
autoHeight = false,
|
|
503
512
|
}: TableProps) {
|
|
504
513
|
if (modal && onSelect)
|
|
505
514
|
throw new Error("Solo se puede usar modal o onSelect por separado");
|
|
@@ -576,13 +585,30 @@ function IHTable({
|
|
|
576
585
|
|
|
577
586
|
if (!rows.length) return null;
|
|
578
587
|
|
|
579
|
-
//
|
|
588
|
+
// ─── Row height props ──────────────────────────────────────────────────────
|
|
589
|
+
// Priority: wrapText always wins (variable row height).
|
|
590
|
+
// autoHeight delegates height control to MUI; rowHeight prop is still
|
|
591
|
+
// respected when neither wrapText nor autoHeight forces auto sizing.
|
|
580
592
|
const rowHeightProps = wrapText
|
|
581
593
|
? { getRowHeight: () => "auto" as const }
|
|
582
594
|
: rowHeight != null
|
|
583
595
|
? { rowHeight }
|
|
584
596
|
: {};
|
|
585
597
|
|
|
598
|
+
// ─── Container height ──────────────────────────────────────────────────────
|
|
599
|
+
// When autoHeight is active the Box must NOT constrain the height so that
|
|
600
|
+
// MUI's own autoHeight can expand the grid to fit all rows without scroll.
|
|
601
|
+
// We still honour HEIGHT_MAP for small datasets when autoHeight is off,
|
|
602
|
+
// falling back to the explicit `height` prop for larger ones.
|
|
603
|
+
const containerHeight = autoHeight
|
|
604
|
+
? undefined // let MUI decide
|
|
605
|
+
: (HEIGHT_MAP[displayRows.length] ?? height);
|
|
606
|
+
|
|
607
|
+
// Whether to hide MUI's built-in pagination footer.
|
|
608
|
+
// With autoHeight all rows are visible, so pagination is never needed.
|
|
609
|
+
const hideFooter =
|
|
610
|
+
autoHeight || displayRows.length <= Object.keys(HEIGHT_MAP).length;
|
|
611
|
+
|
|
586
612
|
return (
|
|
587
613
|
<div className="m-2">
|
|
588
614
|
{header && <div className="font-bold p-2 ">{header}</div>}
|
|
@@ -603,7 +629,8 @@ function IHTable({
|
|
|
603
629
|
sx={{
|
|
604
630
|
display: "flex",
|
|
605
631
|
flexDirection: "column",
|
|
606
|
-
height
|
|
632
|
+
// undefined height lets the child DataGrid size itself freely
|
|
633
|
+
height: containerHeight,
|
|
607
634
|
width,
|
|
608
635
|
zIndex: 999999999,
|
|
609
636
|
}}
|
|
@@ -622,6 +649,9 @@ function IHTable({
|
|
|
622
649
|
rows={displayRows}
|
|
623
650
|
columns={columns as any}
|
|
624
651
|
density={density}
|
|
652
|
+
// MUI's native autoHeight prop — renders all rows and sizes the
|
|
653
|
+
// grid to fit them, regardless of density or wrapText.
|
|
654
|
+
autoHeight={autoHeight}
|
|
625
655
|
checkboxSelection={Boolean(onSelect)}
|
|
626
656
|
rowSelectionModel={selectedRows}
|
|
627
657
|
onRowSelectionModelChange={!modal ? setSelectedRows : undefined}
|
|
@@ -663,7 +693,7 @@ function IHTable({
|
|
|
663
693
|
editMode="row"
|
|
664
694
|
processRowUpdate={handleRowUpdate}
|
|
665
695
|
pageSizeOptions={[5, 10]}
|
|
666
|
-
hideFooter={
|
|
696
|
+
hideFooter={hideFooter}
|
|
667
697
|
/>
|
|
668
698
|
</Box>
|
|
669
699
|
<CustomFooter footer={footer} rows={displayRows} />
|