@me-framework/me-ui-antdv-next 0.0.29 → 0.0.30
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/code-box/code-item.vue.d.ts +14 -0
- package/dist/code-box/index.css +1 -0
- package/dist/code-box/index.d.ts +5 -0
- package/dist/code-box/index.js +178 -0
- package/dist/code-box/index.vue.d.ts +20 -0
- package/dist/code-box/types.d.ts +64 -0
- package/dist/env.d.ts +12 -0
- package/dist/index.d.ts +3 -1
- package/dist/input-property/index.css +1 -1
- package/dist/input-property/index.js +672 -120
- package/dist/input-property/index.vue.d.ts +6 -3
- package/dist/input-property/types.d.ts +79 -3
- package/dist/input-property/validate.d.ts +62 -5
- package/dist/me-ui-antdv-next.js +3595 -415
- package/dist/me-ui-antdv-next.umd.cjs +11 -9
- package/dist/resolver/index.js +3 -1
- package/dist/style.css +1 -1
- package/dist/utils/hljs.d.ts +19 -0
- package/package.json +2 -2
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { MeInputPropertyProps } from './types';
|
|
1
|
+
import { MeInputPropertyProps, MeInputPropertyValidation } from './types';
|
|
2
2
|
declare const __VLS_export: import('vue').DefineComponent<MeInputPropertyProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
|
-
change: (value: Record<string, any
|
|
3
|
+
change: (value: Record<string, any>, validation?: MeInputPropertyValidation | undefined) => any;
|
|
4
4
|
"update:modelValue": (value: Record<string, any>) => any;
|
|
5
5
|
}, string, import('vue').PublicProps, Readonly<MeInputPropertyProps> & Readonly<{
|
|
6
|
-
onChange?: ((value: Record<string, any
|
|
6
|
+
onChange?: ((value: Record<string, any>, validation?: MeInputPropertyValidation | undefined) => any) | undefined;
|
|
7
7
|
"onUpdate:modelValue"?: ((value: Record<string, any>) => any) | undefined;
|
|
8
8
|
}>, {
|
|
9
9
|
size: "small" | "middle" | "large";
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
modelValue: Record<string, any>;
|
|
12
12
|
draggable: boolean;
|
|
13
|
+
showType: boolean;
|
|
14
|
+
showRules: boolean;
|
|
15
|
+
validate: boolean;
|
|
13
16
|
keyPlaceholder: string;
|
|
14
17
|
valuePlaceholder: string;
|
|
15
18
|
emptyText: string;
|
|
@@ -1,14 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MeInputProperty 属性编辑器组件类型定义
|
|
3
3
|
*/
|
|
4
|
+
/** 属性值类型 */
|
|
5
|
+
export type PropertyValueType = 'string' | 'int' | 'float' | 'boolean' | 'date' | 'time';
|
|
6
|
+
/** 类型列下拉选项(中文标签) */
|
|
7
|
+
export declare const VALUE_TYPE_OPTIONS: ReadonlyArray<{
|
|
8
|
+
label: string;
|
|
9
|
+
value: PropertyValueType;
|
|
10
|
+
}>;
|
|
11
|
+
/** float 类型保留的小数位数 */
|
|
12
|
+
export declare const FLOAT_PRECISION = 2;
|
|
13
|
+
/** date 类型内部/导出格式 */
|
|
14
|
+
export declare const DATE_FORMAT = "YYYY-MM-DD";
|
|
15
|
+
/** time 类型内部/导出格式 */
|
|
16
|
+
export declare const TIME_FORMAT = "HH:mm:ss";
|
|
17
|
+
/** boolean 值编辑器下拉选项(是/否) */
|
|
18
|
+
export declare const BOOLEAN_OPTIONS: ReadonlyArray<{
|
|
19
|
+
label: string;
|
|
20
|
+
value: boolean;
|
|
21
|
+
}>;
|
|
4
22
|
/** 内部行数据(一维属性项) */
|
|
5
23
|
export interface PropertyKV {
|
|
6
24
|
/** 行唯一 id(组件内部生成,用于定位编辑行,避免 key 变更导致表格重建) */
|
|
7
25
|
id: string | number;
|
|
8
26
|
/** 属性键 */
|
|
9
27
|
key: string;
|
|
10
|
-
/**
|
|
28
|
+
/** 值类型:导入时按 JS 值自动推断,用户可在类型列切换 */
|
|
29
|
+
type: PropertyValueType;
|
|
30
|
+
/**
|
|
31
|
+
* 属性值。
|
|
32
|
+
* 各类型内部约定:string → 字符串(导入时非 string 原样保留);
|
|
33
|
+
* int → 整数 number;float → 最多保留两位小数的 number;boolean → boolean;
|
|
34
|
+
* date → 'YYYY-MM-DD';time → 'HH:mm:ss'。
|
|
35
|
+
*/
|
|
11
36
|
value: any;
|
|
37
|
+
/** 该行校验规则(弹窗编辑后写入;未配置 → undefined) */
|
|
38
|
+
rules?: PropertyRuleSet;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 属性校验规则集。
|
|
42
|
+
* 字段可用性随值类型区分:required 全类型;string 用 minLength/maxLength/pattern;
|
|
43
|
+
* int/float/date/time 用 min/max(int/float 为 number,date/time 为边界字符串)。
|
|
44
|
+
* 未配置的字段缺省即不启用;message 为全局自定义错误文案,任一规则触发时优先使用。
|
|
45
|
+
*/
|
|
46
|
+
export interface PropertyRuleSet {
|
|
47
|
+
/** 必填:值不能为空 */
|
|
48
|
+
required?: boolean;
|
|
49
|
+
/** string:最小长度 */
|
|
50
|
+
minLength?: number;
|
|
51
|
+
/** string:最大长度 */
|
|
52
|
+
maxLength?: number;
|
|
53
|
+
/** string:正则模式(JS 正则字符串;编译失败时该条不参与校验) */
|
|
54
|
+
pattern?: string;
|
|
55
|
+
/** int/float:最小值(number);date/time:最早边界('YYYY-MM-DD' / 'HH:mm:ss' 字符串) */
|
|
56
|
+
min?: number | string;
|
|
57
|
+
/** int/float:最大值(number);date/time:最晚边界('YYYY-MM-DD' / 'HH:mm:ss' 字符串) */
|
|
58
|
+
max?: number | string;
|
|
59
|
+
/** 全局自定义错误文案:任一规则触发时优先使用,缺省时用各规则默认文案 */
|
|
60
|
+
message?: string;
|
|
12
61
|
}
|
|
13
62
|
/** MeInputProperty Props */
|
|
14
63
|
export interface MeInputPropertyProps {
|
|
@@ -20,19 +69,46 @@ export interface MeInputPropertyProps {
|
|
|
20
69
|
size?: 'small' | 'middle' | 'large';
|
|
21
70
|
/** 是否允许拖拽排序,默认 true */
|
|
22
71
|
draggable?: boolean;
|
|
72
|
+
/** 是否显示类型列(string/int/float/boolean/date/time 下拉),默认 true;隐藏时类型保持推断结果 */
|
|
73
|
+
showType?: boolean;
|
|
74
|
+
/** 是否显示「校验」列(每行魔法图标弹窗编辑规则),默认 true;隐藏时仅隐藏规则编辑入口(不禁止注入/编辑规则数据) */
|
|
75
|
+
showRules?: boolean;
|
|
76
|
+
/** 是否启用校验,默认 false:关闭时不标红(key 空/重复、value 违反规则)且 change 校验报告为空;开启后按行内规则对 key 硬约束与 value 逐行校验并输出报告 */
|
|
77
|
+
validate?: boolean;
|
|
23
78
|
/** key 列占位符 */
|
|
24
79
|
keyPlaceholder?: string;
|
|
25
80
|
/** value 列占位符 */
|
|
26
81
|
valuePlaceholder?: string;
|
|
27
82
|
/** 空数据提示 */
|
|
28
83
|
emptyText?: string;
|
|
84
|
+
/** 外部注入的初始/持久化规则;键为属性 key(trim 后精确匹配)。外部重新赋值 modelValue 时,
|
|
85
|
+
* 会话内已有同 key 规则优先继承,新出现的 key 从这里取规则,消失的 key 规则丢弃 */
|
|
86
|
+
rules?: Record<string, PropertyRuleSet>;
|
|
29
87
|
}
|
|
30
88
|
/** MeInputProperty Events */
|
|
31
89
|
export interface MeInputPropertyEmits {
|
|
32
90
|
/** 更新 v-model 绑定对象 */
|
|
33
91
|
(e: 'update:modelValue', value: Record<string, any>): void;
|
|
34
|
-
/**
|
|
35
|
-
|
|
92
|
+
/**
|
|
93
|
+
* 数据变更(新增/删除/编辑/排序)
|
|
94
|
+
* @param value 合并后的一维 JSON 对象(同名 key 会被覆盖合并,空 key 行被舍弃)
|
|
95
|
+
* @param validation 行级校验报告(重复 key、是否含空 key 等对象输出无法体现的信息)
|
|
96
|
+
*/
|
|
97
|
+
(e: 'change', value: Record<string, any>, validation?: MeInputPropertyValidation): void;
|
|
98
|
+
}
|
|
99
|
+
/** change 事件附带的校验报告(行级信息,对象输出无法体现的数据问题) */
|
|
100
|
+
export interface MeInputPropertyValidation {
|
|
101
|
+
/** 行级重复的 key(忽略大小写与首尾空格,含逐字重复;空数组表示无重复) */
|
|
102
|
+
duplicatedKeys: string[];
|
|
103
|
+
/** 是否存在为空的 key(键名 trim 后为空,该行会被从输出对象中舍弃) */
|
|
104
|
+
hasEmptyKey: boolean;
|
|
105
|
+
/** 逐属性 key 的校验规则快照(空 key 行、无规则行剔除),供消费方构建表单校验/规则体系 */
|
|
106
|
+
rowRules: Record<string, PropertyRuleSet>;
|
|
107
|
+
/**
|
|
108
|
+
* 逐属性 key 的当前违规文案(值为空或违反规则;空 key 行剔除;合法行不纳入)。
|
|
109
|
+
* 供消费方按规则做表单提交校验(提交前判定是否存在非空 valueErrors)。
|
|
110
|
+
*/
|
|
111
|
+
valueErrors: Record<string, string>;
|
|
36
112
|
}
|
|
37
113
|
/** MeInputProperty 组件实例类型 */
|
|
38
114
|
export type MeInputPropertyInstance = InstanceType<typeof import('./index.vue').default>;
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
* MeInputProperty 纯函数校验与转换逻辑
|
|
3
|
-
*
|
|
4
|
-
* 此模块不依赖 Vue,便于复用与单测。
|
|
5
|
-
*/
|
|
1
|
+
import { PropertyKV, PropertyRuleSet, PropertyValueType } from './types';
|
|
6
2
|
/** 生成简单唯一 id(组件内部用于定位行,避免用 key 定位导致表格重建丢焦点) */
|
|
7
3
|
export declare function genId(): string;
|
|
4
|
+
/**
|
|
5
|
+
* 按 JS 值类型推断内部类型:
|
|
6
|
+
* - 整数 number → 'int'
|
|
7
|
+
* - 小数 number(非整数)→ 'float'
|
|
8
|
+
* - boolean → 'boolean'
|
|
9
|
+
* - 匹配 YYYY-MM-DD 的字符串 → 'date'
|
|
10
|
+
* - 匹配 HH:mm(:ss) 的字符串 → 'time'
|
|
11
|
+
* - 其余(含 object/array/null/undefined)→ 'string'
|
|
12
|
+
*/
|
|
13
|
+
export declare function inferValueType(raw: any): PropertyValueType;
|
|
14
|
+
/**
|
|
15
|
+
* 切换类型时把行内当前值归一化为目标类型的内部形态。
|
|
16
|
+
* 解析失败保守处理:int/float 非数字 → 保留原文;date/time 解析失败 → 保留原文,不丢数据;
|
|
17
|
+
* boolean 任何输入都能映射到 true/false(见 toBoolean),不存在丢数据。
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeValue(raw: any, type: PropertyValueType): any;
|
|
20
|
+
/**
|
|
21
|
+
* 导出时把行内值转换为输出对象值。
|
|
22
|
+
* 关键边界:`Number(null)` / `Number('')` 均为 0,int/float 导出必须先判空,避免空行污染为 0。
|
|
23
|
+
* float 统一四舍五入到小数位(如 3.14159 → 3.14)。
|
|
24
|
+
*/
|
|
25
|
+
export declare function exportValue(value: any, type: PropertyValueType): any;
|
|
8
26
|
/** 将 key 统一为用于比较的小写形式(大小写不敏感) */
|
|
9
27
|
export declare function normalizeKey(key: string): string;
|
|
10
28
|
/**
|
|
@@ -16,3 +34,42 @@ export declare function checkDuplicateKeys(rows: {
|
|
|
16
34
|
}[]): string[];
|
|
17
35
|
/** 判断某 key 是否处于重复集合中(大小写不敏感) */
|
|
18
36
|
export declare function isDuplicateKey(key: string, duplicates: string[]): boolean;
|
|
37
|
+
/** 判断某规则字段是否适用于指定类型(用于 sanitize 清理与 UI 渲染) */
|
|
38
|
+
export declare function isRuleApplicable(field: keyof PropertyRuleSet, type: PropertyValueType): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 清理规则集:去掉空/NaN/空串的字段。
|
|
41
|
+
* - required 仅保留 true(false 等价于未设置)
|
|
42
|
+
* - minLength/maxLength 仅保留有效 number
|
|
43
|
+
* - pattern/message 仅保留非空字符串
|
|
44
|
+
* - min/max 仅保留有效 number 或非空字符串(date/time 边界)
|
|
45
|
+
* 清理后无有效字段 → 返回 undefined。
|
|
46
|
+
*/
|
|
47
|
+
export declare function normalizeRuleSet(rules: PropertyRuleSet | undefined): PropertyRuleSet | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* 类型切换时清理规则集:只保留该类型适用的字段。
|
|
50
|
+
* @example string 规则 { pattern, min } 切到 int → 删除 pattern(不适用 int),保留 min(int/float 适用)
|
|
51
|
+
*/
|
|
52
|
+
export declare function sanitizeRulesForType(rules: PropertyRuleSet | undefined, type: PropertyValueType): PropertyRuleSet | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* 校验行值是否满足规则集。
|
|
55
|
+
* @returns 违规时返回提示文案(自定义 message 优先,否则默认文案);通过返回 null。
|
|
56
|
+
* 边界:非法正则编译失败 → 跳过该条;非字符串 string 值(导入遗留)不适用长度/正则;
|
|
57
|
+
* int/float/date/time 空值只由 required 拦截,非必填时不报错;boolean 恒有值无需除 required 外校验。
|
|
58
|
+
*/
|
|
59
|
+
export declare function validateValue(value: any, type: PropertyValueType, rules?: PropertyRuleSet): string | null;
|
|
60
|
+
/**
|
|
61
|
+
* 由行集合构建逐 key 的规则快照(change 事件输出用)。
|
|
62
|
+
* 空 key 行 / 无有效规则的行剔除;同一 key 若多行重复,后出现的覆盖先出现的(与对象输出合并语义一致)。
|
|
63
|
+
*/
|
|
64
|
+
export declare function toRuleMap(rows: Pick<PropertyKV, 'key' | 'rules'>[]): Record<string, PropertyRuleSet>;
|
|
65
|
+
/**
|
|
66
|
+
* 校验行值,返回违规文案或 null(供组件内置标红与 `valueErrors` 输出共用)。
|
|
67
|
+
* 完全委托 validateValue:value 校验严格按已配置的规则集执行——
|
|
68
|
+
* 未配置规则(或规则不适用当前值)→ 不报;空值唯一由 `required` 规则拦截,其余规则只针对有内容的值。
|
|
69
|
+
*/
|
|
70
|
+
export declare function valueError(value: any, type: PropertyValueType, rules?: PropertyRuleSet): string | null;
|
|
71
|
+
/**
|
|
72
|
+
* 由行集合构建逐 key 的当前违规文案快照(change 事件 `valueErrors` 输出用)。
|
|
73
|
+
* 空 key 行 / 合法行剔除;同一 key 若多行重复,后出现的覆盖先出现的(与对象输出合并语义一致)。
|
|
74
|
+
*/
|
|
75
|
+
export declare function toValueErrorMap(rows: Pick<PropertyKV, 'key' | 'type' | 'value' | 'rules'>[]): Record<string, string>;
|