xiaodao-spreader 0.1.34 → 0.1.36
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/README.ZH.md +58 -1
- package/README.md +58 -1
- 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/pickers/outline-picker.vue.d.ts +26 -0
- package/dist/types/components/spreader/components/spreader.vue.d.ts +17 -5
- package/dist/types/components/spreader/components/toolbar.vue.d.ts +9 -1
- package/dist/types/components/spreader/composables/borders-merge.d.ts +3 -1
- package/dist/types/components/spreader/composables/core-state.d.ts +121 -2
- package/dist/types/components/spreader/composables/interactions.d.ts +33 -1
- package/dist/types/components/spreader/core/autofill.d.ts +11 -2
- package/dist/types/components/spreader/core/constants.d.ts +2 -0
- package/dist/types/components/spreader/core/data-validation.d.ts +119 -0
- package/dist/types/components/spreader/core/outline-core.d.ts +64 -0
- package/dist/types/components/spreader/core/types.d.ts +90 -0
- package/dist/types/components/spreader/index.d.ts +2 -1
- package/dist/xiaodao-spreader.es.js +9901 -7153
- 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} +1 -1
- /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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { DimensionOutline } from './types';
|
|
2
|
+
/** 分组校验失败的原因 */
|
|
3
|
+
export type OutlineValidationCode = 'outlineMinSize' | 'outlineCrossing' | 'outlineTooDeep' | 'outlineInvalid';
|
|
4
|
+
export interface OutlineValidationResult {
|
|
5
|
+
ok: boolean;
|
|
6
|
+
code?: OutlineValidationCode;
|
|
7
|
+
/** 通过校验时,根据嵌套关系算出的层级(1 起) */
|
|
8
|
+
level?: number;
|
|
9
|
+
}
|
|
10
|
+
/** 范围内包含多少既有分组(严格包含该范围的组越多,层级越深) */
|
|
11
|
+
export declare function countContaining(outlines: DimensionOutline[], start: number, end: number): number;
|
|
12
|
+
/**
|
|
13
|
+
* 校验一个新分组(start/end 为 0-based 闭区间)是否可在既有分组集合上创建。
|
|
14
|
+
* 规则:
|
|
15
|
+
* - start <= end
|
|
16
|
+
* - 至少连续 2 个维度
|
|
17
|
+
* - 与既有分组要么不相交要么完全包含,禁止部分重叠
|
|
18
|
+
* - 层级(countContaining + 1)不超过 MAX_OUTLINE_LEVEL
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateGroup(existing: DimensionOutline[], start: number, end: number): OutlineValidationResult;
|
|
21
|
+
/** 创建分组后的新集合(校验失败返回原集合,同时给出校验结果供调用方提示) */
|
|
22
|
+
export declare function addOutline(existing: DimensionOutline[], axis: 'row' | 'column', start: number, end: number, id: string, opts?: {
|
|
23
|
+
collapsed?: boolean;
|
|
24
|
+
}): {
|
|
25
|
+
outlines: DimensionOutline[];
|
|
26
|
+
validation: OutlineValidationResult;
|
|
27
|
+
};
|
|
28
|
+
/** 设置某个分组的折叠状态 */
|
|
29
|
+
export declare function setOutlineCollapsed(outlines: DimensionOutline[], id: string, collapsed: boolean): DimensionOutline[];
|
|
30
|
+
/** 删除某个分组(返回新集合) */
|
|
31
|
+
export declare function removeOutline(outlines: DimensionOutline[], id: string): DimensionOutline[];
|
|
32
|
+
/** 清除全部(某方向)分组 */
|
|
33
|
+
export declare function clearOutlines(): DimensionOutline[];
|
|
34
|
+
/** 插入 count 个维度到 index 处后,调整既有分组范围(完全遵循 Range 插入语义) */
|
|
35
|
+
export declare function addOutlineForInsert(outlines: DimensionOutline[], index: number, count: number): DimensionOutline[];
|
|
36
|
+
/** 删除 [index, index+count-1] 这段维度后,调整既有分组;空组自动移除 */
|
|
37
|
+
export declare function addOutlineForDelete(outlines: DimensionOutline[], index: number, count: number): DimensionOutline[];
|
|
38
|
+
/**
|
|
39
|
+
* 根据嵌套关系重建每个分组的 level:
|
|
40
|
+
* level = (严格包含该分组的其它分组数量) + 1
|
|
41
|
+
* 注意:必须排除自身,否则每个分组都会被自己计数导致层级 +1。
|
|
42
|
+
*/
|
|
43
|
+
export declare function recomputeOutlineLevels(outlines: DimensionOutline[]): DimensionOutline[];
|
|
44
|
+
/**
|
|
45
|
+
* 维度可见性索引。
|
|
46
|
+
* - levels[i] : 维度 i 所处的 outline 层级(0 = 不在任何分组内)
|
|
47
|
+
* - hidden[i] : 维度 i 是否被某个「已折叠分组」包含(不可见)
|
|
48
|
+
* - maxLevel : 当前分组最深层级(≥1);无分组为 0
|
|
49
|
+
*/
|
|
50
|
+
export interface OutlineIndex {
|
|
51
|
+
levels: number[];
|
|
52
|
+
hidden: boolean[];
|
|
53
|
+
maxLevel: number;
|
|
54
|
+
}
|
|
55
|
+
/** 构建线性维度(行/列)的 outline 索引。count = 维度总数 */
|
|
56
|
+
export declare function buildOutlineIndex(outlines: DimensionOutline[], count: number): OutlineIndex;
|
|
57
|
+
/** 维度 i 所处的 outline 层级(无分组为 0) */
|
|
58
|
+
export declare function outlineLevelAt(outlines: DimensionOutline[], i: number): number;
|
|
59
|
+
/** 维度 i 是否被某个已折叠分组包含(不可见) */
|
|
60
|
+
export declare function isOutlineCollapsedAt(outlines: DimensionOutline[], i: number): boolean;
|
|
61
|
+
/** 是否已存在跨过该分组 cell 的既有分组(按 cell 命中) */
|
|
62
|
+
export declare function hasOutlineInRange(outlines: DimensionOutline[], start: number, end: number): boolean;
|
|
63
|
+
/** 生成稳定唯一分组 ID(避免与既有 ID 冲突) */
|
|
64
|
+
export declare function genOutlineId(existing: DimensionOutline[], axis: 'row' | 'column'): string;
|
|
@@ -190,6 +190,82 @@ 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
|
+
}
|
|
255
|
+
/** 单个行列分组的最大支持层级(与 Excel 一致,最多 8 级) */
|
|
256
|
+
export declare const MAX_OUTLINE_LEVEL = 8;
|
|
257
|
+
/** 维度分组:属于 Sheet 的结构元数据。start/end 为 0-based 闭区间,且 start <= end */
|
|
258
|
+
export interface DimensionOutline {
|
|
259
|
+
/** 稳定唯一 ID(禁止数组 index) */
|
|
260
|
+
id: string;
|
|
261
|
+
axis: 'row' | 'column';
|
|
262
|
+
start: number;
|
|
263
|
+
end: number;
|
|
264
|
+
/** 由嵌套关系计算得到的层级(1 起),非用户手工输入 */
|
|
265
|
+
level: number;
|
|
266
|
+
/** 是否折叠(折叠时隐藏组内 Detail,逻辑行列仍存在) */
|
|
267
|
+
collapsed: boolean;
|
|
268
|
+
}
|
|
193
269
|
export interface SheetModelData {
|
|
194
270
|
name: string;
|
|
195
271
|
/** 表格级样式池:styles[0] 始终为默认空样式 {} */
|
|
@@ -214,6 +290,12 @@ export interface SheetModelData {
|
|
|
214
290
|
filter?: SheetFilter;
|
|
215
291
|
/** 条件格式规则集合;缺省视为无规则 */
|
|
216
292
|
conditionalFormats?: ConditionalFormattingRule[];
|
|
293
|
+
/** 数据验证规则集合;旧数据缺省视为无数据验证 */
|
|
294
|
+
dataValidations?: DataValidationRule[];
|
|
295
|
+
/** 行分组集合;旧数据缺省视为无分组 */
|
|
296
|
+
rowOutlines?: DimensionOutline[];
|
|
297
|
+
/** 列分组集合;旧数据缺省视为无分组 */
|
|
298
|
+
columnOutlines?: DimensionOutline[];
|
|
217
299
|
}
|
|
218
300
|
export interface SheetState {
|
|
219
301
|
id: string;
|
|
@@ -240,6 +322,12 @@ export interface SheetState {
|
|
|
240
322
|
filter: SheetFilter | null;
|
|
241
323
|
/** 条件格式规则集合;缺省为空数组 */
|
|
242
324
|
conditionalFormats: ConditionalFormattingRule[];
|
|
325
|
+
/** 数据验证规则集合;缺省为空数组 */
|
|
326
|
+
dataValidations: DataValidationRule[];
|
|
327
|
+
/** 行分组集合;缺省为空数组 */
|
|
328
|
+
rowOutlines: DimensionOutline[];
|
|
329
|
+
/** 列分组集合;缺省为空数组 */
|
|
330
|
+
columnOutlines: DimensionOutline[];
|
|
243
331
|
}
|
|
244
332
|
/** 视口区域:冻结窗格将画布划分为四个独立滚动区域 */
|
|
245
333
|
export interface ViewportRegion {
|
|
@@ -275,6 +363,8 @@ export interface ThemeColors {
|
|
|
275
363
|
gridLine: string;
|
|
276
364
|
selectionBg: string;
|
|
277
365
|
activeCellBorder: string;
|
|
366
|
+
outlineGroupBg1: string;
|
|
367
|
+
outlineGroupBg2: string;
|
|
278
368
|
cellText: string;
|
|
279
369
|
scrollTrack: string;
|
|
280
370
|
scrollThumb: string;
|
|
@@ -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';
|