@ldkj/web-ui 0.2.1 → 0.3.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/README.md +27 -23
- package/components/layout/divider/Divider.d.ts +16 -0
- package/components/layout/divider/index.d.ts +1 -0
- package/components/layout/flex/Flex.d.ts +28 -0
- package/components/layout/flex/index.d.ts +1 -0
- package/components/layout/grid/Grid.d.ts +26 -0
- package/components/layout/grid/index.d.ts +1 -0
- package/components/layout/safe-area/SafeArea.d.ts +38 -0
- package/components/layout/safe-area/index.d.ts +1 -0
- package/components/ui/button/Button.d.ts +7 -2
- package/components/ui/button/variants.d.ts +4 -0
- package/components/ui/chip/Chip.d.ts +7 -2
- package/components/ui/chip/variants.d.ts +4 -0
- package/components/ui/qrcodes/QRCode.d.ts +16 -0
- package/components/ui/qrcodes/QRCodeBase.d.ts +32 -0
- package/components/ui/qrcodes/QRCodeCanvas.d.ts +39 -0
- package/components/ui/qrcodes/QRCodeSizable.d.ts +40 -0
- package/components/ui/qrcodes/index.d.ts +7 -0
- package/components/ui/shared/rounded.d.ts +15 -0
- package/index.cjs +8 -1
- package/index.d.ts +6 -0
- package/index.js +3794 -631
- package/lib/CSSUnitConverter.d.ts +47 -0
- package/lib/utils.d.ts +1 -0
- package/package.json +11 -1
- package/style.css +1 -1
- package/styling/SxProvider.d.ts +9 -0
- package/styling/index.d.ts +2 -0
- package/styling/sx.d.ts +13 -0
package/README.md
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
# @ldkj/web-ui
|
|
2
|
-
|
|
3
|
-
由 shadcn-ui, Tailwind CSS 和 VitePress 构建的 React 组件库.
|
|
4
|
-
|
|
5
|
-
## 立即开始
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## 使用示例
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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,16 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type SxProps } from "@/styling";
|
|
3
|
+
export type DividerVariant = "full" | "middle" | "inset";
|
|
4
|
+
export type DividerAlign = "center" | "left" | "right";
|
|
5
|
+
export type DividerProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
6
|
+
vertical?: boolean;
|
|
7
|
+
variant?: DividerVariant;
|
|
8
|
+
align?: DividerAlign;
|
|
9
|
+
type?: React.CSSProperties["borderStyle"];
|
|
10
|
+
color?: string;
|
|
11
|
+
sx?: SxProps;
|
|
12
|
+
};
|
|
13
|
+
export declare function Divider(props: DividerProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare namespace Divider {
|
|
15
|
+
var displayName: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Divider";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type SxProps } from "@/styling";
|
|
3
|
+
export type FlexDirection = "row" | "row-reverse" | "col" | "col-reverse";
|
|
4
|
+
export type FlexWrap = boolean | React.CSSProperties["flexWrap"];
|
|
5
|
+
export type FlexGapPreset = "xs" | "sm" | "md" | "lg" | "xl";
|
|
6
|
+
export type FlexGap = FlexGapPreset | number | string;
|
|
7
|
+
export type FlexSize = number | string;
|
|
8
|
+
/**
|
|
9
|
+
* Flex 容器属性。
|
|
10
|
+
*/
|
|
11
|
+
export type FlexProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
12
|
+
direction?: FlexDirection;
|
|
13
|
+
justify?: React.CSSProperties["justifyContent"];
|
|
14
|
+
items?: React.CSSProperties["alignItems"];
|
|
15
|
+
flex?: React.CSSProperties["flex"];
|
|
16
|
+
wrap?: FlexWrap;
|
|
17
|
+
gap?: FlexGap;
|
|
18
|
+
width?: FlexSize;
|
|
19
|
+
height?: FlexSize;
|
|
20
|
+
sx?: SxProps;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Flex 是基于 CSS Flexbox 的对齐布局容器。
|
|
24
|
+
*/
|
|
25
|
+
export declare function Flex(props: FlexProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare namespace Flex {
|
|
27
|
+
var displayName: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Flex";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type SxProps } from "@/styling";
|
|
3
|
+
export type GridSize = number | "grow";
|
|
4
|
+
export type GridOffset = number | "auto";
|
|
5
|
+
export type GridSpacing = number | string;
|
|
6
|
+
export type GridDirection = "row" | "row-reverse";
|
|
7
|
+
export type GridWrap = boolean | React.CSSProperties["flexWrap"];
|
|
8
|
+
export type GridProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
9
|
+
container?: boolean;
|
|
10
|
+
size?: GridSize;
|
|
11
|
+
offset?: GridOffset;
|
|
12
|
+
columns?: number;
|
|
13
|
+
spacing?: GridSpacing;
|
|
14
|
+
rowSpacing?: GridSpacing;
|
|
15
|
+
columnSpacing?: GridSpacing;
|
|
16
|
+
wrap?: GridWrap;
|
|
17
|
+
direction?: GridDirection;
|
|
18
|
+
sx?: SxProps;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Grid 是基于 Flexbox 的 12 列布局容器。
|
|
22
|
+
*/
|
|
23
|
+
export declare function Grid(props: GridProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare namespace Grid {
|
|
25
|
+
var displayName: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Grid";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ElementType } from "react";
|
|
3
|
+
import { type SxProps } from "@/styling";
|
|
4
|
+
export type SafeAreaPosition = "top" | "bottom" | "both" | "none";
|
|
5
|
+
type PolymorphicProps<T extends ElementType> = {
|
|
6
|
+
component?: T;
|
|
7
|
+
className?: string;
|
|
8
|
+
} & Omit<React.ComponentPropsWithoutRef<T>, "as" | "className">;
|
|
9
|
+
type SafeAreaOwnProps = {
|
|
10
|
+
position?: SafeAreaPosition;
|
|
11
|
+
horizontal?: boolean;
|
|
12
|
+
sx?: SxProps;
|
|
13
|
+
};
|
|
14
|
+
export type SafeAreaProps<T extends ElementType = "div"> = PolymorphicProps<T> & SafeAreaOwnProps;
|
|
15
|
+
/**
|
|
16
|
+
* SafeArea 用于适配移动端刘海屏,灵动岛和手势区域等的安全区容器。
|
|
17
|
+
*/
|
|
18
|
+
export declare function SafeArea<T extends ElementType = "div">(props: SafeAreaProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare namespace SafeArea {
|
|
20
|
+
var displayName: string;
|
|
21
|
+
}
|
|
22
|
+
export type SafeAreaTopProps = Omit<SafeAreaProps<ElementType>, "position">;
|
|
23
|
+
export type SafeAreaBottomProps = Omit<SafeAreaProps<ElementType>, "position">;
|
|
24
|
+
/**
|
|
25
|
+
* SafeAreaTop 仅应用顶部安全区内边距。
|
|
26
|
+
*/
|
|
27
|
+
export declare function SafeAreaTop(props: SafeAreaTopProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare namespace SafeAreaTop {
|
|
29
|
+
var displayName: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* SafeAreaBottom 仅应用底部安全区内边距。
|
|
33
|
+
*/
|
|
34
|
+
export declare function SafeAreaBottom(props: SafeAreaBottomProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare namespace SafeAreaBottom {
|
|
36
|
+
var displayName: string;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SafeArea";
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { ElementType } from "react";
|
|
3
|
-
import { type ButtonVariants } from "./variants";
|
|
3
|
+
import { type ButtonRounded, type ButtonVariants } from "./variants";
|
|
4
|
+
import { type SxProps } from "@/styling";
|
|
4
5
|
type PolymorphicProps<T extends ElementType> = {
|
|
5
6
|
component?: T;
|
|
6
7
|
className?: string;
|
|
7
8
|
class?: string;
|
|
8
9
|
} & Omit<React.ComponentPropsWithoutRef<T>, "as" | "className">;
|
|
9
|
-
|
|
10
|
+
type ButtonOwnProps = Omit<ButtonVariants, "rounded"> & {
|
|
11
|
+
rounded?: ButtonRounded;
|
|
12
|
+
sx?: SxProps;
|
|
13
|
+
};
|
|
14
|
+
export type ButtonProps<T extends ElementType = "button"> = PolymorphicProps<T> & ButtonOwnProps;
|
|
10
15
|
export declare function Button<T extends ElementType = "button">(props: ButtonProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
11
16
|
export declare namespace Button {
|
|
12
17
|
var displayName: string;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import { type Rounded, type RoundedPreset } from "../shared/rounded";
|
|
2
3
|
export declare const buttonVariants: (props?: ({
|
|
3
4
|
variant?: "dark" | "primary" | "secondary" | "minor" | "success" | "warning" | "danger" | "outline" | "ghost" | "link" | "text" | null | undefined;
|
|
4
5
|
size?: "xs" | "sm" | "md" | "lg" | "xl" | "icon" | null | undefined;
|
|
6
|
+
rounded?: "xs" | "sm" | "md" | "lg" | "xl" | "full" | null | undefined;
|
|
5
7
|
bounce?: boolean | null | undefined;
|
|
6
8
|
splash?: boolean | null | undefined;
|
|
7
9
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
10
|
export type ButtonVariants = VariantProps<typeof buttonVariants>;
|
|
11
|
+
export type ButtonRoundedPreset = RoundedPreset;
|
|
12
|
+
export type ButtonRounded = Rounded;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { ElementType } from "react";
|
|
3
|
-
import { type ChipVariants } from "./variants";
|
|
3
|
+
import { type ChipRounded, type ChipVariants } from "./variants";
|
|
4
|
+
import { type SxProps } from "@/styling";
|
|
4
5
|
type PolymorphicProps<T extends ElementType> = {
|
|
5
6
|
component?: T;
|
|
6
7
|
className?: string;
|
|
7
8
|
class?: string;
|
|
8
9
|
} & Omit<React.ComponentPropsWithoutRef<T>, "as" | "className">;
|
|
9
|
-
|
|
10
|
+
type ChipOwnProps = Omit<ChipVariants, "rounded"> & {
|
|
11
|
+
rounded?: ChipRounded;
|
|
12
|
+
sx?: SxProps;
|
|
13
|
+
};
|
|
14
|
+
export type ChipProps<T extends ElementType = "span"> = PolymorphicProps<T> & ChipOwnProps;
|
|
10
15
|
export declare function Chip<T extends ElementType = "span">(props: ChipProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
11
16
|
export declare namespace Chip {
|
|
12
17
|
var displayName: string;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import { type Rounded, type RoundedPreset } from "../shared/rounded";
|
|
2
3
|
export declare const chipVariants: (props?: ({
|
|
3
4
|
variant?: "dark" | "primary" | "minor" | "success" | "warning" | "danger" | "text" | "light" | null | undefined;
|
|
4
5
|
outline?: boolean | null | undefined;
|
|
5
6
|
size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
7
|
+
rounded?: "xs" | "sm" | "md" | "lg" | "xl" | "full" | null | undefined;
|
|
6
8
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
9
|
export type ChipVariants = VariantProps<typeof chipVariants>;
|
|
10
|
+
export type ChipRoundedPreset = RoundedPreset;
|
|
11
|
+
export type ChipRounded = Rounded;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type QRCodeCanvasProps } from "./QRCodeCanvas";
|
|
2
|
+
import { type QRCodeSizableProps } from "./QRCodeSizable";
|
|
3
|
+
export type QRCodeProps = ({
|
|
4
|
+
canvas: true;
|
|
5
|
+
} & QRCodeCanvasProps) | ({
|
|
6
|
+
canvas?: false;
|
|
7
|
+
} & QRCodeSizableProps);
|
|
8
|
+
/**
|
|
9
|
+
* 渲染二维码组件
|
|
10
|
+
* - `canvas: true` -> QRCodeCanvas rendered with canvas
|
|
11
|
+
* - `canvas: false` -> QRCodeSizable rendered with image
|
|
12
|
+
* - `value: string` -> the value to be displayed in the QR code
|
|
13
|
+
* - `size: number|string` -> the size of the QR code
|
|
14
|
+
* - `fullWidth: boolean` -> whether to fill the parent container
|
|
15
|
+
*/
|
|
16
|
+
export default function QRCode({ canvas, ...props }: QRCodeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface QRCodeBaseProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
3
|
+
size?: number;
|
|
4
|
+
value: string;
|
|
5
|
+
useful?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* - 前景色
|
|
8
|
+
* - 默认:"#000000"
|
|
9
|
+
*/
|
|
10
|
+
foregroundColor?: string;
|
|
11
|
+
/**
|
|
12
|
+
* - 背景色
|
|
13
|
+
* - 默认:"#ffffff"
|
|
14
|
+
*/
|
|
15
|
+
backgroundColor?: string;
|
|
16
|
+
/**
|
|
17
|
+
* - 二维码四周的留白(单位是 px)
|
|
18
|
+
* - 默认:`0`
|
|
19
|
+
*/
|
|
20
|
+
margin?: number;
|
|
21
|
+
/**
|
|
22
|
+
* - 二维码识别容错率(部分区域被遮挡仍可识别)
|
|
23
|
+
* - `low`:7% 或更少
|
|
24
|
+
* - `medium`:15% 或更少
|
|
25
|
+
* - `quartile`:25% 或更少
|
|
26
|
+
* - `high`:30% 或更少,二维码中间放 logo 图像时推荐
|
|
27
|
+
*/
|
|
28
|
+
errorCorrectionLevel?: "low" | "medium" | "quartile" | "high";
|
|
29
|
+
unload?: React.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
declare const QRCodeBase: React.FC<QRCodeBaseProps>;
|
|
32
|
+
export default QRCodeBase;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type SxProps } from "@/styling";
|
|
3
|
+
export interface QRCodeCanvasProps extends React.HtmlHTMLAttributes<HTMLDivElement> {
|
|
4
|
+
value: string;
|
|
5
|
+
useful?: boolean;
|
|
6
|
+
uselessElem?: React.ReactNode;
|
|
7
|
+
uselessProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
8
|
+
/**
|
|
9
|
+
* - 前景色
|
|
10
|
+
* - 默认:"#000000"
|
|
11
|
+
*/
|
|
12
|
+
foregroundColor?: string;
|
|
13
|
+
/**
|
|
14
|
+
* - 背景色
|
|
15
|
+
* - 默认:"#ffffff"
|
|
16
|
+
*/
|
|
17
|
+
backgroundColor?: string;
|
|
18
|
+
/**
|
|
19
|
+
* - 二维码四周的留白(单位是 px)
|
|
20
|
+
* - 默认:`4`(qrcode 不设置 margin 默认值是 4)
|
|
21
|
+
*/
|
|
22
|
+
margin?: number;
|
|
23
|
+
/**
|
|
24
|
+
* - 二维码识别容错率(部分区域被遮挡仍可识别)
|
|
25
|
+
* - `low`:7% 或更少
|
|
26
|
+
* - `medium`:15% 或更少
|
|
27
|
+
* - `quartile`:25% 或更少
|
|
28
|
+
* - `high`:30% 或更少,二维码中间放 logo 图像时推荐
|
|
29
|
+
*/
|
|
30
|
+
errorCorrectionLevel?: "low" | "medium" | "quartile" | "high";
|
|
31
|
+
/**
|
|
32
|
+
* - 二维码尺寸
|
|
33
|
+
* - 默认:`200`
|
|
34
|
+
*/
|
|
35
|
+
size?: number | string;
|
|
36
|
+
fullWidth?: boolean;
|
|
37
|
+
sx?: SxProps;
|
|
38
|
+
}
|
|
39
|
+
export declare const QRCodeCanvas: React.FC<QRCodeCanvasProps>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type SxProps } from "@/styling";
|
|
3
|
+
export interface QRCodeSizableProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
4
|
+
/**
|
|
5
|
+
* - 二维码尺寸
|
|
6
|
+
* - 默认:`200`
|
|
7
|
+
*/
|
|
8
|
+
size?: number | string;
|
|
9
|
+
value: string;
|
|
10
|
+
useful?: boolean;
|
|
11
|
+
uselessElem?: React.ReactNode;
|
|
12
|
+
uselessProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
13
|
+
/**
|
|
14
|
+
* - 前景色
|
|
15
|
+
* - 默认:"#000000"
|
|
16
|
+
*/
|
|
17
|
+
foregroundColor?: string;
|
|
18
|
+
/**
|
|
19
|
+
* - 背景色
|
|
20
|
+
* - 默认:"#ffffff"
|
|
21
|
+
*/
|
|
22
|
+
backgroundColor?: string;
|
|
23
|
+
/**
|
|
24
|
+
* - 二维码四周的留白(单位是 px)
|
|
25
|
+
* - 默认:`4`(qrcode 不设置 margin 默认值是 4)
|
|
26
|
+
*/
|
|
27
|
+
margin?: number;
|
|
28
|
+
/**
|
|
29
|
+
* - 二维码识别容错率(部分区域被遮挡仍可识别)
|
|
30
|
+
* - `low`:7% 或更少
|
|
31
|
+
* - `medium`:15% 或更少
|
|
32
|
+
* - `quartile`:25% 或更少
|
|
33
|
+
* - `high`:30% 或更少,二维码中间放 logo 图像时推荐
|
|
34
|
+
*/
|
|
35
|
+
errorCorrectionLevel?: "low" | "medium" | "quartile" | "high";
|
|
36
|
+
unload?: React.ReactNode;
|
|
37
|
+
fullWidth?: boolean;
|
|
38
|
+
sx?: SxProps;
|
|
39
|
+
}
|
|
40
|
+
export declare const QRCodeSizable: React.FC<QRCodeSizableProps>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as QRCode } from "./QRCode";
|
|
2
|
+
export type { QRCodeProps } from "./QRCode";
|
|
3
|
+
export { QRCodeCanvas } from "./QRCodeCanvas";
|
|
4
|
+
export type { QRCodeCanvasProps } from "./QRCodeCanvas";
|
|
5
|
+
export { QRCodeSizable } from "./QRCodeSizable";
|
|
6
|
+
export type { QRCodeSizableProps } from "./QRCodeSizable";
|
|
7
|
+
export { default as QRCodeBase } from "./QRCodeBase";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
export declare const roundedPresetClasses: {
|
|
3
|
+
readonly xs: "rounded-[2px]";
|
|
4
|
+
readonly sm: "rounded-sm";
|
|
5
|
+
readonly md: "rounded-md";
|
|
6
|
+
readonly lg: "rounded-lg";
|
|
7
|
+
readonly xl: "rounded-xl";
|
|
8
|
+
readonly full: "rounded-full";
|
|
9
|
+
};
|
|
10
|
+
export type RoundedPreset = keyof typeof roundedPresetClasses;
|
|
11
|
+
export type Rounded = RoundedPreset | number | string;
|
|
12
|
+
export declare function resolveRounded(rounded?: Rounded): {
|
|
13
|
+
roundedPreset?: RoundedPreset;
|
|
14
|
+
roundedStyle?: CSSProperties;
|
|
15
|
+
};
|