@ldkj/web-ui 0.10.0 → 0.11.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.
@@ -0,0 +1,2 @@
1
+ import type { TableComponent } from "./types";
2
+ export declare const Table: TableComponent;
@@ -0,0 +1,3 @@
1
+ import type { TableSize, TableVariant } from "./types";
2
+ export declare const sizeCellClass: Record<TableSize, string>;
3
+ export declare const variantRootClass: Record<TableVariant, string>;
@@ -0,0 +1,2 @@
1
+ export * from "./Table";
2
+ export * from "./types";
@@ -0,0 +1,8 @@
1
+ import { type BoxProps } from "@/components/layout/box";
2
+ import type { TableColumnProps } from "./types";
3
+ export declare function TableColumnDeclaration<RecordType extends object = Record<string, unknown>>(_: TableColumnProps<RecordType>): null;
4
+ export declare function TableHead(props: BoxProps<"thead">): import("react/jsx-runtime").JSX.Element;
5
+ export declare function TableBody(props: BoxProps<"tbody">): import("react/jsx-runtime").JSX.Element;
6
+ export declare function TableRow(props: BoxProps<"tr">): import("react/jsx-runtime").JSX.Element;
7
+ export declare function TableHeaderCell(props: BoxProps<"th">): import("react/jsx-runtime").JSX.Element;
8
+ export declare function TableCell(props: BoxProps<"td">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import * as React from "react";
2
+ import type { TableColumn, TableProps, TableSize } from "./types";
3
+ export type TableRowMeta<RecordType extends object> = {
4
+ record: RecordType;
5
+ index: number;
6
+ absoluteIndex: number;
7
+ key: React.Key;
8
+ disabled: boolean;
9
+ };
10
+ export type TableHeaderRowsProps<RecordType extends object = Record<string, unknown>> = {
11
+ selectionEnabled: boolean;
12
+ size: TableSize;
13
+ allChecked: boolean;
14
+ partiallyChecked: boolean;
15
+ selectableKeysLength: number;
16
+ onToggleCurrentPage: (checked: boolean) => void;
17
+ indexColumn: TableProps<RecordType>["indexColumn"];
18
+ visibleColumns: TableColumn<RecordType>[];
19
+ };
20
+ export declare function TableHeaderRows<RecordType extends object = Record<string, unknown>>(props: TableHeaderRowsProps<RecordType>): import("react/jsx-runtime").JSX.Element;
21
+ export type TableBodyRowsProps<RecordType extends object = Record<string, unknown>> = {
22
+ bodyProps?: TableProps<RecordType>["bodyProps"];
23
+ currentRowMeta: TableRowMeta<RecordType>[];
24
+ selectedSet: Set<React.Key>;
25
+ rowProps?: TableProps<RecordType>["rowProps"];
26
+ size: TableSize;
27
+ striped: boolean;
28
+ hoverable: boolean;
29
+ selectionEnabled: boolean;
30
+ onToggleRow: (key: React.Key, checked: boolean) => void;
31
+ indexColumn: TableProps<RecordType>["indexColumn"];
32
+ visibleColumns: TableColumn<RecordType>[];
33
+ empty: React.ReactNode;
34
+ tableColumnCount: number;
35
+ };
36
+ export declare function TableBodyRows<RecordType extends object = Record<string, unknown>>(props: TableBodyRowsProps<RecordType>): import("react/jsx-runtime").JSX.Element;
37
+ export type TablePaginationFooterProps = {
38
+ pageCount: number;
39
+ currentPage: number;
40
+ justifyClassName: string;
41
+ onPageChange: (event: React.MouseEvent<HTMLAnchorElement>, page: number) => void;
42
+ };
43
+ export declare function TablePaginationFooter(props: TablePaginationFooterProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,73 @@
1
+ import * as React from "react";
2
+ import type { BoxProps } from "@/components/layout/box";
3
+ import type { SxProps } from "@/styling";
4
+ import type { TableBody, TableCell, TableColumnDeclaration, TableHead, TableHeaderCell, TableRow } from "./parts";
5
+ export type TableAlign = "left" | "center" | "right";
6
+ export type TableSize = "sm" | "md" | "lg";
7
+ export type TableVariant = "outlined" | "filled" | "ghost";
8
+ export type TableColumn<RecordType extends object = Record<string, unknown>> = {
9
+ key?: React.Key;
10
+ dataIndex?: keyof RecordType | (string & {});
11
+ title?: React.ReactNode;
12
+ hidden?: boolean;
13
+ width?: number | string;
14
+ align?: TableAlign;
15
+ headerAlign?: TableAlign;
16
+ className?: string;
17
+ headerClassName?: string;
18
+ sx?: SxProps;
19
+ headerSx?: SxProps;
20
+ render?: (value: unknown, record: RecordType, index: number) => React.ReactNode;
21
+ };
22
+ export type TableColumnProps<RecordType extends object = Record<string, unknown>> = TableColumn<RecordType>;
23
+ export type TableRowSelection<RecordType extends object = Record<string, unknown>> = {
24
+ selectedRowKeys?: React.Key[];
25
+ defaultSelectedRowKeys?: React.Key[];
26
+ onChange?: (selectedRowKeys: React.Key[], selectedRows: RecordType[]) => void;
27
+ getCheckboxProps?: (record: RecordType, index: number) => {
28
+ disabled?: boolean;
29
+ };
30
+ };
31
+ export type TablePaginationConfig = {
32
+ page?: number;
33
+ defaultPage?: number;
34
+ pageSize?: number;
35
+ total?: number;
36
+ onPageChange?: (page: number, pageSize: number) => void;
37
+ position?: "left" | "center" | "right";
38
+ };
39
+ export type TableRowProps<RecordType extends object> = BoxProps<"tr"> | ((record: RecordType, index: number) => BoxProps<"tr">);
40
+ export type TableProps<RecordType extends object = Record<string, unknown>> = Omit<BoxProps<"div">, "children"> & {
41
+ columns?: TableColumn<RecordType>[];
42
+ dataSource?: RecordType[];
43
+ rowKey?: keyof RecordType | (string & {}) | ((record: RecordType, index: number) => React.Key);
44
+ size?: TableSize;
45
+ variant?: TableVariant;
46
+ striped?: boolean;
47
+ bordered?: boolean;
48
+ hoverable?: boolean;
49
+ stickyHeader?: boolean;
50
+ loading?: boolean;
51
+ empty?: React.ReactNode;
52
+ caption?: React.ReactNode;
53
+ indexColumn?: boolean | {
54
+ title?: React.ReactNode;
55
+ width?: number | string;
56
+ };
57
+ rowSelection?: TableRowSelection<RecordType>;
58
+ pagination?: false | TablePaginationConfig;
59
+ tableProps?: BoxProps<"table">;
60
+ headProps?: BoxProps<"thead">;
61
+ bodyProps?: BoxProps<"tbody">;
62
+ rowProps?: TableRowProps<RecordType>;
63
+ children?: React.ReactNode;
64
+ };
65
+ export type TableCompound = {
66
+ Column: typeof TableColumnDeclaration;
67
+ Head: typeof TableHead;
68
+ Body: typeof TableBody;
69
+ Row: typeof TableRow;
70
+ Cell: typeof TableCell;
71
+ HeaderCell: typeof TableHeaderCell;
72
+ };
73
+ export type TableComponent = (<RecordType extends object = Record<string, unknown>>(props: TableProps<RecordType>) => React.ReactElement) & TableCompound;
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ import type { TableColumn, TableProps } from "./types";
3
+ export declare function normalizeCssSize(value: number | string | undefined): string | undefined;
4
+ export declare function getValue<RecordType extends object>(record: RecordType, dataIndex: TableColumn<RecordType>["dataIndex"]): unknown;
5
+ export declare function getColumnKey<RecordType extends object>(column: TableColumn<RecordType>, index: number): React.Key;
6
+ export declare function getRowKey<RecordType extends object>(record: RecordType, index: number, rowKey: TableProps<RecordType>["rowKey"]): React.Key;
7
+ export declare function getAutoColumns<RecordType extends object>(dataSource: RecordType[]): TableColumn<RecordType>[];
8
+ export declare function resolveChildrenColumns<RecordType extends object>(children: React.ReactNode): {
9
+ childColumns: TableColumn<RecordType>[];
10
+ restChildren: React.ReactNode[];
11
+ };
12
+ export declare function useControllableKeys(props: {
13
+ selectedRowKeys?: React.Key[];
14
+ defaultSelectedRowKeys?: React.Key[];
15
+ }): {
16
+ selectedKeys: React.Key[];
17
+ setSelectedKeys: React.Dispatch<React.SetStateAction<React.Key[]>>;
18
+ isControlled: boolean;
19
+ };
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
3
+ import { type SxProps } from "@/styling";
4
+ export type CheckboxProps = React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> & {
5
+ class?: string;
6
+ sx?: SxProps;
7
+ };
8
+ /**
9
+ * 基于 Radix Checkbox 的复选框组件,支持本库 `sx` 样式系统。
10
+ */
11
+ declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxPrimitive.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & {
12
+ class?: string;
13
+ sx?: SxProps;
14
+ } & React.RefAttributes<HTMLButtonElement>>;
15
+ export { Checkbox };
@@ -0,0 +1 @@
1
+ export * from "./Checkbox";
@@ -0,0 +1 @@
1
+ export * from "./pagination";
@@ -0,0 +1,72 @@
1
+ import * as React from "react";
2
+ import { type ButtonProps } from "@/components/interact/button";
3
+ import { type SxProps } from "@/styling";
4
+ type StyledProps = {
5
+ className?: string;
6
+ class?: string;
7
+ style?: React.CSSProperties;
8
+ sx?: SxProps;
9
+ };
10
+ export type PaginationVariant = "outline" | "filled";
11
+ type PaginationGeneratedItem = {
12
+ type: "page";
13
+ page: number;
14
+ selected: boolean;
15
+ disabled: boolean;
16
+ } | {
17
+ type: "previous" | "next";
18
+ page: number;
19
+ selected: false;
20
+ disabled: boolean;
21
+ } | {
22
+ type: "ellipsis";
23
+ page: null;
24
+ selected: false;
25
+ disabled: true;
26
+ };
27
+ export type PaginationRenderItem = PaginationGeneratedItem & {
28
+ href?: string;
29
+ onClick?: React.MouseEventHandler<HTMLAnchorElement>;
30
+ };
31
+ export type PaginationProps = React.ComponentPropsWithoutRef<"nav"> & StyledProps & {
32
+ count?: number;
33
+ page?: number;
34
+ defaultPage?: number;
35
+ onPageChange?: (event: React.MouseEvent<HTMLAnchorElement>, page: number) => void;
36
+ siblingCount?: number;
37
+ boundaryCount?: number;
38
+ variant?: PaginationVariant;
39
+ showPreviousNext?: boolean;
40
+ disabled?: boolean;
41
+ getItemHref?: (page: number, type: PaginationGeneratedItem["type"]) => string;
42
+ renderItem?: (item: PaginationRenderItem) => React.ReactNode;
43
+ contentProps?: React.ComponentProps<typeof PaginationContent>;
44
+ };
45
+ declare const Pagination: {
46
+ ({ count, page: pageProp, defaultPage, onPageChange, siblingCount, boundaryCount, variant, showPreviousNext, disabled, getItemHref, renderItem, contentProps, className, class: legacyClass, sx, style, children, ...props }: PaginationProps): import("react/jsx-runtime").JSX.Element;
47
+ displayName: string;
48
+ };
49
+ declare const PaginationContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & StyledProps & React.RefAttributes<HTMLUListElement>>;
50
+ declare const PaginationItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & StyledProps & React.RefAttributes<HTMLLIElement>>;
51
+ type PaginationLinkProps = {
52
+ isActive?: boolean;
53
+ disabled?: boolean;
54
+ variant?: PaginationVariant;
55
+ } & Omit<ButtonProps<"a">, "component" | "variant" | "disabled">;
56
+ declare const PaginationLink: {
57
+ ({ className, class: legacyClass, isActive, disabled, variant, size, tabIndex, ...props }: PaginationLinkProps): import("react/jsx-runtime").JSX.Element;
58
+ displayName: string;
59
+ };
60
+ declare const PaginationPrevious: {
61
+ ({ className, children, ...props }: React.ComponentProps<typeof PaginationLink>): import("react/jsx-runtime").JSX.Element;
62
+ displayName: string;
63
+ };
64
+ declare const PaginationNext: {
65
+ ({ className, children, ...props }: React.ComponentProps<typeof PaginationLink>): import("react/jsx-runtime").JSX.Element;
66
+ displayName: string;
67
+ };
68
+ declare const PaginationEllipsis: {
69
+ ({ className, class: legacyClass, sx, style, ...props }: React.ComponentPropsWithoutRef<"span"> & StyledProps): import("react/jsx-runtime").JSX.Element;
70
+ displayName: string;
71
+ };
72
+ export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, };