next-recomponents 1.2.1 → 1.2.3
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 +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +38 -9
- package/dist/index.mjs +38 -9
- package/package.json +1 -1
- package/src/modal/index.tsx +24 -6
- package/src/table/filter.menu.tsx +1 -1
- package/src/table/h.tsx +6 -4
package/dist/index.d.mts
CHANGED
|
@@ -125,7 +125,12 @@ interface CustomSelectProps extends React$1.DetailedHTMLProps<React$1.InputHTMLA
|
|
|
125
125
|
declare function Select({ label, placeholder, children, strictMode, ...props }: CustomSelectProps): react_jsx_runtime.JSX.Element;
|
|
126
126
|
|
|
127
127
|
interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
128
|
-
button: React$1.ReactElement
|
|
128
|
+
button: React$1.ReactElement<{
|
|
129
|
+
onClick: (e: React$1.MouseEvent) => void;
|
|
130
|
+
}>;
|
|
131
|
+
children: React$1.ReactElement<{
|
|
132
|
+
hide: () => void;
|
|
133
|
+
}>;
|
|
129
134
|
}
|
|
130
135
|
declare function Modal({ button, children, ref }: Props): react_jsx_runtime.JSX.Element;
|
|
131
136
|
|
package/dist/index.d.ts
CHANGED
|
@@ -125,7 +125,12 @@ interface CustomSelectProps extends React$1.DetailedHTMLProps<React$1.InputHTMLA
|
|
|
125
125
|
declare function Select({ label, placeholder, children, strictMode, ...props }: CustomSelectProps): react_jsx_runtime.JSX.Element;
|
|
126
126
|
|
|
127
127
|
interface Props extends React$1.DetailedHTMLProps<React$1.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
128
|
-
button: React$1.ReactElement
|
|
128
|
+
button: React$1.ReactElement<{
|
|
129
|
+
onClick: (e: React$1.MouseEvent) => void;
|
|
130
|
+
}>;
|
|
131
|
+
children: React$1.ReactElement<{
|
|
132
|
+
hide: () => void;
|
|
133
|
+
}>;
|
|
129
134
|
}
|
|
130
135
|
declare function Modal({ button, children, ref }: Props): react_jsx_runtime.JSX.Element;
|
|
131
136
|
|
package/dist/index.js
CHANGED
|
@@ -11238,7 +11238,10 @@ function FilterMenu({
|
|
|
11238
11238
|
const [newMapedData, setNewMapedData] = (0, import_react24.useState)([]);
|
|
11239
11239
|
(0, import_react24.useEffect)(() => {
|
|
11240
11240
|
setNewMapedData(
|
|
11241
|
-
[...new Set(mapedData.map((md) =>
|
|
11241
|
+
[...new Set(mapedData.map((md) => {
|
|
11242
|
+
var _a;
|
|
11243
|
+
return (_a = md[h]) == null ? void 0 : _a.content;
|
|
11244
|
+
}))].filter(
|
|
11242
11245
|
(item) => {
|
|
11243
11246
|
return item && `${item}`.toLowerCase().includes(text.toLowerCase());
|
|
11244
11247
|
}
|
|
@@ -11403,7 +11406,8 @@ function HTable(_a) {
|
|
|
11403
11406
|
const mapedTotals = (0, import_react25.useMemo)(() => {
|
|
11404
11407
|
return mapedData.reduce((acc, md) => {
|
|
11405
11408
|
head.forEach((h) => {
|
|
11406
|
-
|
|
11409
|
+
var _a2, _b2;
|
|
11410
|
+
const value = isNaN(+((_a2 = md[h]) == null ? void 0 : _a2.content)) ? 0 : +((_b2 = md[h]) == null ? void 0 : _b2.content);
|
|
11407
11411
|
if (acc[h]) {
|
|
11408
11412
|
acc[h] += value;
|
|
11409
11413
|
} else {
|
|
@@ -11417,7 +11421,10 @@ function HTable(_a) {
|
|
|
11417
11421
|
setFilters(__spreadValues({}, head.reduce((acc, hh) => {
|
|
11418
11422
|
const newAcc = __spreadValues({}, acc);
|
|
11419
11423
|
newAcc[hh] = [
|
|
11420
|
-
...new Set(mapedData.map((md) =>
|
|
11424
|
+
...new Set(mapedData.map((md) => {
|
|
11425
|
+
var _a2;
|
|
11426
|
+
return (_a2 = md[hh]) == null ? void 0 : _a2.content;
|
|
11427
|
+
}))
|
|
11421
11428
|
];
|
|
11422
11429
|
return newAcc;
|
|
11423
11430
|
}, {})));
|
|
@@ -11447,7 +11454,12 @@ function HTable(_a) {
|
|
|
11447
11454
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("thead", { className: "bg-gray-800 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { children: head.map((h, key) => {
|
|
11448
11455
|
var _a2;
|
|
11449
11456
|
const items = [
|
|
11450
|
-
...new Set(
|
|
11457
|
+
...new Set(
|
|
11458
|
+
mapedData.map((item) => {
|
|
11459
|
+
var _a3;
|
|
11460
|
+
return (_a3 = item[h]) == null ? void 0 : _a3.content;
|
|
11461
|
+
})
|
|
11462
|
+
)
|
|
11451
11463
|
];
|
|
11452
11464
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
11453
11465
|
"th",
|
|
@@ -11487,8 +11499,9 @@ function HTable(_a) {
|
|
|
11487
11499
|
);
|
|
11488
11500
|
}) }) }),
|
|
11489
11501
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: "divide-y divide-gray-200", children: mapedData.filter((md) => {
|
|
11502
|
+
var _a2;
|
|
11490
11503
|
for (let datum of Object.keys(md)) {
|
|
11491
|
-
if (!filters[datum].map((d) => `${d}`.toLowerCase()).includes(`${md[datum].content}`.toLowerCase())) {
|
|
11504
|
+
if (!filters[datum].map((d) => `${d}`.toLowerCase()).includes(`${(_a2 = md[datum]) == null ? void 0 : _a2.content}`.toLowerCase())) {
|
|
11492
11505
|
return false;
|
|
11493
11506
|
}
|
|
11494
11507
|
}
|
|
@@ -32690,7 +32703,7 @@ function Select(_a) {
|
|
|
32690
32703
|
}
|
|
32691
32704
|
|
|
32692
32705
|
// src/modal/index.tsx
|
|
32693
|
-
var import_react31 = require("react");
|
|
32706
|
+
var import_react31 = __toESM(require("react"));
|
|
32694
32707
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
32695
32708
|
function Modal({ button, children, ref }) {
|
|
32696
32709
|
const modalRef = ref || (0, import_react31.useRef)(null);
|
|
@@ -32703,17 +32716,33 @@ function Modal({ button, children, ref }) {
|
|
|
32703
32716
|
typeof modalRef == "object" && ((_a = modalRef.current) == null ? void 0 : _a.close());
|
|
32704
32717
|
}
|
|
32705
32718
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
32706
|
-
button,
|
|
32719
|
+
import_react31.default.Children.map(button, (child) => {
|
|
32720
|
+
if (import_react31.default.isValidElement(child)) {
|
|
32721
|
+
return import_react31.default.cloneElement(child, {
|
|
32722
|
+
onClick: (e) => {
|
|
32723
|
+
var _a, _b;
|
|
32724
|
+
show();
|
|
32725
|
+
(_b = (_a = child.props) == null ? void 0 : _a.onClick) == null ? void 0 : _b.call(_a, e);
|
|
32726
|
+
}
|
|
32727
|
+
});
|
|
32728
|
+
}
|
|
32729
|
+
return child;
|
|
32730
|
+
}),
|
|
32707
32731
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("dialog", { ref: modalRef, className: "p-5 border shadow rounded", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "relative", children: [
|
|
32708
32732
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
32709
32733
|
"button",
|
|
32710
32734
|
{
|
|
32711
32735
|
onClick: hide,
|
|
32712
32736
|
className: "absolute top-0 right-0 text-red-500 ",
|
|
32713
|
-
children:
|
|
32737
|
+
children: "X"
|
|
32714
32738
|
}
|
|
32715
32739
|
),
|
|
32716
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-col gap-3 pt-6", children
|
|
32740
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-col gap-3 pt-6", children: import_react31.default.Children.map(children, (child) => {
|
|
32741
|
+
if (import_react31.default.isValidElement(child)) {
|
|
32742
|
+
return import_react31.default.cloneElement(child, { hide });
|
|
32743
|
+
}
|
|
32744
|
+
return child;
|
|
32745
|
+
}) })
|
|
32717
32746
|
] }) })
|
|
32718
32747
|
] });
|
|
32719
32748
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -11229,7 +11229,10 @@ function FilterMenu({
|
|
|
11229
11229
|
const [newMapedData, setNewMapedData] = useState5([]);
|
|
11230
11230
|
useEffect6(() => {
|
|
11231
11231
|
setNewMapedData(
|
|
11232
|
-
[...new Set(mapedData.map((md) =>
|
|
11232
|
+
[...new Set(mapedData.map((md) => {
|
|
11233
|
+
var _a;
|
|
11234
|
+
return (_a = md[h]) == null ? void 0 : _a.content;
|
|
11235
|
+
}))].filter(
|
|
11233
11236
|
(item) => {
|
|
11234
11237
|
return item && `${item}`.toLowerCase().includes(text.toLowerCase());
|
|
11235
11238
|
}
|
|
@@ -11394,7 +11397,8 @@ function HTable(_a) {
|
|
|
11394
11397
|
const mapedTotals = useMemo7(() => {
|
|
11395
11398
|
return mapedData.reduce((acc, md) => {
|
|
11396
11399
|
head.forEach((h) => {
|
|
11397
|
-
|
|
11400
|
+
var _a2, _b2;
|
|
11401
|
+
const value = isNaN(+((_a2 = md[h]) == null ? void 0 : _a2.content)) ? 0 : +((_b2 = md[h]) == null ? void 0 : _b2.content);
|
|
11398
11402
|
if (acc[h]) {
|
|
11399
11403
|
acc[h] += value;
|
|
11400
11404
|
} else {
|
|
@@ -11408,7 +11412,10 @@ function HTable(_a) {
|
|
|
11408
11412
|
setFilters(__spreadValues({}, head.reduce((acc, hh) => {
|
|
11409
11413
|
const newAcc = __spreadValues({}, acc);
|
|
11410
11414
|
newAcc[hh] = [
|
|
11411
|
-
...new Set(mapedData.map((md) =>
|
|
11415
|
+
...new Set(mapedData.map((md) => {
|
|
11416
|
+
var _a2;
|
|
11417
|
+
return (_a2 = md[hh]) == null ? void 0 : _a2.content;
|
|
11418
|
+
}))
|
|
11412
11419
|
];
|
|
11413
11420
|
return newAcc;
|
|
11414
11421
|
}, {})));
|
|
@@ -11438,7 +11445,12 @@ function HTable(_a) {
|
|
|
11438
11445
|
/* @__PURE__ */ jsx11("thead", { className: "bg-gray-800 text-white", children: /* @__PURE__ */ jsx11("tr", { children: head.map((h, key) => {
|
|
11439
11446
|
var _a2;
|
|
11440
11447
|
const items = [
|
|
11441
|
-
...new Set(
|
|
11448
|
+
...new Set(
|
|
11449
|
+
mapedData.map((item) => {
|
|
11450
|
+
var _a3;
|
|
11451
|
+
return (_a3 = item[h]) == null ? void 0 : _a3.content;
|
|
11452
|
+
})
|
|
11453
|
+
)
|
|
11442
11454
|
];
|
|
11443
11455
|
return /* @__PURE__ */ jsxs8(
|
|
11444
11456
|
"th",
|
|
@@ -11478,8 +11490,9 @@ function HTable(_a) {
|
|
|
11478
11490
|
);
|
|
11479
11491
|
}) }) }),
|
|
11480
11492
|
/* @__PURE__ */ jsx11("tbody", { className: "divide-y divide-gray-200", children: mapedData.filter((md) => {
|
|
11493
|
+
var _a2;
|
|
11481
11494
|
for (let datum of Object.keys(md)) {
|
|
11482
|
-
if (!filters[datum].map((d) => `${d}`.toLowerCase()).includes(`${md[datum].content}`.toLowerCase())) {
|
|
11495
|
+
if (!filters[datum].map((d) => `${d}`.toLowerCase()).includes(`${(_a2 = md[datum]) == null ? void 0 : _a2.content}`.toLowerCase())) {
|
|
11483
11496
|
return false;
|
|
11484
11497
|
}
|
|
11485
11498
|
}
|
|
@@ -32687,7 +32700,7 @@ function Select(_a) {
|
|
|
32687
32700
|
}
|
|
32688
32701
|
|
|
32689
32702
|
// src/modal/index.tsx
|
|
32690
|
-
import { useRef as useRef6 } from "react";
|
|
32703
|
+
import React6, { useRef as useRef6 } from "react";
|
|
32691
32704
|
import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
32692
32705
|
function Modal({ button, children, ref }) {
|
|
32693
32706
|
const modalRef = ref || useRef6(null);
|
|
@@ -32700,17 +32713,33 @@ function Modal({ button, children, ref }) {
|
|
|
32700
32713
|
typeof modalRef == "object" && ((_a = modalRef.current) == null ? void 0 : _a.close());
|
|
32701
32714
|
}
|
|
32702
32715
|
return /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
32703
|
-
button,
|
|
32716
|
+
React6.Children.map(button, (child) => {
|
|
32717
|
+
if (React6.isValidElement(child)) {
|
|
32718
|
+
return React6.cloneElement(child, {
|
|
32719
|
+
onClick: (e) => {
|
|
32720
|
+
var _a, _b;
|
|
32721
|
+
show();
|
|
32722
|
+
(_b = (_a = child.props) == null ? void 0 : _a.onClick) == null ? void 0 : _b.call(_a, e);
|
|
32723
|
+
}
|
|
32724
|
+
});
|
|
32725
|
+
}
|
|
32726
|
+
return child;
|
|
32727
|
+
}),
|
|
32704
32728
|
/* @__PURE__ */ jsx17("dialog", { ref: modalRef, className: "p-5 border shadow rounded", children: /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
|
|
32705
32729
|
/* @__PURE__ */ jsx17(
|
|
32706
32730
|
"button",
|
|
32707
32731
|
{
|
|
32708
32732
|
onClick: hide,
|
|
32709
32733
|
className: "absolute top-0 right-0 text-red-500 ",
|
|
32710
|
-
children:
|
|
32734
|
+
children: "X"
|
|
32711
32735
|
}
|
|
32712
32736
|
),
|
|
32713
|
-
/* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-3 pt-6", children
|
|
32737
|
+
/* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-3 pt-6", children: React6.Children.map(children, (child) => {
|
|
32738
|
+
if (React6.isValidElement(child)) {
|
|
32739
|
+
return React6.cloneElement(child, { hide });
|
|
32740
|
+
}
|
|
32741
|
+
return child;
|
|
32742
|
+
}) })
|
|
32714
32743
|
] }) })
|
|
32715
32744
|
] });
|
|
32716
32745
|
}
|
package/package.json
CHANGED
package/src/modal/index.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
|
+
|
|
3
3
|
interface Props
|
|
4
4
|
extends React.DetailedHTMLProps<
|
|
5
5
|
React.DialogHTMLAttributes<HTMLDialogElement>,
|
|
6
6
|
HTMLDialogElement
|
|
7
7
|
> {
|
|
8
|
-
button: React.ReactElement
|
|
8
|
+
button: React.ReactElement<{ onClick: (e: React.MouseEvent) => void }>;
|
|
9
|
+
children: React.ReactElement<{ hide: () => void }>;
|
|
9
10
|
}
|
|
10
11
|
export default function Modal({ button, children, ref }: Props) {
|
|
11
12
|
const modalRef = ref || useRef<HTMLDialogElement>(null);
|
|
@@ -18,7 +19,17 @@ export default function Modal({ button, children, ref }: Props) {
|
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
21
|
<>
|
|
21
|
-
{button
|
|
22
|
+
{React.Children.map(button, (child) => {
|
|
23
|
+
if (React.isValidElement(child)) {
|
|
24
|
+
return React.cloneElement(child, {
|
|
25
|
+
onClick: (e) => {
|
|
26
|
+
show();
|
|
27
|
+
child.props?.onClick?.(e);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return child;
|
|
32
|
+
})}
|
|
22
33
|
<dialog ref={modalRef} className="p-5 border shadow rounded">
|
|
23
34
|
<div className="relative">
|
|
24
35
|
{/* Botón de cerrar en la esquina superior derecha */}
|
|
@@ -26,9 +37,16 @@ export default function Modal({ button, children, ref }: Props) {
|
|
|
26
37
|
onClick={hide}
|
|
27
38
|
className="absolute top-0 right-0 text-red-500 "
|
|
28
39
|
>
|
|
29
|
-
|
|
40
|
+
X
|
|
30
41
|
</button>
|
|
31
|
-
<div className="flex flex-col gap-3 pt-6">
|
|
42
|
+
<div className="flex flex-col gap-3 pt-6">
|
|
43
|
+
{React.Children.map(children, (child) => {
|
|
44
|
+
if (React.isValidElement(child)) {
|
|
45
|
+
return React.cloneElement(child, { hide });
|
|
46
|
+
}
|
|
47
|
+
return child;
|
|
48
|
+
})}
|
|
49
|
+
</div>
|
|
32
50
|
</div>
|
|
33
51
|
</dialog>
|
|
34
52
|
</>
|
|
@@ -27,7 +27,7 @@ export default function FilterMenu({
|
|
|
27
27
|
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
setNewMapedData(
|
|
30
|
-
[...new Set<string>(mapedData.map((md: any) => md[h]
|
|
30
|
+
[...new Set<string>(mapedData.map((md: any) => md[h]?.content))].filter(
|
|
31
31
|
(item) => {
|
|
32
32
|
return item && `${item}`.toLowerCase().includes(text.toLowerCase());
|
|
33
33
|
}
|
package/src/table/h.tsx
CHANGED
|
@@ -24,7 +24,7 @@ export default function HTable({
|
|
|
24
24
|
const mapedTotals = useMemo(() => {
|
|
25
25
|
return mapedData.reduce((acc: any, md: any) => {
|
|
26
26
|
head.forEach((h) => {
|
|
27
|
-
const value = isNaN(+md[h]
|
|
27
|
+
const value = isNaN(+md[h]?.content) ? 0 : +md[h]?.content;
|
|
28
28
|
if (acc[h]) {
|
|
29
29
|
acc[h] += value;
|
|
30
30
|
} else {
|
|
@@ -40,7 +40,7 @@ export default function HTable({
|
|
|
40
40
|
...head.reduce((acc, hh) => {
|
|
41
41
|
const newAcc: any = { ...acc };
|
|
42
42
|
newAcc[hh] = [
|
|
43
|
-
...new Set<string>(mapedData.map((md: any) => md[hh]
|
|
43
|
+
...new Set<string>(mapedData.map((md: any) => md[hh]?.content)),
|
|
44
44
|
];
|
|
45
45
|
return newAcc;
|
|
46
46
|
}, {}),
|
|
@@ -80,7 +80,9 @@ export default function HTable({
|
|
|
80
80
|
<tr>
|
|
81
81
|
{head.map((h, key) => {
|
|
82
82
|
const items = [
|
|
83
|
-
...new Set<string>(
|
|
83
|
+
...new Set<string>(
|
|
84
|
+
mapedData.map((item: any) => item[h]?.content)
|
|
85
|
+
),
|
|
84
86
|
];
|
|
85
87
|
return (
|
|
86
88
|
<th
|
|
@@ -125,7 +127,7 @@ export default function HTable({
|
|
|
125
127
|
if (
|
|
126
128
|
!filters[datum]
|
|
127
129
|
.map((d: any) => `${d}`.toLowerCase())
|
|
128
|
-
.includes(`${md[datum]
|
|
130
|
+
.includes(`${md[datum]?.content}`.toLowerCase())
|
|
129
131
|
) {
|
|
130
132
|
return false;
|
|
131
133
|
}
|