@univerjs/sheets-data-validation-ui 1.0.0-alpha.8 → 1.0.0-beta.1
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 +173 -244
- package/lib/cjs/locale/ar-SA.js +1 -36
- package/lib/cjs/locale/ca-ES.js +1 -36
- package/lib/cjs/locale/de-DE.js +1 -36
- package/lib/cjs/locale/en-US.js +1 -36
- package/lib/cjs/locale/es-ES.js +1 -36
- package/lib/cjs/locale/fa-IR.js +1 -36
- package/lib/cjs/locale/fr-FR.js +1 -36
- package/lib/cjs/locale/id-ID.js +1 -36
- package/lib/cjs/locale/it-IT.js +1 -36
- package/lib/cjs/locale/ja-JP.js +1 -36
- package/lib/cjs/locale/ko-KR.js +1 -36
- package/lib/cjs/locale/pl-PL.js +1 -36
- package/lib/cjs/locale/pt-BR.js +1 -36
- package/lib/cjs/locale/ru-RU.js +1 -36
- package/lib/cjs/locale/sk-SK.js +1 -36
- package/lib/cjs/locale/vi-VN.js +1 -36
- package/lib/cjs/locale/zh-CN.js +1 -36
- package/lib/cjs/locale/zh-HK.js +1 -36
- package/lib/cjs/locale/zh-TW.js +1 -36
- package/lib/es/index.js +175 -246
- package/lib/es/locale/ar-SA.js +1 -36
- package/lib/es/locale/ca-ES.js +1 -36
- package/lib/es/locale/de-DE.js +1 -36
- package/lib/es/locale/en-US.js +1 -36
- package/lib/es/locale/es-ES.js +1 -36
- package/lib/es/locale/fa-IR.js +1 -36
- package/lib/es/locale/fr-FR.js +1 -36
- package/lib/es/locale/id-ID.js +1 -36
- package/lib/es/locale/it-IT.js +1 -36
- package/lib/es/locale/ja-JP.js +1 -36
- package/lib/es/locale/ko-KR.js +1 -36
- package/lib/es/locale/pl-PL.js +1 -36
- package/lib/es/locale/pt-BR.js +1 -36
- package/lib/es/locale/ru-RU.js +1 -36
- package/lib/es/locale/sk-SK.js +1 -36
- package/lib/es/locale/vi-VN.js +1 -36
- package/lib/es/locale/zh-CN.js +1 -36
- package/lib/es/locale/zh-HK.js +1 -36
- package/lib/es/locale/zh-TW.js +1 -36
- package/lib/index.css +24 -8
- package/lib/index.js +175 -246
- package/lib/locale/ar-SA.js +1 -36
- package/lib/locale/ca-ES.js +1 -36
- package/lib/locale/de-DE.js +1 -36
- package/lib/locale/en-US.js +1 -36
- package/lib/locale/es-ES.js +1 -36
- package/lib/locale/fa-IR.js +1 -36
- package/lib/locale/fr-FR.js +1 -36
- package/lib/locale/id-ID.js +1 -36
- package/lib/locale/it-IT.js +1 -36
- package/lib/locale/ja-JP.js +1 -36
- package/lib/locale/ko-KR.js +1 -36
- package/lib/locale/pl-PL.js +1 -36
- package/lib/locale/pt-BR.js +1 -36
- package/lib/locale/ru-RU.js +1 -36
- package/lib/locale/sk-SK.js +1 -36
- package/lib/locale/vi-VN.js +1 -36
- package/lib/locale/zh-CN.js +1 -36
- package/lib/locale/zh-HK.js +1 -36
- package/lib/locale/zh-TW.js +1 -36
- package/lib/types/const.d.ts +2 -1
- package/lib/types/locale/en-US.d.ts +0 -39
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +15 -15
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentManager, IDialogService, IMenuManagerService, ISidebarService, IconManager, KeyCode, MenuItemType, RibbonDataGroup, RibbonInsertGroup, UniverMobileUIPlugin,
|
|
2
|
-
import { CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DataValidationErrorStyle, DataValidationRenderMode, DataValidationStatus, DataValidationType, DependentOn, Disposable, DisposableCollection, HorizontalAlign, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService,
|
|
1
|
+
import { ComponentManager, IDialogService, IMenuManagerService, ISidebarService, IconManager, KeyCode, MenuItemType, RibbonDataGroup, RibbonInsertGroup, UniverMobileUIPlugin, getMenuHiddenObservable, useDependency, useEvent, useObservable, useSidebarClick } from "@univerjs/ui";
|
|
2
|
+
import { CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DataValidationErrorStyle, DataValidationRenderMode, DataValidationStatus, DataValidationType, DependentOn, Disposable, DisposableCollection, HorizontalAlign, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Rectangle, RedoCommand, RxDisposable, ThemeService, UndoCommand, UniverInstanceType, VerticalAlign, WrapStrategy, bufferDebounceTime, dateKit, debounce, generateRandomId, getIntersectRange, isFormulaString, isUnitRangesEqual, merge, numfmt, sequenceExecute, shallowEqual, toDisposable } from "@univerjs/core";
|
|
3
3
|
import { AUTO_FILL_APPLY_TYPE, AutoFillTools, IAutoFillService, INTERCEPTOR_POINT, InterceptCellContentPriority, RangeProtectionPermissionEditPoint, SetRangeValuesCommand, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, VALIDATE_CELL, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, checkRangesEditablePermission, deserializeListOptions, getSheetCommandTarget, rangeToDiscreteRange, serializeListOptions } from "@univerjs/sheets";
|
|
4
4
|
import { AddSheetDataValidationCommand, BASE_FORMULA_INPUT_NAME, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, CHECKBOX_FORMULA_INPUT_NAME, CUSTOM_FORMULA_INPUT_NAME, ClearRangeDataValidationCommand, DATA_VALIDATION_PLUGIN_NAME, DataValidationCacheService, DataValidationFormulaController, DataValidationFormulaService, LIST_FORMULA_INPUT_NAME, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, SheetDataValidationModel, SheetsDataValidationValidatorService, UniverSheetsDataValidationPlugin, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, createDefaultNewRule, getCellValueOrigin, getDataValidationCellValue, getDataValidationDiffMutations, getFormulaResult, isLegalFormulaResult, transformCheckboxValue } from "@univerjs/sheets-data-validation";
|
|
5
5
|
import { DataValidationModel, DataValidatorDropdownType, DataValidatorRegistryScope, DataValidatorRegistryService, TWO_FORMULA_OPERATOR_COUNT, UniverDataValidationPlugin, getRuleOptions, getRuleSetting } from "@univerjs/data-validation";
|
|
@@ -161,7 +161,8 @@ const defaultPluginConfig = {};
|
|
|
161
161
|
* See the License for the specific language governing permissions and
|
|
162
162
|
* limitations under the License.
|
|
163
163
|
*/
|
|
164
|
-
const DROP_DOWN_DEFAULT_COLOR = "
|
|
164
|
+
const DROP_DOWN_DEFAULT_COLOR = "gray.100";
|
|
165
|
+
const DROP_DOWN_ICON_COLOR = "gray.600";
|
|
165
166
|
|
|
166
167
|
//#endregion
|
|
167
168
|
//#region src/controllers/dv-reject-input.controller.ts
|
|
@@ -302,7 +303,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
302
303
|
if (!(validator === null || validator === void 0 ? void 0 : validator.dropdownType)) return;
|
|
303
304
|
let popupDisposable;
|
|
304
305
|
const handleSave = async (date, targetPatternType) => {
|
|
305
|
-
var _numfmt$parseDate, _cellStyle$n
|
|
306
|
+
var _numfmt$parseDate, _cellStyle$n;
|
|
306
307
|
if (!date) return true;
|
|
307
308
|
const newValue = date;
|
|
308
309
|
const cellData = worksheet.getCell(row, col);
|
|
@@ -310,7 +311,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
310
311
|
const serialNum = (_numfmt$parseDate = numfmt.parseDate(dateStr)) === null || _numfmt$parseDate === void 0 ? void 0 : _numfmt$parseDate.v;
|
|
311
312
|
const serialTime = targetPatternType === "time" ? serialNum % 1 : serialNum;
|
|
312
313
|
const cellStyle = workbook.getStyles().getStyleByCell(cellData);
|
|
313
|
-
const format = (
|
|
314
|
+
const format = (cellStyle === null || cellStyle === void 0 || (_cellStyle$n = cellStyle.n) === null || _cellStyle$n === void 0 ? void 0 : _cellStyle$n.pattern) ?? "";
|
|
314
315
|
if (rule.errorStyle !== DataValidationErrorStyle.STOP || await validator.validator({
|
|
315
316
|
value: serialTime,
|
|
316
317
|
unitId,
|
|
@@ -404,11 +405,10 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
404
405
|
}
|
|
405
406
|
case DataValidatorDropdownType.LIST:
|
|
406
407
|
case DataValidatorDropdownType.MULTIPLE_LIST: {
|
|
407
|
-
var _this$_configService$, _this$_configService$2
|
|
408
|
+
var _this$_configService$, _this$_configService$2;
|
|
408
409
|
const multiple = validator.dropdownType === DataValidatorDropdownType.MULTIPLE_LIST;
|
|
409
410
|
const handleSave = async (newValue) => {
|
|
410
|
-
|
|
411
|
-
const str = multiple ? serializeListOptions(newValue) : (_newValue$ = newValue[0]) !== null && _newValue$ !== void 0 ? _newValue$ : "";
|
|
411
|
+
const str = multiple ? serializeListOptions(newValue) : newValue[0] ?? "";
|
|
412
412
|
const params = {
|
|
413
413
|
unitId,
|
|
414
414
|
subUnitId,
|
|
@@ -450,19 +450,18 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
450
450
|
options: list.map((item) => ({
|
|
451
451
|
label: item.label,
|
|
452
452
|
value: item.label,
|
|
453
|
-
color: showColor || item.color ? item.color || "
|
|
453
|
+
color: showColor || item.color ? item.color || "gray.100" : "transparent"
|
|
454
454
|
})),
|
|
455
455
|
onEdit: handleEdit,
|
|
456
456
|
defaultValue: cellStr,
|
|
457
457
|
multiple,
|
|
458
|
-
showEdit: (
|
|
459
|
-
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
|
|
460
460
|
}
|
|
461
461
|
};
|
|
462
462
|
break;
|
|
463
463
|
}
|
|
464
464
|
case DataValidatorDropdownType.CASCADE: {
|
|
465
|
-
var _rule$formula;
|
|
466
465
|
const handleSave = (newValue) => {
|
|
467
466
|
const params = {
|
|
468
467
|
unitId,
|
|
@@ -494,7 +493,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
|
|
|
494
493
|
props: {
|
|
495
494
|
onChange: handleSave,
|
|
496
495
|
defaultValue: getDataValidationCellValue(worksheet.getCellRaw(row, col)).split("/"),
|
|
497
|
-
options: JSON.parse(
|
|
496
|
+
options: JSON.parse(rule.formula1 ?? "[]")
|
|
498
497
|
},
|
|
499
498
|
location
|
|
500
499
|
};
|
|
@@ -776,7 +775,7 @@ function DropdownPresets({ onChange }) {
|
|
|
776
775
|
children: presets.map((values) => /* @__PURE__ */ jsx("button", {
|
|
777
776
|
type: "button",
|
|
778
777
|
"aria-label": values.join(" / "),
|
|
779
|
-
className: "univer-flex univer-min-h-20 univer-cursor-pointer univer-flex-col univer-items-start univer-gap-1.5 univer-rounded-md univer-border-0 univer-bg-gray-50 univer-p-3 univer-text-left univer-text-sm univer-leading-5 univer-text-gray-900 univer-transition-colors hover:univer-bg-gray-100 focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 focus-visible:univer-ring-offset-0 dark:!univer-bg-gray-800 dark:!univer-text-
|
|
778
|
+
className: "univer-flex univer-min-h-20 univer-cursor-pointer univer-flex-col univer-items-start univer-gap-1.5 univer-rounded-md univer-border-0 univer-bg-gray-50 univer-p-3 univer-text-left univer-text-sm univer-leading-5 univer-text-gray-900 univer-transition-colors hover:univer-bg-gray-100 focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 focus-visible:univer-ring-offset-0 dark:!univer-bg-gray-800 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700",
|
|
780
779
|
onClick: () => onChange(serializeListOptions(values)),
|
|
781
780
|
children: values.map((value) => /* @__PURE__ */ jsx("span", {
|
|
782
781
|
className: "univer-w-full univer-break-words",
|
|
@@ -991,19 +990,18 @@ const menuSchema = {
|
|
|
991
990
|
//#endregion
|
|
992
991
|
//#region package.json
|
|
993
992
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
994
|
-
var version = "1.0.0-
|
|
993
|
+
var version = "1.0.0-beta.1";
|
|
995
994
|
|
|
996
995
|
//#endregion
|
|
997
996
|
//#region src/views/components/DataValidationOptions.tsx
|
|
998
997
|
function DataValidationOptions(props) {
|
|
999
|
-
var _value$errorStyle;
|
|
1000
998
|
const localeService = useDependency(LocaleService);
|
|
1001
999
|
const componentManager = useDependency(ComponentManager);
|
|
1002
1000
|
const { value, onChange, extraComponent } = props;
|
|
1003
1001
|
const [show, setShow] = useState(false);
|
|
1004
1002
|
const ExtraOptions = extraComponent ? componentManager.get(extraComponent) : null;
|
|
1005
1003
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
1006
|
-
className: "univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-
|
|
1004
|
+
className: "univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0",
|
|
1007
1005
|
onClick: () => setShow(!show),
|
|
1008
1006
|
children: [localeService.t("sheets-data-validation-ui.panel.options"), show ? /* @__PURE__ */ jsx(MoreUpIcon, { className: "univer-ml-1" }) : /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-ml-1" })]
|
|
1009
1007
|
}), show && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1014,7 +1012,7 @@ function DataValidationOptions(props) {
|
|
|
1014
1012
|
/* @__PURE__ */ jsx(FormLayout, {
|
|
1015
1013
|
label: localeService.t("sheets-data-validation-ui.panel.invalid"),
|
|
1016
1014
|
children: /* @__PURE__ */ jsxs(RadioGroup, {
|
|
1017
|
-
value: `${
|
|
1015
|
+
value: `${value.errorStyle ?? DataValidationErrorStyle.WARNING}`,
|
|
1018
1016
|
onChange: (errorStyle) => onChange({
|
|
1019
1017
|
...value,
|
|
1020
1018
|
errorStyle: +errorStyle
|
|
@@ -1074,7 +1072,7 @@ function DataValidationDetail() {
|
|
|
1074
1072
|
} });
|
|
1075
1073
|
}
|
|
1076
1074
|
function DataValidationDetailInner(props) {
|
|
1077
|
-
var _validators$sort
|
|
1075
|
+
var _validators$sort;
|
|
1078
1076
|
const [key, setKey] = useState(0);
|
|
1079
1077
|
const dataValidationPanelService = useDependency(DataValidationPanelService);
|
|
1080
1078
|
const { unitId, subUnitId, rule } = props.activeRuleInfo;
|
|
@@ -1086,10 +1084,7 @@ function DataValidationDetailInner(props) {
|
|
|
1086
1084
|
const dataValidationModel = useDependency(DataValidationModel);
|
|
1087
1085
|
const localeService = useDependency(LocaleService);
|
|
1088
1086
|
const workbook = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), void 0, void 0, []);
|
|
1089
|
-
const worksheet = useObservable(() =>
|
|
1090
|
-
var _workbook$activeSheet;
|
|
1091
|
-
return (_workbook$activeSheet = workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) !== null && _workbook$activeSheet !== void 0 ? _workbook$activeSheet : of(null);
|
|
1092
|
-
}, void 0, void 0, []);
|
|
1087
|
+
const worksheet = useObservable(() => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null), void 0, void 0, []);
|
|
1093
1088
|
const [localRule, setLocalRule] = useState(rule);
|
|
1094
1089
|
const validator = validatorService.getValidatorItem(localRule.type);
|
|
1095
1090
|
const [showError, setShowError] = useState(false);
|
|
@@ -1337,14 +1332,11 @@ function DataValidationDetailInner(props) {
|
|
|
1337
1332
|
ruleId
|
|
1338
1333
|
}, key + localRule.type) : null,
|
|
1339
1334
|
/* @__PURE__ */ jsx(FormLayout, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1340
|
-
checked:
|
|
1341
|
-
onChange: () => {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
allowBlank: !((_localRule$allowBlank2 = localRule.allowBlank) !== null && _localRule$allowBlank2 !== void 0 ? _localRule$allowBlank2 : true)
|
|
1346
|
-
});
|
|
1347
|
-
},
|
|
1335
|
+
checked: localRule.allowBlank ?? true,
|
|
1336
|
+
onChange: () => handleUpdateRuleSetting({
|
|
1337
|
+
...baseRule,
|
|
1338
|
+
allowBlank: !(localRule.allowBlank ?? true)
|
|
1339
|
+
}),
|
|
1348
1340
|
children: localeService.t("sheets-data-validation-ui.panel.allowBlank")
|
|
1349
1341
|
}) }),
|
|
1350
1342
|
/* @__PURE__ */ jsx(DataValidationOptions, {
|
|
@@ -1381,10 +1373,9 @@ const DataValidationItem = (props) => {
|
|
|
1381
1373
|
const [isHover, setIsHover] = useState(false);
|
|
1382
1374
|
const themeService = useDependency(ThemeService);
|
|
1383
1375
|
const style = useMemo(() => {
|
|
1384
|
-
var _themeService$getColo;
|
|
1385
1376
|
const defaultColor = themeService.getColorFromTheme("primary.600");
|
|
1386
1377
|
const key = themeService.getColorFromTheme("loop-color.2");
|
|
1387
|
-
const color =
|
|
1378
|
+
const color = themeService.getColorFromTheme(key) ?? defaultColor;
|
|
1388
1379
|
const rgb = new ColorKit(color).toRgb();
|
|
1389
1380
|
return {
|
|
1390
1381
|
fill: `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 0.1)`,
|
|
@@ -1410,7 +1401,7 @@ const DataValidationItem = (props) => {
|
|
|
1410
1401
|
};
|
|
1411
1402
|
}, [markSelectionService]);
|
|
1412
1403
|
return /* @__PURE__ */ jsxs("div", {
|
|
1413
|
-
className: clsx("univer-bg-secondary univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md univer-p-2 univer-pr-9", {
|
|
1404
|
+
className: clsx("univer-bg-secondary univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md univer-p-2 univer-pr-9 rtl:univer-pl-9 rtl:univer-pr-2", {
|
|
1414
1405
|
"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700": !disable,
|
|
1415
1406
|
"univer-opacity-50": disable
|
|
1416
1407
|
}),
|
|
@@ -1434,7 +1425,7 @@ const DataValidationItem = (props) => {
|
|
|
1434
1425
|
},
|
|
1435
1426
|
children: [
|
|
1436
1427
|
/* @__PURE__ */ jsx("div", {
|
|
1437
|
-
className: "univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-
|
|
1428
|
+
className: "univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-gray-0",
|
|
1438
1429
|
children: validator === null || validator === void 0 ? void 0 : validator.generateRuleName(rule)
|
|
1439
1430
|
}),
|
|
1440
1431
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -1442,7 +1433,7 @@ const DataValidationItem = (props) => {
|
|
|
1442
1433
|
children: rule.ranges.map((range) => serializeRange(range)).join(",")
|
|
1443
1434
|
}),
|
|
1444
1435
|
isHover && /* @__PURE__ */ jsx("div", {
|
|
1445
|
-
className: "univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-size-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",
|
|
1436
|
+
className: "univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-size-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 rtl:univer-left-2 rtl:univer-right-auto dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",
|
|
1446
1437
|
onClick: handleDelete,
|
|
1447
1438
|
children: /* @__PURE__ */ jsx(DeleteIcon, {})
|
|
1448
1439
|
})
|
|
@@ -1505,23 +1496,20 @@ function DataValidationList(props) {
|
|
|
1505
1496
|
const hasDisableRule = rulesByPermissionCheck === null || rulesByPermissionCheck === void 0 ? void 0 : rulesByPermissionCheck.some((rule) => rule.disable);
|
|
1506
1497
|
return /* @__PURE__ */ jsxs("div", {
|
|
1507
1498
|
className: "univer-pb-4",
|
|
1508
|
-
children: [rulesByPermissionCheck === null || rulesByPermissionCheck === void 0 ? void 0 : rulesByPermissionCheck.map((rule) => {
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
disable: (_rule$disable = rule.disable) !== null && _rule$disable !== void 0 ? _rule$disable : false
|
|
1523
|
-
}, rule.uid);
|
|
1524
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
1499
|
+
children: [rulesByPermissionCheck === null || rulesByPermissionCheck === void 0 ? void 0 : rulesByPermissionCheck.map((rule) => /* @__PURE__ */ 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__ */ jsxs("div", {
|
|
1525
1513
|
className: "univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",
|
|
1526
1514
|
children: [rules.length && !hasDisableRule ? /* @__PURE__ */ jsx(Button, {
|
|
1527
1515
|
onClick: handleRemoveAll,
|
|
@@ -1542,10 +1530,7 @@ const DataValidationPanel = () => {
|
|
|
1542
1530
|
const activeRule = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule);
|
|
1543
1531
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
1544
1532
|
const workbook = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), void 0, void 0, []);
|
|
1545
|
-
const worksheet = useObservable(() =>
|
|
1546
|
-
var _workbook$activeSheet;
|
|
1547
|
-
return (_workbook$activeSheet = workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) !== null && _workbook$activeSheet !== void 0 ? _workbook$activeSheet : of(null);
|
|
1548
|
-
}, void 0, void 0, []);
|
|
1533
|
+
const worksheet = useObservable(() => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null), void 0, void 0, []);
|
|
1549
1534
|
if (!workbook || !worksheet) return null;
|
|
1550
1535
|
return activeRule && (activeRule.subUnitId === worksheet.getSheetId() || activeRule.subUnitId === dataValidationPanelService.getFocusFormulaEditorActiveRuleSubUnitId()) ? /* @__PURE__ */ jsx(DataValidationDetail, {}, activeRule.rule.uid) : /* @__PURE__ */ jsx(DataValidationList, { workbook });
|
|
1551
1536
|
};
|
|
@@ -1687,7 +1672,6 @@ function CheckboxFormulaInput(props) {
|
|
|
1687
1672
|
//#endregion
|
|
1688
1673
|
//#region src/views/components/formula-input/CustomFormulaInput.tsx
|
|
1689
1674
|
function CustomFormulaInput(props) {
|
|
1690
|
-
var _value$formula;
|
|
1691
1675
|
const { unitId, subUnitId, value, onChange, showError, validResult } = props;
|
|
1692
1676
|
const formula1Res = showError ? validResult === null || validResult === void 0 ? void 0 : validResult.formula1 : void 0;
|
|
1693
1677
|
const formulaEditorRef = useRef(null);
|
|
@@ -1700,14 +1684,14 @@ function CustomFormulaInput(props) {
|
|
|
1700
1684
|
error: formula1Res,
|
|
1701
1685
|
children: /* @__PURE__ */ jsx(FormulaEditor, {
|
|
1702
1686
|
ref: formulaEditorRef,
|
|
1703
|
-
className: clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-
|
|
1704
|
-
initValue: (
|
|
1687
|
+
className: clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", borderClassName),
|
|
1688
|
+
initValue: (value === null || value === void 0 ? void 0 : value.formula1) ?? "=",
|
|
1705
1689
|
unitId,
|
|
1706
1690
|
subUnitId,
|
|
1707
1691
|
isFocus: isFocusFormulaEditor,
|
|
1708
1692
|
isSupportAcrossSheet: true,
|
|
1709
1693
|
onChange: (newValue) => {
|
|
1710
|
-
const newFormula = (newValue
|
|
1694
|
+
const newFormula = (newValue ?? "").trim();
|
|
1711
1695
|
if (newFormula === (value === null || value === void 0 ? void 0 : value.formula1)) return;
|
|
1712
1696
|
onChange === null || onChange === void 0 || onChange({
|
|
1713
1697
|
...value,
|
|
@@ -1781,6 +1765,9 @@ const DEFAULT_COLOR_PRESET = [
|
|
|
1781
1765
|
const ColorSelect = (props) => {
|
|
1782
1766
|
const { value, onChange, disabled } = props;
|
|
1783
1767
|
const [open, setOpen] = useState(false);
|
|
1768
|
+
const themeService = useDependency(ThemeService);
|
|
1769
|
+
useObservable(themeService.currentTheme$);
|
|
1770
|
+
const backgroundColor = value.includes(".") && themeService.isValidThemeColor(value) ? themeService.getColorFromTheme(value) : value;
|
|
1784
1771
|
return /* @__PURE__ */ jsx(Dropdown, {
|
|
1785
1772
|
align: "start",
|
|
1786
1773
|
disabled,
|
|
@@ -1798,10 +1785,10 @@ const ColorSelect = (props) => {
|
|
|
1798
1785
|
}, color))
|
|
1799
1786
|
}),
|
|
1800
1787
|
children: /* @__PURE__ */ jsxs("div", {
|
|
1801
|
-
className: clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-
|
|
1788
|
+
className: clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-gray-0 univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0", borderClassName),
|
|
1802
1789
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1803
1790
|
className: "univer-box-border univer-size-4 univer-rounded univer-text-base",
|
|
1804
|
-
style: { background:
|
|
1791
|
+
style: { background: backgroundColor }
|
|
1805
1792
|
}), /* @__PURE__ */ jsx(MoreDownIcon, {})]
|
|
1806
1793
|
})
|
|
1807
1794
|
});
|
|
@@ -1886,7 +1873,7 @@ function ListFormulaInput(props) {
|
|
|
1886
1873
|
const strColors = formula2.split(",");
|
|
1887
1874
|
return strOptions.map((label, i) => ({
|
|
1888
1875
|
label,
|
|
1889
|
-
color: strColors[i] || "
|
|
1876
|
+
color: strColors[i] || "gray.100",
|
|
1890
1877
|
isRef: false,
|
|
1891
1878
|
id: generateRandomId(4)
|
|
1892
1879
|
}));
|
|
@@ -1907,7 +1894,7 @@ function ListFormulaInput(props) {
|
|
|
1907
1894
|
};
|
|
1908
1895
|
const refFinalList = useMemo(() => refOptions.map((label, i) => ({
|
|
1909
1896
|
label,
|
|
1910
|
-
color: refColors[i] || "
|
|
1897
|
+
color: refColors[i] || "gray.100",
|
|
1911
1898
|
id: `${i}`,
|
|
1912
1899
|
isRef: true
|
|
1913
1900
|
})), [refColors, refOptions]);
|
|
@@ -1997,7 +1984,7 @@ function ListFormulaInput(props) {
|
|
|
1997
1984
|
error: formula1Res || localError || void 0,
|
|
1998
1985
|
children: [/* @__PURE__ */ jsx(FormulaEditor, {
|
|
1999
1986
|
ref: formulaEditorRef,
|
|
2000
|
-
className: clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-
|
|
1987
|
+
className: clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", borderClassName),
|
|
2001
1988
|
initValue: formulaStr,
|
|
2002
1989
|
unitId,
|
|
2003
1990
|
subUnitId,
|
|
@@ -2005,7 +1992,7 @@ function ListFormulaInput(props) {
|
|
|
2005
1992
|
isSupportAcrossSheet: true,
|
|
2006
1993
|
onFocus: () => setIsFocusFormulaEditor(true),
|
|
2007
1994
|
onChange: (v = "") => {
|
|
2008
|
-
const str = (v
|
|
1995
|
+
const str = (v ?? "").trim();
|
|
2009
1996
|
setFormulaStrCopy(str);
|
|
2010
1997
|
updateFormula(str);
|
|
2011
1998
|
}
|
|
@@ -2056,13 +2043,12 @@ const FORMULA_INPUTS = [
|
|
|
2056
2043
|
//#region src/views/components/ListRenderModeInput.tsx
|
|
2057
2044
|
const LIST_RENDER_MODE_OPTION_INPUT = "LIST_RENDER_MODE_OPTION_INPUT";
|
|
2058
2045
|
function ListRenderModeInput(props) {
|
|
2059
|
-
var _value$renderMode;
|
|
2060
2046
|
const { value, onChange } = props;
|
|
2061
2047
|
const localeService = useDependency(LocaleService);
|
|
2062
2048
|
return /* @__PURE__ */ jsx(FormLayout, {
|
|
2063
2049
|
label: localeService.t("sheets-data-validation-ui.renderMode.label"),
|
|
2064
2050
|
children: /* @__PURE__ */ jsxs(RadioGroup, {
|
|
2065
|
-
value: `${
|
|
2051
|
+
value: `${value.renderMode ?? DataValidationRenderMode.CUSTOM}`,
|
|
2066
2052
|
onChange: (renderMode) => onChange({
|
|
2067
2053
|
...value,
|
|
2068
2054
|
renderMode: +renderMode
|
|
@@ -2221,52 +2207,36 @@ let DataValidationAutoFillController = class DataValidationAutoFillController ex
|
|
|
2221
2207
|
const ruleMatrixCopy = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
|
|
2222
2208
|
const virtualRange = virtualizeDiscreteRanges([sourceRange, targetRange]);
|
|
2223
2209
|
const [vSourceRange, vTargetRange] = virtualRange.ranges;
|
|
2224
|
-
const {
|
|
2225
|
-
const sourceStartCell = {
|
|
2226
|
-
row: vSourceRange.startRow,
|
|
2227
|
-
col: vSourceRange.startColumn
|
|
2228
|
-
};
|
|
2210
|
+
const { mapRange, projectRange } = virtualRange;
|
|
2229
2211
|
const repeats = AutoFillTools.getAutoFillRepeatRange(vSourceRange, vTargetRange);
|
|
2230
|
-
const
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
startRow: targetStartCell.row,
|
|
2243
|
-
startColumn: targetStartCell.col,
|
|
2244
|
-
endColumn: targetStartCell.col,
|
|
2245
|
-
endRow: targetStartCell.row
|
|
2246
|
-
};
|
|
2247
|
-
Range.foreach(relativeRange, (row, col) => {
|
|
2248
|
-
const sourcePositionRange = Rectangle.getPositionRange({
|
|
2249
|
-
startRow: row,
|
|
2250
|
-
startColumn: col,
|
|
2251
|
-
endColumn: col,
|
|
2252
|
-
endRow: row
|
|
2253
|
-
}, sourceRange);
|
|
2254
|
-
const { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn);
|
|
2255
|
-
const ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, sourceRow, sourceCol) || "";
|
|
2256
|
-
const targetPositionRange = Rectangle.getPositionRange({
|
|
2257
|
-
startRow: row,
|
|
2258
|
-
startColumn: col,
|
|
2259
|
-
endColumn: col,
|
|
2260
|
-
endRow: row
|
|
2261
|
-
}, targetRange);
|
|
2262
|
-
const { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn);
|
|
2263
|
-
additionMatrix.setValue(targetRow, targetCol, ruleId);
|
|
2264
|
-
additionRules.add(ruleId);
|
|
2212
|
+
const additionsByRuleId = /* @__PURE__ */ new Map();
|
|
2213
|
+
additionsByRuleId.set("", repeats.flatMap((repeat) => mapRange(Rectangle.getPositionRange(repeat.relativeRange, {
|
|
2214
|
+
startRow: repeat.repeatStartCell.row,
|
|
2215
|
+
endRow: repeat.repeatStartCell.row,
|
|
2216
|
+
startColumn: repeat.repeatStartCell.col,
|
|
2217
|
+
endColumn: repeat.repeatStartCell.col
|
|
2218
|
+
}))));
|
|
2219
|
+
this._sheetDataValidationModel.getRules(unitId, subUnitId).forEach((rule) => {
|
|
2220
|
+
const relativeSourceRanges = rule.ranges.flatMap((range) => {
|
|
2221
|
+
const projected = projectRange(range);
|
|
2222
|
+
const intersected = projected && getIntersectRange(projected, vSourceRange);
|
|
2223
|
+
return intersected ? [Rectangle.getRelativeRange(intersected, vSourceRange)] : [];
|
|
2265
2224
|
});
|
|
2225
|
+
const targetRanges = repeats.flatMap((repeat) => relativeSourceRanges.flatMap((sourceRange) => {
|
|
2226
|
+
const copiedRange = getIntersectRange(sourceRange, repeat.relativeRange);
|
|
2227
|
+
if (!copiedRange) return [];
|
|
2228
|
+
return mapRange(Rectangle.getPositionRange(copiedRange, {
|
|
2229
|
+
startRow: repeat.repeatStartCell.row,
|
|
2230
|
+
endRow: repeat.repeatStartCell.row,
|
|
2231
|
+
startColumn: repeat.repeatStartCell.col,
|
|
2232
|
+
endColumn: repeat.repeatStartCell.col
|
|
2233
|
+
}));
|
|
2234
|
+
}));
|
|
2235
|
+
if (targetRanges.length) additionsByRuleId.set(rule.uid, targetRanges);
|
|
2266
2236
|
});
|
|
2267
|
-
const additions = Array.from(
|
|
2237
|
+
const additions = Array.from(additionsByRuleId, ([id, ranges]) => ({
|
|
2268
2238
|
id,
|
|
2269
|
-
ranges:
|
|
2239
|
+
ranges: ranges.length > 1 ? Rectangle.mergeRanges(ranges) : ranges
|
|
2270
2240
|
}));
|
|
2271
2241
|
ruleMatrixCopy.addRangeRules(additions);
|
|
2272
2242
|
const { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, ruleMatrixCopy.diff(this._sheetDataValidationModel.getRules(unitId, subUnitId)), this._injector, "patched", applyType === AUTO_FILL_APPLY_TYPE.ONLY_FORMAT);
|
|
@@ -2279,13 +2249,8 @@ let DataValidationAutoFillController = class DataValidationAutoFillController ex
|
|
|
2279
2249
|
id: DATA_VALIDATION_PLUGIN_NAME,
|
|
2280
2250
|
onBeforeFillData: (location) => {
|
|
2281
2251
|
const { source: sourceRange, unitId, subUnitId } = location;
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
if (dv && dv.type === DataValidationType.CHECKBOX) {
|
|
2285
|
-
this._autoFillService.setDisableApplyType(AUTO_FILL_APPLY_TYPE.SERIES, true);
|
|
2286
|
-
return;
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2252
|
+
const { projectRange } = virtualizeDiscreteRanges([sourceRange]);
|
|
2253
|
+
if (this._sheetDataValidationModel.getRules(unitId, subUnitId).some((rule) => rule.type === DataValidationType.CHECKBOX && rule.ranges.some((range) => projectRange(range) !== null))) this._autoFillService.setDisableApplyType(AUTO_FILL_APPLY_TYPE.SERIES, true);
|
|
2289
2254
|
},
|
|
2290
2255
|
onFillData: (location, direction, applyType) => {
|
|
2291
2256
|
if (applyType === AUTO_FILL_APPLY_TYPE.COPY || applyType === AUTO_FILL_APPLY_TYPE.ONLY_FORMAT || applyType === AUTO_FILL_APPLY_TYPE.SERIES) return generalApplyFunc(location, applyType);
|
|
@@ -2334,25 +2299,31 @@ let DataValidationCopyPasteController = class DataValidationCopyPasteController
|
|
|
2334
2299
|
});
|
|
2335
2300
|
}
|
|
2336
2301
|
_collect(unitId, subUnitId, range) {
|
|
2337
|
-
const
|
|
2302
|
+
const rules = /* @__PURE__ */ new Map();
|
|
2338
2303
|
this._copyInfo = {
|
|
2339
2304
|
unitId,
|
|
2340
2305
|
subUnitId,
|
|
2341
|
-
|
|
2306
|
+
rules
|
|
2342
2307
|
};
|
|
2343
2308
|
const discreteRange = this._injector.invoke((accessor) => {
|
|
2344
2309
|
return rangeToDiscreteRange(range, accessor, unitId, subUnitId);
|
|
2345
2310
|
});
|
|
2346
2311
|
if (!discreteRange) return;
|
|
2347
|
-
const {
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
const
|
|
2351
|
-
|
|
2312
|
+
const { projectRange } = virtualizeDiscreteRanges([discreteRange]);
|
|
2313
|
+
this._sheetDataValidationModel.getRules(unitId, subUnitId).forEach((rule) => {
|
|
2314
|
+
const projectedRanges = rule.ranges.flatMap((ruleRange) => {
|
|
2315
|
+
const projected = projectRange(ruleRange);
|
|
2316
|
+
return projected ? [projected] : [];
|
|
2352
2317
|
});
|
|
2318
|
+
if (projectedRanges.length) rules.set(rule.uid, projectedRanges.length > 1 ? Rectangle.mergeRanges(projectedRanges) : projectedRanges);
|
|
2353
2319
|
});
|
|
2354
2320
|
}
|
|
2355
2321
|
_generateMutations(pasteFrom, pasteTo, payload) {
|
|
2322
|
+
const copyInfo = this._copyInfo;
|
|
2323
|
+
if (!copyInfo) return {
|
|
2324
|
+
redos: [],
|
|
2325
|
+
undos: []
|
|
2326
|
+
};
|
|
2356
2327
|
const { unitId: copyUnitId, subUnitId: copySubUnitId, range: copyRange } = pasteFrom;
|
|
2357
2328
|
const { unitId: pastedUnitId, subUnitId: pastedSubUnitId, range: pastedRange } = pasteTo;
|
|
2358
2329
|
const { copyType = COPY_TYPE.COPY } = payload;
|
|
@@ -2370,51 +2341,38 @@ let DataValidationCopyPasteController = class DataValidationCopyPasteController
|
|
|
2370
2341
|
undos: []
|
|
2371
2342
|
};
|
|
2372
2343
|
}
|
|
2344
|
+
const sourceVirtualRange = virtualizeDiscreteRanges([copyRange]).ranges[0];
|
|
2345
|
+
const targetVirtualization = virtualizeDiscreteRanges([pastedRange]);
|
|
2346
|
+
const targetVirtualRange = targetVirtualization.ranges[0];
|
|
2347
|
+
const repeatRange = getRepeatRange(sourceVirtualRange, targetVirtualRange, true);
|
|
2348
|
+
const clearTargetRanges = targetVirtualization.mapRange(targetVirtualRange);
|
|
2349
|
+
const getTargetRanges = (sourceRanges) => repeatRange.flatMap(({ startRange }) => sourceRanges.flatMap((sourceRange) => targetVirtualization.mapRange(Rectangle.getPositionRange(sourceRange, startRange))));
|
|
2373
2350
|
if (pastedUnitId !== copyUnitId || pastedSubUnitId !== copySubUnitId) {
|
|
2374
2351
|
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(pastedUnitId, pastedSubUnitId).clone();
|
|
2375
|
-
const additionMatrix = new ObjectMatrix();
|
|
2376
|
-
const addRules = /* @__PURE__ */ new Set();
|
|
2377
|
-
const { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyRange, pastedRange]);
|
|
2378
|
-
const repeatRange = getRepeatRange(vCopyRange, vPastedRange, true);
|
|
2379
2352
|
const additionRules = /* @__PURE__ */ new Map();
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
});
|
|
2395
|
-
const { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn);
|
|
2396
|
-
addRules.add(transformedRuleId);
|
|
2397
|
-
additionMatrix.setValue(startRow, startColumn, transformedRuleId);
|
|
2353
|
+
const additions = [{
|
|
2354
|
+
id: "",
|
|
2355
|
+
ranges: clearTargetRanges
|
|
2356
|
+
}];
|
|
2357
|
+
copyInfo.rules.forEach((ranges, ruleId) => {
|
|
2358
|
+
const transformedRuleId = `${copySubUnitId}-${ruleId}`;
|
|
2359
|
+
const oldRule = this._sheetDataValidationModel.getRuleById(copyUnitId, copySubUnitId, ruleId);
|
|
2360
|
+
if (!this._sheetDataValidationModel.getRuleById(pastedUnitId, pastedSubUnitId, transformedRuleId) && oldRule) additionRules.set(transformedRuleId, {
|
|
2361
|
+
...oldRule,
|
|
2362
|
+
uid: transformedRuleId
|
|
2363
|
+
});
|
|
2364
|
+
additions.push({
|
|
2365
|
+
id: transformedRuleId,
|
|
2366
|
+
ranges: getTargetRanges(ranges)
|
|
2398
2367
|
});
|
|
2399
2368
|
});
|
|
2400
|
-
const additions = Array.from(addRules).map((id) => ({
|
|
2401
|
-
id,
|
|
2402
|
-
ranges: queryObjectMatrix(additionMatrix, (value) => value === id)
|
|
2403
|
-
}));
|
|
2404
2369
|
ruleMatrix.addRangeRules(additions);
|
|
2405
2370
|
const { redoMutations, undoMutations } = getDataValidationDiffMutations(pastedUnitId, pastedSubUnitId, ruleMatrix.diffWithAddition(this._sheetDataValidationModel.getRules(pastedUnitId, pastedSubUnitId), additionRules.values()), this._injector, "patched", false);
|
|
2406
2371
|
if (copyType === COPY_TYPE.CUT) {
|
|
2407
2372
|
const copySheetRuleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(copyUnitId, copySubUnitId).clone();
|
|
2408
|
-
const deleteRangeStartCell = mapFunc(vCopyRange.startRow, vCopyRange.startColumn);
|
|
2409
|
-
const deleteRangeEndCell = mapFunc(vCopyRange.endRow, vCopyRange.endColumn);
|
|
2410
2373
|
copySheetRuleMatrix.addRangeRules([{
|
|
2411
2374
|
id: "",
|
|
2412
|
-
ranges: [
|
|
2413
|
-
startRow: deleteRangeStartCell.row,
|
|
2414
|
-
endRow: deleteRangeEndCell.row,
|
|
2415
|
-
startColumn: deleteRangeStartCell.col,
|
|
2416
|
-
endColumn: deleteRangeEndCell.col
|
|
2417
|
-
}]
|
|
2375
|
+
ranges: virtualizeDiscreteRanges([copyRange]).mapRange(sourceVirtualRange)
|
|
2418
2376
|
}]);
|
|
2419
2377
|
const { redoMutations: cutRedos, undoMutations: cutUndos } = getDataValidationDiffMutations(copyUnitId, copySubUnitId, copySheetRuleMatrix.diff(this._sheetDataValidationModel.getRules(copyUnitId, copySubUnitId)), this._injector, "patched", false);
|
|
2420
2378
|
redoMutations.push(...cutRedos);
|
|
@@ -2426,27 +2384,13 @@ let DataValidationCopyPasteController = class DataValidationCopyPasteController
|
|
|
2426
2384
|
};
|
|
2427
2385
|
} else {
|
|
2428
2386
|
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(copyUnitId, copySubUnitId).clone();
|
|
2429
|
-
const
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
var _this$_copyInfo2;
|
|
2434
|
-
(_this$_copyInfo2 = this._copyInfo) === null || _this$_copyInfo2 === void 0 || _this$_copyInfo2.matrix.forValue((row, col, ruleId) => {
|
|
2435
|
-
const range = Rectangle.getPositionRange({
|
|
2436
|
-
startRow: row,
|
|
2437
|
-
endRow: row,
|
|
2438
|
-
startColumn: col,
|
|
2439
|
-
endColumn: col
|
|
2440
|
-
}, startRange);
|
|
2441
|
-
const { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn);
|
|
2442
|
-
additionMatrix.setValue(startRow, startColumn, ruleId);
|
|
2443
|
-
additionRules.add(ruleId);
|
|
2444
|
-
});
|
|
2445
|
-
});
|
|
2446
|
-
const additions = Array.from(additionRules).map((id) => ({
|
|
2387
|
+
const additions = [{
|
|
2388
|
+
id: "",
|
|
2389
|
+
ranges: clearTargetRanges
|
|
2390
|
+
}, ...Array.from(copyInfo.rules, ([id, ranges]) => ({
|
|
2447
2391
|
id,
|
|
2448
|
-
ranges:
|
|
2449
|
-
}));
|
|
2392
|
+
ranges: getTargetRanges(ranges)
|
|
2393
|
+
}))];
|
|
2450
2394
|
ruleMatrix.addRangeRules(additions);
|
|
2451
2395
|
const { redoMutations, undoMutations } = getDataValidationDiffMutations(pastedUnitId, pastedSubUnitId, ruleMatrix.diff(this._sheetDataValidationModel.getRules(copyUnitId, copySubUnitId)), this._injector, "patched", false);
|
|
2452
2396
|
return {
|
|
@@ -2570,32 +2514,30 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
2570
2514
|
effect: InterceptorEffectEnum.Style,
|
|
2571
2515
|
priority: InterceptCellContentPriority.DATA_VALIDATION,
|
|
2572
2516
|
handler: (cell, pos, next) => {
|
|
2573
|
-
var
|
|
2517
|
+
var _cell$fontRenderExten, _validator$skipDefaul;
|
|
2574
2518
|
const { row, col, unitId, subUnitId, workbook, worksheet } = pos;
|
|
2575
2519
|
const ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
2576
2520
|
if (!ruleId) return next(cell);
|
|
2577
2521
|
const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
2578
2522
|
if (!rule) return next(cell);
|
|
2579
|
-
const validStatus =
|
|
2523
|
+
const validStatus = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col) ?? DataValidationStatus.VALID;
|
|
2580
2524
|
const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
|
|
2581
2525
|
const cellOrigin = pos.rawData;
|
|
2582
2526
|
let cache;
|
|
2583
2527
|
const cellValue = { get value() {
|
|
2584
|
-
var _getCellValueOrigin;
|
|
2585
2528
|
if (cache !== void 0) return cache;
|
|
2586
|
-
cache =
|
|
2529
|
+
cache = getCellValueOrigin(cellOrigin) ?? null;
|
|
2587
2530
|
return cache;
|
|
2588
2531
|
} };
|
|
2589
2532
|
const valueStr = { get value() {
|
|
2590
|
-
|
|
2591
|
-
return `${(_cellValue$value = cellValue.value) !== null && _cellValue$value !== void 0 ? _cellValue$value : ""}`;
|
|
2533
|
+
return `${cellValue.value ?? ""}`;
|
|
2592
2534
|
} };
|
|
2593
2535
|
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
2594
2536
|
cell.markers = {
|
|
2595
2537
|
...cell === null || cell === void 0 ? void 0 : cell.markers,
|
|
2596
2538
|
...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
|
|
2597
2539
|
};
|
|
2598
|
-
cell.customRender = [...(
|
|
2540
|
+
cell.customRender = [...(cell === null || cell === void 0 ? void 0 : cell.customRender) ?? [], ...(validator === null || validator === void 0 ? void 0 : validator.canvasRender) ? [validator.canvasRender] : []];
|
|
2599
2541
|
cell.fontRenderExtension = {
|
|
2600
2542
|
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
2601
2543
|
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))
|
|
@@ -2608,14 +2550,14 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
2608
2550
|
} }, row, col)
|
|
2609
2551
|
};
|
|
2610
2552
|
cell.interceptorAutoHeight = () => {
|
|
2611
|
-
var _this$_renderManagerS,
|
|
2553
|
+
var _this$_renderManagerS, _validator$canvasRend, _validator$canvasRend2;
|
|
2612
2554
|
const skeleton = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 || (_this$_renderManagerS = _this$_renderManagerS.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.skeleton;
|
|
2613
2555
|
if (!skeleton) return;
|
|
2614
2556
|
const mergeCell = skeleton.worksheet.getMergedCell(row, col);
|
|
2615
2557
|
const info = {
|
|
2616
2558
|
data: cell,
|
|
2617
2559
|
style: workbook.getStyles().getStyleByCell(cell),
|
|
2618
|
-
primaryWithCoord: skeleton.getCellWithCoordByIndex((
|
|
2560
|
+
primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
|
|
2619
2561
|
unitId,
|
|
2620
2562
|
subUnitId,
|
|
2621
2563
|
row,
|
|
@@ -2626,14 +2568,14 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
2626
2568
|
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);
|
|
2627
2569
|
};
|
|
2628
2570
|
cell.interceptorAutoWidth = () => {
|
|
2629
|
-
var _this$_renderManagerS2,
|
|
2571
|
+
var _this$_renderManagerS2, _validator$canvasRend3, _validator$canvasRend4;
|
|
2630
2572
|
const skeleton = (_this$_renderManagerS2 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS2 === void 0 || (_this$_renderManagerS2 = _this$_renderManagerS2.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.skeleton;
|
|
2631
2573
|
if (!skeleton) return;
|
|
2632
2574
|
const mergeCell = skeleton.worksheet.getMergedCell(row, col);
|
|
2633
2575
|
const info = {
|
|
2634
2576
|
data: cell,
|
|
2635
2577
|
style: workbook.getStyles().getStyleByCell(cell),
|
|
2636
|
-
primaryWithCoord: skeleton.getCellWithCoordByIndex((
|
|
2578
|
+
primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
|
|
2637
2579
|
unitId,
|
|
2638
2580
|
subUnitId,
|
|
2639
2581
|
row,
|
|
@@ -2643,7 +2585,7 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
2643
2585
|
};
|
|
2644
2586
|
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);
|
|
2645
2587
|
};
|
|
2646
|
-
cell.coverable = ((
|
|
2588
|
+
cell.coverable = ((cell === null || cell === void 0 ? void 0 : cell.coverable) ?? true) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE);
|
|
2647
2589
|
return next(cell);
|
|
2648
2590
|
}
|
|
2649
2591
|
}));
|
|
@@ -2693,22 +2635,22 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
|
|
|
2693
2635
|
effect: InterceptorEffectEnum.Style,
|
|
2694
2636
|
priority: InterceptCellContentPriority.DATA_VALIDATION,
|
|
2695
2637
|
handler: (cell, pos, next) => {
|
|
2696
|
-
var
|
|
2638
|
+
var _cell$fontRenderExten2, _validator$skipDefaul2;
|
|
2697
2639
|
const { row, col, unitId, subUnitId, workbook, worksheet } = pos;
|
|
2698
2640
|
const ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
2699
2641
|
if (!ruleId) return next(cell);
|
|
2700
2642
|
const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
2701
2643
|
if (!rule) return next(cell);
|
|
2702
|
-
const validStatus =
|
|
2644
|
+
const validStatus = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col) ?? DataValidationStatus.VALID;
|
|
2703
2645
|
const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
|
|
2704
2646
|
const cellValue = getCellValueOrigin(worksheet.getCellRaw(row, col));
|
|
2705
|
-
const valueStr = `${cellValue
|
|
2647
|
+
const valueStr = `${cellValue ?? ""}`;
|
|
2706
2648
|
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
2707
2649
|
cell.markers = {
|
|
2708
2650
|
...cell === null || cell === void 0 ? void 0 : cell.markers,
|
|
2709
2651
|
...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
|
|
2710
2652
|
};
|
|
2711
|
-
cell.customRender = [...(
|
|
2653
|
+
cell.customRender = [...(cell === null || cell === void 0 ? void 0 : cell.customRender) ?? [], ...(validator === null || validator === void 0 ? void 0 : validator.canvasRender) ? [validator.canvasRender] : []];
|
|
2712
2654
|
cell.fontRenderExtension = {
|
|
2713
2655
|
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
2714
2656
|
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))
|
|
@@ -2721,14 +2663,14 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
|
|
|
2721
2663
|
} }, row, col)
|
|
2722
2664
|
};
|
|
2723
2665
|
cell.interceptorAutoHeight = () => {
|
|
2724
|
-
var _this$_renderManagerS3,
|
|
2666
|
+
var _this$_renderManagerS3, _validator$canvasRend5, _validator$canvasRend6;
|
|
2725
2667
|
const skeleton = (_this$_renderManagerS3 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS3 === void 0 || (_this$_renderManagerS3 = _this$_renderManagerS3.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS3 === void 0 ? void 0 : _this$_renderManagerS3.skeleton;
|
|
2726
2668
|
if (!skeleton) return;
|
|
2727
2669
|
const mergeCell = skeleton.worksheet.getMergedCell(row, col);
|
|
2728
2670
|
const info = {
|
|
2729
2671
|
data: cell,
|
|
2730
2672
|
style: workbook.getStyles().getStyleByCell(cell),
|
|
2731
|
-
primaryWithCoord: skeleton.getCellWithCoordByIndex((
|
|
2673
|
+
primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
|
|
2732
2674
|
unitId,
|
|
2733
2675
|
subUnitId,
|
|
2734
2676
|
row,
|
|
@@ -2739,14 +2681,14 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
|
|
|
2739
2681
|
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);
|
|
2740
2682
|
};
|
|
2741
2683
|
cell.interceptorAutoWidth = () => {
|
|
2742
|
-
var _this$_renderManagerS4,
|
|
2684
|
+
var _this$_renderManagerS4, _validator$canvasRend7, _validator$canvasRend8;
|
|
2743
2685
|
const skeleton = (_this$_renderManagerS4 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS4 === void 0 || (_this$_renderManagerS4 = _this$_renderManagerS4.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS4 === void 0 ? void 0 : _this$_renderManagerS4.skeleton;
|
|
2744
2686
|
if (!skeleton) return;
|
|
2745
2687
|
const mergeCell = skeleton.worksheet.getMergedCell(row, col);
|
|
2746
2688
|
const info = {
|
|
2747
2689
|
data: cell,
|
|
2748
2690
|
style: workbook.getStyles().getStyleByCell(cell),
|
|
2749
|
-
primaryWithCoord: skeleton.getCellWithCoordByIndex((
|
|
2691
|
+
primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
|
|
2750
2692
|
unitId,
|
|
2751
2693
|
subUnitId,
|
|
2752
2694
|
row,
|
|
@@ -2756,7 +2698,7 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
|
|
|
2756
2698
|
};
|
|
2757
2699
|
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);
|
|
2758
2700
|
};
|
|
2759
|
-
cell.coverable = ((
|
|
2701
|
+
cell.coverable = ((cell === null || cell === void 0 ? void 0 : cell.coverable) ?? true) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE);
|
|
2760
2702
|
return next(cell);
|
|
2761
2703
|
}
|
|
2762
2704
|
}));
|
|
@@ -2818,11 +2760,10 @@ SheetsDataValidationReRenderController = __decorate([__decorateParam(1, Inject(S
|
|
|
2818
2760
|
const MARGIN_H$2 = 6;
|
|
2819
2761
|
let CheckboxRender = class CheckboxRender {
|
|
2820
2762
|
_calc(cellInfo, style) {
|
|
2821
|
-
var _style$fs, _style$fs2, _style$fs3;
|
|
2822
2763
|
const { vt, ht } = style || {};
|
|
2823
2764
|
const width = cellInfo.endX - cellInfo.startX - MARGIN_H$2 * 2;
|
|
2824
2765
|
const height = cellInfo.endY - cellInfo.startY;
|
|
2825
|
-
const size = ((
|
|
2766
|
+
const size = ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
|
|
2826
2767
|
let widgetLeft = 0;
|
|
2827
2768
|
let widgetTop = 0;
|
|
2828
2769
|
switch (vt) {
|
|
@@ -2850,8 +2791,8 @@ let CheckboxRender = class CheckboxRender {
|
|
|
2850
2791
|
return {
|
|
2851
2792
|
left: cellInfo.startX + widgetLeft,
|
|
2852
2793
|
top: cellInfo.startY + widgetTop,
|
|
2853
|
-
width: ((
|
|
2854
|
-
height: ((
|
|
2794
|
+
width: ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6,
|
|
2795
|
+
height: ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6
|
|
2855
2796
|
};
|
|
2856
2797
|
}
|
|
2857
2798
|
constructor(_commandService, _univerInstanceService, _formulaService, _themeService, _renderManagerService, _dataValidationModel) {
|
|
@@ -2863,14 +2804,12 @@ let CheckboxRender = class CheckboxRender {
|
|
|
2863
2804
|
this._dataValidationModel = _dataValidationModel;
|
|
2864
2805
|
}
|
|
2865
2806
|
calcCellAutoHeight(info) {
|
|
2866
|
-
var _style$fs4;
|
|
2867
2807
|
const { style } = info;
|
|
2868
|
-
return ((
|
|
2808
|
+
return ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
|
|
2869
2809
|
}
|
|
2870
2810
|
calcCellAutoWidth(info) {
|
|
2871
|
-
var _style$fs5;
|
|
2872
2811
|
const { style } = info;
|
|
2873
|
-
return ((
|
|
2812
|
+
return ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
|
|
2874
2813
|
}
|
|
2875
2814
|
async _parseFormula(rule, unitId, subUnitId) {
|
|
2876
2815
|
var _results$, _results$2, _results$3;
|
|
@@ -2886,7 +2825,7 @@ let CheckboxRender = class CheckboxRender {
|
|
|
2886
2825
|
};
|
|
2887
2826
|
}
|
|
2888
2827
|
drawWith(ctx, info) {
|
|
2889
|
-
var _validator$skipDefaul, _style$
|
|
2828
|
+
var _validator$skipDefaul, _style$cl;
|
|
2890
2829
|
const { style, primaryWithCoord, unitId, subUnitId, worksheet, row, col } = info;
|
|
2891
2830
|
const cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
2892
2831
|
const value = getCellValueOrigin(worksheet.getCellRaw(row, col));
|
|
@@ -2924,14 +2863,14 @@ let CheckboxRender = class CheckboxRender {
|
|
|
2924
2863
|
ctx.clip();
|
|
2925
2864
|
const m = transform.getMatrix();
|
|
2926
2865
|
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
2927
|
-
const size = ((
|
|
2866
|
+
const size = ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
|
|
2928
2867
|
const checked = String(value) === String(formula1);
|
|
2929
2868
|
const defaultColor = this._themeService.getColorFromTheme("primary.600");
|
|
2930
2869
|
CheckboxShape.drawWith(ctx, {
|
|
2931
2870
|
checked,
|
|
2932
2871
|
width: size,
|
|
2933
2872
|
height: size,
|
|
2934
|
-
fill: (
|
|
2873
|
+
fill: (style === null || style === void 0 || (_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? defaultColor
|
|
2935
2874
|
});
|
|
2936
2875
|
ctx.restore();
|
|
2937
2876
|
}
|
|
@@ -3187,7 +3126,7 @@ var Dropdown$1 = class extends Shape {
|
|
|
3187
3126
|
width: layout.width,
|
|
3188
3127
|
height: layout.height,
|
|
3189
3128
|
radius: RADIUS,
|
|
3190
|
-
fill: fill || "
|
|
3129
|
+
fill: fill || "gray.100"
|
|
3191
3130
|
});
|
|
3192
3131
|
ctx.translateWithPrecision(4, layout.ba);
|
|
3193
3132
|
ctx.font = fontString;
|
|
@@ -3234,12 +3173,11 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
3234
3173
|
}
|
|
3235
3174
|
ctx.save();
|
|
3236
3175
|
ctx.translateWithPrecision(cellBounding.startX + left, cellBounding.startY + top);
|
|
3237
|
-
ctx.fillStyle =
|
|
3176
|
+
ctx.fillStyle = DROP_DOWN_ICON_COLOR;
|
|
3238
3177
|
ctx.fill(downPath$1);
|
|
3239
3178
|
ctx.restore();
|
|
3240
3179
|
}
|
|
3241
3180
|
drawWith(ctx, info, skeleton, spreadsheets) {
|
|
3242
|
-
var _ref, _getCellValueOrigin;
|
|
3243
3181
|
const { primaryWithCoord, row, col, style, data, subUnitId } = info;
|
|
3244
3182
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
3245
3183
|
const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
|
|
@@ -3260,11 +3198,11 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
3260
3198
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
3261
3199
|
const cellHeight = cellBounding.endY - cellBounding.startY;
|
|
3262
3200
|
const { cl } = style || {};
|
|
3263
|
-
const color = (
|
|
3264
|
-
const fontStyle = getFontStyleString(style
|
|
3201
|
+
const color = (typeof cl === "object" ? cl === null || cl === void 0 ? void 0 : cl.rgb : cl) ?? "#000";
|
|
3202
|
+
const fontStyle = getFontStyleString(style ?? void 0);
|
|
3265
3203
|
const { vt: _vt, ht } = style || {};
|
|
3266
|
-
const vt = _vt
|
|
3267
|
-
const cellValue =
|
|
3204
|
+
const vt = _vt ?? VerticalAlign.MIDDLE;
|
|
3205
|
+
const cellValue = getCellValueOrigin(data) ?? "";
|
|
3268
3206
|
const items = validator.parseCellValue(cellValue);
|
|
3269
3207
|
const labelColorMap = validator.getListWithColorMap(rule);
|
|
3270
3208
|
const layout = layoutDropdowns(items, fontStyle, cellWidth, cellHeight);
|
|
@@ -3322,7 +3260,6 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
3322
3260
|
});
|
|
3323
3261
|
}
|
|
3324
3262
|
calcCellAutoHeight(info) {
|
|
3325
|
-
var _getCellValueOrigin2;
|
|
3326
3263
|
const { primaryWithCoord, style, data, row, col } = info;
|
|
3327
3264
|
const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
|
|
3328
3265
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
@@ -3338,11 +3275,10 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
3338
3275
|
if (!validator) return;
|
|
3339
3276
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
3340
3277
|
const cellHeight = cellBounding.endY - cellBounding.startY;
|
|
3341
|
-
const cellValue =
|
|
3342
|
-
return layoutDropdowns(validator.parseCellValue(cellValue), getFontStyleString(style
|
|
3278
|
+
const cellValue = getCellValueOrigin(data) ?? "";
|
|
3279
|
+
return layoutDropdowns(validator.parseCellValue(cellValue), getFontStyleString(style ?? void 0), cellWidth, cellHeight).cellAutoHeight;
|
|
3343
3280
|
}
|
|
3344
3281
|
calcCellAutoWidth(info) {
|
|
3345
|
-
var _getCellValueOrigin3;
|
|
3346
3282
|
const { primaryWithCoord, style, data, row, col } = info;
|
|
3347
3283
|
const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
|
|
3348
3284
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
@@ -3358,8 +3294,8 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
|
|
|
3358
3294
|
if (!validator) return;
|
|
3359
3295
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
3360
3296
|
const cellHeight = cellBounding.endY - cellBounding.startY;
|
|
3361
|
-
const cellValue =
|
|
3362
|
-
return layoutDropdowns(validator.parseCellValue(cellValue), getFontStyleString(style
|
|
3297
|
+
const cellValue = getCellValueOrigin(data) ?? "";
|
|
3298
|
+
return layoutDropdowns(validator.parseCellValue(cellValue), getFontStyleString(style ?? void 0), cellWidth, cellHeight).calcAutoWidth;
|
|
3363
3299
|
}
|
|
3364
3300
|
isHit(position, info) {
|
|
3365
3301
|
const { primaryWithCoord } = info;
|
|
@@ -3436,7 +3372,6 @@ const PADDING_V = 1;
|
|
|
3436
3372
|
const MARGIN_H = 6;
|
|
3437
3373
|
const MARGIN_V = 3;
|
|
3438
3374
|
const RADIUS_BG = 8;
|
|
3439
|
-
const DROP_DOWN_ICON_COLOR = "#565656";
|
|
3440
3375
|
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");
|
|
3441
3376
|
function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margin = true) {
|
|
3442
3377
|
let paddingTop = 0;
|
|
@@ -3507,12 +3442,11 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3507
3442
|
}
|
|
3508
3443
|
ctx.save();
|
|
3509
3444
|
ctx.translateWithPrecision(cellBounding.startX + left, cellBounding.startY + top);
|
|
3510
|
-
ctx.fillStyle =
|
|
3445
|
+
ctx.fillStyle = DROP_DOWN_ICON_COLOR;
|
|
3511
3446
|
ctx.fill(downPath);
|
|
3512
3447
|
ctx.restore();
|
|
3513
3448
|
}
|
|
3514
3449
|
drawWith(ctx, info, skeleton) {
|
|
3515
|
-
var _tb, _vt, _ht, _pd;
|
|
3516
3450
|
const { primaryWithCoord, row, col, style, data, subUnitId } = info;
|
|
3517
3451
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
3518
3452
|
const _row = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo.startRow : row;
|
|
@@ -3535,14 +3469,13 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3535
3469
|
const map = this._ensureMap(subUnitId);
|
|
3536
3470
|
const key = this._generateKey(row, col);
|
|
3537
3471
|
const colorMap = validator.getListWithColorMap(rule);
|
|
3538
|
-
const
|
|
3539
|
-
const valueStr = `${value !== null && value !== void 0 ? value : ""}`;
|
|
3472
|
+
const valueStr = `${getCellValueOrigin(data) ?? ""}`;
|
|
3540
3473
|
const activeColor = colorMap[valueStr];
|
|
3541
3474
|
let { tb, vt, ht, pd } = style || {};
|
|
3542
|
-
tb =
|
|
3543
|
-
vt =
|
|
3544
|
-
ht =
|
|
3545
|
-
pd =
|
|
3475
|
+
tb = tb ?? WrapStrategy.WRAP;
|
|
3476
|
+
vt = vt ?? VerticalAlign.BOTTOM;
|
|
3477
|
+
ht = ht ?? DEFAULT_STYLES.ht;
|
|
3478
|
+
pd = pd ?? DEFAULT_STYLES.pd;
|
|
3546
3479
|
const fontStyle = getFontStyleString(style).fontCache;
|
|
3547
3480
|
if (rule.renderMode === DataValidationRenderMode.ARROW) {
|
|
3548
3481
|
var _style$cl, _style$st, _style$ul;
|
|
@@ -3603,7 +3536,7 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3603
3536
|
Rect.drawWith(ctx, {
|
|
3604
3537
|
width: rectWidth,
|
|
3605
3538
|
height: rectHeight,
|
|
3606
|
-
fill: activeColor || "
|
|
3539
|
+
fill: activeColor || "gray.100",
|
|
3607
3540
|
radius: RADIUS_BG
|
|
3608
3541
|
});
|
|
3609
3542
|
ctx.save();
|
|
@@ -3636,7 +3569,6 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3636
3569
|
}
|
|
3637
3570
|
}
|
|
3638
3571
|
calcCellAutoHeight(info) {
|
|
3639
|
-
var _tb2;
|
|
3640
3572
|
const { primaryWithCoord, style, data, row, col } = info;
|
|
3641
3573
|
const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
3642
3574
|
const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
|
|
@@ -3650,13 +3582,12 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3650
3582
|
endY: _cellBounding.endY - downOffset
|
|
3651
3583
|
};
|
|
3652
3584
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
3653
|
-
const
|
|
3654
|
-
const valueStr = `${value !== null && value !== void 0 ? value : ""}`;
|
|
3585
|
+
const valueStr = `${getCellValueOrigin(data) ?? ""}`;
|
|
3655
3586
|
let { tb, pd } = style || {};
|
|
3656
|
-
const { t = DEFAULT_STYLES.pd.t, b = DEFAULT_STYLES.pd.b } = pd
|
|
3657
|
-
tb =
|
|
3587
|
+
const { t = DEFAULT_STYLES.pd.t, b = DEFAULT_STYLES.pd.b } = pd ?? {};
|
|
3588
|
+
tb = tb ?? WrapStrategy.WRAP;
|
|
3658
3589
|
if (rule.renderMode === DataValidationRenderMode.ARROW) {
|
|
3659
|
-
const { l = DEFAULT_STYLES.pd.l, r = DEFAULT_STYLES.pd.r } = pd
|
|
3590
|
+
const { l = DEFAULT_STYLES.pd.l, r = DEFAULT_STYLES.pd.r } = pd ?? {};
|
|
3660
3591
|
const realWidth = cellWidth - l - r - ICON_PLACE - 4;
|
|
3661
3592
|
const skeleton = new DocSimpleSkeleton(valueStr, getFontStyleString(style).fontCache, Boolean(tb === WrapStrategy.WRAP), realWidth, Infinity);
|
|
3662
3593
|
skeleton.calculate();
|
|
@@ -3669,7 +3600,6 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3669
3600
|
}
|
|
3670
3601
|
}
|
|
3671
3602
|
calcCellAutoWidth(info) {
|
|
3672
|
-
var _tb3;
|
|
3673
3603
|
const { primaryWithCoord, style, data, row, col } = info;
|
|
3674
3604
|
const cellRange = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
|
|
3675
3605
|
const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
|
|
@@ -3683,11 +3613,10 @@ let DropdownWidget = class DropdownWidget {
|
|
|
3683
3613
|
endY: cellRange.endY - downOffset
|
|
3684
3614
|
};
|
|
3685
3615
|
const cellWidth = cellBounding.endX - cellBounding.startX;
|
|
3686
|
-
const
|
|
3687
|
-
const valueStr = `${value !== null && value !== void 0 ? value : ""}`;
|
|
3616
|
+
const valueStr = `${getCellValueOrigin(data) ?? ""}`;
|
|
3688
3617
|
let { tb, pd } = style || {};
|
|
3689
|
-
const { l = DEFAULT_STYLES.pd.l, r = DEFAULT_STYLES.pd.r } = pd
|
|
3690
|
-
tb =
|
|
3618
|
+
const { l = DEFAULT_STYLES.pd.l, r = DEFAULT_STYLES.pd.r } = pd ?? {};
|
|
3619
|
+
tb = tb ?? WrapStrategy.WRAP;
|
|
3691
3620
|
let paddingAll = 26;
|
|
3692
3621
|
switch (rule.renderMode) {
|
|
3693
3622
|
case DataValidationRenderMode.ARROW:
|
|
@@ -3966,7 +3895,7 @@ _defineProperty(UniverSheetsDataValidationUIPlugin, "packageName", name);
|
|
|
3966
3895
|
_defineProperty(UniverSheetsDataValidationUIPlugin, "version", version);
|
|
3967
3896
|
_defineProperty(UniverSheetsDataValidationUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
3968
3897
|
UniverSheetsDataValidationUIPlugin = __decorate([
|
|
3969
|
-
DependentOn(UniverDataValidationPlugin, UniverRenderEnginePlugin, UniverSheetsPlugin,
|
|
3898
|
+
DependentOn(UniverDataValidationPlugin, UniverRenderEnginePlugin, UniverSheetsPlugin, UniverSheetsUIPlugin, UniverSheetsDataValidationPlugin),
|
|
3970
3899
|
__decorateParam(1, Inject(Injector)),
|
|
3971
3900
|
__decorateParam(2, ICommandService),
|
|
3972
3901
|
__decorateParam(3, IConfigService)
|