next-recomponents 2.0.54 → 2.0.56
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 +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +66 -2
- package/dist/index.mjs +64 -2
- package/package.json +1 -1
- package/src/index.tsx +2 -0
- package/src/select/index.tsx +3 -2
- package/src/tabs/index.tsx +83 -0
package/dist/index.d.mts
CHANGED
|
@@ -280,4 +280,17 @@ interface TableProps {
|
|
|
280
280
|
|
|
281
281
|
declare function TableAdvanced(tableProps: TableProps): react_jsx_runtime.JSX.Element | null;
|
|
282
282
|
|
|
283
|
-
|
|
283
|
+
interface TabContainerProps {
|
|
284
|
+
children: ReactNode;
|
|
285
|
+
labelMaxWidth?: number;
|
|
286
|
+
currentIndex?: number;
|
|
287
|
+
}
|
|
288
|
+
declare function TabContainer({ children, labelMaxWidth, currentIndex, }: TabContainerProps): react_jsx_runtime.JSX.Element;
|
|
289
|
+
interface TabItemProps {
|
|
290
|
+
label: string;
|
|
291
|
+
children: ReactNode;
|
|
292
|
+
disabled?: boolean;
|
|
293
|
+
}
|
|
294
|
+
declare function TabItem({ children }: TabItemProps): react_jsx_runtime.JSX.Element;
|
|
295
|
+
|
|
296
|
+
export { Alert, Button, Container, DocumentViewer, Form, Input, Modal, MyCalendar, Pre, Select, TabContainer, TabItem, Table, Table3, TableAdvanced, type TableButtonProps, type TableButtonProps as TableEventProps, TextArea, regularExpresions, useDates, useExcel, useFormValues, usePopup, useResources };
|
package/dist/index.d.ts
CHANGED
|
@@ -280,4 +280,17 @@ interface TableProps {
|
|
|
280
280
|
|
|
281
281
|
declare function TableAdvanced(tableProps: TableProps): react_jsx_runtime.JSX.Element | null;
|
|
282
282
|
|
|
283
|
-
|
|
283
|
+
interface TabContainerProps {
|
|
284
|
+
children: ReactNode;
|
|
285
|
+
labelMaxWidth?: number;
|
|
286
|
+
currentIndex?: number;
|
|
287
|
+
}
|
|
288
|
+
declare function TabContainer({ children, labelMaxWidth, currentIndex, }: TabContainerProps): react_jsx_runtime.JSX.Element;
|
|
289
|
+
interface TabItemProps {
|
|
290
|
+
label: string;
|
|
291
|
+
children: ReactNode;
|
|
292
|
+
disabled?: boolean;
|
|
293
|
+
}
|
|
294
|
+
declare function TabItem({ children }: TabItemProps): react_jsx_runtime.JSX.Element;
|
|
295
|
+
|
|
296
|
+
export { Alert, Button, Container, DocumentViewer, Form, Input, Modal, MyCalendar, Pre, Select, TabContainer, TabItem, Table, Table3, TableAdvanced, type TableButtonProps, type TableButtonProps as TableEventProps, TextArea, regularExpresions, useDates, useExcel, useFormValues, usePopup, useResources };
|
package/dist/index.js
CHANGED
|
@@ -3498,6 +3498,8 @@ __export(index_exports, {
|
|
|
3498
3498
|
MyCalendar: () => MyCalendar,
|
|
3499
3499
|
Pre: () => pre_default,
|
|
3500
3500
|
Select: () => Select,
|
|
3501
|
+
TabContainer: () => TabContainer,
|
|
3502
|
+
TabItem: () => TabItem,
|
|
3501
3503
|
Table: () => Table,
|
|
3502
3504
|
Table3: () => Table3,
|
|
3503
3505
|
TableAdvanced: () => TableAdvanced,
|
|
@@ -36786,9 +36788,11 @@ function Select({
|
|
|
36786
36788
|
const parsedOptions = import_react9.default.Children.toArray(children).filter((child) => {
|
|
36787
36789
|
return child.type === "option";
|
|
36788
36790
|
}).map((child) => {
|
|
36791
|
+
var _a2;
|
|
36792
|
+
const label2 = import_react9.default.Children.toArray(child.props.children).join("");
|
|
36789
36793
|
return {
|
|
36790
|
-
value: child.props.value,
|
|
36791
|
-
label:
|
|
36794
|
+
value: ((_a2 = child.props) == null ? void 0 : _a2.value) || label2,
|
|
36795
|
+
label: label2
|
|
36792
36796
|
};
|
|
36793
36797
|
});
|
|
36794
36798
|
setOptions(parsedOptions);
|
|
@@ -39664,6 +39668,64 @@ function TableAdvanced(tableProps) {
|
|
|
39664
39668
|
}
|
|
39665
39669
|
return null;
|
|
39666
39670
|
}
|
|
39671
|
+
|
|
39672
|
+
// src/tabs/index.tsx
|
|
39673
|
+
var import_react22 = __toESM(require("react"));
|
|
39674
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
39675
|
+
function TabContainer({
|
|
39676
|
+
children,
|
|
39677
|
+
labelMaxWidth = 100,
|
|
39678
|
+
currentIndex = 0
|
|
39679
|
+
}) {
|
|
39680
|
+
const [index, setIndex] = (0, import_react22.useState)(0);
|
|
39681
|
+
const items = import_react22.default.Children.toArray(
|
|
39682
|
+
children
|
|
39683
|
+
);
|
|
39684
|
+
const labels = items.map((c) => c.props.label);
|
|
39685
|
+
const handleKeyDown = (e, k) => {
|
|
39686
|
+
if (e.key === "ArrowRight") setIndex((k + 1) % labels.length);
|
|
39687
|
+
if (e.key === "ArrowLeft")
|
|
39688
|
+
setIndex((k - 1 + labels.length) % labels.length);
|
|
39689
|
+
};
|
|
39690
|
+
(0, import_react22.useEffect)(() => {
|
|
39691
|
+
setIndex(currentIndex);
|
|
39692
|
+
}, [currentIndex]);
|
|
39693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "w-full bg-white", children: [
|
|
39694
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { role: "tablist", className: "flex gap-1 border-b border-slate-200", children: labels.map((label, k) => {
|
|
39695
|
+
var _a, _b;
|
|
39696
|
+
const active = k === index;
|
|
39697
|
+
const isDisabled = (_b = (_a = items.find((i) => i.props.label == label)) == null ? void 0 : _a.props) == null ? void 0 : _b.disabled;
|
|
39698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
39699
|
+
"button",
|
|
39700
|
+
{
|
|
39701
|
+
style: { maxWidth: labelMaxWidth },
|
|
39702
|
+
title: label,
|
|
39703
|
+
role: "tab",
|
|
39704
|
+
type: "button",
|
|
39705
|
+
"aria-selected": active,
|
|
39706
|
+
tabIndex: active ? 0 : -1,
|
|
39707
|
+
onClick: () => !isDisabled && setIndex(k),
|
|
39708
|
+
onKeyDown: (e) => !isDisabled && handleKeyDown(e, k),
|
|
39709
|
+
className: [
|
|
39710
|
+
"truncate relative px-4 py-2 text-sm font-medium transition-colors duration-150",
|
|
39711
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 focus-visible:ring-offset-1 rounded-t-md",
|
|
39712
|
+
active ? "text-indigo-600" : "text-slate-500 hover:text-slate-700 hover:bg-gray-200",
|
|
39713
|
+
isDisabled ? " text-gray-300 cursor-not-allowed hover:text-gray-300 hover:bg-white" : ""
|
|
39714
|
+
].join(" "),
|
|
39715
|
+
children: [
|
|
39716
|
+
label,
|
|
39717
|
+
active && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "absolute left-0 right-0 -bottom-px h-0.5 bg-indigo-600 rounded-full" })
|
|
39718
|
+
]
|
|
39719
|
+
},
|
|
39720
|
+
label + k
|
|
39721
|
+
);
|
|
39722
|
+
}) }),
|
|
39723
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { role: "tabpanel", className: "p-4 text-sm text-slate-700", children: items[index] })
|
|
39724
|
+
] });
|
|
39725
|
+
}
|
|
39726
|
+
function TabItem({ children }) {
|
|
39727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
|
39728
|
+
}
|
|
39667
39729
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39668
39730
|
0 && (module.exports = {
|
|
39669
39731
|
Alert,
|
|
@@ -39676,6 +39738,8 @@ function TableAdvanced(tableProps) {
|
|
|
39676
39738
|
MyCalendar,
|
|
39677
39739
|
Pre,
|
|
39678
39740
|
Select,
|
|
39741
|
+
TabContainer,
|
|
39742
|
+
TabItem,
|
|
39679
39743
|
Table,
|
|
39680
39744
|
Table3,
|
|
39681
39745
|
TableAdvanced,
|
package/dist/index.mjs
CHANGED
|
@@ -36771,9 +36771,11 @@ function Select({
|
|
|
36771
36771
|
const parsedOptions = React5.Children.toArray(children).filter((child) => {
|
|
36772
36772
|
return child.type === "option";
|
|
36773
36773
|
}).map((child) => {
|
|
36774
|
+
var _a2;
|
|
36775
|
+
const label2 = React5.Children.toArray(child.props.children).join("");
|
|
36774
36776
|
return {
|
|
36775
|
-
value: child.props.value,
|
|
36776
|
-
label:
|
|
36777
|
+
value: ((_a2 = child.props) == null ? void 0 : _a2.value) || label2,
|
|
36778
|
+
label: label2
|
|
36777
36779
|
};
|
|
36778
36780
|
});
|
|
36779
36781
|
setOptions(parsedOptions);
|
|
@@ -39662,6 +39664,64 @@ function TableAdvanced(tableProps) {
|
|
|
39662
39664
|
}
|
|
39663
39665
|
return null;
|
|
39664
39666
|
}
|
|
39667
|
+
|
|
39668
|
+
// src/tabs/index.tsx
|
|
39669
|
+
import React11, { useEffect as useEffect14, useState as useState18 } from "react";
|
|
39670
|
+
import { Fragment as Fragment3, jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
39671
|
+
function TabContainer({
|
|
39672
|
+
children,
|
|
39673
|
+
labelMaxWidth = 100,
|
|
39674
|
+
currentIndex = 0
|
|
39675
|
+
}) {
|
|
39676
|
+
const [index, setIndex] = useState18(0);
|
|
39677
|
+
const items = React11.Children.toArray(
|
|
39678
|
+
children
|
|
39679
|
+
);
|
|
39680
|
+
const labels = items.map((c) => c.props.label);
|
|
39681
|
+
const handleKeyDown = (e, k) => {
|
|
39682
|
+
if (e.key === "ArrowRight") setIndex((k + 1) % labels.length);
|
|
39683
|
+
if (e.key === "ArrowLeft")
|
|
39684
|
+
setIndex((k - 1 + labels.length) % labels.length);
|
|
39685
|
+
};
|
|
39686
|
+
useEffect14(() => {
|
|
39687
|
+
setIndex(currentIndex);
|
|
39688
|
+
}, [currentIndex]);
|
|
39689
|
+
return /* @__PURE__ */ jsxs26("div", { className: "w-full bg-white", children: [
|
|
39690
|
+
/* @__PURE__ */ jsx35("div", { role: "tablist", className: "flex gap-1 border-b border-slate-200", children: labels.map((label, k) => {
|
|
39691
|
+
var _a, _b;
|
|
39692
|
+
const active = k === index;
|
|
39693
|
+
const isDisabled = (_b = (_a = items.find((i) => i.props.label == label)) == null ? void 0 : _a.props) == null ? void 0 : _b.disabled;
|
|
39694
|
+
return /* @__PURE__ */ jsxs26(
|
|
39695
|
+
"button",
|
|
39696
|
+
{
|
|
39697
|
+
style: { maxWidth: labelMaxWidth },
|
|
39698
|
+
title: label,
|
|
39699
|
+
role: "tab",
|
|
39700
|
+
type: "button",
|
|
39701
|
+
"aria-selected": active,
|
|
39702
|
+
tabIndex: active ? 0 : -1,
|
|
39703
|
+
onClick: () => !isDisabled && setIndex(k),
|
|
39704
|
+
onKeyDown: (e) => !isDisabled && handleKeyDown(e, k),
|
|
39705
|
+
className: [
|
|
39706
|
+
"truncate relative px-4 py-2 text-sm font-medium transition-colors duration-150",
|
|
39707
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 focus-visible:ring-offset-1 rounded-t-md",
|
|
39708
|
+
active ? "text-indigo-600" : "text-slate-500 hover:text-slate-700 hover:bg-gray-200",
|
|
39709
|
+
isDisabled ? " text-gray-300 cursor-not-allowed hover:text-gray-300 hover:bg-white" : ""
|
|
39710
|
+
].join(" "),
|
|
39711
|
+
children: [
|
|
39712
|
+
label,
|
|
39713
|
+
active && /* @__PURE__ */ jsx35("span", { className: "absolute left-0 right-0 -bottom-px h-0.5 bg-indigo-600 rounded-full" })
|
|
39714
|
+
]
|
|
39715
|
+
},
|
|
39716
|
+
label + k
|
|
39717
|
+
);
|
|
39718
|
+
}) }),
|
|
39719
|
+
/* @__PURE__ */ jsx35("div", { role: "tabpanel", className: "p-4 text-sm text-slate-700", children: items[index] })
|
|
39720
|
+
] });
|
|
39721
|
+
}
|
|
39722
|
+
function TabItem({ children }) {
|
|
39723
|
+
return /* @__PURE__ */ jsx35(Fragment3, { children });
|
|
39724
|
+
}
|
|
39665
39725
|
export {
|
|
39666
39726
|
Alert,
|
|
39667
39727
|
Button,
|
|
@@ -39673,6 +39733,8 @@ export {
|
|
|
39673
39733
|
MyCalendar,
|
|
39674
39734
|
pre_default as Pre,
|
|
39675
39735
|
Select,
|
|
39736
|
+
TabContainer,
|
|
39737
|
+
TabItem,
|
|
39676
39738
|
Table,
|
|
39677
39739
|
Table3,
|
|
39678
39740
|
TableAdvanced,
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -20,3 +20,5 @@ export { default as DocumentViewer } from "./doc-viewer";
|
|
|
20
20
|
export { default as Table3 } from "./table3";
|
|
21
21
|
export { default as usePopup } from "./pop";
|
|
22
22
|
export { default as TableAdvanced } from "./table-advanced";
|
|
23
|
+
export { default as TabContainer } from "./tabs";
|
|
24
|
+
export { TabItem } from "./tabs";
|
package/src/select/index.tsx
CHANGED
|
@@ -85,9 +85,10 @@ export default function Select({
|
|
|
85
85
|
return (child as ReactElement).type === "option";
|
|
86
86
|
})
|
|
87
87
|
.map((child: any) => {
|
|
88
|
+
const label = React.Children.toArray(child.props.children).join("");
|
|
88
89
|
return {
|
|
89
|
-
value: child.props
|
|
90
|
-
label
|
|
90
|
+
value: child.props?.value || label,
|
|
91
|
+
label,
|
|
91
92
|
};
|
|
92
93
|
});
|
|
93
94
|
setOptions(parsedOptions);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { ReactNode, useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
interface TabContainerProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
labelMaxWidth?: number;
|
|
6
|
+
currentIndex?: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default function TabContainer({
|
|
10
|
+
children,
|
|
11
|
+
labelMaxWidth = 100,
|
|
12
|
+
currentIndex = 0,
|
|
13
|
+
}: TabContainerProps) {
|
|
14
|
+
const [index, setIndex] = useState(0);
|
|
15
|
+
const items = React.Children.toArray(
|
|
16
|
+
children,
|
|
17
|
+
) as React.ReactElement<TabItemProps>[];
|
|
18
|
+
const labels = items.map((c) => c.props.label);
|
|
19
|
+
|
|
20
|
+
const handleKeyDown = (e: React.KeyboardEvent, k: number) => {
|
|
21
|
+
if (e.key === "ArrowRight") setIndex((k + 1) % labels.length);
|
|
22
|
+
if (e.key === "ArrowLeft")
|
|
23
|
+
setIndex((k - 1 + labels.length) % labels.length);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setIndex(currentIndex);
|
|
28
|
+
}, [currentIndex]);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className="w-full bg-white">
|
|
32
|
+
<div role="tablist" className="flex gap-1 border-b border-slate-200">
|
|
33
|
+
{labels.map((label, k) => {
|
|
34
|
+
const active = k === index;
|
|
35
|
+
const isDisabled = items.find((i) => i.props.label == label)?.props
|
|
36
|
+
?.disabled;
|
|
37
|
+
return (
|
|
38
|
+
<button
|
|
39
|
+
style={{ maxWidth: labelMaxWidth }}
|
|
40
|
+
key={label + k}
|
|
41
|
+
title={label}
|
|
42
|
+
role="tab"
|
|
43
|
+
type="button"
|
|
44
|
+
aria-selected={active}
|
|
45
|
+
tabIndex={active ? 0 : -1}
|
|
46
|
+
onClick={() => !isDisabled && setIndex(k)}
|
|
47
|
+
onKeyDown={(e) => !isDisabled && handleKeyDown(e, k)}
|
|
48
|
+
className={[
|
|
49
|
+
"truncate relative px-4 py-2 text-sm font-medium transition-colors duration-150",
|
|
50
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 focus-visible:ring-offset-1 rounded-t-md",
|
|
51
|
+
active
|
|
52
|
+
? "text-indigo-600"
|
|
53
|
+
: "text-slate-500 hover:text-slate-700 hover:bg-gray-200",
|
|
54
|
+
isDisabled
|
|
55
|
+
? " text-gray-300 cursor-not-allowed hover:text-gray-300 hover:bg-white"
|
|
56
|
+
: "",
|
|
57
|
+
].join(" ")}
|
|
58
|
+
>
|
|
59
|
+
{label}
|
|
60
|
+
{active && (
|
|
61
|
+
<span className="absolute left-0 right-0 -bottom-px h-0.5 bg-indigo-600 rounded-full" />
|
|
62
|
+
)}
|
|
63
|
+
</button>
|
|
64
|
+
);
|
|
65
|
+
})}
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<div role="tabpanel" className="p-4 text-sm text-slate-700">
|
|
69
|
+
{items[index]}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface TabItemProps {
|
|
76
|
+
label: string;
|
|
77
|
+
children: ReactNode;
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function TabItem({ children }: TabItemProps) {
|
|
82
|
+
return <>{children}</>;
|
|
83
|
+
}
|