@kayak-sj/design 1.0.49 → 1.0.51
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/assets/Complex-2LP9XsDR.css +1 -0
- package/dist/assets/{components-crJ55-Y9.css → componentRegistry-BhoC2OWH.css} +1 -1
- package/dist/assets/index-Biv6Btn_.css +1 -0
- package/dist/chunks/{Complex-C7w3K3P5.js → Complex-CijuFsnI.js} +3 -3
- package/dist/chunks/componentRegistry-BCjeWYov.js +2389 -0
- package/dist/components/k-editor/utils/editorValue.d.ts +50 -10
- package/dist/components/k-form/composables/useFormSchema.d.ts +16 -0
- package/dist/components/k-form/composables/useKFormFields.d.ts +7 -2
- package/dist/components/k-form/composables/useKFormModel.d.ts +20 -3
- package/dist/components/k-form/composables/useKFormTemplateRef.d.ts +4 -0
- package/dist/components/k-form/formComponent/componentRegistry.d.ts +10 -3
- package/dist/components/k-form/utils/fieldValue.d.ts +51 -4
- package/dist/components/k-form/utils/formRules.d.ts +6 -0
- package/dist/components/k-form/utils/resolveFormFieldComponent.d.ts +15 -2
- package/dist/components/k-handle-page/useHandlePageInit.d.ts +13 -1
- package/dist/components/k-icon/resolveLucideIcon.d.ts +23 -4
- package/dist/components/k-table/composables/useColumnDisplay.d.ts +4 -0
- package/dist/components/k-table/composables/useKTable.d.ts +27 -2
- package/dist/components/k-table/composables/useKTableCrossPageSelection.d.ts +26 -0
- package/dist/components/k-table/composables/useKTableTemplateRef.d.ts +10 -0
- package/dist/components/k-table/composables/useTableColumns.d.ts +14 -2
- package/dist/components/k-table/composables/useTableData.d.ts +28 -5
- package/dist/components/k-table/composables/useTablePagination.d.ts +3 -0
- package/dist/components/k-table/composables/useTableRadio.d.ts +9 -0
- package/dist/components/k-table/composables/useTableRowSort.d.ts +9 -0
- package/dist/components/k-table/composables/useTableTreeLoad.d.ts +12 -0
- package/dist/components/k-table/dictOptions.d.ts +6 -1
- package/dist/components/k-table/report/exportKTableReport.d.ts +30 -5
- package/dist/components/k-table/types.d.ts +4 -0
- package/dist/components/k-upload/utils/uploadFileValue.d.ts +40 -12
- package/dist/config/uploadConfig.d.ts +11 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2641 -50
- package/dist/theme/index.d.ts +7 -3
- package/dist/utils/createStubComponent.d.ts +12 -1
- package/dist/utils/validators.d.ts +38 -6
- package/package.json +2 -7
- package/src/styles/components/_k-handle-page.scss +7 -4
- package/dist/assets/Complex-DIKmdv9F.css +0 -1
- package/dist/chunks/components-MlPbHyef.js +0 -4976
- package/dist/components/index.js +0 -3
|
@@ -1,31 +1,71 @@
|
|
|
1
1
|
import { KEditorModelValue, KEditorValue } from '../types';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* 从 string / `{ html }` 中取出 HTML,供 `setHtml` 与只读展示使用。
|
|
4
|
+
*
|
|
5
|
+
* @param value - KEditor v-model(string 或 `{ html, length? }`)
|
|
6
|
+
* @returns HTML 字符串;空值时返回 `''`
|
|
7
|
+
*/
|
|
3
8
|
export declare function getEditorHtml(value: KEditorModelValue): string;
|
|
4
9
|
/**
|
|
5
10
|
* HTML → 纯文本(去标签与常见实体),供回填 / 校验字数使用。
|
|
6
|
-
* 与编辑器 getText() 结果对齐的近似实现(无 DOM 依赖,可在 Node/SSR 用)。
|
|
11
|
+
* 与编辑器 `getText()` 结果对齐的近似实现(无 DOM 依赖,可在 Node/SSR 用)。
|
|
12
|
+
*
|
|
13
|
+
* @param html - 富文本 HTML
|
|
14
|
+
* @returns 去标签后的纯文本
|
|
7
15
|
*/
|
|
8
16
|
export declare function stripEditorHtml(html: string): string;
|
|
9
17
|
/**
|
|
10
18
|
* 字数统计(对齐 legacy k-editor)。
|
|
11
|
-
* 去除
|
|
19
|
+
* 去除 ` `、换行与空白后计字符数。入参应为纯文本(如 `editor.getText()`)。
|
|
20
|
+
*
|
|
21
|
+
* @param text - 纯文本
|
|
22
|
+
* @returns 字数
|
|
12
23
|
*/
|
|
13
24
|
export declare function countEditorWords(text: string): number;
|
|
14
25
|
/**
|
|
15
|
-
* 按 HTML 计字:先去标签再走 countEditorWords。
|
|
16
|
-
* 表单校验 / 接口回填 length 请用此方法,勿用 html.length
|
|
26
|
+
* 按 HTML 计字:先去标签再走 {@link countEditorWords}。
|
|
27
|
+
* 表单校验 / 接口回填 `length` 请用此方法,勿用 `html.length`。
|
|
28
|
+
*
|
|
29
|
+
* @param html - 富文本 HTML
|
|
30
|
+
* @returns 字数
|
|
17
31
|
*/
|
|
18
32
|
export declare function countEditorHtmlWords(html: string): number;
|
|
19
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* 从 v-model 值取字数(string | `{ html, length }`);表单 validator 可直接传入 value。
|
|
35
|
+
*
|
|
36
|
+
* @param value - KEditor v-model 或未知表单值
|
|
37
|
+
* @returns 字数;空值时返回 `0`
|
|
38
|
+
*/
|
|
20
39
|
export declare function getEditorWordCount(value: KEditorModelValue | unknown): number;
|
|
21
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* 构造 emit 载荷;无内容时 `html` 归一为 `''`。
|
|
42
|
+
*
|
|
43
|
+
* @param html - 当前 HTML
|
|
44
|
+
* @param length - 字数(通常来自 {@link countEditorHtmlWords})
|
|
45
|
+
* @returns `{ html, length }`
|
|
46
|
+
*/
|
|
22
47
|
export declare function buildEditorEmitValue(html: string, length: number): KEditorValue;
|
|
23
48
|
/**
|
|
24
49
|
* 接口 HTML → KEditor v-model。
|
|
25
|
-
* length 与编辑器字数统计一致,供 setValues / 默认值回填。
|
|
50
|
+
* `length` 与编辑器字数统计一致,供 `setValues` / 默认值回填。
|
|
51
|
+
*
|
|
52
|
+
* @param html - 接口返回的 HTML;`null` / `undefined` 按空串处理
|
|
53
|
+
* @returns `{ html, length }`
|
|
26
54
|
*/
|
|
27
55
|
export declare function toKEditorValue(html?: string | null): KEditorValue;
|
|
28
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* 解析 `maxWordCount` / `maxLength`;无效或非正数返回 `undefined`(不限制)。
|
|
58
|
+
*
|
|
59
|
+
* @param maxWordCount - 优先使用的字数上限
|
|
60
|
+
* @param maxLength - 兼容旧字段名
|
|
61
|
+
* @returns 正数上限,或 `undefined` 表示不限制
|
|
62
|
+
*/
|
|
29
63
|
export declare function resolveMaxWordCount(maxWordCount?: number | string, maxLength?: number | string): number | undefined;
|
|
30
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* 外部 `modelValue` 变更时,仅比较 html 避免重复 `setHtml`。
|
|
66
|
+
*
|
|
67
|
+
* @param a - 旧值
|
|
68
|
+
* @param b - 新值
|
|
69
|
+
* @returns 两者 HTML 是否相同
|
|
70
|
+
*/
|
|
31
71
|
export declare function isSameEditorHtml(a: KEditorModelValue, b: KEditorModelValue): boolean;
|
|
@@ -5,6 +5,11 @@ import { KFormConfigItem, KFormSchemaField } from '../types';
|
|
|
5
5
|
*
|
|
6
6
|
* 不 mutate 入参,每次根据当前 model 重新计算 display / readonly / disabled / options。
|
|
7
7
|
* 替代旧版 formConfigFactory + FMSetDisplay 突变 formConfigs 的写法。
|
|
8
|
+
*
|
|
9
|
+
* @typeParam T - 表单 model 类型
|
|
10
|
+
* @param field - 带 `visibleWhen` / `optionsFromModel` 等声明的 schema 字段
|
|
11
|
+
* @param model - 当前表单 model(用于求值依赖)
|
|
12
|
+
* @returns 可直接交给 `KForm` 的 `KFormConfigItem`
|
|
8
13
|
*/
|
|
9
14
|
export declare function resolveSchemaField<T>(field: KFormSchemaField<T>, model: T): KFormConfigItem;
|
|
10
15
|
export interface UseFormSchemaOptions {
|
|
@@ -17,6 +22,12 @@ export interface UseFormSchemaOptions {
|
|
|
17
22
|
/**
|
|
18
23
|
* 根据 model 派生表单 schema(computed,只读)。
|
|
19
24
|
*
|
|
25
|
+
* @typeParam T - 表单 model 类型
|
|
26
|
+
* @param baseFields - 静态或响应式 schema 字段列表
|
|
27
|
+
* @param model - 表单 model(plain / ref / getter)
|
|
28
|
+
* @param options - 见 {@link UseFormSchemaOptions};`excludeHidden` 控制是否剔除隐藏字段
|
|
29
|
+
* @returns 解析后的 `KFormConfigItem[]` computed,可绑 `:form-configs`
|
|
30
|
+
*
|
|
20
31
|
* @example
|
|
21
32
|
* ```ts
|
|
22
33
|
* const model = ref({ menu_type: 'C', grant: '0' })
|
|
@@ -28,5 +39,10 @@ export declare function useFormSchema<T>(baseFields: MaybeRefOrGetter<KFormSchem
|
|
|
28
39
|
/**
|
|
29
40
|
* 批量设置字段可见性(返回新 schema,不 mutate 原数组)。
|
|
30
41
|
* 便于从旧版 FMSetDisplay 迁移到一次性映射。
|
|
42
|
+
*
|
|
43
|
+
* @typeParam T - 表单 model 类型
|
|
44
|
+
* @param fields - 原始 schema 字段列表
|
|
45
|
+
* @param visibility - 按字段 `id` 索引的显隐映射;未出现的字段保持原样
|
|
46
|
+
* @returns 写入 `visibleWhen` 后的新 schema 数组
|
|
31
47
|
*/
|
|
32
48
|
export declare function mapFieldVisibility<T>(fields: KFormSchemaField<T>[], visibility: Partial<Record<string, boolean>>): KFormSchemaField<T>[];
|
|
@@ -6,8 +6,13 @@ export interface FieldOption {
|
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* 表单项展示层逻辑:可见性过滤、查询区 hideLabel
|
|
10
|
-
* 字典通过 inject(DICT_KEY)
|
|
9
|
+
* 表单项展示层逻辑:可见性过滤、查询区 `hideLabel`、字典选项、flex 布局。
|
|
10
|
+
* 字典通过 `inject(DICT_KEY)`,与 KTable 列翻译共用同一数据源。
|
|
11
|
+
*
|
|
12
|
+
* @param options.formConfigs - 表单字段配置(响应式)
|
|
13
|
+
* @param options.layout - 布局选项(含 `hideLabel` 等)
|
|
14
|
+
* @param options.formReadonly - 整表只读时跳过校验、渲染纯文本
|
|
15
|
+
* @returns `normalizedConfigs` 与字段 options / rules / 样式辅助方法
|
|
11
16
|
*/
|
|
12
17
|
export declare function useKFormFields(options: {
|
|
13
18
|
formConfigs: Ref<KFormConfigItem[]>;
|
|
@@ -4,10 +4,27 @@ import { KFormConfigItem } from '../types';
|
|
|
4
4
|
* 表单 model 单一数据源。
|
|
5
5
|
*
|
|
6
6
|
* 两种模式:
|
|
7
|
-
* - **非受控**(查询面板):仅内部 formModel
|
|
8
|
-
* - **受控**(v-model):父级 model 为真相,内部 formModel 与之双向同步
|
|
7
|
+
* - **非受控**(查询面板):仅内部 `formModel`,通过 `getParams` / `validateFields` 取值
|
|
8
|
+
* - **受控**(v-model):父级 model 为真相,内部 `formModel` 与之双向同步
|
|
9
9
|
*
|
|
10
|
-
* - firsthandModel
|
|
10
|
+
* - `firsthandModel`:reset 时恢复的快照(受控 / 非受控均记录;受控 reset 后会 publish 回父级)
|
|
11
|
+
*
|
|
12
|
+
* @param options.formConfigs - 表单字段配置(响应式)
|
|
13
|
+
* @param options.modelValue - v-model 绑定值(受控模式)
|
|
14
|
+
* @param options.data - @deprecated 优先使用 `modelValue`
|
|
15
|
+
* @param options.controlled - `props.modelValue !== undefined` 时为 true
|
|
16
|
+
* @param options.onChange - 模型变更回调(受控时用于 `emit('update:modelValue')`)
|
|
17
|
+
* @returns `formModel` 与字段读写 / 重置方法,供 `KForm.vue` 使用
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const { formModel, setFieldsValue, getVisibleFieldsValue, resetFormModel } = useKFormModel({
|
|
22
|
+
* formConfigs,
|
|
23
|
+
* modelValue,
|
|
24
|
+
* controlled,
|
|
25
|
+
* onChange: (values) => emit('update:modelValue', values)
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
11
28
|
*/
|
|
12
29
|
export declare function useKFormModel(options: {
|
|
13
30
|
formConfigs: Ref<KFormConfigItem[]>;
|
|
@@ -8,6 +8,10 @@ import { KFormInstance } from '../types';
|
|
|
8
8
|
*
|
|
9
9
|
* `T` 约束为 `object`:业务表单 interface 可直接作泛型,无需 `extends Record<string, unknown>`。
|
|
10
10
|
*
|
|
11
|
+
* @typeParam T - 表单 model 类型
|
|
12
|
+
* @param key - 模板 `ref` 同名字符串,如 `baseFormRef`
|
|
13
|
+
* @returns 指向 `KFormInstance<T>` 的 template ref(挂载前请用可选链)
|
|
14
|
+
*
|
|
11
15
|
* @example
|
|
12
16
|
* ```ts
|
|
13
17
|
* const formRef = useKFormTemplateRef<SupplierBaseForm>('baseFormRef')
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
2
|
/** formConfigs.component 字段 → Vue 子组件 */
|
|
3
3
|
export declare const FORM_COMPONENT_MAP: Record<string, Component>;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* 未命中注册表时返回 Fallback,避免未知 component 静默空白。
|
|
6
|
+
*
|
|
7
|
+
* @param componentType - `formConfigs.component` 字符串名
|
|
8
|
+
* @returns 注册表中的组件,或 Fallback
|
|
9
|
+
*/
|
|
5
10
|
export declare function resolveFormComponent(componentType: string): Component;
|
|
6
11
|
/**
|
|
7
|
-
* 注册业务扩展表单控件(运行时写入 FORM_COMPONENT_MAP)。
|
|
8
|
-
* 类型侧请在 cms-base 将组件名追加到 CmsFormComponentType
|
|
12
|
+
* 注册业务扩展表单控件(运行时写入 {@link FORM_COMPONENT_MAP})。
|
|
13
|
+
* 类型侧请在 cms-base 将组件名追加到 `CmsFormComponentType`。
|
|
14
|
+
*
|
|
15
|
+
* @param components - `component` 名 → Vue 组件的映射,如 `{ OrgTreeSelect: OrgTreeSelect }`
|
|
9
16
|
*/
|
|
10
17
|
export declare function registerFormComponents(components: Record<string, Component>): void;
|
|
@@ -36,61 +36,98 @@ export type TimePickerType = 'time' | 'timerange';
|
|
|
36
36
|
/**
|
|
37
37
|
* 收窄为选项控件可绑定的 value。
|
|
38
38
|
* ElOption 仅接受 string / number,其余类型转为 string。
|
|
39
|
+
*
|
|
40
|
+
* @param value - 原始字段值
|
|
41
|
+
* @returns `string | number`
|
|
39
42
|
*/
|
|
40
43
|
export declare function toOptionValue(value: unknown): OptionFieldValue;
|
|
41
44
|
/**
|
|
42
45
|
* 收窄为标量字段值。
|
|
43
46
|
* null / undefined 返回 undefined;其余非标量类型转为 string。
|
|
47
|
+
*
|
|
48
|
+
* @param value - 原始字段值
|
|
49
|
+
* @returns `string | number | boolean | undefined`
|
|
44
50
|
*/
|
|
45
51
|
export declare function toScalarValue(value: unknown): ScalarFieldValue;
|
|
46
52
|
/**
|
|
47
53
|
* 收窄为 Input / Textarea 等文本控件可绑定的 string。
|
|
48
54
|
* null / undefined 返回空字符串。
|
|
55
|
+
*
|
|
56
|
+
* @param value - 原始字段值
|
|
57
|
+
* @returns 文本;空值时为 `''`
|
|
49
58
|
*/
|
|
50
59
|
export declare function toStringValue(value: unknown): string;
|
|
51
60
|
/**
|
|
52
61
|
* 收窄为 CheckboxGroup / SelectMultiple 可绑定的数组。
|
|
53
62
|
* 非数组返回 [];仅保留 string / number 元素。
|
|
63
|
+
*
|
|
64
|
+
* @param value - 原始字段值
|
|
65
|
+
* @returns `(string | number)[]`
|
|
54
66
|
*/
|
|
55
67
|
export declare function toCheckboxGroupValue(value: unknown): CheckboxGroupValue;
|
|
56
68
|
/**
|
|
57
69
|
* 收窄为 InputNumber 可绑定的 number。
|
|
58
70
|
* 空值、NaN、无法解析的字符串返回 undefined。
|
|
71
|
+
*
|
|
72
|
+
* @param value - 原始字段值
|
|
73
|
+
* @returns 有效数字,或 `undefined`
|
|
59
74
|
*/
|
|
60
75
|
export declare function toNumberValue(value: unknown): number | undefined;
|
|
61
76
|
/**
|
|
62
77
|
* 收窄为 ElDatePicker model-value 可接受的值。
|
|
63
78
|
* 范围值要求长度为 2 且元素类型一致(全 Date 或全 string);其余情况回退为 string。
|
|
79
|
+
*
|
|
80
|
+
* @param value - 原始字段值
|
|
81
|
+
* @returns DatePicker 可绑定值
|
|
64
82
|
*/
|
|
65
83
|
export declare function toDatePickerValue(value: unknown): DatePickerFieldValue;
|
|
66
84
|
/**
|
|
67
85
|
* 校验并收窄 ElDatePicker type。
|
|
68
|
-
* 不在白名单内时回退为 'date'
|
|
86
|
+
* 不在白名单内时回退为 `'date'`。
|
|
87
|
+
*
|
|
88
|
+
* @param type - schema 透传的 type 字符串
|
|
89
|
+
* @returns 合法的 {@link DatePickerType}
|
|
69
90
|
*/
|
|
70
91
|
export declare function toDatePickerType(type?: string): DatePickerType;
|
|
71
92
|
/**
|
|
72
93
|
* 收窄为 ElTimePicker model-value 可接受的值。
|
|
73
94
|
* 范围值要求长度为 2 且元素类型一致(全 Date 或全 string);其余情况回退为 string。
|
|
95
|
+
*
|
|
96
|
+
* @param value - 原始字段值
|
|
97
|
+
* @returns TimePicker 可绑定值
|
|
74
98
|
*/
|
|
75
99
|
export declare function toTimePickerValue(value: unknown): TimePickerFieldValue;
|
|
76
100
|
/**
|
|
77
101
|
* 校验并收窄 ElTimePicker type。
|
|
78
|
-
* 不在白名单内时回退为 'time'
|
|
102
|
+
* 不在白名单内时回退为 `'time'`。
|
|
103
|
+
*
|
|
104
|
+
* @param type - schema 透传的 type 字符串
|
|
105
|
+
* @returns `'time' | 'timerange'`
|
|
79
106
|
*/
|
|
80
107
|
export declare function toTimePickerType(type?: string): TimePickerType;
|
|
81
108
|
/**
|
|
82
109
|
* 收窄为 ElCascader model-value 可接受的值。
|
|
83
110
|
* 数组仅保留 string / number 路径段;对象原样透传;其余转为 string。
|
|
111
|
+
*
|
|
112
|
+
* @param value - 原始字段值
|
|
113
|
+
* @returns Cascader 可绑定值
|
|
84
114
|
*/
|
|
85
115
|
export declare function toCascaderValue(value: unknown): CascaderFieldValue;
|
|
86
116
|
/**
|
|
87
117
|
* 收窄为 TreeSelect options 树数据。
|
|
88
118
|
* 非数组返回空数组。
|
|
119
|
+
*
|
|
120
|
+
* @param data - 原始 options
|
|
121
|
+
* @returns 树节点数组
|
|
89
122
|
*/
|
|
90
123
|
export declare function toTreeSelectData(data: unknown): TreeSelectData;
|
|
91
124
|
/**
|
|
92
125
|
* 在 TreeSelect 树数据中按节点 value 查找 label,供只读态展示。
|
|
93
|
-
* 默认字段名 value / label / children
|
|
126
|
+
* 默认字段名 `value` / `label` / `children`,与 ElTreeSelect 及机构树数据一致。
|
|
127
|
+
*
|
|
128
|
+
* @param data - 树 options
|
|
129
|
+
* @param targetValue - 当前选中值
|
|
130
|
+
* @returns 匹配节点的 label;未找到时为 `undefined`
|
|
94
131
|
*/
|
|
95
132
|
export declare function findTreeSelectLabel(data: TreeSelectData, targetValue: unknown): string | undefined;
|
|
96
133
|
/** Cascader 节点字段映射(对齐 ElCascader props) */
|
|
@@ -102,11 +139,21 @@ export type CascaderFieldMap = {
|
|
|
102
139
|
/**
|
|
103
140
|
* 按 Cascader 路径从 options 解析只读文案(默认用 ` / ` 拼接,对齐 ElCascader separator)。
|
|
104
141
|
* 路径段找不到对应节点时回退为原始值文案。
|
|
142
|
+
*
|
|
143
|
+
* @param options - Cascader options 树
|
|
144
|
+
* @param value - 当前选中值(叶子或路径数组)
|
|
145
|
+
* @param fieldMap - 节点字段映射,默认 `value` / `label` / `children`
|
|
146
|
+
* @param separator - 路径拼接符,默认 `' / '`
|
|
147
|
+
* @returns 只读展示文案
|
|
105
148
|
*/
|
|
106
149
|
export declare function findCascaderReadonlyText(options: unknown[] | undefined, value: unknown, fieldMap?: CascaderFieldMap, separator?: string): string;
|
|
107
150
|
/**
|
|
108
151
|
* 只读态展示文案。
|
|
109
|
-
* null / undefined / 空字符串返回 fallback(默认 '--'
|
|
152
|
+
* null / undefined / 空字符串返回 fallback(默认 `'--'`)。
|
|
153
|
+
*
|
|
154
|
+
* @param value - 原始字段值
|
|
155
|
+
* @param fallback - 空值占位,默认 `'--'`
|
|
156
|
+
* @returns 展示字符串
|
|
110
157
|
*/
|
|
111
158
|
export declare function formatReadonlyText(value: unknown, fallback?: string): string;
|
|
112
159
|
export {};
|
|
@@ -2,6 +2,12 @@ import { FormItemRule } from 'element-plus';
|
|
|
2
2
|
/**
|
|
3
3
|
* 按组件类型合并默认校验规则。
|
|
4
4
|
* 隐藏项 / 只读项 / 表单 readonly 时不附加规则(由 KForm 侧判断)。
|
|
5
|
+
*
|
|
6
|
+
* - `Input` + `type: number|phone|money|percentage` → 追加格式校验
|
|
7
|
+
* - `InputMixInput` + `required` → 追加两侧均必填校验
|
|
8
|
+
*
|
|
9
|
+
* @param item - 含 `component` / `componentProps` / `rules` 的字段配置
|
|
10
|
+
* @returns 合并后的 `FormItemRule[]`(含业务自定义 `rules`)
|
|
5
11
|
*/
|
|
6
12
|
export declare function resolveFormItemRules(item: {
|
|
7
13
|
component: string | import('vue').Component;
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
2
|
import { KFormBuiltInComponentType, KFormComponentRef } from '../types';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* `component` 是否为内置控件名字符串。
|
|
5
|
+
*
|
|
6
|
+
* @param component - schema 上的 `component` 字段
|
|
7
|
+
* @returns 是否为 {@link KFormBuiltInComponentType}
|
|
8
|
+
*/
|
|
4
9
|
export declare function isBuiltinFormComponentType(component: KFormComponentRef): component is KFormBuiltInComponentType;
|
|
5
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* `component` 是否为业务自定义 Vue 组件(对齐 legacy formConfigs 直接 import 写法)。
|
|
12
|
+
*
|
|
13
|
+
* @param component - schema 上的 `component` 字段
|
|
14
|
+
* @returns 是否为 Vue `Component` 对象 / 函数
|
|
15
|
+
*/
|
|
6
16
|
export declare function isCustomFormComponent(component: KFormComponentRef): component is Component;
|
|
7
17
|
/**
|
|
8
18
|
* 解析表单项实际渲染组件。
|
|
9
19
|
* - 字符串 → formComponent 注册表
|
|
10
20
|
* - Component 对象 → 直接使用(legacy 兼容)
|
|
21
|
+
*
|
|
22
|
+
* @param component - 内置控件名或自定义组件
|
|
23
|
+
* @returns 可渲染的 Vue 组件
|
|
11
24
|
*/
|
|
12
25
|
export declare function resolveFormFieldComponent(component: KFormComponentRef): Component;
|
|
@@ -6,7 +6,19 @@ export interface UseHandlePageInitOptions {
|
|
|
6
6
|
immediate?: boolean;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* KHandlePage 维护页 init 加载态:包裹 initPage
|
|
9
|
+
* KHandlePage 维护页 init 加载态:包裹 `initPage`,编辑/详情态展示局部 loading。
|
|
10
|
+
*
|
|
11
|
+
* @param init - 页面初始化异步函数(如拉详情、机构树)
|
|
12
|
+
* @param options - 加载态与是否 `onMounted` 自动执行,见 {@link UseHandlePageInitOptions}
|
|
13
|
+
* @returns `pageLoading` 绑到 `KHandlePage`;`runInit` 供弹窗等手动触发
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const { pageLoading, runInit } = useHandlePageInit(async () => {
|
|
18
|
+
* await loadDetail()
|
|
19
|
+
* })
|
|
20
|
+
* // <KHandlePage :loading="pageLoading">...</KHandlePage>
|
|
21
|
+
* ```
|
|
10
22
|
*/
|
|
11
23
|
export declare function useHandlePageInit(init: () => Promise<void>, options?: UseHandlePageInitOptions): {
|
|
12
24
|
pageLoading: import('vue').Ref<boolean, boolean>;
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* kebab-case slug → PascalCase(与 `lucide-vue-next` 导出名一致)。
|
|
4
|
+
*
|
|
5
|
+
* @param name - Lucide slug,如 `chevron-down`
|
|
6
|
+
* @returns PascalCase 导出名,如 `ChevronDown`
|
|
7
|
+
*/
|
|
3
8
|
export declare function toLucidePascalName(name: string): string;
|
|
4
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* PascalCase → kebab-case(与 lucide.dev slug 一致)。
|
|
11
|
+
*
|
|
12
|
+
* @param name - PascalCase 导出名,如 `ChevronDown`
|
|
13
|
+
* @returns kebab-case slug,如 `chevron-down`
|
|
14
|
+
*/
|
|
5
15
|
export declare function pascalToKebab(name: string): string;
|
|
6
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* 按 Lucide slug 解析图标组件;未命中或空名时返回占位组件。
|
|
18
|
+
*
|
|
19
|
+
* @param name - Lucide kebab slug;空 / `#` 时走占位
|
|
20
|
+
* @returns 可渲染的 Vue 组件
|
|
21
|
+
*/
|
|
7
22
|
export declare function resolveLucideIcon(name?: string): Component;
|
|
8
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* 返回全部 Lucide 图标 kebab 名称(去重、排序,供图标选择器使用)。
|
|
25
|
+
*
|
|
26
|
+
* @returns 已排序的 kebab slug 列表(结果有模块级缓存)
|
|
27
|
+
*/
|
|
9
28
|
export declare function getAllLucideKebabNames(): string[];
|
|
@@ -22,6 +22,10 @@ export interface UseColumnDisplayOptions<T = Record<string, unknown>> {
|
|
|
22
22
|
* - `tableKey` 为空时使用随机 key,仅内存态、不写入 localStorage
|
|
23
23
|
* - `required` / selection / index / radio 列始终显示且不可在面板取消
|
|
24
24
|
* - 显隐变更后通过 `onLayout` 调用 ElTable.doLayout 刷新布局
|
|
25
|
+
*
|
|
26
|
+
* @typeParam T - 表格行数据类型
|
|
27
|
+
* @param options - 见 {@link UseColumnDisplayOptions}
|
|
28
|
+
* @returns `visibleColumns` / `selectorItems` 与显隐写入、重置方法
|
|
25
29
|
*/
|
|
26
30
|
export declare function useColumnDisplay<T = Record<string, unknown>>(options: UseColumnDisplayOptions<T>): {
|
|
27
31
|
columnDisplay: import('vue').Ref<Record<string, boolean>, Record<string, boolean>>;
|
|
@@ -72,18 +72,43 @@ export interface KTableEmits<T> {
|
|
|
72
72
|
/** 透传 ElTable `sort-change`(列头排序变化) */
|
|
73
73
|
(event: 'sort-change', data: KTableSortChangeData): void;
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* {@link useKTable} 入参(由 `KTable.vue` 传入,页面侧通常不直接调用)。
|
|
77
|
+
*
|
|
78
|
+
* @typeParam T - 表格行数据类型
|
|
79
|
+
*/
|
|
75
80
|
interface UseKTableOptions<T> {
|
|
76
81
|
/** SFC 经 withDefaults 合并后的 props */
|
|
77
82
|
props: ResolvedKTableProps<T>;
|
|
78
83
|
emit: KTableEmits<T>;
|
|
79
84
|
attrs: Record<string, unknown>;
|
|
80
85
|
slots: Slots;
|
|
81
|
-
/** 由 SFC 顶层声明,供模板
|
|
86
|
+
/** 由 SFC 顶层声明,供模板 `:ref` 绑定 */
|
|
82
87
|
tableRef: Ref<TableInstance | undefined>;
|
|
83
88
|
queryRef: Ref<KPanelQueryInstance | undefined>;
|
|
84
89
|
}
|
|
85
90
|
/**
|
|
86
|
-
* KTable 编排层:聚合分页 / 查询 / 数据请求 /
|
|
91
|
+
* KTable 编排层:聚合分页 / 查询 / 数据请求 / 列显隐 / 单选 / 树懒加载 / 行拖拽。
|
|
92
|
+
*
|
|
93
|
+
* 向 SFC 返回模板绑定态与 `defineExpose` 实例方法;不直接操作 DOM。
|
|
94
|
+
* 页面侧请通过 {@link useKTableTemplateRef} 拿到 {@link KTableInstance},勿直接调用本函数。
|
|
95
|
+
*
|
|
96
|
+
* @typeParam T - 表格行数据类型
|
|
97
|
+
* @param options - 见 {@link UseKTableOptions}
|
|
98
|
+
* @returns 模板绑定(`tableProps` / `renderColumns` / handlers)与 expose 方法(`refresh` / `getSelection` 等)
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* // KTable.vue 内部
|
|
103
|
+
* const tableRef = ref<TableInstance>()
|
|
104
|
+
* const queryRef = ref<KPanelQueryInstance>()
|
|
105
|
+
* const api = useKTable({ props, emit, attrs, slots, tableRef, queryRef })
|
|
106
|
+
* defineExpose({
|
|
107
|
+
* refresh: api.refresh,
|
|
108
|
+
* getSelection: api.getSelection,
|
|
109
|
+
* // ...
|
|
110
|
+
* })
|
|
111
|
+
* ```
|
|
87
112
|
*/
|
|
88
113
|
export declare function useKTable<T>(options: UseKTableOptions<T>): {
|
|
89
114
|
showQuery: import('vue').ComputedRef<boolean>;
|
|
@@ -28,4 +28,30 @@ export type UseKTableCrossPageSelectionReturn<T> = {
|
|
|
28
28
|
onSelectionChange: (rows: T[]) => void;
|
|
29
29
|
onRadioChange: (row: T) => void;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* KTable 弹窗/列表跨页多选回显。
|
|
33
|
+
*
|
|
34
|
+
* 消费侧典型用法:打开弹框时 `setSelection(已选)`,表格绑
|
|
35
|
+
* `@data-loaded="onDataLoaded"` + `@selection-change="onSelectionChange"`。
|
|
36
|
+
* 不把草稿选择写进 KTable 内部,避免污染表格数据层。
|
|
37
|
+
*
|
|
38
|
+
* @typeParam T - 表格行数据类型
|
|
39
|
+
* @param options - 行主键、表格实例与勾选模式,见 {@link UseKTableCrossPageSelectionOptions}
|
|
40
|
+
* @returns 草稿 `selection` 与事件处理器,见 {@link UseKTableCrossPageSelectionReturn}
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const { selection, tableRef, setSelection, onDataLoaded, onSelectionChange } =
|
|
45
|
+
* useKTableCrossPageSelection<UserRow>({ rowKey: 'user_id' })
|
|
46
|
+
*
|
|
47
|
+
* // 打开弹窗时回填已选
|
|
48
|
+
* setSelection([...pickedUsers])
|
|
49
|
+
*
|
|
50
|
+
* // <KTable
|
|
51
|
+
* // ref="tableRef"
|
|
52
|
+
* // @data-loaded="onDataLoaded"
|
|
53
|
+
* // @selection-change="onSelectionChange"
|
|
54
|
+
* // />
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
31
57
|
export declare function useKTableCrossPageSelection<T = Record<string, unknown>>(options: UseKTableCrossPageSelectionOptions<T>): UseKTableCrossPageSelectionReturn<T>;
|
|
@@ -5,5 +5,15 @@ import { KTableInstance } from './useKTable';
|
|
|
5
5
|
*
|
|
6
6
|
* `useTemplateRef` 挂载前 value 为 null,但页面 composable 侧通常按已挂载实例使用;
|
|
7
7
|
* 类型上省略 null,调用处请继续用 `tableRef.value?.refresh()` 等可选链。
|
|
8
|
+
*
|
|
9
|
+
* @typeParam T - 表格行数据类型
|
|
10
|
+
* @param key - 模板 `ref` 同名字符串,如 `tableRef`
|
|
11
|
+
* @returns 指向 `KTableInstance<T>` 的 template ref(挂载前请用可选链)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const tableRef = useKTableTemplateRef<UserRow>('tableRef')
|
|
16
|
+
* await tableRef.value?.refresh()
|
|
17
|
+
* ```
|
|
8
18
|
*/
|
|
9
19
|
export declare function useKTableTemplateRef<T = Record<string, unknown>>(key: string): Ref<KTableInstance<T>>;
|
|
@@ -3,15 +3,27 @@ import { KTableColumn } from '../types';
|
|
|
3
3
|
* 归一化列配置:
|
|
4
4
|
* - `selectionShow` 为 true 且无 selection 列时,自动前置多选列
|
|
5
5
|
* - `prop: 'operates'` 且无 type 时,自动补 `type: 'operates'`(兼容旧 tableConfig)
|
|
6
|
+
*
|
|
7
|
+
* @typeParam T - 表格行数据类型
|
|
8
|
+
* @param columns - 原始列配置
|
|
9
|
+
* @param selectionShow - 是否自动插入多选列,默认 `false`
|
|
10
|
+
* @returns 归一化后的新列数组(有变更时为新引用)
|
|
6
11
|
*/
|
|
7
12
|
export declare function normalizeColumns<T>(columns: KTableColumn<T>[], selectionShow?: boolean): KTableColumn<T>[];
|
|
8
13
|
/**
|
|
9
|
-
* 将 KTableColumn 转为 ElTableColumn 可绑定的 props,并填充旧版默认样式约定。
|
|
14
|
+
* 将 `KTableColumn` 转为 ElTableColumn 可绑定的 props,并填充旧版默认样式约定。
|
|
15
|
+
*
|
|
16
|
+
* @typeParam T - 表格行数据类型
|
|
17
|
+
* @param column - 单列配置
|
|
18
|
+
* @returns 可 `v-bind` 到 `ElTableColumn` 的 props 对象
|
|
10
19
|
*/
|
|
11
20
|
export declare function convertColumnBind<T>(column: KTableColumn<T>): Record<string, unknown>;
|
|
12
21
|
/**
|
|
13
22
|
* 列单元格展示值 hook。
|
|
14
|
-
* 通过 inject(DICT_KEY) 获取字典服务,保持 design 与 cms-base 解耦。
|
|
23
|
+
* 通过 `inject(DICT_KEY)` 获取字典服务,保持 design 与 cms-base 解耦。
|
|
24
|
+
*
|
|
25
|
+
* @param nullValueFormat - 空值占位文案,默认 `'--'`
|
|
26
|
+
* @returns `getCellDisplayValue(column, row, index)` 计算展示文本
|
|
15
27
|
*/
|
|
16
28
|
export declare function useCellValue(nullValueFormat?: string): {
|
|
17
29
|
getCellDisplayValue: <T>(column: KTableColumn<T>, row: T, index: number) => string;
|
|
@@ -1,24 +1,47 @@
|
|
|
1
1
|
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
2
|
import { KTableResponseConfig } from '../types';
|
|
3
3
|
import { useTablePagination } from './useTablePagination';
|
|
4
|
-
/** 列表请求函数;直接传 CMS 接口即可,响应体由 responseConfig 解析 */
|
|
4
|
+
/** 列表请求函数;直接传 CMS 接口即可,响应体由 `responseConfig` 解析 */
|
|
5
5
|
export type TableAction = (params: Record<string, unknown>) => Promise<unknown>;
|
|
6
|
+
/**
|
|
7
|
+
* {@link useTableData} 入参。
|
|
8
|
+
*
|
|
9
|
+
* @typeParam T - 表格行数据类型
|
|
10
|
+
*/
|
|
6
11
|
export interface UseTableDataOptions<T> {
|
|
7
|
-
/** 列表查询接口;传入后进入 action 模式,由组件内部管理 tableData */
|
|
12
|
+
/** 列表查询接口;传入后进入 action 模式,由组件内部管理 `tableData` */
|
|
8
13
|
action?: TableAction;
|
|
9
14
|
/** 请求外置固定参数,与分页、查询条件合并后发出;可传具体对象,无需 extends Record */
|
|
10
15
|
params?: MaybeRefOrGetter<Record<string, any> | undefined>;
|
|
11
16
|
/** 接口响应字段映射 */
|
|
12
17
|
responseConfig?: MaybeRefOrGetter<KTableResponseConfig | undefined>;
|
|
13
|
-
/** 与 useTablePagination 共享的分页状态 */
|
|
18
|
+
/** 与 {@link useTablePagination} 共享的分页状态 */
|
|
14
19
|
pagination: ReturnType<typeof useTablePagination>;
|
|
15
|
-
/** 查询条件,与 params 合并后作为请求参数 */
|
|
20
|
+
/** 查询条件,与 `params` 合并后作为请求参数 */
|
|
16
21
|
queryParams?: MaybeRefOrGetter<Record<string, unknown> | undefined>;
|
|
17
|
-
/** 数据加载完成回调,用于 emit data-loaded */
|
|
22
|
+
/** 数据加载完成回调,用于 emit `data-loaded` */
|
|
18
23
|
onDataLoaded?: (data: T[], total: number) => void;
|
|
19
24
|
/** action 首屏会自动请求时,首帧直接展示加载态,避免闪现空状态 */
|
|
20
25
|
initialLoading?: boolean;
|
|
21
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* action 模式下管理表格数据:请求、解析响应、写入分页 total。
|
|
29
|
+
*
|
|
30
|
+
* @typeParam T - 表格行数据类型
|
|
31
|
+
* @param options - 见 {@link UseTableDataOptions}
|
|
32
|
+
* @returns `tableData` / `loading` / `loaded`;`fetchData` 发起请求;`refresh` 可重置页码后重拉
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const pagination = useTablePagination({ hasAction: ref(true) })
|
|
37
|
+
* const { tableData, loading, fetchData, refresh } = useTableData<UserRow>({
|
|
38
|
+
* action: fetchUsers,
|
|
39
|
+
* queryParams,
|
|
40
|
+
* pagination,
|
|
41
|
+
* onDataLoaded: (rows, total) => emit('data-loaded', rows, total)
|
|
42
|
+
* })
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
22
45
|
export declare function useTableData<T>(options: UseTableDataOptions<T>): {
|
|
23
46
|
tableData: Ref<T[], T[]>;
|
|
24
47
|
loading: Ref<boolean, boolean>;
|
|
@@ -13,6 +13,9 @@ export interface UseTablePaginationOptions {
|
|
|
13
13
|
* 管理表格分页状态,产出 KPagination 可绑定的 props。
|
|
14
14
|
*
|
|
15
15
|
* action 模式下 `total` 由接口回填;非 action 模式下同步外部分页字段。
|
|
16
|
+
*
|
|
17
|
+
* @param options - 外部分页配置与是否 action 模式,见 {@link UseTablePaginationOptions}
|
|
18
|
+
* @returns `state` / `bindProps` / `indexOffset` 与页码写入方法
|
|
16
19
|
*/
|
|
17
20
|
export declare function useTablePagination(options: UseTablePaginationOptions): {
|
|
18
21
|
state: Ref<{
|
|
@@ -5,6 +5,15 @@ export interface UseTableRadioOptions<T> {
|
|
|
5
5
|
/** 行唯一键字段名,与 KTable rowKey 对齐 */
|
|
6
6
|
rowKey: MaybeRefOrGetter<string>;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* 单选列(`type: 'radio'`)选中态。
|
|
10
|
+
*
|
|
11
|
+
* 存在 radio 列时 {@link useKTable} 默认开启 `highlight-current-row`(可通过 attrs 关闭)。
|
|
12
|
+
*
|
|
13
|
+
* @typeParam T - 表格行数据类型
|
|
14
|
+
* @param options - 列配置与 `rowKey`,见 {@link UseTableRadioOptions}
|
|
15
|
+
* @returns `radioSelected` / `hasRadioColumn` 与选中写入方法
|
|
16
|
+
*/
|
|
8
17
|
export declare function useTableRadio<T>(options: UseTableRadioOptions<T>): {
|
|
9
18
|
radioSelected: import('vue').Ref<string | number | boolean, string | number | boolean>;
|
|
10
19
|
hasRadioColumn: import('vue').ComputedRef<boolean>;
|