disguise-ui 0.2.0 → 0.2.1

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.
Files changed (83) hide show
  1. package/dist/disguise-ui.js +145 -93
  2. package/dist/style.css +1 -1
  3. package/dist/types/components/async-select/async-select.type.d.ts +14 -0
  4. package/dist/types/components/async-select/async-select.utils.d.ts +12 -0
  5. package/dist/types/components/async-select/async-select.vue.d.ts +52 -0
  6. package/dist/types/components/async-select/index.d.ts +2 -0
  7. package/dist/types/components/card/index.vue.d.ts +15 -0
  8. package/dist/types/components/crud-page/index.d.ts +2 -0
  9. package/dist/types/components/crud-page/index.type.d.ts +105 -0
  10. package/dist/types/components/crud-page/index.vue.d.ts +66 -0
  11. package/dist/types/components/dialog-list/index.vue.d.ts +540 -0
  12. package/dist/types/components/dict-tag/index.vue.d.ts +18 -0
  13. package/dist/types/components/disguise-icon/index.vue.d.ts +14 -0
  14. package/dist/types/components/drawer-form-page/index.d.ts +3 -0
  15. package/dist/types/components/drawer-form-page/index.type.d.ts +76 -0
  16. package/dist/types/components/drawer-form-page/index.vue.d.ts +94 -0
  17. package/dist/types/components/drawer-form-page/use-drawer-form-page.d.ts +4 -0
  18. package/dist/types/components/file-upload/components/file-status.vue.d.ts +50 -0
  19. package/dist/types/components/file-upload/composables/use-file-type.d.ts +41 -0
  20. package/dist/types/components/file-upload/composables/use-file-upload.d.ts +82 -0
  21. package/dist/types/components/file-upload/composables/use-file-upload.utils.d.ts +9 -0
  22. package/dist/types/components/file-upload/composables/use-multiple-file-upload.d.ts +119 -0
  23. package/dist/types/components/file-upload/file-upload.type.d.ts +68 -0
  24. package/dist/types/components/file-upload/file-upload.vue.d.ts +33 -0
  25. package/dist/types/components/file-upload/index.d.ts +2 -0
  26. package/dist/types/components/image-upload/index.vue.d.ts +26 -0
  27. package/dist/types/components/images-view/index.vue.d.ts +18 -0
  28. package/dist/types/components/import-dialog/index.d.ts +3 -0
  29. package/dist/types/components/import-dialog/index.type.d.ts +101 -0
  30. package/dist/types/components/import-dialog/index.vue.d.ts +35 -0
  31. package/dist/types/components/picture-upload/index.d.ts +3 -0
  32. package/dist/types/components/picture-upload/picture-upload.vue.d.ts +52 -0
  33. package/dist/types/components/rich-text-editor/index.vue.d.ts +35 -0
  34. package/dist/types/components/schema-form/index.d.ts +5 -0
  35. package/dist/types/components/schema-form/readonly-text.vue.d.ts +7 -0
  36. package/dist/types/components/schema-form/schema-form-item.vue.d.ts +36 -0
  37. package/dist/types/components/schema-form/schema-form-registry.d.ts +18 -0
  38. package/dist/types/components/schema-form/schema-form.type.d.ts +190 -0
  39. package/dist/types/components/schema-form/schema-form.util.d.ts +10 -0
  40. package/dist/types/components/schema-form/schema-form.vue.d.ts +59 -0
  41. package/dist/types/components/schema-form/translate-field.vue.d.ts +27 -0
  42. package/dist/types/components/schema-form/translate-toolbar.vue.d.ts +24 -0
  43. package/dist/types/components/schema-form/use-field-options.d.ts +4 -0
  44. package/dist/types/components/search-form/index.d.ts +2 -0
  45. package/dist/types/components/search-form/index.type.d.ts +3 -0
  46. package/dist/types/components/search-form/index.vue.d.ts +66 -0
  47. package/dist/types/components/table-entity/cells/avatar-cell.vue.d.ts +10 -0
  48. package/dist/types/components/table-entity/cells/file-cell.vue.d.ts +20 -0
  49. package/dist/types/components/table-entity/cells/index.d.ts +10 -0
  50. package/dist/types/components/table-entity/cells/list-expand-cell.vue.d.ts +19 -0
  51. package/dist/types/components/table-entity/cells/picture-cell.vue.d.ts +22 -0
  52. package/dist/types/components/table-entity/cells/price-cell.vue.d.ts +10 -0
  53. package/dist/types/components/table-entity/components/ColumnFixedPanel.vue.d.ts +13 -0
  54. package/dist/types/components/table-entity/components/ColumnSettingsPanel.vue.d.ts +25 -0
  55. package/dist/types/components/table-entity/composables/use-column-fixed.d.ts +15 -0
  56. package/dist/types/components/table-entity/composables/use-column-resize.d.ts +25 -0
  57. package/dist/types/components/table-entity/composables/use-column-settings.d.ts +41 -0
  58. package/dist/types/components/table-entity/composables/use-row-drag.d.ts +21 -0
  59. package/dist/types/components/table-entity/composables/use-table-selection.d.ts +23 -0
  60. package/dist/types/components/table-entity/index.type.d.ts +189 -0
  61. package/dist/types/components/table-entity/index.vue.d.ts +101 -0
  62. package/dist/types/components/table-entity/utils/column-slots.d.ts +8 -0
  63. package/dist/types/components/table-entity/utils/column-utils.d.ts +7 -0
  64. package/dist/types/components/table-entity/utils/list-expand.d.ts +9 -0
  65. package/dist/types/components/user-avatar-info/index.vue.d.ts +114 -0
  66. package/dist/types/composables/use-dict-data.d.ts +192 -0
  67. package/dist/types/composables/use-image-url.d.ts +8 -0
  68. package/dist/types/entities/index.d.ts +2 -0
  69. package/dist/types/entities/registry.d.ts +33 -0
  70. package/dist/types/index.d.ts +25 -0
  71. package/dist/types/runtime/access.d.ts +13 -0
  72. package/dist/types/runtime/context.d.ts +48 -0
  73. package/dist/types/runtime/dict.d.ts +22 -0
  74. package/dist/types/runtime/i18n.d.ts +12 -0
  75. package/dist/types/runtime/modal.d.ts +31 -0
  76. package/dist/types/runtime/preferences.d.ts +6 -0
  77. package/dist/types/runtime/request.d.ts +19 -0
  78. package/dist/types/runtime/types.d.ts +1 -0
  79. package/dist/types/runtime/upload.d.ts +5 -0
  80. package/dist/types/runtime/utils.d.ts +16 -0
  81. package/dist/types/services/file-upload.d.ts +11 -0
  82. package/dist/types/setup.d.ts +7 -0
  83. package/package.json +6 -3
@@ -0,0 +1,101 @@
1
+ /** ****************************** 基础类型 ********************************/
2
+ export type ImportDialogMode = 'create' | 'update' | (string & {});
3
+ export type ImportDialogStep = 'importing' | 'mapping' | 'preview' | 'upload';
4
+ /** ****************************** 组件数据 ********************************/
5
+ export interface ImportDialogModeOption {
6
+ label: string;
7
+ value: ImportDialogMode;
8
+ disabled?: boolean;
9
+ }
10
+ export interface ImportDialogSheetOption {
11
+ label: string;
12
+ value: string;
13
+ }
14
+ export interface ImportDialogPreviewColumn {
15
+ prop: string;
16
+ label: string;
17
+ width?: number | string;
18
+ minWidth?: number | string;
19
+ }
20
+ export interface ImportDialogTargetField {
21
+ field: string;
22
+ label: string;
23
+ required?: boolean;
24
+ allowDuplicateCheck?: boolean;
25
+ }
26
+ export interface ImportDialogMappingItem {
27
+ targetField: string;
28
+ targetLabel: string;
29
+ sourceColumn: string;
30
+ required?: boolean;
31
+ duplicateCheck: boolean;
32
+ allowDuplicateCheck?: boolean;
33
+ }
34
+ export interface ImportDialogParsePayload {
35
+ file: File;
36
+ mode: ImportDialogMode;
37
+ sheet?: string;
38
+ }
39
+ export interface ImportDialogParseResult {
40
+ fileName?: string;
41
+ total: number;
42
+ sheets: ImportDialogSheetOption[];
43
+ currentSheet?: string;
44
+ previewColumns: ImportDialogPreviewColumn[];
45
+ previewRows: Record<string, unknown>[];
46
+ mappings?: ImportDialogMappingItem[];
47
+ }
48
+ export interface ImportDialogSubmitPayload {
49
+ file: File;
50
+ mode: ImportDialogMode;
51
+ sheet: string;
52
+ mappings: ImportDialogMappingItem[];
53
+ onProgress?: (progress: number, message?: string) => void;
54
+ }
55
+ export interface ImportDialogSubmitResult {
56
+ success: boolean;
57
+ title?: string;
58
+ description?: string;
59
+ detail?: string;
60
+ successCount?: number;
61
+ failureCount?: number;
62
+ }
63
+ /** ****************************** 组件协议 ********************************/
64
+ /** 导入弹窗的接口地址配置,可同时配置上传接口和模板下载接口。 */
65
+ export interface ImportDialogUrlConfig {
66
+ /** 上传导入接口 */
67
+ api?: string;
68
+ /** 模板下载接口 */
69
+ templateUrl?: string;
70
+ /** 模板下载请求方法,默认 GET */
71
+ templateMethod?: 'GET' | 'POST';
72
+ }
73
+ export interface ImportDialogProps {
74
+ modelValue: boolean;
75
+ /** 直接上传导入接口,传入后组件内部负责提交文件 */
76
+ api?: string;
77
+ /** 下载导入模板接口,传入后组件内部负责下载文件 */
78
+ templateUrl?: string;
79
+ /** 下载导入模板请求方法,默认 GET */
80
+ templateMethod?: 'GET' | 'POST';
81
+ title?: string;
82
+ defaultMode?: ImportDialogMode;
83
+ modes?: ImportDialogModeOption[];
84
+ accept?: string[];
85
+ maxSize?: number;
86
+ maxPreviewCount?: number;
87
+ tips?: string[];
88
+ targetFields?: ImportDialogTargetField[];
89
+ parseFile?: (payload: ImportDialogParsePayload) => Promise<ImportDialogParseResult>;
90
+ submitImport?: (payload: ImportDialogSubmitPayload) => Promise<ImportDialogSubmitResult>;
91
+ resetOnClose?: boolean;
92
+ templateName?: string;
93
+ }
94
+ export interface ImportDialogEmits {
95
+ (e: 'update:modelValue', value: boolean): void;
96
+ (e: 'downloadTemplate'): void;
97
+ (e: 'fileChange', file: File | null): void;
98
+ (e: 'success', result: ImportDialogSubmitResult): void;
99
+ (e: 'error', result: Error | ImportDialogSubmitResult): void;
100
+ (e: 'cancel'): void;
101
+ }
@@ -0,0 +1,35 @@
1
+ import type { ImportDialogMode, ImportDialogModeOption, ImportDialogParseResult, ImportDialogProps, ImportDialogSubmitResult } from './index.type';
2
+ declare const __VLS_export: import("vue").DefineComponent<ImportDialogProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
3
+ "update:modelValue": (value: boolean) => any;
4
+ cancel: () => any;
5
+ error: (result: Error | ImportDialogSubmitResult) => any;
6
+ downloadTemplate: () => any;
7
+ fileChange: (file: File | null) => any;
8
+ success: (result: ImportDialogSubmitResult) => any;
9
+ }, string, import("vue").PublicProps, Readonly<ImportDialogProps> & Readonly<{
10
+ "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
11
+ onCancel?: (() => any) | undefined;
12
+ onError?: ((result: Error | ImportDialogSubmitResult) => any) | undefined;
13
+ onDownloadTemplate?: (() => any) | undefined;
14
+ onFileChange?: ((file: File | null) => any) | undefined;
15
+ onSuccess?: ((result: ImportDialogSubmitResult) => any) | undefined;
16
+ }>, {
17
+ modelValue: boolean;
18
+ title: string;
19
+ api: string;
20
+ templateUrl: string;
21
+ templateMethod: "POST" | "GET";
22
+ defaultMode: ImportDialogMode;
23
+ modes: ImportDialogModeOption[];
24
+ accept: string[];
25
+ maxSize: number;
26
+ maxPreviewCount: number;
27
+ tips: string[];
28
+ targetFields: import("./index.type").ImportDialogTargetField[];
29
+ parseFile: (payload: import("./index.type").ImportDialogParsePayload) => Promise<ImportDialogParseResult>;
30
+ submitImport: (payload: import("./index.type").ImportDialogSubmitPayload) => Promise<ImportDialogSubmitResult>;
31
+ resetOnClose: boolean;
32
+ templateName: string;
33
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
+ declare const _default: typeof __VLS_export;
35
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import PictureUpload from './picture-upload.vue';
2
+ export { PictureUpload };
3
+ export default PictureUpload;
@@ -0,0 +1,52 @@
1
+ import type { AttachmentData } from '../file-upload/file-upload.type';
2
+ /** ****************************** 类型定义 ********************************/
3
+ interface PictureUploadProps {
4
+ modelValue?: AttachmentData | AttachmentData[] | string | string[];
5
+ disabled?: boolean;
6
+ maxSize?: number;
7
+ accept?: string[];
8
+ width?: number;
9
+ height?: number;
10
+ showPreview?: boolean;
11
+ showDownload?: boolean;
12
+ showRemove?: boolean;
13
+ selected?: boolean;
14
+ errorMessage?: string;
15
+ /** OSS 保存目录,相对 attachment/v3 */
16
+ baseFolder?: string;
17
+ /** 是否给图片加中心水印 */
18
+ addWatermark?: boolean;
19
+ /** 最大图片数量,大于 1 时启用多图模式 */
20
+ maxCount?: number;
21
+ }
22
+ declare const __VLS_export: import("vue").DefineComponent<PictureUploadProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
23
+ "update:modelValue": (value: string | string[] | AttachmentData | AttachmentData[] | undefined) => any;
24
+ uploadSuccess: (file: AttachmentData) => any;
25
+ uploadError: (error: Error) => any;
26
+ remove: (file: AttachmentData) => any;
27
+ preview: (file: AttachmentData) => any;
28
+ download: (file: AttachmentData) => any;
29
+ }, string, import("vue").PublicProps, Readonly<PictureUploadProps> & Readonly<{
30
+ "onUpdate:modelValue"?: ((value: string | string[] | AttachmentData | AttachmentData[] | undefined) => any) | undefined;
31
+ onUploadSuccess?: ((file: AttachmentData) => any) | undefined;
32
+ onUploadError?: ((error: Error) => any) | undefined;
33
+ onRemove?: ((file: AttachmentData) => any) | undefined;
34
+ onPreview?: ((file: AttachmentData) => any) | undefined;
35
+ onDownload?: ((file: AttachmentData) => any) | undefined;
36
+ }>, {
37
+ modelValue: string | string[] | AttachmentData | AttachmentData[];
38
+ width: number;
39
+ accept: string[];
40
+ maxSize: number;
41
+ height: number;
42
+ disabled: boolean;
43
+ errorMessage: string;
44
+ showPreview: boolean;
45
+ showDownload: boolean;
46
+ showRemove: boolean;
47
+ selected: boolean;
48
+ maxCount: number;
49
+ baseFolder: string;
50
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
51
+ declare const _default: typeof __VLS_export;
52
+ export default _default;
@@ -0,0 +1,35 @@
1
+ import type { Editor } from '@tiptap/vue-3';
2
+ type __VLS_Props = {
3
+ editable?: boolean;
4
+ maxHeight?: string;
5
+ modelValue?: string;
6
+ placeholder?: string;
7
+ };
8
+ declare function clearFormat(): void;
9
+ declare const __VLS_template: () => {
10
+ __VLS_Slots: {
11
+ 'toolbar-append'?: (props: {}) => any;
12
+ };
13
+ };
14
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
15
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
16
+ editor: import("vue").ShallowRef<Editor | undefined, Editor | undefined>;
17
+ clearFormat: typeof clearFormat;
18
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ "update:modelValue": (value: string) => any;
20
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
21
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
22
+ }>, {
23
+ modelValue: string;
24
+ placeholder: string;
25
+ editable: boolean;
26
+ maxHeight: string;
27
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
+ declare const _default: typeof __VLS_export;
30
+ export default _default;
31
+ type __VLS_WithSlots<T, S> = T & {
32
+ new (): {
33
+ $slots: S;
34
+ };
35
+ };
@@ -0,0 +1,5 @@
1
+ export { registerSchemaFormComponents, resolveSchemaFormComponent, } from './schema-form-registry';
2
+ export type { SchemaFormComponent, SchemaFormComponentConfig, SchemaFormComponentRegistration, } from './schema-form-registry';
3
+ export type { ApiFieldOptions, FieldCondition, FieldContext, FieldOption, FieldOptionsResolver, FieldPropsContext, FieldPropsResolver, SchemaFormField, SchemaFormGroup, SchemaFormItem, SchemaFormMode, SchemaFormProps, SchemaFormSlotProps, TranslateCommand, TranslateConfig, TranslateHandlerContext, TranslateLanguage, TranslateLanguageValues, } from './schema-form.type';
4
+ export { DEFAULT_TRANSLATE_LANGUAGES } from './schema-form.type';
5
+ export { default as SchemaForm } from './schema-form.vue';
@@ -0,0 +1,7 @@
1
+ type __VLS_Props = {
2
+ copyable?: boolean;
3
+ value?: any;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,36 @@
1
+ import type { FieldContext, ResolvedField } from './schema-form.type';
2
+ type __VLS_Props = {
3
+ disabled?: boolean;
4
+ field: ResolvedField;
5
+ context?: FieldContext;
6
+ /** 分组内的子项由容器统一出标签 */
7
+ hideLabel?: boolean;
8
+ labelPosition?: 'left' | 'right' | 'top';
9
+ modelValue?: any;
10
+ readonly?: boolean;
11
+ };
12
+ declare function update(value: any): void;
13
+ declare const __VLS_template: () => {
14
+ __VLS_Slots: {
15
+ default?: (props: {
16
+ field: ResolvedField;
17
+ value: any;
18
+ disabled: boolean;
19
+ updateValue: typeof update;
20
+ }) => any;
21
+ };
22
+ };
23
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
24
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
+ "update:modelValue": (value: any) => any;
26
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
27
+ "onUpdate:modelValue"?: ((value: any) => any) | undefined;
28
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
29
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
30
+ declare const _default: typeof __VLS_export;
31
+ export default _default;
32
+ type __VLS_WithSlots<T, S> = T & {
33
+ new (): {
34
+ $slots: S;
35
+ };
36
+ };
@@ -0,0 +1,18 @@
1
+ import type { Component } from 'vue';
2
+ export type SchemaFormComponent = Component;
3
+ export type SchemaFormComponentConfig = {
4
+ component: SchemaFormComponent;
5
+ modelProp?: string;
6
+ updateEvent?: string;
7
+ valueExtractor?: (value: any) => any;
8
+ };
9
+ export type SchemaFormComponentRegistration = SchemaFormComponent | SchemaFormComponentConfig;
10
+ /**
11
+ * 注册 SchemaForm 可通过 schema.component 使用的组件。
12
+ *
13
+ * 默认按 v-model:modelValue 绑定。组件使用其他值属性时,可配置
14
+ * modelProp 与 updateEvent,例如:
15
+ * { component: MyCheckbox, modelProp: 'checked', updateEvent: 'update:checked' }
16
+ */
17
+ export declare function registerSchemaFormComponents(components: Partial<Record<string, SchemaFormComponentRegistration>>): void;
18
+ export declare function resolveSchemaFormComponent(component: SchemaFormComponent | SchemaFormComponentConfig | string | undefined): SchemaFormComponentConfig | undefined;
@@ -0,0 +1,190 @@
1
+ import type { FormItemRule } from 'element-plus';
2
+ import type { SchemaFormComponent, SchemaFormComponentConfig } from './schema-form-registry';
3
+ /** ****************************** 基础 ********************************/
4
+ export type SchemaFormMode = 'create' | 'edit' | 'view';
5
+ export type FieldOption = {
6
+ flag?: string;
7
+ label: string;
8
+ value: any;
9
+ };
10
+ export type SchemaFormProps = {
11
+ /** 整体栅格列数,字段可用 span 单独覆盖 */
12
+ columns?: number;
13
+ disabled?: boolean;
14
+ /** 为 true 时输入框只显示下边框;不传则使用全边框 */
15
+ underline?: boolean;
16
+ /** 标签文字在 label 宽度内的对齐 */
17
+ labelAlign?: 'center' | 'left' | 'right';
18
+ /** 表单项之间的纵向间距 */
19
+ itemGap?: number | string;
20
+ /** 分组相对其他表单项额外增加的上下间距 */
21
+ groupGap?: number | string;
22
+ /** 标签与控件之间的间距 */
23
+ labelGap?: number | string;
24
+ /** 标签相对控件的位置 */
25
+ labelPosition?: 'left' | 'right' | 'top';
26
+ labelWidth?: number | string;
27
+ loading?: boolean;
28
+ mode?: SchemaFormMode;
29
+ schema?: SchemaFormItem[];
30
+ };
31
+ /** 布尔属性的函数形态可以拿到当前模式与全量表单值,用于字段联动 */
32
+ export type FieldContext = {
33
+ mode: SchemaFormMode;
34
+ values: Record<string, any>;
35
+ };
36
+ export type FieldCondition = ((ctx: FieldContext) => boolean) | boolean;
37
+ export type FieldOptionsResolver = (ctx: FieldContext) => FieldOption[];
38
+ export type FieldPropsContext = FieldContext & {
39
+ updateValue: (value: any) => void;
40
+ };
41
+ export type FieldPropsResolver = (ctx: FieldPropsContext) => Record<string, any>;
42
+ export type TranslateLanguage = {
43
+ code: string;
44
+ label: string;
45
+ };
46
+ export type TranslateCommand = 'polish' | 'translate';
47
+ export type TranslateLanguageValues = Record<string, unknown>;
48
+ export type TranslateHandlerContext = {
49
+ /**
50
+ * 精翻 普翻
51
+ */
52
+ command: TranslateCommand;
53
+ fieldProp: string;
54
+ fieldValue: TranslateLanguageValues;
55
+ sourceLanguage: string;
56
+ sourceValue: unknown;
57
+ targetLanguage: string;
58
+ targetLanguages: string[];
59
+ /** 当前字段的翻译前值;回调返回的对象会与此值合并 */
60
+ before: TranslateLanguageValues;
61
+ } & FieldContext;
62
+ export declare const DEFAULT_TRANSLATE_LANGUAGES: TranslateLanguage[];
63
+ export type TranslateConfig = {
64
+ language?: TranslateLanguage[];
65
+ /** 多语言输入布局;rich-text、text、textarea 默认都使用 tabs */
66
+ layout?: 'grid' | 'tabs';
67
+ /** 未配置时使用显式提示的模拟翻译(复制源文到目标语言) */
68
+ translate?: (ctx: TranslateHandlerContext) => Partial<TranslateLanguageValues> | Promise<Partial<TranslateLanguageValues> | undefined> | undefined;
69
+ };
70
+ export type FieldType = 'async-select' | 'checkbox' | 'component' | 'date' | 'datetime' | 'file' | 'number' | 'picture' | 'radio' | 'rich-text' | 'select' | 'slot' | 'switch' | 'text' | 'textarea' | 'upload';
71
+ /** ****************************** 字段 ********************************/
72
+ type BaseField = {
73
+ /** 覆盖内置控件,或配合 type: 'component' 使用注册的自定义组件 */
74
+ component?: SchemaFormComponent | SchemaFormComponentConfig | string;
75
+ /** 只读态是否附带复制按钮,默认跟随 readonly */
76
+ copyable?: boolean;
77
+ defaultValue?: any;
78
+ disabled?: FieldCondition;
79
+ /** 新建时隐藏,等价于 hidden: ({ mode }) => mode === 'create' */
80
+ hideOnCreate?: boolean;
81
+ hideOnEdit?: boolean;
82
+ hidden?: FieldCondition;
83
+ /** 顶层字段必填;分组子项可不写,只用于占位符和校验文案 */
84
+ label?: string;
85
+ /** 在 ElRow 中强制另起一行,仍可使用 span 控制宽度 */
86
+ newRow?: boolean;
87
+ placeholder?: string;
88
+ /** 透传给底层控件的额外属性 */
89
+ props?: FieldPropsResolver | Record<string, any>;
90
+ prop: string;
91
+ /** 渲染为纯文本而非输入控件 */
92
+ readonly?: boolean;
93
+ /** 自动生成必填规则,与 rules 合并 */
94
+ required?: FieldCondition;
95
+ rules?: FormItemRule[];
96
+ /** 24 栅格占位,默认按表单的 columns 均分 */
97
+ span?: number;
98
+ /** 控件下方的灰色提示 */
99
+ tip?: string;
100
+ /** 为 text、textarea、rich-text 字段启用多语言编辑 */
101
+ translateConfig?: TranslateConfig;
102
+ };
103
+ export type ApiFieldOptions = {
104
+ entityKey: string;
105
+ labelKey?: string;
106
+ multiple?: boolean;
107
+ /** 附加查询条件 */
108
+ params?: Record<string, any>;
109
+ subtitleKey?: string;
110
+ valueKey?: string;
111
+ };
112
+ export type SchemaFormField = BaseField & ({
113
+ apiOptions: ApiFieldOptions;
114
+ optionSource?: 'api';
115
+ type: 'async-select';
116
+ } | {
117
+ component: SchemaFormComponent | SchemaFormComponentConfig | string;
118
+ type: 'component';
119
+ } | {
120
+ dictCode: string;
121
+ optionSource: 'dict';
122
+ type: 'async-select';
123
+ } | {
124
+ dictCode: string;
125
+ optionSource: 'dict';
126
+ type: 'checkbox' | 'radio' | 'select';
127
+ } | {
128
+ options: FieldOption[] | FieldOptionsResolver;
129
+ optionSource?: 'static';
130
+ type: 'checkbox' | 'radio' | 'select';
131
+ } | {
132
+ type: 'date' | 'datetime' | 'file' | 'listExpand' | 'number' | 'picture' | 'rich-text' | 'slot' | 'switch' | 'text' | 'textarea' | 'upload';
133
+ }) & {
134
+ label: string;
135
+ };
136
+ /** Omit 作用在联合类型上会丢掉各分支特有字段,分组子项必须按成员展开 */
137
+ type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
138
+ /** ****************************** 分组 ********************************/
139
+ /**
140
+ * 一个 label 下并排多个控件(如重量加单位)。容器自身没有 prop,
141
+ * 值仍由 children 平铺在表单对象里,它只负责标签与布局。
142
+ */
143
+ export type SchemaFormGroupChild = DistributiveOmit<SchemaFormField, 'label'> & {
144
+ label?: string;
145
+ };
146
+ export type SchemaFormGroup = {
147
+ /** 组内控件,按声明顺序横向排列,不支持再嵌套分组 */
148
+ children: SchemaFormGroupChild[];
149
+ /** 锚点分组标题下方的辅助说明 */
150
+ description?: string;
151
+ /** 整组禁用,与子项自身的 disabled 取或 */
152
+ disabled?: FieldCondition;
153
+ hideOnCreate?: boolean;
154
+ hideOnEdit?: boolean;
155
+ hidden?: FieldCondition;
156
+ label: string;
157
+ /** 在长表单顶部显示锚点导航 */
158
+ anchor?: boolean;
159
+ /** 在 ElRow 中强制另起一行,仍可使用 span 控制宽度 */
160
+ newRow?: boolean;
161
+ /** 24 栅格占位,默认按表单的 columns 均分 */
162
+ span?: number;
163
+ tip?: string;
164
+ type: 'group';
165
+ };
166
+ /** schema 的顶层元素:普通字段或分组容器 */
167
+ export type SchemaFormItem = SchemaFormField | SchemaFormGroup;
168
+ /**
169
+ * 组件内部使用的宽松形态:联合类型在模板里无法按 optionSource 收窄,
170
+ * 统一在入口处断言一次,避免每个分支重复断言。
171
+ */
172
+ export type ResolvedField = BaseField & {
173
+ apiOptions?: ApiFieldOptions;
174
+ dictCode?: string;
175
+ optionSource?: 'api' | 'dict' | 'static';
176
+ options?: FieldOption[] | FieldOptionsResolver;
177
+ type: FieldType;
178
+ };
179
+ export type ResolvedGroup = Omit<SchemaFormGroup, 'children'> & {
180
+ children: ResolvedField[];
181
+ };
182
+ export type ResolvedEntry = ResolvedField | ResolvedGroup;
183
+ /** ****************************** 插槽 ********************************/
184
+ export type SchemaFormSlotProps = {
185
+ disabled: boolean;
186
+ field: ResolvedField;
187
+ updateValue: (value: any) => void;
188
+ value: any;
189
+ };
190
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { FormItemRule } from 'element-plus';
2
+ import type { FieldCondition, FieldContext, ResolvedEntry, ResolvedField, ResolvedGroup } from './schema-form.type';
3
+ export declare function isChoiceField(field: ResolvedField): boolean;
4
+ export declare function isGroup(entry: ResolvedEntry): entry is ResolvedGroup;
5
+ /** 分组只是布局容器,取值与默认值都按平铺后的叶子字段处理 */
6
+ export declare function flattenFields(entries: ResolvedEntry[]): ResolvedField[];
7
+ export declare function evalCondition(condition: FieldCondition | undefined, ctx: FieldContext): boolean;
8
+ export declare function isFieldHidden(entry: ResolvedEntry, ctx: FieldContext): boolean;
9
+ export declare function resolvePlaceholder(field: ResolvedField): string;
10
+ export declare function resolveRules(field: ResolvedField, context: FieldContext): FormItemRule[];
@@ -0,0 +1,59 @@
1
+ import type { ResolvedField, SchemaFormProps } from './schema-form.type';
2
+ type __VLS_Props = SchemaFormProps;
3
+ declare function validate(): Promise<boolean>;
4
+ type __VLS_ModelProps = {
5
+ modelValue?: Record<string, any>;
6
+ };
7
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
8
+ declare const __VLS_template: () => {
9
+ __VLS_Slots: {
10
+ [x: string]: ((props: {
11
+ field: ResolvedField;
12
+ value: any;
13
+ disabled: boolean;
14
+ updateValue: (value: any) => void;
15
+ }) => any) | undefined;
16
+ } & {
17
+ [x: string]: ((props: {
18
+ field: ResolvedField;
19
+ value: any;
20
+ disabled: boolean;
21
+ updateValue: (value: any) => void;
22
+ }) => any) | undefined;
23
+ };
24
+ };
25
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
26
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
27
+ validate: typeof validate;
28
+ clearValidate: () => void | undefined;
29
+ resetFields: () => void | undefined;
30
+ /** 提交用的值,已剔除当前隐藏的字段 */
31
+ getValues: () => {
32
+ [k: string]: any;
33
+ };
34
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
35
+ "update:modelValue": (value: Record<string, any>) => any;
36
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
37
+ "onUpdate:modelValue"?: ((value: Record<string, any>) => any) | undefined;
38
+ }>, {
39
+ mode: import("./schema-form.type").SchemaFormMode;
40
+ columns: number;
41
+ disabled: boolean;
42
+ loading: boolean;
43
+ labelPosition: "top" | "left" | "right";
44
+ underline: boolean;
45
+ labelAlign: "center" | "left" | "right";
46
+ itemGap: string | number;
47
+ groupGap: string | number;
48
+ labelGap: string | number;
49
+ labelWidth: string | number;
50
+ schema: import("./schema-form.type").SchemaFormItem[];
51
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
52
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
53
+ declare const _default: typeof __VLS_export;
54
+ export default _default;
55
+ type __VLS_WithSlots<T, S> = T & {
56
+ new (): {
57
+ $slots: S;
58
+ };
59
+ };
@@ -0,0 +1,27 @@
1
+ import type { FieldContext, ResolvedField, TranslateConfig, TranslateLanguageValues } from './schema-form.type';
2
+ type __VLS_Props = {
3
+ config?: TranslateConfig;
4
+ context: FieldContext;
5
+ disabled?: boolean;
6
+ field: ResolvedField;
7
+ inputProps?: Record<string, any>;
8
+ labelPosition?: 'left' | 'right' | 'top';
9
+ modelValue?: unknown;
10
+ placeholder?: string;
11
+ readonly?: boolean;
12
+ };
13
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
+ "update:modelValue": (value: TranslateLanguageValues) => any;
15
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
16
+ "onUpdate:modelValue"?: ((value: TranslateLanguageValues) => any) | undefined;
17
+ }>, {
18
+ modelValue: undefined;
19
+ placeholder: string;
20
+ disabled: boolean;
21
+ config: TranslateConfig;
22
+ inputProps: Record<string, any>;
23
+ labelPosition: "top" | "left" | "right";
24
+ readonly: boolean;
25
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
+ declare const _default: typeof __VLS_export;
27
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import type { TranslateCommand, TranslateLanguage } from './schema-form.type';
2
+ type __VLS_Props = {
3
+ disabled?: boolean;
4
+ inline?: boolean;
5
+ languages: TranslateLanguage[];
6
+ loading?: boolean;
7
+ sourceLanguage: string;
8
+ targetLanguage: string;
9
+ };
10
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
+ "update:sourceLanguage": (value: string) => any;
12
+ "update:targetLanguage": (value: string) => any;
13
+ translate: (command: TranslateCommand) => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
15
+ "onUpdate:sourceLanguage"?: ((value: string) => any) | undefined;
16
+ "onUpdate:targetLanguage"?: ((value: string) => any) | undefined;
17
+ onTranslate?: ((command: TranslateCommand) => any) | undefined;
18
+ }>, {
19
+ disabled: boolean;
20
+ inline: boolean;
21
+ loading: boolean;
22
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
+ declare const _default: typeof __VLS_export;
24
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import type { FieldContext, FieldOption, ResolvedField } from './schema-form.type';
2
+ import { type ComputedRef } from 'vue';
3
+ /** 统一 static 与 dict 两种来源的选项,api 来源由 async-select 自行取数 */
4
+ export declare function useFieldOptions(getField: () => ResolvedField, context: ComputedRef<FieldContext>): ComputedRef<FieldOption[]>;
@@ -0,0 +1,2 @@
1
+ export type { SearchFormItem, SearchFormValues } from './index.type';
2
+ export { default as SearchForm } from './index.vue';
@@ -0,0 +1,3 @@
1
+ import type { SchemaFormItem } from '../schema-form';
2
+ export type SearchFormValues = Record<string, any>;
3
+ export type SearchFormItem = SchemaFormItem;