@univerjs/sheets-data-validation-ui 1.5.1 → 1.6.0
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/lib/cjs/index.js +29 -63
- package/lib/es/index.js +29 -63
- package/lib/index.js +29 -63
- package/lib/types/views/widgets/dropdown-widget.d.ts +2 -5
- package/lib/umd/index.js +1 -1
- package/package.json +20 -19
package/lib/cjs/index.js
CHANGED
|
@@ -12,10 +12,11 @@ let _univerjs_design = require("@univerjs/design");
|
|
|
12
12
|
let react = require("react");
|
|
13
13
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
14
|
let _univerjs_icons = require("@univerjs/icons");
|
|
15
|
+
let _univerjs_icons_svg = require("@univerjs/icons-svg");
|
|
15
16
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
16
17
|
let _univerjs_sheets_formula_ui = require("@univerjs/sheets-formula-ui");
|
|
17
18
|
|
|
18
|
-
// \0@oxc-project+runtime@0.
|
|
19
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
|
|
19
20
|
function _typeof(o) {
|
|
20
21
|
"@babel/helpers - typeof";
|
|
21
22
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -25,7 +26,7 @@ function _typeof(o) {
|
|
|
25
26
|
}, _typeof(o);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
// \0@oxc-project+runtime@0.
|
|
29
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
29
30
|
function toPrimitive(t, e) {
|
|
30
31
|
if ("object" != _typeof(t) || !t) return t;
|
|
31
32
|
var r;
|
|
@@ -37,13 +38,13 @@ function toPrimitive(t, e) {
|
|
|
37
38
|
return ("string" === e ? String : Number)(t);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
// \0@oxc-project+runtime@0.
|
|
41
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
|
|
41
42
|
function toPropertyKey(t) {
|
|
42
43
|
var i = toPrimitive(t, "string");
|
|
43
44
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
// \0@oxc-project+runtime@0.
|
|
47
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
|
|
47
48
|
function _defineProperty(e, r, t) {
|
|
48
49
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
49
50
|
value: t,
|
|
@@ -53,14 +54,14 @@ function _defineProperty(e, r, t) {
|
|
|
53
54
|
}) : e[r] = t, e;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
// \0@oxc-project+runtime@0.
|
|
57
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
|
|
57
58
|
function __decorateParam(paramIndex, decorator) {
|
|
58
59
|
return function(target, key) {
|
|
59
60
|
decorator(target, key, paramIndex);
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
// \0@oxc-project+runtime@0.
|
|
64
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
|
|
64
65
|
function __decorate(decorators, target, key, desc) {
|
|
65
66
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
66
67
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -510,6 +511,11 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
510
511
|
const showColor = (rule === null || rule === void 0 ? void 0 : rule.renderMode) === _univerjs_core.DataValidationRenderMode.CUSTOM || (rule === null || rule === void 0 ? void 0 : rule.renderMode) === void 0;
|
|
511
512
|
const list = validator.getListWithColor(rule, unitId, subUnitId);
|
|
512
513
|
const cellStr = (0, _univerjs_sheets_data_validation.getDataValidationCellValue)(worksheet.getCellRaw(row, col));
|
|
514
|
+
const toOptionLabel = (value) => {
|
|
515
|
+
var _list$find;
|
|
516
|
+
return ((_list$find = list.find((item) => item.label.toLowerCase() === value.toLowerCase())) === null || _list$find === void 0 ? void 0 : _list$find.label) ?? value;
|
|
517
|
+
};
|
|
518
|
+
const defaultValue = multiple ? (0, _univerjs_sheets.serializeListOptions)((0, _univerjs_sheets.deserializeListOptions)(cellStr).map(toOptionLabel)) : toOptionLabel(cellStr);
|
|
513
519
|
const handleEdit = () => {
|
|
514
520
|
this._commandService.executeCommand(OpenValidationPanelOperation.id, { ruleId: rule.uid });
|
|
515
521
|
popupDisposable === null || popupDisposable === void 0 || popupDisposable.dispose();
|
|
@@ -525,7 +531,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
525
531
|
color: showColor || item.color ? item.color || "gray.100" : "transparent"
|
|
526
532
|
})),
|
|
527
533
|
onEdit: handleEdit,
|
|
528
|
-
defaultValue
|
|
534
|
+
defaultValue,
|
|
529
535
|
multiple,
|
|
530
536
|
showEdit: ((_this$_configService$ = this._configService.getConfig("sheets-data-validation-ui.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.showEditOnDropdown) ?? true,
|
|
531
537
|
showSearch: ((_this$_configService$2 = this._configService.getConfig("sheets-data-validation-ui.config")) === null || _this$_configService$2 === void 0 ? void 0 : _this$_configService$2.showSearchOnDropdown) ?? true
|
|
@@ -1059,7 +1065,7 @@ const menuSchema = {
|
|
|
1059
1065
|
|
|
1060
1066
|
// package.json
|
|
1061
1067
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
1062
|
-
var version = "1.
|
|
1068
|
+
var version = "1.6.0";
|
|
1063
1069
|
|
|
1064
1070
|
// src/controllers/dv-alert.controller.ts
|
|
1065
1071
|
const ALERT_KEY = "SHEET_DATA_VALIDATION_ALERT";
|
|
@@ -2195,7 +2201,6 @@ var Dropdown$1 = class extends _univerjs_engine_render.Shape {
|
|
|
2195
2201
|
};
|
|
2196
2202
|
|
|
2197
2203
|
// src/views/widgets/dropdown-multiple-widget.ts
|
|
2198
|
-
const downPath$1 = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
|
|
2199
2204
|
let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
2200
2205
|
constructor(_commandService, _univerInstanceService, _renderManagerService, _dataValidationModel) {
|
|
2201
2206
|
this._commandService = _commandService;
|
|
@@ -2227,8 +2232,7 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
2227
2232
|
}
|
|
2228
2233
|
ctx.save();
|
|
2229
2234
|
ctx.translateWithPrecision(cellBounding.startX + left, cellBounding.startY + top);
|
|
2230
|
-
ctx
|
|
2231
|
-
ctx.fill(downPath$1);
|
|
2235
|
+
(0, _univerjs_icons_svg.drawCanvasIcon)(ctx, "down-icon", -2, -2, 10, DROP_DOWN_ICON_COLOR);
|
|
2232
2236
|
ctx.restore();
|
|
2233
2237
|
}
|
|
2234
2238
|
drawWith(ctx, info, skeleton, spreadsheets) {
|
|
@@ -2258,7 +2262,6 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
2258
2262
|
const vt = _vt ?? _univerjs_core.VerticalAlign.MIDDLE;
|
|
2259
2263
|
const cellValue = (0, _univerjs_sheets_data_validation.getCellValueOrigin)(data) ?? "";
|
|
2260
2264
|
const items = validator.parseCellValue(cellValue);
|
|
2261
|
-
const labelColorMap = validator.getListWithColorMap(rule);
|
|
2262
2265
|
const layout = layoutDropdowns(items, fontStyle, cellWidth, cellHeight);
|
|
2263
2266
|
this._drawDownIcon(ctx, cellBounding, cellWidth, cellHeight, vt);
|
|
2264
2267
|
ctx.save();
|
|
@@ -2293,7 +2296,7 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
2293
2296
|
...fontStyle,
|
|
2294
2297
|
info: item,
|
|
2295
2298
|
color,
|
|
2296
|
-
fill:
|
|
2299
|
+
fill: validator.getOptionColor(rule, item.text)
|
|
2297
2300
|
});
|
|
2298
2301
|
ctx.restore();
|
|
2299
2302
|
});
|
|
@@ -2454,7 +2457,6 @@ const PADDING_V = 1;
|
|
|
2454
2457
|
const MARGIN_H = 6;
|
|
2455
2458
|
const MARGIN_V = 3;
|
|
2456
2459
|
const RADIUS_BG = 8;
|
|
2457
|
-
const downPath = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
|
|
2458
2460
|
function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margin = true) {
|
|
2459
2461
|
let paddingTop = 0;
|
|
2460
2462
|
const realMargin = margin ? MARGIN_V : 0;
|
|
@@ -2488,20 +2490,8 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2488
2490
|
this._commandService = _commandService;
|
|
2489
2491
|
this._renderManagerService = _renderManagerService;
|
|
2490
2492
|
this._dataValidationModel = _dataValidationModel;
|
|
2491
|
-
_defineProperty(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
|
|
2492
2493
|
_defineProperty(this, "zIndex", void 0);
|
|
2493
2494
|
}
|
|
2494
|
-
_ensureMap(subUnitId) {
|
|
2495
|
-
let map = this._dropdownInfoMap.get(subUnitId);
|
|
2496
|
-
if (!map) {
|
|
2497
|
-
map = /* @__PURE__ */ new Map();
|
|
2498
|
-
this._dropdownInfoMap.set(subUnitId, map);
|
|
2499
|
-
}
|
|
2500
|
-
return map;
|
|
2501
|
-
}
|
|
2502
|
-
_generateKey(row, col) {
|
|
2503
|
-
return `${row}.${col}`;
|
|
2504
|
-
}
|
|
2505
2495
|
_drawDownIcon(ctx, cellBounding, cellWidth, cellHeight, fontHeight, vt, pd) {
|
|
2506
2496
|
const { t = _univerjs_core.DEFAULT_STYLES.pd.t, b = _univerjs_core.DEFAULT_STYLES.pd.b } = pd;
|
|
2507
2497
|
const left = cellWidth - ICON_PLACE;
|
|
@@ -2517,12 +2507,11 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2517
2507
|
}
|
|
2518
2508
|
ctx.save();
|
|
2519
2509
|
ctx.translateWithPrecision(cellBounding.startX + left, cellBounding.startY + top);
|
|
2520
|
-
ctx
|
|
2521
|
-
ctx.fill(downPath);
|
|
2510
|
+
(0, _univerjs_icons_svg.drawCanvasIcon)(ctx, "down-icon", -2, -2, 10, DROP_DOWN_ICON_COLOR);
|
|
2522
2511
|
ctx.restore();
|
|
2523
2512
|
}
|
|
2524
|
-
drawWith(ctx, info,
|
|
2525
|
-
const { primaryWithCoord, row, col, style, data
|
|
2513
|
+
drawWith(ctx, info, _skeleton) {
|
|
2514
|
+
const { primaryWithCoord, row, col, style, data } = info;
|
|
2526
2515
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
2527
2516
|
const _row = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo.startRow : row;
|
|
2528
2517
|
const _col = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo.startColumn : col;
|
|
@@ -2541,11 +2530,8 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2541
2530
|
};
|
|
2542
2531
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
2543
2532
|
const cellHeight = cellBounding.endY - cellBounding.startY;
|
|
2544
|
-
const map = this._ensureMap(subUnitId);
|
|
2545
|
-
const key = this._generateKey(row, col);
|
|
2546
|
-
const colorMap = validator.getListWithColorMap(rule);
|
|
2547
2533
|
const valueStr = `${(0, _univerjs_sheets_data_validation.getCellValueOrigin)(data) ?? ""}`;
|
|
2548
|
-
const activeColor =
|
|
2534
|
+
const activeColor = validator.getOptionColor(rule, valueStr);
|
|
2549
2535
|
let { tb, vt, ht, pd } = style || {};
|
|
2550
2536
|
tb = tb ?? _univerjs_core.WrapStrategy.WRAP;
|
|
2551
2537
|
vt = vt ?? _univerjs_core.VerticalAlign.BOTTOM;
|
|
@@ -2556,7 +2542,7 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2556
2542
|
var _style$cl, _style$st, _style$ul;
|
|
2557
2543
|
const { l = _univerjs_core.DEFAULT_STYLES.pd.l, t = _univerjs_core.DEFAULT_STYLES.pd.t, r = _univerjs_core.DEFAULT_STYLES.pd.r, b = _univerjs_core.DEFAULT_STYLES.pd.b } = pd;
|
|
2558
2544
|
const realWidth = cellWidth - l - r - ICON_PLACE - 4;
|
|
2559
|
-
const textSkeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, fontStyle, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), realWidth,
|
|
2545
|
+
const textSkeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, fontStyle, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), realWidth, 1e400);
|
|
2560
2546
|
textSkeleton.calculate();
|
|
2561
2547
|
const fontWidth = textSkeleton.getTotalWidth();
|
|
2562
2548
|
const fontHeight = textSkeleton.getTotalHeight();
|
|
@@ -2586,12 +2572,6 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2586
2572
|
}, textSkeleton);
|
|
2587
2573
|
ctx.restore();
|
|
2588
2574
|
ctx.restore();
|
|
2589
|
-
map.set(key, {
|
|
2590
|
-
left: cellBounding.endX - ICON_PLACE + skeleton.rowHeaderWidth,
|
|
2591
|
-
top: cellBounding.startY + t + skeleton.columnHeaderHeight,
|
|
2592
|
-
width: ICON_PLACE,
|
|
2593
|
-
height: cellHeight - t - b
|
|
2594
|
-
});
|
|
2595
2575
|
} else {
|
|
2596
2576
|
var _style$cl2, _style$st2, _style$ul2;
|
|
2597
2577
|
ctx.save();
|
|
@@ -2600,7 +2580,7 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2600
2580
|
ctx.rect(0, 0, cellWidth, cellHeight);
|
|
2601
2581
|
ctx.clip();
|
|
2602
2582
|
const realWidth = cellWidth - 12 - PADDING_H - ICON_PLACE - 4;
|
|
2603
|
-
const textSkeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, fontStyle, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), realWidth,
|
|
2583
|
+
const textSkeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, fontStyle, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), realWidth, 1e400);
|
|
2604
2584
|
textSkeleton.calculate();
|
|
2605
2585
|
const fontWidth = textSkeleton.getTotalWidth();
|
|
2606
2586
|
const fontHeight = textSkeleton.getTotalHeight();
|
|
@@ -2632,15 +2612,8 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2632
2612
|
}, textSkeleton);
|
|
2633
2613
|
ctx.restore();
|
|
2634
2614
|
ctx.translateWithPrecision(realWidth + PADDING_H + 4, (fontHeight - ICON_SIZE) / 2);
|
|
2635
|
-
ctx
|
|
2636
|
-
ctx.fill(downPath);
|
|
2615
|
+
(0, _univerjs_icons_svg.drawCanvasIcon)(ctx, "down-icon", -2, -2, 10, DROP_DOWN_ICON_COLOR);
|
|
2637
2616
|
ctx.restore();
|
|
2638
|
-
map.set(key, {
|
|
2639
|
-
left: cellBounding.startX + MARGIN_H + skeleton.rowHeaderWidth,
|
|
2640
|
-
top: cellBounding.startY + paddingTop + skeleton.columnHeaderHeight,
|
|
2641
|
-
width: rectWidth,
|
|
2642
|
-
height: rectHeight
|
|
2643
|
-
});
|
|
2644
2617
|
}
|
|
2645
2618
|
}
|
|
2646
2619
|
calcCellAutoHeight(info) {
|
|
@@ -2664,12 +2637,12 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2664
2637
|
if (rule.renderMode === _univerjs_core.DataValidationRenderMode.ARROW) {
|
|
2665
2638
|
const { l = _univerjs_core.DEFAULT_STYLES.pd.l, r = _univerjs_core.DEFAULT_STYLES.pd.r } = pd ?? {};
|
|
2666
2639
|
const realWidth = cellWidth - l - r - ICON_PLACE - 4;
|
|
2667
|
-
const skeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, (0, _univerjs_engine_render.getFontStyleString)(style).fontCache, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), realWidth,
|
|
2640
|
+
const skeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, (0, _univerjs_engine_render.getFontStyleString)(style).fontCache, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), realWidth, 1e400);
|
|
2668
2641
|
skeleton.calculate();
|
|
2669
2642
|
return skeleton.getTotalHeight() + t + b + 6;
|
|
2670
2643
|
} else {
|
|
2671
2644
|
const realWidth = Math.max(cellWidth - 12 - PADDING_H - ICON_PLACE - 4, 10);
|
|
2672
|
-
const skeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, (0, _univerjs_engine_render.getFontStyleString)(style).fontCache, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), realWidth,
|
|
2645
|
+
const skeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, (0, _univerjs_engine_render.getFontStyleString)(style).fontCache, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), realWidth, 1e400);
|
|
2673
2646
|
skeleton.calculate();
|
|
2674
2647
|
return skeleton.getTotalHeight() + 6 + 2;
|
|
2675
2648
|
}
|
|
@@ -2703,21 +2676,14 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2703
2676
|
default: paddingAll = 34 + r + l + RADIUS_BG / 2 + 1;
|
|
2704
2677
|
}
|
|
2705
2678
|
const widthForTextLayout = cellWidth - paddingAll;
|
|
2706
|
-
const skeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, (0, _univerjs_engine_render.getFontStyleString)(style).fontCache, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), widthForTextLayout,
|
|
2679
|
+
const skeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, (0, _univerjs_engine_render.getFontStyleString)(style).fontCache, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), widthForTextLayout, 1e400);
|
|
2707
2680
|
skeleton.calculate();
|
|
2708
2681
|
return skeleton.getTotalWidth() + paddingAll;
|
|
2709
2682
|
}
|
|
2710
|
-
isHit(
|
|
2711
|
-
const
|
|
2712
|
-
const dropdownInfo = this._ensureMap(subUnitId).get(this._generateKey(row, col));
|
|
2713
|
-
const rule = this._dataValidationModel.getRuleByLocation(info.unitId, info.subUnitId, row, col);
|
|
2683
|
+
isHit(_position, info) {
|
|
2684
|
+
const rule = this._dataValidationModel.getRuleByLocation(info.unitId, info.subUnitId, info.row, info.col);
|
|
2714
2685
|
if (!rule) return false;
|
|
2715
|
-
|
|
2716
|
-
if (rule.renderMode === _univerjs_core.DataValidationRenderMode.TEXT) return false;
|
|
2717
|
-
const { top, left, width, height } = dropdownInfo;
|
|
2718
|
-
const { x, y } = position;
|
|
2719
|
-
if (x >= left && x <= left + width && y >= top && y <= top + height) return true;
|
|
2720
|
-
return false;
|
|
2686
|
+
return rule.type === _univerjs_core.DataValidationType.LIST;
|
|
2721
2687
|
}
|
|
2722
2688
|
onPointerDown(info, evt) {
|
|
2723
2689
|
if (evt.button === 2) return;
|
package/lib/es/index.js
CHANGED
|
@@ -11,10 +11,11 @@ import { ActionRow, Button, Checkbox, DraggableList, Dropdown as Dropdown$1, For
|
|
|
11
11
|
import { createElement, useEffect, useMemo, useRef, useState } from "react";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { CheckboxIcon, DataValidationIcon, DatePickerIcon, DeleteIcon, DropdownListIcon, GripVerticalIcon, IncreaseIcon, MoreDownIcon, MoreUpIcon } from "@univerjs/icons";
|
|
14
|
+
import { drawCanvasIcon } from "@univerjs/icons-svg";
|
|
14
15
|
import { deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
|
|
15
16
|
import { FormulaEditor, RangeSelector } from "@univerjs/sheets-formula-ui";
|
|
16
17
|
|
|
17
|
-
// \0@oxc-project+runtime@0.
|
|
18
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
|
|
18
19
|
function _typeof(o) {
|
|
19
20
|
"@babel/helpers - typeof";
|
|
20
21
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -24,7 +25,7 @@ function _typeof(o) {
|
|
|
24
25
|
}, _typeof(o);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
// \0@oxc-project+runtime@0.
|
|
28
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
28
29
|
function toPrimitive(t, e) {
|
|
29
30
|
if ("object" != _typeof(t) || !t) return t;
|
|
30
31
|
var r;
|
|
@@ -36,13 +37,13 @@ function toPrimitive(t, e) {
|
|
|
36
37
|
return ("string" === e ? String : Number)(t);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
// \0@oxc-project+runtime@0.
|
|
40
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
|
|
40
41
|
function toPropertyKey(t) {
|
|
41
42
|
var i = toPrimitive(t, "string");
|
|
42
43
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
// \0@oxc-project+runtime@0.
|
|
46
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
|
|
46
47
|
function _defineProperty(e, r, t) {
|
|
47
48
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
48
49
|
value: t,
|
|
@@ -52,14 +53,14 @@ function _defineProperty(e, r, t) {
|
|
|
52
53
|
}) : e[r] = t, e;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
// \0@oxc-project+runtime@0.
|
|
56
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
|
|
56
57
|
function __decorateParam(paramIndex, decorator) {
|
|
57
58
|
return function(target, key) {
|
|
58
59
|
decorator(target, key, paramIndex);
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
// \0@oxc-project+runtime@0.
|
|
63
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
|
|
63
64
|
function __decorate(decorators, target, key, desc) {
|
|
64
65
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
65
66
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -509,6 +510,11 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
509
510
|
const showColor = (rule === null || rule === void 0 ? void 0 : rule.renderMode) === DataValidationRenderMode.CUSTOM || (rule === null || rule === void 0 ? void 0 : rule.renderMode) === void 0;
|
|
510
511
|
const list = validator.getListWithColor(rule, unitId, subUnitId);
|
|
511
512
|
const cellStr = getDataValidationCellValue(worksheet.getCellRaw(row, col));
|
|
513
|
+
const toOptionLabel = (value) => {
|
|
514
|
+
var _list$find;
|
|
515
|
+
return ((_list$find = list.find((item) => item.label.toLowerCase() === value.toLowerCase())) === null || _list$find === void 0 ? void 0 : _list$find.label) ?? value;
|
|
516
|
+
};
|
|
517
|
+
const defaultValue = multiple ? serializeListOptions(deserializeListOptions(cellStr).map(toOptionLabel)) : toOptionLabel(cellStr);
|
|
512
518
|
const handleEdit = () => {
|
|
513
519
|
this._commandService.executeCommand(OpenValidationPanelOperation.id, { ruleId: rule.uid });
|
|
514
520
|
popupDisposable === null || popupDisposable === void 0 || popupDisposable.dispose();
|
|
@@ -524,7 +530,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
524
530
|
color: showColor || item.color ? item.color || "gray.100" : "transparent"
|
|
525
531
|
})),
|
|
526
532
|
onEdit: handleEdit,
|
|
527
|
-
defaultValue
|
|
533
|
+
defaultValue,
|
|
528
534
|
multiple,
|
|
529
535
|
showEdit: ((_this$_configService$ = this._configService.getConfig("sheets-data-validation-ui.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.showEditOnDropdown) ?? true,
|
|
530
536
|
showSearch: ((_this$_configService$2 = this._configService.getConfig("sheets-data-validation-ui.config")) === null || _this$_configService$2 === void 0 ? void 0 : _this$_configService$2.showSearchOnDropdown) ?? true
|
|
@@ -1058,7 +1064,7 @@ const menuSchema = {
|
|
|
1058
1064
|
|
|
1059
1065
|
// package.json
|
|
1060
1066
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
1061
|
-
var version = "1.
|
|
1067
|
+
var version = "1.6.0";
|
|
1062
1068
|
|
|
1063
1069
|
// src/controllers/dv-alert.controller.ts
|
|
1064
1070
|
const ALERT_KEY = "SHEET_DATA_VALIDATION_ALERT";
|
|
@@ -2194,7 +2200,6 @@ var Dropdown = class extends Shape {
|
|
|
2194
2200
|
};
|
|
2195
2201
|
|
|
2196
2202
|
// src/views/widgets/dropdown-multiple-widget.ts
|
|
2197
|
-
const downPath$1 = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
|
|
2198
2203
|
let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
2199
2204
|
constructor(_commandService, _univerInstanceService, _renderManagerService, _dataValidationModel) {
|
|
2200
2205
|
this._commandService = _commandService;
|
|
@@ -2226,8 +2231,7 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
2226
2231
|
}
|
|
2227
2232
|
ctx.save();
|
|
2228
2233
|
ctx.translateWithPrecision(cellBounding.startX + left, cellBounding.startY + top);
|
|
2229
|
-
ctx
|
|
2230
|
-
ctx.fill(downPath$1);
|
|
2234
|
+
drawCanvasIcon(ctx, "down-icon", -2, -2, 10, DROP_DOWN_ICON_COLOR);
|
|
2231
2235
|
ctx.restore();
|
|
2232
2236
|
}
|
|
2233
2237
|
drawWith(ctx, info, skeleton, spreadsheets) {
|
|
@@ -2257,7 +2261,6 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
2257
2261
|
const vt = _vt ?? VerticalAlign.MIDDLE;
|
|
2258
2262
|
const cellValue = getCellValueOrigin(data) ?? "";
|
|
2259
2263
|
const items = validator.parseCellValue(cellValue);
|
|
2260
|
-
const labelColorMap = validator.getListWithColorMap(rule);
|
|
2261
2264
|
const layout = layoutDropdowns(items, fontStyle, cellWidth, cellHeight);
|
|
2262
2265
|
this._drawDownIcon(ctx, cellBounding, cellWidth, cellHeight, vt);
|
|
2263
2266
|
ctx.save();
|
|
@@ -2292,7 +2295,7 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
2292
2295
|
...fontStyle,
|
|
2293
2296
|
info: item,
|
|
2294
2297
|
color,
|
|
2295
|
-
fill:
|
|
2298
|
+
fill: validator.getOptionColor(rule, item.text)
|
|
2296
2299
|
});
|
|
2297
2300
|
ctx.restore();
|
|
2298
2301
|
});
|
|
@@ -2453,7 +2456,6 @@ const PADDING_V = 1;
|
|
|
2453
2456
|
const MARGIN_H = 6;
|
|
2454
2457
|
const MARGIN_V = 3;
|
|
2455
2458
|
const RADIUS_BG = 8;
|
|
2456
|
-
const downPath = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
|
|
2457
2459
|
function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margin = true) {
|
|
2458
2460
|
let paddingTop = 0;
|
|
2459
2461
|
const realMargin = margin ? MARGIN_V : 0;
|
|
@@ -2487,20 +2489,8 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2487
2489
|
this._commandService = _commandService;
|
|
2488
2490
|
this._renderManagerService = _renderManagerService;
|
|
2489
2491
|
this._dataValidationModel = _dataValidationModel;
|
|
2490
|
-
_defineProperty(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
|
|
2491
2492
|
_defineProperty(this, "zIndex", void 0);
|
|
2492
2493
|
}
|
|
2493
|
-
_ensureMap(subUnitId) {
|
|
2494
|
-
let map = this._dropdownInfoMap.get(subUnitId);
|
|
2495
|
-
if (!map) {
|
|
2496
|
-
map = /* @__PURE__ */ new Map();
|
|
2497
|
-
this._dropdownInfoMap.set(subUnitId, map);
|
|
2498
|
-
}
|
|
2499
|
-
return map;
|
|
2500
|
-
}
|
|
2501
|
-
_generateKey(row, col) {
|
|
2502
|
-
return `${row}.${col}`;
|
|
2503
|
-
}
|
|
2504
2494
|
_drawDownIcon(ctx, cellBounding, cellWidth, cellHeight, fontHeight, vt, pd) {
|
|
2505
2495
|
const { t = DEFAULT_STYLES.pd.t, b = DEFAULT_STYLES.pd.b } = pd;
|
|
2506
2496
|
const left = cellWidth - ICON_PLACE;
|
|
@@ -2516,12 +2506,11 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2516
2506
|
}
|
|
2517
2507
|
ctx.save();
|
|
2518
2508
|
ctx.translateWithPrecision(cellBounding.startX + left, cellBounding.startY + top);
|
|
2519
|
-
ctx
|
|
2520
|
-
ctx.fill(downPath);
|
|
2509
|
+
drawCanvasIcon(ctx, "down-icon", -2, -2, 10, DROP_DOWN_ICON_COLOR);
|
|
2521
2510
|
ctx.restore();
|
|
2522
2511
|
}
|
|
2523
|
-
drawWith(ctx, info,
|
|
2524
|
-
const { primaryWithCoord, row, col, style, data
|
|
2512
|
+
drawWith(ctx, info, _skeleton) {
|
|
2513
|
+
const { primaryWithCoord, row, col, style, data } = info;
|
|
2525
2514
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
2526
2515
|
const _row = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo.startRow : row;
|
|
2527
2516
|
const _col = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo.startColumn : col;
|
|
@@ -2540,11 +2529,8 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2540
2529
|
};
|
|
2541
2530
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
2542
2531
|
const cellHeight = cellBounding.endY - cellBounding.startY;
|
|
2543
|
-
const map = this._ensureMap(subUnitId);
|
|
2544
|
-
const key = this._generateKey(row, col);
|
|
2545
|
-
const colorMap = validator.getListWithColorMap(rule);
|
|
2546
2532
|
const valueStr = `${getCellValueOrigin(data) ?? ""}`;
|
|
2547
|
-
const activeColor =
|
|
2533
|
+
const activeColor = validator.getOptionColor(rule, valueStr);
|
|
2548
2534
|
let { tb, vt, ht, pd } = style || {};
|
|
2549
2535
|
tb = tb ?? WrapStrategy.WRAP;
|
|
2550
2536
|
vt = vt ?? VerticalAlign.BOTTOM;
|
|
@@ -2555,7 +2541,7 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2555
2541
|
var _style$cl, _style$st, _style$ul;
|
|
2556
2542
|
const { l = DEFAULT_STYLES.pd.l, t = DEFAULT_STYLES.pd.t, r = DEFAULT_STYLES.pd.r, b = DEFAULT_STYLES.pd.b } = pd;
|
|
2557
2543
|
const realWidth = cellWidth - l - r - ICON_PLACE - 4;
|
|
2558
|
-
const textSkeleton = new DocSimpleSkeleton(valueStr, fontStyle, Boolean(tb === WrapStrategy.WRAP), realWidth,
|
|
2544
|
+
const textSkeleton = new DocSimpleSkeleton(valueStr, fontStyle, Boolean(tb === WrapStrategy.WRAP), realWidth, 1e400);
|
|
2559
2545
|
textSkeleton.calculate();
|
|
2560
2546
|
const fontWidth = textSkeleton.getTotalWidth();
|
|
2561
2547
|
const fontHeight = textSkeleton.getTotalHeight();
|
|
@@ -2585,12 +2571,6 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2585
2571
|
}, textSkeleton);
|
|
2586
2572
|
ctx.restore();
|
|
2587
2573
|
ctx.restore();
|
|
2588
|
-
map.set(key, {
|
|
2589
|
-
left: cellBounding.endX - ICON_PLACE + skeleton.rowHeaderWidth,
|
|
2590
|
-
top: cellBounding.startY + t + skeleton.columnHeaderHeight,
|
|
2591
|
-
width: ICON_PLACE,
|
|
2592
|
-
height: cellHeight - t - b
|
|
2593
|
-
});
|
|
2594
2574
|
} else {
|
|
2595
2575
|
var _style$cl2, _style$st2, _style$ul2;
|
|
2596
2576
|
ctx.save();
|
|
@@ -2599,7 +2579,7 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2599
2579
|
ctx.rect(0, 0, cellWidth, cellHeight);
|
|
2600
2580
|
ctx.clip();
|
|
2601
2581
|
const realWidth = cellWidth - 12 - PADDING_H - ICON_PLACE - 4;
|
|
2602
|
-
const textSkeleton = new DocSimpleSkeleton(valueStr, fontStyle, Boolean(tb === WrapStrategy.WRAP), realWidth,
|
|
2582
|
+
const textSkeleton = new DocSimpleSkeleton(valueStr, fontStyle, Boolean(tb === WrapStrategy.WRAP), realWidth, 1e400);
|
|
2603
2583
|
textSkeleton.calculate();
|
|
2604
2584
|
const fontWidth = textSkeleton.getTotalWidth();
|
|
2605
2585
|
const fontHeight = textSkeleton.getTotalHeight();
|
|
@@ -2631,15 +2611,8 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2631
2611
|
}, textSkeleton);
|
|
2632
2612
|
ctx.restore();
|
|
2633
2613
|
ctx.translateWithPrecision(realWidth + PADDING_H + 4, (fontHeight - ICON_SIZE) / 2);
|
|
2634
|
-
ctx
|
|
2635
|
-
ctx.fill(downPath);
|
|
2614
|
+
drawCanvasIcon(ctx, "down-icon", -2, -2, 10, DROP_DOWN_ICON_COLOR);
|
|
2636
2615
|
ctx.restore();
|
|
2637
|
-
map.set(key, {
|
|
2638
|
-
left: cellBounding.startX + MARGIN_H + skeleton.rowHeaderWidth,
|
|
2639
|
-
top: cellBounding.startY + paddingTop + skeleton.columnHeaderHeight,
|
|
2640
|
-
width: rectWidth,
|
|
2641
|
-
height: rectHeight
|
|
2642
|
-
});
|
|
2643
2616
|
}
|
|
2644
2617
|
}
|
|
2645
2618
|
calcCellAutoHeight(info) {
|
|
@@ -2663,12 +2636,12 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2663
2636
|
if (rule.renderMode === DataValidationRenderMode.ARROW) {
|
|
2664
2637
|
const { l = DEFAULT_STYLES.pd.l, r = DEFAULT_STYLES.pd.r } = pd ?? {};
|
|
2665
2638
|
const realWidth = cellWidth - l - r - ICON_PLACE - 4;
|
|
2666
|
-
const skeleton = new DocSimpleSkeleton(valueStr, getFontStyleString(style).fontCache, Boolean(tb === WrapStrategy.WRAP), realWidth,
|
|
2639
|
+
const skeleton = new DocSimpleSkeleton(valueStr, getFontStyleString(style).fontCache, Boolean(tb === WrapStrategy.WRAP), realWidth, 1e400);
|
|
2667
2640
|
skeleton.calculate();
|
|
2668
2641
|
return skeleton.getTotalHeight() + t + b + 6;
|
|
2669
2642
|
} else {
|
|
2670
2643
|
const realWidth = Math.max(cellWidth - 12 - PADDING_H - ICON_PLACE - 4, 10);
|
|
2671
|
-
const skeleton = new DocSimpleSkeleton(valueStr, getFontStyleString(style).fontCache, Boolean(tb === WrapStrategy.WRAP), realWidth,
|
|
2644
|
+
const skeleton = new DocSimpleSkeleton(valueStr, getFontStyleString(style).fontCache, Boolean(tb === WrapStrategy.WRAP), realWidth, 1e400);
|
|
2672
2645
|
skeleton.calculate();
|
|
2673
2646
|
return skeleton.getTotalHeight() + 6 + 2;
|
|
2674
2647
|
}
|
|
@@ -2702,21 +2675,14 @@ let DropdownWidget = class DropdownWidget {
|
|
|
2702
2675
|
default: paddingAll = 34 + r + l + RADIUS_BG / 2 + 1;
|
|
2703
2676
|
}
|
|
2704
2677
|
const widthForTextLayout = cellWidth - paddingAll;
|
|
2705
|
-
const skeleton = new DocSimpleSkeleton(valueStr, getFontStyleString(style).fontCache, Boolean(tb === WrapStrategy.WRAP), widthForTextLayout,
|
|
2678
|
+
const skeleton = new DocSimpleSkeleton(valueStr, getFontStyleString(style).fontCache, Boolean(tb === WrapStrategy.WRAP), widthForTextLayout, 1e400);
|
|
2706
2679
|
skeleton.calculate();
|
|
2707
2680
|
return skeleton.getTotalWidth() + paddingAll;
|
|
2708
2681
|
}
|
|
2709
|
-
isHit(
|
|
2710
|
-
const
|
|
2711
|
-
const dropdownInfo = this._ensureMap(subUnitId).get(this._generateKey(row, col));
|
|
2712
|
-
const rule = this._dataValidationModel.getRuleByLocation(info.unitId, info.subUnitId, row, col);
|
|
2682
|
+
isHit(_position, info) {
|
|
2683
|
+
const rule = this._dataValidationModel.getRuleByLocation(info.unitId, info.subUnitId, info.row, info.col);
|
|
2713
2684
|
if (!rule) return false;
|
|
2714
|
-
|
|
2715
|
-
if (rule.renderMode === DataValidationRenderMode.TEXT) return false;
|
|
2716
|
-
const { top, left, width, height } = dropdownInfo;
|
|
2717
|
-
const { x, y } = position;
|
|
2718
|
-
if (x >= left && x <= left + width && y >= top && y <= top + height) return true;
|
|
2719
|
-
return false;
|
|
2685
|
+
return rule.type === DataValidationType.LIST;
|
|
2720
2686
|
}
|
|
2721
2687
|
onPointerDown(info, evt) {
|
|
2722
2688
|
if (evt.button === 2) return;
|