@neasg/design-system 0.1.3 → 0.2.1
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/README.md +102 -14
- package/dist/animated-icons/arrow-down.d.ts +10 -0
- package/dist/animated-icons/arrow-down.js +54 -0
- package/dist/animated-icons/arrow-up.d.ts +10 -0
- package/dist/animated-icons/arrow-up.js +54 -0
- package/dist/animated-icons/bell.d.ts +10 -0
- package/dist/animated-icons/bell.js +42 -0
- package/dist/animated-icons/bold.d.ts +10 -0
- package/dist/animated-icons/bold.js +45 -0
- package/dist/animated-icons/book-open.d.ts +10 -0
- package/dist/animated-icons/book-open.js +55 -0
- package/dist/animated-icons/building.d.ts +10 -0
- package/dist/animated-icons/building.js +46 -0
- package/dist/animated-icons/check.d.ts +10 -0
- package/dist/animated-icons/check.js +55 -0
- package/dist/animated-icons/chevron-down.d.ts +10 -0
- package/dist/animated-icons/chevron-down.js +42 -0
- package/dist/animated-icons/chevron-left.d.ts +10 -0
- package/dist/animated-icons/chevron-left.js +42 -0
- package/dist/animated-icons/chevron-right.d.ts +10 -0
- package/dist/animated-icons/chevron-right.js +42 -0
- package/dist/animated-icons/chevron-up.d.ts +10 -0
- package/dist/animated-icons/chevron-up.js +42 -0
- package/dist/animated-icons/clipboard-check.d.ts +10 -0
- package/dist/animated-icons/clipboard-check.js +56 -0
- package/dist/animated-icons/download.d.ts +10 -0
- package/dist/animated-icons/download.js +47 -0
- package/dist/animated-icons/external-link.d.ts +10 -0
- package/dist/animated-icons/external-link.js +59 -0
- package/dist/animated-icons/eye.d.ts +10 -0
- package/dist/animated-icons/eye.js +41 -0
- package/dist/animated-icons/file-text.d.ts +11 -0
- package/dist/animated-icons/file-text.js +89 -0
- package/dist/animated-icons/filter.d.ts +10 -0
- package/dist/animated-icons/filter.js +78 -0
- package/dist/animated-icons/folder-open.d.ts +10 -0
- package/dist/animated-icons/folder-open.js +46 -0
- package/dist/animated-icons/form.d.ts +10 -0
- package/dist/animated-icons/form.js +56 -0
- package/dist/animated-icons/git-branch.d.ts +10 -0
- package/dist/animated-icons/git-branch.js +56 -0
- package/dist/animated-icons/grip-horizontal.d.ts +10 -0
- package/dist/animated-icons/grip-horizontal.js +70 -0
- package/dist/animated-icons/grip-vertical.d.ts +10 -0
- package/dist/animated-icons/grip-vertical.js +67 -0
- package/dist/animated-icons/grip.d.ts +10 -0
- package/dist/animated-icons/grip.js +72 -0
- package/dist/animated-icons/highlighter.d.ts +10 -0
- package/dist/animated-icons/highlighter.js +46 -0
- package/dist/animated-icons/history.d.ts +10 -0
- package/dist/animated-icons/history.js +80 -0
- package/dist/animated-icons/index.d.ts +100 -0
- package/dist/animated-icons/index.js +50 -0
- package/dist/animated-icons/italic.d.ts +10 -0
- package/dist/animated-icons/italic.js +45 -0
- package/dist/animated-icons/link.d.ts +10 -0
- package/dist/animated-icons/link.js +51 -0
- package/dist/animated-icons/list-ordered.d.ts +10 -0
- package/dist/animated-icons/list-ordered.js +46 -0
- package/dist/animated-icons/list.d.ts +10 -0
- package/dist/animated-icons/list.js +56 -0
- package/dist/animated-icons/loader-pinwheel.d.ts +10 -0
- package/dist/animated-icons/loader-pinwheel.js +51 -0
- package/dist/animated-icons/logout.d.ts +10 -0
- package/dist/animated-icons/logout.js +44 -0
- package/dist/animated-icons/maximize.d.ts +10 -0
- package/dist/animated-icons/maximize.js +45 -0
- package/dist/animated-icons/message-square.d.ts +10 -0
- package/dist/animated-icons/message-square.js +56 -0
- package/dist/animated-icons/palette.d.ts +10 -0
- package/dist/animated-icons/palette.js +45 -0
- package/dist/animated-icons/paperclip.d.ts +10 -0
- package/dist/animated-icons/paperclip.js +45 -0
- package/dist/animated-icons/pencil.d.ts +10 -0
- package/dist/animated-icons/pencil.js +46 -0
- package/dist/animated-icons/plus.d.ts +10 -0
- package/dist/animated-icons/plus.js +42 -0
- package/dist/animated-icons/search.d.ts +10 -0
- package/dist/animated-icons/search.js +44 -0
- package/dist/animated-icons/send.d.ts +10 -0
- package/dist/animated-icons/send.js +46 -0
- package/dist/animated-icons/settings.d.ts +10 -0
- package/dist/animated-icons/settings.js +42 -0
- package/dist/animated-icons/shield.d.ts +10 -0
- package/dist/animated-icons/shield.js +45 -0
- package/dist/animated-icons/strikethrough.d.ts +10 -0
- package/dist/animated-icons/strikethrough.js +45 -0
- package/dist/animated-icons/timer.d.ts +10 -0
- package/dist/animated-icons/timer.js +70 -0
- package/dist/animated-icons/trash.d.ts +10 -0
- package/dist/animated-icons/trash.js +56 -0
- package/dist/animated-icons/trending-down.d.ts +10 -0
- package/dist/animated-icons/trending-down.js +86 -0
- package/dist/animated-icons/trending-up.d.ts +10 -0
- package/dist/animated-icons/trending-up.js +86 -0
- package/dist/animated-icons/underline.d.ts +10 -0
- package/dist/animated-icons/underline.js +45 -0
- package/dist/animated-icons/upload.d.ts +10 -0
- package/dist/animated-icons/upload.js +47 -0
- package/dist/animated-icons/users.d.ts +10 -0
- package/dist/animated-icons/users.js +45 -0
- package/dist/animated-icons/x.d.ts +10 -0
- package/dist/animated-icons/x.js +45 -0
- package/dist/avatar.d.ts +32 -0
- package/dist/avatar.js +21 -0
- package/dist/badge.d.ts +4 -3
- package/dist/badge.js +7 -12
- package/dist/breadcrumb.d.ts +30 -0
- package/dist/breadcrumb.js +32 -0
- package/dist/button.d.ts +2 -2
- package/dist/button.js +84 -6
- package/dist/command-search.d.ts +44 -0
- package/dist/command-search.js +73 -0
- package/dist/command.d.ts +77 -0
- package/dist/command.js +24 -0
- package/dist/count-badge.d.ts +10 -0
- package/dist/count-badge.js +34 -0
- package/dist/dialog-primitive.d.ts +22 -0
- package/dist/dialog-primitive.js +23 -0
- package/dist/dialog.d.ts +28 -0
- package/dist/dialog.js +60 -0
- package/dist/draggable-tabs.d.ts +27 -0
- package/dist/draggable-tabs.js +61 -0
- package/dist/drawer.d.ts +30 -0
- package/dist/drawer.js +77 -0
- package/dist/editable-table.d.ts +31 -0
- package/dist/editable-table.js +122 -0
- package/dist/email-input.d.ts +16 -0
- package/dist/email-input.js +55 -0
- package/dist/empty-state.d.ts +11 -0
- package/dist/empty-state.js +7 -0
- package/dist/field.d.ts +6 -0
- package/dist/field.js +18 -0
- package/dist/filter-toggle.d.ts +12 -0
- package/dist/filter-toggle.js +23 -0
- package/dist/govt-masthead.d.ts +9 -0
- package/dist/govt-masthead.js +8 -0
- package/dist/index.d.ts +55 -4
- package/dist/index.js +32 -4
- package/dist/input-control.d.ts +4 -0
- package/dist/input-control.js +7 -0
- package/dist/input-validation.d.ts +9 -0
- package/dist/input-validation.js +75 -0
- package/dist/input.d.ts +16 -0
- package/dist/input.js +22 -0
- package/dist/label-value-grid.d.ts +13 -0
- package/dist/label-value-grid.js +61 -0
- package/dist/label-value.d.ts +11 -0
- package/dist/label-value.js +19 -0
- package/dist/layout.d.ts +57 -0
- package/dist/layout.js +166 -0
- package/dist/otp-input.d.ts +21 -0
- package/dist/otp-input.js +60 -0
- package/dist/page-header.d.ts +9 -0
- package/dist/page-header.js +6 -0
- package/dist/pagination.d.ts +12 -0
- package/dist/pagination.js +24 -0
- package/dist/phone-input.d.ts +36 -0
- package/dist/phone-input.js +135 -0
- package/dist/right-drawer.d.ts +2 -0
- package/dist/right-drawer.js +1 -0
- package/dist/search-input-shell.d.ts +8 -0
- package/dist/search-input-shell.js +9 -0
- package/dist/search-input.d.ts +20 -0
- package/dist/search-input.js +73 -0
- package/dist/select-primitive.d.ts +17 -0
- package/dist/select-primitive.js +33 -0
- package/dist/select.d.ts +31 -0
- package/dist/select.js +97 -0
- package/dist/styles.css +111 -1
- package/dist/table-toolbar.d.ts +7 -0
- package/dist/table-toolbar.js +7 -0
- package/dist/table.d.ts +87 -3
- package/dist/table.js +102 -5
- package/dist/tabs.d.ts +24 -7
- package/dist/tabs.js +22 -26
- package/dist/tailwind-preset.d.ts +4 -0
- package/dist/tailwind-preset.js +97 -0
- package/dist/textarea.d.ts +16 -0
- package/dist/textarea.js +23 -0
- package/dist/theme.d.ts +259 -0
- package/dist/theme.js +118 -0
- package/dist/tooltip.d.ts +15 -3
- package/dist/tooltip.js +9 -4
- package/dist/typography.d.ts +11 -0
- package/dist/typography.js +41 -0
- package/dist/use-search-highlight.d.ts +13 -0
- package/dist/use-search-highlight.js +46 -0
- package/package.json +126 -4
package/dist/table.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import { type PaginationProps } from "./pagination";
|
|
3
|
+
interface TableRootProps extends React.HTMLAttributes<HTMLTableElement> {
|
|
3
4
|
wrapperClassName?: string;
|
|
4
5
|
}
|
|
5
|
-
declare const
|
|
6
|
+
declare const TableRoot: React.ForwardRefExoticComponent<TableRootProps & React.RefAttributes<HTMLTableElement>>;
|
|
7
|
+
interface TableContainerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
}
|
|
9
|
+
declare const TableContainer: React.ForwardRefExoticComponent<TableContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
10
|
declare const TableHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
7
11
|
declare const TableBody: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
8
12
|
declare const TableFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
@@ -20,4 +24,84 @@ declare const TableCell: React.ForwardRefExoticComponent<React.TdHTMLAttributes<
|
|
|
20
24
|
wrap?: boolean;
|
|
21
25
|
} & React.RefAttributes<HTMLTableCellElement>>;
|
|
22
26
|
declare const TableCaption: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableCaptionElement> & React.RefAttributes<HTMLTableCaptionElement>>;
|
|
23
|
-
|
|
27
|
+
type TableAlign = "left" | "center" | "right";
|
|
28
|
+
export type TableSortDirection = "asc" | "desc";
|
|
29
|
+
export type SortDirection = TableSortDirection;
|
|
30
|
+
export type TableSkeletonLine = {
|
|
31
|
+
width?: string;
|
|
32
|
+
height?: string;
|
|
33
|
+
badge?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type TableSkeletonConfig = {
|
|
36
|
+
width?: string;
|
|
37
|
+
height?: string;
|
|
38
|
+
badge?: boolean;
|
|
39
|
+
lines?: TableSkeletonLine[];
|
|
40
|
+
actions?: number;
|
|
41
|
+
};
|
|
42
|
+
export interface TableRowSkeletonProps {
|
|
43
|
+
columns: TableSkeletonConfig[];
|
|
44
|
+
rows?: number;
|
|
45
|
+
}
|
|
46
|
+
declare function TableRowSkeleton({ columns, rows }: TableRowSkeletonProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export declare const TABLE_SKELETON_PRESETS: {
|
|
48
|
+
readonly text: (width?: string, height?: string) => TableSkeletonConfig;
|
|
49
|
+
readonly badge: (width?: string, height?: string) => TableSkeletonConfig;
|
|
50
|
+
readonly actions: (count?: number) => TableSkeletonConfig;
|
|
51
|
+
readonly textWithSubtitle: (textWidth?: string, subtitleWidth?: string) => TableSkeletonConfig;
|
|
52
|
+
readonly badgeGroup: (count?: number, width?: string) => TableSkeletonConfig;
|
|
53
|
+
};
|
|
54
|
+
export interface TableColumn<Row> {
|
|
55
|
+
key: string;
|
|
56
|
+
header: React.ReactNode;
|
|
57
|
+
accessorKey?: keyof Row;
|
|
58
|
+
cell?: (row: Row, rowIndex: number) => React.ReactNode;
|
|
59
|
+
width?: string;
|
|
60
|
+
minWidth?: string;
|
|
61
|
+
maxWidth?: string;
|
|
62
|
+
wrap?: boolean;
|
|
63
|
+
align?: TableAlign;
|
|
64
|
+
sortable?: boolean;
|
|
65
|
+
sortKey?: string;
|
|
66
|
+
sortLabel?: string;
|
|
67
|
+
skeleton?: TableSkeletonConfig;
|
|
68
|
+
headerClassName?: string;
|
|
69
|
+
cellClassName?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface TableSortingProps {
|
|
72
|
+
field: string | null;
|
|
73
|
+
direction: TableSortDirection;
|
|
74
|
+
onSort: (field: string) => void;
|
|
75
|
+
}
|
|
76
|
+
interface SortableTableHeadProps<T extends string> {
|
|
77
|
+
field: T;
|
|
78
|
+
children: React.ReactNode;
|
|
79
|
+
currentSortField: T | null;
|
|
80
|
+
currentSortDirection: SortDirection;
|
|
81
|
+
onSort: (field: T) => void;
|
|
82
|
+
className?: string;
|
|
83
|
+
allowWrap?: boolean;
|
|
84
|
+
width?: string;
|
|
85
|
+
minWidth?: string;
|
|
86
|
+
maxWidth?: string;
|
|
87
|
+
align?: TableAlign;
|
|
88
|
+
sortLabel?: string;
|
|
89
|
+
}
|
|
90
|
+
declare function SortableTableHead<T extends string>({ field, children, currentSortField, currentSortDirection, onSort, className, allowWrap, width, minWidth, maxWidth, align, sortLabel, }: SortableTableHeadProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
91
|
+
export interface TableProps<Row> extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
92
|
+
columns: TableColumn<Row>[];
|
|
93
|
+
rows: Row[];
|
|
94
|
+
getRowKey: (row: Row, index: number) => string;
|
|
95
|
+
emptyState?: React.ReactNode;
|
|
96
|
+
toolbar?: React.ReactNode;
|
|
97
|
+
caption?: React.ReactNode;
|
|
98
|
+
containerClassName?: string;
|
|
99
|
+
tableClassName?: string;
|
|
100
|
+
rowClassName?: string | ((row: Row, index: number) => string | undefined);
|
|
101
|
+
sorting?: TableSortingProps;
|
|
102
|
+
pagination?: Omit<PaginationProps, "className">;
|
|
103
|
+
loading?: boolean;
|
|
104
|
+
loadingRows?: number;
|
|
105
|
+
}
|
|
106
|
+
declare function Table<Row>({ columns, rows, getRowKey, emptyState, toolbar, caption, className, containerClassName, tableClassName, rowClassName, sorting, pagination, loading, loadingRows, ...props }: TableProps<Row>): import("react/jsx-runtime").JSX.Element;
|
|
107
|
+
export { Table, TableRoot, TableContainer, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, SortableTableHead, TableRowSkeleton, };
|
package/dist/table.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import { ArrowUpDown } from "lucide-react";
|
|
4
|
+
import { ArrowDownIcon } from "./animated-icons/arrow-down";
|
|
5
|
+
import { ArrowUpIcon } from "./animated-icons/arrow-up";
|
|
6
|
+
import { EmptyState } from "./empty-state";
|
|
7
|
+
import { Pagination } from "./pagination";
|
|
3
8
|
import { cn } from "./lib/utils";
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
9
|
+
const TableRoot = React.forwardRef(({ className, wrapperClassName: _wrapperClassName, ...props }, ref) => (_jsx("table", { ref: ref, className: cn("w-full caption-bottom text-sm", className), ...props })));
|
|
10
|
+
TableRoot.displayName = "TableRoot";
|
|
11
|
+
const TableContainer = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("overflow-x-auto rounded-lg border bg-card", className), ...props })));
|
|
12
|
+
TableContainer.displayName = "TableContainer";
|
|
13
|
+
const TableHeader = React.forwardRef(({ className, ...props }, ref) => (_jsx("thead", { ref: ref, className: cn("sticky top-0 z-10 bg-muted/50 [&_tr]:border-b", className), ...props })));
|
|
7
14
|
TableHeader.displayName = "TableHeader";
|
|
8
15
|
const TableBody = React.forwardRef(({ className, ...props }, ref) => (_jsx("tbody", { ref: ref, className: cn("[&_tr:last-child]:border-0", className), ...props })));
|
|
9
16
|
TableBody.displayName = "TableBody";
|
|
@@ -13,6 +20,7 @@ const TableRow = React.forwardRef(({ className, ...props }, ref) => (_jsx("tr",
|
|
|
13
20
|
TableRow.displayName = "TableRow";
|
|
14
21
|
const TableHead = React.forwardRef(({ className, style, width, minWidth, maxWidth, wrap = false, ...props }, ref) => (_jsx("th", { ref: ref, className: cn("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0", wrap ? "whitespace-normal" : "whitespace-nowrap", className), style: {
|
|
15
22
|
...style,
|
|
23
|
+
fontWeight: 500,
|
|
16
24
|
...(width ? { width } : {}),
|
|
17
25
|
...(minWidth ? { minWidth } : {}),
|
|
18
26
|
...(maxWidth ? { maxWidth } : {}),
|
|
@@ -27,4 +35,93 @@ const TableCell = React.forwardRef(({ className, style, width, minWidth, maxWidt
|
|
|
27
35
|
TableCell.displayName = "TableCell";
|
|
28
36
|
const TableCaption = React.forwardRef(({ className, ...props }, ref) => (_jsx("caption", { ref: ref, className: cn("mt-4 text-sm text-muted-foreground", className), ...props })));
|
|
29
37
|
TableCaption.displayName = "TableCaption";
|
|
30
|
-
|
|
38
|
+
function alignClassName(align) {
|
|
39
|
+
switch (align) {
|
|
40
|
+
case "center":
|
|
41
|
+
return "text-center";
|
|
42
|
+
case "right":
|
|
43
|
+
return "text-right";
|
|
44
|
+
default:
|
|
45
|
+
return "text-left";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function SkeletonBlock({ width = "6rem", height = "1rem", badge = false, }) {
|
|
49
|
+
return (_jsx("div", { className: cn("animate-pulse bg-muted/80", badge ? "rounded-full" : "rounded"), style: { width, height }, "aria-hidden": "true" }));
|
|
50
|
+
}
|
|
51
|
+
function SkeletonCell({ config }) {
|
|
52
|
+
var _a;
|
|
53
|
+
if (config.actions) {
|
|
54
|
+
return (_jsx(TableCell, { children: _jsx("div", { className: "flex items-center gap-2", children: Array.from({ length: config.actions }).map((_, index) => (_jsx(SkeletonBlock, { width: "2rem", height: "2rem" }, index))) }) }));
|
|
55
|
+
}
|
|
56
|
+
if ((_a = config.lines) === null || _a === void 0 ? void 0 : _a.length) {
|
|
57
|
+
return (_jsx(TableCell, { children: _jsx("div", { className: "space-y-2", children: config.lines.map((line, index) => (_jsx(SkeletonBlock, { width: line.width, height: line.height, badge: line.badge }, index))) }) }));
|
|
58
|
+
}
|
|
59
|
+
return (_jsx(TableCell, { children: _jsx(SkeletonBlock, { width: config.width, height: config.height, badge: config.badge }) }));
|
|
60
|
+
}
|
|
61
|
+
function TableRowSkeleton({ columns, rows = 1 }) {
|
|
62
|
+
return (_jsx(_Fragment, { children: Array.from({ length: rows }).map((_, rowIndex) => (_jsx(TableRow, { children: columns.map((config, columnIndex) => (_jsx(SkeletonCell, { config: config }, columnIndex))) }, rowIndex))) }));
|
|
63
|
+
}
|
|
64
|
+
export const TABLE_SKELETON_PRESETS = {
|
|
65
|
+
text: (width = "8rem", height = "1rem") => ({
|
|
66
|
+
width,
|
|
67
|
+
height,
|
|
68
|
+
}),
|
|
69
|
+
badge: (width = "5rem", height = "1.25rem") => ({
|
|
70
|
+
width,
|
|
71
|
+
height,
|
|
72
|
+
badge: true,
|
|
73
|
+
}),
|
|
74
|
+
actions: (count = 2) => ({
|
|
75
|
+
actions: count,
|
|
76
|
+
}),
|
|
77
|
+
textWithSubtitle: (textWidth = "8rem", subtitleWidth = "6rem") => ({
|
|
78
|
+
lines: [
|
|
79
|
+
{ width: textWidth, height: "1rem" },
|
|
80
|
+
{ width: subtitleWidth, height: "0.75rem" },
|
|
81
|
+
],
|
|
82
|
+
}),
|
|
83
|
+
badgeGroup: (count = 2, width = "4rem") => ({
|
|
84
|
+
lines: Array.from({ length: count }).map(() => ({
|
|
85
|
+
width,
|
|
86
|
+
height: "1.25rem",
|
|
87
|
+
badge: true,
|
|
88
|
+
})),
|
|
89
|
+
}),
|
|
90
|
+
};
|
|
91
|
+
function SortableTableHead({ field, children, currentSortField, currentSortDirection, onSort, className, allowWrap = false, width, minWidth, maxWidth, align, sortLabel, }) {
|
|
92
|
+
const isSorted = currentSortField === field;
|
|
93
|
+
return (_jsx(TableHead, { className: cn(alignClassName(align), className), wrap: allowWrap, width: width, minWidth: minWidth, maxWidth: maxWidth, children: _jsxs("button", { type: "button", onClick: () => onSort(field), className: cn("flex cursor-pointer items-center gap-1 rounded px-2 py-1 font-medium transition-colors hover:text-foreground -ml-2", allowWrap
|
|
94
|
+
? "max-w-full items-start whitespace-normal text-left"
|
|
95
|
+
: "whitespace-nowrap", align === "right" && "ml-auto justify-end", align === "center" && "mx-auto justify-center"), style: { font: "inherit", color: "inherit", fontWeight: 500 }, "aria-label": `Sort by ${sortLabel !== null && sortLabel !== void 0 ? sortLabel : field}`, children: [children, _jsx("span", { className: "inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center", children: isSorted ? (currentSortDirection === "asc" ? (_jsx(ArrowUpIcon, { className: "shrink-0", size: 14 })) : (_jsx(ArrowDownIcon, { className: "shrink-0", size: 14 }))) : (_jsx(ArrowUpDown, { className: "h-3.5 w-3.5 shrink-0 opacity-50" })) })] }) }));
|
|
96
|
+
}
|
|
97
|
+
function getDefaultSkeleton(column) {
|
|
98
|
+
var _a, _b;
|
|
99
|
+
return {
|
|
100
|
+
width: (_b = (_a = column.width) !== null && _a !== void 0 ? _a : column.minWidth) !== null && _b !== void 0 ? _b : "7rem",
|
|
101
|
+
height: "1rem",
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function Table({ columns, rows, getRowKey, emptyState = (_jsx(EmptyState, { message: "No data available", description: "There are no rows to display in this table yet.", className: "border-0 bg-transparent px-0 py-6" })), toolbar, caption, className, containerClassName, tableClassName, rowClassName, sorting, pagination, loading = false, loadingRows = 5, ...props }) {
|
|
105
|
+
const shouldUseFixedLayout = columns.some((column) => column.width !== undefined ||
|
|
106
|
+
column.minWidth !== undefined ||
|
|
107
|
+
column.maxWidth !== undefined);
|
|
108
|
+
const container = (_jsx(TableContainer, { className: cn("w-full", className, containerClassName), ...props, children: _jsxs(TableRoot, { className: cn(shouldUseFixedLayout && "table-fixed", tableClassName), children: [caption ? _jsx(TableCaption, { children: caption }) : null, _jsx(TableHeader, { children: _jsx(TableRow, { children: columns.map((column) => {
|
|
109
|
+
var _a;
|
|
110
|
+
const sortField = (_a = column.sortKey) !== null && _a !== void 0 ? _a : column.key;
|
|
111
|
+
const isSortable = column.sortable && sorting;
|
|
112
|
+
return (isSortable ? (_jsx(SortableTableHead, { field: sortField, currentSortField: sorting.field, currentSortDirection: sorting.direction, onSort: sorting.onSort, className: column.headerClassName, allowWrap: column.wrap, width: column.width, minWidth: column.minWidth, maxWidth: column.maxWidth, align: column.align, sortLabel: column.sortLabel, children: column.header }, column.key)) : (_jsx(TableHead, { width: column.width, minWidth: column.minWidth, maxWidth: column.maxWidth, wrap: column.wrap, className: cn(alignClassName(column.align), column.headerClassName), children: column.header }, column.key)));
|
|
113
|
+
}) }) }), _jsx(TableBody, { children: loading ? (_jsx(TableRowSkeleton, { rows: loadingRows, columns: columns.map((column) => { var _a; return (_a = column.skeleton) !== null && _a !== void 0 ? _a : getDefaultSkeleton(column); }) })) : rows.length ? (rows.map((row, rowIndex) => (_jsx(TableRow, { className: typeof rowClassName === "function"
|
|
114
|
+
? rowClassName(row, rowIndex)
|
|
115
|
+
: rowClassName, children: columns.map((column) => {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
const value = (_b = (_a = column.cell) === null || _a === void 0 ? void 0 : _a.call(column, row, rowIndex)) !== null && _b !== void 0 ? _b : (column.accessorKey !== undefined
|
|
118
|
+
? row[column.accessorKey]
|
|
119
|
+
: null);
|
|
120
|
+
return (_jsx(TableCell, { width: column.width, minWidth: column.minWidth, maxWidth: column.maxWidth, wrap: column.wrap, className: cn(alignClassName(column.align), column.cellClassName), children: value }, column.key));
|
|
121
|
+
}) }, getRowKey(row, rowIndex))))) : (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length, className: "p-6", children: emptyState }) })) })] }) }));
|
|
122
|
+
if (!pagination) {
|
|
123
|
+
return (_jsxs("div", { className: "space-y-4", children: [toolbar, container] }));
|
|
124
|
+
}
|
|
125
|
+
return (_jsxs("div", { className: "space-y-4", children: [toolbar, container, _jsx(Pagination, { ...pagination })] }));
|
|
126
|
+
}
|
|
127
|
+
export { Table, TableRoot, TableContainer, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, SortableTableHead, TableRowSkeleton, };
|
package/dist/tabs.d.ts
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
2
3
|
type TabsContextValue = {
|
|
3
4
|
value: string;
|
|
4
5
|
setValue: (value: string) => void;
|
|
5
6
|
};
|
|
6
7
|
export declare function useTabsContext(): TabsContextValue | null;
|
|
7
|
-
interface
|
|
8
|
-
defaultValue
|
|
8
|
+
interface TabsRootProps extends Omit<React.ComponentPropsWithoutRef<typeof TabsPrimitive.Root>, "value" | "defaultValue" | "onValueChange"> {
|
|
9
|
+
defaultValue?: string;
|
|
9
10
|
value?: string;
|
|
10
11
|
onValueChange?: (value: string) => void;
|
|
11
12
|
}
|
|
12
|
-
declare
|
|
13
|
-
declare const TabsList: React.ForwardRefExoticComponent<React.
|
|
14
|
-
interface TabsTriggerProps extends React.
|
|
13
|
+
declare const TabsRoot: React.ForwardRefExoticComponent<TabsRootProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
interface TabsTriggerProps extends React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger> {
|
|
15
16
|
value: string;
|
|
16
17
|
}
|
|
17
18
|
declare const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
18
|
-
interface TabsContentProps extends React.
|
|
19
|
+
interface TabsContentProps extends React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content> {
|
|
19
20
|
value: string;
|
|
20
21
|
}
|
|
21
22
|
declare const TabsContent: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
-
export
|
|
23
|
+
export interface TabsItem {
|
|
24
|
+
value: string;
|
|
25
|
+
label: React.ReactNode;
|
|
26
|
+
content: React.ReactNode;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface TabsProps extends Omit<React.ComponentPropsWithoutRef<typeof TabsPrimitive.Root>, "children" | "value" | "defaultValue" | "onValueChange"> {
|
|
30
|
+
items: TabsItem[];
|
|
31
|
+
defaultValue?: string;
|
|
32
|
+
value?: string;
|
|
33
|
+
onValueChange?: (value: string) => void;
|
|
34
|
+
listClassName?: string;
|
|
35
|
+
triggerClassName?: string;
|
|
36
|
+
panelClassName?: string;
|
|
37
|
+
}
|
|
38
|
+
declare function Tabs({ items, defaultValue, value, onValueChange, className, listClassName, triggerClassName, panelClassName, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
39
|
+
export { Tabs, TabsRoot, TabsList, TabsTrigger, TabsContent };
|
package/dist/tabs.js
CHANGED
|
@@ -1,42 +1,38 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
4
5
|
import { cn } from "./lib/utils";
|
|
5
6
|
const TabsContext = React.createContext(null);
|
|
6
7
|
export function useTabsContext() {
|
|
7
8
|
return React.useContext(TabsContext);
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
const TabsRoot = React.forwardRef(({ defaultValue = "", value: valueProp, onValueChange, className, children, ...props }, ref) => {
|
|
10
11
|
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);
|
|
11
12
|
const isControlled = valueProp !== undefined;
|
|
12
13
|
const value = isControlled ? valueProp : uncontrolledValue;
|
|
13
14
|
const setValue = React.useCallback((next) => {
|
|
14
|
-
if (!isControlled)
|
|
15
|
+
if (!isControlled) {
|
|
15
16
|
setUncontrolledValue(next);
|
|
17
|
+
}
|
|
16
18
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(next);
|
|
17
19
|
}, [isControlled, onValueChange]);
|
|
18
|
-
const
|
|
19
|
-
return (_jsx(TabsContext.Provider, { value:
|
|
20
|
-
}
|
|
21
|
-
const TabsList = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("inline-flex h-fit items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground", className), ...props })));
|
|
22
|
-
TabsList.displayName = "TabsList";
|
|
23
|
-
const TabsTrigger = React.forwardRef(({ className, value, disabled, ...props }, ref) => {
|
|
24
|
-
const ctx = React.useContext(TabsContext);
|
|
25
|
-
if (!ctx) {
|
|
26
|
-
throw new Error("TabsTrigger must be used within Tabs");
|
|
27
|
-
}
|
|
28
|
-
const isActive = ctx.value === value;
|
|
29
|
-
return (_jsx("button", { ref: ref, type: "button", onClick: () => !disabled && ctx.setValue(value), "data-state": isActive ? "active" : "inactive", disabled: disabled, className: cn("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm", className), ...props }));
|
|
20
|
+
const contextValue = React.useMemo(() => ({ value, setValue }), [setValue, value]);
|
|
21
|
+
return (_jsx(TabsContext.Provider, { value: contextValue, children: _jsx(TabsPrimitive.Root, { ref: ref, value: value, onValueChange: setValue, className: cn(className), ...props, children: children }) }));
|
|
30
22
|
});
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
TabsRoot.displayName = TabsPrimitive.Root.displayName;
|
|
24
|
+
const TabsList = React.forwardRef(({ className, ...props }, ref) => (_jsx(TabsPrimitive.List, { ref: ref, className: cn("inline-flex h-fit items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground", className), ...props })));
|
|
25
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
26
|
+
const TabsTrigger = React.forwardRef(({ className, value, ...props }, ref) => (_jsx(TabsPrimitive.Trigger, { ref: ref, value: value, className: cn("inline-flex cursor-pointer items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm", className), ...props })));
|
|
27
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
28
|
+
const TabsContent = React.forwardRef(({ className, value, ...props }, ref) => (_jsx(TabsPrimitive.Content, { ref: ref, value: value, className: cn("focus-visible:outline-none", className), ...props })));
|
|
29
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
30
|
+
function Tabs({ items, defaultValue, value, onValueChange, className, listClassName, triggerClassName, panelClassName, ...props }) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const fallbackValue = (_b = defaultValue !== null && defaultValue !== void 0 ? defaultValue : (_a = items[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "";
|
|
33
|
+
if (!items.length) {
|
|
38
34
|
return null;
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
35
|
+
}
|
|
36
|
+
return (_jsxs(TabsRoot, { defaultValue: fallbackValue, value: value, onValueChange: onValueChange, className: cn("space-y-4", className), ...props, children: [_jsx(TabsList, { className: listClassName, children: items.map((item) => (_jsx(TabsTrigger, { value: item.value, disabled: item.disabled, className: triggerClassName, children: item.label }, item.value))) }), items.map((item) => (_jsx(TabsContent, { value: item.value, className: cn("rounded-md border p-4", panelClassName), children: item.content }, item.value)))] }));
|
|
37
|
+
}
|
|
38
|
+
export { Tabs, TabsRoot, TabsList, TabsTrigger, TabsContent };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import animate from "tailwindcss-animate";
|
|
2
|
+
export const neaDesignSystemContent = [
|
|
3
|
+
"./node_modules/@neasg/design-system/dist/**/*.js",
|
|
4
|
+
];
|
|
5
|
+
export const neaTailwindPreset = {
|
|
6
|
+
darkMode: ["class"],
|
|
7
|
+
theme: {
|
|
8
|
+
container: {
|
|
9
|
+
center: true,
|
|
10
|
+
padding: "2rem",
|
|
11
|
+
screens: {
|
|
12
|
+
"2xl": "1400px",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
extend: {
|
|
16
|
+
colors: {
|
|
17
|
+
border: "hsl(var(--border))",
|
|
18
|
+
input: "hsl(var(--input))",
|
|
19
|
+
ring: "hsl(var(--ring))",
|
|
20
|
+
background: "hsl(var(--background))",
|
|
21
|
+
foreground: "hsl(var(--foreground))",
|
|
22
|
+
primary: {
|
|
23
|
+
DEFAULT: "hsl(var(--primary))",
|
|
24
|
+
foreground: "hsl(var(--primary-foreground))",
|
|
25
|
+
},
|
|
26
|
+
secondary: {
|
|
27
|
+
DEFAULT: "hsl(var(--secondary))",
|
|
28
|
+
foreground: "hsl(var(--secondary-foreground))",
|
|
29
|
+
},
|
|
30
|
+
destructive: {
|
|
31
|
+
DEFAULT: "hsl(var(--destructive))",
|
|
32
|
+
foreground: "hsl(var(--destructive-foreground))",
|
|
33
|
+
},
|
|
34
|
+
muted: {
|
|
35
|
+
DEFAULT: "hsl(var(--muted))",
|
|
36
|
+
foreground: "hsl(var(--muted-foreground))",
|
|
37
|
+
},
|
|
38
|
+
accent: {
|
|
39
|
+
DEFAULT: "hsl(var(--accent))",
|
|
40
|
+
foreground: "hsl(var(--accent-foreground))",
|
|
41
|
+
},
|
|
42
|
+
popover: {
|
|
43
|
+
DEFAULT: "hsl(var(--popover))",
|
|
44
|
+
foreground: "hsl(var(--popover-foreground))",
|
|
45
|
+
},
|
|
46
|
+
card: {
|
|
47
|
+
DEFAULT: "hsl(var(--card))",
|
|
48
|
+
foreground: "hsl(var(--card-foreground))",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
borderRadius: {
|
|
52
|
+
lg: "var(--radius-lg)",
|
|
53
|
+
md: "var(--radius-md)",
|
|
54
|
+
sm: "var(--radius-sm)",
|
|
55
|
+
xl: "var(--radius-xl)",
|
|
56
|
+
},
|
|
57
|
+
fontFamily: {
|
|
58
|
+
sans: ["var(--font-sans)"],
|
|
59
|
+
mono: ["var(--font-mono)"],
|
|
60
|
+
},
|
|
61
|
+
fontWeight: {
|
|
62
|
+
normal: "var(--font-weight-regular)",
|
|
63
|
+
medium: "var(--font-weight-medium)",
|
|
64
|
+
semibold: "var(--font-weight-semibold)",
|
|
65
|
+
bold: "var(--font-weight-bold)",
|
|
66
|
+
},
|
|
67
|
+
spacing: {
|
|
68
|
+
0: "var(--space-0)",
|
|
69
|
+
1: "var(--space-1)",
|
|
70
|
+
2: "var(--space-2)",
|
|
71
|
+
3: "var(--space-3)",
|
|
72
|
+
4: "var(--space-4)",
|
|
73
|
+
5: "var(--space-5)",
|
|
74
|
+
6: "var(--space-6)",
|
|
75
|
+
8: "var(--space-8)",
|
|
76
|
+
10: "var(--space-10)",
|
|
77
|
+
12: "var(--space-12)",
|
|
78
|
+
},
|
|
79
|
+
keyframes: {
|
|
80
|
+
"accordion-down": {
|
|
81
|
+
from: { height: "0" },
|
|
82
|
+
to: { height: "var(--radix-accordion-content-height)" },
|
|
83
|
+
},
|
|
84
|
+
"accordion-up": {
|
|
85
|
+
from: { height: "var(--radix-accordion-content-height)" },
|
|
86
|
+
to: { height: "0" },
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
animation: {
|
|
90
|
+
"accordion-down": "accordion-down 0.2s ease-out",
|
|
91
|
+
"accordion-up": "accordion-up 0.2s ease-out",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
plugins: [animate],
|
|
96
|
+
};
|
|
97
|
+
export default neaTailwindPreset;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare const TextareaControl: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
|
|
3
|
+
export interface TextareaProps extends Omit<React.ComponentProps<typeof TextareaControl>, "className"> {
|
|
4
|
+
label: React.ReactNode;
|
|
5
|
+
description?: React.ReactNode;
|
|
6
|
+
error?: React.ReactNode;
|
|
7
|
+
invalid?: boolean;
|
|
8
|
+
hideLabel?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
textareaClassName?: string;
|
|
11
|
+
labelClassName?: string;
|
|
12
|
+
descriptionClassName?: string;
|
|
13
|
+
errorClassName?: string;
|
|
14
|
+
}
|
|
15
|
+
declare const Textarea: React.ForwardRefExoticComponent<Omit<TextareaProps, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
|
|
16
|
+
export { Textarea };
|
package/dist/textarea.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "./field";
|
|
4
|
+
import { cn } from "./lib/utils";
|
|
5
|
+
const TextareaControl = React.forwardRef(({ className, ...props }, ref) => (_jsx("textarea", { ref: ref, "data-slot": "textarea", className: cn("flex min-h-20 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/20 md:text-sm", className), ...props })));
|
|
6
|
+
TextareaControl.displayName = "TextareaControl";
|
|
7
|
+
const Textarea = React.forwardRef(({ label, description, error, invalid = false, hideLabel = false, className, textareaClassName, labelClassName, descriptionClassName, errorClassName, id, disabled, "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedBy, ...props }, ref) => {
|
|
8
|
+
const generatedId = React.useId();
|
|
9
|
+
const textareaId = id !== null && id !== void 0 ? id : `textarea-${generatedId}`;
|
|
10
|
+
const errorId = error ? `${textareaId}-error` : undefined;
|
|
11
|
+
const showDescription = Boolean(description) && !error;
|
|
12
|
+
const descriptionId = showDescription ? `${textareaId}-description` : undefined;
|
|
13
|
+
const isInvalid = invalid ||
|
|
14
|
+
ariaInvalid === true ||
|
|
15
|
+
ariaInvalid === "true" ||
|
|
16
|
+
Boolean(error);
|
|
17
|
+
const describedBy = [ariaDescribedBy, descriptionId, errorId]
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
.join(" ") || undefined;
|
|
20
|
+
return (_jsxs(Field, { className: className, "data-disabled": disabled ? "true" : undefined, "data-invalid": isInvalid ? "true" : undefined, children: [_jsx(FieldLabel, { htmlFor: textareaId, className: cn(hideLabel && "sr-only", labelClassName), children: label }), _jsx(TextareaControl, { ref: ref, id: textareaId, disabled: disabled, "aria-invalid": isInvalid ? "true" : undefined, "aria-describedby": describedBy, className: textareaClassName, ...props }), showDescription ? (_jsx(FieldDescription, { id: descriptionId, className: descriptionClassName, children: description })) : null, _jsx(FieldError, { id: errorId, className: errorClassName, children: error })] }));
|
|
21
|
+
});
|
|
22
|
+
Textarea.displayName = "Textarea";
|
|
23
|
+
export { Textarea };
|