imean-service-engine-htmx-plugin 2.5.0 → 2.7.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/dist/index.d.mts +357 -116
- package/dist/index.d.ts +357 -116
- package/dist/index.js +322 -591
- package/dist/index.mjs +312 -588
- package/docs/README.md +0 -38
- package/package.json +1 -1
- package/docs/alpinejs-interactive-components.md +0 -653
- package/docs/custom-form-field-renderers.md +0 -541
- package/docs/field-editor-best-practices.md +0 -320
- package/docs/hono-html-best-practices.md +0 -509
package/dist/index.d.mts
CHANGED
|
@@ -3,55 +3,6 @@ import { z } from 'zod';
|
|
|
3
3
|
import { Plugin, PluginPriority, Microservice } from 'imean-service-engine';
|
|
4
4
|
import * as hono_jsx_jsx_dev_runtime from 'hono/jsx/jsx-dev-runtime';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* 组件系统上下文
|
|
8
|
-
* 提供渲染上下文和组件上下文
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
declare class RenderContext<TProps = any, TState = any> {
|
|
12
|
-
readonly prefix: string;
|
|
13
|
-
readonly instanceId: string;
|
|
14
|
-
readonly componentName: string;
|
|
15
|
-
constructor(prefix: string, instanceId: string, componentName: string);
|
|
16
|
-
$id(): string;
|
|
17
|
-
setState(state: Partial<TState>): void;
|
|
18
|
-
get state(): TState;
|
|
19
|
-
get props(): TProps;
|
|
20
|
-
url(methodName: string, params?: Record<string, any>): string;
|
|
21
|
-
callMethod(methodName: string, params: Record<string, string>): any;
|
|
22
|
-
}
|
|
23
|
-
declare class ComponentContext extends RenderContext {
|
|
24
|
-
readonly ctx: Context;
|
|
25
|
-
constructor(prefix: string, ctx: Context, componentName: string);
|
|
26
|
-
params(): Promise<Record<string, any>>;
|
|
27
|
-
query(): Record<string, string>;
|
|
28
|
-
body(): Promise<any>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 组件系统核心
|
|
33
|
-
* 提供组件基类、方法装饰器和组件注册功能
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
interface MethodConfig {
|
|
37
|
-
method?: "get" | "post" | "put" | "delete";
|
|
38
|
-
path?: string;
|
|
39
|
-
}
|
|
40
|
-
declare function Method(config?: MethodConfig): (target: any, propertyKey: string, _descriptor: PropertyDescriptor) => void;
|
|
41
|
-
declare abstract class HtmxComponent<TProps = any> {
|
|
42
|
-
readonly name: string;
|
|
43
|
-
prefix: string;
|
|
44
|
-
constructor(name: string);
|
|
45
|
-
readonly Component: (props: TProps) => any;
|
|
46
|
-
protected abstract render(ctx: RenderContext, props: TProps): any;
|
|
47
|
-
getScript?(): any;
|
|
48
|
-
static getMethods(component: HtmxComponent<any>): Map<string, {
|
|
49
|
-
method: "get" | "post" | "put" | "delete";
|
|
50
|
-
path?: string;
|
|
51
|
-
handler: (ctx: ComponentContext) => Promise<Response>;
|
|
52
|
-
}>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
6
|
/**
|
|
56
7
|
* Feature 注册表
|
|
57
8
|
*/
|
|
@@ -133,6 +84,39 @@ declare abstract class PageModel {
|
|
|
133
84
|
* HtmxAdminPlugin 核心类型定义
|
|
134
85
|
*/
|
|
135
86
|
|
|
87
|
+
/**
|
|
88
|
+
* 操作按钮配置
|
|
89
|
+
*/
|
|
90
|
+
interface ActionButton {
|
|
91
|
+
/** 按钮文本 */
|
|
92
|
+
label: string;
|
|
93
|
+
/** 链接地址(页面模式使用) */
|
|
94
|
+
href?: string;
|
|
95
|
+
/** HTTP 方法 */
|
|
96
|
+
method?: "get" | "post" | "put" | "delete";
|
|
97
|
+
/** 按钮样式 */
|
|
98
|
+
variant?: "primary" | "secondary" | "danger" | "ghost";
|
|
99
|
+
/** HTMX GET 请求(弹窗模式使用) */
|
|
100
|
+
hxGet?: string;
|
|
101
|
+
/** HTMX POST 请求 */
|
|
102
|
+
hxPost?: string;
|
|
103
|
+
/** HTMX PUT 请求 */
|
|
104
|
+
hxPut?: string;
|
|
105
|
+
/** HTMX DELETE 请求 */
|
|
106
|
+
hxDelete?: string;
|
|
107
|
+
/** 确认提示 */
|
|
108
|
+
confirm?: string;
|
|
109
|
+
/** 是否关闭弹窗(设置为 true 时,点击按钮会自动关闭弹窗,无需写代码) */
|
|
110
|
+
close?: boolean;
|
|
111
|
+
/** 是否提交表单(设置为 true 时,按钮会提交指定的表单,需要配合 formId 使用) */
|
|
112
|
+
submit?: boolean;
|
|
113
|
+
/** 表单 ID(当 submit 为 true 时,指定要提交的表单 ID) */
|
|
114
|
+
formId?: string;
|
|
115
|
+
/** 自定义类名 */
|
|
116
|
+
className?: string;
|
|
117
|
+
/** 链接目标(如 "_blank" 表示新窗口打开) */
|
|
118
|
+
target?: string;
|
|
119
|
+
}
|
|
136
120
|
/**
|
|
137
121
|
* 对话框大小类型
|
|
138
122
|
*/
|
|
@@ -396,8 +380,6 @@ interface HtmxAdminPluginOptions {
|
|
|
396
380
|
navigation?: NavItemConfig[];
|
|
397
381
|
/** 认证提供者(用于鉴权和权限控制) */
|
|
398
382
|
authProvider?: AuthProvider;
|
|
399
|
-
/** 组件配置(可选,用于注册组件) */
|
|
400
|
-
components?: HtmxComponent<any>[];
|
|
401
383
|
/** 页面配置(可选,用于注册页面) */
|
|
402
384
|
pages: PageModel[];
|
|
403
385
|
}
|
|
@@ -410,7 +392,7 @@ interface HtmxAdminPluginOptions {
|
|
|
410
392
|
* - 让类型系统更准确地反映实际的数据状态
|
|
411
393
|
* - 减少类型错误和运行时检查
|
|
412
394
|
*/
|
|
413
|
-
type ResolvedHtmxAdminPluginOptions = Required<Pick<HtmxAdminPluginOptions, "title" | "prefix" | "navigation" | "pages"
|
|
395
|
+
type ResolvedHtmxAdminPluginOptions = Required<Pick<HtmxAdminPluginOptions, "title" | "prefix" | "navigation" | "pages">> & Pick<HtmxAdminPluginOptions, "logo" | "homePath" | "authProvider" | "pages">;
|
|
414
396
|
/**
|
|
415
397
|
* 导航项配置
|
|
416
398
|
*/
|
|
@@ -441,19 +423,101 @@ interface FormField {
|
|
|
441
423
|
/** HTML input step 属性(用于 number 类型,支持小数) */
|
|
442
424
|
step?: string | number;
|
|
443
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* 字段渲染器属性
|
|
428
|
+
* 统一接口,可在不同 Feature 中复用
|
|
429
|
+
*/
|
|
430
|
+
interface FieldRendererProps<T = any, K extends keyof T = keyof T> {
|
|
431
|
+
/** 字段值 */
|
|
432
|
+
value: T[K];
|
|
433
|
+
/** 完整的初始数据项 */
|
|
434
|
+
item: Partial<T>;
|
|
435
|
+
/** 字段名 */
|
|
436
|
+
name: string;
|
|
437
|
+
/** 字段标签(没有会使用name的值作为标签) */
|
|
438
|
+
label: string;
|
|
439
|
+
}
|
|
444
440
|
/**
|
|
445
441
|
* 表单字段渲染器属性
|
|
442
|
+
* 统一接口,可在不同 Feature 中复用
|
|
446
443
|
*/
|
|
447
|
-
interface FormFieldRendererProps<T = any> {
|
|
444
|
+
interface FormFieldRendererProps<T = any, K extends keyof T = keyof T> extends FieldRendererProps<T, K> {
|
|
448
445
|
/** 字段定义 */
|
|
449
446
|
field: FormField;
|
|
450
|
-
/** 当前值(已解析的对象/数组,不是 JSON 字符串) */
|
|
451
|
-
value: any;
|
|
452
|
-
/** 完整的初始数据 */
|
|
453
|
-
initialData?: Partial<T>;
|
|
454
|
-
/** 字段名(用于更新隐藏字段) */
|
|
455
|
-
fieldName: string;
|
|
456
447
|
}
|
|
448
|
+
/**
|
|
449
|
+
* 字段渲染器
|
|
450
|
+
* 用于渲染字段,可用于自定义渲染器
|
|
451
|
+
*/
|
|
452
|
+
interface FieldRenderer<T extends FieldRendererProps = FieldRendererProps> {
|
|
453
|
+
(props: T): any;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* 表单字段渲染器类型别名
|
|
457
|
+
* 用于统一表单字段渲染器的类型定义
|
|
458
|
+
* 支持字段名泛型,可以根据字段名推导出对应的值类型
|
|
459
|
+
*/
|
|
460
|
+
type FormFieldRenderer<T = any, K extends keyof T = keyof T> = FieldRenderer<FormFieldRendererProps<T, K>>;
|
|
461
|
+
/**
|
|
462
|
+
* 表单字段渲染器映射类型
|
|
463
|
+
* 根据字段名自动推导对应的值类型,并严格约束 key 只能是 T 的字段名
|
|
464
|
+
*
|
|
465
|
+
* 使用方式:
|
|
466
|
+
* ```typescript
|
|
467
|
+
* formFieldRenderers: {
|
|
468
|
+
* banners: (props) => {
|
|
469
|
+
* // props.value 自动推导为 T["banners"] 类型
|
|
470
|
+
* return <BannerEditor {...props} value={props.value} />;
|
|
471
|
+
* }
|
|
472
|
+
* }
|
|
473
|
+
* ```
|
|
474
|
+
*
|
|
475
|
+
* TypeScript 会根据字段名自动推导对应的值类型,无需手动添加类型注解
|
|
476
|
+
* key 约束:只能使用 T 中存在的字段名,拼写错误会被 TypeScript 检查出来
|
|
477
|
+
* 例如:如果写成了 "tgas" 而不是 "tags",TypeScript 会报错
|
|
478
|
+
*
|
|
479
|
+
* 注意:为了支持类型推导,移除了索引签名,运行时访问字符串键时需要使用类型断言
|
|
480
|
+
*/
|
|
481
|
+
/**
|
|
482
|
+
* 表单字段渲染器映射类型
|
|
483
|
+
* 根据字段名自动推导对应的值类型,并严格约束 key 只能是 T 的字段名
|
|
484
|
+
*
|
|
485
|
+
* 使用方式:
|
|
486
|
+
* ```typescript
|
|
487
|
+
* formFieldRenderers: {
|
|
488
|
+
* banners: (props) => {
|
|
489
|
+
* // props.value 自动推导为 T["banners"] 类型
|
|
490
|
+
* return <BannerEditor {...props} value={props.value} />;
|
|
491
|
+
* }
|
|
492
|
+
* }
|
|
493
|
+
* ```
|
|
494
|
+
*
|
|
495
|
+
* TypeScript 会根据字段名自动推导对应的值类型,无需手动添加类型注解
|
|
496
|
+
* key 约束:只能使用 T 中存在的字段名,拼写错误会被 TypeScript 检查出来
|
|
497
|
+
* 例如:如果写成了 "tgas" 而不是 "tags",TypeScript 会报错
|
|
498
|
+
*
|
|
499
|
+
* 注意:为了支持类型推导,移除了索引签名,运行时访问字符串键时需要使用类型断言
|
|
500
|
+
*/
|
|
501
|
+
type FormFieldRendererMap<T = any> = {
|
|
502
|
+
[K in keyof T]?: FormFieldRenderer<T, K>;
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
505
|
+
* 字段渲染器类型别名(用于详情页等非表单场景)
|
|
506
|
+
* 用于统一字段渲染器的类型定义
|
|
507
|
+
* 支持字段名泛型,可以根据字段名推导出对应的值类型
|
|
508
|
+
*/
|
|
509
|
+
type FieldRendererType<T = any, K extends keyof T = keyof T> = FieldRenderer<FieldRendererProps<T, K>>;
|
|
510
|
+
/**
|
|
511
|
+
* 字段渲染器映射类型
|
|
512
|
+
* 根据字段名自动推导对应的值类型
|
|
513
|
+
* 使用 Record 类型保持兼容性,但在使用时可以通过类型断言获得字段级别的类型推导
|
|
514
|
+
*
|
|
515
|
+
* 注意:在使用时,TypeScript 会根据字段名自动推导对应的值类型
|
|
516
|
+
* 例如:fieldRenderers.banners 的类型会被推导为 FieldRendererType<T, "banners">
|
|
517
|
+
*/
|
|
518
|
+
type FieldRendererTypeMap<T = any> = {
|
|
519
|
+
[K in keyof T]?: FieldRendererType<T, K>;
|
|
520
|
+
} & Record<string, FieldRendererType<T, any> | undefined> & Partial<Record<keyof T, FieldRendererType<T, keyof T>>>;
|
|
457
521
|
|
|
458
522
|
/**
|
|
459
523
|
* Feature 基类
|
|
@@ -518,6 +582,11 @@ declare abstract class BaseFeature implements Feature {
|
|
|
518
582
|
render?(context: FeatureContext): Promise<any>;
|
|
519
583
|
}
|
|
520
584
|
|
|
585
|
+
/**
|
|
586
|
+
* 表单 Feature 基类
|
|
587
|
+
* 提供创建和编辑 Feature 的公共逻辑
|
|
588
|
+
*/
|
|
589
|
+
|
|
521
590
|
/**
|
|
522
591
|
* 表单操作类型
|
|
523
592
|
*/
|
|
@@ -534,7 +603,9 @@ declare abstract class BaseFormFeature<T extends {
|
|
|
534
603
|
/** 当前请求的表单 ID(用于在 render 和 getActions 之间共享) */
|
|
535
604
|
private currentFormId?;
|
|
536
605
|
/** 自定义表单字段渲染器 */
|
|
537
|
-
protected formFieldRenderers?:
|
|
606
|
+
protected formFieldRenderers?: {
|
|
607
|
+
[K in keyof T]?: FormFieldRenderer<T, K>;
|
|
608
|
+
};
|
|
538
609
|
/**
|
|
539
610
|
* 获取或生成表单 ID(确保在同一个请求中保持一致)
|
|
540
611
|
*/
|
|
@@ -641,6 +712,10 @@ declare class CustomFeature extends BaseFeature {
|
|
|
641
712
|
render(context: FeatureContext): Promise<any>;
|
|
642
713
|
}
|
|
643
714
|
|
|
715
|
+
/**
|
|
716
|
+
* 默认创建 Feature
|
|
717
|
+
*/
|
|
718
|
+
|
|
644
719
|
/**
|
|
645
720
|
* 默认创建 Feature
|
|
646
721
|
* 类型通过 schema 的 z.infer 推断
|
|
@@ -666,7 +741,7 @@ declare class DefaultCreateFeature<T extends {
|
|
|
666
741
|
/** 字段分组配置(可选,用于将字段分组展示为 Tab) */
|
|
667
742
|
groups?: FieldGroup[];
|
|
668
743
|
/** 自定义表单字段渲染器 */
|
|
669
|
-
formFieldRenderers?:
|
|
744
|
+
formFieldRenderers?: FormFieldRendererMap<T>;
|
|
670
745
|
});
|
|
671
746
|
getFormAction(): "create";
|
|
672
747
|
getRoutes(): ({
|
|
@@ -739,7 +814,7 @@ declare class DefaultDetailFeature<T extends {
|
|
|
739
814
|
/** 详情显示字段名(可选,不提供则显示 schema 中的所有字段) */
|
|
740
815
|
detailFieldNames?: string[];
|
|
741
816
|
/** 自定义字段渲染函数(可选,key 为字段名,value 为渲染函数) */
|
|
742
|
-
fieldRenderers?:
|
|
817
|
+
fieldRenderers?: FieldRendererTypeMap<T>;
|
|
743
818
|
/** 字段分组配置(可选,用于将字段分组展示为卡片) */
|
|
744
819
|
groups?: FieldGroup[];
|
|
745
820
|
});
|
|
@@ -753,6 +828,10 @@ declare class DefaultDetailFeature<T extends {
|
|
|
753
828
|
getActions(context: FeatureContext): Promise<any>;
|
|
754
829
|
}
|
|
755
830
|
|
|
831
|
+
/**
|
|
832
|
+
* 默认编辑 Feature
|
|
833
|
+
*/
|
|
834
|
+
|
|
756
835
|
/**
|
|
757
836
|
* 默认编辑 Feature
|
|
758
837
|
* 类型通过 schema 的 z.infer 推断
|
|
@@ -779,8 +858,11 @@ declare class DefaultEditFeature<T extends {
|
|
|
779
858
|
formFieldNames?: string[];
|
|
780
859
|
/** 字段分组配置(可选,用于将字段分组展示为 Tab) */
|
|
781
860
|
groups?: FieldGroup[];
|
|
782
|
-
/** 自定义表单字段渲染器
|
|
783
|
-
|
|
861
|
+
/** 自定义表单字段渲染器
|
|
862
|
+
* 使用 satisfies FormFieldRendererMap<T> 来检查 key 约束
|
|
863
|
+
* 例如:formFieldRenderers: { ... } satisfies FormFieldRendererMap<T>
|
|
864
|
+
*/
|
|
865
|
+
formFieldRenderers?: FormFieldRendererMap<T>;
|
|
784
866
|
});
|
|
785
867
|
getFormAction(): "edit";
|
|
786
868
|
getRoutes(): ({
|
|
@@ -874,7 +956,6 @@ declare class HtmxAdminPlugin implements Plugin {
|
|
|
874
956
|
readonly options: ResolvedHtmxAdminPluginOptions;
|
|
875
957
|
private serviceName;
|
|
876
958
|
private pages;
|
|
877
|
-
private componentHandler;
|
|
878
959
|
constructor(options?: HtmxAdminPluginOptions);
|
|
879
960
|
private initPages;
|
|
880
961
|
/**
|
|
@@ -955,6 +1036,8 @@ interface DialogProps {
|
|
|
955
1036
|
/**
|
|
956
1037
|
* 对话框组件
|
|
957
1038
|
* 用于在模态框中显示内容,支持 HTMX 交互
|
|
1039
|
+
* 支持多开:每个对话框都有唯一 ID,可以同时打开多个对话框
|
|
1040
|
+
* 使用 Alpine.js 实现关闭逻辑
|
|
958
1041
|
*/
|
|
959
1042
|
declare function Dialog(props: DialogProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
960
1043
|
|
|
@@ -975,6 +1058,8 @@ interface ErrorAlertProps {
|
|
|
975
1058
|
className?: string;
|
|
976
1059
|
/** 自动关闭时间(毫秒),0 表示不自动关闭 */
|
|
977
1060
|
autoClose?: number;
|
|
1061
|
+
/** HTMX OOB swap 属性 */
|
|
1062
|
+
"hx-swap-oob"?: string;
|
|
978
1063
|
}
|
|
979
1064
|
/**
|
|
980
1065
|
* 错误提示组件
|
|
@@ -982,46 +1067,215 @@ interface ErrorAlertProps {
|
|
|
982
1067
|
*/
|
|
983
1068
|
declare function ErrorAlert(props: ErrorAlertProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
984
1069
|
|
|
1070
|
+
interface FilterFormProps {
|
|
1071
|
+
/** 筛选字段 */
|
|
1072
|
+
fields: FormField[];
|
|
1073
|
+
/** 列表路径(用于提交筛选表单) */
|
|
1074
|
+
listPath: string;
|
|
1075
|
+
/** 当前筛选参数 */
|
|
1076
|
+
currentFilters?: Record<string, any>;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* 筛选表单组件
|
|
1080
|
+
*/
|
|
1081
|
+
declare function FilterForm(props: FilterFormProps): hono_jsx_jsx_dev_runtime.JSX.Element | null;
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* 面包屑组件
|
|
1085
|
+
*/
|
|
1086
|
+
interface BreadcrumbItem {
|
|
1087
|
+
label: string;
|
|
1088
|
+
href?: string;
|
|
1089
|
+
}
|
|
1090
|
+
interface BreadcrumbProps {
|
|
1091
|
+
items: BreadcrumbItem[];
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* 面包屑组件
|
|
1095
|
+
*/
|
|
1096
|
+
declare function Breadcrumb(props: BreadcrumbProps): hono_jsx_jsx_dev_runtime.JSX.Element | null;
|
|
1097
|
+
|
|
1098
|
+
interface HeaderProps {
|
|
1099
|
+
/** 面包屑项 */
|
|
1100
|
+
breadcrumbs?: BreadcrumbItem[];
|
|
1101
|
+
/** 用户信息 */
|
|
1102
|
+
userInfo?: UserInfo | null;
|
|
1103
|
+
/** 退出登录的URL */
|
|
1104
|
+
logoutUrl?: string;
|
|
1105
|
+
/** 页面标题(当没有面包屑时显示) */
|
|
1106
|
+
title?: string;
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* 头部组件
|
|
1110
|
+
*/
|
|
1111
|
+
declare function Header(props: HeaderProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1112
|
+
|
|
985
1113
|
/**
|
|
986
1114
|
* 加载条组件
|
|
987
1115
|
* 用于显示 HTMX 请求的加载状态
|
|
988
1116
|
*/
|
|
989
1117
|
declare function LoadingBar(): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
990
1118
|
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
/**
|
|
999
|
-
|
|
1000
|
-
/**
|
|
1001
|
-
|
|
1119
|
+
/**
|
|
1120
|
+
* 表格组件
|
|
1121
|
+
*/
|
|
1122
|
+
/**
|
|
1123
|
+
* 表格组件 Props
|
|
1124
|
+
*/
|
|
1125
|
+
interface TableProps<T = any> {
|
|
1126
|
+
/** 数据列表 */
|
|
1127
|
+
items: T[];
|
|
1128
|
+
/** 列定义 */
|
|
1129
|
+
columns: Array<{
|
|
1130
|
+
key: string;
|
|
1131
|
+
label: string;
|
|
1132
|
+
render?: (value: any, item: T) => any;
|
|
1133
|
+
}>;
|
|
1134
|
+
/** 操作列 */
|
|
1135
|
+
actions?: Array<{
|
|
1136
|
+
label: string;
|
|
1137
|
+
href: (item: T) => string;
|
|
1138
|
+
method?: string;
|
|
1139
|
+
class?: string;
|
|
1140
|
+
target?: string;
|
|
1141
|
+
}>;
|
|
1142
|
+
/** 分页信息 */
|
|
1143
|
+
pagination?: {
|
|
1144
|
+
page: number;
|
|
1145
|
+
pageSize: number;
|
|
1146
|
+
total: number;
|
|
1147
|
+
totalPages: number;
|
|
1148
|
+
baseUrl: string;
|
|
1149
|
+
currentParams?: Record<string, string | number | undefined>;
|
|
1150
|
+
};
|
|
1151
|
+
/** 表格标题 */
|
|
1152
|
+
title?: string;
|
|
1153
|
+
/** 表格操作按钮(如导出、清空、刷新等) */
|
|
1154
|
+
tableActions?: Array<{
|
|
1155
|
+
label: string;
|
|
1156
|
+
href?: string;
|
|
1157
|
+
hxGet?: string;
|
|
1158
|
+
hxPost?: string;
|
|
1159
|
+
hxDelete?: string;
|
|
1160
|
+
variant?: "primary" | "secondary" | "danger" | "ghost";
|
|
1161
|
+
hxConfirm?: string;
|
|
1162
|
+
}>;
|
|
1163
|
+
/** 操作列样式(link 或 button) */
|
|
1164
|
+
actionStyle?: "link" | "button";
|
|
1002
1165
|
}
|
|
1003
|
-
|
|
1166
|
+
/**
|
|
1167
|
+
* 表格组件
|
|
1168
|
+
*/
|
|
1169
|
+
declare function Table<T extends {
|
|
1170
|
+
id: string | number;
|
|
1171
|
+
}>(props: TableProps<T>): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1004
1172
|
|
|
1005
1173
|
/**
|
|
1006
|
-
*
|
|
1007
|
-
* 使用 Alpine.js 实现纯 JSX 交互式组件
|
|
1008
|
-
*
|
|
1009
|
-
* 设计原则:
|
|
1010
|
-
* - 使用 Alpine.js 的 x-data 定义状态
|
|
1011
|
-
* - 尽量使用声明式语法,避免在 HTML 中写方法
|
|
1012
|
-
* - 使用 x-model、x-show、x-for 等 Alpine.js 指令
|
|
1013
|
-
* - 支持拖放排序(使用 SortableList 组件)
|
|
1014
|
-
* - 表单提交:通过 form-data-processor 自动解析嵌套结构和压缩数组索引
|
|
1174
|
+
* 分页组件
|
|
1015
1175
|
*/
|
|
1016
|
-
interface
|
|
1017
|
-
/**
|
|
1018
|
-
|
|
1019
|
-
/**
|
|
1020
|
-
|
|
1021
|
-
/**
|
|
1022
|
-
|
|
1023
|
-
/**
|
|
1024
|
-
|
|
1176
|
+
interface PaginationProps {
|
|
1177
|
+
/** 当前页码 */
|
|
1178
|
+
page: number;
|
|
1179
|
+
/** 每页数量 */
|
|
1180
|
+
pageSize: number;
|
|
1181
|
+
/** 总记录数 */
|
|
1182
|
+
total: number;
|
|
1183
|
+
/** 总页数 */
|
|
1184
|
+
totalPages: number;
|
|
1185
|
+
/** 基础 URL */
|
|
1186
|
+
baseUrl: string;
|
|
1187
|
+
/** 当前查询参数(用于保留筛选条件等) */
|
|
1188
|
+
currentParams?: Record<string, string | number | undefined>;
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* 分页组件
|
|
1192
|
+
*/
|
|
1193
|
+
declare function Pagination(props: PaginationProps): hono_jsx_jsx_dev_runtime.JSX.Element | null;
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* 卡片组件
|
|
1197
|
+
*/
|
|
1198
|
+
interface CardProps {
|
|
1199
|
+
/** 卡片内容 */
|
|
1200
|
+
children: any;
|
|
1201
|
+
/** 卡片标题 */
|
|
1202
|
+
title?: string;
|
|
1203
|
+
/** 自定义类名 */
|
|
1204
|
+
className?: string;
|
|
1205
|
+
/** 是否显示阴影 */
|
|
1206
|
+
shadow?: boolean;
|
|
1207
|
+
/** 是否显示边框 */
|
|
1208
|
+
bordered?: boolean;
|
|
1209
|
+
/** 是否去掉内边距 */
|
|
1210
|
+
noPadding?: boolean;
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* 卡片组件
|
|
1214
|
+
*/
|
|
1215
|
+
declare function Card(props: CardProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1216
|
+
|
|
1217
|
+
/**
|
|
1218
|
+
* 空状态组件
|
|
1219
|
+
*/
|
|
1220
|
+
interface EmptyStateProps {
|
|
1221
|
+
/** 提示文本 */
|
|
1222
|
+
message?: string;
|
|
1223
|
+
/** 自定义内容 */
|
|
1224
|
+
children?: any;
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* 空状态组件
|
|
1228
|
+
*/
|
|
1229
|
+
declare function EmptyState(props: EmptyStateProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* 按钮组件
|
|
1233
|
+
* 只负责样式,其他属性(如 HTMX 属性)通过解构动态传递
|
|
1234
|
+
*/
|
|
1235
|
+
interface ButtonProps {
|
|
1236
|
+
/** 按钮文本 */
|
|
1237
|
+
children: any;
|
|
1238
|
+
/** 按钮类型 */
|
|
1239
|
+
variant?: "primary" | "secondary" | "danger" | "ghost";
|
|
1240
|
+
/** 按钮大小 */
|
|
1241
|
+
size?: "sm" | "md" | "lg";
|
|
1242
|
+
/** 是否禁用 */
|
|
1243
|
+
disabled?: boolean;
|
|
1244
|
+
/** 自定义类名 */
|
|
1245
|
+
className?: string;
|
|
1246
|
+
/** 其他属性(包括 HTMX 属性、href 等) */
|
|
1247
|
+
[key: string]: any;
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* 按钮组件
|
|
1251
|
+
* 只负责样式,其他属性通过解构动态传递
|
|
1252
|
+
*/
|
|
1253
|
+
declare function Button(props: ButtonProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1254
|
+
|
|
1255
|
+
interface PermissionDeniedContentProps {
|
|
1256
|
+
/** 操作ID(权限标识) */
|
|
1257
|
+
operationId?: string;
|
|
1258
|
+
/** 请求路径 */
|
|
1259
|
+
fromPath?: string;
|
|
1260
|
+
/** 错误消息 */
|
|
1261
|
+
message?: string;
|
|
1262
|
+
/** 用户信息 */
|
|
1263
|
+
userInfo?: UserInfo | null;
|
|
1264
|
+
/** 插件选项 */
|
|
1265
|
+
pluginOptions?: HtmxAdminPluginOptions;
|
|
1266
|
+
/** 是否在弹框中显示(用于 HTMX 请求) */
|
|
1267
|
+
isDialog?: boolean;
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* 权限提示内容组件(用于弹框或页面)
|
|
1271
|
+
*/
|
|
1272
|
+
declare function PermissionDeniedContent(props: PermissionDeniedContentProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1273
|
+
/**
|
|
1274
|
+
* 权限提示页面组件(完整页面,用于整页加载)
|
|
1275
|
+
*/
|
|
1276
|
+
declare function PermissionDeniedPage(props: PermissionDeniedContentProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1277
|
+
|
|
1278
|
+
interface StringArrayEditorProps extends FormFieldRendererProps {
|
|
1025
1279
|
/** 占位符文本(可选) */
|
|
1026
1280
|
placeholder?: string;
|
|
1027
1281
|
/** 是否允许空值(默认 false) */
|
|
@@ -1035,26 +1289,7 @@ interface StringArrayEditorProps {
|
|
|
1035
1289
|
*/
|
|
1036
1290
|
declare function StringArrayEditor(props: StringArrayEditorProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1037
1291
|
|
|
1038
|
-
|
|
1039
|
-
* 标签编辑器组件(Alpine.js 版本)
|
|
1040
|
-
* 使用 Alpine.js 实现纯 JSX 交互式组件
|
|
1041
|
-
*
|
|
1042
|
-
* 设计原则:
|
|
1043
|
-
* - 使用 Alpine.js 的 x-data 定义状态
|
|
1044
|
-
* - 尽量使用声明式语法,避免在 HTML 中写方法
|
|
1045
|
-
* - 使用 x-model、x-show、x-for 等 Alpine.js 指令
|
|
1046
|
-
* - 支持拖放排序(使用 SortableList 组件)
|
|
1047
|
-
* - 表单提交:通过 form-data-processor 自动解析嵌套结构和压缩数组索引
|
|
1048
|
-
*/
|
|
1049
|
-
interface TagsEditorProps {
|
|
1050
|
-
/** 字段定义 */
|
|
1051
|
-
field: any;
|
|
1052
|
-
/** 当前值(字符串数组,已解析) */
|
|
1053
|
-
value: string[] | null;
|
|
1054
|
-
/** 完整的初始数据 */
|
|
1055
|
-
initialData?: any;
|
|
1056
|
-
/** 字段名(用于更新隐藏字段) */
|
|
1057
|
-
fieldName: string;
|
|
1292
|
+
interface TagsEditorProps extends FormFieldRendererProps {
|
|
1058
1293
|
/** 占位符文本(可选) */
|
|
1059
1294
|
placeholder?: string;
|
|
1060
1295
|
/** 是否允许空值(默认 false) */
|
|
@@ -1066,6 +1301,12 @@ interface TagsEditorProps {
|
|
|
1066
1301
|
*/
|
|
1067
1302
|
declare function TagsEditor(props: TagsEditorProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1068
1303
|
|
|
1304
|
+
interface ObjectEditorProps extends FormFieldRendererProps {
|
|
1305
|
+
/** 对象的 Zod schema(用于自动渲染结构) */
|
|
1306
|
+
objectSchema?: z.ZodObject<any>;
|
|
1307
|
+
}
|
|
1308
|
+
declare function ObjectEditor(props: ObjectEditorProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1309
|
+
|
|
1069
1310
|
/**
|
|
1070
1311
|
* 可拖拽排序列表组件
|
|
1071
1312
|
* 使用 HTML5 原生拖放 API 实现拖拽排序
|
|
@@ -1103,4 +1344,4 @@ interface SortableListProps {
|
|
|
1103
1344
|
*/
|
|
1104
1345
|
declare function SortableList(props: SortableListProps): hono_jsx_jsx_dev_runtime.JSX.Element;
|
|
1105
1346
|
|
|
1106
|
-
export { type AuthProvider, BaseFeature,
|
|
1347
|
+
export { type ActionButton, type AuthProvider, BaseFeature, BaseFormFeature, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, CustomFeature, DefaultCreateFeature, DefaultDeleteFeature, DefaultDetailFeature, DefaultEditFeature, DefaultListFeature, Dialog, type DialogProps, type DialogSize, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, type Feature, type FeatureContext, type FeatureType, type FieldGroup, type FieldMetadata, type FieldRenderer, type FieldRendererProps, type FieldRendererType, type FieldRendererTypeMap, FilterForm, type FormAction, type FormField, type FormFieldRenderer, type FormFieldRendererMap, type FormFieldRendererProps, Header, type HeaderProps, HtmxAdminPlugin, type HtmxAdminPluginOptions, type ListParams, type ListResult, LoadingBar, type ModelField, type NavItemConfig, type Notification, type NotificationType$1 as NotificationType, ObjectEditor, type ObjectEditorProps, type OpenMode, type PageMetadata, PageModel, Pagination, type PaginationProps, PermissionDeniedContent, type PermissionDeniedContentProps, PermissionDeniedPage, type PermissionResult, type ResolvedHtmxAdminPluginOptions, SortableList, type SortableListProps, StringArrayEditor, type StringArrayEditorProps, Table, type TableProps, TagsEditor, type TagsEditorProps, type UserInfo, checkUserPermission, getUserInfo, modelNameToPath, parseListParams };
|