imean-service-engine-htmx-plugin 2.10.1 → 2.11.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
@@ -270,8 +270,9 @@ interface Feature {
270
270
  }
271
271
  /**
272
272
  * 列表查询参数
273
+ * @template F 筛选条件的类型(从 filterSchema 推导)
273
274
  */
274
- interface ListParams {
275
+ interface ListParams<F = Record<string, any>> {
275
276
  /** 页码(从1开始) */
276
277
  page?: number;
277
278
  /** 每页数量 */
@@ -281,7 +282,7 @@ interface ListParams {
281
282
  /** 排序方向 */
282
283
  sortOrder?: "asc" | "desc";
283
284
  /** 筛选条件 */
284
- filters?: Record<string, any>;
285
+ filters?: F;
285
286
  }
286
287
  /**
287
288
  * 列表查询结果
@@ -540,6 +541,9 @@ declare abstract class BaseModelFeature<T extends ZodObject, M = z$1.infer<T>> e
540
541
  * 表单操作类型
541
542
  */
542
543
  type FormAction = "create" | "edit";
544
+ interface BaseFormFeatureOptions<T extends ZodObject = z$1.ZodObject, M = z$1.infer<T>> extends BaseModelFeatureOptions<T, M> {
545
+ actions?: ActionButton[];
546
+ }
543
547
  /**
544
548
  * 表单 Feature 基类
545
549
  * 用于创建和编辑 Feature 的共同逻辑
@@ -570,6 +574,8 @@ declare abstract class BaseFormFeature<T extends ZodObject = z$1.ZodObject, M =
570
574
  * 获取取消按钮的跳转 URL
571
575
  */
572
576
  abstract getCancelUrl(context: FeatureContext): string | undefined;
577
+ protected options: BaseFormFeatureOptions<T, M>;
578
+ constructor(options: BaseFormFeatureOptions<T, M>);
573
579
  /**
574
580
  * 设置标题和描述到 context
575
581
  */
@@ -600,15 +606,15 @@ declare abstract class BaseFormFeature<T extends ZodObject = z$1.ZodObject, M =
600
606
  * 默认创建 Feature
601
607
  */
602
608
  declare class DefaultCreateFeature<T extends ZodObject = z$2.ZodObject, M = z$2.infer<T>> extends BaseFormFeature<T, M> {
603
- private options;
604
609
  private createItem;
605
- constructor(options: Omit<BaseModelFeatureOptions<T, M>, "name" | "type" | "routes" | "render" | "actions"> & {
610
+ constructor(createOptions: Omit<BaseFormFeatureOptions<T, M>, "name" | "type" | "routes" | "render"> & {
606
611
  schema: T;
607
612
  createItem: (data: Partial<M>) => Promise<M>;
608
613
  permission?: string;
609
614
  dialogSize?: DialogSize;
610
615
  closeOnBackdropClick?: boolean;
611
616
  groups?: FieldGroup[];
617
+ actions?: ActionButton[];
612
618
  });
613
619
  getFormAction(): "create";
614
620
  getSubmitUrl(context: FeatureContext): string;
@@ -662,10 +668,9 @@ declare class DefaultDetailFeature<T extends ZodObject = z$2.ZodObject, M = z$2.
662
668
  * 默认编辑 Feature
663
669
  */
664
670
  declare class DefaultEditFeature<T extends ZodObject = z$2.ZodObject, M = z$2.infer<T>, ID = keyof M> extends BaseFormFeature<T, M> {
665
- private options;
666
671
  private getItem;
667
672
  private updateItem;
668
- constructor(options: Omit<BaseModelFeatureOptions<T, M>, "name" | "type" | "routes" | "render" | "actions"> & {
673
+ constructor(editOptions: Omit<BaseModelFeatureOptions<T, M>, "name" | "type" | "routes" | "render" | "actions"> & {
669
674
  schema: T;
670
675
  getItem: (id: ID) => Promise<M | null | undefined>;
671
676
  updateItem: (id: ID, data: Partial<M>) => Promise<M | null>;
@@ -686,20 +691,26 @@ declare class DefaultEditFeature<T extends ZodObject = z$2.ZodObject, M = z$2.in
686
691
  * 默认列表 Feature
687
692
  */
688
693
 
694
+ /**
695
+ * 从 filterSchema 推导 filters 的类型
696
+ * 如果 filterSchema 是 optional,则 filters 也是 optional
697
+ */
698
+ type InferFilterType<FSchema extends z$2.ZodObject<any> | undefined> = FSchema extends z$2.ZodObject<infer Shape> ? Partial<z$2.infer<FSchema>> : Record<string, any> | undefined;
689
699
  /**
690
700
  * 默认列表 Feature
691
701
  */
692
- declare class DefaultListFeature<T extends ZodObject = z$2.ZodObject, M = z$2.infer<T>, ID = keyof M> extends BaseModelFeature<T, M> {
702
+ declare class DefaultListFeature<T extends ZodObject = z$2.ZodObject, M = z$2.infer<T>, ID = keyof M, FSchema extends z$2.ZodObject<any> | undefined = z$2.ZodObject<any> | undefined> extends BaseModelFeature<T, M> {
693
703
  private options;
694
704
  private getList;
695
705
  private deleteItem?;
696
706
  private filterSchema?;
697
707
  private filterFields;
698
708
  private openMode?;
699
- constructor(options: Omit<BaseModelFeatureOptions<T, M>, "name" | "type" | "routes" | "render" | "actions"> & {
700
- getList: (params: ListParams) => Promise<ListResult<M>>;
709
+ constructor(options: Omit<BaseModelFeatureOptions<T, M>, "name" | "type" | "routes" | "render"> & {
710
+ getList: (params: ListParams<InferFilterType<FSchema>>) => Promise<ListResult<M>>;
701
711
  deleteItem?: (id: ID) => Promise<boolean>;
702
- filterSchema?: z$2.ZodObject<any>;
712
+ filterSchema?: FSchema;
713
+ actions?: ActionButton[];
703
714
  openMode?: {
704
715
  create?: OpenMode;
705
716
  detail?: OpenMode;
@@ -756,9 +767,13 @@ declare function getUserInfo(ctx: Context, authProvider?: AuthProvider): Promise
756
767
  */
757
768
 
758
769
  /**
759
- * 解析列表查询参数
770
+ * 解析列表查询参数(带 filterSchema 类型推导)
771
+ */
772
+ declare function parseListParams<FSchema extends z$2.ZodObject<any>>(ctx: Context, filterSchema: FSchema): ListParams<Partial<z$2.infer<FSchema>>>;
773
+ /**
774
+ * 解析列表查询参数(不带 filterSchema)
760
775
  */
761
- declare function parseListParams(ctx: Context): ListParams;
776
+ declare function parseListParams(ctx: Context, filterSchema?: undefined): ListParams<Record<string, any> | undefined>;
762
777
 
763
778
  /**
764
779
  * 路径工具函数
@@ -837,18 +852,34 @@ interface ErrorAlertProps {
837
852
  */
838
853
  declare function ErrorAlert(props: ErrorAlertProps): hono_jsx_jsx_dev_runtime.JSX.Element;
839
854
 
855
+ /**
856
+ * 动态筛选组件的类型定义
857
+ */
858
+
859
+ /**
860
+ * 动态筛选组件 Props
861
+ */
862
+ interface DynamicFiltersProps {
863
+ /** 可用的筛选字段 */
864
+ fields: FormField[];
865
+ /** 列表路径(用于提交筛选表单) */
866
+ listPath: string;
867
+ /** 当前筛选参数 */
868
+ currentFilters?: Record<string, any> | undefined;
869
+ }
870
+
840
871
  interface FilterFormProps {
841
872
  /** 筛选字段 */
842
873
  fields: FormField[];
843
874
  /** 列表路径(用于提交筛选表单) */
844
875
  listPath: string;
845
876
  /** 当前筛选参数 */
846
- currentFilters?: Record<string, any>;
877
+ currentFilters?: Record<string, any> | undefined;
847
878
  }
848
879
  /**
849
- * 筛选表单组件
880
+ * 动态筛选组件
850
881
  */
851
- declare function FilterForm(props: FilterFormProps): hono_jsx_jsx_dev_runtime.JSX.Element | null;
882
+ declare function DynamicFilters(props: FilterFormProps): hono_jsx_jsx_dev_runtime.JSX.Element | null;
852
883
 
853
884
  /**
854
885
  * 面包屑组件
@@ -1140,4 +1171,4 @@ interface SortableListProps {
1140
1171
  */
1141
1172
  declare function SortableList(props: SortableListProps): hono_jsx_jsx_dev_runtime.JSX.Element;
1142
1173
 
1143
- export { type ActionButton, type AuthProvider, BaseFeature, BaseFormFeature, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, ColumnRenderer, CustomFeature, DefaultCreateFeature, DefaultDeleteFeature, DefaultDetailFeature, DefaultEditFeature, DefaultListFeature, DetailFieldRenderer, Dialog, type DialogProps, type DialogSize, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, type Feature, type FeatureContext, type FeatureType, type FieldGroup, type FieldRenderer, type FieldRendererProps, FilterForm, type FormAction, type FormField, type FormGroup, FragmentFeature, 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 };
1174
+ export { type ActionButton, type AuthProvider, BaseFeature, BaseFormFeature, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, ColumnRenderer, CustomFeature, DefaultCreateFeature, DefaultDeleteFeature, DefaultDetailFeature, DefaultEditFeature, DefaultListFeature, DetailFieldRenderer, Dialog, type DialogProps, type DialogSize, DynamicFilters, type DynamicFiltersProps, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, type Feature, type FeatureContext, type FeatureType, type FieldGroup, type FieldRenderer, type FieldRendererProps, type FormAction, type FormField, type FormGroup, FragmentFeature, 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 };
package/dist/index.d.ts CHANGED
@@ -270,8 +270,9 @@ interface Feature {
270
270
  }
271
271
  /**
272
272
  * 列表查询参数
273
+ * @template F 筛选条件的类型(从 filterSchema 推导)
273
274
  */
274
- interface ListParams {
275
+ interface ListParams<F = Record<string, any>> {
275
276
  /** 页码(从1开始) */
276
277
  page?: number;
277
278
  /** 每页数量 */
@@ -281,7 +282,7 @@ interface ListParams {
281
282
  /** 排序方向 */
282
283
  sortOrder?: "asc" | "desc";
283
284
  /** 筛选条件 */
284
- filters?: Record<string, any>;
285
+ filters?: F;
285
286
  }
286
287
  /**
287
288
  * 列表查询结果
@@ -540,6 +541,9 @@ declare abstract class BaseModelFeature<T extends ZodObject, M = z$1.infer<T>> e
540
541
  * 表单操作类型
541
542
  */
542
543
  type FormAction = "create" | "edit";
544
+ interface BaseFormFeatureOptions<T extends ZodObject = z$1.ZodObject, M = z$1.infer<T>> extends BaseModelFeatureOptions<T, M> {
545
+ actions?: ActionButton[];
546
+ }
543
547
  /**
544
548
  * 表单 Feature 基类
545
549
  * 用于创建和编辑 Feature 的共同逻辑
@@ -570,6 +574,8 @@ declare abstract class BaseFormFeature<T extends ZodObject = z$1.ZodObject, M =
570
574
  * 获取取消按钮的跳转 URL
571
575
  */
572
576
  abstract getCancelUrl(context: FeatureContext): string | undefined;
577
+ protected options: BaseFormFeatureOptions<T, M>;
578
+ constructor(options: BaseFormFeatureOptions<T, M>);
573
579
  /**
574
580
  * 设置标题和描述到 context
575
581
  */
@@ -600,15 +606,15 @@ declare abstract class BaseFormFeature<T extends ZodObject = z$1.ZodObject, M =
600
606
  * 默认创建 Feature
601
607
  */
602
608
  declare class DefaultCreateFeature<T extends ZodObject = z$2.ZodObject, M = z$2.infer<T>> extends BaseFormFeature<T, M> {
603
- private options;
604
609
  private createItem;
605
- constructor(options: Omit<BaseModelFeatureOptions<T, M>, "name" | "type" | "routes" | "render" | "actions"> & {
610
+ constructor(createOptions: Omit<BaseFormFeatureOptions<T, M>, "name" | "type" | "routes" | "render"> & {
606
611
  schema: T;
607
612
  createItem: (data: Partial<M>) => Promise<M>;
608
613
  permission?: string;
609
614
  dialogSize?: DialogSize;
610
615
  closeOnBackdropClick?: boolean;
611
616
  groups?: FieldGroup[];
617
+ actions?: ActionButton[];
612
618
  });
613
619
  getFormAction(): "create";
614
620
  getSubmitUrl(context: FeatureContext): string;
@@ -662,10 +668,9 @@ declare class DefaultDetailFeature<T extends ZodObject = z$2.ZodObject, M = z$2.
662
668
  * 默认编辑 Feature
663
669
  */
664
670
  declare class DefaultEditFeature<T extends ZodObject = z$2.ZodObject, M = z$2.infer<T>, ID = keyof M> extends BaseFormFeature<T, M> {
665
- private options;
666
671
  private getItem;
667
672
  private updateItem;
668
- constructor(options: Omit<BaseModelFeatureOptions<T, M>, "name" | "type" | "routes" | "render" | "actions"> & {
673
+ constructor(editOptions: Omit<BaseModelFeatureOptions<T, M>, "name" | "type" | "routes" | "render" | "actions"> & {
669
674
  schema: T;
670
675
  getItem: (id: ID) => Promise<M | null | undefined>;
671
676
  updateItem: (id: ID, data: Partial<M>) => Promise<M | null>;
@@ -686,20 +691,26 @@ declare class DefaultEditFeature<T extends ZodObject = z$2.ZodObject, M = z$2.in
686
691
  * 默认列表 Feature
687
692
  */
688
693
 
694
+ /**
695
+ * 从 filterSchema 推导 filters 的类型
696
+ * 如果 filterSchema 是 optional,则 filters 也是 optional
697
+ */
698
+ type InferFilterType<FSchema extends z$2.ZodObject<any> | undefined> = FSchema extends z$2.ZodObject<infer Shape> ? Partial<z$2.infer<FSchema>> : Record<string, any> | undefined;
689
699
  /**
690
700
  * 默认列表 Feature
691
701
  */
692
- declare class DefaultListFeature<T extends ZodObject = z$2.ZodObject, M = z$2.infer<T>, ID = keyof M> extends BaseModelFeature<T, M> {
702
+ declare class DefaultListFeature<T extends ZodObject = z$2.ZodObject, M = z$2.infer<T>, ID = keyof M, FSchema extends z$2.ZodObject<any> | undefined = z$2.ZodObject<any> | undefined> extends BaseModelFeature<T, M> {
693
703
  private options;
694
704
  private getList;
695
705
  private deleteItem?;
696
706
  private filterSchema?;
697
707
  private filterFields;
698
708
  private openMode?;
699
- constructor(options: Omit<BaseModelFeatureOptions<T, M>, "name" | "type" | "routes" | "render" | "actions"> & {
700
- getList: (params: ListParams) => Promise<ListResult<M>>;
709
+ constructor(options: Omit<BaseModelFeatureOptions<T, M>, "name" | "type" | "routes" | "render"> & {
710
+ getList: (params: ListParams<InferFilterType<FSchema>>) => Promise<ListResult<M>>;
701
711
  deleteItem?: (id: ID) => Promise<boolean>;
702
- filterSchema?: z$2.ZodObject<any>;
712
+ filterSchema?: FSchema;
713
+ actions?: ActionButton[];
703
714
  openMode?: {
704
715
  create?: OpenMode;
705
716
  detail?: OpenMode;
@@ -756,9 +767,13 @@ declare function getUserInfo(ctx: Context, authProvider?: AuthProvider): Promise
756
767
  */
757
768
 
758
769
  /**
759
- * 解析列表查询参数
770
+ * 解析列表查询参数(带 filterSchema 类型推导)
771
+ */
772
+ declare function parseListParams<FSchema extends z$2.ZodObject<any>>(ctx: Context, filterSchema: FSchema): ListParams<Partial<z$2.infer<FSchema>>>;
773
+ /**
774
+ * 解析列表查询参数(不带 filterSchema)
760
775
  */
761
- declare function parseListParams(ctx: Context): ListParams;
776
+ declare function parseListParams(ctx: Context, filterSchema?: undefined): ListParams<Record<string, any> | undefined>;
762
777
 
763
778
  /**
764
779
  * 路径工具函数
@@ -837,18 +852,34 @@ interface ErrorAlertProps {
837
852
  */
838
853
  declare function ErrorAlert(props: ErrorAlertProps): hono_jsx_jsx_dev_runtime.JSX.Element;
839
854
 
855
+ /**
856
+ * 动态筛选组件的类型定义
857
+ */
858
+
859
+ /**
860
+ * 动态筛选组件 Props
861
+ */
862
+ interface DynamicFiltersProps {
863
+ /** 可用的筛选字段 */
864
+ fields: FormField[];
865
+ /** 列表路径(用于提交筛选表单) */
866
+ listPath: string;
867
+ /** 当前筛选参数 */
868
+ currentFilters?: Record<string, any> | undefined;
869
+ }
870
+
840
871
  interface FilterFormProps {
841
872
  /** 筛选字段 */
842
873
  fields: FormField[];
843
874
  /** 列表路径(用于提交筛选表单) */
844
875
  listPath: string;
845
876
  /** 当前筛选参数 */
846
- currentFilters?: Record<string, any>;
877
+ currentFilters?: Record<string, any> | undefined;
847
878
  }
848
879
  /**
849
- * 筛选表单组件
880
+ * 动态筛选组件
850
881
  */
851
- declare function FilterForm(props: FilterFormProps): hono_jsx_jsx_dev_runtime.JSX.Element | null;
882
+ declare function DynamicFilters(props: FilterFormProps): hono_jsx_jsx_dev_runtime.JSX.Element | null;
852
883
 
853
884
  /**
854
885
  * 面包屑组件
@@ -1140,4 +1171,4 @@ interface SortableListProps {
1140
1171
  */
1141
1172
  declare function SortableList(props: SortableListProps): hono_jsx_jsx_dev_runtime.JSX.Element;
1142
1173
 
1143
- export { type ActionButton, type AuthProvider, BaseFeature, BaseFormFeature, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, ColumnRenderer, CustomFeature, DefaultCreateFeature, DefaultDeleteFeature, DefaultDetailFeature, DefaultEditFeature, DefaultListFeature, DetailFieldRenderer, Dialog, type DialogProps, type DialogSize, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, type Feature, type FeatureContext, type FeatureType, type FieldGroup, type FieldRenderer, type FieldRendererProps, FilterForm, type FormAction, type FormField, type FormGroup, FragmentFeature, 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 };
1174
+ export { type ActionButton, type AuthProvider, BaseFeature, BaseFormFeature, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, ColumnRenderer, CustomFeature, DefaultCreateFeature, DefaultDeleteFeature, DefaultDetailFeature, DefaultEditFeature, DefaultListFeature, DetailFieldRenderer, Dialog, type DialogProps, type DialogSize, DynamicFilters, type DynamicFiltersProps, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, type Feature, type FeatureContext, type FeatureType, type FieldGroup, type FieldRenderer, type FieldRendererProps, type FormAction, type FormField, type FormGroup, FragmentFeature, 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 };