@ldkj/web-ui 0.8.2 → 0.10.0

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 ldkj
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ldkj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,27 +1,27 @@
1
- # @ldkj/web-ui
2
-
3
- 由 shadcn-ui, Tailwind CSS 和 VitePress 构建的 React 组件库.
4
-
5
- ## 立即开始
6
-
7
- ```bash
8
- pnpm add @ldkj/web-ui
9
- ```
10
-
11
- ## 使用示例
12
-
13
- ```tsx
14
- import "@ldkj/web-ui/style.css";
15
- import { Button, Chip } from "@ldkj/web-ui";
16
-
17
- export default function App() {
18
- return (
19
- <div className="p-4">
20
- <Button variant="primary">Hello World</Button>
21
- <Chip variant="success" size="sm">
22
- Ready
23
- </Chip>
24
- </div>
25
- );
26
- }
27
- ```
1
+ # @ldkj/web-ui
2
+
3
+ 由 shadcn-ui, Tailwind CSS 和 VitePress 构建的 React 组件库.
4
+
5
+ ## 立即开始
6
+
7
+ ```bash
8
+ pnpm add @ldkj/web-ui
9
+ ```
10
+
11
+ ## 使用示例
12
+
13
+ ```tsx
14
+ import "@ldkj/web-ui/style.css";
15
+ import { Button, Chip } from "@ldkj/web-ui";
16
+
17
+ export default function App() {
18
+ return (
19
+ <div className="p-4">
20
+ <Button variant="primary">Hello World</Button>
21
+ <Chip variant="success" size="sm">
22
+ Ready
23
+ </Chip>
24
+ </div>
25
+ );
26
+ }
27
+ ```
@@ -0,0 +1,121 @@
1
+ import * as React from "react";
2
+ import type { CSSProperties, ElementType, ReactElement } from "react";
3
+ import { type IconProps } from "@/components/data-display/icon";
4
+ import { type BoxProps } from "@/components/layout/box";
5
+ import { type SxProps } from "@/styling";
6
+ type MenuKey = string;
7
+ type StyledProps = {
8
+ className?: string;
9
+ class?: string;
10
+ style?: CSSProperties;
11
+ sx?: SxProps;
12
+ };
13
+ type MenuChangeInfo = {
14
+ key: MenuKey;
15
+ keys: MenuKey[];
16
+ };
17
+ export type MenuItemColors = {
18
+ itemText?: string;
19
+ itemBackground?: string;
20
+ itemHoverText?: string;
21
+ itemHoverBackground?: string;
22
+ itemSelectedText?: string;
23
+ itemSelectedBackground?: string;
24
+ itemSelectedHoverText?: string;
25
+ itemDisabledText?: string;
26
+ };
27
+ export type MenuRef = {
28
+ select: (key: MenuKey) => void;
29
+ unselect: (key: MenuKey) => void;
30
+ open: (key: MenuKey) => void;
31
+ close: (key: MenuKey) => void;
32
+ toggleOpen: (key: MenuKey) => void;
33
+ getSelectedKeys: () => MenuKey[];
34
+ getOpenKeys: () => MenuKey[];
35
+ };
36
+ /**
37
+ * 创建 `Menu` 的命令式控制引用,适合配合 `menuRef` 属性使用。
38
+ */
39
+ export declare function useMenuRef(): React.RefObject<MenuRef>;
40
+ declare function MenuList(props: React.ComponentPropsWithoutRef<"ul"> & StyledProps): import("react/jsx-runtime").JSX.Element;
41
+ declare namespace MenuList {
42
+ var displayName: string;
43
+ }
44
+ export type MenuItemProps<T extends ElementType = "button"> = Omit<React.ComponentPropsWithoutRef<T>, "as" | "className" | "style" | "children" | "disabled" | "onClick"> & StyledProps & {
45
+ itemKey: MenuKey;
46
+ label?: React.ReactNode;
47
+ icon?: IconProps["name"];
48
+ iconProps?: Omit<IconProps, "name">;
49
+ href?: string;
50
+ component?: T;
51
+ disabled?: boolean;
52
+ selected?: boolean;
53
+ unselectOnClick?: boolean;
54
+ onClick?: React.MouseEventHandler<Element>;
55
+ onSelect?: (key: MenuKey) => void;
56
+ children?: React.ReactNode;
57
+ };
58
+ declare function MenuItem<T extends ElementType = "button">(props: MenuItemProps<T>): import("react/jsx-runtime").JSX.Element;
59
+ declare namespace MenuItem {
60
+ var displayName: string;
61
+ }
62
+ export type MenuSubProps = Omit<React.ComponentPropsWithoutRef<"li">, "className" | "style" | "children" | "title"> & StyledProps & {
63
+ itemKey: MenuKey;
64
+ label: React.ReactNode;
65
+ icon?: IconProps["name"];
66
+ iconProps?: Omit<IconProps, "name">;
67
+ disabled?: boolean;
68
+ children?: React.ReactNode;
69
+ };
70
+ declare function MenuSub(props: MenuSubProps): import("react/jsx-runtime").JSX.Element;
71
+ declare namespace MenuSub {
72
+ var displayName: string;
73
+ }
74
+ export type MenuGroupProps = Omit<React.ComponentPropsWithoutRef<"li">, "className" | "style" | "children" | "title"> & StyledProps & {
75
+ label?: React.ReactNode;
76
+ children?: React.ReactNode;
77
+ };
78
+ declare function MenuGroup(props: MenuGroupProps): import("react/jsx-runtime").JSX.Element;
79
+ declare namespace MenuGroup {
80
+ var displayName: string;
81
+ }
82
+ export type MenuItemConfig = {
83
+ key?: MenuKey;
84
+ label: React.ReactNode;
85
+ icon?: IconProps["name"];
86
+ iconProps?: Omit<IconProps, "name">;
87
+ href?: string;
88
+ disabled?: boolean;
89
+ children?: MenuItemConfig[];
90
+ type?: "item" | "sub" | "group";
91
+ unselectOnClick?: boolean;
92
+ itemProps?: Omit<MenuItemProps, "itemKey" | "label" | "icon" | "iconProps" | "href" | "disabled" | "children">;
93
+ subProps?: Omit<MenuSubProps, "itemKey" | "label" | "icon" | "iconProps" | "disabled" | "children">;
94
+ groupProps?: Omit<MenuGroupProps, "label" | "children">;
95
+ };
96
+ export type MenuProps<T extends ElementType = "nav"> = Omit<BoxProps<T>, "children"> & {
97
+ items?: MenuItemConfig[];
98
+ selectedKeys?: MenuKey[];
99
+ defaultSelectedKeys?: MenuKey[];
100
+ onSelectedKeysChange?: (keys: MenuKey[], info: MenuChangeInfo) => void;
101
+ openKeys?: MenuKey[];
102
+ defaultOpenKeys?: MenuKey[];
103
+ onOpenKeysChange?: (keys: MenuKey[], info: MenuChangeInfo) => void;
104
+ multiple?: boolean;
105
+ accordion?: boolean;
106
+ indent?: number;
107
+ itemGap?: number | string;
108
+ itemColors?: MenuItemColors;
109
+ menuRef?: React.Ref<MenuRef>;
110
+ children?: React.ReactNode;
111
+ listProps?: React.ComponentPropsWithoutRef<"ul"> & StyledProps;
112
+ };
113
+ type MenuCompound = {
114
+ Item: typeof MenuItem;
115
+ Sub: typeof MenuSub;
116
+ Group: typeof MenuGroup;
117
+ List: typeof MenuList;
118
+ };
119
+ type MenuComponent = (<T extends ElementType = "nav">(props: MenuProps<T>) => ReactElement | null) & MenuCompound;
120
+ export declare const Menu: MenuComponent;
121
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./Menu";
@@ -0,0 +1 @@
1
+ export * from "./tabs";
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ import * as TabsPrimitive from "@radix-ui/react-tabs";
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 TabsItemConfig = {
11
+ value: string;
12
+ label: React.ReactNode;
13
+ content?: React.ReactNode;
14
+ disabled?: boolean;
15
+ triggerProps?: Omit<TabsTriggerProps, "value" | "children" | "disabled">;
16
+ contentProps?: Omit<TabsContentProps, "value" | "children">;
17
+ };
18
+ export type TabsProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Root> & StyledProps & {
19
+ items?: TabsItemConfig[];
20
+ listProps?: TabsListProps;
21
+ };
22
+ export declare function Tabs(props: TabsProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare namespace Tabs {
24
+ var displayName: string;
25
+ }
26
+ export type TabsListProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> & StyledProps;
27
+ export declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> & StyledProps & React.RefAttributes<HTMLDivElement>>;
28
+ export type TabsTriggerProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger> & StyledProps;
29
+ export declare const TabsTrigger: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & StyledProps & React.RefAttributes<HTMLButtonElement>>;
30
+ export type TabsContentProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content> & StyledProps & {
31
+ borderless?: boolean;
32
+ };
33
+ export declare const TabsContent: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & StyledProps & {
34
+ borderless?: boolean;
35
+ } & React.RefAttributes<HTMLDivElement>>;
36
+ export {};