next-recomponents 2.0.28 → 2.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +162 -92
- package/dist/index.mjs +119 -49
- package/package.json +1 -1
- package/src/input/index.tsx +66 -12
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
|
|
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
|
|
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,
|
|
@@ -36019,16 +36089,16 @@ function IHTable({
|
|
|
36019
36089
|
var _a;
|
|
36020
36090
|
if (modal && onSelect)
|
|
36021
36091
|
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,
|
|
36092
|
+
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
36093
|
+
const [rows, setRows] = (0, import_react5.useState)(data);
|
|
36094
|
+
const [selectedRows, setSelectedRows] = (0, import_react5.useState)({
|
|
36025
36095
|
type: "include",
|
|
36026
36096
|
ids: /* @__PURE__ */ new Set()
|
|
36027
36097
|
});
|
|
36028
|
-
const [modalRow, setModalRow] = (0,
|
|
36029
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
36098
|
+
const [modalRow, setModalRow] = (0, import_react5.useState)();
|
|
36099
|
+
const [searchQuery, setSearchQuery] = (0, import_react5.useState)("");
|
|
36030
36100
|
const resolvedButtons = modal ? { ...buttons, Modal: "" } : buttons;
|
|
36031
|
-
(0,
|
|
36101
|
+
(0, import_react5.useEffect)(() => {
|
|
36032
36102
|
setRows(data);
|
|
36033
36103
|
}, [data]);
|
|
36034
36104
|
const handleModalOpen = (row) => {
|
|
@@ -36049,7 +36119,7 @@ function IHTable({
|
|
|
36049
36119
|
);
|
|
36050
36120
|
return updated;
|
|
36051
36121
|
};
|
|
36052
|
-
const filteredRows = (0,
|
|
36122
|
+
const filteredRows = (0, import_react5.useMemo)(() => {
|
|
36053
36123
|
if ((selectedRows == null ? void 0 : selectedRows.type) === "exclude") {
|
|
36054
36124
|
return rows.filter((r) => !Array.from(selectedRows.ids).includes(r.id));
|
|
36055
36125
|
}
|
|
@@ -36058,7 +36128,7 @@ function IHTable({
|
|
|
36058
36128
|
}
|
|
36059
36129
|
return [];
|
|
36060
36130
|
}, [selectedRows, rows]);
|
|
36061
|
-
const displayRows = (0,
|
|
36131
|
+
const displayRows = (0, import_react5.useMemo)(
|
|
36062
36132
|
() => searchable ? rows.filter((r) => rowMatchesSearch(r, searchQuery)) : rows,
|
|
36063
36133
|
[rows, searchQuery, searchable]
|
|
36064
36134
|
);
|
|
@@ -36179,7 +36249,7 @@ function Table(props) {
|
|
|
36179
36249
|
}
|
|
36180
36250
|
|
|
36181
36251
|
// src/text-area/index.tsx
|
|
36182
|
-
var
|
|
36252
|
+
var import_react6 = require("react");
|
|
36183
36253
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
36184
36254
|
function TextArea({
|
|
36185
36255
|
label,
|
|
@@ -36189,7 +36259,7 @@ function TextArea({
|
|
|
36189
36259
|
children = "",
|
|
36190
36260
|
...props
|
|
36191
36261
|
}) {
|
|
36192
|
-
const [value, setValue] = (0,
|
|
36262
|
+
const [value, setValue] = (0, import_react6.useState)((props == null ? void 0 : props.value) || "");
|
|
36193
36263
|
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
36264
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "font-bold ", children: [
|
|
36195
36265
|
label,
|
|
@@ -36224,12 +36294,12 @@ function TextArea({
|
|
|
36224
36294
|
}
|
|
36225
36295
|
|
|
36226
36296
|
// src/use-resources/index.ts
|
|
36227
|
-
var
|
|
36297
|
+
var import_react8 = require("react");
|
|
36228
36298
|
|
|
36229
36299
|
// src/use-resources/get.token.tsx
|
|
36230
|
-
var
|
|
36300
|
+
var import_react7 = require("react");
|
|
36231
36301
|
function useToken() {
|
|
36232
|
-
const token = (0,
|
|
36302
|
+
const token = (0, import_react7.useMemo)(() => {
|
|
36233
36303
|
if (typeof window != "undefined") {
|
|
36234
36304
|
const t = window.localStorage.getItem("token");
|
|
36235
36305
|
if (t) return t;
|
|
@@ -36321,7 +36391,7 @@ function useResources({
|
|
|
36321
36391
|
onError
|
|
36322
36392
|
}) {
|
|
36323
36393
|
const token = useToken();
|
|
36324
|
-
const [info, setInfo] = (0,
|
|
36394
|
+
const [info, setInfo] = (0, import_react8.useState)(
|
|
36325
36395
|
Object.keys(endpoints).reduce((acc, key) => {
|
|
36326
36396
|
var _a, _b;
|
|
36327
36397
|
const newAcc = {
|
|
@@ -36704,14 +36774,14 @@ function useResources({
|
|
|
36704
36774
|
}
|
|
36705
36775
|
}
|
|
36706
36776
|
}
|
|
36707
|
-
(0,
|
|
36777
|
+
(0, import_react8.useEffect)(() => {
|
|
36708
36778
|
doSome();
|
|
36709
36779
|
}, [JSON.stringify(Object.values(info).map((v) => v.loaded))]);
|
|
36710
36780
|
return results;
|
|
36711
36781
|
}
|
|
36712
36782
|
|
|
36713
36783
|
// src/select/index.tsx
|
|
36714
|
-
var
|
|
36784
|
+
var import_react9 = __toESM(require("react"));
|
|
36715
36785
|
|
|
36716
36786
|
// src/select/icon.tsx
|
|
36717
36787
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
@@ -36758,24 +36828,24 @@ function Select({
|
|
|
36758
36828
|
strictMode = true,
|
|
36759
36829
|
...props
|
|
36760
36830
|
}) {
|
|
36761
|
-
const [isOpen, setIsOpen] = (0,
|
|
36762
|
-
const [inputValue, setInputValue] = (0,
|
|
36763
|
-
const [options, setOptions] = (0,
|
|
36831
|
+
const [isOpen, setIsOpen] = (0, import_react9.useState)(false);
|
|
36832
|
+
const [inputValue, setInputValue] = (0, import_react9.useState)("");
|
|
36833
|
+
const [options, setOptions] = (0, import_react9.useState)(
|
|
36764
36834
|
[]
|
|
36765
36835
|
);
|
|
36766
|
-
const [filtered, setFiltered] = (0,
|
|
36836
|
+
const [filtered, setFiltered] = (0, import_react9.useState)(
|
|
36767
36837
|
[]
|
|
36768
36838
|
);
|
|
36769
|
-
const [hasEdition, setHasEdition] = (0,
|
|
36770
|
-
const [highlightedIndex, setHighlightedIndex] = (0,
|
|
36771
|
-
const inputRef = (0,
|
|
36839
|
+
const [hasEdition, setHasEdition] = (0, import_react9.useState)(false);
|
|
36840
|
+
const [highlightedIndex, setHighlightedIndex] = (0, import_react9.useState)(-1);
|
|
36841
|
+
const inputRef = (0, import_react9.useRef)(null);
|
|
36772
36842
|
const validOption = (value) => {
|
|
36773
36843
|
return options.find((opt) => opt.label == value);
|
|
36774
36844
|
};
|
|
36775
36845
|
const normalize = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z]/g, "");
|
|
36776
|
-
(0,
|
|
36846
|
+
(0, import_react9.useEffect)(() => {
|
|
36777
36847
|
var _a;
|
|
36778
|
-
const parsedOptions =
|
|
36848
|
+
const parsedOptions = import_react9.default.Children.toArray(children).filter((child) => {
|
|
36779
36849
|
return child.type === "option";
|
|
36780
36850
|
}).map((child) => {
|
|
36781
36851
|
return {
|
|
@@ -36788,7 +36858,7 @@ function Select({
|
|
|
36788
36858
|
const value = (props == null ? void 0 : props.value) && ((_a = parsedOptions.find((opt) => opt.value == props.value)) == null ? void 0 : _a.label);
|
|
36789
36859
|
setInputValue(value);
|
|
36790
36860
|
}, [children]);
|
|
36791
|
-
(0,
|
|
36861
|
+
(0, import_react9.useEffect)(() => {
|
|
36792
36862
|
const items = options.filter((opt) => {
|
|
36793
36863
|
if (!hasEdition) return true;
|
|
36794
36864
|
const normilizedLabel = normalize(`${opt == null ? void 0 : opt.label}`);
|
|
@@ -36816,9 +36886,9 @@ function Select({
|
|
|
36816
36886
|
setInputValue(opt.label);
|
|
36817
36887
|
setIsOpen(false);
|
|
36818
36888
|
};
|
|
36819
|
-
const containerRef = (0,
|
|
36820
|
-
const [openUpwards, setOpenUpwards] = (0,
|
|
36821
|
-
(0,
|
|
36889
|
+
const containerRef = (0, import_react9.useRef)(null);
|
|
36890
|
+
const [openUpwards, setOpenUpwards] = (0, import_react9.useState)(false);
|
|
36891
|
+
(0, import_react9.useEffect)(() => {
|
|
36822
36892
|
if (isOpen && containerRef.current) {
|
|
36823
36893
|
const rect = containerRef.current.getBoundingClientRect();
|
|
36824
36894
|
const spaceBelow = window.innerHeight - rect.bottom;
|
|
@@ -36951,10 +37021,10 @@ function Select({
|
|
|
36951
37021
|
}
|
|
36952
37022
|
|
|
36953
37023
|
// src/modal/index.tsx
|
|
36954
|
-
var
|
|
37024
|
+
var import_react11 = require("react");
|
|
36955
37025
|
|
|
36956
37026
|
// src/pop/index.tsx
|
|
36957
|
-
var
|
|
37027
|
+
var import_react10 = require("react");
|
|
36958
37028
|
|
|
36959
37029
|
// src/pop/actions.tsx
|
|
36960
37030
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
@@ -37198,9 +37268,9 @@ var INITIAL_STATE = {
|
|
|
37198
37268
|
full: false
|
|
37199
37269
|
};
|
|
37200
37270
|
function usePopup() {
|
|
37201
|
-
const [popup, setPopup] = (0,
|
|
37202
|
-
const messageRef = (0,
|
|
37203
|
-
const open = (0,
|
|
37271
|
+
const [popup, setPopup] = (0, import_react10.useState)(INITIAL_STATE);
|
|
37272
|
+
const messageRef = (0, import_react10.useRef)(null);
|
|
37273
|
+
const open = (0, import_react10.useCallback)(
|
|
37204
37274
|
(partial) => {
|
|
37205
37275
|
const { message, ...rest } = partial;
|
|
37206
37276
|
messageRef.current = message;
|
|
@@ -37208,7 +37278,7 @@ function usePopup() {
|
|
|
37208
37278
|
},
|
|
37209
37279
|
[]
|
|
37210
37280
|
);
|
|
37211
|
-
const close = (0,
|
|
37281
|
+
const close = (0, import_react10.useCallback)((confirmed, value) => {
|
|
37212
37282
|
setPopup((prev) => {
|
|
37213
37283
|
var _a, _b;
|
|
37214
37284
|
if (confirmed) (_a = prev.onConfirm) == null ? void 0 : _a.call(prev, value);
|
|
@@ -37216,7 +37286,7 @@ function usePopup() {
|
|
|
37216
37286
|
return { ...prev, visible: false, inputValue: "" };
|
|
37217
37287
|
});
|
|
37218
37288
|
}, []);
|
|
37219
|
-
const alert2 = (0,
|
|
37289
|
+
const alert2 = (0, import_react10.useCallback)(
|
|
37220
37290
|
(message, color = "primary") => new Promise(
|
|
37221
37291
|
(resolve) => open({
|
|
37222
37292
|
type: "alert",
|
|
@@ -37228,7 +37298,7 @@ function usePopup() {
|
|
|
37228
37298
|
),
|
|
37229
37299
|
[open]
|
|
37230
37300
|
);
|
|
37231
|
-
const modal = (0,
|
|
37301
|
+
const modal = (0, import_react10.useCallback)(
|
|
37232
37302
|
(message, color = "primary", icons = false, full = false) => new Promise(
|
|
37233
37303
|
(resolve) => open({
|
|
37234
37304
|
type: "modal",
|
|
@@ -37242,7 +37312,7 @@ function usePopup() {
|
|
|
37242
37312
|
),
|
|
37243
37313
|
[open]
|
|
37244
37314
|
);
|
|
37245
|
-
const confirm = (0,
|
|
37315
|
+
const confirm = (0, import_react10.useCallback)(
|
|
37246
37316
|
(message, color = "primary") => new Promise(
|
|
37247
37317
|
(resolve) => open({
|
|
37248
37318
|
type: "confirm",
|
|
@@ -37254,7 +37324,7 @@ function usePopup() {
|
|
|
37254
37324
|
),
|
|
37255
37325
|
[open]
|
|
37256
37326
|
);
|
|
37257
|
-
const prompt = (0,
|
|
37327
|
+
const prompt = (0, import_react10.useCallback)(
|
|
37258
37328
|
(message, color = "primary") => new Promise(
|
|
37259
37329
|
(resolve) => open({
|
|
37260
37330
|
type: "prompt",
|
|
@@ -37266,7 +37336,7 @@ function usePopup() {
|
|
|
37266
37336
|
),
|
|
37267
37337
|
[open]
|
|
37268
37338
|
);
|
|
37269
|
-
const updateMessage = (0,
|
|
37339
|
+
const updateMessage = (0, import_react10.useCallback)((message) => {
|
|
37270
37340
|
messageRef.current = message;
|
|
37271
37341
|
setPopup((prev) => ({ ...prev }));
|
|
37272
37342
|
}, []);
|
|
@@ -37299,14 +37369,14 @@ function Modal({
|
|
|
37299
37369
|
}) {
|
|
37300
37370
|
const pop = usePopup();
|
|
37301
37371
|
const hide = () => pop.close(false);
|
|
37302
|
-
const childrenWithHide = (0,
|
|
37303
|
-
(0,
|
|
37372
|
+
const childrenWithHide = (0, import_react11.cloneElement)(children, { hide });
|
|
37373
|
+
(0, import_react11.useEffect)(() => {
|
|
37304
37374
|
pop.updateMessage(childrenWithHide);
|
|
37305
37375
|
}, [children]);
|
|
37306
37376
|
const props = button == null ? void 0 : button.props;
|
|
37307
37377
|
const onClick = props == null ? void 0 : props.onClick;
|
|
37308
37378
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
37309
|
-
(0,
|
|
37379
|
+
(0, import_react11.cloneElement)(button, {
|
|
37310
37380
|
onClick: (e) => {
|
|
37311
37381
|
onClick == null ? void 0 : onClick(e);
|
|
37312
37382
|
pop.modal(childrenWithHide, color, false, true);
|
|
@@ -37365,7 +37435,7 @@ function useDates() {
|
|
|
37365
37435
|
}
|
|
37366
37436
|
|
|
37367
37437
|
// src/calendar/index.tsx
|
|
37368
|
-
var
|
|
37438
|
+
var import_react12 = require("react");
|
|
37369
37439
|
var import_react_datepicker = __toESM(require("react-datepicker"));
|
|
37370
37440
|
|
|
37371
37441
|
// src/calendar/calendar.icon.tsx
|
|
@@ -37398,11 +37468,11 @@ function MyCalendar({
|
|
|
37398
37468
|
value,
|
|
37399
37469
|
...otherProps
|
|
37400
37470
|
}) {
|
|
37401
|
-
const [selectedDate, setSelectedDate] = (0,
|
|
37402
|
-
const [dateStr, setDateStr] = (0,
|
|
37471
|
+
const [selectedDate, setSelectedDate] = (0, import_react12.useState)(null);
|
|
37472
|
+
const [dateStr, setDateStr] = (0, import_react12.useState)(
|
|
37403
37473
|
defaultValue || value || ""
|
|
37404
37474
|
);
|
|
37405
|
-
const [open, setOpen] = (0,
|
|
37475
|
+
const [open, setOpen] = (0, import_react12.useState)(false);
|
|
37406
37476
|
function handleChange(date) {
|
|
37407
37477
|
if (!date) return;
|
|
37408
37478
|
setSelectedDate(date);
|
|
@@ -37555,10 +37625,10 @@ function DocumentViewer({ item }) {
|
|
|
37555
37625
|
}
|
|
37556
37626
|
|
|
37557
37627
|
// src/table3/index.tsx
|
|
37558
|
-
var
|
|
37628
|
+
var import_react17 = __toESM(require("react"));
|
|
37559
37629
|
|
|
37560
37630
|
// src/table3/filter.tsx
|
|
37561
|
-
var
|
|
37631
|
+
var import_react13 = require("react");
|
|
37562
37632
|
|
|
37563
37633
|
// src/table3/filters.tsx
|
|
37564
37634
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
@@ -37668,14 +37738,14 @@ function Filter({
|
|
|
37668
37738
|
sort,
|
|
37669
37739
|
setSort
|
|
37670
37740
|
}) {
|
|
37671
|
-
const [visible, setVisible] = (0,
|
|
37672
|
-
const [text, setText] = (0,
|
|
37673
|
-
const items = (0,
|
|
37741
|
+
const [visible, setVisible] = (0, import_react13.useState)(false);
|
|
37742
|
+
const [text, setText] = (0, import_react13.useState)("");
|
|
37743
|
+
const items = (0, import_react13.useMemo)(
|
|
37674
37744
|
() => [...new Set(Object.values(objectData).map((o) => o[h]))],
|
|
37675
37745
|
[objectData]
|
|
37676
37746
|
);
|
|
37677
|
-
const [selected, setSelected] = (0,
|
|
37678
|
-
const itemsFiltered = (0,
|
|
37747
|
+
const [selected, setSelected] = (0, import_react13.useState)(items);
|
|
37748
|
+
const itemsFiltered = (0, import_react13.useMemo)(
|
|
37679
37749
|
() => items.sort((a, b) => `${a}`.localeCompare(b)).filter((item) => {
|
|
37680
37750
|
if (!text) return true;
|
|
37681
37751
|
return `${item}`.toLowerCase().includes(text.toLowerCase());
|
|
@@ -37712,7 +37782,7 @@ function Filter({
|
|
|
37712
37782
|
const hidden = Object.values(objectData).filter(
|
|
37713
37783
|
(d) => d._visible === false
|
|
37714
37784
|
);
|
|
37715
|
-
(0,
|
|
37785
|
+
(0, import_react13.useEffect)(() => {
|
|
37716
37786
|
if (data.length != Object.values(objectData).map((o) => (o == null ? void 0 : o._id) || (o == null ? void 0 : o.id)).length) {
|
|
37717
37787
|
const news = [...new Set(data.map((o) => o[h]))];
|
|
37718
37788
|
setSelected(news);
|
|
@@ -37963,10 +38033,10 @@ function TableHead({
|
|
|
37963
38033
|
}
|
|
37964
38034
|
|
|
37965
38035
|
// src/table3/body.tsx
|
|
37966
|
-
var
|
|
38036
|
+
var import_react15 = require("react");
|
|
37967
38037
|
|
|
37968
38038
|
// src/table3/tr.tsx
|
|
37969
|
-
var
|
|
38039
|
+
var import_react14 = __toESM(require("react"));
|
|
37970
38040
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
37971
38041
|
function TR({
|
|
37972
38042
|
handlers,
|
|
@@ -38028,7 +38098,7 @@ function TR({
|
|
|
38028
38098
|
return null;
|
|
38029
38099
|
} else if (handlers == null ? void 0 : handlers[h]) {
|
|
38030
38100
|
const original = handlers[h];
|
|
38031
|
-
const cloned =
|
|
38101
|
+
const cloned = import_react14.default.cloneElement(original, {
|
|
38032
38102
|
// si es controlado por value → actualiza con row[h]
|
|
38033
38103
|
value: ((_a = original.props) == null ? void 0 : _a.value) !== void 0 ? row[h] : void 0,
|
|
38034
38104
|
// si usa children → actualiza con row[h] también
|
|
@@ -38108,7 +38178,7 @@ function TableBody({
|
|
|
38108
38178
|
symbols,
|
|
38109
38179
|
sort
|
|
38110
38180
|
}) {
|
|
38111
|
-
const [selected, setSelected] = (0,
|
|
38181
|
+
const [selected, setSelected] = (0, import_react15.useState)(-1);
|
|
38112
38182
|
const sorted = Object.entries(objectData).sort(([, a], [, b]) => {
|
|
38113
38183
|
for (const [key, order] of Object.entries(
|
|
38114
38184
|
sort || { id: "desc", _id: "desc" }
|
|
@@ -38284,7 +38354,7 @@ function TableFooter({
|
|
|
38284
38354
|
}
|
|
38285
38355
|
|
|
38286
38356
|
// src/table3/dialog.tsx
|
|
38287
|
-
var
|
|
38357
|
+
var import_react16 = __toESM(require("react"));
|
|
38288
38358
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
38289
38359
|
function Dialog3({
|
|
38290
38360
|
modalRef,
|
|
@@ -38301,9 +38371,9 @@ function Dialog3({
|
|
|
38301
38371
|
var _a;
|
|
38302
38372
|
return (_a = modalRef.current) == null ? void 0 : _a.close();
|
|
38303
38373
|
};
|
|
38304
|
-
const clonedModal = (0,
|
|
38305
|
-
if (dialogRow &&
|
|
38306
|
-
return
|
|
38374
|
+
const clonedModal = (0, import_react16.useMemo)(() => {
|
|
38375
|
+
if (dialogRow && import_react16.default.isValidElement(children)) {
|
|
38376
|
+
return import_react16.default.cloneElement(children, {
|
|
38307
38377
|
key: JSON.stringify(dialogRow),
|
|
38308
38378
|
row: dialogRow,
|
|
38309
38379
|
show,
|
|
@@ -38357,8 +38427,8 @@ function Table3({
|
|
|
38357
38427
|
sortBy,
|
|
38358
38428
|
...props
|
|
38359
38429
|
}) {
|
|
38360
|
-
const [handlers, setHandlers] = (0,
|
|
38361
|
-
const [page, setPage] = (0,
|
|
38430
|
+
const [handlers, setHandlers] = (0, import_react17.useState)({});
|
|
38431
|
+
const [page, setPage] = (0, import_react17.useState)(1);
|
|
38362
38432
|
function dataReducer(a, b) {
|
|
38363
38433
|
if (b == null) return {};
|
|
38364
38434
|
if (Array.isArray(b)) {
|
|
@@ -38379,7 +38449,7 @@ function Table3({
|
|
|
38379
38449
|
};
|
|
38380
38450
|
const newHandlers = { ...handlers };
|
|
38381
38451
|
for (let item in cc) {
|
|
38382
|
-
const isReactComponent =
|
|
38452
|
+
const isReactComponent = import_react17.default.isValidElement(cc[item]);
|
|
38383
38453
|
if (isReactComponent) {
|
|
38384
38454
|
newHandlers[item] = cc[item];
|
|
38385
38455
|
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 +38469,12 @@ function Table3({
|
|
|
38399
38469
|
return newA;
|
|
38400
38470
|
}
|
|
38401
38471
|
}
|
|
38402
|
-
const [objectData, setObjectData] = (0,
|
|
38403
|
-
(0,
|
|
38472
|
+
const [objectData, setObjectData] = (0, import_react17.useReducer)(dataReducer, null);
|
|
38473
|
+
(0, import_react17.useEffect)(() => {
|
|
38404
38474
|
setObjectData(data);
|
|
38405
38475
|
setPage(1);
|
|
38406
38476
|
}, [data]);
|
|
38407
|
-
const headers = (0,
|
|
38477
|
+
const headers = (0, import_react17.useMemo)(() => {
|
|
38408
38478
|
if (!objectData) return [];
|
|
38409
38479
|
return [
|
|
38410
38480
|
...new Set(
|
|
@@ -38412,13 +38482,13 @@ function Table3({
|
|
|
38412
38482
|
)
|
|
38413
38483
|
];
|
|
38414
38484
|
}, [objectData]);
|
|
38415
|
-
const totalPages = (0,
|
|
38485
|
+
const totalPages = (0, import_react17.useMemo)(() => {
|
|
38416
38486
|
if (!objectData) return 0;
|
|
38417
38487
|
return maxItems ? Math.ceil(Object.keys(objectData).length / maxItems) : 1;
|
|
38418
38488
|
}, [objectData, maxItems]);
|
|
38419
|
-
const [sort, setSort] = (0,
|
|
38420
|
-
const modalRef = (0,
|
|
38421
|
-
const [dialogRow, setDialogRow] = (0,
|
|
38489
|
+
const [sort, setSort] = (0, import_react17.useState)(sortBy);
|
|
38490
|
+
const modalRef = (0, import_react17.useRef)(null);
|
|
38491
|
+
const [dialogRow, setDialogRow] = (0, import_react17.useState)({});
|
|
38422
38492
|
const context = {
|
|
38423
38493
|
objectData,
|
|
38424
38494
|
headers,
|
|
@@ -38445,7 +38515,7 @@ function Table3({
|
|
|
38445
38515
|
setSort,
|
|
38446
38516
|
...props
|
|
38447
38517
|
};
|
|
38448
|
-
(0,
|
|
38518
|
+
(0, import_react17.useEffect)(() => {
|
|
38449
38519
|
if ((dialogRow == null ? void 0 : dialogRow.id) || (dialogRow == null ? void 0 : dialogRow._id)) {
|
|
38450
38520
|
const newDialogRow = objectData[dialogRow == null ? void 0 : dialogRow.id] || objectData[dialogRow == null ? void 0 : dialogRow._id];
|
|
38451
38521
|
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 = {};
|
|
@@ -35999,14 +36069,14 @@ function IHTable({
|
|
|
35999
36069
|
var _a;
|
|
36000
36070
|
if (modal && onSelect)
|
|
36001
36071
|
throw new Error("Solo se puede usar modal o onSelect por separado");
|
|
36002
|
-
const [open, setOpen] =
|
|
36003
|
-
const [rows, setRows] =
|
|
36004
|
-
const [selectedRows, setSelectedRows] =
|
|
36072
|
+
const [open, setOpen] = useState5(false);
|
|
36073
|
+
const [rows, setRows] = useState5(data);
|
|
36074
|
+
const [selectedRows, setSelectedRows] = useState5({
|
|
36005
36075
|
type: "include",
|
|
36006
36076
|
ids: /* @__PURE__ */ new Set()
|
|
36007
36077
|
});
|
|
36008
|
-
const [modalRow, setModalRow] =
|
|
36009
|
-
const [searchQuery, setSearchQuery] =
|
|
36078
|
+
const [modalRow, setModalRow] = useState5();
|
|
36079
|
+
const [searchQuery, setSearchQuery] = useState5("");
|
|
36010
36080
|
const resolvedButtons = modal ? { ...buttons, Modal: "" } : buttons;
|
|
36011
36081
|
useEffect3(() => {
|
|
36012
36082
|
setRows(data);
|
|
@@ -36160,7 +36230,7 @@ function Table(props) {
|
|
|
36160
36230
|
|
|
36161
36231
|
// src/text-area/index.tsx
|
|
36162
36232
|
import {
|
|
36163
|
-
useState as
|
|
36233
|
+
useState as useState6
|
|
36164
36234
|
} from "react";
|
|
36165
36235
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
36166
36236
|
function TextArea({
|
|
@@ -36171,7 +36241,7 @@ function TextArea({
|
|
|
36171
36241
|
children = "",
|
|
36172
36242
|
...props
|
|
36173
36243
|
}) {
|
|
36174
|
-
const [value, setValue] =
|
|
36244
|
+
const [value, setValue] = useState6((props == null ? void 0 : props.value) || "");
|
|
36175
36245
|
return /* @__PURE__ */ jsx7("div", { className: "w-full", children: /* @__PURE__ */ jsxs6("label", { className: "flex flex-col gap-1", children: [
|
|
36176
36246
|
/* @__PURE__ */ jsxs6("div", { className: "font-bold ", children: [
|
|
36177
36247
|
label,
|
|
@@ -36206,7 +36276,7 @@ function TextArea({
|
|
|
36206
36276
|
}
|
|
36207
36277
|
|
|
36208
36278
|
// src/use-resources/index.ts
|
|
36209
|
-
import { useEffect as useEffect4, useState as
|
|
36279
|
+
import { useEffect as useEffect4, useState as useState7 } from "react";
|
|
36210
36280
|
|
|
36211
36281
|
// src/use-resources/get.token.tsx
|
|
36212
36282
|
import { useMemo as useMemo2 } from "react";
|
|
@@ -36303,7 +36373,7 @@ function useResources({
|
|
|
36303
36373
|
onError
|
|
36304
36374
|
}) {
|
|
36305
36375
|
const token = useToken();
|
|
36306
|
-
const [info, setInfo] =
|
|
36376
|
+
const [info, setInfo] = useState7(
|
|
36307
36377
|
Object.keys(endpoints).reduce((acc, key) => {
|
|
36308
36378
|
var _a, _b;
|
|
36309
36379
|
const newAcc = {
|
|
@@ -36696,7 +36766,7 @@ function useResources({
|
|
|
36696
36766
|
import React5, {
|
|
36697
36767
|
useEffect as useEffect5,
|
|
36698
36768
|
useRef as useRef3,
|
|
36699
|
-
useState as
|
|
36769
|
+
useState as useState8
|
|
36700
36770
|
} from "react";
|
|
36701
36771
|
|
|
36702
36772
|
// src/select/icon.tsx
|
|
@@ -36744,16 +36814,16 @@ function Select({
|
|
|
36744
36814
|
strictMode = true,
|
|
36745
36815
|
...props
|
|
36746
36816
|
}) {
|
|
36747
|
-
const [isOpen, setIsOpen] =
|
|
36748
|
-
const [inputValue, setInputValue] =
|
|
36749
|
-
const [options, setOptions] =
|
|
36817
|
+
const [isOpen, setIsOpen] = useState8(false);
|
|
36818
|
+
const [inputValue, setInputValue] = useState8("");
|
|
36819
|
+
const [options, setOptions] = useState8(
|
|
36750
36820
|
[]
|
|
36751
36821
|
);
|
|
36752
|
-
const [filtered, setFiltered] =
|
|
36822
|
+
const [filtered, setFiltered] = useState8(
|
|
36753
36823
|
[]
|
|
36754
36824
|
);
|
|
36755
|
-
const [hasEdition, setHasEdition] =
|
|
36756
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
36825
|
+
const [hasEdition, setHasEdition] = useState8(false);
|
|
36826
|
+
const [highlightedIndex, setHighlightedIndex] = useState8(-1);
|
|
36757
36827
|
const inputRef = useRef3(null);
|
|
36758
36828
|
const validOption = (value) => {
|
|
36759
36829
|
return options.find((opt) => opt.label == value);
|
|
@@ -36803,7 +36873,7 @@ function Select({
|
|
|
36803
36873
|
setIsOpen(false);
|
|
36804
36874
|
};
|
|
36805
36875
|
const containerRef = useRef3(null);
|
|
36806
|
-
const [openUpwards, setOpenUpwards] =
|
|
36876
|
+
const [openUpwards, setOpenUpwards] = useState8(false);
|
|
36807
36877
|
useEffect5(() => {
|
|
36808
36878
|
if (isOpen && containerRef.current) {
|
|
36809
36879
|
const rect = containerRef.current.getBoundingClientRect();
|
|
@@ -36940,7 +37010,7 @@ function Select({
|
|
|
36940
37010
|
import { cloneElement as cloneElement2, useEffect as useEffect6 } from "react";
|
|
36941
37011
|
|
|
36942
37012
|
// src/pop/index.tsx
|
|
36943
|
-
import { useState as
|
|
37013
|
+
import { useState as useState9, useCallback, useRef as useRef4 } from "react";
|
|
36944
37014
|
|
|
36945
37015
|
// src/pop/actions.tsx
|
|
36946
37016
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
@@ -37184,7 +37254,7 @@ var INITIAL_STATE = {
|
|
|
37184
37254
|
full: false
|
|
37185
37255
|
};
|
|
37186
37256
|
function usePopup() {
|
|
37187
|
-
const [popup, setPopup] =
|
|
37257
|
+
const [popup, setPopup] = useState9(INITIAL_STATE);
|
|
37188
37258
|
const messageRef = useRef4(null);
|
|
37189
37259
|
const open = useCallback(
|
|
37190
37260
|
(partial) => {
|
|
@@ -37352,7 +37422,7 @@ function useDates() {
|
|
|
37352
37422
|
|
|
37353
37423
|
// src/calendar/index.tsx
|
|
37354
37424
|
import {
|
|
37355
|
-
useState as
|
|
37425
|
+
useState as useState10
|
|
37356
37426
|
} from "react";
|
|
37357
37427
|
import DatePicker from "react-datepicker";
|
|
37358
37428
|
|
|
@@ -37386,11 +37456,11 @@ function MyCalendar({
|
|
|
37386
37456
|
value,
|
|
37387
37457
|
...otherProps
|
|
37388
37458
|
}) {
|
|
37389
|
-
const [selectedDate, setSelectedDate] =
|
|
37390
|
-
const [dateStr, setDateStr] =
|
|
37459
|
+
const [selectedDate, setSelectedDate] = useState10(null);
|
|
37460
|
+
const [dateStr, setDateStr] = useState10(
|
|
37391
37461
|
defaultValue || value || ""
|
|
37392
37462
|
);
|
|
37393
|
-
const [open, setOpen] =
|
|
37463
|
+
const [open, setOpen] = useState10(false);
|
|
37394
37464
|
function handleChange(date) {
|
|
37395
37465
|
if (!date) return;
|
|
37396
37466
|
setSelectedDate(date);
|
|
@@ -37548,11 +37618,11 @@ import React9, {
|
|
|
37548
37618
|
useMemo as useMemo6,
|
|
37549
37619
|
useReducer as useReducer2,
|
|
37550
37620
|
useRef as useRef6,
|
|
37551
|
-
useState as
|
|
37621
|
+
useState as useState13
|
|
37552
37622
|
} from "react";
|
|
37553
37623
|
|
|
37554
37624
|
// src/table3/filter.tsx
|
|
37555
|
-
import { useEffect as useEffect8, useMemo as useMemo4, useState as
|
|
37625
|
+
import { useEffect as useEffect8, useMemo as useMemo4, useState as useState11 } from "react";
|
|
37556
37626
|
|
|
37557
37627
|
// src/table3/filters.tsx
|
|
37558
37628
|
import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
@@ -37662,13 +37732,13 @@ function Filter({
|
|
|
37662
37732
|
sort,
|
|
37663
37733
|
setSort
|
|
37664
37734
|
}) {
|
|
37665
|
-
const [visible, setVisible] =
|
|
37666
|
-
const [text, setText] =
|
|
37735
|
+
const [visible, setVisible] = useState11(false);
|
|
37736
|
+
const [text, setText] = useState11("");
|
|
37667
37737
|
const items = useMemo4(
|
|
37668
37738
|
() => [...new Set(Object.values(objectData).map((o) => o[h]))],
|
|
37669
37739
|
[objectData]
|
|
37670
37740
|
);
|
|
37671
|
-
const [selected, setSelected] =
|
|
37741
|
+
const [selected, setSelected] = useState11(items);
|
|
37672
37742
|
const itemsFiltered = useMemo4(
|
|
37673
37743
|
() => items.sort((a, b) => `${a}`.localeCompare(b)).filter((item) => {
|
|
37674
37744
|
if (!text) return true;
|
|
@@ -37957,7 +38027,7 @@ function TableHead({
|
|
|
37957
38027
|
}
|
|
37958
38028
|
|
|
37959
38029
|
// src/table3/body.tsx
|
|
37960
|
-
import { useState as
|
|
38030
|
+
import { useState as useState12 } from "react";
|
|
37961
38031
|
|
|
37962
38032
|
// src/table3/tr.tsx
|
|
37963
38033
|
import React7 from "react";
|
|
@@ -38102,7 +38172,7 @@ function TableBody({
|
|
|
38102
38172
|
symbols,
|
|
38103
38173
|
sort
|
|
38104
38174
|
}) {
|
|
38105
|
-
const [selected, setSelected] =
|
|
38175
|
+
const [selected, setSelected] = useState12(-1);
|
|
38106
38176
|
const sorted = Object.entries(objectData).sort(([, a], [, b]) => {
|
|
38107
38177
|
for (const [key, order] of Object.entries(
|
|
38108
38178
|
sort || { id: "desc", _id: "desc" }
|
|
@@ -38351,8 +38421,8 @@ function Table3({
|
|
|
38351
38421
|
sortBy,
|
|
38352
38422
|
...props
|
|
38353
38423
|
}) {
|
|
38354
|
-
const [handlers, setHandlers] =
|
|
38355
|
-
const [page, setPage] =
|
|
38424
|
+
const [handlers, setHandlers] = useState13({});
|
|
38425
|
+
const [page, setPage] = useState13(1);
|
|
38356
38426
|
function dataReducer(a, b) {
|
|
38357
38427
|
if (b == null) return {};
|
|
38358
38428
|
if (Array.isArray(b)) {
|
|
@@ -38410,9 +38480,9 @@ function Table3({
|
|
|
38410
38480
|
if (!objectData) return 0;
|
|
38411
38481
|
return maxItems ? Math.ceil(Object.keys(objectData).length / maxItems) : 1;
|
|
38412
38482
|
}, [objectData, maxItems]);
|
|
38413
|
-
const [sort, setSort] =
|
|
38483
|
+
const [sort, setSort] = useState13(sortBy);
|
|
38414
38484
|
const modalRef = useRef6(null);
|
|
38415
|
-
const [dialogRow, setDialogRow] =
|
|
38485
|
+
const [dialogRow, setDialogRow] = useState13({});
|
|
38416
38486
|
const context = {
|
|
38417
38487
|
objectData,
|
|
38418
38488
|
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>
|