xiaodao-spreader 0.1.34 → 0.1.35
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/style.css +1 -1
- package/dist/types/components/spreader/components/data-validation-input-message.vue.d.ts +22 -0
- package/dist/types/components/spreader/components/{conditional-format-manager.vue.d.ts → pickers/conditional-format-manager.vue.d.ts} +1 -1
- package/dist/types/components/spreader/components/{conditional-format-rule-editor.vue.d.ts → pickers/conditional-format-rule-editor.vue.d.ts} +1 -1
- package/dist/types/components/spreader/components/pickers/data-validation-alert.vue.d.ts +18 -0
- package/dist/types/components/spreader/components/pickers/data-validation-dialog.vue.d.ts +22 -0
- package/dist/types/components/spreader/components/pickers/data-validation-dropdown.vue.d.ts +31 -0
- package/dist/types/components/spreader/components/{filter-popup.vue.d.ts → pickers/filter-popup.vue.d.ts} +1 -1
- package/dist/types/components/spreader/components/spreader.vue.d.ts +8 -5
- package/dist/types/components/spreader/components/toolbar.vue.d.ts +3 -1
- package/dist/types/components/spreader/composables/borders-merge.d.ts +3 -1
- package/dist/types/components/spreader/composables/core-state.d.ts +81 -2
- package/dist/types/components/spreader/composables/interactions.d.ts +23 -1
- package/dist/types/components/spreader/core/data-validation.d.ts +119 -0
- package/dist/types/components/spreader/core/types.d.ts +66 -0
- package/dist/types/components/spreader/index.d.ts +2 -1
- package/dist/xiaodao-spreader.es.js +9106 -7127
- package/dist/xiaodao-spreader.umd.js +9 -9
- package/package.json +1 -1
- /package/dist/types/components/spreader/components/pickers/{borderPicker.vue.d.ts → border-picker.vue.d.ts} +0 -0
- /package/dist/types/components/spreader/components/pickers/{calcPicker.vue.d.ts → calc-picker.vue.d.ts} +0 -0
- /package/dist/types/components/spreader/components/pickers/{colorPicker.vue.d.ts → color-picker.vue.d.ts} +0 -0
- /package/dist/types/components/spreader/components/{conditional-format-menu.vue.d.ts → pickers/conditional-format-menu.vue.d.ts} +0 -0
- /package/dist/types/components/spreader/components/pickers/{insertFunctionDialog.vue.d.ts → insert-function-dialog.vue.d.ts} +0 -0
- /package/dist/types/components/spreader/components/pickers/{mergePicker.vue.d.ts → merge-picker.vue.d.ts} +0 -0
- /package/dist/types/components/spreader/components/pickers/{numberFormatDialog.vue.d.ts → number-format-dialog.vue.d.ts} +0 -0
- /package/dist/types/components/spreader/components/pickers/{sortConfirmDialog.vue.d.ts → sort-confirm-dialog.vue.d.ts} +0 -0
- /package/dist/types/components/spreader/components/pickers/{sortPicker.vue.d.ts → sort-picker.vue.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ComputedRef, type Ref } from 'vue';
|
|
2
2
|
import { FormulaDeps } from '../core/formula';
|
|
3
|
-
import type { CellCoord, CellData, CellStyle, SelectionRange, BorderStyle, BorderSide, FreezePane, ViewportRegion, SheetFilter, FilterColumn, ConditionalFormattingRule, ConditionalFormattingFormat } from '../core/types';
|
|
3
|
+
import type { CellCoord, CellData, CellStyle, SelectionRange, BorderStyle, BorderSide, FreezePane, ViewportRegion, SheetFilter, FilterColumn, ConditionalFormattingRule, ConditionalFormattingFormat, DataValidationRule, DataValidationResult, DataValidationSeverity } from '../core/types';
|
|
4
4
|
import { type FilterCandidates } from '../core/filter-core';
|
|
5
5
|
/** 选区触发方式,影响「合并单元格是否扩大选区」。
|
|
6
6
|
* - 'cell':单元格点击/拖动(默认)→ 保持现有 expandSelectionForMerges 行为
|
|
@@ -9,6 +9,20 @@ import { type FilterCandidates } from '../core/filter-core';
|
|
|
9
9
|
* - 'all' :左上角全选按钮 → expandSelectionForMerges 行为
|
|
10
10
|
*/
|
|
11
11
|
export type SelectionMode = 'cell' | 'row' | 'col' | 'all';
|
|
12
|
+
/** 数据验证出错警告的用户选择:
|
|
13
|
+
* - 'continue':确认继续(写入非法值);
|
|
14
|
+
* - 'retry' :返回编辑态修正(stop 专用);
|
|
15
|
+
* - 'cancel' :放弃本次输入(不写入)。
|
|
16
|
+
*/
|
|
17
|
+
export type DataValidationAlertAction = 'continue' | 'retry' | 'cancel';
|
|
18
|
+
/** 出错警告弹窗需要展示的信息 */
|
|
19
|
+
export interface DataValidationAlertPayload {
|
|
20
|
+
severity: DataValidationSeverity;
|
|
21
|
+
title: string;
|
|
22
|
+
message: string;
|
|
23
|
+
col: number;
|
|
24
|
+
row: number;
|
|
25
|
+
}
|
|
12
26
|
/** AutoFill 拖拽状态 */
|
|
13
27
|
export interface AutoFillState {
|
|
14
28
|
active: boolean;
|
|
@@ -157,7 +171,9 @@ export interface CoreState {
|
|
|
157
171
|
setCellValue: (c: number, r: number, v: string | null | undefined) => void;
|
|
158
172
|
clearCellsInRange: (cS: number, cE: number, rS: number, rE: number) => void;
|
|
159
173
|
startEdit: (initialValue?: string) => void;
|
|
160
|
-
|
|
174
|
+
/** 提交编辑:数据验证发生在写入之前。
|
|
175
|
+
* @returns Promise<boolean> —— true 表示已写入;false 表示被数据验证拦截(仍保持编辑态) */
|
|
176
|
+
commitEdit: () => Promise<boolean>;
|
|
161
177
|
cancelEdit: () => void;
|
|
162
178
|
moveActive: (dC: number, dR: number) => void;
|
|
163
179
|
ensureVisible: (c: number, r: number) => void;
|
|
@@ -203,6 +219,69 @@ export interface CoreState {
|
|
|
203
219
|
clampScroll?: (sx: number | null, sy: number | null) => void;
|
|
204
220
|
/** 查找高亮钩子:返回某单元格当前的高亮类型(由 find-replace 模块注入) */
|
|
205
221
|
findHighlight?: (col: number, row: number) => 'active' | 'match' | null;
|
|
222
|
+
/** 当前工作表的全部数据验证规则(规则属于 Sheet,不属于 Cell) */
|
|
223
|
+
dataValidations: DataValidationRule[];
|
|
224
|
+
/** 命中该单元格的全部规则(经空间索引,不遍历整表) */
|
|
225
|
+
getDataValidationRules: (row: number, col: number) => DataValidationRule[];
|
|
226
|
+
/** 命中该单元格的首条规则(用于「打开数据验证对话框」时回填已有规则) */
|
|
227
|
+
getDataValidationRule: (row: number, col: number) => DataValidationRule | null;
|
|
228
|
+
hasDataValidation: (row: number, col: number) => boolean;
|
|
229
|
+
/** 命中且需要显示下拉箭头的 list 规则 */
|
|
230
|
+
getListValidation: (row: number, col: number) => DataValidationRule | null;
|
|
231
|
+
/** 下拉列表数据(去重、跟随源区域变化) */
|
|
232
|
+
getValidationDropdown: (row: number, col: number) => {
|
|
233
|
+
rule: DataValidationRule;
|
|
234
|
+
items: string[];
|
|
235
|
+
} | null;
|
|
236
|
+
/** 选中单元格时展示的输入信息 */
|
|
237
|
+
getValidationInputMessage: (row: number, col: number) => {
|
|
238
|
+
title: string;
|
|
239
|
+
message: string;
|
|
240
|
+
} | null;
|
|
241
|
+
/** 核心校验入口:编辑 / 粘贴 / AutoFill 等所有输入链路统一调用 */
|
|
242
|
+
validateCell: (row: number, col: number, value: string | null | undefined) => DataValidationResult;
|
|
243
|
+
/** 批量校验(粘贴 / 填充等原子操作):返回最严重的那条失败结果 */
|
|
244
|
+
validateCells: (entries: {
|
|
245
|
+
col: number;
|
|
246
|
+
row: number;
|
|
247
|
+
value: string | null | undefined;
|
|
248
|
+
}[]) => DataValidationResult;
|
|
249
|
+
/** 新建规则(一个完整的规则级 Undo) */
|
|
250
|
+
createDataValidation: (rule: DataValidationRule, opts?: {
|
|
251
|
+
silent?: boolean;
|
|
252
|
+
}) => DataValidationRule;
|
|
253
|
+
/** 更新既有规则(按 id),不存在则视为新建 */
|
|
254
|
+
updateDataValidation: (id: string, patch: Partial<DataValidationRule>, opts?: {
|
|
255
|
+
silent?: boolean;
|
|
256
|
+
}) => void;
|
|
257
|
+
removeDataValidation: (id: string, opts?: {
|
|
258
|
+
silent?: boolean;
|
|
259
|
+
}) => void;
|
|
260
|
+
/** 清除指定范围的验证(规则的 Range 会被拆分/缩小);range 为 null 时清除整个工作表 */
|
|
261
|
+
clearDataValidation: (range: SelectionRange | null, opts?: {
|
|
262
|
+
silent?: boolean;
|
|
263
|
+
}) => void;
|
|
264
|
+
/** 与给定矩形相交的规则(复制携带规则时用) */
|
|
265
|
+
getDataValidationsInRange: (range: SelectionRange) => {
|
|
266
|
+
rule: DataValidationRule;
|
|
267
|
+
range: SelectionRange;
|
|
268
|
+
}[];
|
|
269
|
+
/** 将一批规则应用到目标矩形(先扣除目标区域已有规则,再写入) */
|
|
270
|
+
applyDataValidationsToRange: (rules: DataValidationRule[], target: SelectionRange, opts?: {
|
|
271
|
+
silent?: boolean;
|
|
272
|
+
}) => void;
|
|
273
|
+
/** 规则集合 / 源区域数据变化后失效索引与列表缓存 */
|
|
274
|
+
invalidateDataValidationCache: () => void;
|
|
275
|
+
/** 出错警告弹窗是否打开(编辑器 blur 提交需要避让,避免重入) */
|
|
276
|
+
isValidationAlertOpen: () => boolean;
|
|
277
|
+
/** 出错警告弹窗钩子(由 spreader.vue 注入;未注入时按「stop 拒绝 / 其它放行」处理) */
|
|
278
|
+
showValidationAlert?: (payload: DataValidationAlertPayload) => Promise<DataValidationAlertAction>;
|
|
279
|
+
/** 复用出错警告流程:传入校验失败结果,返回用户决策(供下拉选择等非编辑器入口调用) */
|
|
280
|
+
confirmInvalidValue: (res: DataValidationResult, col: number, row: number) => Promise<DataValidationAlertAction>;
|
|
281
|
+
/** 按 id 或名称取其它工作表的 cells(list 跨表引用,由 spreader.vue 注入) */
|
|
282
|
+
getSheetCellsById?: (sheetId: string) => Record<string, CellData> | null;
|
|
283
|
+
/** 请求打开「数据验证」对话框(由 spreader.vue 注入,供右键菜单 / 工具栏使用) */
|
|
284
|
+
requestDataValidationDialog?: () => void;
|
|
206
285
|
/** AutoFill 拖拽状态:active 时 render 绘制预览,mouseup 触发 applyAutoFill */
|
|
207
286
|
autoFillState: Ref<AutoFillState>;
|
|
208
287
|
/** 一次性提交 AutoFill:saveUndo → ensureCapacity → applyAutoFillPlan → 写入 cells + formulaDeps → selectRange → scheduleRender */
|
|
@@ -3,7 +3,20 @@ import type { CoreState } from './core-state';
|
|
|
3
3
|
import type { UndoStylesState } from './undo-styles';
|
|
4
4
|
import type { BordersMergeState } from './borders-merge';
|
|
5
5
|
import type { SheetsOpsState } from './sheets-ops';
|
|
6
|
-
import type { ContextMenuItem } from '../core/types';
|
|
6
|
+
import type { ContextMenuItem, DataValidationRule } from '../core/types';
|
|
7
|
+
/** 数据验证下拉弹窗状态:anchor 为单元格在视口中的位置(client 坐标) */
|
|
8
|
+
export interface ValidationDropdownState {
|
|
9
|
+
col: number;
|
|
10
|
+
row: number;
|
|
11
|
+
rule: DataValidationRule;
|
|
12
|
+
items: string[];
|
|
13
|
+
/** 当前单元格原始值(用于标记选中项) */
|
|
14
|
+
current: string;
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}
|
|
7
20
|
export interface InteractionsState {
|
|
8
21
|
scheduleRender: () => void;
|
|
9
22
|
render: () => void;
|
|
@@ -47,6 +60,15 @@ export interface InteractionsState {
|
|
|
47
60
|
isFilterButtonHit: (x: number, y: number) => number;
|
|
48
61
|
openFilterPopup: (col: number) => void;
|
|
49
62
|
closeFilterPopup: () => void;
|
|
63
|
+
validationDropdown: Ref<ValidationDropdownState | null>;
|
|
64
|
+
/** 屏幕坐标(client)是否命中某单元格的下拉箭头;命中返回该单元格坐标(合并格返回左上角) */
|
|
65
|
+
isValidationDropdownHit: (x: number, y: number) => {
|
|
66
|
+
col: number;
|
|
67
|
+
row: number;
|
|
68
|
+
} | null;
|
|
69
|
+
openValidationDropdown: (col: number, row: number) => boolean;
|
|
70
|
+
closeValidationDropdown: () => void;
|
|
71
|
+
onValidationDropdownSelect: (value: string) => void;
|
|
50
72
|
dimInputRef: Ref<HTMLInputElement | null>;
|
|
51
73
|
dimPanel: Ref<{
|
|
52
74
|
type: 'row' | 'col';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { CellData, SelectionRange, DataValidationRule, DataValidationResult, DataValidationOperator, DataValidationSeverity } from './types';
|
|
2
|
+
/** 数据验证求值上下文(由 core-state 注入,引擎本身保持纯净) */
|
|
3
|
+
export interface DataValidationContext {
|
|
4
|
+
/** 当前工作表原始单元格数据(供公式引擎引用) */
|
|
5
|
+
cells: Record<string, CellData>;
|
|
6
|
+
colCount: number;
|
|
7
|
+
rowCount: number;
|
|
8
|
+
locale: string;
|
|
9
|
+
/** 取单元格计算后的值(公式已求值) */
|
|
10
|
+
getCellValue: (col: number, row: number) => string;
|
|
11
|
+
/** 按 id 或名称取其它工作表的 cells;用于 list 类型跨表引用。取不到返回 null */
|
|
12
|
+
getSheetCells?: (sheetId: string) => Record<string, CellData> | null;
|
|
13
|
+
}
|
|
14
|
+
/** 生成稳定唯一 ID(供新建规则使用,禁止依赖数组 index) */
|
|
15
|
+
export declare function genDataValidationId(): string;
|
|
16
|
+
/** 单元格是否落在任一应用范围之内(含边界) */
|
|
17
|
+
export declare function dvCellInRanges(ranges: SelectionRange[], col: number, row: number): boolean;
|
|
18
|
+
/** 规则范围左上角(所有 ranges 的最小 startCol/startRow),作为相对引用的基准 */
|
|
19
|
+
export declare function dvRuleAnchor(rule: DataValidationRule): {
|
|
20
|
+
col: number;
|
|
21
|
+
row: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 空值判定:null / undefined / '' / 纯空白 均视为空。
|
|
25
|
+
* 与「不存在的单元格」在业务上等价(本项目单元格缺省即空字符串)。
|
|
26
|
+
*/
|
|
27
|
+
export declare function isBlankValue(value: unknown): boolean;
|
|
28
|
+
/** 文本长度:按 Unicode 码点统计(中文 / Emoji 不会像 UTF-16 那样被算成 2) */
|
|
29
|
+
export declare function dvTextLength(value: string): number;
|
|
30
|
+
/**
|
|
31
|
+
* 将「操作数」(单元格输入值或规则条件值)解析为数值。
|
|
32
|
+
* - 前导 '=' 视为公式,求值后取数值结果(如 =TODAY());公式错误返回 null;
|
|
33
|
+
* - 复用项目 parseNumericText 处理千分位 / 百分比 / 货币符号;
|
|
34
|
+
* - 其余走严格数值正则,避免 Number('0x10') 之类的误判。
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseNumericOperand(raw: string, ctx: DataValidationContext): number | null;
|
|
37
|
+
/**
|
|
38
|
+
* 将操作数解析为「日期序列号」。
|
|
39
|
+
* - 纯数值 → 直接作为序列号(Excel 日期序列);
|
|
40
|
+
* - 日期/日期时间字符串 → 复用项目 parseDateTimeInput(与单元格输入识别同源);
|
|
41
|
+
* - 纯时间字符串(如 12:30)不属于日期 → null。
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseDateOperand(raw: string, ctx: DataValidationContext): number | null;
|
|
44
|
+
/**
|
|
45
|
+
* 将操作数解析为「时间」(一天的分数,0 <= x < 1)。
|
|
46
|
+
* - 纯时间字符串 → 复用 parseDateTimeInput;
|
|
47
|
+
* - 日期时间字符串 → 取小数部分;
|
|
48
|
+
* - 数值 → 取小数部分(Excel 时间即序列的小数部分)。
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseTimeOperand(raw: string, ctx: DataValidationContext): number | null;
|
|
51
|
+
/** 通用比较:op 作用于 (value, v1[, v2]);操作数解析失败或比较数缺失一律视为不通过(返回 false) */
|
|
52
|
+
export declare function compareWithOperator(op: DataValidationOperator, value: number, v1: number | null, v2: number | null): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 解析 list 规则的候选项(去重、保序)。
|
|
55
|
+
* - values:直接使用常量列表;
|
|
56
|
+
* - range:读取目标区域(默认当前表,可通过 sheetId 跨表),空单元格按 allowBlank 决定是否保留。
|
|
57
|
+
* 本函数不做缓存(缓存与失效由调用方 core-state 负责)。
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveListItems(rule: DataValidationRule, ctx: DataValidationContext): string[];
|
|
60
|
+
/** list 规则是否显示单元格内下拉箭头 */
|
|
61
|
+
export declare function hasDropdownIndicator(rule: DataValidationRule | null | undefined): boolean;
|
|
62
|
+
/** 单条规则求值:value 为待写入的原始文本(不含隐式类型转换),col/row 为目标单元格坐标 */
|
|
63
|
+
export declare function evaluateDataValidationRule(rule: DataValidationRule, value: string | null | undefined, col: number, row: number, ctx: DataValidationContext): boolean;
|
|
64
|
+
/** errorStyle → severity(未配置默认 stop) */
|
|
65
|
+
export declare function dvSeverityOf(rule: DataValidationRule): DataValidationSeverity;
|
|
66
|
+
/**
|
|
67
|
+
* 校验某个单元格的候选值。
|
|
68
|
+
* 规则:命中范围内的**所有**规则必须全部通过(rules.every);
|
|
69
|
+
* 失败时取严重级别最高(stop > warning > information)的那条规则生成提示。
|
|
70
|
+
*/
|
|
71
|
+
export declare function validateCellValue(value: string | null | undefined, col: number, row: number, rules: DataValidationRule[], ctx: DataValidationContext): DataValidationResult;
|
|
72
|
+
/**
|
|
73
|
+
* 生成默认错误提示文案(用户未自定义 title/message 时使用)。
|
|
74
|
+
* 文案按类型描述约束条件,便于用户理解「为什么非法」。
|
|
75
|
+
*/
|
|
76
|
+
export declare function defaultDataValidationText(rule: DataValidationRule, locale: string): {
|
|
77
|
+
title: string;
|
|
78
|
+
message: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* 数据验证规则空间索引。
|
|
82
|
+
* - rebuild(rules):重建(随规则变化调用,成本 O(区域总数));
|
|
83
|
+
* - getRules(col,row):返回命中该单元格且启用的规则列表。
|
|
84
|
+
*/
|
|
85
|
+
export declare class DataValidationIndex {
|
|
86
|
+
private bands;
|
|
87
|
+
private dirty;
|
|
88
|
+
private source;
|
|
89
|
+
constructor(rules?: DataValidationRule[]);
|
|
90
|
+
/** 规则集合发生变化(增/删/改/切表/撤销恢复)后调用 */
|
|
91
|
+
invalidate(): void;
|
|
92
|
+
private ensure;
|
|
93
|
+
/** 命中该单元格的规则(保持源数组顺序) */
|
|
94
|
+
getRules(col: number, row: number, rules?: DataValidationRule[]): DataValidationRule[];
|
|
95
|
+
/** 该单元格是否存在任何数据验证 */
|
|
96
|
+
has(col: number, row: number, rules?: DataValidationRule[]): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 命中该单元格且满足 predicate 的首条规则。
|
|
99
|
+
* 渲染热路径(每格判定是否画下拉箭头)专用:不分配数组,零垃圾。
|
|
100
|
+
*/
|
|
101
|
+
findRule(col: number, row: number, predicate: (rule: DataValidationRule) => boolean, rules?: DataValidationRule[]): DataValidationRule | null;
|
|
102
|
+
/** 取某坐标所在行带的候选条目(必要时先重建索引) */
|
|
103
|
+
private bandsOf;
|
|
104
|
+
}
|
|
105
|
+
/** 删除带(axis='row' 删行 / 'col' 删列)后收缩单个 Range;整段落在删除带内返回 null */
|
|
106
|
+
export declare function adjustDvRangeForDelete(r: SelectionRange, axis: 'row' | 'col', idx: number, count: number): SelectionRange | null;
|
|
107
|
+
/** 插入带(axis='row' 插行 / 'col' 插列)后放大单个 Range */
|
|
108
|
+
export declare function adjustDvRangeForInsert(r: SelectionRange, axis: 'row' | 'col', idx: number, count: number): SelectionRange;
|
|
109
|
+
/** 规则区域是否与给定矩形相交 */
|
|
110
|
+
export declare function dvRangeIntersects(a: SelectionRange, b: SelectionRange): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* 从规则中扣除给定矩形(用于「清除所选区域的验证」):
|
|
113
|
+
* 支持矩形差集拆分,剩余为空时返回空数组。
|
|
114
|
+
*/
|
|
115
|
+
export declare function subtractDvRange(range: SelectionRange, cut: SelectionRange): SelectionRange[];
|
|
116
|
+
/** 平移规则的某个区域(复制粘贴携带规则时使用) */
|
|
117
|
+
export declare function translateDvRange(r: SelectionRange, dCol: number, dRow: number): SelectionRange;
|
|
118
|
+
/** 求两个矩形的交集;不相交返回 null */
|
|
119
|
+
export declare function intersectDvRange(a: SelectionRange, b: SelectionRange): SelectionRange | null;
|
|
@@ -190,6 +190,68 @@ export interface ConditionalFormattingRule {
|
|
|
190
190
|
/** 是否启用 */
|
|
191
191
|
enabled: boolean;
|
|
192
192
|
}
|
|
193
|
+
/** 数据验证类型(对齐 Excel:整数 / 小数 / 列表 / 日期 / 时间 / 文本长度 / 自定义) */
|
|
194
|
+
export type DataValidationType = 'any' | 'list' | 'wholeNumber' | 'decimal' | 'date' | 'time' | 'textLength' | 'custom';
|
|
195
|
+
/** 条件运算符(数值 / 日期 / 时间 / 文本长度通用) */
|
|
196
|
+
export type DataValidationOperator = 'between' | 'notBetween' | 'equal' | 'notEqual' | 'greaterThan' | 'greaterThanOrEqual' | 'lessThan' | 'lessThanOrEqual';
|
|
197
|
+
/** 出错警告样式:停止(拒绝提交)/ 警告(可确认继续)/ 信息(提示后由用户决定) */
|
|
198
|
+
export type DataValidationErrorStyle = 'stop' | 'warning' | 'information';
|
|
199
|
+
/** 下拉列表数据源:
|
|
200
|
+
* - values:直接输入的逗号分隔常量列表;
|
|
201
|
+
* - range:引用工作表区域(可跨表),支持动态列表(区域数据变化时下拉项同步更新)。
|
|
202
|
+
*/
|
|
203
|
+
export type DataValidationListSource = {
|
|
204
|
+
type: 'values';
|
|
205
|
+
values: string[];
|
|
206
|
+
} | {
|
|
207
|
+
type: 'range';
|
|
208
|
+
range: SelectionRange; /** 目标工作表 id 或名称;缺省表示当前工作表 */
|
|
209
|
+
sheetId?: string;
|
|
210
|
+
};
|
|
211
|
+
/** 单条数据验证规则:属于 Sheet 而非 Cell;仅描述「输入约束 + UI 行为」,不写入 cell style */
|
|
212
|
+
export interface DataValidationRule {
|
|
213
|
+
/** 稳定唯一 ID(禁止数组 index) */
|
|
214
|
+
id: string;
|
|
215
|
+
/** 应用范围(支持多区域) */
|
|
216
|
+
ranges: SelectionRange[];
|
|
217
|
+
type: DataValidationType;
|
|
218
|
+
operator?: DataValidationOperator;
|
|
219
|
+
/** 条件值 1(between/notBetween 时为下界) */
|
|
220
|
+
formula1?: string;
|
|
221
|
+
/** 条件值 2(between/notBetween 时为上界) */
|
|
222
|
+
formula2?: string;
|
|
223
|
+
/** list 类型的数据源(优先于 values) */
|
|
224
|
+
listSource?: DataValidationListSource;
|
|
225
|
+
/** 兼容字段:list + 常量列表时与 listSource.values 保持同步 */
|
|
226
|
+
values?: string[];
|
|
227
|
+
/** 忽略空值(默认 true) */
|
|
228
|
+
allowBlank?: boolean;
|
|
229
|
+
/** list 类型是否显示单元格内下拉箭头(默认 true) */
|
|
230
|
+
showDropdown?: boolean;
|
|
231
|
+
/** 选中单元格时显示输入信息(默认 false) */
|
|
232
|
+
showInputMessage?: boolean;
|
|
233
|
+
inputTitle?: string;
|
|
234
|
+
inputMessage?: string;
|
|
235
|
+
/** 无效数据时显示错误警告(默认 true) */
|
|
236
|
+
showErrorMessage?: boolean;
|
|
237
|
+
/** 出错警告样式(默认 stop) */
|
|
238
|
+
errorStyle?: DataValidationErrorStyle;
|
|
239
|
+
errorTitle?: string;
|
|
240
|
+
errorMessage?: string;
|
|
241
|
+
/** 是否启用(默认 true) */
|
|
242
|
+
enabled?: boolean;
|
|
243
|
+
}
|
|
244
|
+
/** 单条规则的验证结果严重级别(与 errorStyle 对应) */
|
|
245
|
+
export type DataValidationSeverity = 'stop' | 'warning' | 'information';
|
|
246
|
+
/** 数据验证结果:valid=false 时携带最严重的那条失败规则与提示文案 */
|
|
247
|
+
export interface DataValidationResult {
|
|
248
|
+
valid: boolean;
|
|
249
|
+
/** 命中的失败规则(多条失败时取严重级别最高的一条) */
|
|
250
|
+
rule?: DataValidationRule;
|
|
251
|
+
severity?: DataValidationSeverity;
|
|
252
|
+
title?: string;
|
|
253
|
+
message?: string;
|
|
254
|
+
}
|
|
193
255
|
export interface SheetModelData {
|
|
194
256
|
name: string;
|
|
195
257
|
/** 表格级样式池:styles[0] 始终为默认空样式 {} */
|
|
@@ -214,6 +276,8 @@ export interface SheetModelData {
|
|
|
214
276
|
filter?: SheetFilter;
|
|
215
277
|
/** 条件格式规则集合;缺省视为无规则 */
|
|
216
278
|
conditionalFormats?: ConditionalFormattingRule[];
|
|
279
|
+
/** 数据验证规则集合;旧数据缺省视为无数据验证 */
|
|
280
|
+
dataValidations?: DataValidationRule[];
|
|
217
281
|
}
|
|
218
282
|
export interface SheetState {
|
|
219
283
|
id: string;
|
|
@@ -240,6 +304,8 @@ export interface SheetState {
|
|
|
240
304
|
filter: SheetFilter | null;
|
|
241
305
|
/** 条件格式规则集合;缺省为空数组 */
|
|
242
306
|
conditionalFormats: ConditionalFormattingRule[];
|
|
307
|
+
/** 数据验证规则集合;缺省为空数组 */
|
|
308
|
+
dataValidations: DataValidationRule[];
|
|
243
309
|
}
|
|
244
310
|
/** 视口区域:冻结窗格将画布划分为四个独立滚动区域 */
|
|
245
311
|
export interface ViewportRegion {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Spreader from './components/spreader.vue';
|
|
2
2
|
export default Spreader;
|
|
3
3
|
export { Spreader };
|
|
4
|
-
export type { CellCoord, SelectionRange, CellData, CellStyle, BorderStyle, BorderSide, BorderSource, Range, SpreadsheetOptions, SpreadsheetData, SheetModelData, SheetState, UndoSnapshot, ContextMenuItem, ThemeColors, Point, } from './core/types';
|
|
4
|
+
export type { CellCoord, SelectionRange, CellData, CellStyle, BorderStyle, BorderSide, BorderSource, Range, SpreadsheetOptions, SpreadsheetData, SheetModelData, SheetState, UndoSnapshot, ContextMenuItem, ThemeColors, Point, DataValidationRule, DataValidationType, DataValidationOperator, DataValidationErrorStyle, DataValidationListSource, DataValidationResult, DataValidationSeverity, ConditionalFormattingRule, ConditionalFormattingCondition, ConditionalFormattingFormat, } from './core/types';
|
|
5
|
+
export { validateCellValue, evaluateDataValidationRule, resolveListItems, DataValidationIndex, genDataValidationId, } from './core/data-validation';
|
|
5
6
|
export { StylePool, resolveStyle, migrateCells, cloneCells } from './core/style-pool';
|