@react-component-library-nlxx/components 1.0.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/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/index.d.mts +220 -0
- package/dist/index.d.ts +220 -0
- package/dist/index.js +690 -0
- package/dist/index.mjs +652 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
File without changes
|
package/README.md
ADDED
|
File without changes
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import React$1, { ButtonHTMLAttributes, InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
|
|
5
|
+
//#region src/Button/interface.d.ts
|
|
6
|
+
type ButtonSize = 'small' | 'medium' | 'large';
|
|
7
|
+
type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost';
|
|
8
|
+
type ButtonShape = 'default' | 'round' | 'circle';
|
|
9
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
10
|
+
/** 按钮内容 */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/** 按钮尺寸 */
|
|
13
|
+
size?: ButtonSize;
|
|
14
|
+
/** 按钮变体 */
|
|
15
|
+
variant?: ButtonVariant;
|
|
16
|
+
/** 按钮形状 */
|
|
17
|
+
shape?: ButtonShape;
|
|
18
|
+
/** 是否加载中 */
|
|
19
|
+
loading?: boolean;
|
|
20
|
+
/** 是否禁用 */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** 是否块级按钮 */
|
|
23
|
+
block?: boolean;
|
|
24
|
+
/** 图标 */
|
|
25
|
+
icon?: ReactNode;
|
|
26
|
+
/** 图标位置 */
|
|
27
|
+
iconPosition?: 'left' | 'right';
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/Button/index.d.ts
|
|
31
|
+
declare const Button: React$1.ForwardRefExoticComponent<ButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/Input/interface.d.ts
|
|
34
|
+
/**
|
|
35
|
+
* 暴露给父组件的方法接口
|
|
36
|
+
*/
|
|
37
|
+
interface InputRef {
|
|
38
|
+
focus: () => void;
|
|
39
|
+
blur: () => void;
|
|
40
|
+
clear: () => void;
|
|
41
|
+
getValue: () => string | undefined;
|
|
42
|
+
}
|
|
43
|
+
interface InputProps {
|
|
44
|
+
name?: string;
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
value?: string;
|
|
47
|
+
defaultValue?: string;
|
|
48
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
clearable?: boolean;
|
|
51
|
+
onClear?: () => void;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/Input/index.d.ts
|
|
55
|
+
/**
|
|
56
|
+
* 非受控组件将状态交给 DOM 自己管理
|
|
57
|
+
* - 子组件:通过 forwardRef 接收 ref,并将其附加到内部的 input 元素,通过 ref 调用 clear()、直接操作 DOM(不推荐)。
|
|
58
|
+
*
|
|
59
|
+
* 受控组件将状态
|
|
60
|
+
* - 动态更新值,应采用受控模式(即使用 value 和 onChange)
|
|
61
|
+
*/
|
|
62
|
+
declare const Input: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<InputProps & React$1.RefAttributes<InputRef>>>;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/SearchInput/interface.d.ts
|
|
65
|
+
interface SearchInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
66
|
+
/** 防抖延迟(ms) */
|
|
67
|
+
debounceTime?: number;
|
|
68
|
+
/** 最小搜索长度 */
|
|
69
|
+
minSearchLength?: number;
|
|
70
|
+
/** 搜索回调 */
|
|
71
|
+
onSearch?: (value: string) => void;
|
|
72
|
+
/** 搜索结果流 */
|
|
73
|
+
searchResults$?: Observable<string[]>;
|
|
74
|
+
/** 是否显示下拉建议 */
|
|
75
|
+
showSuggestions?: boolean;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/SearchInput/index.d.ts
|
|
79
|
+
declare const SearchInput: React$1.FC<SearchInputProps>;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/Card/interface.d.ts
|
|
82
|
+
interface CardProps {
|
|
83
|
+
/** 卡片标题 */
|
|
84
|
+
title?: ReactNode;
|
|
85
|
+
/** 卡片额外内容(右上角) */
|
|
86
|
+
extra?: ReactNode;
|
|
87
|
+
/** 卡片内容 */
|
|
88
|
+
children?: ReactNode;
|
|
89
|
+
/** 是否显示边框 */
|
|
90
|
+
bordered?: boolean;
|
|
91
|
+
/** 是否显示阴影 */
|
|
92
|
+
shadow?: boolean | 'hover' | 'always';
|
|
93
|
+
/** 卡片尺寸 */
|
|
94
|
+
size?: 'small' | 'default' | 'large';
|
|
95
|
+
/** 是否可悬停 */
|
|
96
|
+
hoverable?: boolean;
|
|
97
|
+
/** 卡片封面 */
|
|
98
|
+
cover?: ReactNode;
|
|
99
|
+
/** 卡片操作组 */
|
|
100
|
+
actions?: ReactNode[];
|
|
101
|
+
/** 加载状态 */
|
|
102
|
+
loading?: boolean;
|
|
103
|
+
/** 点击回调 */
|
|
104
|
+
onClick?: () => void;
|
|
105
|
+
/** 自定义样式 */
|
|
106
|
+
className?: string;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/Card/index.d.ts
|
|
110
|
+
declare const Card: React$1.FC<CardProps>;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/VirtualList/interface.d.ts
|
|
113
|
+
/**
|
|
114
|
+
* 虚拟列表组件的属性接口
|
|
115
|
+
* @template T 列表项的数据类型
|
|
116
|
+
*/
|
|
117
|
+
interface VirtualListProps<T = any> {
|
|
118
|
+
/** 数据源数组 */
|
|
119
|
+
data: T[];
|
|
120
|
+
/** 渲染每个列表项的函数,接收当前项和索引,返回 React 节点 */
|
|
121
|
+
renderItem: (item: T, index: number) => ReactNode;
|
|
122
|
+
/** 每个列表项的固定高度(像素) */
|
|
123
|
+
itemHeight: number;
|
|
124
|
+
/** 容器可视区域高度(像素) */
|
|
125
|
+
height: number;
|
|
126
|
+
/** 可视区域上下额外渲染的项数,用于缓冲,默认为 3 */
|
|
127
|
+
overscan?: number;
|
|
128
|
+
/** 获取列表项唯一键的函数,默认使用索引 */
|
|
129
|
+
keyExtractor?: (item: T, index: number) => string;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/VirtualList/index.d.ts
|
|
133
|
+
declare function VirtualList<T>({
|
|
134
|
+
data,
|
|
135
|
+
renderItem,
|
|
136
|
+
itemHeight,
|
|
137
|
+
height,
|
|
138
|
+
overscan,
|
|
139
|
+
keyExtractor
|
|
140
|
+
}: VirtualListProps<T>): react_jsx_runtime0.JSX.Element;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/hooks/useDebounce.d.ts
|
|
143
|
+
/**
|
|
144
|
+
* 对传入的值进行防抖处理
|
|
145
|
+
* @param value 需要防抖的值
|
|
146
|
+
* @param delay 延迟时间(毫秒),默认 300ms
|
|
147
|
+
* @returns 防抖后的值
|
|
148
|
+
*/
|
|
149
|
+
declare function useDebounce<T>(value: T, delay?: number): T;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/hooks/useObservable.d.ts
|
|
152
|
+
declare function useObservable<T>(observable: Observable<T>, initialValue: T): T;
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region ../theme/src/tokens.d.ts
|
|
155
|
+
interface ThemeTokens {
|
|
156
|
+
colors: {
|
|
157
|
+
primary: string;
|
|
158
|
+
secondary: string;
|
|
159
|
+
success: string;
|
|
160
|
+
warning: string;
|
|
161
|
+
error: string;
|
|
162
|
+
info: string;
|
|
163
|
+
background: string;
|
|
164
|
+
text: {
|
|
165
|
+
primary: string;
|
|
166
|
+
secondary: string;
|
|
167
|
+
disabled: string;
|
|
168
|
+
};
|
|
169
|
+
border: string;
|
|
170
|
+
};
|
|
171
|
+
spacing: {
|
|
172
|
+
xs: number;
|
|
173
|
+
sm: number;
|
|
174
|
+
md: number;
|
|
175
|
+
lg: number;
|
|
176
|
+
xl: number;
|
|
177
|
+
};
|
|
178
|
+
typography: {
|
|
179
|
+
fontSize: {
|
|
180
|
+
xs: number;
|
|
181
|
+
sm: number;
|
|
182
|
+
md: number;
|
|
183
|
+
lg: number;
|
|
184
|
+
xl: number;
|
|
185
|
+
};
|
|
186
|
+
fontWeight: {
|
|
187
|
+
normal: number;
|
|
188
|
+
medium: number;
|
|
189
|
+
bold: number;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
borderRadius: {
|
|
193
|
+
xs: number;
|
|
194
|
+
sm: number;
|
|
195
|
+
md: number;
|
|
196
|
+
lg: number;
|
|
197
|
+
xl: number;
|
|
198
|
+
round: string;
|
|
199
|
+
};
|
|
200
|
+
shadows: {
|
|
201
|
+
sm: string;
|
|
202
|
+
md: string;
|
|
203
|
+
lg: string;
|
|
204
|
+
};
|
|
205
|
+
transitions: {
|
|
206
|
+
fast: string;
|
|
207
|
+
normal: string;
|
|
208
|
+
slow: string;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region ../theme/src/index.d.ts
|
|
213
|
+
declare const useTheme: () => ThemeTokens;
|
|
214
|
+
interface ThemeProviderProps {
|
|
215
|
+
theme?: Partial<ThemeTokens>;
|
|
216
|
+
children: React$1.ReactNode;
|
|
217
|
+
}
|
|
218
|
+
declare const ThemeProvider: React$1.FC<ThemeProviderProps>;
|
|
219
|
+
//#endregion
|
|
220
|
+
export { Button, Card, Input, SearchInput, ThemeProvider, VirtualList, useDebounce, useObservable, useTheme };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import React$1, { ButtonHTMLAttributes, InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/Button/interface.d.ts
|
|
6
|
+
type ButtonSize = 'small' | 'medium' | 'large';
|
|
7
|
+
type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost';
|
|
8
|
+
type ButtonShape = 'default' | 'round' | 'circle';
|
|
9
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
10
|
+
/** 按钮内容 */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/** 按钮尺寸 */
|
|
13
|
+
size?: ButtonSize;
|
|
14
|
+
/** 按钮变体 */
|
|
15
|
+
variant?: ButtonVariant;
|
|
16
|
+
/** 按钮形状 */
|
|
17
|
+
shape?: ButtonShape;
|
|
18
|
+
/** 是否加载中 */
|
|
19
|
+
loading?: boolean;
|
|
20
|
+
/** 是否禁用 */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** 是否块级按钮 */
|
|
23
|
+
block?: boolean;
|
|
24
|
+
/** 图标 */
|
|
25
|
+
icon?: ReactNode;
|
|
26
|
+
/** 图标位置 */
|
|
27
|
+
iconPosition?: 'left' | 'right';
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/Button/index.d.ts
|
|
31
|
+
declare const Button: React$1.ForwardRefExoticComponent<ButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/Input/interface.d.ts
|
|
34
|
+
/**
|
|
35
|
+
* 暴露给父组件的方法接口
|
|
36
|
+
*/
|
|
37
|
+
interface InputRef {
|
|
38
|
+
focus: () => void;
|
|
39
|
+
blur: () => void;
|
|
40
|
+
clear: () => void;
|
|
41
|
+
getValue: () => string | undefined;
|
|
42
|
+
}
|
|
43
|
+
interface InputProps {
|
|
44
|
+
name?: string;
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
value?: string;
|
|
47
|
+
defaultValue?: string;
|
|
48
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
clearable?: boolean;
|
|
51
|
+
onClear?: () => void;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/Input/index.d.ts
|
|
55
|
+
/**
|
|
56
|
+
* 非受控组件将状态交给 DOM 自己管理
|
|
57
|
+
* - 子组件:通过 forwardRef 接收 ref,并将其附加到内部的 input 元素,通过 ref 调用 clear()、直接操作 DOM(不推荐)。
|
|
58
|
+
*
|
|
59
|
+
* 受控组件将状态
|
|
60
|
+
* - 动态更新值,应采用受控模式(即使用 value 和 onChange)
|
|
61
|
+
*/
|
|
62
|
+
declare const Input: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<InputProps & React$1.RefAttributes<InputRef>>>;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/SearchInput/interface.d.ts
|
|
65
|
+
interface SearchInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
66
|
+
/** 防抖延迟(ms) */
|
|
67
|
+
debounceTime?: number;
|
|
68
|
+
/** 最小搜索长度 */
|
|
69
|
+
minSearchLength?: number;
|
|
70
|
+
/** 搜索回调 */
|
|
71
|
+
onSearch?: (value: string) => void;
|
|
72
|
+
/** 搜索结果流 */
|
|
73
|
+
searchResults$?: Observable<string[]>;
|
|
74
|
+
/** 是否显示下拉建议 */
|
|
75
|
+
showSuggestions?: boolean;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/SearchInput/index.d.ts
|
|
79
|
+
declare const SearchInput: React$1.FC<SearchInputProps>;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/Card/interface.d.ts
|
|
82
|
+
interface CardProps {
|
|
83
|
+
/** 卡片标题 */
|
|
84
|
+
title?: ReactNode;
|
|
85
|
+
/** 卡片额外内容(右上角) */
|
|
86
|
+
extra?: ReactNode;
|
|
87
|
+
/** 卡片内容 */
|
|
88
|
+
children?: ReactNode;
|
|
89
|
+
/** 是否显示边框 */
|
|
90
|
+
bordered?: boolean;
|
|
91
|
+
/** 是否显示阴影 */
|
|
92
|
+
shadow?: boolean | 'hover' | 'always';
|
|
93
|
+
/** 卡片尺寸 */
|
|
94
|
+
size?: 'small' | 'default' | 'large';
|
|
95
|
+
/** 是否可悬停 */
|
|
96
|
+
hoverable?: boolean;
|
|
97
|
+
/** 卡片封面 */
|
|
98
|
+
cover?: ReactNode;
|
|
99
|
+
/** 卡片操作组 */
|
|
100
|
+
actions?: ReactNode[];
|
|
101
|
+
/** 加载状态 */
|
|
102
|
+
loading?: boolean;
|
|
103
|
+
/** 点击回调 */
|
|
104
|
+
onClick?: () => void;
|
|
105
|
+
/** 自定义样式 */
|
|
106
|
+
className?: string;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/Card/index.d.ts
|
|
110
|
+
declare const Card: React$1.FC<CardProps>;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/VirtualList/interface.d.ts
|
|
113
|
+
/**
|
|
114
|
+
* 虚拟列表组件的属性接口
|
|
115
|
+
* @template T 列表项的数据类型
|
|
116
|
+
*/
|
|
117
|
+
interface VirtualListProps<T = any> {
|
|
118
|
+
/** 数据源数组 */
|
|
119
|
+
data: T[];
|
|
120
|
+
/** 渲染每个列表项的函数,接收当前项和索引,返回 React 节点 */
|
|
121
|
+
renderItem: (item: T, index: number) => ReactNode;
|
|
122
|
+
/** 每个列表项的固定高度(像素) */
|
|
123
|
+
itemHeight: number;
|
|
124
|
+
/** 容器可视区域高度(像素) */
|
|
125
|
+
height: number;
|
|
126
|
+
/** 可视区域上下额外渲染的项数,用于缓冲,默认为 3 */
|
|
127
|
+
overscan?: number;
|
|
128
|
+
/** 获取列表项唯一键的函数,默认使用索引 */
|
|
129
|
+
keyExtractor?: (item: T, index: number) => string;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/VirtualList/index.d.ts
|
|
133
|
+
declare function VirtualList<T>({
|
|
134
|
+
data,
|
|
135
|
+
renderItem,
|
|
136
|
+
itemHeight,
|
|
137
|
+
height,
|
|
138
|
+
overscan,
|
|
139
|
+
keyExtractor
|
|
140
|
+
}: VirtualListProps<T>): react_jsx_runtime0.JSX.Element;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/hooks/useDebounce.d.ts
|
|
143
|
+
/**
|
|
144
|
+
* 对传入的值进行防抖处理
|
|
145
|
+
* @param value 需要防抖的值
|
|
146
|
+
* @param delay 延迟时间(毫秒),默认 300ms
|
|
147
|
+
* @returns 防抖后的值
|
|
148
|
+
*/
|
|
149
|
+
declare function useDebounce<T>(value: T, delay?: number): T;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/hooks/useObservable.d.ts
|
|
152
|
+
declare function useObservable<T>(observable: Observable<T>, initialValue: T): T;
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region ../theme/src/tokens.d.ts
|
|
155
|
+
interface ThemeTokens {
|
|
156
|
+
colors: {
|
|
157
|
+
primary: string;
|
|
158
|
+
secondary: string;
|
|
159
|
+
success: string;
|
|
160
|
+
warning: string;
|
|
161
|
+
error: string;
|
|
162
|
+
info: string;
|
|
163
|
+
background: string;
|
|
164
|
+
text: {
|
|
165
|
+
primary: string;
|
|
166
|
+
secondary: string;
|
|
167
|
+
disabled: string;
|
|
168
|
+
};
|
|
169
|
+
border: string;
|
|
170
|
+
};
|
|
171
|
+
spacing: {
|
|
172
|
+
xs: number;
|
|
173
|
+
sm: number;
|
|
174
|
+
md: number;
|
|
175
|
+
lg: number;
|
|
176
|
+
xl: number;
|
|
177
|
+
};
|
|
178
|
+
typography: {
|
|
179
|
+
fontSize: {
|
|
180
|
+
xs: number;
|
|
181
|
+
sm: number;
|
|
182
|
+
md: number;
|
|
183
|
+
lg: number;
|
|
184
|
+
xl: number;
|
|
185
|
+
};
|
|
186
|
+
fontWeight: {
|
|
187
|
+
normal: number;
|
|
188
|
+
medium: number;
|
|
189
|
+
bold: number;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
borderRadius: {
|
|
193
|
+
xs: number;
|
|
194
|
+
sm: number;
|
|
195
|
+
md: number;
|
|
196
|
+
lg: number;
|
|
197
|
+
xl: number;
|
|
198
|
+
round: string;
|
|
199
|
+
};
|
|
200
|
+
shadows: {
|
|
201
|
+
sm: string;
|
|
202
|
+
md: string;
|
|
203
|
+
lg: string;
|
|
204
|
+
};
|
|
205
|
+
transitions: {
|
|
206
|
+
fast: string;
|
|
207
|
+
normal: string;
|
|
208
|
+
slow: string;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region ../theme/src/index.d.ts
|
|
213
|
+
declare const useTheme: () => ThemeTokens;
|
|
214
|
+
interface ThemeProviderProps {
|
|
215
|
+
theme?: Partial<ThemeTokens>;
|
|
216
|
+
children: React$1.ReactNode;
|
|
217
|
+
}
|
|
218
|
+
declare const ThemeProvider: React$1.FC<ThemeProviderProps>;
|
|
219
|
+
//#endregion
|
|
220
|
+
export { Button, Card, Input, SearchInput, ThemeProvider, VirtualList, useDebounce, useObservable, useTheme };
|