imean-service-engine-htmx-plugin 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.
@@ -0,0 +1,1484 @@
1
+ import { Context } from 'hono';
2
+ import { z } from 'zod';
3
+ import { Plugin, PluginPriority, PluginModuleOptionsSchema, Microservice, ModuleMetadata } from 'imean-service-engine';
4
+ import * as hono_jsx_jsx_dev_runtime from 'hono/jsx/jsx-dev-runtime';
5
+
6
+ /**
7
+ * HtmxAdminPlugin 类型定义
8
+ */
9
+
10
+ /**
11
+ * 导航项配置
12
+ */
13
+ interface NavItemConfig {
14
+ /** 导航标签 */
15
+ label: string;
16
+ /** 导航图标 */
17
+ icon?: string;
18
+ /** 自定义路径 */
19
+ href: string;
20
+ /** 嵌套子路由 */
21
+ children?: NavItemConfig[];
22
+ }
23
+ /**
24
+ * 用户信息接口
25
+ */
26
+ interface UserInfo {
27
+ name?: string;
28
+ avatar?: string;
29
+ email?: string;
30
+ [key: string]: any;
31
+ }
32
+ /**
33
+ * 模块类型信息
34
+ */
35
+ interface ModuleTypeInfo {
36
+ /** 模块标题 */
37
+ title: string;
38
+ /** 模块描述 */
39
+ description: string;
40
+ /** 模块基础路径 */
41
+ basePath: string;
42
+ /** 是否有 list 类型的模块 */
43
+ hasList: boolean;
44
+ /** 是否有 detail 类型的模块 */
45
+ hasDetail: boolean;
46
+ /** 是否有 form 类型的模块 */
47
+ hasForm: boolean;
48
+ /** 是否有 custom 类型的模块 */
49
+ hasCustom: boolean;
50
+ }
51
+ /**
52
+ * 面包屑项
53
+ */
54
+ interface BreadcrumbItem {
55
+ label: string;
56
+ href?: string;
57
+ }
58
+ /**
59
+ * 站点配置选项
60
+ */
61
+ interface HtmxAdminPluginOptions {
62
+ /** 站点标题 */
63
+ title?: string;
64
+ /** 站点 Logo URL(可选) */
65
+ logo?: string;
66
+ /** 管理后台路径前缀(默认 /admin) */
67
+ prefix?: string;
68
+ /** 首页路径(访问插件默认路径时重定向到此路径,如果未配置则使用第一个模块的路径) */
69
+ homePath?: string;
70
+ /** 导航配置(集中式声明导航结构,支持嵌套) */
71
+ navigation?: NavItemConfig[];
72
+ /** 获取用户信息的函数(用于显示用户信息) */
73
+ getUserInfo?: (ctx: Context) => UserInfo | null | Promise<UserInfo | null>;
74
+ }
75
+ /**
76
+ * 模块类型
77
+ */
78
+ type ModuleType = "list" | "detail" | "form" | "custom";
79
+ /**
80
+ * 模块配置选项
81
+ * 通用配置放在这里,不同类型页面的差异配置通过类来实现
82
+ */
83
+ interface HtmxAdminModuleOptions {
84
+ type: ModuleType;
85
+ title?: string;
86
+ description?: string;
87
+ /** 是否使用管理后台布局(默认 true,设置为 false 时不使用侧边栏和头部,只使用 BaseLayout) */
88
+ useAdminLayout?: boolean;
89
+ }
90
+ /**
91
+ * 列表数据源接口(仅用于 list 类型)
92
+ */
93
+ interface ListDatasource<T = any> {
94
+ /** 获取列表数据 */
95
+ getList(params: ListParams): Promise<ListResult<T>>;
96
+ /** 删除数据(可选,如果不提供则列表页不显示删除操作) */
97
+ deleteItem?(id: string | number): Promise<boolean>;
98
+ }
99
+ /**
100
+ * 详情数据源接口(仅用于 detail 类型)
101
+ */
102
+ interface DetailDatasource<T = any> {
103
+ /** 获取单条数据 */
104
+ getItem(id: string | number): Promise<T | null>;
105
+ /** 删除数据(可选) */
106
+ deleteItem?(id: string | number): Promise<boolean>;
107
+ }
108
+ /**
109
+ * 表单数据源接口(仅用于 form 类型)
110
+ */
111
+ interface FormDatasource<T = any> {
112
+ /** 获取单条数据(编辑时使用) */
113
+ getItem?(id: string | number): Promise<T | null>;
114
+ /** 更新数据 */
115
+ updateItem?(id: string | number, data: Partial<T>): Promise<T | null>;
116
+ /** 创建数据 */
117
+ createItem?(data: Partial<T>): Promise<T>;
118
+ }
119
+ /**
120
+ * 列表查询参数
121
+ */
122
+ interface ListParams {
123
+ /** 页码(从1开始) */
124
+ page?: number;
125
+ /** 每页数量 */
126
+ pageSize?: number;
127
+ /** 排序字段 */
128
+ sortBy?: string;
129
+ /** 排序方向 */
130
+ sortOrder?: "asc" | "desc";
131
+ /** 筛选条件 */
132
+ filters?: Record<string, any>;
133
+ }
134
+ /**
135
+ * 列表查询结果
136
+ */
137
+ interface ListResult<T> {
138
+ /** 数据列表 */
139
+ items: T[];
140
+ /** 总数量 */
141
+ total: number;
142
+ /** 当前页码 */
143
+ page: number;
144
+ /** 每页数量 */
145
+ pageSize: number;
146
+ /** 总页数 */
147
+ totalPages: number;
148
+ }
149
+
150
+ /**
151
+ * Action Helper - 简化操作按钮定义
152
+ */
153
+ /**
154
+ * Action Helper 类
155
+ * 提供便捷的方法来定义操作按钮,隐藏路径规则的具体实现
156
+ */
157
+ declare class PathHelper {
158
+ private basePath;
159
+ constructor(basePath: string);
160
+ /**
161
+ * 详情页动作
162
+ * 生成路径: {basePath}/detail/{id}
163
+ * @param label 按钮标签
164
+ * @param dialog 是否在对话框中打开
165
+ */
166
+ detail(id: string | number, dialog?: boolean): string;
167
+ /**
168
+ * 编辑页动作
169
+ * 生成路径: {basePath}/edit/{id}
170
+ * @param dialog 是否在对话框中打开
171
+ */
172
+ edit(id: string | number, dialog?: boolean): string;
173
+ /**
174
+ * 删除动作
175
+ * 生成路径: {basePath}/detail/{id},方法: DELETE
176
+ */
177
+ delete(id: string | number): string;
178
+ /**
179
+ * 新建页动作
180
+ * 生成路径: {basePath}/new
181
+ * @param label 按钮标签
182
+ * @param dialog 是否在对话框中打开
183
+ */
184
+ create(dialog?: boolean): string;
185
+ /**
186
+ * 列表页动作
187
+ * 生成路径: {basePath}/list
188
+ */
189
+ list(): string;
190
+ base(): string;
191
+ }
192
+
193
+ /**
194
+ * HtmxAdmin 上下文对象
195
+ * 封装请求处理过程中的状态和操作
196
+ */
197
+
198
+ /**
199
+ * 通知类型
200
+ */
201
+ type NotificationType = "error" | "warning" | "info" | "success";
202
+ /**
203
+ * 通知项
204
+ */
205
+ interface Notification {
206
+ type: NotificationType;
207
+ title: string;
208
+ message: string;
209
+ }
210
+ /**
211
+ * HtmxAdmin 上下文
212
+ * 封装请求处理过程中的所有状态和操作
213
+ */
214
+ declare class HtmxAdminContext {
215
+ /** 模块元数据 */
216
+ readonly moduleMetadata: ModuleTypeInfo;
217
+ /** 插件选项 */
218
+ readonly pluginOptions: Required<HtmxAdminPluginOptions>;
219
+ /** Hono Context */
220
+ readonly ctx: Context;
221
+ /** 之前的模块名 */
222
+ readonly previousModuleName?: string;
223
+ /** 是否是片段请求(HTMX 请求) */
224
+ readonly isFragment: boolean;
225
+ /** 是否是对话框请求 */
226
+ readonly isDialog: boolean;
227
+ /** 用户信息 */
228
+ readonly userInfo: UserInfo | null;
229
+ /** 通知队列 */
230
+ readonly notifications: Notification[];
231
+ /** 页面标题(用于 HX-Title 和页面展示) */
232
+ title: string;
233
+ /** 页面描述(用于SEO和页面展示) */
234
+ description: string;
235
+ /** 面包屑项 */
236
+ breadcrumbs: BreadcrumbItem[];
237
+ /** 主要内容 */
238
+ content: any;
239
+ /** 需要重定向的 URL */
240
+ redirectUrl?: string;
241
+ /** 是否需要刷新页面(用于 HX-Refresh) */
242
+ refresh: boolean;
243
+ constructor(ctx: Context, userInfo: UserInfo | null, moduleMetadata: ModuleTypeInfo, pluginOptions: Required<HtmxAdminPluginOptions>);
244
+ /**
245
+ * 发送通知
246
+ * 通知将在响应时通过 OOB 更新到错误容器
247
+ */
248
+ sendNotification(type: NotificationType, title: string, message: string): void;
249
+ /**
250
+ * 发送错误通知(便捷方法)
251
+ */
252
+ sendError(title: string, message: string): void;
253
+ /**
254
+ * 发送警告通知(便捷方法)
255
+ */
256
+ sendWarning(title: string, message: string): void;
257
+ /**
258
+ * 发送信息通知(便捷方法)
259
+ */
260
+ sendInfo(title: string, message: string): void;
261
+ /**
262
+ * 发送成功通知(便捷方法)
263
+ */
264
+ sendSuccess(title: string, message: string): void;
265
+ /**
266
+ * 设置需要推送的 URL
267
+ * 用于 HX-Push-Url 响应头
268
+ */
269
+ redirect(url: string): void;
270
+ /**
271
+ * 设置需要刷新页面
272
+ * 用于 HX-Refresh 响应头
273
+ */
274
+ setRefresh(refresh?: boolean): void;
275
+ /**
276
+ * 检查是否有列表页面
277
+ * 封装 moduleMetadata 访问,避免直接访问内部属性
278
+ */
279
+ hasList(): boolean;
280
+ /**
281
+ * 检查是否有详情页面
282
+ * 封装 moduleMetadata 访问,避免直接访问内部属性
283
+ */
284
+ hasDetail(): boolean;
285
+ /**
286
+ * 检查是否有表单页面
287
+ * 封装 moduleMetadata 访问,避免直接访问内部属性
288
+ */
289
+ hasForm(): boolean;
290
+ /**
291
+ * 检查是否有自定义页面
292
+ * 封装 moduleMetadata 访问,避免直接访问内部属性
293
+ */
294
+ hasCustom(): boolean;
295
+ }
296
+
297
+ /**
298
+ * Page 模块基类
299
+ * 所有页面模块的基类,提供通用的属性和方法
300
+ */
301
+
302
+ /**
303
+ * Page 页面模块基类
304
+ * 所有页面模块都继承此类,包括 ListPageModule、DetailPageModule、FormPageModule
305
+ *
306
+ * 对于 custom 类型的模块,必须实现 render 方法
307
+ * 对于其他类型的模块,可以重写 render 方法来自定义渲染,否则使用默认渲染逻辑
308
+ */
309
+ declare abstract class PageModule {
310
+ /** HtmxAdmin 上下文对象 */
311
+ context: HtmxAdminContext;
312
+ /** Action Helper 实例 */
313
+ paths: PathHelper;
314
+ /**
315
+ * 初始化模块实例(私有方法,仅由 RouteHandler 调用)
316
+ * 用于设置模块的基础属性
317
+ */
318
+ __init(context: HtmxAdminContext): void;
319
+ /**
320
+ * 获取页面标题
321
+ * 子类可以重写此方法来返回页面标题
322
+ * 默认实现:使用模块名
323
+ */
324
+ getTitle(): string;
325
+ /**
326
+ * 获取页面描述
327
+ * 子类可以重写此方法来返回页面描述(用于SEO和页面展示)
328
+ * 默认实现:返回空字符串
329
+ */
330
+ getDescription(): string;
331
+ /**
332
+ * 获取面包屑
333
+ * 子类可以重写此方法来自定义面包屑
334
+ * 默认实现:首页 => 自定义页面
335
+ */
336
+ getBreadcrumbs(): BreadcrumbItem[];
337
+ /**
338
+ * 处理请求的统一入口(由 RouteHandler 调用)
339
+ * 默认实现:直接调用 render 方法
340
+ * 子类可以重写此方法来处理请求级别的逻辑(如根据 HTTP method 分发)
341
+ *
342
+ * @param adminContext HtmxAdmin 上下文对象(必需),包含请求状态和 helper 方法
343
+ * @returns 页面内容
344
+ */
345
+ __handle(): Promise<any>;
346
+ /**
347
+ * 渲染页面内容
348
+ *
349
+ * 所有页面模块都必须提供 render 方法
350
+ * - Custom 类型:必须实现此方法
351
+ * - List/Detail/Form 类型:基类提供默认实现,可以重写来自定义渲染
352
+ *
353
+ * @param adminContext HtmxAdmin 上下文对象(必需),包含请求状态和 helper 方法
354
+ * 可以通过 adminContext.ctx 访问 Hono Context
355
+ */
356
+ abstract render(): any | Promise<any>;
357
+ }
358
+
359
+ /**
360
+ * Detail 模块基类
361
+ * 用于详情展示,继承自 PageModule
362
+ */
363
+
364
+ /**
365
+ * Detail 页面模块基类
366
+ * 继承自 PageModule,提供详情页面的默认行为
367
+ *
368
+ * 可以重写 render 方法来自定义渲染,否则使用默认的详情渲染逻辑
369
+ */
370
+ declare abstract class DetailPageModule<T = any> extends PageModule {
371
+ /** ID 字段名(默认 "id") */
372
+ protected readonly idField: string;
373
+ /**
374
+ * 获取数据源(抽象方法,必须实现)
375
+ * 子类必须实现此方法来提供数据源
376
+ */
377
+ abstract getDatasource(): DetailDatasource<T>;
378
+ /**
379
+ * 获取字段标签(可选)
380
+ * 子类可以重写此方法来自定义字段的中文标签
381
+ */
382
+ getFieldLabel?(field: string): string;
383
+ /**
384
+ * 渲染字段值(可选)
385
+ * 子类可以重写此方法来自定义字段的渲染方式
386
+ */
387
+ renderField?(field: string, value: any, item: T): any;
388
+ /**
389
+ * 获取字段分组(可选)
390
+ * 子类可以重写此方法来定义字段分组
391
+ * 返回 null 或 undefined 表示不分组,平铺显示
392
+ */
393
+ getFieldGroups?(item: T): Array<{
394
+ title: string;
395
+ fields: string[];
396
+ }> | null;
397
+ /**
398
+ * 获取可见字段列表(可选)
399
+ * 子类可以重写此方法来控制字段的显示顺序和可见性
400
+ * 返回 null 或 undefined 表示显示所有字段
401
+ */
402
+ getVisibleFields?(item: T): string[] | null;
403
+ /**
404
+ * 获取详情页操作按钮(可选)
405
+ * 子类可以重写此方法来添加详情页的操作按钮
406
+ * 如果不定义,则根据模块元数据智能生成默认操作按钮
407
+ */
408
+ getDetailActions?(item: T): Array<{
409
+ label: string;
410
+ href: string | ((item: T) => string);
411
+ method?: string;
412
+ class?: string;
413
+ }>;
414
+ /**
415
+ * 渲染详情页面(默认实现)
416
+ * 子类可以重写此方法来自定义渲染
417
+ */
418
+ render(): Promise<any>;
419
+ }
420
+
421
+ /**
422
+ * Form 模块基类
423
+ * 用于表单(新建/编辑),继承自 PageModule
424
+ */
425
+
426
+ /**
427
+ * Form 页面模块基类
428
+ * 继承自 PageModule,提供表单页面的默认行为
429
+ *
430
+ * 可以重写 render 方法来自定义渲染,否则使用默认的表单渲染逻辑
431
+ */
432
+ declare abstract class FormPageModule<T = any> extends PageModule {
433
+ /** ID 字段名(默认 "id") */
434
+ protected idField: string;
435
+ /** Zod Schema(可选,如果提供则自动生成表单字段和校验) */
436
+ protected schema?: z.ZodObject<any>;
437
+ constructor(schema?: z.ZodObject<any>);
438
+ /**
439
+ * 获取数据源(抽象方法,必须实现)
440
+ * 子类必须实现此方法来提供数据源
441
+ */
442
+ abstract getDatasource(): FormDatasource<T>;
443
+ /**
444
+ * 获取单条数据(编辑时使用)
445
+ */
446
+ getItem(id: string | number): Promise<T | null>;
447
+ /**
448
+ * 获取字段标签(可选)
449
+ * 子类可以重写此方法来自定义字段的中文标签
450
+ */
451
+ getFieldLabel?(field: string): string;
452
+ /**
453
+ * 获取表单字段定义
454
+ *
455
+ * 如果提供了 schema,则自动从 schema 生成字段定义
456
+ * 否则子类必须实现此方法来定义表单的字段
457
+ */
458
+ getFormFields(item: T | null): Array<{
459
+ name: string;
460
+ label: string;
461
+ type?: "text" | "email" | "number" | "textarea" | "select" | "date" | "datetime-local";
462
+ required?: boolean;
463
+ placeholder?: string;
464
+ options?: Array<{
465
+ value: string | number;
466
+ label: string;
467
+ }>;
468
+ }>;
469
+ /**
470
+ * 获取字段标签映射(可选)
471
+ * 用于覆盖从 schema description 提取的标签
472
+ */
473
+ getFieldLabels?(): Record<string, string>;
474
+ /**
475
+ * 获取字段占位符映射(可选)
476
+ */
477
+ getFieldPlaceholders?(): Record<string, string>;
478
+ /**
479
+ * 获取字段选项映射(可选)
480
+ * 用于覆盖从 schema enum 提取的选项
481
+ */
482
+ getFieldOptions?(): Record<string, Array<{
483
+ value: string | number;
484
+ label: string;
485
+ }>>;
486
+ /**
487
+ * 获取字段类型映射(可选)
488
+ * 用于覆盖自动推断的类型
489
+ */
490
+ getFieldTypes?(): Record<string, "text" | "email" | "number" | "textarea" | "select" | "date" | "datetime-local">;
491
+ /**
492
+ * 获取要排除的字段列表(可选)
493
+ */
494
+ getExcludeFields?(): string[];
495
+ /**
496
+ * 验证表单数据
497
+ *
498
+ * 如果提供了 schema,则自动使用 schema 进行校验
499
+ * 否则子类可以重写此方法来验证表单数据
500
+ */
501
+ validateFormData(data: Record<string, any>, item: T | null): string | null;
502
+ /**
503
+ * 处理请求的统一入口(重写基类方法)
504
+ * 根据 HTTP method 处理不同请求:
505
+ * - GET: 渲染表单页面(调用 render)
506
+ * - POST: 创建数据
507
+ * - PUT: 更新数据
508
+ * - DELETE: 删除数据
509
+ * 子类可以重写此方法来自定义请求处理逻辑
510
+ */
511
+ __handle(): Promise<any>;
512
+ /**
513
+ * 渲染表单页面(默认实现)
514
+ * 子类可以重写此方法来自定义渲染
515
+ * @param formData 表单数据(用于回填验证失败时的值)
516
+ */
517
+ render(formData?: Record<string, any>): Promise<any>;
518
+ /**
519
+ * 处理创建请求(POST)
520
+ */
521
+ private handleCreate;
522
+ /**
523
+ * 处理更新请求(PUT)
524
+ */
525
+ private handleUpdate;
526
+ /**
527
+ * 处理删除请求(DELETE)
528
+ * 注意:FormDatasource 不包含 deleteItem,删除操作通常由 List 或 Detail 模块处理
529
+ * 这里提供默认实现,子类可以重写
530
+ */
531
+ private handleDelete;
532
+ /**
533
+ * 渲染表单页面(辅助方法)
534
+ * 用于在验证失败时重新渲染表单页面
535
+ * @param adminContext 上下文对象
536
+ * @param item 原始数据项(编辑时)
537
+ * @param isEdit 是否是编辑模式
538
+ * @param formData 表单数据(用于回填验证失败时的值)
539
+ */
540
+ private renderFormPage;
541
+ }
542
+
543
+ /**
544
+ * List 模块基类
545
+ * 用于列表展示,继承自 PageModule
546
+ */
547
+
548
+ /**
549
+ * List 页面模块基类
550
+ * 继承自 PageModule,提供列表页面的默认行为
551
+ *
552
+ * 可以重写 render 方法来自定义渲染,否则使用默认的列表渲染逻辑
553
+ */
554
+ declare abstract class ListPageModule<T extends {
555
+ id: string | number;
556
+ } = {
557
+ id: string | number;
558
+ }> extends PageModule {
559
+ /** ID 字段名(默认 "id") */
560
+ protected readonly idField: string;
561
+ /**
562
+ * 获取数据源(抽象方法,必须实现)
563
+ * 子类必须实现此方法来提供数据源
564
+ */
565
+ abstract getDatasource(): ListDatasource<T>;
566
+ /**
567
+ * 获取列表数据
568
+ */
569
+ getList(params: ListParams): Promise<ListResult<T>>;
570
+ /**
571
+ * 删除数据(可选,如果数据源支持删除)
572
+ */
573
+ deleteItem(id: string | number): Promise<boolean>;
574
+ /**
575
+ * 获取字段标签(可选)
576
+ * 子类可以重写此方法来自定义字段的中文标签
577
+ */
578
+ getFieldLabel?(field: string): string;
579
+ /**
580
+ * 自定义列渲染(可选)
581
+ * 子类可以重写此方法来自定义列的渲染逻辑
582
+ */
583
+ renderColumn?(field: string, value: any, item: T): any;
584
+ /**
585
+ * 获取统计信息(可选)
586
+ * 子类可以重写此方法来返回 KPI 统计卡片数据
587
+ * 返回的数组将渲染为 StatCard 组件
588
+ */
589
+ getStats?(params: ListParams): Promise<Array<{
590
+ title: string;
591
+ value: string | number;
592
+ change?: number;
593
+ changeLabel?: string;
594
+ iconColor?: "blue" | "green" | "yellow" | "purple" | "red" | "indigo";
595
+ icon?: any;
596
+ }>> | Array<{
597
+ title: string;
598
+ value: string | number;
599
+ change?: number;
600
+ changeLabel?: string;
601
+ iconColor?: "blue" | "green" | "yellow" | "purple" | "red" | "indigo";
602
+ icon?: any;
603
+ }>;
604
+ /**
605
+ * 获取筛选器配置(可选)
606
+ * 子类可以重写此方法来返回筛选器字段配置
607
+ * 返回的配置将渲染为 FilterCard 组件
608
+ */
609
+ getFilters?(params: ListParams): Array<{
610
+ name: string;
611
+ label: string;
612
+ options: Array<{
613
+ value: string | number;
614
+ label: string;
615
+ disabled?: boolean;
616
+ }>;
617
+ value?: string | number;
618
+ defaultValue?: string | number;
619
+ }>;
620
+ /**
621
+ * 获取表格标题(可选)
622
+ * 子类可以重写此方法来返回表格标题
623
+ * 如果不定义,默认使用模块名
624
+ */
625
+ getTableTitle?(): string;
626
+ /**
627
+ * 获取表格操作按钮(可选)
628
+ * 子类可以重写此方法来返回表格操作按钮配置(如导出、清空、刷新等)
629
+ * 如果不定义,默认会生成一个刷新按钮
630
+ */
631
+ getTableActions?(params: ListParams, basePath: string): Array<{
632
+ label: string;
633
+ href?: string;
634
+ hxGet?: string;
635
+ hxPost?: string;
636
+ hxDelete?: string;
637
+ variant?: "primary" | "secondary" | "danger" | "ghost";
638
+ hxConfirm?: string;
639
+ }>;
640
+ /**
641
+ * 自定义操作按钮(可选)
642
+ * 子类可以重写此方法来添加自定义操作按钮
643
+ * 如果不定义,则根据模块元数据智能生成默认操作按钮
644
+ */
645
+ getActions?(item: T): Array<{
646
+ label: string;
647
+ href: string | ((item: T) => string);
648
+ method?: string;
649
+ class?: string;
650
+ }>;
651
+ /**
652
+ * 渲染列表页面(默认实现)
653
+ * 子类可以重写此方法来自定义渲染
654
+ */
655
+ render(): Promise<any>;
656
+ }
657
+
658
+ /**
659
+ * 数据源接口和基础实现
660
+ */
661
+
662
+ /**
663
+ * 内存数据源(完整实现,可用于 list、detail、form 类型)
664
+ */
665
+ declare class MemoryListDatasource<T extends {
666
+ id: string | number;
667
+ }> implements ListDatasource<T>, DetailDatasource<T>, FormDatasource<T> {
668
+ private data;
669
+ constructor(data?: T[]);
670
+ getList(params?: ListParams): Promise<ListResult<T>>;
671
+ getItem(id: string | number): Promise<T | null>;
672
+ deleteItem(id: string | number): Promise<boolean>;
673
+ updateItem(id: string | number, data: Partial<T>): Promise<T | null>;
674
+ createItem(data: Partial<T>): Promise<T>;
675
+ }
676
+
677
+ /**
678
+ * HtmxAdminPlugin - 管理后台插件
679
+ * 使用 HTMX + Tailwind + Hyperscript + JSX 快速构建管理后台
680
+ */
681
+
682
+ /**
683
+ * HtmxAdminPlugin
684
+ */
685
+ declare class HtmxAdminPlugin implements Plugin<HtmxAdminModuleOptions> {
686
+ readonly name = "htmx-admin-plugin";
687
+ readonly priority = PluginPriority.ROUTE;
688
+ private engine;
689
+ private hono;
690
+ private options;
691
+ private moduleTypeMap;
692
+ constructor(options?: HtmxAdminPluginOptions);
693
+ /**
694
+ * 声明Module配置Schema
695
+ */
696
+ getModuleOptionsSchema(): PluginModuleOptionsSchema<HtmxAdminModuleOptions>;
697
+ /**
698
+ * 引擎初始化钩子
699
+ */
700
+ onInit(engine: Microservice): void;
701
+ /**
702
+ * 检查并注册模块
703
+ */
704
+ private checkAndRegisterModules;
705
+ /**
706
+ * 注册路由
707
+ */
708
+ private registerRoutes;
709
+ /**
710
+ * 模块加载钩子:检查模块类型约束并注册路由
711
+ */
712
+ onModuleLoad(modules: ModuleMetadata[]): void;
713
+ }
714
+
715
+ /**
716
+ * 渲染工具函数
717
+ */
718
+ /**
719
+ * 安全渲染值(支持 JSX 和字符串 HTML)
720
+ * 如果返回的是字符串 HTML,将其转换为 JSX 元素
721
+ */
722
+ declare function safeRender(value: any): any;
723
+
724
+ /**
725
+ * 表单组件(用于编辑和新建)
726
+ */
727
+ /**
728
+ * 字段定义
729
+ */
730
+ interface FormField$1 {
731
+ /** 字段名 */
732
+ name: string;
733
+ /** 字段标签 */
734
+ label: string;
735
+ /** 字段类型 */
736
+ type?: "text" | "email" | "number" | "textarea" | "select" | "date" | "datetime-local";
737
+ /** 是否必填 */
738
+ required?: boolean;
739
+ /** 占位符 */
740
+ placeholder?: string;
741
+ /** 选项(用于 select 类型) */
742
+ options?: Array<{
743
+ value: string | number;
744
+ label: string;
745
+ }>;
746
+ /** 自定义渲染函数 */
747
+ render?: (value: any, item: any) => any;
748
+ }
749
+ /**
750
+ * 表单组件 Props
751
+ */
752
+ interface FormProps<T = any> {
753
+ /** 数据项(编辑时传入,新建时为 null) */
754
+ item: T | null;
755
+ /** 字段定义列表 */
756
+ fields: FormField$1[];
757
+ /** 提交 URL */
758
+ submitUrl: string;
759
+ /** 提交方法(默认 PUT) */
760
+ method?: "PUT" | "POST";
761
+ /** 提交后重定向 URL */
762
+ redirectUrl?: string;
763
+ /** 页面标题(默认 "编辑" 或 "新建") */
764
+ title?: string;
765
+ /** 取消按钮 URL */
766
+ cancelUrl?: string;
767
+ /** 是否在对话框中显示 */
768
+ isDialog?: boolean;
769
+ /** 表单数据(用于回填验证失败时的值) */
770
+ formData?: Record<string, any>;
771
+ }
772
+ /**
773
+ * 表单组件
774
+ */
775
+ declare const Form: <T extends Record<string, any>>(props: FormProps<T>) => hono_jsx_jsx_dev_runtime.JSX.Element;
776
+
777
+ /**
778
+ * Zod Schema 表单工具
779
+ * 从 Zod Schema 自动生成表单字段定义和校验逻辑
780
+ */
781
+
782
+ /**
783
+ * 从 Zod Object Schema 生成表单字段定义
784
+ */
785
+ declare function generateFormFieldsFromSchema<T extends z.ZodObject<any>>(schema: T, options?: {
786
+ /** 字段标签映射(覆盖从 description 提取的标签) */
787
+ fieldLabels?: Record<string, string>;
788
+ /** 字段占位符映射 */
789
+ fieldPlaceholders?: Record<string, string>;
790
+ /** 字段选项映射(覆盖从 enum 提取的选项) */
791
+ fieldOptions?: Record<string, Array<{
792
+ value: string | number;
793
+ label: string;
794
+ }>>;
795
+ /** 字段类型映射(覆盖自动推断的类型) */
796
+ fieldTypes?: Record<string, FormField$1["type"]>;
797
+ /** 要排除的字段 */
798
+ excludeFields?: string[];
799
+ }): FormField$1[];
800
+ /**
801
+ * 使用 Zod Schema 验证表单数据
802
+ */
803
+ declare function validateFormDataWithSchema<T extends z.ZodObject<any>>(schema: T, data: Record<string, any>): {
804
+ success: true;
805
+ data: z.infer<T>;
806
+ } | {
807
+ success: false;
808
+ error: string;
809
+ };
810
+
811
+ /**
812
+ * 操作按钮组件
813
+ */
814
+ interface ActionButtonProps {
815
+ /** 按钮文本 */
816
+ label: string;
817
+ /** 链接地址 */
818
+ href: string | ((item: any) => string);
819
+ /** HTTP 方法 */
820
+ method?: string;
821
+ /** 自定义类名 */
822
+ className?: string;
823
+ /** 数据项(用于生成动态链接) */
824
+ item?: any;
825
+ }
826
+ /**
827
+ * 操作按钮组件
828
+ */
829
+ declare const ActionButton: (props: ActionButtonProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
830
+
831
+ /**
832
+ * 最近活动卡片组件
833
+ */
834
+ interface ActivityItem {
835
+ /** 活动描述 */
836
+ description: string;
837
+ /** 时间(如"2分钟前") */
838
+ time: string;
839
+ /** 活动类型颜色(blue, green, purple, gray等) */
840
+ color?: "blue" | "green" | "purple" | "gray" | "yellow" | "red";
841
+ }
842
+ interface ActivityCardProps {
843
+ /** 标题 */
844
+ title: string;
845
+ /** 活动列表 */
846
+ activities: ActivityItem[];
847
+ /** 自定义类名 */
848
+ className?: string;
849
+ }
850
+ /**
851
+ * 最近活动卡片组件
852
+ * 用于展示最近的活动记录列表
853
+ */
854
+ declare const ActivityCard: (props: ActivityCardProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
855
+
856
+ /**
857
+ * 徽章组件(用于标签显示)
858
+ */
859
+ interface BadgeProps {
860
+ /** 标签文本 */
861
+ children: any;
862
+ /** 颜色主题 */
863
+ variant?: "blue" | "green" | "yellow" | "red" | "gray" | "purple" | "indigo";
864
+ /** 自定义类名 */
865
+ className?: string;
866
+ }
867
+ /**
868
+ * 徽章组件
869
+ * 用于显示状态标签,如日志级别、状态等
870
+ */
871
+ declare const Badge: (props: BadgeProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
872
+
873
+ /**
874
+ * 按钮组件
875
+ */
876
+ interface ButtonProps {
877
+ /** 按钮文本 */
878
+ children: any;
879
+ /** 按钮类型 */
880
+ variant?: "primary" | "secondary" | "danger" | "ghost";
881
+ /** 按钮大小 */
882
+ size?: "sm" | "md" | "lg";
883
+ /** 是否禁用 */
884
+ disabled?: boolean;
885
+ /** 自定义类名 */
886
+ className?: string;
887
+ /** HTMX 属性 */
888
+ hxGet?: string;
889
+ hxPost?: string;
890
+ hxPut?: string;
891
+ hxDelete?: string;
892
+ hxTarget?: string;
893
+ hxSwap?: string;
894
+ hxPushUrl?: string | boolean;
895
+ hxIndicator?: string;
896
+ hxConfirm?: string;
897
+ hxHeaders?: string;
898
+ /** 其他属性 */
899
+ [key: string]: any;
900
+ }
901
+ /**
902
+ * 按钮组件
903
+ */
904
+ declare const Button: (props: ButtonProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
905
+
906
+ /**
907
+ * 卡片组件
908
+ */
909
+ interface CardProps {
910
+ /** 卡片内容 */
911
+ children: any;
912
+ /** 卡片标题 */
913
+ title?: string;
914
+ /** 自定义类名 */
915
+ className?: string;
916
+ /** 是否显示阴影 */
917
+ shadow?: boolean;
918
+ /** 是否显示边框 */
919
+ bordered?: boolean;
920
+ /** 是否去掉内边距 */
921
+ noPadding?: boolean;
922
+ }
923
+ /**
924
+ * 卡片组件
925
+ */
926
+ declare const Card: (props: CardProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
927
+
928
+ /**
929
+ * 详情页面组件
930
+ */
931
+ /**
932
+ * 字段组定义
933
+ */
934
+ interface FieldGroup {
935
+ title: string;
936
+ fields: string[];
937
+ }
938
+ /**
939
+ * 详情页面组件 Props
940
+ */
941
+ interface DetailProps<T = any> {
942
+ /** 数据项 */
943
+ item: T;
944
+ /** 字段标签映射(字段名 -> 中文标签) */
945
+ fieldLabels?: Record<string, string>;
946
+ /** 字段渲染函数(字段名 -> 渲染函数) */
947
+ fieldRenderers?: Record<string, (value: any, item: T) => any>;
948
+ /** 字段分组(可选,如果不提供则平铺显示) */
949
+ fieldGroups?: FieldGroup[];
950
+ /** 可见字段列表(控制显示顺序和可见性) */
951
+ visibleFields?: string[];
952
+ /** 操作按钮 */
953
+ actions?: Array<{
954
+ label: string;
955
+ href: string | ((item: T) => string);
956
+ method?: string;
957
+ class?: string;
958
+ }>;
959
+ /** 页面标题(默认 "详情") */
960
+ title?: string;
961
+ /** 是否在对话框中显示 */
962
+ isDialog?: boolean;
963
+ }
964
+ /**
965
+ * 详情页面组件
966
+ */
967
+ declare const Detail: <T extends Record<string, any>>(props: DetailProps<T>) => hono_jsx_jsx_dev_runtime.JSX.Element;
968
+
969
+ /**
970
+ * DetailContent - 详情内容组件(纯组件)
971
+ * 接收渲染所需的数据,渲染详情页面内容
972
+ */
973
+ /**
974
+ * 详情内容组件 Props
975
+ */
976
+ interface DetailContentProps<T = any> {
977
+ /** 数据项 */
978
+ item: T;
979
+ /** 字段标签映射 */
980
+ fieldLabels: Record<string, string>;
981
+ /** 字段渲染器映射 */
982
+ fieldRenderers?: Record<string, (value: any, item: T) => any>;
983
+ /** 字段分组 */
984
+ fieldGroups?: Array<{
985
+ title: string;
986
+ fields: string[];
987
+ }>;
988
+ /** 可见字段列表 */
989
+ visibleFields?: string[];
990
+ /** 操作按钮配置 */
991
+ actions?: Array<{
992
+ label: string;
993
+ href: string | ((item: T) => string);
994
+ method?: string;
995
+ class?: string;
996
+ }>;
997
+ /** 页面标题 */
998
+ title: string;
999
+ /** 是否是对话框模式 */
1000
+ isDialog: boolean;
1001
+ }
1002
+ /**
1003
+ * 详情内容组件
1004
+ */
1005
+ declare function DetailContent<T extends Record<string, any> = Record<string, any>>(props: DetailContentProps<T>): hono_jsx_jsx_dev_runtime.JSX.Element;
1006
+
1007
+ /**
1008
+ * 对话框组件(Modal/Dialog)
1009
+ */
1010
+ interface DialogProps {
1011
+ /** 对话框标题 */
1012
+ title?: string;
1013
+ /** 对话框内容 */
1014
+ children: any;
1015
+ /** 是否显示关闭按钮 */
1016
+ showClose?: boolean;
1017
+ /** 关闭时的回调 URL(用于关闭对话框) */
1018
+ closeUrl?: string;
1019
+ /** 自定义类名 */
1020
+ className?: string;
1021
+ /** 对话框大小 */
1022
+ size?: "sm" | "md" | "lg" | "xl" | "full";
1023
+ }
1024
+ /**
1025
+ * 对话框组件
1026
+ * 用于在模态框中显示内容,支持 HTMX 交互
1027
+ */
1028
+ declare const Dialog: (props: DialogProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1029
+
1030
+ /**
1031
+ * 空状态组件
1032
+ */
1033
+ interface EmptyStateProps {
1034
+ /** 提示文本 */
1035
+ message?: string;
1036
+ /** 自定义内容 */
1037
+ children?: any;
1038
+ }
1039
+ /**
1040
+ * 空状态组件
1041
+ */
1042
+ declare const EmptyState: (props: EmptyStateProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1043
+
1044
+ interface ErrorAlertProps {
1045
+ /** 错误标题 */
1046
+ title?: string;
1047
+ /** 错误消息 */
1048
+ message: string;
1049
+ /** 错误类型 */
1050
+ type?: NotificationType;
1051
+ /** 是否显示关闭按钮 */
1052
+ showClose?: boolean;
1053
+ /** 自定义类名 */
1054
+ className?: string;
1055
+ }
1056
+ /**
1057
+ * 错误提示组件
1058
+ * 用于显示错误、警告或信息提示
1059
+ */
1060
+ declare const ErrorAlert: (props: ErrorAlertProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1061
+
1062
+ /**
1063
+ * 选择框组件
1064
+ */
1065
+ interface SelectOption {
1066
+ value: string | number;
1067
+ label: string;
1068
+ disabled?: boolean;
1069
+ }
1070
+ interface SelectProps {
1071
+ /** 字段ID */
1072
+ id?: string;
1073
+ /** 字段名 */
1074
+ name: string;
1075
+ /** 字段值 */
1076
+ value?: string | number;
1077
+ /** 默认值 */
1078
+ defaultValue?: string | number;
1079
+ /** 是否必填 */
1080
+ required?: boolean;
1081
+ /** 是否禁用 */
1082
+ disabled?: boolean;
1083
+ /** 选项列表 */
1084
+ options: SelectOption[];
1085
+ /** 占位符选项(当required为false时显示) */
1086
+ placeholder?: string;
1087
+ /** 自定义类名 */
1088
+ className?: string;
1089
+ /** 其他属性 */
1090
+ [key: string]: any;
1091
+ }
1092
+ /**
1093
+ * 选择框组件
1094
+ */
1095
+ declare const Select: (props: SelectProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1096
+
1097
+ interface FilterField {
1098
+ /** 字段名 */
1099
+ name: string;
1100
+ /** 字段标签 */
1101
+ label: string;
1102
+ /** 选项列表 */
1103
+ options: SelectOption[];
1104
+ /** 当前值 */
1105
+ value?: string | number;
1106
+ /** 默认值 */
1107
+ defaultValue?: string | number;
1108
+ }
1109
+ interface FilterCardProps {
1110
+ /** 标题 */
1111
+ title?: string;
1112
+ /** 筛选字段列表 */
1113
+ fields: FilterField[];
1114
+ /** 筛选按钮文本 */
1115
+ filterButtonText?: string;
1116
+ /** 筛选按钮的 HTMX 属性 */
1117
+ filterButtonHxGet?: string;
1118
+ /** 需要保留的查询参数名列表(如排序参数) */
1119
+ preserveParams?: string[];
1120
+ /** 自定义类名 */
1121
+ className?: string;
1122
+ }
1123
+ /**
1124
+ * 筛选卡片组件
1125
+ * 用于展示筛选表单,包含多个下拉选择器和筛选按钮
1126
+ */
1127
+ declare const FilterCard: (props: FilterCardProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1128
+
1129
+ /**
1130
+ * 列表内容组件 Props
1131
+ */
1132
+ interface ListContentProps<T = any> {
1133
+ /** 列表查询结果 */
1134
+ result: ListResult<T>;
1135
+ /** 列表查询参数 */
1136
+ params: ListParams;
1137
+ /** 页面标题 */
1138
+ pageTitle: string;
1139
+ /** 页面描述 */
1140
+ pageDescription?: string;
1141
+ /** 表格标题 */
1142
+ tableTitle: string;
1143
+ /** 列定义 */
1144
+ columns: Array<{
1145
+ key: string;
1146
+ label: string;
1147
+ render?: (value: any, item: T) => any;
1148
+ }>;
1149
+ /** 操作按钮配置 */
1150
+ actions?: Array<{
1151
+ label: string;
1152
+ href: string | ((item: T) => string);
1153
+ method?: string;
1154
+ class?: string;
1155
+ }>;
1156
+ /** 统计信息(KPI卡片) */
1157
+ stats?: Array<{
1158
+ title: string;
1159
+ value: string | number;
1160
+ change?: number;
1161
+ changeLabel?: string;
1162
+ iconColor?: "blue" | "green" | "yellow" | "purple" | "red" | "indigo";
1163
+ icon?: any;
1164
+ }>;
1165
+ /** 筛选器配置 */
1166
+ filters?: Array<{
1167
+ name: string;
1168
+ label: string;
1169
+ options: Array<{
1170
+ value: string | number;
1171
+ label: string;
1172
+ disabled?: boolean;
1173
+ }>;
1174
+ value?: string | number;
1175
+ defaultValue?: string | number;
1176
+ }>;
1177
+ /** 表格操作按钮 */
1178
+ tableActions?: Array<{
1179
+ label: string;
1180
+ href?: string;
1181
+ hxGet?: string;
1182
+ hxPost?: string;
1183
+ hxDelete?: string;
1184
+ variant?: "primary" | "secondary" | "danger" | "ghost";
1185
+ hxConfirm?: string;
1186
+ }>;
1187
+ /** 是否有 form 模块(用于决定是否显示新建按钮) */
1188
+ hasFormModule: boolean;
1189
+ /** 新建按钮路径 */
1190
+ createPath: string;
1191
+ /** 列表路径(用于分页和筛选) */
1192
+ listPath: string;
1193
+ }
1194
+ /**
1195
+ * 列表内容组件
1196
+ */
1197
+ declare function ListContent<T extends {
1198
+ id: string | number;
1199
+ } = {
1200
+ id: string | number;
1201
+ }>(props: ListContentProps<T>): hono_jsx_jsx_dev_runtime.JSX.Element;
1202
+
1203
+ /**
1204
+ * 页面标题组件
1205
+ */
1206
+ interface PageHeaderProps {
1207
+ /** 标题 */
1208
+ title: string;
1209
+ /** 描述文本 */
1210
+ description?: string;
1211
+ /** 右侧操作按钮 */
1212
+ actions?: any;
1213
+ /** 自定义类名 */
1214
+ className?: string;
1215
+ }
1216
+ /**
1217
+ * 页面标题组件
1218
+ */
1219
+ declare const PageHeader: (props: PageHeaderProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1220
+
1221
+ /**
1222
+ * 分页组件
1223
+ */
1224
+ interface PaginationProps {
1225
+ /** 当前页码 */
1226
+ page: number;
1227
+ /** 每页数量 */
1228
+ pageSize: number;
1229
+ /** 总记录数 */
1230
+ total: number;
1231
+ /** 总页数 */
1232
+ totalPages: number;
1233
+ /** 基础 URL */
1234
+ baseUrl: string;
1235
+ /** 当前查询参数(用于保留筛选条件等) */
1236
+ currentParams?: Record<string, string | number | undefined>;
1237
+ }
1238
+ /**
1239
+ * 分页组件
1240
+ */
1241
+ declare const Pagination: (props: PaginationProps) => hono_jsx_jsx_dev_runtime.JSX.Element | null;
1242
+
1243
+ /**
1244
+ * 统计卡片组件(KPI卡片)
1245
+ */
1246
+ interface StatCardProps {
1247
+ /** 标题 */
1248
+ title: string;
1249
+ /** 数值 */
1250
+ value: string | number;
1251
+ /** 变化百分比(正数表示增长,负数表示下降) */
1252
+ change?: number;
1253
+ /** 变化描述(如"相比上月") */
1254
+ changeLabel?: string;
1255
+ /** 图标颜色(blue, green, yellow, purple等) */
1256
+ iconColor?: "blue" | "green" | "yellow" | "purple" | "red" | "indigo";
1257
+ /** 自定义图标(SVG或emoji) */
1258
+ icon?: any;
1259
+ /** 自定义类名 */
1260
+ className?: string;
1261
+ }
1262
+ /**
1263
+ * 统计卡片组件
1264
+ * 用于展示关键指标,包含标题、数值、变化趋势和图标
1265
+ */
1266
+ declare const StatCard: (props: StatCardProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1267
+
1268
+ /**
1269
+ * 系统状态卡片组件
1270
+ */
1271
+ interface StatusItem {
1272
+ /** 状态名称 */
1273
+ label: string;
1274
+ /** 当前值(百分比或文本) */
1275
+ value: string | number;
1276
+ /** 进度条百分比(0-100) */
1277
+ progress?: number;
1278
+ /** 进度条颜色 */
1279
+ color?: "blue" | "green" | "orange" | "red" | "purple" | "yellow";
1280
+ /** 是否为文本状态(如"正常") */
1281
+ isText?: boolean;
1282
+ }
1283
+ interface SystemStatusCardProps {
1284
+ /** 标题 */
1285
+ title: string;
1286
+ /** 状态项列表 */
1287
+ statusItems: StatusItem[];
1288
+ /** 自定义类名 */
1289
+ className?: string;
1290
+ }
1291
+ /**
1292
+ * 系统状态卡片组件
1293
+ * 用于展示系统资源使用情况,包含进度条和文本状态
1294
+ */
1295
+ declare const SystemStatusCard: (props: SystemStatusCardProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1296
+
1297
+ /**
1298
+ * 日期输入组件
1299
+ */
1300
+ interface DateInputProps {
1301
+ /** 字段ID */
1302
+ id?: string;
1303
+ /** 字段名 */
1304
+ name: string;
1305
+ /** 日期类型 */
1306
+ type?: "date" | "datetime-local" | "time" | "month" | "week";
1307
+ /** 字段值 */
1308
+ value?: string;
1309
+ /** 默认值 */
1310
+ defaultValue?: string;
1311
+ /** 是否必填 */
1312
+ required?: boolean;
1313
+ /** 是否禁用 */
1314
+ disabled?: boolean;
1315
+ /** 是否只读 */
1316
+ readOnly?: boolean;
1317
+ /** 最小值 */
1318
+ min?: string;
1319
+ /** 最大值 */
1320
+ max?: string;
1321
+ /** 自定义类名 */
1322
+ className?: string;
1323
+ /** 其他属性 */
1324
+ [key: string]: any;
1325
+ }
1326
+ /**
1327
+ * 日期输入组件
1328
+ */
1329
+ declare const DateInput: (props: DateInputProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1330
+
1331
+ /**
1332
+ * 表单字段组件(标签 + 输入框的包装器)
1333
+ */
1334
+ interface FormFieldProps {
1335
+ /** 字段标签 */
1336
+ label: string;
1337
+ /** 字段ID(用于关联label和input) */
1338
+ id: string;
1339
+ /** 是否必填 */
1340
+ required?: boolean;
1341
+ /** 错误信息 */
1342
+ error?: string;
1343
+ /** 帮助文本 */
1344
+ help?: string;
1345
+ /** 子元素(输入框等) */
1346
+ children: any;
1347
+ /** 自定义类名 */
1348
+ className?: string;
1349
+ }
1350
+ /**
1351
+ * 表单字段组件
1352
+ * 提供统一的标签、错误提示、帮助文本样式
1353
+ */
1354
+ declare const FormField: (props: FormFieldProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1355
+
1356
+ /**
1357
+ * 输入框组件
1358
+ */
1359
+ interface InputProps {
1360
+ /** 字段ID */
1361
+ id?: string;
1362
+ /** 字段名 */
1363
+ name: string;
1364
+ /** 字段类型 */
1365
+ type?: "text" | "email" | "password" | "number" | "tel" | "url" | "search";
1366
+ /** 字段值 */
1367
+ value?: string | number;
1368
+ /** 默认值 */
1369
+ defaultValue?: string | number;
1370
+ /** 占位符 */
1371
+ placeholder?: string;
1372
+ /** 是否必填 */
1373
+ required?: boolean;
1374
+ /** 是否禁用 */
1375
+ disabled?: boolean;
1376
+ /** 是否只读 */
1377
+ readOnly?: boolean;
1378
+ /** 最小值(用于number类型) */
1379
+ min?: number;
1380
+ /** 最大值(用于number类型) */
1381
+ max?: number;
1382
+ /** 步长(用于number类型) */
1383
+ step?: number;
1384
+ /** 自定义类名 */
1385
+ className?: string;
1386
+ /** 其他属性 */
1387
+ [key: string]: any;
1388
+ }
1389
+ /**
1390
+ * 输入框组件
1391
+ */
1392
+ declare const Input: (props: InputProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1393
+
1394
+ /**
1395
+ * 文本域组件
1396
+ */
1397
+ interface TextareaProps {
1398
+ /** 字段ID */
1399
+ id?: string;
1400
+ /** 字段名 */
1401
+ name: string;
1402
+ /** 字段值 */
1403
+ value?: string;
1404
+ /** 默认值 */
1405
+ defaultValue?: string;
1406
+ /** 占位符 */
1407
+ placeholder?: string;
1408
+ /** 是否必填 */
1409
+ required?: boolean;
1410
+ /** 是否禁用 */
1411
+ disabled?: boolean;
1412
+ /** 是否只读 */
1413
+ readOnly?: boolean;
1414
+ /** 行数 */
1415
+ rows?: number;
1416
+ /** 自定义类名 */
1417
+ className?: string;
1418
+ /** 其他属性 */
1419
+ [key: string]: any;
1420
+ }
1421
+ /**
1422
+ * 文本域组件
1423
+ */
1424
+ declare const Textarea: (props: TextareaProps) => hono_jsx_jsx_dev_runtime.JSX.Element;
1425
+
1426
+ /**
1427
+ * HtmxAdmin 组件导出
1428
+ * 外部可用的组件通过 Components 命名空间导出
1429
+ */
1430
+
1431
+ declare const index_ActionButton: typeof ActionButton;
1432
+ type index_ActionButtonProps = ActionButtonProps;
1433
+ declare const index_ActivityCard: typeof ActivityCard;
1434
+ type index_ActivityCardProps = ActivityCardProps;
1435
+ type index_ActivityItem = ActivityItem;
1436
+ declare const index_Badge: typeof Badge;
1437
+ type index_BadgeProps = BadgeProps;
1438
+ declare const index_Button: typeof Button;
1439
+ type index_ButtonProps = ButtonProps;
1440
+ declare const index_Card: typeof Card;
1441
+ type index_CardProps = CardProps;
1442
+ declare const index_DateInput: typeof DateInput;
1443
+ type index_DateInputProps = DateInputProps;
1444
+ declare const index_Detail: typeof Detail;
1445
+ declare const index_DetailContent: typeof DetailContent;
1446
+ type index_DetailContentProps<T = any> = DetailContentProps<T>;
1447
+ type index_DetailProps<T = any> = DetailProps<T>;
1448
+ declare const index_Dialog: typeof Dialog;
1449
+ type index_DialogProps = DialogProps;
1450
+ declare const index_EmptyState: typeof EmptyState;
1451
+ type index_EmptyStateProps = EmptyStateProps;
1452
+ declare const index_ErrorAlert: typeof ErrorAlert;
1453
+ type index_ErrorAlertProps = ErrorAlertProps;
1454
+ type index_FieldGroup = FieldGroup;
1455
+ declare const index_FilterCard: typeof FilterCard;
1456
+ type index_FilterCardProps = FilterCardProps;
1457
+ type index_FilterField = FilterField;
1458
+ declare const index_Form: typeof Form;
1459
+ declare const index_FormField: typeof FormField;
1460
+ type index_FormFieldProps = FormFieldProps;
1461
+ type index_FormProps<T = any> = FormProps<T>;
1462
+ declare const index_Input: typeof Input;
1463
+ type index_InputProps = InputProps;
1464
+ declare const index_ListContent: typeof ListContent;
1465
+ type index_ListContentProps<T = any> = ListContentProps<T>;
1466
+ declare const index_PageHeader: typeof PageHeader;
1467
+ type index_PageHeaderProps = PageHeaderProps;
1468
+ declare const index_Pagination: typeof Pagination;
1469
+ type index_PaginationProps = PaginationProps;
1470
+ declare const index_Select: typeof Select;
1471
+ type index_SelectOption = SelectOption;
1472
+ type index_SelectProps = SelectProps;
1473
+ declare const index_StatCard: typeof StatCard;
1474
+ type index_StatCardProps = StatCardProps;
1475
+ type index_StatusItem = StatusItem;
1476
+ declare const index_SystemStatusCard: typeof SystemStatusCard;
1477
+ type index_SystemStatusCardProps = SystemStatusCardProps;
1478
+ declare const index_Textarea: typeof Textarea;
1479
+ type index_TextareaProps = TextareaProps;
1480
+ declare namespace index {
1481
+ export { index_ActionButton as ActionButton, type index_ActionButtonProps as ActionButtonProps, index_ActivityCard as ActivityCard, type index_ActivityCardProps as ActivityCardProps, type index_ActivityItem as ActivityItem, index_Badge as Badge, type index_BadgeProps as BadgeProps, index_Button as Button, type index_ButtonProps as ButtonProps, index_Card as Card, type index_CardProps as CardProps, index_DateInput as DateInput, type index_DateInputProps as DateInputProps, index_Detail as Detail, index_DetailContent as DetailContent, type index_DetailContentProps as DetailContentProps, type index_DetailProps as DetailProps, index_Dialog as Dialog, type index_DialogProps as DialogProps, index_EmptyState as EmptyState, type index_EmptyStateProps as EmptyStateProps, index_ErrorAlert as ErrorAlert, type index_ErrorAlertProps as ErrorAlertProps, type index_FieldGroup as FieldGroup, index_FilterCard as FilterCard, type index_FilterCardProps as FilterCardProps, type index_FilterField as FilterField, index_Form as Form, index_FormField as FormField, type index_FormFieldProps as FormFieldProps, type FormField$1 as FormFieldType, type index_FormProps as FormProps, index_Input as Input, type index_InputProps as InputProps, index_ListContent as ListContent, type index_ListContentProps as ListContentProps, index_PageHeader as PageHeader, type index_PageHeaderProps as PageHeaderProps, index_Pagination as Pagination, type index_PaginationProps as PaginationProps, index_Select as Select, type index_SelectOption as SelectOption, type index_SelectProps as SelectProps, index_StatCard as StatCard, type index_StatCardProps as StatCardProps, type index_StatusItem as StatusItem, index_SystemStatusCard as SystemStatusCard, type index_SystemStatusCardProps as SystemStatusCardProps, index_Textarea as Textarea, type index_TextareaProps as TextareaProps };
1482
+ }
1483
+
1484
+ export { type BreadcrumbItem, index as Components, type DetailDatasource, DetailPageModule, type FormDatasource, FormPageModule, HtmxAdminContext, type HtmxAdminModuleOptions, HtmxAdminPlugin, type HtmxAdminPluginOptions, type ListDatasource, ListPageModule, type ListParams, type ListResult, MemoryListDatasource, type ModuleType, PageModule, PathHelper, type UserInfo, generateFormFieldsFromSchema, safeRender, validateFormDataWithSchema };