imean-service-engine-htmx-plugin 2.2.0 → 2.3.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 CHANGED
@@ -2,6 +2,7 @@ import { Context } from 'hono';
2
2
  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
+ import * as hono_utils_html from 'hono/utils/html';
5
6
 
6
7
  /**
7
8
  * HtmxAdminPlugin 核心类型定义
@@ -39,11 +40,17 @@ interface ActionButton {
39
40
  onClick?: string;
40
41
  /** 自定义类名 */
41
42
  className?: string;
43
+ /** 链接目标(如 "_blank" 表示新窗口打开) */
44
+ target?: string;
42
45
  }
43
46
  /**
44
47
  * 对话框大小类型
45
48
  */
46
49
  type DialogSize = "sm" | "md" | "lg" | "xl" | "full";
50
+ /**
51
+ * 打开方式类型
52
+ */
53
+ type OpenMode = "dialog" | "page" | "newWindow";
47
54
  /**
48
55
  * 页面元数据配置
49
56
  */
@@ -785,6 +792,7 @@ declare class DefaultListFeature<T extends {
785
792
  private listFieldNames?;
786
793
  private filterSchema?;
787
794
  private columnRenderers?;
795
+ private openMode?;
788
796
  constructor(options: {
789
797
  /** 列表数据的 Schema(用于字段推断和显示) */
790
798
  schema: z.ZodObject<any>;
@@ -806,6 +814,16 @@ declare class DefaultListFeature<T extends {
806
814
  filterSchema?: z.ZodObject<any>;
807
815
  /** 自定义列渲染函数(可选,key 为字段名,value 为渲染函数) */
808
816
  columnRenderers?: Record<string, (value: any, item: T) => any>;
817
+ /** 打开方式配置(可选,默认为 dialog)
818
+ * - create: 新建按钮的打开方式(默认 "dialog")
819
+ * - detail: 查看按钮的打开方式(默认 "dialog")
820
+ * - edit: 编辑按钮的打开方式(默认 "dialog")
821
+ */
822
+ openMode?: {
823
+ create?: OpenMode;
824
+ detail?: OpenMode;
825
+ edit?: OpenMode;
826
+ };
809
827
  });
810
828
  getRoutes(): {
811
829
  method: "get";
@@ -859,70 +877,6 @@ declare class HtmxAdminPlugin implements Plugin {
859
877
  */
860
878
  declare function getUserInfo(ctx: Context, authProvider?: AuthProvider): Promise<UserInfo | null>;
861
879
 
862
- /**
863
- * 表单字段渲染器的 Alpine.js x-data 工具函数
864
- * 提供统一的模式,简化自定义表单字段渲染器的开发
865
- */
866
- interface FormFieldXDataOptions {
867
- /** 字段名(用于更新隐藏字段) */
868
- fieldName: string;
869
- /** 数据对象的键名(如 'banners', 'items' 等) */
870
- dataKey: string;
871
- /** 默认值(如 [] 或 {}) */
872
- defaultValue?: any;
873
- /** 额外的数据属性 */
874
- customData?: Record<string, any>;
875
- /** 自定义方法(方法名 -> 方法体字符串) */
876
- customMethods?: Record<string, string>;
877
- /** 是否使用 x-effect 自动同步(默认 false,需要在方法中手动调用 updateHiddenField) */
878
- autoSync?: boolean;
879
- }
880
- /**
881
- * 创建表单字段的 Alpine.js x-data 字符串
882
- *
883
- * @example
884
- * ```tsx
885
- * const xData = createFormFieldXData({
886
- * fieldName: 'banners',
887
- * dataKey: 'banners',
888
- * defaultValue: [],
889
- * customMethods: {
890
- * addBanner() {
891
- * this.banners.push({ url: '', alt: '', order: this.banners.length });
892
- * this.updateHiddenField();
893
- * },
894
- * removeBanner(index) {
895
- * this.banners.splice(index, 1);
896
- * this.updateHiddenField();
897
- * }
898
- * }
899
- * });
900
- * ```
901
- */
902
- declare function createFormFieldXData(options: FormFieldXDataOptions): string;
903
- /**
904
- * 表单字段渲染器包装器组件的属性
905
- */
906
- interface FormFieldWrapperProps {
907
- /** 字段名 */
908
- fieldName: string;
909
- /** 初始值(会被序列化为 JSON) */
910
- initialValue: any;
911
- /** x-data 字符串 */
912
- xData: string;
913
- /** 是否使用 x-effect 自动同步 */
914
- autoSync?: boolean;
915
- /** 子元素(组件 UI) */
916
- children: any;
917
- /** 额外的 className */
918
- className?: string;
919
- }
920
- /**
921
- * 表单字段渲染器包装器组件
922
- * 自动处理隐藏字段、x-data、data-initial-value 等固定模式
923
- */
924
- declare function FormFieldWrapper(props: FormFieldWrapperProps): hono_jsx_jsx_dev_runtime.JSX.Element;
925
-
926
880
  /**
927
881
  * 参数解析工具函数
928
882
  */
@@ -1004,4 +958,39 @@ declare function ErrorAlert(props: ErrorAlertProps): hono_jsx_jsx_dev_runtime.JS
1004
958
  */
1005
959
  declare function LoadingBar(): hono_jsx_jsx_dev_runtime.JSX.Element;
1006
960
 
1007
- export { type AuthProvider, BaseFeature, CustomFeature, DefaultCreateFeature, DefaultDeleteFeature, DefaultDetailFeature, DefaultEditFeature, DefaultListFeature, Dialog, type DialogProps, type DialogSize, ErrorAlert, type ErrorAlertProps, type Feature, type FeatureContext, type FeatureType, type FieldMetadata, FormFieldWrapper, HtmxAdminPlugin, type HtmxAdminPluginOptions, type ListParams, type ListResult, LoadingBar, type NavItemConfig, type Notification, type NotificationType$1 as NotificationType, type PageMetadata, PageModel, type PermissionResult, type UserInfo, checkUserPermission, createFormFieldXData, getUserInfo, modelNameToPath, parseListParams };
961
+ interface ObjectEditorProps {
962
+ /** 字段定义 */
963
+ field: any;
964
+ /** 当前值(对象,已解析) */
965
+ value: Record<string, any> | null;
966
+ /** 完整的初始数据 */
967
+ initialData?: any;
968
+ /** 字段名(用于更新隐藏字段) */
969
+ fieldName: string;
970
+ /** 对象的 Zod schema(用于自动渲染结构) */
971
+ objectSchema?: z.ZodObject<any>;
972
+ }
973
+ declare function ObjectEditor(props: ObjectEditorProps): hono_jsx_jsx_dev_runtime.JSX.Element;
974
+
975
+ /**
976
+ * 字符串数组编辑器组件
977
+ * 支持增加、删除和拖放排序功能
978
+ * 使用 Alpine.js 管理状态,通过隐藏字段与表单系统同步数据
979
+ */
980
+ interface StringArrayEditorProps {
981
+ /** 字段定义 */
982
+ field: any;
983
+ /** 当前值(字符串数组,已解析) */
984
+ value: string[] | null;
985
+ /** 完整的初始数据 */
986
+ initialData?: any;
987
+ /** 字段名(用于更新隐藏字段) */
988
+ fieldName: string;
989
+ /** 占位符文本(可选) */
990
+ placeholder?: string;
991
+ /** 是否允许空值(默认 false) */
992
+ allowEmpty?: boolean;
993
+ }
994
+ declare function StringArrayEditor(props: StringArrayEditorProps): hono_utils_html.HtmlEscapedString | Promise<hono_utils_html.HtmlEscapedString>;
995
+
996
+ export { type AuthProvider, BaseFeature, CustomFeature, DefaultCreateFeature, DefaultDeleteFeature, DefaultDetailFeature, DefaultEditFeature, DefaultListFeature, Dialog, type DialogProps, type DialogSize, ErrorAlert, type ErrorAlertProps, type Feature, type FeatureContext, type FeatureType, type FieldMetadata, HtmxAdminPlugin, type HtmxAdminPluginOptions, type ListParams, type ListResult, LoadingBar, type NavItemConfig, type Notification, type NotificationType$1 as NotificationType, ObjectEditor, type ObjectEditorProps, type PageMetadata, PageModel, type PermissionResult, StringArrayEditor, type StringArrayEditorProps, type UserInfo, checkUserPermission, getUserInfo, modelNameToPath, parseListParams };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Context } from 'hono';
2
2
  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
+ import * as hono_utils_html from 'hono/utils/html';
5
6
 
6
7
  /**
7
8
  * HtmxAdminPlugin 核心类型定义
@@ -39,11 +40,17 @@ interface ActionButton {
39
40
  onClick?: string;
40
41
  /** 自定义类名 */
41
42
  className?: string;
43
+ /** 链接目标(如 "_blank" 表示新窗口打开) */
44
+ target?: string;
42
45
  }
43
46
  /**
44
47
  * 对话框大小类型
45
48
  */
46
49
  type DialogSize = "sm" | "md" | "lg" | "xl" | "full";
50
+ /**
51
+ * 打开方式类型
52
+ */
53
+ type OpenMode = "dialog" | "page" | "newWindow";
47
54
  /**
48
55
  * 页面元数据配置
49
56
  */
@@ -785,6 +792,7 @@ declare class DefaultListFeature<T extends {
785
792
  private listFieldNames?;
786
793
  private filterSchema?;
787
794
  private columnRenderers?;
795
+ private openMode?;
788
796
  constructor(options: {
789
797
  /** 列表数据的 Schema(用于字段推断和显示) */
790
798
  schema: z.ZodObject<any>;
@@ -806,6 +814,16 @@ declare class DefaultListFeature<T extends {
806
814
  filterSchema?: z.ZodObject<any>;
807
815
  /** 自定义列渲染函数(可选,key 为字段名,value 为渲染函数) */
808
816
  columnRenderers?: Record<string, (value: any, item: T) => any>;
817
+ /** 打开方式配置(可选,默认为 dialog)
818
+ * - create: 新建按钮的打开方式(默认 "dialog")
819
+ * - detail: 查看按钮的打开方式(默认 "dialog")
820
+ * - edit: 编辑按钮的打开方式(默认 "dialog")
821
+ */
822
+ openMode?: {
823
+ create?: OpenMode;
824
+ detail?: OpenMode;
825
+ edit?: OpenMode;
826
+ };
809
827
  });
810
828
  getRoutes(): {
811
829
  method: "get";
@@ -859,70 +877,6 @@ declare class HtmxAdminPlugin implements Plugin {
859
877
  */
860
878
  declare function getUserInfo(ctx: Context, authProvider?: AuthProvider): Promise<UserInfo | null>;
861
879
 
862
- /**
863
- * 表单字段渲染器的 Alpine.js x-data 工具函数
864
- * 提供统一的模式,简化自定义表单字段渲染器的开发
865
- */
866
- interface FormFieldXDataOptions {
867
- /** 字段名(用于更新隐藏字段) */
868
- fieldName: string;
869
- /** 数据对象的键名(如 'banners', 'items' 等) */
870
- dataKey: string;
871
- /** 默认值(如 [] 或 {}) */
872
- defaultValue?: any;
873
- /** 额外的数据属性 */
874
- customData?: Record<string, any>;
875
- /** 自定义方法(方法名 -> 方法体字符串) */
876
- customMethods?: Record<string, string>;
877
- /** 是否使用 x-effect 自动同步(默认 false,需要在方法中手动调用 updateHiddenField) */
878
- autoSync?: boolean;
879
- }
880
- /**
881
- * 创建表单字段的 Alpine.js x-data 字符串
882
- *
883
- * @example
884
- * ```tsx
885
- * const xData = createFormFieldXData({
886
- * fieldName: 'banners',
887
- * dataKey: 'banners',
888
- * defaultValue: [],
889
- * customMethods: {
890
- * addBanner() {
891
- * this.banners.push({ url: '', alt: '', order: this.banners.length });
892
- * this.updateHiddenField();
893
- * },
894
- * removeBanner(index) {
895
- * this.banners.splice(index, 1);
896
- * this.updateHiddenField();
897
- * }
898
- * }
899
- * });
900
- * ```
901
- */
902
- declare function createFormFieldXData(options: FormFieldXDataOptions): string;
903
- /**
904
- * 表单字段渲染器包装器组件的属性
905
- */
906
- interface FormFieldWrapperProps {
907
- /** 字段名 */
908
- fieldName: string;
909
- /** 初始值(会被序列化为 JSON) */
910
- initialValue: any;
911
- /** x-data 字符串 */
912
- xData: string;
913
- /** 是否使用 x-effect 自动同步 */
914
- autoSync?: boolean;
915
- /** 子元素(组件 UI) */
916
- children: any;
917
- /** 额外的 className */
918
- className?: string;
919
- }
920
- /**
921
- * 表单字段渲染器包装器组件
922
- * 自动处理隐藏字段、x-data、data-initial-value 等固定模式
923
- */
924
- declare function FormFieldWrapper(props: FormFieldWrapperProps): hono_jsx_jsx_dev_runtime.JSX.Element;
925
-
926
880
  /**
927
881
  * 参数解析工具函数
928
882
  */
@@ -1004,4 +958,39 @@ declare function ErrorAlert(props: ErrorAlertProps): hono_jsx_jsx_dev_runtime.JS
1004
958
  */
1005
959
  declare function LoadingBar(): hono_jsx_jsx_dev_runtime.JSX.Element;
1006
960
 
1007
- export { type AuthProvider, BaseFeature, CustomFeature, DefaultCreateFeature, DefaultDeleteFeature, DefaultDetailFeature, DefaultEditFeature, DefaultListFeature, Dialog, type DialogProps, type DialogSize, ErrorAlert, type ErrorAlertProps, type Feature, type FeatureContext, type FeatureType, type FieldMetadata, FormFieldWrapper, HtmxAdminPlugin, type HtmxAdminPluginOptions, type ListParams, type ListResult, LoadingBar, type NavItemConfig, type Notification, type NotificationType$1 as NotificationType, type PageMetadata, PageModel, type PermissionResult, type UserInfo, checkUserPermission, createFormFieldXData, getUserInfo, modelNameToPath, parseListParams };
961
+ interface ObjectEditorProps {
962
+ /** 字段定义 */
963
+ field: any;
964
+ /** 当前值(对象,已解析) */
965
+ value: Record<string, any> | null;
966
+ /** 完整的初始数据 */
967
+ initialData?: any;
968
+ /** 字段名(用于更新隐藏字段) */
969
+ fieldName: string;
970
+ /** 对象的 Zod schema(用于自动渲染结构) */
971
+ objectSchema?: z.ZodObject<any>;
972
+ }
973
+ declare function ObjectEditor(props: ObjectEditorProps): hono_jsx_jsx_dev_runtime.JSX.Element;
974
+
975
+ /**
976
+ * 字符串数组编辑器组件
977
+ * 支持增加、删除和拖放排序功能
978
+ * 使用 Alpine.js 管理状态,通过隐藏字段与表单系统同步数据
979
+ */
980
+ interface StringArrayEditorProps {
981
+ /** 字段定义 */
982
+ field: any;
983
+ /** 当前值(字符串数组,已解析) */
984
+ value: string[] | null;
985
+ /** 完整的初始数据 */
986
+ initialData?: any;
987
+ /** 字段名(用于更新隐藏字段) */
988
+ fieldName: string;
989
+ /** 占位符文本(可选) */
990
+ placeholder?: string;
991
+ /** 是否允许空值(默认 false) */
992
+ allowEmpty?: boolean;
993
+ }
994
+ declare function StringArrayEditor(props: StringArrayEditorProps): hono_utils_html.HtmlEscapedString | Promise<hono_utils_html.HtmlEscapedString>;
995
+
996
+ export { type AuthProvider, BaseFeature, CustomFeature, DefaultCreateFeature, DefaultDeleteFeature, DefaultDetailFeature, DefaultEditFeature, DefaultListFeature, Dialog, type DialogProps, type DialogSize, ErrorAlert, type ErrorAlertProps, type Feature, type FeatureContext, type FeatureType, type FieldMetadata, HtmxAdminPlugin, type HtmxAdminPluginOptions, type ListParams, type ListResult, LoadingBar, type NavItemConfig, type Notification, type NotificationType$1 as NotificationType, ObjectEditor, type ObjectEditorProps, type PageMetadata, PageModel, type PermissionResult, StringArrayEditor, type StringArrayEditorProps, type UserInfo, checkUserPermission, getUserInfo, modelNameToPath, parseListParams };