next-recomponents 2.0.55 → 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 +62 -0
- package/dist/index.mjs +60 -0
- package/package.json +1 -1
- package/src/index.tsx +2 -0
- 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,
|
|
@@ -39666,6 +39668,64 @@ function TableAdvanced(tableProps) {
|
|
|
39666
39668
|
}
|
|
39667
39669
|
return null;
|
|
39668
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
|
+
}
|
|
39669
39729
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39670
39730
|
0 && (module.exports = {
|
|
39671
39731
|
Alert,
|
|
@@ -39678,6 +39738,8 @@ function TableAdvanced(tableProps) {
|
|
|
39678
39738
|
MyCalendar,
|
|
39679
39739
|
Pre,
|
|
39680
39740
|
Select,
|
|
39741
|
+
TabContainer,
|
|
39742
|
+
TabItem,
|
|
39681
39743
|
Table,
|
|
39682
39744
|
Table3,
|
|
39683
39745
|
TableAdvanced,
|
package/dist/index.mjs
CHANGED
|
@@ -39664,6 +39664,64 @@ function TableAdvanced(tableProps) {
|
|
|
39664
39664
|
}
|
|
39665
39665
|
return null;
|
|
39666
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
|
+
}
|
|
39667
39725
|
export {
|
|
39668
39726
|
Alert,
|
|
39669
39727
|
Button,
|
|
@@ -39675,6 +39733,8 @@ export {
|
|
|
39675
39733
|
MyCalendar,
|
|
39676
39734
|
pre_default as Pre,
|
|
39677
39735
|
Select,
|
|
39736
|
+
TabContainer,
|
|
39737
|
+
TabItem,
|
|
39678
39738
|
Table,
|
|
39679
39739
|
Table3,
|
|
39680
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";
|
|
@@ -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
|
+
}
|