@ldkj/web-ui 0.15.0 → 0.16.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.
@@ -1,9 +1,74 @@
1
- export type RateProps = {
1
+ import * as React from "react";
2
+ import { type SxProps } from "@/styling";
3
+ export type RateSize = "sm" | "md" | "lg";
4
+ export type RateProps = Omit<React.ComponentPropsWithoutRef<"div">, "children" | "onChange"> & {
5
+ /** 受控评分值。 */
2
6
  value?: number;
7
+ /** 非受控默认评分值。 */
8
+ defaultValue?: number;
9
+ /** 星级总数,最小为 `1`。 */
3
10
  count?: number;
11
+ /** 是否允许再次点击当前值后清空。 */
12
+ allowClear?: boolean;
13
+ /** 是否移除外层边框与背景。 */
14
+ borderless?: boolean;
15
+ /** 是否禁用。 */
4
16
  disabled?: boolean;
17
+ /** 是否只读。只读时保留展示,不响应交互。 */
18
+ readOnly?: boolean;
19
+ /** 与原生表单联动的字段名。 */
20
+ name?: string;
21
+ /** 评分变更回调。 */
22
+ onChange?: (value: number) => void;
23
+ /** 鼠标悬停预览值变更回调。 */
24
+ onHoverChange?: (value: number | null) => void;
25
+ /** 星星尺寸。 */
26
+ size?: RateSize;
27
+ /** 评分图标。 */
28
+ character?: React.ReactNode;
29
+ /** 根节点类名。 */
5
30
  className?: string;
31
+ /** 兼容旧写法的类名。 */
6
32
  class?: string;
7
- onChange?: (value: number) => void;
33
+ /** 根节点样式。 */
34
+ style?: React.CSSProperties;
35
+ /** CSS-in-JS 样式入口。 */
36
+ sx?: SxProps;
8
37
  };
9
- export declare function Rate(props: RateProps): import("react/jsx-runtime").JSX.Element;
38
+ /**
39
+ * Rate 用于星级评分、满意度打分和快速反馈场景,支持受控/非受控、悬停预览、键盘操作与表单提交。
40
+ */
41
+ export declare const Rate: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children" | "onChange"> & {
42
+ /** 受控评分值。 */
43
+ value?: number;
44
+ /** 非受控默认评分值。 */
45
+ defaultValue?: number;
46
+ /** 星级总数,最小为 `1`。 */
47
+ count?: number;
48
+ /** 是否允许再次点击当前值后清空。 */
49
+ allowClear?: boolean;
50
+ /** 是否移除外层边框与背景。 */
51
+ borderless?: boolean;
52
+ /** 是否禁用。 */
53
+ disabled?: boolean;
54
+ /** 是否只读。只读时保留展示,不响应交互。 */
55
+ readOnly?: boolean;
56
+ /** 与原生表单联动的字段名。 */
57
+ name?: string;
58
+ /** 评分变更回调。 */
59
+ onChange?: (value: number) => void;
60
+ /** 鼠标悬停预览值变更回调。 */
61
+ onHoverChange?: (value: number | null) => void;
62
+ /** 星星尺寸。 */
63
+ size?: RateSize;
64
+ /** 评分图标。 */
65
+ character?: React.ReactNode;
66
+ /** 根节点类名。 */
67
+ className?: string;
68
+ /** 兼容旧写法的类名。 */
69
+ class?: string;
70
+ /** 根节点样式。 */
71
+ style?: React.CSSProperties;
72
+ /** CSS-in-JS 样式入口。 */
73
+ sx?: SxProps;
74
+ } & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,30 @@
1
+ import * as React from "react";
2
+ import { type SxProps } from "@/styling";
3
+ export type SliderProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange"> & {
4
+ value?: number;
5
+ class?: string;
6
+ /**
7
+ * 视觉变体。
8
+ * - `"solid"`:纯色风格,与组件库整体风格统一(默认)
9
+ * - `"gradient"`:渐变色风格,提供更丰富的视觉效果
10
+ */
11
+ variant?: "solid" | "gradient";
12
+ /**
13
+ * 轨道粗细。数字会自动转换为 px,字符串会作为 CSS 长度值透传。
14
+ */
15
+ trackSize?: number | string;
16
+ /**
17
+ * 滑块头尺寸。数字会自动转换为 px,字符串会作为 CSS 长度值透传。
18
+ */
19
+ thumbSize?: number | string;
20
+ sx?: SxProps;
21
+ onValueChange?: (value: number) => void;
22
+ };
23
+ /**
24
+ * Slider 是原生 range 输入的封装,保留浏览器原生交互语义,
25
+ * 同时提供更符合本库风格的视觉样式与数值回调。
26
+ */
27
+ export declare function Slider(props: SliderProps): import("react/jsx-runtime").JSX.Element;
28
+ export declare namespace Slider {
29
+ var displayName: string;
30
+ }
@@ -0,0 +1 @@
1
+ export * from "./Slider";
@@ -1,6 +1,10 @@
1
+ /**
2
+ * Uploader 属性。组件通过 `onChange(FileList | null)` 暴露用户选择的文件列表。
3
+ */
1
4
  export type UploaderProps = {
2
5
  accept?: string;
3
6
  multiple?: boolean;
7
+ name?: string;
4
8
  disabled?: boolean;
5
9
  onChange?: (files: FileList | null) => void;
6
10
  };
@@ -0,0 +1,2 @@
1
+ export * from "./mobile-select";
2
+ export * from "./mobile-cascader";
@@ -0,0 +1,85 @@
1
+ import * as React from "react";
2
+ import type { CascaderFieldNames, CascaderLoadDataMeta, CascaderOption, CascaderRenderOptionState, CascaderValue, CascaderValueChangeMeta } from "@/components/form/cascader";
3
+ import { type SxProps } from "@/styling";
4
+ import { type MobileOptionAlign } from "../shared";
5
+ export type MobileCascaderRef = {
6
+ focus: () => void;
7
+ blur: () => void;
8
+ open: () => void;
9
+ close: () => void;
10
+ clear: () => void;
11
+ getValue: () => CascaderValue;
12
+ };
13
+ export type MobileCascaderProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "children" | "value" | "defaultValue" | "onChange"> & {
14
+ class?: string;
15
+ sx?: SxProps;
16
+ options?: CascaderOption[];
17
+ value?: CascaderValue;
18
+ defaultValue?: CascaderValue;
19
+ onValueChange?: (value: CascaderValue, meta: CascaderValueChangeMeta) => void;
20
+ open?: boolean;
21
+ defaultOpen?: boolean;
22
+ onOpenChange?: (open: boolean) => void;
23
+ placeholder?: React.ReactNode;
24
+ title?: React.ReactNode;
25
+ cancelText?: React.ReactNode;
26
+ confirmText?: React.ReactNode;
27
+ separator?: React.ReactNode;
28
+ displayRender?: (labels: React.ReactNode[], options: CascaderOption[]) => React.ReactNode;
29
+ renderOption?: (option: CascaderOption, state: CascaderRenderOptionState) => React.ReactNode;
30
+ fieldNames?: CascaderFieldNames;
31
+ changeOnSelect?: boolean;
32
+ clearable?: boolean;
33
+ readOnly?: boolean;
34
+ required?: boolean;
35
+ loadData?: (selectedOptions: CascaderOption[], meta: CascaderLoadDataMeta) => void | Promise<void>;
36
+ align?: MobileOptionAlign;
37
+ levelLabels?: React.ReactNode[];
38
+ drawerClassName?: string;
39
+ drawerClass?: string;
40
+ drawerStyle?: React.CSSProperties;
41
+ drawerSx?: SxProps;
42
+ maxDrawerHeight?: number | string;
43
+ optionClassName?: string;
44
+ optionClass?: string;
45
+ optionStyle?: React.CSSProperties;
46
+ optionSx?: SxProps;
47
+ };
48
+ /**
49
+ * MobileCascader 是移动端级联抽屉,沿用 Cascader 的路径数组值模型。
50
+ */
51
+ export declare const MobileCascader: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "value" | "children" | "defaultValue" | "onChange"> & {
52
+ class?: string;
53
+ sx?: SxProps;
54
+ options?: CascaderOption[];
55
+ value?: CascaderValue;
56
+ defaultValue?: CascaderValue;
57
+ onValueChange?: (value: CascaderValue, meta: CascaderValueChangeMeta) => void;
58
+ open?: boolean;
59
+ defaultOpen?: boolean;
60
+ onOpenChange?: (open: boolean) => void;
61
+ placeholder?: React.ReactNode;
62
+ title?: React.ReactNode;
63
+ cancelText?: React.ReactNode;
64
+ confirmText?: React.ReactNode;
65
+ separator?: React.ReactNode;
66
+ displayRender?: (labels: React.ReactNode[], options: CascaderOption[]) => React.ReactNode;
67
+ renderOption?: (option: CascaderOption, state: CascaderRenderOptionState) => React.ReactNode;
68
+ fieldNames?: CascaderFieldNames;
69
+ changeOnSelect?: boolean;
70
+ clearable?: boolean;
71
+ readOnly?: boolean;
72
+ required?: boolean;
73
+ loadData?: (selectedOptions: CascaderOption[], meta: CascaderLoadDataMeta) => void | Promise<void>;
74
+ align?: MobileOptionAlign;
75
+ levelLabels?: React.ReactNode[];
76
+ drawerClassName?: string;
77
+ drawerClass?: string;
78
+ drawerStyle?: React.CSSProperties;
79
+ drawerSx?: SxProps;
80
+ maxDrawerHeight?: number | string;
81
+ optionClassName?: string;
82
+ optionClass?: string;
83
+ optionStyle?: React.CSSProperties;
84
+ optionSx?: SxProps;
85
+ } & React.RefAttributes<MobileCascaderRef>>;
@@ -0,0 +1 @@
1
+ export * from "./MobileCascader";
@@ -0,0 +1,86 @@
1
+ import * as React from "react";
2
+ import type { SelectOption, SelectOptionGroup } from "@/components/form/select";
3
+ import { type SxProps } from "@/styling";
4
+ import { type MobileOptionAlign } from "../shared";
5
+ export type MobileSelectValueChangeReason = "select" | "clear";
6
+ export type MobileSelectValueChangeMeta = {
7
+ reason: MobileSelectValueChangeReason;
8
+ option?: SelectOption;
9
+ event?: React.SyntheticEvent;
10
+ };
11
+ export type MobileSelectRenderOptionState = {
12
+ active: boolean;
13
+ checked: boolean;
14
+ disabled: boolean;
15
+ };
16
+ export type MobileSelectRef = {
17
+ focus: () => void;
18
+ blur: () => void;
19
+ open: () => void;
20
+ close: () => void;
21
+ clear: () => void;
22
+ getValue: () => string;
23
+ };
24
+ export type MobileSelectProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "children" | "value" | "defaultValue" | "onChange"> & {
25
+ class?: string;
26
+ sx?: SxProps;
27
+ options?: Array<SelectOption | SelectOptionGroup>;
28
+ value?: string;
29
+ defaultValue?: string;
30
+ onValueChange?: (value: string, meta: MobileSelectValueChangeMeta) => void;
31
+ open?: boolean;
32
+ defaultOpen?: boolean;
33
+ onOpenChange?: (open: boolean) => void;
34
+ placeholder?: React.ReactNode;
35
+ title?: React.ReactNode;
36
+ cancelText?: React.ReactNode;
37
+ confirmText?: React.ReactNode;
38
+ clearable?: boolean;
39
+ readOnly?: boolean;
40
+ required?: boolean;
41
+ align?: MobileOptionAlign;
42
+ displayRender?: (option: SelectOption | undefined) => React.ReactNode;
43
+ renderOption?: (option: SelectOption, state: MobileSelectRenderOptionState) => React.ReactNode;
44
+ drawerClassName?: string;
45
+ drawerClass?: string;
46
+ drawerStyle?: React.CSSProperties;
47
+ drawerSx?: SxProps;
48
+ maxDrawerHeight?: number | string;
49
+ optionClassName?: string;
50
+ optionClass?: string;
51
+ optionStyle?: React.CSSProperties;
52
+ optionSx?: SxProps;
53
+ };
54
+ /**
55
+ * MobileSelect 是面向移动端的单选抽屉,沿用 Select 的 option 数据模型。
56
+ */
57
+ export declare const MobileSelect: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "value" | "children" | "defaultValue" | "onChange"> & {
58
+ class?: string;
59
+ sx?: SxProps;
60
+ options?: Array<SelectOption | SelectOptionGroup>;
61
+ value?: string;
62
+ defaultValue?: string;
63
+ onValueChange?: (value: string, meta: MobileSelectValueChangeMeta) => void;
64
+ open?: boolean;
65
+ defaultOpen?: boolean;
66
+ onOpenChange?: (open: boolean) => void;
67
+ placeholder?: React.ReactNode;
68
+ title?: React.ReactNode;
69
+ cancelText?: React.ReactNode;
70
+ confirmText?: React.ReactNode;
71
+ clearable?: boolean;
72
+ readOnly?: boolean;
73
+ required?: boolean;
74
+ align?: MobileOptionAlign;
75
+ displayRender?: (option: SelectOption | undefined) => React.ReactNode;
76
+ renderOption?: (option: SelectOption, state: MobileSelectRenderOptionState) => React.ReactNode;
77
+ drawerClassName?: string;
78
+ drawerClass?: string;
79
+ drawerStyle?: React.CSSProperties;
80
+ drawerSx?: SxProps;
81
+ maxDrawerHeight?: number | string;
82
+ optionClassName?: string;
83
+ optionClass?: string;
84
+ optionStyle?: React.CSSProperties;
85
+ optionSx?: SxProps;
86
+ } & React.RefAttributes<MobileSelectRef>>;
@@ -0,0 +1 @@
1
+ export * from "./MobileSelect";
@@ -0,0 +1,62 @@
1
+ import * as React from "react";
2
+ import { type SxProps } from "@/styling";
3
+ export type MobileOptionAlign = "left" | "center" | "right";
4
+ export type MobileDrawerProps = {
5
+ open: boolean;
6
+ title?: React.ReactNode;
7
+ cancelText?: React.ReactNode;
8
+ confirmText?: React.ReactNode;
9
+ confirmDisabled?: boolean;
10
+ maxHeight?: number | string;
11
+ children?: React.ReactNode;
12
+ className?: string;
13
+ class?: string;
14
+ style?: React.CSSProperties;
15
+ sx?: SxProps;
16
+ onCancel?: () => void;
17
+ onConfirm?: () => void;
18
+ onOpenChange?: (open: boolean) => void;
19
+ };
20
+ export type MobileTriggerProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "children"> & {
21
+ open?: boolean;
22
+ clearable?: boolean;
23
+ hasValue?: boolean;
24
+ readOnly?: boolean;
25
+ placeholder?: React.ReactNode;
26
+ display?: React.ReactNode;
27
+ class?: string;
28
+ sx?: SxProps;
29
+ onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;
30
+ };
31
+ type ControllableOptions<T> = {
32
+ value?: T;
33
+ defaultValue: T;
34
+ onChange?: (value: T) => void;
35
+ };
36
+ export declare function useControllableValue<T>(options: ControllableOptions<T>): readonly [T, (nextValue: T) => void, boolean];
37
+ export declare function useResolvedSx(sx: SxProps | undefined): {
38
+ sxClassName: undefined;
39
+ sxInlineStyle: undefined;
40
+ } | {
41
+ sxClassName: string;
42
+ sxInlineStyle: React.CSSProperties;
43
+ };
44
+ export declare function resolveLength(value: number | string | undefined): string | undefined;
45
+ export declare function getAlignClass(align: MobileOptionAlign | undefined): "justify-center text-center" | "justify-end text-right" | "justify-start text-left";
46
+ export declare function ChevronDownIcon(props: React.SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
47
+ export declare function ChevronRightIcon(props: React.SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
48
+ export declare function ClearIcon(props: React.SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
49
+ export declare function LoadingSpinner(): import("react/jsx-runtime").JSX.Element;
50
+ export declare function MobileDrawer(props: MobileDrawerProps): import("react/jsx-runtime").JSX.Element | null;
51
+ export declare const MobileTrigger: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "children"> & {
52
+ open?: boolean;
53
+ clearable?: boolean;
54
+ hasValue?: boolean;
55
+ readOnly?: boolean;
56
+ placeholder?: React.ReactNode;
57
+ display?: React.ReactNode;
58
+ class?: string;
59
+ sx?: SxProps;
60
+ onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;
61
+ } & React.RefAttributes<HTMLButtonElement>>;
62
+ export {};