@univerjs/sheets-data-validation-ui 1.0.0-alpha.7 → 1.0.0-beta.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 +113 -139
- package/lib/es/index.js +118 -144
- package/lib/index.js +118 -144
- package/lib/umd/index.js +1 -1
- package/package.json +17 -18
package/lib/cjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ let _univerjs_icons = require("@univerjs/icons");
|
|
|
15
15
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
16
16
|
let _univerjs_sheets_formula_ui = require("@univerjs/sheets-formula-ui");
|
|
17
17
|
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
19
19
|
function _typeof(o) {
|
|
20
20
|
"@babel/helpers - typeof";
|
|
21
21
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -26,7 +26,7 @@ function _typeof(o) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
|
-
//#region \0@oxc-project+runtime@0.
|
|
29
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
30
30
|
function toPrimitive(t, r) {
|
|
31
31
|
if ("object" != _typeof(t) || !t) return t;
|
|
32
32
|
var e = t[Symbol.toPrimitive];
|
|
@@ -39,14 +39,14 @@ function toPrimitive(t, r) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
//#endregion
|
|
42
|
-
//#region \0@oxc-project+runtime@0.
|
|
42
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
43
43
|
function toPropertyKey(t) {
|
|
44
44
|
var i = toPrimitive(t, "string");
|
|
45
45
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
50
50
|
function _defineProperty(e, r, t) {
|
|
51
51
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
52
52
|
value: t,
|
|
@@ -57,7 +57,7 @@ function _defineProperty(e, r, t) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
61
61
|
function __decorateParam(paramIndex, decorator) {
|
|
62
62
|
return function(target, key) {
|
|
63
63
|
decorator(target, key, paramIndex);
|
|
@@ -65,7 +65,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
//#endregion
|
|
68
|
-
//#region \0@oxc-project+runtime@0.
|
|
68
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
69
69
|
function __decorate(decorators, target, key, desc) {
|
|
70
70
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
71
71
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -303,7 +303,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
303
303
|
if (!(validator === null || validator === void 0 ? void 0 : validator.dropdownType)) return;
|
|
304
304
|
let popupDisposable;
|
|
305
305
|
const handleSave = async (date, targetPatternType) => {
|
|
306
|
-
var _numfmt$parseDate, _cellStyle$n
|
|
306
|
+
var _numfmt$parseDate, _cellStyle$n;
|
|
307
307
|
if (!date) return true;
|
|
308
308
|
const newValue = date;
|
|
309
309
|
const cellData = worksheet.getCell(row, col);
|
|
@@ -311,7 +311,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
311
311
|
const serialNum = (_numfmt$parseDate = _univerjs_core.numfmt.parseDate(dateStr)) === null || _numfmt$parseDate === void 0 ? void 0 : _numfmt$parseDate.v;
|
|
312
312
|
const serialTime = targetPatternType === "time" ? serialNum % 1 : serialNum;
|
|
313
313
|
const cellStyle = workbook.getStyles().getStyleByCell(cellData);
|
|
314
|
-
const format = (
|
|
314
|
+
const format = (cellStyle === null || cellStyle === void 0 || (_cellStyle$n = cellStyle.n) === null || _cellStyle$n === void 0 ? void 0 : _cellStyle$n.pattern) ?? "";
|
|
315
315
|
if (rule.errorStyle !== _univerjs_core.DataValidationErrorStyle.STOP || await validator.validator({
|
|
316
316
|
value: serialTime,
|
|
317
317
|
unitId,
|
|
@@ -362,7 +362,8 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
362
362
|
switch (validator.dropdownType) {
|
|
363
363
|
case _univerjs_data_validation.DataValidatorDropdownType.DATE: {
|
|
364
364
|
var _rule$bizInfo;
|
|
365
|
-
const
|
|
365
|
+
const cellStr = (0, _univerjs_sheets_data_validation.getCellValueOrigin)(worksheet.getCellRaw(row, col));
|
|
366
|
+
const originDate = transformDate(cellStr);
|
|
366
367
|
const showTime = Boolean((_rule$bizInfo = rule.bizInfo) === null || _rule$bizInfo === void 0 ? void 0 : _rule$bizInfo.showTime);
|
|
367
368
|
dropdownParam = {
|
|
368
369
|
location,
|
|
@@ -376,35 +377,38 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
376
377
|
};
|
|
377
378
|
break;
|
|
378
379
|
}
|
|
379
|
-
case _univerjs_data_validation.DataValidatorDropdownType.TIME:
|
|
380
|
+
case _univerjs_data_validation.DataValidatorDropdownType.TIME: {
|
|
381
|
+
const cellStr = (0, _univerjs_sheets_data_validation.getCellValueOrigin)(worksheet.getCellRaw(row, col));
|
|
380
382
|
dropdownParam = {
|
|
381
383
|
location,
|
|
382
384
|
type: "datepicker",
|
|
383
385
|
props: {
|
|
384
386
|
onChange: (newValue) => handleSave(newValue, "time"),
|
|
385
|
-
defaultValue: transformDate(
|
|
387
|
+
defaultValue: transformDate(cellStr),
|
|
386
388
|
patternType: "time"
|
|
387
389
|
}
|
|
388
390
|
};
|
|
389
391
|
break;
|
|
390
|
-
|
|
392
|
+
}
|
|
393
|
+
case _univerjs_data_validation.DataValidatorDropdownType.DATETIME: {
|
|
394
|
+
const cellStr = (0, _univerjs_sheets_data_validation.getCellValueOrigin)(worksheet.getCellRaw(row, col));
|
|
391
395
|
dropdownParam = {
|
|
392
396
|
location,
|
|
393
397
|
type: "datepicker",
|
|
394
398
|
props: {
|
|
395
399
|
onChange: (newValue) => handleSave(newValue, "datetime"),
|
|
396
|
-
defaultValue: transformDate(
|
|
400
|
+
defaultValue: transformDate(cellStr),
|
|
397
401
|
patternType: "datetime"
|
|
398
402
|
}
|
|
399
403
|
};
|
|
400
404
|
break;
|
|
405
|
+
}
|
|
401
406
|
case _univerjs_data_validation.DataValidatorDropdownType.LIST:
|
|
402
407
|
case _univerjs_data_validation.DataValidatorDropdownType.MULTIPLE_LIST: {
|
|
403
|
-
var _this$_configService$, _this$_configService$2
|
|
408
|
+
var _this$_configService$, _this$_configService$2;
|
|
404
409
|
const multiple = validator.dropdownType === _univerjs_data_validation.DataValidatorDropdownType.MULTIPLE_LIST;
|
|
405
410
|
const handleSave = async (newValue) => {
|
|
406
|
-
|
|
407
|
-
const str = multiple ? (0, _univerjs_sheets.serializeListOptions)(newValue) : (_newValue$ = newValue[0]) !== null && _newValue$ !== void 0 ? _newValue$ : "";
|
|
411
|
+
const str = multiple ? (0, _univerjs_sheets.serializeListOptions)(newValue) : newValue[0] ?? "";
|
|
408
412
|
const params = {
|
|
409
413
|
unitId,
|
|
410
414
|
subUnitId,
|
|
@@ -451,14 +455,13 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
451
455
|
onEdit: handleEdit,
|
|
452
456
|
defaultValue: cellStr,
|
|
453
457
|
multiple,
|
|
454
|
-
showEdit: (
|
|
455
|
-
showSearch: (
|
|
458
|
+
showEdit: ((_this$_configService$ = this._configService.getConfig("sheets-data-validation-ui.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.showEditOnDropdown) ?? true,
|
|
459
|
+
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
|
|
456
460
|
}
|
|
457
461
|
};
|
|
458
462
|
break;
|
|
459
463
|
}
|
|
460
464
|
case _univerjs_data_validation.DataValidatorDropdownType.CASCADE: {
|
|
461
|
-
var _rule$formula;
|
|
462
465
|
const handleSave = (newValue) => {
|
|
463
466
|
const params = {
|
|
464
467
|
unitId,
|
|
@@ -490,7 +493,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
490
493
|
props: {
|
|
491
494
|
onChange: handleSave,
|
|
492
495
|
defaultValue: (0, _univerjs_sheets_data_validation.getDataValidationCellValue)(worksheet.getCellRaw(row, col)).split("/"),
|
|
493
|
-
options: JSON.parse(
|
|
496
|
+
options: JSON.parse(rule.formula1 ?? "[]")
|
|
494
497
|
},
|
|
495
498
|
location
|
|
496
499
|
};
|
|
@@ -987,12 +990,11 @@ const menuSchema = {
|
|
|
987
990
|
//#endregion
|
|
988
991
|
//#region package.json
|
|
989
992
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
990
|
-
var version = "1.0.0-
|
|
993
|
+
var version = "1.0.0-beta.0";
|
|
991
994
|
|
|
992
995
|
//#endregion
|
|
993
996
|
//#region src/views/components/DataValidationOptions.tsx
|
|
994
997
|
function DataValidationOptions(props) {
|
|
995
|
-
var _value$errorStyle;
|
|
996
998
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
997
999
|
const componentManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.ComponentManager);
|
|
998
1000
|
const { value, onChange, extraComponent } = props;
|
|
@@ -1010,7 +1012,7 @@ function DataValidationOptions(props) {
|
|
|
1010
1012
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
|
|
1011
1013
|
label: localeService.t("sheets-data-validation-ui.panel.invalid"),
|
|
1012
1014
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.RadioGroup, {
|
|
1013
|
-
value: `${
|
|
1015
|
+
value: `${value.errorStyle ?? _univerjs_core.DataValidationErrorStyle.WARNING}`,
|
|
1014
1016
|
onChange: (errorStyle) => onChange({
|
|
1015
1017
|
...value,
|
|
1016
1018
|
errorStyle: +errorStyle
|
|
@@ -1070,7 +1072,7 @@ function DataValidationDetail() {
|
|
|
1070
1072
|
} });
|
|
1071
1073
|
}
|
|
1072
1074
|
function DataValidationDetailInner(props) {
|
|
1073
|
-
var _validators$sort
|
|
1075
|
+
var _validators$sort;
|
|
1074
1076
|
const [key, setKey] = (0, react.useState)(0);
|
|
1075
1077
|
const dataValidationPanelService = (0, _univerjs_ui.useDependency)(DataValidationPanelService);
|
|
1076
1078
|
const { unitId, subUnitId, rule } = props.activeRuleInfo;
|
|
@@ -1082,10 +1084,7 @@ function DataValidationDetailInner(props) {
|
|
|
1082
1084
|
const dataValidationModel = (0, _univerjs_ui.useDependency)(_univerjs_data_validation.DataValidationModel);
|
|
1083
1085
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1084
1086
|
const workbook = (0, _univerjs_ui.useObservable)(() => univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET), void 0, void 0, []);
|
|
1085
|
-
const worksheet = (0, _univerjs_ui.useObservable)(() =>
|
|
1086
|
-
var _workbook$activeSheet;
|
|
1087
|
-
return (_workbook$activeSheet = workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) !== null && _workbook$activeSheet !== void 0 ? _workbook$activeSheet : (0, rxjs.of)(null);
|
|
1088
|
-
}, void 0, void 0, []);
|
|
1087
|
+
const worksheet = (0, _univerjs_ui.useObservable)(() => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? (0, rxjs.of)(null), void 0, void 0, []);
|
|
1089
1088
|
const [localRule, setLocalRule] = (0, react.useState)(rule);
|
|
1090
1089
|
const validator = validatorService.getValidatorItem(localRule.type);
|
|
1091
1090
|
const [showError, setShowError] = (0, react.useState)(false);
|
|
@@ -1333,14 +1332,11 @@ function DataValidationDetailInner(props) {
|
|
|
1333
1332
|
ruleId
|
|
1334
1333
|
}, key + localRule.type) : null,
|
|
1335
1334
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
1336
|
-
checked:
|
|
1337
|
-
onChange: () => {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
allowBlank: !((_localRule$allowBlank2 = localRule.allowBlank) !== null && _localRule$allowBlank2 !== void 0 ? _localRule$allowBlank2 : true)
|
|
1342
|
-
});
|
|
1343
|
-
},
|
|
1335
|
+
checked: localRule.allowBlank ?? true,
|
|
1336
|
+
onChange: () => handleUpdateRuleSetting({
|
|
1337
|
+
...baseRule,
|
|
1338
|
+
allowBlank: !(localRule.allowBlank ?? true)
|
|
1339
|
+
}),
|
|
1344
1340
|
children: localeService.t("sheets-data-validation-ui.panel.allowBlank")
|
|
1345
1341
|
}) }),
|
|
1346
1342
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataValidationOptions, {
|
|
@@ -1377,10 +1373,9 @@ const DataValidationItem = (props) => {
|
|
|
1377
1373
|
const [isHover, setIsHover] = (0, react.useState)(false);
|
|
1378
1374
|
const themeService = (0, _univerjs_ui.useDependency)(_univerjs_core.ThemeService);
|
|
1379
1375
|
const style = (0, react.useMemo)(() => {
|
|
1380
|
-
var _themeService$getColo;
|
|
1381
1376
|
const defaultColor = themeService.getColorFromTheme("primary.600");
|
|
1382
1377
|
const key = themeService.getColorFromTheme("loop-color.2");
|
|
1383
|
-
const color =
|
|
1378
|
+
const color = themeService.getColorFromTheme(key) ?? defaultColor;
|
|
1384
1379
|
const rgb = new _univerjs_core.ColorKit(color).toRgb();
|
|
1385
1380
|
return {
|
|
1386
1381
|
fill: `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 0.1)`,
|
|
@@ -1501,23 +1496,20 @@ function DataValidationList(props) {
|
|
|
1501
1496
|
const hasDisableRule = rulesByPermissionCheck === null || rulesByPermissionCheck === void 0 ? void 0 : rulesByPermissionCheck.some((rule) => rule.disable);
|
|
1502
1497
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1503
1498
|
className: "univer-pb-4",
|
|
1504
|
-
children: [rulesByPermissionCheck === null || rulesByPermissionCheck === void 0 ? void 0 : rulesByPermissionCheck.map((rule) => {
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
disable: (_rule$disable = rule.disable) !== null && _rule$disable !== void 0 ? _rule$disable : false
|
|
1519
|
-
}, rule.uid);
|
|
1520
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1499
|
+
children: [rulesByPermissionCheck === null || rulesByPermissionCheck === void 0 ? void 0 : rulesByPermissionCheck.map((rule) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataValidationItem, {
|
|
1500
|
+
unitId,
|
|
1501
|
+
subUnitId,
|
|
1502
|
+
onClick: () => {
|
|
1503
|
+
if (rule.disable) return;
|
|
1504
|
+
dataValidationPanelService.setActiveRule({
|
|
1505
|
+
unitId,
|
|
1506
|
+
subUnitId,
|
|
1507
|
+
rule
|
|
1508
|
+
});
|
|
1509
|
+
},
|
|
1510
|
+
rule,
|
|
1511
|
+
disable: rule.disable ?? false
|
|
1512
|
+
}, rule.uid)), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1521
1513
|
className: "univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",
|
|
1522
1514
|
children: [rules.length && !hasDisableRule ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1523
1515
|
onClick: handleRemoveAll,
|
|
@@ -1538,10 +1530,7 @@ const DataValidationPanel = () => {
|
|
|
1538
1530
|
const activeRule = (0, _univerjs_ui.useObservable)(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule);
|
|
1539
1531
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
1540
1532
|
const workbook = (0, _univerjs_ui.useObservable)(() => univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET), void 0, void 0, []);
|
|
1541
|
-
const worksheet = (0, _univerjs_ui.useObservable)(() =>
|
|
1542
|
-
var _workbook$activeSheet;
|
|
1543
|
-
return (_workbook$activeSheet = workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) !== null && _workbook$activeSheet !== void 0 ? _workbook$activeSheet : (0, rxjs.of)(null);
|
|
1544
|
-
}, void 0, void 0, []);
|
|
1533
|
+
const worksheet = (0, _univerjs_ui.useObservable)(() => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? (0, rxjs.of)(null), void 0, void 0, []);
|
|
1545
1534
|
if (!workbook || !worksheet) return null;
|
|
1546
1535
|
return activeRule && (activeRule.subUnitId === worksheet.getSheetId() || activeRule.subUnitId === dataValidationPanelService.getFocusFormulaEditorActiveRuleSubUnitId()) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataValidationDetail, {}, activeRule.rule.uid) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataValidationList, { workbook });
|
|
1547
1536
|
};
|
|
@@ -1683,27 +1672,26 @@ function CheckboxFormulaInput(props) {
|
|
|
1683
1672
|
//#endregion
|
|
1684
1673
|
//#region src/views/components/formula-input/CustomFormulaInput.tsx
|
|
1685
1674
|
function CustomFormulaInput(props) {
|
|
1686
|
-
var _value$formula;
|
|
1687
1675
|
const { unitId, subUnitId, value, onChange, showError, validResult } = props;
|
|
1688
1676
|
const formula1Res = showError ? validResult === null || validResult === void 0 ? void 0 : validResult.formula1 : void 0;
|
|
1689
1677
|
const formulaEditorRef = (0, react.useRef)(null);
|
|
1690
1678
|
const [isFocusFormulaEditor, setIsFocusFormulaEditor] = (0, react.useState)(false);
|
|
1691
1679
|
(0, _univerjs_ui.useSidebarClick)((e) => {
|
|
1692
1680
|
var _formulaEditorRef$cur;
|
|
1693
|
-
|
|
1681
|
+
(_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
|
|
1694
1682
|
});
|
|
1695
1683
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
|
|
1696
1684
|
error: formula1Res,
|
|
1697
1685
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_sheets_formula_ui.FormulaEditor, {
|
|
1698
1686
|
ref: formulaEditorRef,
|
|
1699
1687
|
className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", _univerjs_design.borderClassName),
|
|
1700
|
-
initValue: (
|
|
1688
|
+
initValue: (value === null || value === void 0 ? void 0 : value.formula1) ?? "=",
|
|
1701
1689
|
unitId,
|
|
1702
1690
|
subUnitId,
|
|
1703
1691
|
isFocus: isFocusFormulaEditor,
|
|
1704
1692
|
isSupportAcrossSheet: true,
|
|
1705
1693
|
onChange: (newValue) => {
|
|
1706
|
-
const newFormula = (newValue
|
|
1694
|
+
const newFormula = (newValue ?? "").trim();
|
|
1707
1695
|
if (newFormula === (value === null || value === void 0 ? void 0 : value.formula1)) return;
|
|
1708
1696
|
onChange === null || onChange === void 0 || onChange({
|
|
1709
1697
|
...value,
|
|
@@ -1959,7 +1947,7 @@ function ListFormulaInput(props) {
|
|
|
1959
1947
|
const [isFocusFormulaEditor, setIsFocusFormulaEditor] = (0, react.useState)(false);
|
|
1960
1948
|
(0, _univerjs_ui.useSidebarClick)((e) => {
|
|
1961
1949
|
var _formulaEditorRef$cur;
|
|
1962
|
-
|
|
1950
|
+
(_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
|
|
1963
1951
|
});
|
|
1964
1952
|
(0, react.useEffect)(() => {
|
|
1965
1953
|
if (isFocusFormulaEditor) dataValidationPanelService.setFocusFormulaEditorActiveRuleSubUnitId(subUnitId);
|
|
@@ -2001,7 +1989,7 @@ function ListFormulaInput(props) {
|
|
|
2001
1989
|
isSupportAcrossSheet: true,
|
|
2002
1990
|
onFocus: () => setIsFocusFormulaEditor(true),
|
|
2003
1991
|
onChange: (v = "") => {
|
|
2004
|
-
const str = (v
|
|
1992
|
+
const str = (v ?? "").trim();
|
|
2005
1993
|
setFormulaStrCopy(str);
|
|
2006
1994
|
updateFormula(str);
|
|
2007
1995
|
}
|
|
@@ -2052,13 +2040,12 @@ const FORMULA_INPUTS = [
|
|
|
2052
2040
|
//#region src/views/components/ListRenderModeInput.tsx
|
|
2053
2041
|
const LIST_RENDER_MODE_OPTION_INPUT = "LIST_RENDER_MODE_OPTION_INPUT";
|
|
2054
2042
|
function ListRenderModeInput(props) {
|
|
2055
|
-
var _value$renderMode;
|
|
2056
2043
|
const { value, onChange } = props;
|
|
2057
2044
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
2058
2045
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
|
|
2059
2046
|
label: localeService.t("sheets-data-validation-ui.renderMode.label"),
|
|
2060
2047
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.RadioGroup, {
|
|
2061
|
-
value: `${
|
|
2048
|
+
value: `${value.renderMode ?? _univerjs_core.DataValidationRenderMode.CUSTOM}`,
|
|
2062
2049
|
onChange: (renderMode) => onChange({
|
|
2063
2050
|
...value,
|
|
2064
2051
|
renderMode: +renderMode
|
|
@@ -2344,7 +2331,7 @@ let DataValidationCopyPasteController = class DataValidationCopyPasteController
|
|
|
2344
2331
|
rows.forEach((row, rowIndex) => {
|
|
2345
2332
|
cols.forEach((col, colIndex) => {
|
|
2346
2333
|
const ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
2347
|
-
matrix.setValue(rowIndex, colIndex, ruleId
|
|
2334
|
+
matrix.setValue(rowIndex, colIndex, ruleId ?? "");
|
|
2348
2335
|
});
|
|
2349
2336
|
});
|
|
2350
2337
|
}
|
|
@@ -2535,7 +2522,7 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
2535
2522
|
const state = this._editorBridgeService.getEditCellState();
|
|
2536
2523
|
if (state) {
|
|
2537
2524
|
const { unitId, sheetId, row, column } = state;
|
|
2538
|
-
const workbook = this._univerInstanceService.
|
|
2525
|
+
const workbook = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
2539
2526
|
if (!workbook) return;
|
|
2540
2527
|
const rule = this._sheetDataValidationModel.getRuleByLocation(unitId, sheetId, row, column);
|
|
2541
2528
|
if (!rule) return;
|
|
@@ -2566,32 +2553,30 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
2566
2553
|
effect: _univerjs_core.InterceptorEffectEnum.Style,
|
|
2567
2554
|
priority: _univerjs_sheets.InterceptCellContentPriority.DATA_VALIDATION,
|
|
2568
2555
|
handler: (cell, pos, next) => {
|
|
2569
|
-
var
|
|
2556
|
+
var _cell$fontRenderExten, _validator$skipDefaul;
|
|
2570
2557
|
const { row, col, unitId, subUnitId, workbook, worksheet } = pos;
|
|
2571
2558
|
const ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
2572
2559
|
if (!ruleId) return next(cell);
|
|
2573
2560
|
const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
2574
2561
|
if (!rule) return next(cell);
|
|
2575
|
-
const validStatus =
|
|
2562
|
+
const validStatus = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col) ?? _univerjs_core.DataValidationStatus.VALID;
|
|
2576
2563
|
const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
|
|
2577
2564
|
const cellOrigin = pos.rawData;
|
|
2578
2565
|
let cache;
|
|
2579
2566
|
const cellValue = { get value() {
|
|
2580
|
-
var _getCellValueOrigin;
|
|
2581
2567
|
if (cache !== void 0) return cache;
|
|
2582
|
-
cache = (
|
|
2568
|
+
cache = (0, _univerjs_sheets_data_validation.getCellValueOrigin)(cellOrigin) ?? null;
|
|
2583
2569
|
return cache;
|
|
2584
2570
|
} };
|
|
2585
2571
|
const valueStr = { get value() {
|
|
2586
|
-
|
|
2587
|
-
return `${(_cellValue$value = cellValue.value) !== null && _cellValue$value !== void 0 ? _cellValue$value : ""}`;
|
|
2572
|
+
return `${cellValue.value ?? ""}`;
|
|
2588
2573
|
} };
|
|
2589
2574
|
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
2590
2575
|
cell.markers = {
|
|
2591
2576
|
...cell === null || cell === void 0 ? void 0 : cell.markers,
|
|
2592
2577
|
...validStatus === _univerjs_core.DataValidationStatus.INVALID ? INVALID_MARK : null
|
|
2593
2578
|
};
|
|
2594
|
-
cell.customRender = [...(
|
|
2579
|
+
cell.customRender = [...(cell === null || cell === void 0 ? void 0 : cell.customRender) ?? [], ...(validator === null || validator === void 0 ? void 0 : validator.canvasRender) ? [validator.canvasRender] : []];
|
|
2595
2580
|
cell.fontRenderExtension = {
|
|
2596
2581
|
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
2597
2582
|
isSkip: (cell === null || cell === void 0 || (_cell$fontRenderExten = cell.fontRenderExtension) === null || _cell$fontRenderExten === void 0 ? void 0 : _cell$fontRenderExten.isSkip) || (validator === null || validator === void 0 || (_validator$skipDefaul = validator.skipDefaultFontRender) === null || _validator$skipDefaul === void 0 ? void 0 : _validator$skipDefaul.call(validator, rule, cellValue.value, pos))
|
|
@@ -2604,14 +2589,14 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
2604
2589
|
} }, row, col)
|
|
2605
2590
|
};
|
|
2606
2591
|
cell.interceptorAutoHeight = () => {
|
|
2607
|
-
var _this$_renderManagerS,
|
|
2608
|
-
const skeleton = (_this$_renderManagerS = this._renderManagerService.
|
|
2592
|
+
var _this$_renderManagerS, _validator$canvasRend, _validator$canvasRend2;
|
|
2593
|
+
const skeleton = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 || (_this$_renderManagerS = _this$_renderManagerS.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.skeleton;
|
|
2609
2594
|
if (!skeleton) return;
|
|
2610
2595
|
const mergeCell = skeleton.worksheet.getMergedCell(row, col);
|
|
2611
2596
|
const info = {
|
|
2612
2597
|
data: cell,
|
|
2613
|
-
style:
|
|
2614
|
-
primaryWithCoord: skeleton.getCellWithCoordByIndex((
|
|
2598
|
+
style: workbook.getStyles().getStyleByCell(cell),
|
|
2599
|
+
primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
|
|
2615
2600
|
unitId,
|
|
2616
2601
|
subUnitId,
|
|
2617
2602
|
row,
|
|
@@ -2622,14 +2607,14 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
2622
2607
|
return validator === null || validator === void 0 || (_validator$canvasRend = validator.canvasRender) === null || _validator$canvasRend === void 0 || (_validator$canvasRend2 = _validator$canvasRend.calcCellAutoHeight) === null || _validator$canvasRend2 === void 0 ? void 0 : _validator$canvasRend2.call(_validator$canvasRend, info);
|
|
2623
2608
|
};
|
|
2624
2609
|
cell.interceptorAutoWidth = () => {
|
|
2625
|
-
var _this$_renderManagerS2,
|
|
2626
|
-
const skeleton = (_this$_renderManagerS2 = this._renderManagerService.
|
|
2610
|
+
var _this$_renderManagerS2, _validator$canvasRend3, _validator$canvasRend4;
|
|
2611
|
+
const skeleton = (_this$_renderManagerS2 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS2 === void 0 || (_this$_renderManagerS2 = _this$_renderManagerS2.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.skeleton;
|
|
2627
2612
|
if (!skeleton) return;
|
|
2628
2613
|
const mergeCell = skeleton.worksheet.getMergedCell(row, col);
|
|
2629
2614
|
const info = {
|
|
2630
2615
|
data: cell,
|
|
2631
|
-
style:
|
|
2632
|
-
primaryWithCoord: skeleton.getCellWithCoordByIndex((
|
|
2616
|
+
style: workbook.getStyles().getStyleByCell(cell),
|
|
2617
|
+
primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
|
|
2633
2618
|
unitId,
|
|
2634
2619
|
subUnitId,
|
|
2635
2620
|
row,
|
|
@@ -2639,7 +2624,7 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
2639
2624
|
};
|
|
2640
2625
|
return validator === null || validator === void 0 || (_validator$canvasRend3 = validator.canvasRender) === null || _validator$canvasRend3 === void 0 || (_validator$canvasRend4 = _validator$canvasRend3.calcCellAutoWidth) === null || _validator$canvasRend4 === void 0 ? void 0 : _validator$canvasRend4.call(_validator$canvasRend3, info);
|
|
2641
2626
|
};
|
|
2642
|
-
cell.coverable = ((
|
|
2627
|
+
cell.coverable = ((cell === null || cell === void 0 ? void 0 : cell.coverable) ?? true) && !(rule.type === _univerjs_core.DataValidationType.LIST || rule.type === _univerjs_core.DataValidationType.LIST_MULTIPLE);
|
|
2643
2628
|
return next(cell);
|
|
2644
2629
|
}
|
|
2645
2630
|
}));
|
|
@@ -2689,22 +2674,22 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
|
|
|
2689
2674
|
effect: _univerjs_core.InterceptorEffectEnum.Style,
|
|
2690
2675
|
priority: _univerjs_sheets.InterceptCellContentPriority.DATA_VALIDATION,
|
|
2691
2676
|
handler: (cell, pos, next) => {
|
|
2692
|
-
var
|
|
2677
|
+
var _cell$fontRenderExten2, _validator$skipDefaul2;
|
|
2693
2678
|
const { row, col, unitId, subUnitId, workbook, worksheet } = pos;
|
|
2694
2679
|
const ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
2695
2680
|
if (!ruleId) return next(cell);
|
|
2696
2681
|
const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
2697
2682
|
if (!rule) return next(cell);
|
|
2698
|
-
const validStatus =
|
|
2683
|
+
const validStatus = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col) ?? _univerjs_core.DataValidationStatus.VALID;
|
|
2699
2684
|
const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
|
|
2700
2685
|
const cellValue = (0, _univerjs_sheets_data_validation.getCellValueOrigin)(worksheet.getCellRaw(row, col));
|
|
2701
|
-
const valueStr = `${cellValue
|
|
2686
|
+
const valueStr = `${cellValue ?? ""}`;
|
|
2702
2687
|
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
2703
2688
|
cell.markers = {
|
|
2704
2689
|
...cell === null || cell === void 0 ? void 0 : cell.markers,
|
|
2705
2690
|
...validStatus === _univerjs_core.DataValidationStatus.INVALID ? INVALID_MARK : null
|
|
2706
2691
|
};
|
|
2707
|
-
cell.customRender = [...(
|
|
2692
|
+
cell.customRender = [...(cell === null || cell === void 0 ? void 0 : cell.customRender) ?? [], ...(validator === null || validator === void 0 ? void 0 : validator.canvasRender) ? [validator.canvasRender] : []];
|
|
2708
2693
|
cell.fontRenderExtension = {
|
|
2709
2694
|
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
2710
2695
|
isSkip: (cell === null || cell === void 0 || (_cell$fontRenderExten2 = cell.fontRenderExtension) === null || _cell$fontRenderExten2 === void 0 ? void 0 : _cell$fontRenderExten2.isSkip) || (validator === null || validator === void 0 || (_validator$skipDefaul2 = validator.skipDefaultFontRender) === null || _validator$skipDefaul2 === void 0 ? void 0 : _validator$skipDefaul2.call(validator, rule, cellValue, pos))
|
|
@@ -2717,14 +2702,14 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
|
|
|
2717
2702
|
} }, row, col)
|
|
2718
2703
|
};
|
|
2719
2704
|
cell.interceptorAutoHeight = () => {
|
|
2720
|
-
var _this$_renderManagerS3,
|
|
2721
|
-
const skeleton = (_this$_renderManagerS3 = this._renderManagerService.
|
|
2705
|
+
var _this$_renderManagerS3, _validator$canvasRend5, _validator$canvasRend6;
|
|
2706
|
+
const skeleton = (_this$_renderManagerS3 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS3 === void 0 || (_this$_renderManagerS3 = _this$_renderManagerS3.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS3 === void 0 ? void 0 : _this$_renderManagerS3.skeleton;
|
|
2722
2707
|
if (!skeleton) return;
|
|
2723
2708
|
const mergeCell = skeleton.worksheet.getMergedCell(row, col);
|
|
2724
2709
|
const info = {
|
|
2725
2710
|
data: cell,
|
|
2726
|
-
style:
|
|
2727
|
-
primaryWithCoord: skeleton.getCellWithCoordByIndex((
|
|
2711
|
+
style: workbook.getStyles().getStyleByCell(cell),
|
|
2712
|
+
primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
|
|
2728
2713
|
unitId,
|
|
2729
2714
|
subUnitId,
|
|
2730
2715
|
row,
|
|
@@ -2735,14 +2720,14 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
|
|
|
2735
2720
|
return validator === null || validator === void 0 || (_validator$canvasRend5 = validator.canvasRender) === null || _validator$canvasRend5 === void 0 || (_validator$canvasRend6 = _validator$canvasRend5.calcCellAutoHeight) === null || _validator$canvasRend6 === void 0 ? void 0 : _validator$canvasRend6.call(_validator$canvasRend5, info);
|
|
2736
2721
|
};
|
|
2737
2722
|
cell.interceptorAutoWidth = () => {
|
|
2738
|
-
var _this$_renderManagerS4,
|
|
2739
|
-
const skeleton = (_this$_renderManagerS4 = this._renderManagerService.
|
|
2723
|
+
var _this$_renderManagerS4, _validator$canvasRend7, _validator$canvasRend8;
|
|
2724
|
+
const skeleton = (_this$_renderManagerS4 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS4 === void 0 || (_this$_renderManagerS4 = _this$_renderManagerS4.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS4 === void 0 ? void 0 : _this$_renderManagerS4.skeleton;
|
|
2740
2725
|
if (!skeleton) return;
|
|
2741
2726
|
const mergeCell = skeleton.worksheet.getMergedCell(row, col);
|
|
2742
2727
|
const info = {
|
|
2743
2728
|
data: cell,
|
|
2744
|
-
style:
|
|
2745
|
-
primaryWithCoord: skeleton.getCellWithCoordByIndex((
|
|
2729
|
+
style: workbook.getStyles().getStyleByCell(cell),
|
|
2730
|
+
primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
|
|
2746
2731
|
unitId,
|
|
2747
2732
|
subUnitId,
|
|
2748
2733
|
row,
|
|
@@ -2752,7 +2737,7 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
|
|
|
2752
2737
|
};
|
|
2753
2738
|
return validator === null || validator === void 0 || (_validator$canvasRend7 = validator.canvasRender) === null || _validator$canvasRend7 === void 0 || (_validator$canvasRend8 = _validator$canvasRend7.calcCellAutoWidth) === null || _validator$canvasRend8 === void 0 ? void 0 : _validator$canvasRend8.call(_validator$canvasRend7, info);
|
|
2754
2739
|
};
|
|
2755
|
-
cell.coverable = ((
|
|
2740
|
+
cell.coverable = ((cell === null || cell === void 0 ? void 0 : cell.coverable) ?? true) && !(rule.type === _univerjs_core.DataValidationType.LIST || rule.type === _univerjs_core.DataValidationType.LIST_MULTIPLE);
|
|
2756
2741
|
return next(cell);
|
|
2757
2742
|
}
|
|
2758
2743
|
}));
|
|
@@ -2814,11 +2799,10 @@ SheetsDataValidationReRenderController = __decorate([__decorateParam(1, (0, _uni
|
|
|
2814
2799
|
const MARGIN_H$2 = 6;
|
|
2815
2800
|
let CheckboxRender = class CheckboxRender {
|
|
2816
2801
|
_calc(cellInfo, style) {
|
|
2817
|
-
var _style$fs, _style$fs2, _style$fs3;
|
|
2818
2802
|
const { vt, ht } = style || {};
|
|
2819
2803
|
const width = cellInfo.endX - cellInfo.startX - MARGIN_H$2 * 2;
|
|
2820
2804
|
const height = cellInfo.endY - cellInfo.startY;
|
|
2821
|
-
const size = ((
|
|
2805
|
+
const size = ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
|
|
2822
2806
|
let widgetLeft = 0;
|
|
2823
2807
|
let widgetTop = 0;
|
|
2824
2808
|
switch (vt) {
|
|
@@ -2846,8 +2830,8 @@ let CheckboxRender = class CheckboxRender {
|
|
|
2846
2830
|
return {
|
|
2847
2831
|
left: cellInfo.startX + widgetLeft,
|
|
2848
2832
|
top: cellInfo.startY + widgetTop,
|
|
2849
|
-
width: ((
|
|
2850
|
-
height: ((
|
|
2833
|
+
width: ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6,
|
|
2834
|
+
height: ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6
|
|
2851
2835
|
};
|
|
2852
2836
|
}
|
|
2853
2837
|
constructor(_commandService, _univerInstanceService, _formulaService, _themeService, _renderManagerService, _dataValidationModel) {
|
|
@@ -2859,14 +2843,12 @@ let CheckboxRender = class CheckboxRender {
|
|
|
2859
2843
|
this._dataValidationModel = _dataValidationModel;
|
|
2860
2844
|
}
|
|
2861
2845
|
calcCellAutoHeight(info) {
|
|
2862
|
-
var _style$fs4;
|
|
2863
2846
|
const { style } = info;
|
|
2864
|
-
return ((
|
|
2847
|
+
return ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
|
|
2865
2848
|
}
|
|
2866
2849
|
calcCellAutoWidth(info) {
|
|
2867
|
-
var _style$fs5;
|
|
2868
2850
|
const { style } = info;
|
|
2869
|
-
return ((
|
|
2851
|
+
return ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
|
|
2870
2852
|
}
|
|
2871
2853
|
async _parseFormula(rule, unitId, subUnitId) {
|
|
2872
2854
|
var _results$, _results$2, _results$3;
|
|
@@ -2882,7 +2864,7 @@ let CheckboxRender = class CheckboxRender {
|
|
|
2882
2864
|
};
|
|
2883
2865
|
}
|
|
2884
2866
|
drawWith(ctx, info) {
|
|
2885
|
-
var _validator$skipDefaul, _style$
|
|
2867
|
+
var _validator$skipDefaul, _style$cl;
|
|
2886
2868
|
const { style, primaryWithCoord, unitId, subUnitId, worksheet, row, col } = info;
|
|
2887
2869
|
const cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
2888
2870
|
const value = (0, _univerjs_sheets_data_validation.getCellValueOrigin)(worksheet.getCellRaw(row, col));
|
|
@@ -2920,14 +2902,14 @@ let CheckboxRender = class CheckboxRender {
|
|
|
2920
2902
|
ctx.clip();
|
|
2921
2903
|
const m = transform.getMatrix();
|
|
2922
2904
|
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
2923
|
-
const size = ((
|
|
2905
|
+
const size = ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
|
|
2924
2906
|
const checked = String(value) === String(formula1);
|
|
2925
2907
|
const defaultColor = this._themeService.getColorFromTheme("primary.600");
|
|
2926
2908
|
_univerjs_engine_render.CheckboxShape.drawWith(ctx, {
|
|
2927
2909
|
checked,
|
|
2928
2910
|
width: size,
|
|
2929
2911
|
height: size,
|
|
2930
|
-
fill: (
|
|
2912
|
+
fill: (style === null || style === void 0 || (_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? defaultColor
|
|
2931
2913
|
});
|
|
2932
2914
|
ctx.restore();
|
|
2933
2915
|
}
|
|
@@ -3235,7 +3217,6 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
3235
3217
|
ctx.restore();
|
|
3236
3218
|
}
|
|
3237
3219
|
drawWith(ctx, info, skeleton, spreadsheets) {
|
|
3238
|
-
var _ref, _getCellValueOrigin;
|
|
3239
3220
|
const { primaryWithCoord, row, col, style, data, subUnitId } = info;
|
|
3240
3221
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
3241
3222
|
const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
|
|
@@ -3256,11 +3237,11 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
3256
3237
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
3257
3238
|
const cellHeight = cellBounding.endY - cellBounding.startY;
|
|
3258
3239
|
const { cl } = style || {};
|
|
3259
|
-
const color = (
|
|
3260
|
-
const fontStyle = (0, _univerjs_engine_render.getFontStyleString)(style
|
|
3240
|
+
const color = (typeof cl === "object" ? cl === null || cl === void 0 ? void 0 : cl.rgb : cl) ?? "#000";
|
|
3241
|
+
const fontStyle = (0, _univerjs_engine_render.getFontStyleString)(style ?? void 0);
|
|
3261
3242
|
const { vt: _vt, ht } = style || {};
|
|
3262
|
-
const vt = _vt
|
|
3263
|
-
const cellValue = (
|
|
3243
|
+
const vt = _vt ?? _univerjs_core.VerticalAlign.MIDDLE;
|
|
3244
|
+
const cellValue = (0, _univerjs_sheets_data_validation.getCellValueOrigin)(data) ?? "";
|
|
3264
3245
|
const items = validator.parseCellValue(cellValue);
|
|
3265
3246
|
const labelColorMap = validator.getListWithColorMap(rule);
|
|
3266
3247
|
const layout = layoutDropdowns(items, fontStyle, cellWidth, cellHeight);
|
|
@@ -3318,7 +3299,6 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
3318
3299
|
});
|
|
3319
3300
|
}
|
|
3320
3301
|
calcCellAutoHeight(info) {
|
|
3321
|
-
var _getCellValueOrigin2;
|
|
3322
3302
|
const { primaryWithCoord, style, data, row, col } = info;
|
|
3323
3303
|
const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
|
|
3324
3304
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
@@ -3334,11 +3314,10 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
3334
3314
|
if (!validator) return;
|
|
3335
3315
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
3336
3316
|
const cellHeight = cellBounding.endY - cellBounding.startY;
|
|
3337
|
-
const cellValue = (
|
|
3338
|
-
return layoutDropdowns(validator.parseCellValue(cellValue), (0, _univerjs_engine_render.getFontStyleString)(style
|
|
3317
|
+
const cellValue = (0, _univerjs_sheets_data_validation.getCellValueOrigin)(data) ?? "";
|
|
3318
|
+
return layoutDropdowns(validator.parseCellValue(cellValue), (0, _univerjs_engine_render.getFontStyleString)(style ?? void 0), cellWidth, cellHeight).cellAutoHeight;
|
|
3339
3319
|
}
|
|
3340
3320
|
calcCellAutoWidth(info) {
|
|
3341
|
-
var _getCellValueOrigin3;
|
|
3342
3321
|
const { primaryWithCoord, style, data, row, col } = info;
|
|
3343
3322
|
const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
|
|
3344
3323
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
@@ -3354,8 +3333,8 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
3354
3333
|
if (!validator) return;
|
|
3355
3334
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
3356
3335
|
const cellHeight = cellBounding.endY - cellBounding.startY;
|
|
3357
|
-
const cellValue = (
|
|
3358
|
-
return layoutDropdowns(validator.parseCellValue(cellValue), (0, _univerjs_engine_render.getFontStyleString)(style
|
|
3336
|
+
const cellValue = (0, _univerjs_sheets_data_validation.getCellValueOrigin)(data) ?? "";
|
|
3337
|
+
return layoutDropdowns(validator.parseCellValue(cellValue), (0, _univerjs_engine_render.getFontStyleString)(style ?? void 0), cellWidth, cellHeight).calcAutoWidth;
|
|
3359
3338
|
}
|
|
3360
3339
|
isHit(position, info) {
|
|
3361
3340
|
const { primaryWithCoord } = info;
|
|
@@ -3508,7 +3487,6 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3508
3487
|
ctx.restore();
|
|
3509
3488
|
}
|
|
3510
3489
|
drawWith(ctx, info, skeleton) {
|
|
3511
|
-
var _tb, _vt, _ht, _pd;
|
|
3512
3490
|
const { primaryWithCoord, row, col, style, data, subUnitId } = info;
|
|
3513
3491
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
3514
3492
|
const _row = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo.startRow : row;
|
|
@@ -3531,14 +3509,13 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3531
3509
|
const map = this._ensureMap(subUnitId);
|
|
3532
3510
|
const key = this._generateKey(row, col);
|
|
3533
3511
|
const colorMap = validator.getListWithColorMap(rule);
|
|
3534
|
-
const
|
|
3535
|
-
const valueStr = `${value !== null && value !== void 0 ? value : ""}`;
|
|
3512
|
+
const valueStr = `${(0, _univerjs_sheets_data_validation.getCellValueOrigin)(data) ?? ""}`;
|
|
3536
3513
|
const activeColor = colorMap[valueStr];
|
|
3537
3514
|
let { tb, vt, ht, pd } = style || {};
|
|
3538
|
-
tb =
|
|
3539
|
-
vt =
|
|
3540
|
-
ht =
|
|
3541
|
-
pd =
|
|
3515
|
+
tb = tb ?? _univerjs_core.WrapStrategy.WRAP;
|
|
3516
|
+
vt = vt ?? _univerjs_core.VerticalAlign.BOTTOM;
|
|
3517
|
+
ht = ht ?? _univerjs_core.DEFAULT_STYLES.ht;
|
|
3518
|
+
pd = pd ?? _univerjs_core.DEFAULT_STYLES.pd;
|
|
3542
3519
|
const fontStyle = (0, _univerjs_engine_render.getFontStyleString)(style).fontCache;
|
|
3543
3520
|
if (rule.renderMode === _univerjs_core.DataValidationRenderMode.ARROW) {
|
|
3544
3521
|
var _style$cl, _style$st, _style$ul;
|
|
@@ -3632,7 +3609,6 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3632
3609
|
}
|
|
3633
3610
|
}
|
|
3634
3611
|
calcCellAutoHeight(info) {
|
|
3635
|
-
var _tb2;
|
|
3636
3612
|
const { primaryWithCoord, style, data, row, col } = info;
|
|
3637
3613
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
3638
3614
|
const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
|
|
@@ -3646,13 +3622,12 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3646
3622
|
endY: _cellBounding.endY - downOffset
|
|
3647
3623
|
};
|
|
3648
3624
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
3649
|
-
const
|
|
3650
|
-
const valueStr = `${value !== null && value !== void 0 ? value : ""}`;
|
|
3625
|
+
const valueStr = `${(0, _univerjs_sheets_data_validation.getCellValueOrigin)(data) ?? ""}`;
|
|
3651
3626
|
let { tb, pd } = style || {};
|
|
3652
|
-
const { t = _univerjs_core.DEFAULT_STYLES.pd.t, b = _univerjs_core.DEFAULT_STYLES.pd.b } = pd
|
|
3653
|
-
tb =
|
|
3627
|
+
const { t = _univerjs_core.DEFAULT_STYLES.pd.t, b = _univerjs_core.DEFAULT_STYLES.pd.b } = pd ?? {};
|
|
3628
|
+
tb = tb ?? _univerjs_core.WrapStrategy.WRAP;
|
|
3654
3629
|
if (rule.renderMode === _univerjs_core.DataValidationRenderMode.ARROW) {
|
|
3655
|
-
const { l = _univerjs_core.DEFAULT_STYLES.pd.l, r = _univerjs_core.DEFAULT_STYLES.pd.r } = pd
|
|
3630
|
+
const { l = _univerjs_core.DEFAULT_STYLES.pd.l, r = _univerjs_core.DEFAULT_STYLES.pd.r } = pd ?? {};
|
|
3656
3631
|
const realWidth = cellWidth - l - r - ICON_PLACE - 4;
|
|
3657
3632
|
const skeleton = new _univerjs_engine_render.DocSimpleSkeleton(valueStr, (0, _univerjs_engine_render.getFontStyleString)(style).fontCache, Boolean(tb === _univerjs_core.WrapStrategy.WRAP), realWidth, Infinity);
|
|
3658
3633
|
skeleton.calculate();
|
|
@@ -3665,7 +3640,6 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3665
3640
|
}
|
|
3666
3641
|
}
|
|
3667
3642
|
calcCellAutoWidth(info) {
|
|
3668
|
-
var _tb3;
|
|
3669
3643
|
const { primaryWithCoord, style, data, row, col } = info;
|
|
3670
3644
|
const cellRange = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
3671
3645
|
const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
|
|
@@ -3679,11 +3653,10 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3679
3653
|
endY: cellRange.endY - downOffset
|
|
3680
3654
|
};
|
|
3681
3655
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
3682
|
-
const
|
|
3683
|
-
const valueStr = `${value !== null && value !== void 0 ? value : ""}`;
|
|
3656
|
+
const valueStr = `${(0, _univerjs_sheets_data_validation.getCellValueOrigin)(data) ?? ""}`;
|
|
3684
3657
|
let { tb, pd } = style || {};
|
|
3685
|
-
const { l = _univerjs_core.DEFAULT_STYLES.pd.l, r = _univerjs_core.DEFAULT_STYLES.pd.r } = pd
|
|
3686
|
-
tb =
|
|
3658
|
+
const { l = _univerjs_core.DEFAULT_STYLES.pd.l, r = _univerjs_core.DEFAULT_STYLES.pd.r } = pd ?? {};
|
|
3659
|
+
tb = tb ?? _univerjs_core.WrapStrategy.WRAP;
|
|
3687
3660
|
let paddingAll = 26;
|
|
3688
3661
|
switch (rule.renderMode) {
|
|
3689
3662
|
case _univerjs_core.DataValidationRenderMode.ARROW:
|
|
@@ -3894,6 +3867,7 @@ _defineProperty(UniverSheetsDataValidationMobileUIPlugin, "packageName", name);
|
|
|
3894
3867
|
_defineProperty(UniverSheetsDataValidationMobileUIPlugin, "version", version);
|
|
3895
3868
|
_defineProperty(UniverSheetsDataValidationMobileUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
3896
3869
|
UniverSheetsDataValidationMobileUIPlugin = __decorate([
|
|
3870
|
+
(0, _univerjs_core.DependentOn)(_univerjs_data_validation.UniverDataValidationPlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_ui.UniverMobileUIPlugin, _univerjs_sheets_ui.UniverSheetsMobileUIPlugin, _univerjs_sheets_data_validation.UniverSheetsDataValidationPlugin),
|
|
3897
3871
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
3898
3872
|
__decorateParam(2, _univerjs_core.ICommandService),
|
|
3899
3873
|
__decorateParam(3, _univerjs_core.IConfigService)
|
|
@@ -3961,7 +3935,7 @@ _defineProperty(UniverSheetsDataValidationUIPlugin, "packageName", name);
|
|
|
3961
3935
|
_defineProperty(UniverSheetsDataValidationUIPlugin, "version", version);
|
|
3962
3936
|
_defineProperty(UniverSheetsDataValidationUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
3963
3937
|
UniverSheetsDataValidationUIPlugin = __decorate([
|
|
3964
|
-
(0, _univerjs_core.DependentOn)(_univerjs_sheets_data_validation.UniverSheetsDataValidationPlugin),
|
|
3938
|
+
(0, _univerjs_core.DependentOn)(_univerjs_data_validation.UniverDataValidationPlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin, _univerjs_sheets_data_validation.UniverSheetsDataValidationPlugin),
|
|
3965
3939
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
3966
3940
|
__decorateParam(2, _univerjs_core.ICommandService),
|
|
3967
3941
|
__decorateParam(3, _univerjs_core.IConfigService)
|