sinking-antd 1.0.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 ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024
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.
22
+
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # sinking-antd
2
+
3
+ 一个基于 Ant Design 和 antd-style 构建的企业级 React 组件库,专为中后台应用设计。
4
+
5
+ ## ✨ 特性
6
+
7
+ - 🎨 **主题定制**:完整的主题系统,支持亮色/暗色/跟随系统
8
+ - 📦 **开箱即用**:高质量的 React 组件
9
+ - 🔧 **TypeScript**:完整的类型定义
10
+ - 🎯 **企业级**:适用于中后台产品
11
+ - 🚀 **性能优化**:内置性能优化
12
+ - 📱 **响应式**:自适应各种屏幕
13
+
14
+ ## 📦 安装
15
+
16
+ ```bash
17
+ npm install sinking-antd
18
+ # 或
19
+ yarn add sinking-antd
20
+ # 或
21
+ pnpm add sinking-antd
22
+ ```
23
+
24
+ ### Peer Dependencies
25
+
26
+ ```bash
27
+ npm install react react-dom antd @ant-design/icons antd-style
28
+ ```
29
+
30
+ ## 🔨 快速开始
31
+
32
+ ```tsx
33
+ import { Theme, Layout, ProTable } from 'sinking-antd';
34
+
35
+ function App() {
36
+ return (
37
+ <Theme>
38
+ <Layout menus={menus} pathname={pathname}>
39
+ <ProTable columns={columns} request={fetchData} />
40
+ </Layout>
41
+ </Theme>
42
+ );
43
+ }
44
+ ```
45
+
46
+ ## 📚 组件列表
47
+
48
+ | 组件 | 说明 |
49
+ |------|------|
50
+ | Theme | 主题管理 |
51
+ | Layout | 后台布局 |
52
+ | ProTable | 高级表格 |
53
+ | ProModal | 高级弹窗 |
54
+ | Icon | 图标 |
55
+ | Title | 标题 |
56
+ | Breadcrumb | 面包屑 |
57
+ | Animation | 动画 |
58
+ | Antd | 工具(Message、Notification、Modal)|
@@ -0,0 +1,413 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { MessageInstance } from 'antd/es/message/interface';
3
+ import { ModalStaticFunctions } from 'antd/es/modal/confirm';
4
+ import { NotificationInstance } from 'antd/es/notification/interface';
5
+ import { ThemeMode } from 'antd-style';
6
+ import { TableColumnProps, TableProps, PaginationProps, FormInstance, ModalProps } from 'antd';
7
+
8
+ /**
9
+ * Icon 组件 - 支持 Ant Design 图标和 iconfont 图标
10
+ *
11
+ * 使用方式:
12
+ *
13
+ * 1. 全局配置(推荐,应用启动时设置一次)
14
+ * ```tsx
15
+ * import { setIconfontUrl } from '@/components/icon';
16
+ *
17
+ * // 设置单个 iconfont 地址
18
+ * setIconfontUrl('//at.alicdn.com/t/c/font_xxx.js');
19
+ *
20
+ * // 设置多个 iconfont 地址(支持多个图标库)
21
+ * setIconfontUrl([
22
+ * '//at.alicdn.com/t/c/font_xxx1.js',
23
+ * '//at.alicdn.com/t/c/font_xxx2.js'
24
+ * ]);
25
+ * ```
26
+ *
27
+ * 2. 使用 Provider 局部配置(适用于特定区域需要不同图标库)
28
+ * ```tsx
29
+ * import { Icon, IconFontProvider } from '@/components/icon';
30
+ *
31
+ * <IconFontProvider iconfontUrl="//at.alicdn.com/t/c/font_xxx.js">
32
+ * <Icon type="icon-xxx" />
33
+ * </IconFontProvider>
34
+ * ```
35
+ *
36
+ * 3. 直接在组件上配置(优先级最高,适用于个别图标需要特殊处理)
37
+ * ```tsx
38
+ * import { Icon } from '@/components/icon';
39
+ *
40
+ * <Icon type="icon-xxx" iconfontUrl="//at.alicdn.com/t/c/font_xxx.js" />
41
+ * ```
42
+ *
43
+ * 优先级:组件 props > IconFontProvider > 全局配置 > 默认值
44
+ */
45
+
46
+ /**
47
+ * 设置全局 iconfont 地址
48
+ * @param url iconfont 脚本地址(单个或多个)
49
+ */
50
+ declare const setIconfontUrl: (url: string | string[]) => void;
51
+ /**
52
+ * 获取当前 iconfont 地址
53
+ * @returns 当前配置的 iconfont 地址(未配置时返回 undefined)
54
+ */
55
+ declare const getIconfontUrl: () => string | string[] | undefined;
56
+ /**
57
+ * IconFont 配置 Provider 组件属性
58
+ */
59
+ interface IconFontProviderProps {
60
+ iconfontUrl?: string | string[];
61
+ children: React.ReactNode;
62
+ }
63
+ /**
64
+ * IconFont 配置 Provider 组件
65
+ * 用于为子组件提供自定义的 iconfont 地址
66
+ */
67
+ declare const IconFontProvider: React.FC<IconFontProviderProps>;
68
+ /**
69
+ * Icon 组件属性
70
+ */
71
+ interface IconProps extends React.HTMLAttributes<HTMLSpanElement> {
72
+ type: string;
73
+ iconfontUrl?: string | string[];
74
+ ref?: any;
75
+ className?: any;
76
+ style?: any;
77
+ onClick?: any;
78
+ }
79
+ /**
80
+ * Icon 组件
81
+ * 支持 Ant Design 图标和 iconfont 图标
82
+ */
83
+ declare const Icon: React.ForwardRefExoticComponent<Omit<IconProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
84
+ /**
85
+ * 获取所有 Antd 图标名称
86
+ */
87
+ declare const getAntdIconNames: () => string[];
88
+ /**
89
+ * 获取所有 iconfont 图标名称
90
+ * @param url 可选的 iconfont 地址(不传则使用全局配置)
91
+ * @returns iconfont 图标名称数组
92
+ */
93
+ declare const getIconfontIconNames: (url?: string | string[]) => Promise<string[]>;
94
+ /**
95
+ * 获取所有图标名称(Antd + Iconfont)
96
+ * @param iconfontUrl 可选的 iconfont 地址(不传则使用全局配置)
97
+ * @returns 所有图标名称数组
98
+ */
99
+ declare const getAllIconNames: (iconfontUrl?: string | string[]) => Promise<string[]>;
100
+
101
+ /**
102
+ * 面包屑项目类型
103
+ */
104
+ type BreadCrumbItem$1 = {
105
+ title: string;
106
+ path?: string;
107
+ onClick?: () => void;
108
+ };
109
+ /**
110
+ * 面包屑组件属性
111
+ */
112
+ type BreadCrumbProps = {
113
+ style?: React.CSSProperties;
114
+ className?: string;
115
+ enabled?: boolean;
116
+ items?: BreadCrumbItem$1[];
117
+ hideBreadCrumb?: boolean;
118
+ };
119
+ /**
120
+ * 面包屑组件
121
+ * @param props
122
+ * @constructor
123
+ */
124
+ declare const BreadCrumb: React.FC<BreadCrumbProps>;
125
+
126
+ declare let Message: MessageInstance;
127
+ declare let Notification: NotificationInstance;
128
+ declare let Modal: Omit<ModalStaticFunctions, 'warn'>;
129
+ declare const _default: () => null;
130
+
131
+ /**
132
+ * 主题上下文类型
133
+ * 提供主题管理的所有方法和状态
134
+ */
135
+ interface ThemeContextType {
136
+ themes: any;
137
+ setColor: (color: string) => void;
138
+ setRadius: (radius: number) => void;
139
+ setThemes: (theme: any) => void;
140
+ setDefaultTheme: () => void;
141
+ setCompactTheme: () => void;
142
+ appearance: any;
143
+ setAppearance: (appearance: any) => void;
144
+ mode: ThemeMode;
145
+ getModeName: (mode: ThemeMode) => string;
146
+ lightMode: ThemeMode;
147
+ darkMode: ThemeMode;
148
+ autoMode: ThemeMode;
149
+ setLightMode: () => void;
150
+ setDarkMode: () => void;
151
+ setAutoMode: () => void;
152
+ isLightMode: () => boolean;
153
+ isDarkMode: () => boolean;
154
+ isAutoMode: () => boolean;
155
+ isLightTheme: () => boolean;
156
+ isDarkTheme: () => boolean;
157
+ isCompactTheme: () => boolean;
158
+ toggle: () => void;
159
+ }
160
+ declare const useTheme: () => ThemeContextType | undefined;
161
+ /**
162
+ * 主题组件属性
163
+ */
164
+ type ThemeProps = {
165
+ theme?: any;
166
+ mode?: ThemeMode;
167
+ appearance?: any;
168
+ onAppearanceChange?: (appearance: any) => void;
169
+ children?: ReactNode;
170
+ };
171
+ declare const Theme: React.FC<ThemeProps>;
172
+
173
+ type AnimationProps = {
174
+ animate?: string;
175
+ style?: React.CSSProperties;
176
+ children?: React.ReactNode;
177
+ };
178
+ declare const Animate: {
179
+ readonly None: "";
180
+ readonly FadeUp: "fadeInUp";
181
+ readonly FadeDown: "fadeInDown";
182
+ };
183
+ declare const Animation: React.FC<AnimationProps>;
184
+
185
+ /**
186
+ * 标题条位置类型
187
+ */
188
+ type TitlePlacement = 'left' | 'right';
189
+ /**
190
+ * 标题条大小类型
191
+ */
192
+ type TitleSize = 'small' | 'normal' | 'larger';
193
+ /**
194
+ * 标题条组件属性
195
+ */
196
+ type TitleProps = {
197
+ children?: any;
198
+ placement?: TitlePlacement;
199
+ size?: TitleSize;
200
+ open?: boolean;
201
+ width?: number;
202
+ height?: number;
203
+ radius?: number;
204
+ space?: number;
205
+ };
206
+ declare const Title: React.FC<TitleProps>;
207
+
208
+ type BodyProps = {
209
+ loading?: boolean;
210
+ space?: boolean;
211
+ animation?: boolean;
212
+ style?: any;
213
+ className?: any;
214
+ children?: any;
215
+ };
216
+ /**
217
+ * 页面主体部分
218
+ * @param props
219
+ * @constructor
220
+ */
221
+ declare const Body: React.FC<BodyProps>;
222
+
223
+ type FooterProps = {
224
+ children?: any;
225
+ };
226
+ declare const Footer: React.FC<FooterProps>;
227
+
228
+ type HeaderProps = {
229
+ right?: any;
230
+ left?: any;
231
+ };
232
+ declare const Header: React.FC<HeaderProps>;
233
+
234
+ /**
235
+ * 侧边栏菜单组件属性
236
+ */
237
+ type SiderProps = {
238
+ collapsed?: boolean;
239
+ menus?: any;
240
+ classNames?: any;
241
+ pathname?: string;
242
+ matchedRoutes?: string[];
243
+ onNavigate?: (path: string) => void;
244
+ onMenuClick?: (item: any) => void;
245
+ onLogoClick?: () => void;
246
+ collapsedLogo?: (isLight: boolean | undefined) => any;
247
+ unCollapsedLogo?: (isLight: boolean | undefined) => any;
248
+ menuBottomBtnIcon?: string;
249
+ menuBottomBtnText?: any;
250
+ onMenuBottomBtnClick?: () => void;
251
+ layout?: string;
252
+ theme?: string;
253
+ };
254
+ declare const Sider: React.FC<SiderProps>;
255
+
256
+ /**
257
+ * 面包屑项目类型
258
+ */
259
+ type BreadCrumbItem = {
260
+ title: string;
261
+ path?: string;
262
+ onClick?: () => void;
263
+ };
264
+ /**
265
+ * 布局组件属性
266
+ */
267
+ type LayoutProps = {
268
+ ref?: React.Ref<SinKingRef>;
269
+ loading?: boolean;
270
+ breadCrumb?: boolean;
271
+ breadCrumbItems?: BreadCrumbItem[];
272
+ hideBreadCrumb?: boolean;
273
+ menuCollapsedWidth?: number;
274
+ menuUnCollapsedWidth?: number;
275
+ menus?: any;
276
+ menuClassNames?: any;
277
+ pathname?: string;
278
+ matchedRoutes?: any;
279
+ onNavigate?: (path: string) => void;
280
+ onMenuClick?: (item: any) => void;
281
+ onMenuBtnClick?: (state: boolean) => void;
282
+ footer?: any;
283
+ headerRight?: any;
284
+ headerLeft?: any;
285
+ headerHidden?: boolean;
286
+ headerFixed?: boolean;
287
+ onLogoClick?: () => void;
288
+ collapsedLogo?: (isLight: boolean) => any;
289
+ unCollapsedLogo?: (isLight: boolean) => any;
290
+ menuBottomBtnIcon?: any;
291
+ menuBottomBtnText?: any;
292
+ onMenuBottomBtnClick?: () => void;
293
+ layout?: string;
294
+ flowLayout?: boolean;
295
+ menuTheme?: string;
296
+ waterMark?: any;
297
+ children?: React.ReactNode;
298
+ };
299
+ /**
300
+ * 布局组件引用接口
301
+ * 用于父组件通过 ref 调用布局组件的方法
302
+ */
303
+ interface SinKingRef {
304
+ collapsedMenu?: () => void;
305
+ unCollapsedMenu?: () => void;
306
+ toggleCollapsedMenu?: () => void;
307
+ }
308
+
309
+ declare const Layout: React.FC<LayoutProps>;
310
+
311
+ /**
312
+ * ProTable 列配置接口
313
+ * 扩展自 Ant Design 的 TableColumnProps,添加了更多功能
314
+ */
315
+ interface ProColumns<T = any> extends TableColumnProps<T> {
316
+ hideInSearch?: boolean;
317
+ hideInTable?: boolean;
318
+ valueType?: 'text' | 'time' | 'date' | 'dateTime' | 'dateRange' | 'dateTimeRange' | 'timeRange' | 'rate' | 'digit' | 'progress' | 'percent' | 'switch' | 'select';
319
+ copyable?: boolean;
320
+ tip?: string;
321
+ valueEnum?: Record<string, {
322
+ text: string;
323
+ color?: string;
324
+ }>;
325
+ transform?: (value: any) => any;
326
+ fieldProps?: any;
327
+ formItemProps?: any;
328
+ props?: any;
329
+ }
330
+ /**
331
+ * ProTable 搜索表单配置接口
332
+ */
333
+ interface ProTableSearch<T = any> {
334
+ layout?: "horizontal" | "vertical";
335
+ }
336
+ /**
337
+ * ProTable 组件属性
338
+ */
339
+ type ProTableProps = {
340
+ title?: any;
341
+ extra?: any;
342
+ extraRefreshBtn?: boolean;
343
+ rowKey?: string;
344
+ columns?: ProColumns[];
345
+ tableProps?: TableProps<any> & undefined;
346
+ search?: ProTableSearch | boolean;
347
+ pageHidden?: boolean;
348
+ pageInTable?: boolean;
349
+ paginationProps?: PaginationProps;
350
+ defaultPage?: number;
351
+ defaultPageSize?: number;
352
+ request?: (params: any, sort: any) => Promise<any>;
353
+ virtual?: boolean;
354
+ rowSelection?: {
355
+ selectedRowKeys?: React.Key[];
356
+ onChange?: (selectedRowKeys: React.Key[], selectedRows: any[]) => void;
357
+ onSelect?: (record: any, selected: boolean, selectedRows: any[]) => void;
358
+ onSelectAll?: (selected: boolean, selectedRows: any[], changeRows: any[]) => void;
359
+ onSelectInvert?: (selectedRowKeys: React.Key[]) => void;
360
+ align?: string;
361
+ columnWidth?: number;
362
+ fixed?: boolean;
363
+ leftExtra?: any;
364
+ rightExtra?: any;
365
+ hideExtra?: boolean;
366
+ } | false | true;
367
+ selectionAffix?: boolean;
368
+ paginationAffix?: boolean;
369
+ };
370
+ /**
371
+ * ProTable 组件引用接口
372
+ * 用于父组件通过 ref 调用表格的方法
373
+ */
374
+ interface ProTableRef {
375
+ searchForm?: FormInstance | any;
376
+ refreshTableData?: () => void | any;
377
+ resetTableData?: () => void | any;
378
+ getTableData?: () => any;
379
+ getSelectedRowKeys?: () => React.Key[];
380
+ getSelectedRows?: () => any[];
381
+ setSelectedRowKeys?: (keys: React.Key[]) => void;
382
+ clearSelectedRows?: () => void;
383
+ invertSelectedRow?: () => void;
384
+ allSelectedRow?: () => void;
385
+ }
386
+ declare const ProTableComponent: React.ForwardRefExoticComponent<ProTableProps & React.RefAttributes<ProTableRef>>;
387
+
388
+ /**
389
+ * ProModal 组件属性
390
+ */
391
+ type ProModalProps = {
392
+ modalProps?: ModalProps & any & undefined;
393
+ title?: any;
394
+ onOk?: () => void | any;
395
+ onCancel?: () => void | any;
396
+ afterClose?: () => void | any;
397
+ okText?: string;
398
+ okType?: "primary" | "default" | "dashed" | "link" | "text";
399
+ width?: number | string;
400
+ afterOpenChange?: (open: boolean) => void | any;
401
+ children?: React.ReactNode;
402
+ };
403
+ /**
404
+ * ProModal 组件引用接口
405
+ * 用于父组件通过 ref 调用模态框的方法
406
+ */
407
+ interface ProModalRef {
408
+ show: () => void;
409
+ hide: () => void;
410
+ }
411
+ declare const ProModal: React.ForwardRefExoticComponent<ProModalProps & React.RefAttributes<ProModalRef>>;
412
+
413
+ export { Animate, Animation, type AnimationProps, _default as Antd, Body, type BreadCrumbItem$1 as BreadCrumbItem, type BreadCrumbProps, BreadCrumb as Breadcrumb, Footer, Header, Icon, IconFontProvider, type IconFontProviderProps, Layout, type LayoutProps, Message, Modal, Notification, type ProColumns, ProModal, type ProModalProps, type ProModalRef, ProTableComponent as ProTable, type ProTableProps, type ProTableRef, type ProTableSearch, Sider, type SinKingRef, Theme, type ThemeContextType, type ThemeProps, Title, type TitlePlacement, type TitleProps, type TitleSize, getAllIconNames, getAntdIconNames, getIconfontIconNames, getIconfontUrl, setIconfontUrl, useTheme };