@univerjs/sheets-data-validation-ui 0.17.0 → 0.18.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 +48 -2
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +48 -3241
- package/lib/es/locale/ca-ES.js +1 -182
- package/lib/es/locale/en-US.js +1 -182
- package/lib/es/locale/es-ES.js +1 -182
- package/lib/es/locale/fa-IR.js +1 -182
- package/lib/es/locale/fr-FR.js +1 -182
- package/lib/es/locale/ja-JP.js +1 -182
- package/lib/es/locale/ko-KR.js +1 -182
- package/lib/es/locale/ru-RU.js +1 -182
- package/lib/es/locale/sk-SK.js +1 -182
- package/lib/es/locale/vi-VN.js +1 -182
- package/lib/es/locale/zh-CN.js +1 -184
- package/lib/es/locale/zh-TW.js +1 -182
- package/lib/index.css +317 -1
- package/lib/index.js +48 -3241
- package/lib/locale/ca-ES.js +1 -182
- package/lib/locale/en-US.js +1 -182
- package/lib/locale/es-ES.js +1 -182
- package/lib/locale/fa-IR.js +1 -182
- package/lib/locale/fr-FR.js +1 -182
- package/lib/locale/ja-JP.js +1 -182
- package/lib/locale/ko-KR.js +1 -182
- package/lib/locale/ru-RU.js +1 -182
- package/lib/locale/sk-SK.js +1 -182
- package/lib/locale/vi-VN.js +1 -182
- package/lib/locale/zh-CN.js +1 -184
- package/lib/locale/zh-TW.js +1 -182
- package/lib/types/commands/commands/data-validation-ui.command.d.ts +16 -1
- package/lib/types/commands/operations/data-validation.operation.d.ts +16 -1
- package/lib/types/config/config.d.ts +16 -1
- package/lib/types/controllers/dv-alert.controller.d.ts +15 -0
- package/lib/types/controllers/dv-auto-fill.controller.d.ts +15 -0
- package/lib/types/controllers/dv-copy-paste.controller.d.ts +15 -0
- package/lib/types/controllers/dv-permission.controller.d.ts +15 -0
- package/lib/types/controllers/dv-reject-input.controller.d.ts +15 -0
- package/lib/types/controllers/dv-render.controller.d.ts +15 -0
- package/lib/types/controllers/dv-rerender.controller.d.ts +18 -2
- package/lib/types/controllers/dv-ui.controller.d.ts +15 -0
- package/lib/types/locale/ca-ES.d.ts +16 -1
- package/lib/types/locale/es-ES.d.ts +16 -1
- package/lib/types/locale/fa-IR.d.ts +16 -1
- package/lib/types/locale/fr-FR.d.ts +16 -1
- package/lib/types/locale/ja-JP.d.ts +16 -1
- package/lib/types/locale/ko-KR.d.ts +16 -1
- package/lib/types/locale/ru-RU.d.ts +16 -1
- package/lib/types/locale/sk-SK.d.ts +16 -1
- package/lib/types/locale/vi-VN.d.ts +16 -1
- package/lib/types/locale/zh-CN.d.ts +16 -1
- package/lib/types/locale/zh-TW.d.ts +16 -1
- package/lib/types/menu/dv.menu.d.ts +17 -2
- package/lib/types/menu/schema.d.ts +16 -1
- package/lib/types/mobile-plugin.d.ts +16 -1
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/data-validation-panel.service.d.ts +19 -3
- package/lib/types/services/dropdown-manager.service.d.ts +20 -3
- package/lib/types/views/components/formula-input/BaseFormulaInput.d.ts +16 -1
- package/lib/types/views/components/formula-input/CheckboxFormulaInput.d.ts +16 -1
- package/lib/types/views/components/formula-input/CustomFormulaInput.d.ts +16 -1
- package/lib/types/views/components/formula-input/ListFormulaInput.d.ts +16 -1
- package/lib/types/views/components/formula-input/formula-input.d.ts +16 -1
- package/lib/types/views/components/formula-input/index.d.ts +16 -1
- package/lib/types/views/components/item/index.d.ts +16 -1
- package/lib/types/views/components/list/index.d.ts +16 -1
- package/lib/types/views/components/options/index.d.ts +16 -1
- package/lib/types/views/components/render-mode/index.d.ts +16 -1
- package/lib/types/views/components/show-time/index.d.ts +16 -1
- package/lib/types/views/validator-views/checkbox-validator-view.d.ts +15 -0
- package/lib/types/views/validator-views/custom-validator-view.d.ts +15 -0
- package/lib/types/views/validator-views/date-validator-view.d.ts +15 -0
- package/lib/types/views/validator-views/decimal-validator-view.d.ts +15 -0
- package/lib/types/views/validator-views/list-multiple-view.d.ts +15 -0
- package/lib/types/views/validator-views/list-validator-view.d.ts +19 -2
- package/lib/types/views/validator-views/sheet-validator-view.d.ts +18 -2
- package/lib/types/views/validator-views/text-length-validator.view.d.ts +15 -0
- package/lib/types/views/validator-views/whole-validator-view.d.ts +15 -0
- package/lib/types/views/widgets/checkbox-widget.d.ts +20 -3
- package/lib/types/views/widgets/dropdown-multiple-widget.d.ts +20 -3
- package/lib/types/views/widgets/dropdown-widget.d.ts +20 -3
- package/lib/types/views/widgets/shape/dropdown.d.ts +18 -2
- package/lib/types/views/widgets/shape/layout.d.ts +18 -3
- package/lib/umd/index.js +48 -2
- package/lib/umd/locale/ca-ES.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/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.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-TW.js +1 -1
- package/package.json +17 -16
package/lib/index.js
CHANGED
|
@@ -1,3244 +1,51 @@
|
|
|
1
|
-
var kr = Object.defineProperty;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { DeviceInputEventType as _t, IRenderManagerService as xe, fixLineWidthByScale as Tn, Transform as Kr, CheckboxShape as Gr, getCurrentTypeOfRenderer as Ge, CURSOR_TYPE as qe, FontCache as qr, Shape as Jr, Rect as Qn, getFontStyleString as Le, DocSimpleSkeleton as lt, Text as On } from "@univerjs/engine-render";
|
|
6
|
-
import { SheetInterceptorService as mn, VALIDATE_CELL as Qr, SheetsSelectionsService as er, SetRangeValuesCommand as ut, getSheetCommandTarget as tr, IAutoFillService as eo, AUTO_FILL_APPLY_TYPE as dt, AutoFillTools as to, rangeToDiscreteRange as no, SheetPermissionCheckController as ro, WorksheetEditPermission as nn, WorksheetSetCellStylePermission as rn, RangeProtectionPermissionEditPoint as on, WorkbookEditablePermission as an, INTERCEPTOR_POINT as nr, InterceptCellContentPriority as rr, SetWorksheetActiveOperation as oo, checkRangesEditablePermission as io } from "@univerjs/sheets";
|
|
7
|
-
import { SheetDataValidationModel as ae, SheetsDataValidationValidatorService as ao, getDataValidationCellValue as Wt, getCellValueOrigin as ie, serializeListOptions as or, createDefaultNewRule as ir, AddSheetDataValidationCommand as fn, DATA_VALIDATION_PLUGIN_NAME as ar, getDataValidationDiffMutations as sn, UpdateSheetDataValidationRangeCommand as sr, DataValidationCacheService as lr, UpdateSheetDataValidationSettingCommand as An, UpdateSheetDataValidationOptionsCommand as so, RemoveSheetDataValidationCommand as dr, RemoveSheetAllDataValidationCommand as lo, DataValidationFormulaController as co, deserializeListOptions as uo, CUSTOM_FORMULA_INPUT_NAME as cr, BASE_FORMULA_INPUT_NAME as Nt, LIST_FORMULA_INPUT_NAME as _n, CHECKBOX_FORMULA_INPUT_NAME as ur, DataValidationFormulaService as ho, CHECKBOX_FORMULA_2 as po, CHECKBOX_FORMULA_1 as go, getFormulaResult as Ht, isLegalFormulaResult as Pn, transformCheckboxValue as vo, UniverSheetsDataValidationPlugin as mo } from "@univerjs/sheets-data-validation";
|
|
8
|
-
import { DataValidatorRegistryService as Te, DataValidatorDropdownType as fe, DataValidationModel as Sn, DataValidatorRegistryScope as fo, TWO_FORMULA_OPERATOR_COUNT as _o, getRuleOptions as Ln, getRuleSetting as kn } from "@univerjs/data-validation";
|
|
9
|
-
import { ISidebarService as hr, IDialogService as So, IZenZoneService as pr, KeyCode as St, MenuItemType as Cn, getMenuHiddenObservable as Co, RibbonDataGroup as Io, IMenuManagerService as wo, useDependency as F, ComponentManager as In, useObservable as Re, useEvent as ln, useSidebarClick as gr } from "@univerjs/ui";
|
|
10
|
-
import { filter as wn, BehaviorSubject as Nn, distinctUntilChanged as Ro, Subject as yo, debounceTime as vr, bufferTime as mr, of as fr } from "rxjs";
|
|
11
|
-
import { getPatternType as bo } from "@univerjs/sheets-numfmt";
|
|
12
|
-
import { ISheetCellDropdownManagerService as Mo, IEditorBridgeService as _r, SetCellEditVisibleOperation as Ct, HoverManagerService as Eo, CellAlertManagerService as Do, CellAlertType as Vo, virtualizeDiscreteRanges as dn, ISheetClipboardService as To, COPY_TYPE as Un, PREDEFINED_HOOK_NAME_PASTE as It, getRepeatRange as Fn, getCurrentRangeDisable$ as Oo, AutoHeightController as Sr, SheetSkeletonManagerService as pt, IMarkSelectionService as Ao } from "@univerjs/sheets-ui";
|
|
13
|
-
import { Button as Je, FormLayout as Z, RadioGroup as Rn, Radio as Ne, Checkbox as Ut, Input as Ue, Select as $n, clsx as Fe, borderClassName as Et, DraggableList as Po, Dropdown as Lo } from "@univerjs/design";
|
|
14
|
-
import { createElement as ye, useRef as ft, forwardRef as st, useState as W, useMemo as gt, useEffect as Me } from "react";
|
|
15
|
-
import { jsxs as Y, Fragment as vt, jsx as S } from "react/jsx-runtime";
|
|
16
|
-
import { deserializeRangeWithSheet as ko, serializeRange as Cr } from "@univerjs/engine-formula";
|
|
17
|
-
import { RangeSelector as No, FormulaEditor as Ir } from "@univerjs/sheets-formula-ui";
|
|
18
|
-
const Uo = "@univerjs/sheets-data-validation-ui", Fo = "0.17.0", Dt = {
|
|
19
|
-
name: Uo,
|
|
20
|
-
version: Fo
|
|
21
|
-
};
|
|
22
|
-
var $o = Object.getOwnPropertyDescriptor, xo = (e, t, n, r) => {
|
|
23
|
-
for (var o = r > 1 ? void 0 : r ? $o(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
24
|
-
(a = e[i]) && (o = a(o) || o);
|
|
25
|
-
return o;
|
|
26
|
-
}, xn = (e, t) => (n, r) => t(n, r, e);
|
|
27
|
-
let _e = class extends De {
|
|
28
|
-
constructor(t, n) {
|
|
29
|
-
super();
|
|
30
|
-
E(this, "_open$", new Nn(!1));
|
|
31
|
-
E(this, "open$", this._open$.pipe(Ro()));
|
|
32
|
-
E(this, "_activeRule");
|
|
33
|
-
E(this, "_activeRule$", new Nn(void 0));
|
|
34
|
-
E(this, "activeRule$", this._activeRule$.asObservable());
|
|
35
|
-
E(this, "_closeDisposable", null);
|
|
36
|
-
// Record the worksheet to which the rule using the range selector belongs, so that the rule list is not switched when making cross-sheet selections
|
|
37
|
-
E(this, "_focusFormulaEditorActiveRuleSubUnitId", null);
|
|
38
|
-
this._univerInstanceService = t, this._sidebarService = n, this.disposeWithMe(
|
|
39
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(H.UNIVER_SHEET).pipe(wn((r) => !r)).subscribe(() => {
|
|
40
|
-
this.close();
|
|
41
|
-
})
|
|
42
|
-
), this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe((r) => {
|
|
43
|
-
r.id === Ot && (r.visible || setTimeout(() => {
|
|
44
|
-
this._sidebarService.sidebarOptions$.next({ visible: !1 });
|
|
45
|
-
}));
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
get activeRule() {
|
|
49
|
-
return this._activeRule;
|
|
50
|
-
}
|
|
51
|
-
get isOpen() {
|
|
52
|
-
return this._open$.getValue();
|
|
53
|
-
}
|
|
54
|
-
dispose() {
|
|
55
|
-
var t;
|
|
56
|
-
super.dispose(), this._open$.next(!1), this._open$.complete(), this._activeRule$.complete(), (t = this._closeDisposable) == null || t.dispose();
|
|
57
|
-
}
|
|
58
|
-
open() {
|
|
59
|
-
this._open$.next(!0);
|
|
60
|
-
}
|
|
61
|
-
close() {
|
|
62
|
-
var t;
|
|
63
|
-
this._open$.next(!1), (t = this._closeDisposable) == null || t.dispose();
|
|
64
|
-
}
|
|
65
|
-
setCloseDisposable(t) {
|
|
66
|
-
this._closeDisposable = Ur(() => {
|
|
67
|
-
t.dispose(), this._closeDisposable = null;
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
setActiveRule(t) {
|
|
71
|
-
this._activeRule = t, this._activeRule$.next(t);
|
|
72
|
-
}
|
|
73
|
-
setFocusFormulaEditorActiveRuleSubUnitId(t) {
|
|
74
|
-
this._focusFormulaEditorActiveRuleSubUnitId = t;
|
|
75
|
-
}
|
|
76
|
-
getFocusFormulaEditorActiveRuleSubUnitId() {
|
|
77
|
-
return this._focusFormulaEditorActiveRuleSubUnitId;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
_e = xo([
|
|
81
|
-
xn(0, pe),
|
|
82
|
-
xn(1, hr)
|
|
83
|
-
], _e);
|
|
84
|
-
const Vt = "sheets-data-validation-ui.config", Tt = {}, ke = "#ECECEC";
|
|
85
|
-
var Bo = Object.getOwnPropertyDescriptor, Wo = (e, t, n, r) => {
|
|
86
|
-
for (var o = r > 1 ? void 0 : r ? Bo(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
87
|
-
(a = e[i]) && (o = a(o) || o);
|
|
88
|
-
return o;
|
|
89
|
-
}, He = (e, t) => (n, r) => t(n, r, e);
|
|
90
|
-
let Qe = class extends De {
|
|
91
|
-
constructor(e, t, n, r, o, i) {
|
|
92
|
-
super(), this._sheetInterceptorService = e, this._dataValidationModel = t, this._dataValidatorRegistryService = n, this._dialogService = r, this._localeService = o, this._sheetsDataValidationValidatorService = i, this._initEditorBridgeInterceptor();
|
|
93
|
-
}
|
|
94
|
-
_initEditorBridgeInterceptor() {
|
|
95
|
-
this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(
|
|
96
|
-
Qr,
|
|
97
|
-
{
|
|
98
|
-
handler: async (e, t, n) => {
|
|
99
|
-
const r = await e, { row: o, col: i, unitId: a, subUnitId: l } = t, s = this._dataValidationModel.getRuleIdByLocation(a, l, o, i), d = s ? this._dataValidationModel.getRuleById(a, l, s) : void 0;
|
|
100
|
-
if (r === !1)
|
|
101
|
-
return n(Promise.resolve(!1));
|
|
102
|
-
if (!d || d.errorStyle !== ht.STOP)
|
|
103
|
-
return n(Promise.resolve(!0));
|
|
104
|
-
const u = this._dataValidatorRegistryService.getValidatorItem(d.type);
|
|
105
|
-
return !u || await this._sheetsDataValidationValidatorService.validatorCell(a, l, o, i) === Ke.VALID ? n(Promise.resolve(!0)) : (this._dialogService.open({
|
|
106
|
-
width: 368,
|
|
107
|
-
title: {
|
|
108
|
-
title: this._localeService.t("dataValidation.alert.title")
|
|
109
|
-
},
|
|
110
|
-
id: "reject-input-dialog",
|
|
111
|
-
children: {
|
|
112
|
-
title: u.getRuleFinalError(d, { row: o, col: i, unitId: a, subUnitId: l })
|
|
113
|
-
},
|
|
114
|
-
footer: {
|
|
115
|
-
title: ye(
|
|
116
|
-
Je,
|
|
117
|
-
{
|
|
118
|
-
variant: "primary",
|
|
119
|
-
onClick: () => this._dialogService.close("reject-input-dialog")
|
|
120
|
-
},
|
|
121
|
-
this._localeService.t("dataValidation.alert.ok")
|
|
122
|
-
)
|
|
123
|
-
},
|
|
124
|
-
onClose: () => {
|
|
125
|
-
this._dialogService.close("reject-input-dialog");
|
|
126
|
-
}
|
|
127
|
-
}), n(Promise.resolve(!1)));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
));
|
|
131
|
-
}
|
|
132
|
-
showReject(e) {
|
|
133
|
-
this._dialogService.open({
|
|
134
|
-
width: 368,
|
|
135
|
-
title: {
|
|
136
|
-
title: this._localeService.t("dataValidation.alert.title")
|
|
137
|
-
},
|
|
138
|
-
id: "reject-input-dialog",
|
|
139
|
-
children: {
|
|
140
|
-
title: e
|
|
141
|
-
},
|
|
142
|
-
footer: {
|
|
143
|
-
title: ye(
|
|
144
|
-
Je,
|
|
145
|
-
{
|
|
146
|
-
variant: "primary",
|
|
147
|
-
onClick: () => this._dialogService.close("reject-input-dialog")
|
|
148
|
-
},
|
|
149
|
-
this._localeService.t("dataValidation.alert.ok")
|
|
150
|
-
)
|
|
151
|
-
},
|
|
152
|
-
onClose: () => {
|
|
153
|
-
this._dialogService.close("reject-input-dialog");
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
Qe = Wo([
|
|
159
|
-
He(0, D(mn)),
|
|
160
|
-
He(1, D(ae)),
|
|
161
|
-
He(2, D(Te)),
|
|
162
|
-
He(3, So),
|
|
163
|
-
He(4, D(ge)),
|
|
164
|
-
He(5, D(ao))
|
|
165
|
-
], Qe);
|
|
166
|
-
var Ho = Object.getOwnPropertyDescriptor, jo = (e, t, n, r) => {
|
|
167
|
-
for (var o = r > 1 ? void 0 : r ? Ho(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
168
|
-
(a = e[i]) && (o = a(o) || o);
|
|
169
|
-
return o;
|
|
170
|
-
}, ve = (e, t) => (n, r) => t(n, r, e);
|
|
171
|
-
const jt = (e) => {
|
|
172
|
-
if (e == null || typeof e == "boolean")
|
|
173
|
-
return;
|
|
174
|
-
if (e === "") return Bt();
|
|
175
|
-
if (typeof e == "number" || !Number.isNaN(+e))
|
|
176
|
-
return Bt(Zn.format("yyyy-MM-dd HH:mm:ss", Number(e)));
|
|
177
|
-
const t = Bt(e);
|
|
178
|
-
if (t.isValid())
|
|
179
|
-
return t;
|
|
180
|
-
};
|
|
181
|
-
function Yo(e, t) {
|
|
182
|
-
const n = bo(t);
|
|
183
|
-
if (e === n)
|
|
184
|
-
return t;
|
|
185
|
-
switch (e) {
|
|
186
|
-
case "datetime":
|
|
187
|
-
return "yyyy-MM-dd hh:mm:ss";
|
|
188
|
-
case "date":
|
|
189
|
-
return "yyyy-MM-dd";
|
|
190
|
-
case "time":
|
|
191
|
-
return "HH:mm:ss";
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
let $e = class extends De {
|
|
195
|
-
constructor(t, n, r, o, i, a, l, s, d, u, h) {
|
|
196
|
-
super();
|
|
197
|
-
E(this, "_activeDropdown");
|
|
198
|
-
E(this, "_activeDropdown$", new yo());
|
|
199
|
-
E(this, "_currentPopup", null);
|
|
200
|
-
E(this, "activeDropdown$", this._activeDropdown$.asObservable());
|
|
201
|
-
E(this, "_zenVisible", !1);
|
|
202
|
-
this._univerInstanceService = t, this._dataValidatorRegistryService = n, this._zenZoneService = r, this._dataValidationModel = o, this._sheetsSelectionsService = i, this._cellDropdownManagerService = a, this._sheetDataValidationModel = l, this._commandService = s, this._editorBridgeService = d, this._injector = u, this._configService = h, this._init(), this._initSelectionChange(), this.disposeWithMe(() => {
|
|
203
|
-
this._activeDropdown$.complete();
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
get activeDropdown() {
|
|
207
|
-
return this._activeDropdown;
|
|
208
|
-
}
|
|
209
|
-
_init() {
|
|
210
|
-
this.disposeWithMe(this._zenZoneService.visible$.subscribe((t) => {
|
|
211
|
-
this._zenVisible = t, t && this.hideDropdown();
|
|
212
|
-
}));
|
|
213
|
-
}
|
|
214
|
-
_getDropdownByCell(t, n, r, o) {
|
|
215
|
-
const i = t ? this._univerInstanceService.getUnit(t, H.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(H.UNIVER_SHEET);
|
|
216
|
-
if (!i)
|
|
217
|
-
return;
|
|
218
|
-
const a = n ? i.getSheetBySheetId(n) : i.getActiveSheet();
|
|
219
|
-
if (!a)
|
|
220
|
-
return;
|
|
221
|
-
const l = this._dataValidationModel.getRuleByLocation(i.getUnitId(), a.getSheetId(), r, o);
|
|
222
|
-
if (!l)
|
|
223
|
-
return;
|
|
224
|
-
const s = this._dataValidatorRegistryService.getValidatorItem(l.type);
|
|
225
|
-
return s == null ? void 0 : s.dropdownType;
|
|
226
|
-
}
|
|
227
|
-
_initSelectionChange() {
|
|
228
|
-
this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe((t) => {
|
|
229
|
-
t && t.every((n) => !(n.primary && this._getDropdownByCell(n.primary.unitId, n.primary.sheetId, n.primary.actualRow, n.primary.actualColumn))) && this.hideDropdown();
|
|
230
|
-
}));
|
|
231
|
-
}
|
|
232
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
233
|
-
showDropdown(t) {
|
|
234
|
-
var V, v, C, f, w, M;
|
|
235
|
-
const { location: n } = t, { row: r, col: o, unitId: i, subUnitId: a, workbook: l, worksheet: s } = n;
|
|
236
|
-
if (this._currentPopup && this._currentPopup.dispose(), this._zenVisible)
|
|
237
|
-
return;
|
|
238
|
-
this._activeDropdown = t, this._activeDropdown$.next(this._activeDropdown);
|
|
239
|
-
const d = this._sheetDataValidationModel.getRuleByLocation(i, a, r, o);
|
|
240
|
-
if (!d)
|
|
241
|
-
return;
|
|
242
|
-
const u = this._dataValidatorRegistryService.getValidatorItem(d.type);
|
|
243
|
-
if (!(u != null && u.dropdownType))
|
|
244
|
-
return;
|
|
245
|
-
let h;
|
|
246
|
-
const c = async (g, p) => {
|
|
247
|
-
var U, k, x;
|
|
248
|
-
if (!g)
|
|
249
|
-
return !0;
|
|
250
|
-
const _ = g, T = s.getCell(r, o), A = _.format(p === "date" ? "YYYY-MM-DD 00:00:00" : "YYYY-MM-DD HH:mm:ss"), P = (U = Zn.parseDate(A)) == null ? void 0 : U.v, L = p === "time" ? P % 1 : P, y = l.getStyles().getStyleByCell(T), O = (x = (k = y == null ? void 0 : y.n) == null ? void 0 : k.pattern) != null ? x : "";
|
|
251
|
-
return d.errorStyle !== ht.STOP || await u.validator({
|
|
252
|
-
value: L,
|
|
253
|
-
unitId: i,
|
|
254
|
-
subUnitId: a,
|
|
255
|
-
row: r,
|
|
256
|
-
column: o,
|
|
257
|
-
worksheet: s,
|
|
258
|
-
workbook: l,
|
|
259
|
-
interceptValue: A.replace("Z", "").replace("T", " "),
|
|
260
|
-
t: $r.NUMBER
|
|
261
|
-
}, d) ? (await this._commandService.executeCommand(ut.id, {
|
|
262
|
-
unitId: i,
|
|
263
|
-
subUnitId: a,
|
|
264
|
-
range: {
|
|
265
|
-
startColumn: o,
|
|
266
|
-
endColumn: o,
|
|
267
|
-
startRow: r,
|
|
268
|
-
endRow: r
|
|
269
|
-
},
|
|
270
|
-
value: {
|
|
271
|
-
v: L,
|
|
272
|
-
t: 2,
|
|
273
|
-
p: null,
|
|
274
|
-
f: null,
|
|
275
|
-
si: null,
|
|
276
|
-
s: {
|
|
277
|
-
n: {
|
|
278
|
-
pattern: Yo(p, O)
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}), await this._commandService.executeCommand(Ct.id, {
|
|
283
|
-
visible: !1,
|
|
284
|
-
eventType: _t.Keyboard,
|
|
285
|
-
unitId: i,
|
|
286
|
-
keycode: St.ESC
|
|
287
|
-
}), !0) : (this._injector.has(Qe) && this._injector.get(Qe).showReject(u.getRuleFinalError(d, { row: r, col: o, unitId: i, subUnitId: a })), !1);
|
|
288
|
-
};
|
|
289
|
-
let m;
|
|
290
|
-
switch (u.dropdownType) {
|
|
291
|
-
case fe.DATE: {
|
|
292
|
-
const g = ie(s.getCellRaw(r, o)), p = jt(g), _ = !!((V = d.bizInfo) != null && V.showTime);
|
|
293
|
-
m = {
|
|
294
|
-
location: n,
|
|
295
|
-
type: "datepicker",
|
|
296
|
-
props: {
|
|
297
|
-
showTime: _,
|
|
298
|
-
onChange: (T) => c(T, _ ? "datetime" : "date"),
|
|
299
|
-
defaultValue: p,
|
|
300
|
-
patternType: "date"
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
case fe.TIME: {
|
|
306
|
-
const g = ie(s.getCellRaw(r, o)), p = jt(g);
|
|
307
|
-
m = {
|
|
308
|
-
location: n,
|
|
309
|
-
type: "datepicker",
|
|
310
|
-
props: {
|
|
311
|
-
onChange: (_) => c(_, "time"),
|
|
312
|
-
defaultValue: p,
|
|
313
|
-
patternType: "time"
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
case fe.DATETIME: {
|
|
319
|
-
const g = ie(s.getCellRaw(r, o)), p = jt(g);
|
|
320
|
-
m = {
|
|
321
|
-
location: n,
|
|
322
|
-
type: "datepicker",
|
|
323
|
-
props: {
|
|
324
|
-
onChange: (_) => c(_, "datetime"),
|
|
325
|
-
defaultValue: p,
|
|
326
|
-
patternType: "datetime"
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
case fe.LIST:
|
|
332
|
-
case fe.MULTIPLE_LIST: {
|
|
333
|
-
const g = u.dropdownType === fe.MULTIPLE_LIST, p = async (y) => {
|
|
334
|
-
const O = or(y), U = {
|
|
335
|
-
unitId: i,
|
|
336
|
-
subUnitId: a,
|
|
337
|
-
range: {
|
|
338
|
-
startColumn: o,
|
|
339
|
-
endColumn: o,
|
|
340
|
-
startRow: r,
|
|
341
|
-
endRow: r
|
|
342
|
-
},
|
|
343
|
-
value: {
|
|
344
|
-
v: O,
|
|
345
|
-
p: null,
|
|
346
|
-
f: null,
|
|
347
|
-
si: null
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
return this._commandService.executeCommand(ut.id, U), this._editorBridgeService.isVisible().visible && await this._commandService.executeCommand(Ct.id, {
|
|
351
|
-
visible: !1,
|
|
352
|
-
eventType: _t.Keyboard,
|
|
353
|
-
unitId: i,
|
|
354
|
-
keycode: St.ESC
|
|
355
|
-
}), !g;
|
|
356
|
-
}, _ = (d == null ? void 0 : d.renderMode) === ue.CUSTOM || (d == null ? void 0 : d.renderMode) === void 0, T = u.getListWithColor(d, i, a), A = Wt(s.getCellRaw(r, o)), P = () => {
|
|
357
|
-
this._commandService.executeCommand(Be.id, {
|
|
358
|
-
ruleId: d.uid
|
|
359
|
-
}), h == null || h.dispose();
|
|
360
|
-
}, L = T.map((y) => ({
|
|
361
|
-
label: y.label,
|
|
362
|
-
value: y.label,
|
|
363
|
-
color: _ || y.color ? y.color || ke : "transparent"
|
|
364
|
-
}));
|
|
365
|
-
m = {
|
|
366
|
-
location: n,
|
|
367
|
-
type: "list",
|
|
368
|
-
props: {
|
|
369
|
-
onChange: (y) => p(y),
|
|
370
|
-
options: L,
|
|
371
|
-
onEdit: P,
|
|
372
|
-
defaultValue: A,
|
|
373
|
-
multiple: g,
|
|
374
|
-
showEdit: (C = (v = this._configService.getConfig(Vt)) == null ? void 0 : v.showEditOnDropdown) != null ? C : !0,
|
|
375
|
-
showSearch: (w = (f = this._configService.getConfig(Vt)) == null ? void 0 : f.showSearchOnDropdown) != null ? w : !0
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
break;
|
|
379
|
-
}
|
|
380
|
-
case fe.CASCADE: {
|
|
381
|
-
m = {
|
|
382
|
-
type: "cascader",
|
|
383
|
-
props: {
|
|
384
|
-
onChange: (p) => {
|
|
385
|
-
const _ = {
|
|
386
|
-
unitId: i,
|
|
387
|
-
subUnitId: a,
|
|
388
|
-
range: {
|
|
389
|
-
startColumn: o,
|
|
390
|
-
endColumn: o,
|
|
391
|
-
startRow: r,
|
|
392
|
-
endRow: r
|
|
393
|
-
},
|
|
394
|
-
value: {
|
|
395
|
-
v: p.join("/"),
|
|
396
|
-
p: null,
|
|
397
|
-
f: null,
|
|
398
|
-
si: null
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
return this._commandService.syncExecuteCommand(ut.id, _), this._editorBridgeService.isVisible().visible && this._commandService.syncExecuteCommand(Ct.id, {
|
|
402
|
-
visible: !1,
|
|
403
|
-
eventType: _t.Keyboard,
|
|
404
|
-
unitId: i,
|
|
405
|
-
keycode: St.ESC
|
|
406
|
-
}), !0;
|
|
407
|
-
},
|
|
408
|
-
defaultValue: Wt(s.getCellRaw(r, o)).split("/"),
|
|
409
|
-
options: JSON.parse((M = d.formula1) != null ? M : "[]")
|
|
410
|
-
},
|
|
411
|
-
location: n
|
|
412
|
-
};
|
|
413
|
-
break;
|
|
414
|
-
}
|
|
415
|
-
case fe.COLOR: {
|
|
416
|
-
m = {
|
|
417
|
-
type: "color",
|
|
418
|
-
props: {
|
|
419
|
-
onChange: (p) => {
|
|
420
|
-
const _ = {
|
|
421
|
-
unitId: i,
|
|
422
|
-
subUnitId: a,
|
|
423
|
-
range: {
|
|
424
|
-
startColumn: o,
|
|
425
|
-
endColumn: o,
|
|
426
|
-
startRow: r,
|
|
427
|
-
endRow: r
|
|
428
|
-
},
|
|
429
|
-
value: {
|
|
430
|
-
v: p,
|
|
431
|
-
p: null,
|
|
432
|
-
f: null,
|
|
433
|
-
si: null
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
return this._commandService.syncExecuteCommand(ut.id, _), this._editorBridgeService.isVisible().visible && this._commandService.syncExecuteCommand(Ct.id, {
|
|
437
|
-
visible: !1,
|
|
438
|
-
eventType: _t.Keyboard,
|
|
439
|
-
unitId: i,
|
|
440
|
-
keycode: St.ESC
|
|
441
|
-
}), !0;
|
|
442
|
-
},
|
|
443
|
-
defaultValue: Wt(s.getCellRaw(r, o))
|
|
444
|
-
},
|
|
445
|
-
location: n
|
|
446
|
-
};
|
|
447
|
-
break;
|
|
448
|
-
}
|
|
449
|
-
default:
|
|
450
|
-
throw new Error("[DataValidationDropdownManagerService]: unknown type!");
|
|
451
|
-
}
|
|
452
|
-
if (h = this._cellDropdownManagerService.showDropdown({
|
|
453
|
-
...m,
|
|
454
|
-
onHide: () => {
|
|
455
|
-
this._activeDropdown = null, this._activeDropdown$.next(null);
|
|
456
|
-
}
|
|
457
|
-
}), !h)
|
|
458
|
-
throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");
|
|
459
|
-
const I = new Fr();
|
|
460
|
-
I.add(h), I.add({
|
|
461
|
-
dispose: () => {
|
|
462
|
-
var g, p;
|
|
463
|
-
(p = (g = this._activeDropdown) == null ? void 0 : g.onHide) == null || p.call(g);
|
|
464
|
-
}
|
|
465
|
-
}), this._currentPopup = I;
|
|
466
|
-
}
|
|
467
|
-
hideDropdown() {
|
|
468
|
-
this._activeDropdown && (this._currentPopup && this._currentPopup.dispose(), this._currentPopup = null, this._activeDropdown = null, this._activeDropdown$.next(null));
|
|
469
|
-
}
|
|
470
|
-
showDataValidationDropdown(t, n, r, o, i) {
|
|
471
|
-
const a = this._univerInstanceService.getUnit(t, H.UNIVER_SHEET);
|
|
472
|
-
if (!a)
|
|
473
|
-
return;
|
|
474
|
-
const l = a.getSheetBySheetId(n);
|
|
475
|
-
if (!l)
|
|
476
|
-
return;
|
|
477
|
-
const s = this._dataValidationModel.getRuleByLocation(a.getUnitId(), l.getSheetId(), r, o);
|
|
478
|
-
if (!s)
|
|
479
|
-
return;
|
|
480
|
-
const d = this._dataValidatorRegistryService.getValidatorItem(s.type);
|
|
481
|
-
if (!d || !d.dropdownType) {
|
|
482
|
-
this.hideDropdown();
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
this.showDropdown({
|
|
486
|
-
location: {
|
|
487
|
-
workbook: a,
|
|
488
|
-
worksheet: l,
|
|
489
|
-
row: r,
|
|
490
|
-
col: o,
|
|
491
|
-
unitId: t,
|
|
492
|
-
subUnitId: n
|
|
493
|
-
},
|
|
494
|
-
onHide: i
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
$e = jo([
|
|
499
|
-
ve(0, pe),
|
|
500
|
-
ve(1, D(Te)),
|
|
501
|
-
ve(2, pr),
|
|
502
|
-
ve(3, D(ae)),
|
|
503
|
-
ve(4, D(er)),
|
|
504
|
-
ve(5, D(Mo)),
|
|
505
|
-
ve(6, D(ae)),
|
|
506
|
-
ve(7, oe),
|
|
507
|
-
ve(8, _r),
|
|
508
|
-
ve(9, D(Ve)),
|
|
509
|
-
ve(10, gn)
|
|
510
|
-
], $e);
|
|
511
|
-
const Ot = "DataValidationPanel", Be = {
|
|
512
|
-
id: "data-validation.operation.open-validation-panel",
|
|
513
|
-
type: at.OPERATION,
|
|
514
|
-
handler(e, t) {
|
|
515
|
-
if (!t)
|
|
516
|
-
return !1;
|
|
517
|
-
const { ruleId: n, isAdd: r } = t, o = e.get(_e), i = e.get(Sn), a = e.get(pe), l = e.get(hr), s = tr(a);
|
|
518
|
-
if (!s) return !1;
|
|
519
|
-
const { unitId: d, subUnitId: u } = s, h = n ? i.getRuleById(d, u, n) : void 0;
|
|
520
|
-
o.open(), o.setActiveRule(h && {
|
|
521
|
-
unitId: d,
|
|
522
|
-
subUnitId: u,
|
|
523
|
-
rule: h
|
|
524
|
-
});
|
|
525
|
-
const c = l.open({
|
|
526
|
-
id: Ot,
|
|
527
|
-
header: { title: r ? "dataValidation.panel.addTitle" : "dataValidation.panel.title" },
|
|
528
|
-
children: { label: Ot },
|
|
529
|
-
width: 312,
|
|
530
|
-
onClose: () => o.close()
|
|
531
|
-
});
|
|
532
|
-
return o.setCloseDisposable(c), !0;
|
|
533
|
-
}
|
|
534
|
-
}, yn = {
|
|
535
|
-
id: "data-validation.operation.close-validation-panel",
|
|
536
|
-
type: at.OPERATION,
|
|
537
|
-
handler(e) {
|
|
538
|
-
return e.get(_e).close(), !0;
|
|
539
|
-
}
|
|
540
|
-
}, wr = {
|
|
541
|
-
id: "data-validation.operation.toggle-validation-panel",
|
|
542
|
-
type: at.OPERATION,
|
|
543
|
-
handler(e) {
|
|
544
|
-
const t = e.get(oe), n = e.get(_e);
|
|
545
|
-
return n.open(), n.isOpen ? t.executeCommand(yn.id) : t.executeCommand(Be.id), !0;
|
|
546
|
-
}
|
|
547
|
-
}, Ft = {
|
|
548
|
-
type: at.OPERATION,
|
|
549
|
-
id: "sheet.operation.show-data-validation-dropdown",
|
|
550
|
-
handler(e, t) {
|
|
551
|
-
if (!t)
|
|
552
|
-
return !1;
|
|
553
|
-
const n = e.get($e), { unitId: r, subUnitId: o, row: i, column: a } = t, l = n.activeDropdown, s = l == null ? void 0 : l.location;
|
|
554
|
-
return s && s.unitId === r && s.subUnitId === o && s.row === i && s.col === a || n.showDataValidationDropdown(
|
|
555
|
-
r,
|
|
556
|
-
o,
|
|
557
|
-
i,
|
|
558
|
-
a
|
|
559
|
-
), !0;
|
|
560
|
-
}
|
|
561
|
-
}, Rr = {
|
|
562
|
-
type: at.OPERATION,
|
|
563
|
-
id: "sheet.operation.hide-data-validation-dropdown",
|
|
564
|
-
handler(e, t) {
|
|
565
|
-
return t ? (e.get($e).hideDropdown(), !0) : !1;
|
|
566
|
-
}
|
|
567
|
-
}, $t = {
|
|
568
|
-
type: at.COMMAND,
|
|
569
|
-
id: "data-validation.command.addRuleAndOpen",
|
|
570
|
-
handler(e) {
|
|
571
|
-
const t = e.get(pe), n = tr(t);
|
|
572
|
-
if (!n) return !1;
|
|
573
|
-
const { workbook: r, worksheet: o } = n, i = ir(e), a = e.get(oe), l = r.getUnitId(), s = o.getSheetId(), d = {
|
|
574
|
-
rule: i,
|
|
575
|
-
unitId: l,
|
|
576
|
-
subUnitId: s
|
|
577
|
-
};
|
|
578
|
-
return a.syncExecuteCommand(fn.id, d) ? (a.syncExecuteCommand(Be.id, {
|
|
579
|
-
ruleId: i.uid,
|
|
580
|
-
isAdd: !0
|
|
581
|
-
}), !0) : !1;
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
|
-
var Xo = Object.getOwnPropertyDescriptor, Zo = (e, t, n, r) => {
|
|
585
|
-
for (var o = r > 1 ? void 0 : r ? Xo(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
586
|
-
(a = e[i]) && (o = a(o) || o);
|
|
587
|
-
return o;
|
|
588
|
-
}, je = (e, t) => (n, r) => t(n, r, e);
|
|
589
|
-
const Oe = "SHEET_DATA_VALIDATION_ALERT";
|
|
590
|
-
let mt = class extends De {
|
|
591
|
-
constructor(e, t, n, r, o, i) {
|
|
592
|
-
super(), this._hoverManagerService = e, this._cellAlertManagerService = t, this._univerInstanceService = n, this._localeService = r, this._zenZoneService = o, this._dataValidationModel = i, this._init();
|
|
593
|
-
}
|
|
594
|
-
_init() {
|
|
595
|
-
this._initCellAlertPopup(), this._initZenService();
|
|
596
|
-
}
|
|
597
|
-
_initCellAlertPopup() {
|
|
598
|
-
this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(vr(100)).subscribe((e) => {
|
|
599
|
-
var t;
|
|
600
|
-
if (e) {
|
|
601
|
-
const n = this._univerInstanceService.getUnit(e.location.unitId, H.UNIVER_SHEET), r = n.getSheetBySheetId(e.location.subUnitId);
|
|
602
|
-
if (!r) return;
|
|
603
|
-
const o = this._dataValidationModel.getRuleByLocation(e.location.unitId, e.location.subUnitId, e.location.row, e.location.col);
|
|
604
|
-
if (!o) {
|
|
605
|
-
this._cellAlertManagerService.removeAlert(Oe);
|
|
606
|
-
return;
|
|
607
|
-
}
|
|
608
|
-
if (this._dataValidationModel.validator(o, { ...e.location, workbook: n, worksheet: r }) === Ke.INVALID) {
|
|
609
|
-
const a = this._cellAlertManagerService.currentAlert.get(Oe), l = (t = a == null ? void 0 : a.alert) == null ? void 0 : t.location;
|
|
610
|
-
if (l && l.row === e.location.row && l.col === e.location.col && l.subUnitId === e.location.subUnitId && l.unitId === e.location.unitId) {
|
|
611
|
-
this._cellAlertManagerService.removeAlert(Oe);
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
const s = this._dataValidationModel.getValidator(o.type);
|
|
615
|
-
if (!s) {
|
|
616
|
-
this._cellAlertManagerService.removeAlert(Oe);
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
this._cellAlertManagerService.showAlert({
|
|
620
|
-
type: Vo.ERROR,
|
|
621
|
-
title: this._localeService.t("dataValidation.error.title"),
|
|
622
|
-
message: s == null ? void 0 : s.getRuleFinalError(o, e.location),
|
|
623
|
-
location: e.location,
|
|
624
|
-
width: 200,
|
|
625
|
-
height: 74,
|
|
626
|
-
key: Oe
|
|
627
|
-
});
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
this._cellAlertManagerService.removeAlert(Oe);
|
|
632
|
-
}));
|
|
633
|
-
}
|
|
634
|
-
_initZenService() {
|
|
635
|
-
this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
|
|
636
|
-
e && this._cellAlertManagerService.removeAlert(Oe);
|
|
637
|
-
}));
|
|
638
|
-
}
|
|
639
|
-
};
|
|
640
|
-
mt = Zo([
|
|
641
|
-
je(0, D(Eo)),
|
|
642
|
-
je(1, D(Do)),
|
|
643
|
-
je(2, pe),
|
|
644
|
-
je(3, D(ge)),
|
|
645
|
-
je(4, pr),
|
|
646
|
-
je(5, D(ae))
|
|
647
|
-
], mt);
|
|
648
|
-
var zo = Object.getOwnPropertyDescriptor, Ko = (e, t, n, r) => {
|
|
649
|
-
for (var o = r > 1 ? void 0 : r ? zo(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
650
|
-
(a = e[i]) && (o = a(o) || o);
|
|
651
|
-
return o;
|
|
652
|
-
}, Yt = (e, t) => (n, r) => t(n, r, e);
|
|
653
|
-
let et = class extends De {
|
|
654
|
-
constructor(e, t, n) {
|
|
655
|
-
super(), this._autoFillService = e, this._sheetDataValidationModel = t, this._injector = n, this._initAutoFill();
|
|
656
|
-
}
|
|
657
|
-
// eslint-disable-next-line max-lines-per-function
|
|
658
|
-
_initAutoFill() {
|
|
659
|
-
const e = () => ({ redos: [], undos: [] }), t = (r, o) => {
|
|
660
|
-
const { source: i, target: a, unitId: l, subUnitId: s } = r, d = this._sheetDataValidationModel.getRuleObjectMatrix(l, s).clone(), u = dn([i, a]), [h, c] = u.ranges, { mapFunc: m } = u, I = {
|
|
661
|
-
row: h.startRow,
|
|
662
|
-
col: h.startColumn
|
|
663
|
-
}, V = to.getAutoFillRepeatRange(h, c), v = new bt(), C = /* @__PURE__ */ new Set();
|
|
664
|
-
V.forEach((p) => {
|
|
665
|
-
const _ = p.repeatStartCell, T = p.relativeRange, A = {
|
|
666
|
-
startRow: I.row,
|
|
667
|
-
startColumn: I.col,
|
|
668
|
-
endColumn: I.col,
|
|
669
|
-
endRow: I.row
|
|
670
|
-
}, P = {
|
|
671
|
-
startRow: _.row,
|
|
672
|
-
startColumn: _.col,
|
|
673
|
-
endColumn: _.col,
|
|
674
|
-
endRow: _.row
|
|
675
|
-
};
|
|
676
|
-
xr.foreach(T, (L, y) => {
|
|
677
|
-
const O = Mt.getPositionRange(
|
|
678
|
-
{
|
|
679
|
-
startRow: L,
|
|
680
|
-
startColumn: y,
|
|
681
|
-
endColumn: y,
|
|
682
|
-
endRow: L
|
|
683
|
-
},
|
|
684
|
-
A
|
|
685
|
-
), { row: U, col: k } = m(O.startRow, O.startColumn), x = this._sheetDataValidationModel.getRuleIdByLocation(l, s, U, k) || "", te = Mt.getPositionRange(
|
|
686
|
-
{
|
|
687
|
-
startRow: L,
|
|
688
|
-
startColumn: y,
|
|
689
|
-
endColumn: y,
|
|
690
|
-
endRow: L
|
|
691
|
-
},
|
|
692
|
-
P
|
|
693
|
-
), { row: j, col: se } = m(te.startRow, te.startColumn);
|
|
694
|
-
v.setValue(j, se, x), C.add(x);
|
|
695
|
-
});
|
|
696
|
-
});
|
|
697
|
-
const f = Array.from(C).map((p) => ({ id: p, ranges: tn(v, (_) => _ === p) }));
|
|
698
|
-
d.addRangeRules(f);
|
|
699
|
-
const w = d.diff(this._sheetDataValidationModel.getRules(l, s)), { redoMutations: M, undoMutations: g } = sn(l, s, w, this._injector, "patched", o === dt.ONLY_FORMAT);
|
|
700
|
-
return {
|
|
701
|
-
undos: g,
|
|
702
|
-
redos: M
|
|
703
|
-
};
|
|
704
|
-
}, n = {
|
|
705
|
-
id: ar,
|
|
706
|
-
onBeforeFillData: (r) => {
|
|
707
|
-
const { source: o, unitId: i, subUnitId: a } = r;
|
|
708
|
-
for (const l of o.rows)
|
|
709
|
-
for (const s of o.cols) {
|
|
710
|
-
const d = this._sheetDataValidationModel.getRuleByLocation(i, a, l, s);
|
|
711
|
-
if (d && d.type === X.CHECKBOX) {
|
|
712
|
-
this._autoFillService.setDisableApplyType(dt.SERIES, !0);
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
},
|
|
717
|
-
onFillData: (r, o, i) => i === dt.COPY || i === dt.ONLY_FORMAT || i === dt.SERIES ? t(r, i) : e(),
|
|
718
|
-
onAfterFillData: () => {
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
|
-
this.disposeWithMe(this._autoFillService.addHook(n));
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
et = Ko([
|
|
725
|
-
Yt(0, eo),
|
|
726
|
-
Yt(1, D(ae)),
|
|
727
|
-
Yt(2, D(Ve))
|
|
728
|
-
], et);
|
|
729
|
-
var Go = Object.getOwnPropertyDescriptor, qo = (e, t, n, r) => {
|
|
730
|
-
for (var o = r > 1 ? void 0 : r ? Go(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
731
|
-
(a = e[i]) && (o = a(o) || o);
|
|
732
|
-
return o;
|
|
733
|
-
}, Xt = (e, t) => (n, r) => t(n, r, e);
|
|
734
|
-
let tt = class extends De {
|
|
735
|
-
constructor(t, n, r) {
|
|
736
|
-
super();
|
|
737
|
-
E(this, "_copyInfo");
|
|
738
|
-
this._sheetClipboardService = t, this._sheetDataValidationModel = n, this._injector = r, this._initCopyPaste();
|
|
739
|
-
}
|
|
740
|
-
_initCopyPaste() {
|
|
741
|
-
this._sheetClipboardService.addClipboardHook({
|
|
742
|
-
id: ar,
|
|
743
|
-
onBeforeCopy: (t, n, r) => this._collect(t, n, r),
|
|
744
|
-
onPasteCells: (t, n, r, o) => {
|
|
745
|
-
const { copyType: i = Un.COPY, pasteType: a } = o, { range: l } = t || {}, { range: s, unitId: d, subUnitId: u } = n;
|
|
746
|
-
return this._generateMutations(s, { copyType: i, pasteType: a, copyRange: l, unitId: d, subUnitId: u });
|
|
747
|
-
}
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
_collect(t, n, r) {
|
|
751
|
-
const o = new bt();
|
|
752
|
-
this._copyInfo = {
|
|
753
|
-
unitId: t,
|
|
754
|
-
subUnitId: n,
|
|
755
|
-
matrix: o
|
|
756
|
-
};
|
|
757
|
-
const i = this._injector.invoke((s) => no(r, s, t, n));
|
|
758
|
-
if (!i)
|
|
759
|
-
return;
|
|
760
|
-
const { rows: a, cols: l } = i;
|
|
761
|
-
a.forEach((s, d) => {
|
|
762
|
-
l.forEach((u, h) => {
|
|
763
|
-
const c = this._sheetDataValidationModel.getRuleIdByLocation(t, n, s, u);
|
|
764
|
-
o.setValue(d, h, c != null ? c : "");
|
|
765
|
-
});
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
// eslint-disable-next-line max-lines-per-function
|
|
769
|
-
_generateMutations(t, n) {
|
|
770
|
-
if (!this._copyInfo)
|
|
771
|
-
return { redos: [], undos: [] };
|
|
772
|
-
if (n.copyType === Un.CUT)
|
|
773
|
-
return this._copyInfo = null, { redos: [], undos: [] };
|
|
774
|
-
if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !n.copyRange)
|
|
775
|
-
return { redos: [], undos: [] };
|
|
776
|
-
if ([
|
|
777
|
-
It.SPECIAL_PASTE_COL_WIDTH,
|
|
778
|
-
It.SPECIAL_PASTE_VALUE,
|
|
779
|
-
It.SPECIAL_PASTE_FORMAT,
|
|
780
|
-
It.SPECIAL_PASTE_FORMULA
|
|
781
|
-
].includes(n.pasteType))
|
|
782
|
-
return { redos: [], undos: [] };
|
|
783
|
-
const { unitId: o, subUnitId: i } = this._copyInfo;
|
|
784
|
-
if (n.unitId !== o || i !== n.subUnitId) {
|
|
785
|
-
const a = this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId, n.subUnitId).clone(), l = new bt(), s = /* @__PURE__ */ new Set(), { ranges: [d, u], mapFunc: h } = dn([n.copyRange, t]), c = Fn(d, u, !0), m = /* @__PURE__ */ new Map();
|
|
786
|
-
c.forEach(({ startRange: C }) => {
|
|
787
|
-
var f;
|
|
788
|
-
(f = this._copyInfo) == null || f.matrix.forValue((w, M, g) => {
|
|
789
|
-
const p = Mt.getPositionRange(
|
|
790
|
-
{
|
|
791
|
-
startRow: w,
|
|
792
|
-
endRow: w,
|
|
793
|
-
startColumn: M,
|
|
794
|
-
endColumn: M
|
|
795
|
-
},
|
|
796
|
-
C
|
|
797
|
-
), _ = `${i}-${g}`, T = this._sheetDataValidationModel.getRuleById(o, i, g);
|
|
798
|
-
!this._sheetDataValidationModel.getRuleById(n.unitId, n.subUnitId, _) && T && m.set(_, { ...T, uid: _ });
|
|
799
|
-
const { row: A, col: P } = h(p.startRow, p.startColumn);
|
|
800
|
-
s.add(_), l.setValue(A, P, _);
|
|
801
|
-
});
|
|
802
|
-
});
|
|
803
|
-
const I = Array.from(s).map((C) => ({ id: C, ranges: tn(l, (f) => f === C) }));
|
|
804
|
-
a.addRangeRules(I);
|
|
805
|
-
const { redoMutations: V, undoMutations: v } = sn(
|
|
806
|
-
n.unitId,
|
|
807
|
-
n.subUnitId,
|
|
808
|
-
a.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId, n.subUnitId), m.values()),
|
|
809
|
-
this._injector,
|
|
810
|
-
"patched",
|
|
811
|
-
!1
|
|
812
|
-
);
|
|
813
|
-
return {
|
|
814
|
-
redos: V,
|
|
815
|
-
undos: v
|
|
816
|
-
};
|
|
817
|
-
} else {
|
|
818
|
-
const a = this._sheetDataValidationModel.getRuleObjectMatrix(o, i).clone(), l = new bt(), s = /* @__PURE__ */ new Set(), { ranges: [d, u], mapFunc: h } = dn([n.copyRange, t]);
|
|
819
|
-
Fn(d, u, !0).forEach(({ startRange: v }) => {
|
|
820
|
-
var C;
|
|
821
|
-
(C = this._copyInfo) == null || C.matrix.forValue((f, w, M) => {
|
|
822
|
-
const g = Mt.getPositionRange(
|
|
823
|
-
{
|
|
824
|
-
startRow: f,
|
|
825
|
-
endRow: f,
|
|
826
|
-
startColumn: w,
|
|
827
|
-
endColumn: w
|
|
828
|
-
},
|
|
829
|
-
v
|
|
830
|
-
), { row: p, col: _ } = h(g.startRow, g.startColumn);
|
|
831
|
-
l.setValue(p, _, M), s.add(M);
|
|
832
|
-
});
|
|
833
|
-
});
|
|
834
|
-
const m = Array.from(s).map((v) => ({ id: v, ranges: tn(l, (C) => C === v) }));
|
|
835
|
-
a.addRangeRules(m);
|
|
836
|
-
const { redoMutations: I, undoMutations: V } = sn(
|
|
837
|
-
o,
|
|
838
|
-
i,
|
|
839
|
-
a.diff(this._sheetDataValidationModel.getRules(o, i)),
|
|
840
|
-
this._injector,
|
|
841
|
-
"patched",
|
|
842
|
-
!1
|
|
843
|
-
);
|
|
844
|
-
return {
|
|
845
|
-
redos: I,
|
|
846
|
-
undos: V
|
|
847
|
-
};
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
};
|
|
851
|
-
tt = qo([
|
|
852
|
-
Xt(0, To),
|
|
853
|
-
Xt(1, D(ae)),
|
|
854
|
-
Xt(2, D(Ve))
|
|
855
|
-
], tt);
|
|
856
|
-
var Jo = Object.getOwnPropertyDescriptor, Qo = (e, t, n, r) => {
|
|
857
|
-
for (var o = r > 1 ? void 0 : r ? Jo(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
858
|
-
(a = e[i]) && (o = a(o) || o);
|
|
859
|
-
return o;
|
|
860
|
-
}, Zt = (e, t) => (n, r) => t(n, r, e);
|
|
861
|
-
let nt = class extends De {
|
|
862
|
-
constructor(e, t, n) {
|
|
863
|
-
super(), this._localeService = e, this._commandService = t, this._sheetPermissionCheckController = n, this._commandExecutedListener();
|
|
864
|
-
}
|
|
865
|
-
_commandExecutedListener() {
|
|
866
|
-
this.disposeWithMe(
|
|
867
|
-
this._commandService.beforeCommandExecuted((e) => {
|
|
868
|
-
if (e.id === fn.id) {
|
|
869
|
-
const { unitId: t, subUnitId: n, rule: { ranges: r } } = e.params;
|
|
870
|
-
this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
871
|
-
workbookTypes: [an],
|
|
872
|
-
rangeTypes: [on],
|
|
873
|
-
worksheetTypes: [nn, rn]
|
|
874
|
-
}, r, t, n) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"));
|
|
875
|
-
}
|
|
876
|
-
if (e.id === sr.id) {
|
|
877
|
-
const { unitId: t, subUnitId: n, ranges: r } = e.params;
|
|
878
|
-
this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
879
|
-
workbookTypes: [an],
|
|
880
|
-
rangeTypes: [on],
|
|
881
|
-
worksheetTypes: [nn, rn]
|
|
882
|
-
}, r, t, n) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"));
|
|
883
|
-
}
|
|
884
|
-
})
|
|
885
|
-
);
|
|
886
|
-
}
|
|
887
|
-
};
|
|
888
|
-
nt = Qo([
|
|
889
|
-
Zt(0, D(ge)),
|
|
890
|
-
Zt(1, oe),
|
|
891
|
-
Zt(2, D(ro))
|
|
892
|
-
], nt);
|
|
893
|
-
const yr = "sheet.menu.data-validation";
|
|
894
|
-
function ei(e) {
|
|
895
|
-
return {
|
|
896
|
-
id: yr,
|
|
897
|
-
type: Cn.SUBITEMS,
|
|
898
|
-
icon: "DataValidationIcon",
|
|
899
|
-
tooltip: "dataValidation.title",
|
|
900
|
-
hidden$: Co(e, H.UNIVER_SHEET),
|
|
901
|
-
disabled$: Oo(e, { workbookTypes: [an], worksheetTypes: [rn, nn], rangeTypes: [on] })
|
|
902
|
-
};
|
|
903
|
-
}
|
|
904
|
-
function ti(e) {
|
|
905
|
-
return {
|
|
906
|
-
id: Be.id,
|
|
907
|
-
title: "dataValidation.panel.title",
|
|
908
|
-
type: Cn.BUTTON
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
function ni(e) {
|
|
912
|
-
return {
|
|
913
|
-
id: $t.id,
|
|
914
|
-
title: "dataValidation.panel.add",
|
|
915
|
-
type: Cn.BUTTON
|
|
916
|
-
};
|
|
917
|
-
}
|
|
918
|
-
const ri = {
|
|
919
|
-
[Io.RULES]: {
|
|
920
|
-
[yr]: {
|
|
921
|
-
order: 0,
|
|
922
|
-
menuItemFactory: ei,
|
|
923
|
-
[Be.id]: {
|
|
924
|
-
order: 0,
|
|
925
|
-
menuItemFactory: ti
|
|
926
|
-
},
|
|
927
|
-
[$t.id]: {
|
|
928
|
-
order: 1,
|
|
929
|
-
menuItemFactory: ni
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
};
|
|
934
|
-
var oi = Object.getOwnPropertyDescriptor, br = (e, t, n, r) => {
|
|
935
|
-
for (var o = r > 1 ? void 0 : r ? oi(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
936
|
-
(a = e[i]) && (o = a(o) || o);
|
|
937
|
-
return o;
|
|
938
|
-
}, K = (e, t) => (n, r) => t(n, r, e);
|
|
939
|
-
const Mr = {
|
|
940
|
-
tr: {
|
|
941
|
-
size: 6,
|
|
942
|
-
color: "#fe4b4b"
|
|
943
|
-
}
|
|
944
|
-
};
|
|
945
|
-
let rt = class extends vn {
|
|
946
|
-
constructor(e, t, n, r, o, i, a, l, s, d, u) {
|
|
947
|
-
super(), this._commandService = e, this._menuManagerService = t, this._renderManagerService = n, this._univerInstanceService = r, this._autoHeightController = o, this._dropdownManagerService = i, this._sheetDataValidationModel = a, this._dataValidatorRegistryService = l, this._sheetInterceptorService = s, this._dataValidationCacheService = d, this._editorBridgeService = u, this._initMenu(), this._initDropdown(), this._initViewModelIntercept(), this._initAutoHeight();
|
|
948
|
-
}
|
|
949
|
-
_initMenu() {
|
|
950
|
-
this._menuManagerService.mergeMenu(ri);
|
|
951
|
-
}
|
|
952
|
-
_initDropdown() {
|
|
953
|
-
this._editorBridgeService && this.disposeWithMe(this._editorBridgeService.visible$.subscribe((e) => {
|
|
954
|
-
var n;
|
|
955
|
-
if (!e.visible) {
|
|
956
|
-
((n = this._dropdownManagerService.activeDropdown) == null ? void 0 : n.trigger) === "editor-bridge" && this._dropdownManagerService.hideDropdown();
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
const t = this._editorBridgeService.getEditCellState();
|
|
960
|
-
if (t) {
|
|
961
|
-
const { unitId: r, sheetId: o, row: i, column: a } = t, l = this._univerInstanceService.getUniverSheetInstance(r);
|
|
962
|
-
if (!l)
|
|
963
|
-
return;
|
|
964
|
-
const s = this._sheetDataValidationModel.getRuleByLocation(r, o, i, a);
|
|
965
|
-
if (!s)
|
|
966
|
-
return;
|
|
967
|
-
const d = this._dataValidatorRegistryService.getValidatorItem(s.type);
|
|
968
|
-
if (!(d != null && d.dropdownType))
|
|
969
|
-
return;
|
|
970
|
-
const u = l.getActiveSheet();
|
|
971
|
-
if (!u) return;
|
|
972
|
-
const h = this._dropdownManagerService.activeDropdown, c = h == null ? void 0 : h.location;
|
|
973
|
-
if (c && c.unitId === r && c.subUnitId === o && c.row === i && c.col === a)
|
|
974
|
-
return;
|
|
975
|
-
this._dropdownManagerService.showDropdown(
|
|
976
|
-
{
|
|
977
|
-
location: {
|
|
978
|
-
unitId: r,
|
|
979
|
-
subUnitId: o,
|
|
980
|
-
row: i,
|
|
981
|
-
col: a,
|
|
982
|
-
workbook: l,
|
|
983
|
-
worksheet: u
|
|
984
|
-
},
|
|
985
|
-
trigger: "editor-bridge",
|
|
986
|
-
closeOnOutSide: !1
|
|
987
|
-
}
|
|
988
|
-
);
|
|
989
|
-
}
|
|
990
|
-
}));
|
|
991
|
-
}
|
|
992
|
-
// eslint-disable-next-line max-lines-per-function
|
|
993
|
-
_initViewModelIntercept() {
|
|
994
|
-
this.disposeWithMe(
|
|
995
|
-
this._sheetInterceptorService.intercept(
|
|
996
|
-
nr.CELL_CONTENT,
|
|
997
|
-
{
|
|
998
|
-
effect: zn.Style,
|
|
999
|
-
// must be after numfmt
|
|
1000
|
-
priority: rr.DATA_VALIDATION,
|
|
1001
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
1002
|
-
handler: (e, t, n) => {
|
|
1003
|
-
var C, f, w, M, g;
|
|
1004
|
-
const { row: r, col: o, unitId: i, subUnitId: a, workbook: l, worksheet: s } = t, d = this._sheetDataValidationModel.getRuleIdByLocation(i, a, r, o);
|
|
1005
|
-
if (!d)
|
|
1006
|
-
return n(e);
|
|
1007
|
-
const u = this._sheetDataValidationModel.getRuleById(i, a, d);
|
|
1008
|
-
if (!u)
|
|
1009
|
-
return n(e);
|
|
1010
|
-
const h = (C = this._dataValidationCacheService.getValue(i, a, r, o)) != null ? C : Ke.VALID, c = this._dataValidatorRegistryService.getValidatorItem(u.type), m = t.rawData;
|
|
1011
|
-
let I;
|
|
1012
|
-
const V = {
|
|
1013
|
-
get value() {
|
|
1014
|
-
var p;
|
|
1015
|
-
return I !== void 0 || (I = (p = ie(m)) != null ? p : null), I;
|
|
1016
|
-
}
|
|
1017
|
-
}, v = {
|
|
1018
|
-
get value() {
|
|
1019
|
-
var p;
|
|
1020
|
-
return `${(p = V.value) != null ? p : ""}`;
|
|
1021
|
-
}
|
|
1022
|
-
};
|
|
1023
|
-
return (!e || e === t.rawData) && (e = { ...t.rawData }), e.markers = {
|
|
1024
|
-
...e == null ? void 0 : e.markers,
|
|
1025
|
-
...h === Ke.INVALID ? Mr : null
|
|
1026
|
-
}, e.customRender = [
|
|
1027
|
-
...(f = e == null ? void 0 : e.customRender) != null ? f : [],
|
|
1028
|
-
...c != null && c.canvasRender ? [c.canvasRender] : []
|
|
1029
|
-
], e.fontRenderExtension = {
|
|
1030
|
-
...e == null ? void 0 : e.fontRenderExtension,
|
|
1031
|
-
isSkip: ((w = e == null ? void 0 : e.fontRenderExtension) == null ? void 0 : w.isSkip) || ((M = c == null ? void 0 : c.skipDefaultFontRender) == null ? void 0 : M.call(c, u, V.value, t))
|
|
1032
|
-
}, e.interceptorStyle = {
|
|
1033
|
-
...e == null ? void 0 : e.interceptorStyle,
|
|
1034
|
-
...c == null ? void 0 : c.getExtraStyle(u, v.value, {
|
|
1035
|
-
get style() {
|
|
1036
|
-
const p = l.getStyles();
|
|
1037
|
-
return (typeof (e == null ? void 0 : e.s) == "string" ? p.get(e == null ? void 0 : e.s) : e == null ? void 0 : e.s) || {};
|
|
1038
|
-
}
|
|
1039
|
-
}, r, o)
|
|
1040
|
-
}, e.interceptorAutoHeight = () => {
|
|
1041
|
-
var A, P, L, y, O, U;
|
|
1042
|
-
const p = (P = (A = this._renderManagerService.getRenderById(i)) == null ? void 0 : A.with(pt).getSkeletonParam(a)) == null ? void 0 : P.skeleton;
|
|
1043
|
-
if (!p)
|
|
1044
|
-
return;
|
|
1045
|
-
const _ = p.worksheet.getMergedCell(r, o), T = {
|
|
1046
|
-
data: e,
|
|
1047
|
-
style: p.getStyles().getStyleByCell(e),
|
|
1048
|
-
primaryWithCoord: p.getCellWithCoordByIndex((L = _ == null ? void 0 : _.startRow) != null ? L : r, (y = _ == null ? void 0 : _.startColumn) != null ? y : o),
|
|
1049
|
-
unitId: i,
|
|
1050
|
-
subUnitId: a,
|
|
1051
|
-
row: r,
|
|
1052
|
-
col: o,
|
|
1053
|
-
workbook: l,
|
|
1054
|
-
worksheet: s
|
|
1055
|
-
};
|
|
1056
|
-
return (U = (O = c == null ? void 0 : c.canvasRender) == null ? void 0 : O.calcCellAutoHeight) == null ? void 0 : U.call(O, T);
|
|
1057
|
-
}, e.interceptorAutoWidth = () => {
|
|
1058
|
-
var A, P, L, y, O, U;
|
|
1059
|
-
const p = (P = (A = this._renderManagerService.getRenderById(i)) == null ? void 0 : A.with(pt).getSkeletonParam(a)) == null ? void 0 : P.skeleton;
|
|
1060
|
-
if (!p)
|
|
1061
|
-
return;
|
|
1062
|
-
const _ = p.worksheet.getMergedCell(r, o), T = {
|
|
1063
|
-
data: e,
|
|
1064
|
-
style: p.getStyles().getStyleByCell(e),
|
|
1065
|
-
primaryWithCoord: p.getCellWithCoordByIndex((L = _ == null ? void 0 : _.startRow) != null ? L : r, (y = _ == null ? void 0 : _.startColumn) != null ? y : o),
|
|
1066
|
-
unitId: i,
|
|
1067
|
-
subUnitId: a,
|
|
1068
|
-
row: r,
|
|
1069
|
-
col: o,
|
|
1070
|
-
workbook: l,
|
|
1071
|
-
worksheet: s
|
|
1072
|
-
};
|
|
1073
|
-
return (U = (O = c == null ? void 0 : c.canvasRender) == null ? void 0 : O.calcCellAutoWidth) == null ? void 0 : U.call(O, T);
|
|
1074
|
-
}, e.coverable = ((g = e == null ? void 0 : e.coverable) != null ? g : !0) && !(u.type === X.LIST || u.type === X.LIST_MULTIPLE), n(e);
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
)
|
|
1078
|
-
);
|
|
1079
|
-
}
|
|
1080
|
-
_initAutoHeight() {
|
|
1081
|
-
this._sheetDataValidationModel.ruleChange$.pipe(
|
|
1082
|
-
// patched data-validation change don't need to re-calc row height
|
|
1083
|
-
// re-calc of row height will be triggered precisely by the origin command
|
|
1084
|
-
wn((e) => e.source === "command"),
|
|
1085
|
-
mr(100)
|
|
1086
|
-
).subscribe((e) => {
|
|
1087
|
-
if (e.length === 0)
|
|
1088
|
-
return;
|
|
1089
|
-
const t = [];
|
|
1090
|
-
if (e.forEach((n) => {
|
|
1091
|
-
var r;
|
|
1092
|
-
(n.rule.type === X.LIST_MULTIPLE || n.rule.type === X.LIST) && (r = n.rule) != null && r.ranges && t.push(...n.rule.ranges);
|
|
1093
|
-
}), t.length) {
|
|
1094
|
-
const n = this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);
|
|
1095
|
-
Kn(n.redos, this._commandService);
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
};
|
|
1100
|
-
rt = br([
|
|
1101
|
-
K(0, oe),
|
|
1102
|
-
K(1, wo),
|
|
1103
|
-
K(2, xe),
|
|
1104
|
-
K(3, pe),
|
|
1105
|
-
K(4, D(Sr)),
|
|
1106
|
-
K(5, D($e)),
|
|
1107
|
-
K(6, D(ae)),
|
|
1108
|
-
K(7, D(Te)),
|
|
1109
|
-
K(8, D(mn)),
|
|
1110
|
-
K(9, D(lr)),
|
|
1111
|
-
K(10, Br(_r))
|
|
1112
|
-
], rt);
|
|
1113
|
-
let Bn = class extends vn {
|
|
1114
|
-
constructor(e, t, n, r, o, i, a) {
|
|
1115
|
-
super(), this._commandService = e, this._renderManagerService = t, this._autoHeightController = n, this._dataValidatorRegistryService = r, this._sheetInterceptorService = o, this._sheetDataValidationModel = i, this._dataValidationCacheService = a, this._initViewModelIntercept(), this._initAutoHeight();
|
|
1116
|
-
}
|
|
1117
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1118
|
-
_initViewModelIntercept() {
|
|
1119
|
-
this.disposeWithMe(
|
|
1120
|
-
this._sheetInterceptorService.intercept(
|
|
1121
|
-
nr.CELL_CONTENT,
|
|
1122
|
-
{
|
|
1123
|
-
effect: zn.Style,
|
|
1124
|
-
// must be after numfmt
|
|
1125
|
-
priority: rr.DATA_VALIDATION,
|
|
1126
|
-
// eslint-disable-next-line complexity, max-lines-per-function
|
|
1127
|
-
handler: (e, t, n) => {
|
|
1128
|
-
var v, C, f, w, M;
|
|
1129
|
-
const { row: r, col: o, unitId: i, subUnitId: a, workbook: l, worksheet: s } = t, d = this._sheetDataValidationModel.getRuleIdByLocation(i, a, r, o);
|
|
1130
|
-
if (!d)
|
|
1131
|
-
return n(e);
|
|
1132
|
-
const u = this._sheetDataValidationModel.getRuleById(i, a, d);
|
|
1133
|
-
if (!u)
|
|
1134
|
-
return n(e);
|
|
1135
|
-
const h = (v = this._dataValidationCacheService.getValue(i, a, r, o)) != null ? v : Ke.VALID, c = this._dataValidatorRegistryService.getValidatorItem(u.type), m = s.getCellRaw(r, o), I = ie(m), V = `${I != null ? I : ""}`;
|
|
1136
|
-
return (!e || e === t.rawData) && (e = { ...t.rawData }), e.markers = {
|
|
1137
|
-
...e == null ? void 0 : e.markers,
|
|
1138
|
-
...h === Ke.INVALID ? Mr : null
|
|
1139
|
-
}, e.customRender = [
|
|
1140
|
-
...(C = e == null ? void 0 : e.customRender) != null ? C : [],
|
|
1141
|
-
...c != null && c.canvasRender ? [c.canvasRender] : []
|
|
1142
|
-
], e.fontRenderExtension = {
|
|
1143
|
-
...e == null ? void 0 : e.fontRenderExtension,
|
|
1144
|
-
isSkip: ((f = e == null ? void 0 : e.fontRenderExtension) == null ? void 0 : f.isSkip) || ((w = c == null ? void 0 : c.skipDefaultFontRender) == null ? void 0 : w.call(c, u, I, t))
|
|
1145
|
-
}, e.interceptorStyle = {
|
|
1146
|
-
...e == null ? void 0 : e.interceptorStyle,
|
|
1147
|
-
...c == null ? void 0 : c.getExtraStyle(u, V, {
|
|
1148
|
-
get style() {
|
|
1149
|
-
const g = l.getStyles();
|
|
1150
|
-
return (typeof (e == null ? void 0 : e.s) == "string" ? g.get(e == null ? void 0 : e.s) : e == null ? void 0 : e.s) || {};
|
|
1151
|
-
}
|
|
1152
|
-
}, r, o)
|
|
1153
|
-
}, e.interceptorAutoHeight = () => {
|
|
1154
|
-
var T, A, P, L, y, O;
|
|
1155
|
-
const g = (A = (T = this._renderManagerService.getRenderById(i)) == null ? void 0 : T.with(pt).getSkeletonParam(a)) == null ? void 0 : A.skeleton;
|
|
1156
|
-
if (!g)
|
|
1157
|
-
return;
|
|
1158
|
-
const p = g.worksheet.getMergedCell(r, o), _ = {
|
|
1159
|
-
data: e,
|
|
1160
|
-
style: g.getStyles().getStyleByCell(e),
|
|
1161
|
-
primaryWithCoord: g.getCellWithCoordByIndex((P = p == null ? void 0 : p.startRow) != null ? P : r, (L = p == null ? void 0 : p.startColumn) != null ? L : o),
|
|
1162
|
-
unitId: i,
|
|
1163
|
-
subUnitId: a,
|
|
1164
|
-
row: r,
|
|
1165
|
-
col: o,
|
|
1166
|
-
workbook: l,
|
|
1167
|
-
worksheet: s
|
|
1168
|
-
};
|
|
1169
|
-
return (O = (y = c == null ? void 0 : c.canvasRender) == null ? void 0 : y.calcCellAutoHeight) == null ? void 0 : O.call(y, _);
|
|
1170
|
-
}, e.interceptorAutoWidth = () => {
|
|
1171
|
-
var T, A, P, L, y, O;
|
|
1172
|
-
const g = (A = (T = this._renderManagerService.getRenderById(i)) == null ? void 0 : T.with(pt).getSkeletonParam(a)) == null ? void 0 : A.skeleton;
|
|
1173
|
-
if (!g)
|
|
1174
|
-
return;
|
|
1175
|
-
const p = g.worksheet.getMergedCell(r, o), _ = {
|
|
1176
|
-
data: e,
|
|
1177
|
-
style: g.getStyles().getStyleByCell(e),
|
|
1178
|
-
primaryWithCoord: g.getCellWithCoordByIndex((P = p == null ? void 0 : p.startRow) != null ? P : r, (L = p == null ? void 0 : p.startColumn) != null ? L : o),
|
|
1179
|
-
unitId: i,
|
|
1180
|
-
subUnitId: a,
|
|
1181
|
-
row: r,
|
|
1182
|
-
col: o,
|
|
1183
|
-
workbook: l,
|
|
1184
|
-
worksheet: s
|
|
1185
|
-
};
|
|
1186
|
-
return (O = (y = c == null ? void 0 : c.canvasRender) == null ? void 0 : y.calcCellAutoWidth) == null ? void 0 : O.call(y, _);
|
|
1187
|
-
}, e.coverable = ((M = e == null ? void 0 : e.coverable) != null ? M : !0) && !(u.type === X.LIST || u.type === X.LIST_MULTIPLE), n(e);
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
)
|
|
1191
|
-
);
|
|
1192
|
-
}
|
|
1193
|
-
_initAutoHeight() {
|
|
1194
|
-
this._sheetDataValidationModel.ruleChange$.pipe(
|
|
1195
|
-
wn((e) => e.source === "command"),
|
|
1196
|
-
mr(16)
|
|
1197
|
-
).subscribe((e) => {
|
|
1198
|
-
const t = [];
|
|
1199
|
-
if (e.forEach((n) => {
|
|
1200
|
-
var r;
|
|
1201
|
-
(n.rule.type === X.LIST_MULTIPLE || n.rule.type === X.LIST) && (r = n.rule) != null && r.ranges && t.push(...n.rule.ranges);
|
|
1202
|
-
}), t.length) {
|
|
1203
|
-
const n = this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);
|
|
1204
|
-
Kn(n.redos, this._commandService);
|
|
1205
|
-
}
|
|
1206
|
-
});
|
|
1207
|
-
}
|
|
1208
|
-
};
|
|
1209
|
-
Bn = br([
|
|
1210
|
-
K(0, oe),
|
|
1211
|
-
K(1, xe),
|
|
1212
|
-
K(2, D(Sr)),
|
|
1213
|
-
K(3, D(Te)),
|
|
1214
|
-
K(4, D(mn)),
|
|
1215
|
-
K(5, D(ae)),
|
|
1216
|
-
K(6, D(lr))
|
|
1217
|
-
], Bn);
|
|
1218
|
-
var ii = Object.getOwnPropertyDescriptor, ai = (e, t, n, r) => {
|
|
1219
|
-
for (var o = r > 1 ? void 0 : r ? ii(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
1220
|
-
(a = e[i]) && (o = a(o) || o);
|
|
1221
|
-
return o;
|
|
1222
|
-
}, Wn = (e, t) => (n, r) => t(n, r, e);
|
|
1223
|
-
let At = class extends De {
|
|
1224
|
-
constructor(e, t, n) {
|
|
1225
|
-
super(), this._context = e, this._sheetDataValidationModel = t, this._sheetSkeletonManagerService = n, this._initSkeletonChange();
|
|
1226
|
-
}
|
|
1227
|
-
_initSkeletonChange() {
|
|
1228
|
-
const e = (t) => {
|
|
1229
|
-
var r;
|
|
1230
|
-
if (!t.length)
|
|
1231
|
-
return;
|
|
1232
|
-
const n = /* @__PURE__ */ new Set();
|
|
1233
|
-
t.forEach((o) => {
|
|
1234
|
-
n.add(o.subUnitId);
|
|
1235
|
-
}), n.forEach((o) => {
|
|
1236
|
-
var i;
|
|
1237
|
-
(i = this._sheetSkeletonManagerService.getSkeletonParam(o)) == null || i.skeleton.makeDirty(!0);
|
|
1238
|
-
}), (r = this._context.mainComponent) == null || r.makeForceDirty();
|
|
1239
|
-
};
|
|
1240
|
-
this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(Wr(16)).subscribe(e));
|
|
1241
|
-
}
|
|
1242
|
-
};
|
|
1243
|
-
At = ai([
|
|
1244
|
-
Wn(1, D(ae)),
|
|
1245
|
-
Wn(2, D(pt))
|
|
1246
|
-
], At);
|
|
1247
|
-
function We({ ref: e, ...t }) {
|
|
1248
|
-
const { icon: n, id: r, className: o, extend: i, ...a } = t, l = `univerjs-icon univerjs-icon-${r} ${o || ""}`.trim(), s = ft(`_${di()}`);
|
|
1249
|
-
return Er(n, `${r}`, {
|
|
1250
|
-
defIds: n.defIds,
|
|
1251
|
-
idSuffix: s.current
|
|
1252
|
-
}, {
|
|
1253
|
-
ref: e,
|
|
1254
|
-
className: l,
|
|
1255
|
-
...a
|
|
1256
|
-
}, i);
|
|
1257
|
-
}
|
|
1258
|
-
function Er(e, t, n, r, o) {
|
|
1259
|
-
return ye(e.tag, {
|
|
1260
|
-
key: t,
|
|
1261
|
-
...si(e, n, o),
|
|
1262
|
-
...r
|
|
1263
|
-
}, (li(e, n).children || []).map((i, a) => Er(i, `${t}-${e.tag}-${a}`, n, void 0, o)));
|
|
1264
|
-
}
|
|
1265
|
-
function si(e, t, n) {
|
|
1266
|
-
const r = { ...e.attrs };
|
|
1267
|
-
n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1), e.tag === "mask" && r.id && (r.id = r.id + t.idSuffix), Object.entries(r).forEach(([i, a]) => {
|
|
1268
|
-
i === "mask" && typeof a == "string" && (r[i] = a.replace(/url\(#(.*)\)/, `url(#$1${t.idSuffix})`));
|
|
1269
|
-
});
|
|
1270
|
-
const { defIds: o } = t;
|
|
1271
|
-
return !o || o.length === 0 || (e.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + t.idSuffix), Object.entries(r).forEach(([i, a]) => {
|
|
1272
|
-
typeof a == "string" && (r[i] = a.replace(/url\(#(.*)\)/, `url(#$1${t.idSuffix})`));
|
|
1273
|
-
})), r;
|
|
1274
|
-
}
|
|
1275
|
-
function li(e, t) {
|
|
1276
|
-
var r;
|
|
1277
|
-
const { defIds: n } = t;
|
|
1278
|
-
return !n || n.length === 0 ? e : e.tag === "defs" && ((r = e.children) != null && r.length) ? {
|
|
1279
|
-
...e,
|
|
1280
|
-
children: e.children.map((o) => typeof o.attrs.id == "string" && n && n.includes(o.attrs.id) ? {
|
|
1281
|
-
...o,
|
|
1282
|
-
attrs: {
|
|
1283
|
-
...o.attrs,
|
|
1284
|
-
id: o.attrs.id + t.idSuffix
|
|
1285
|
-
}
|
|
1286
|
-
} : o)
|
|
1287
|
-
} : e;
|
|
1288
|
-
}
|
|
1289
|
-
function di() {
|
|
1290
|
-
return Math.random().toString(36).substring(2, 8);
|
|
1291
|
-
}
|
|
1292
|
-
We.displayName = "UniverIcon";
|
|
1293
|
-
const ci = {
|
|
1294
|
-
tag: "svg",
|
|
1295
|
-
attrs: {
|
|
1296
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1297
|
-
fill: "none",
|
|
1298
|
-
viewBox: "0 0 17 16",
|
|
1299
|
-
width: "1em",
|
|
1300
|
-
height: "1em"
|
|
1301
|
-
},
|
|
1302
|
-
children: [
|
|
1303
|
-
{
|
|
1304
|
-
tag: "path",
|
|
1305
|
-
attrs: {
|
|
1306
|
-
fill: "currentColor",
|
|
1307
|
-
d: "M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",
|
|
1308
|
-
fillRule: "evenodd",
|
|
1309
|
-
clipRule: "evenodd"
|
|
1310
|
-
}
|
|
1311
|
-
},
|
|
1312
|
-
{
|
|
1313
|
-
tag: "path",
|
|
1314
|
-
attrs: {
|
|
1315
|
-
fill: "currentColor",
|
|
1316
|
-
d: "M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062C8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767L13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279Z"
|
|
1317
|
-
}
|
|
1318
|
-
},
|
|
1319
|
-
{
|
|
1320
|
-
tag: "path",
|
|
1321
|
-
attrs: {
|
|
1322
|
-
fill: "currentColor",
|
|
1323
|
-
d: "M14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217L14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046C13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703L10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046C9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217L9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746C9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732L13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746Z"
|
|
1324
|
-
}
|
|
1325
|
-
},
|
|
1326
|
-
{
|
|
1327
|
-
tag: "path",
|
|
1328
|
-
attrs: {
|
|
1329
|
-
fill: "currentColor",
|
|
1330
|
-
d: "M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",
|
|
1331
|
-
fillRule: "evenodd",
|
|
1332
|
-
clipRule: "evenodd"
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
]
|
|
1336
|
-
}, Dr = st(function(t, n) {
|
|
1337
|
-
return ye(We, Object.assign({}, t, {
|
|
1338
|
-
id: "data-validation-icon",
|
|
1339
|
-
ref: n,
|
|
1340
|
-
icon: ci
|
|
1341
|
-
}));
|
|
1342
|
-
});
|
|
1343
|
-
Dr.displayName = "DataValidationIcon";
|
|
1344
|
-
const ui = {
|
|
1345
|
-
tag: "svg",
|
|
1346
|
-
attrs: {
|
|
1347
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1348
|
-
fill: "none",
|
|
1349
|
-
viewBox: "0 0 16 16",
|
|
1350
|
-
width: "1em",
|
|
1351
|
-
height: "1em"
|
|
1352
|
-
},
|
|
1353
|
-
children: [
|
|
1354
|
-
{
|
|
1355
|
-
tag: "path",
|
|
1356
|
-
attrs: {
|
|
1357
|
-
fill: "currentColor",
|
|
1358
|
-
d: "M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"
|
|
1359
|
-
}
|
|
1360
|
-
},
|
|
1361
|
-
{
|
|
1362
|
-
tag: "path",
|
|
1363
|
-
attrs: {
|
|
1364
|
-
fill: "currentColor",
|
|
1365
|
-
d: "M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"
|
|
1366
|
-
}
|
|
1367
|
-
},
|
|
1368
|
-
{
|
|
1369
|
-
tag: "path",
|
|
1370
|
-
attrs: {
|
|
1371
|
-
fill: "currentColor",
|
|
1372
|
-
d: "M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"
|
|
1373
|
-
}
|
|
1374
|
-
},
|
|
1375
|
-
{
|
|
1376
|
-
tag: "path",
|
|
1377
|
-
attrs: {
|
|
1378
|
-
fill: "currentColor",
|
|
1379
|
-
d: "M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",
|
|
1380
|
-
fillRule: "evenodd",
|
|
1381
|
-
clipRule: "evenodd"
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
]
|
|
1385
|
-
}, bn = st(function(t, n) {
|
|
1386
|
-
return ye(We, Object.assign({}, t, {
|
|
1387
|
-
id: "delete-icon",
|
|
1388
|
-
ref: n,
|
|
1389
|
-
icon: ui
|
|
1390
|
-
}));
|
|
1391
|
-
});
|
|
1392
|
-
bn.displayName = "DeleteIcon";
|
|
1393
|
-
const hi = {
|
|
1394
|
-
tag: "svg",
|
|
1395
|
-
attrs: {
|
|
1396
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1397
|
-
fill: "none",
|
|
1398
|
-
viewBox: "0 0 16 16",
|
|
1399
|
-
width: "1em",
|
|
1400
|
-
height: "1em"
|
|
1401
|
-
},
|
|
1402
|
-
children: [{
|
|
1403
|
-
tag: "path",
|
|
1404
|
-
attrs: {
|
|
1405
|
-
fill: "currentColor",
|
|
1406
|
-
d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"
|
|
1407
|
-
}
|
|
1408
|
-
}]
|
|
1409
|
-
}, Vr = st(function(t, n) {
|
|
1410
|
-
return ye(We, Object.assign({}, t, {
|
|
1411
|
-
id: "increase-icon",
|
|
1412
|
-
ref: n,
|
|
1413
|
-
icon: hi
|
|
1414
|
-
}));
|
|
1415
|
-
});
|
|
1416
|
-
Vr.displayName = "IncreaseIcon";
|
|
1417
|
-
const pi = {
|
|
1418
|
-
tag: "svg",
|
|
1419
|
-
attrs: {
|
|
1420
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1421
|
-
fill: "none",
|
|
1422
|
-
viewBox: "0 0 16 16",
|
|
1423
|
-
width: "1em",
|
|
1424
|
-
height: "1em"
|
|
1425
|
-
},
|
|
1426
|
-
children: [{
|
|
1427
|
-
tag: "path",
|
|
1428
|
-
attrs: {
|
|
1429
|
-
fill: "currentColor",
|
|
1430
|
-
d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",
|
|
1431
|
-
fillRule: "evenodd",
|
|
1432
|
-
clipRule: "evenodd"
|
|
1433
|
-
}
|
|
1434
|
-
}]
|
|
1435
|
-
}, Mn = st(function(t, n) {
|
|
1436
|
-
return ye(We, Object.assign({}, t, {
|
|
1437
|
-
id: "more-down-icon",
|
|
1438
|
-
ref: n,
|
|
1439
|
-
icon: pi
|
|
1440
|
-
}));
|
|
1441
|
-
});
|
|
1442
|
-
Mn.displayName = "MoreDownIcon";
|
|
1443
|
-
const gi = {
|
|
1444
|
-
tag: "svg",
|
|
1445
|
-
attrs: {
|
|
1446
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1447
|
-
fill: "none",
|
|
1448
|
-
viewBox: "0 0 16 16",
|
|
1449
|
-
width: "1em",
|
|
1450
|
-
height: "1em"
|
|
1451
|
-
},
|
|
1452
|
-
children: [{
|
|
1453
|
-
tag: "path",
|
|
1454
|
-
attrs: {
|
|
1455
|
-
fill: "currentColor",
|
|
1456
|
-
d: "M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",
|
|
1457
|
-
fillRule: "evenodd",
|
|
1458
|
-
clipRule: "evenodd"
|
|
1459
|
-
}
|
|
1460
|
-
}]
|
|
1461
|
-
}, Tr = st(function(t, n) {
|
|
1462
|
-
return ye(We, Object.assign({}, t, {
|
|
1463
|
-
id: "more-up-icon",
|
|
1464
|
-
ref: n,
|
|
1465
|
-
icon: gi
|
|
1466
|
-
}));
|
|
1467
|
-
});
|
|
1468
|
-
Tr.displayName = "MoreUpIcon";
|
|
1469
|
-
const vi = {
|
|
1470
|
-
tag: "svg",
|
|
1471
|
-
attrs: {
|
|
1472
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1473
|
-
fill: "none",
|
|
1474
|
-
viewBox: "0 0 16 16",
|
|
1475
|
-
width: "1em",
|
|
1476
|
-
height: "1em"
|
|
1477
|
-
},
|
|
1478
|
-
children: [
|
|
1479
|
-
{
|
|
1480
|
-
tag: "path",
|
|
1481
|
-
attrs: {
|
|
1482
|
-
fill: "currentColor",
|
|
1483
|
-
d: "M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"
|
|
1484
|
-
}
|
|
1485
|
-
},
|
|
1486
|
-
{
|
|
1487
|
-
tag: "path",
|
|
1488
|
-
attrs: {
|
|
1489
|
-
fill: "currentColor",
|
|
1490
|
-
d: "M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"
|
|
1491
|
-
}
|
|
1492
|
-
},
|
|
1493
|
-
{
|
|
1494
|
-
tag: "path",
|
|
1495
|
-
attrs: {
|
|
1496
|
-
fill: "currentColor",
|
|
1497
|
-
d: "M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"
|
|
1498
|
-
}
|
|
1499
|
-
},
|
|
1500
|
-
{
|
|
1501
|
-
tag: "path",
|
|
1502
|
-
attrs: {
|
|
1503
|
-
fill: "currentColor",
|
|
1504
|
-
d: "M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"
|
|
1505
|
-
}
|
|
1506
|
-
},
|
|
1507
|
-
{
|
|
1508
|
-
tag: "path",
|
|
1509
|
-
attrs: {
|
|
1510
|
-
fill: "currentColor",
|
|
1511
|
-
d: "M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"
|
|
1512
|
-
}
|
|
1513
|
-
},
|
|
1514
|
-
{
|
|
1515
|
-
tag: "path",
|
|
1516
|
-
attrs: {
|
|
1517
|
-
fill: "currentColor",
|
|
1518
|
-
d: "M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
]
|
|
1522
|
-
}, Or = st(function(t, n) {
|
|
1523
|
-
return ye(We, Object.assign({}, t, {
|
|
1524
|
-
id: "sequence-icon",
|
|
1525
|
-
ref: n,
|
|
1526
|
-
icon: vi
|
|
1527
|
-
}));
|
|
1528
|
-
});
|
|
1529
|
-
Or.displayName = "SequenceIcon";
|
|
1530
|
-
function mi(e) {
|
|
1531
|
-
var d;
|
|
1532
|
-
const t = F(ge), n = F(In), { value: r, onChange: o, extraComponent: i } = e, [a, l] = W(!1), s = i ? n.get(i) : null;
|
|
1533
|
-
return /* @__PURE__ */ Y(vt, { children: [
|
|
1534
|
-
/* @__PURE__ */ Y(
|
|
1535
|
-
"div",
|
|
1536
|
-
{
|
|
1537
|
-
className: "univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",
|
|
1538
|
-
onClick: () => l(!a),
|
|
1539
|
-
children: [
|
|
1540
|
-
t.t("dataValidation.panel.options"),
|
|
1541
|
-
a ? /* @__PURE__ */ S(Tr, { className: "univer-ml-1" }) : /* @__PURE__ */ S(Mn, { className: "univer-ml-1" })
|
|
1542
|
-
]
|
|
1543
|
-
}
|
|
1544
|
-
),
|
|
1545
|
-
a && /* @__PURE__ */ Y(vt, { children: [
|
|
1546
|
-
s ? /* @__PURE__ */ S(s, { value: r, onChange: o }) : null,
|
|
1547
|
-
/* @__PURE__ */ S(
|
|
1548
|
-
Z,
|
|
1549
|
-
{
|
|
1550
|
-
label: t.t("dataValidation.panel.invalid"),
|
|
1551
|
-
children: /* @__PURE__ */ Y(
|
|
1552
|
-
Rn,
|
|
1553
|
-
{
|
|
1554
|
-
value: `${(d = r.errorStyle) != null ? d : ht.WARNING}`,
|
|
1555
|
-
onChange: (u) => o({ ...r, errorStyle: +u }),
|
|
1556
|
-
children: [
|
|
1557
|
-
/* @__PURE__ */ S(Ne, { value: `${ht.WARNING}`, children: t.t("dataValidation.panel.showWarning") }),
|
|
1558
|
-
/* @__PURE__ */ S(Ne, { value: `${ht.STOP}`, children: t.t("dataValidation.panel.rejectInput") })
|
|
1559
|
-
]
|
|
1560
|
-
}
|
|
1561
|
-
)
|
|
1562
|
-
}
|
|
1563
|
-
),
|
|
1564
|
-
/* @__PURE__ */ S(
|
|
1565
|
-
Z,
|
|
1566
|
-
{
|
|
1567
|
-
label: t.t("dataValidation.panel.messageInfo"),
|
|
1568
|
-
children: /* @__PURE__ */ S(
|
|
1569
|
-
Ut,
|
|
1570
|
-
{
|
|
1571
|
-
checked: r.showErrorMessage,
|
|
1572
|
-
onChange: () => o({
|
|
1573
|
-
...r,
|
|
1574
|
-
showErrorMessage: !r.showErrorMessage
|
|
1575
|
-
}),
|
|
1576
|
-
children: t.t("dataValidation.panel.showInfo")
|
|
1577
|
-
}
|
|
1578
|
-
)
|
|
1579
|
-
}
|
|
1580
|
-
),
|
|
1581
|
-
r.showErrorMessage ? /* @__PURE__ */ S(Z, { children: /* @__PURE__ */ S(Ue, { value: r.error, onChange: (u) => o({ ...r, error: u }) }) }) : null
|
|
1582
|
-
] })
|
|
1583
|
-
] });
|
|
1584
|
-
}
|
|
1585
|
-
const fi = (e) => Hr(
|
|
1586
|
-
async (t, n, r, o) => {
|
|
1587
|
-
const i = await e.executeCommand(t, n, r);
|
|
1588
|
-
o == null || o(i);
|
|
1589
|
-
},
|
|
1590
|
-
1e3
|
|
1591
|
-
);
|
|
1592
|
-
function _i(e, t, n) {
|
|
1593
|
-
var r, o, i, a;
|
|
1594
|
-
return t ? ((o = (r = e.getUnit(t)) == null ? void 0 : r.getSheetBySheetName(n)) == null ? void 0 : o.getSheetId()) || "" : ((a = (i = e.getCurrentUnitForType(H.UNIVER_SHEET)) == null ? void 0 : i.getSheetBySheetName(n)) == null ? void 0 : a.getSheetId()) || "";
|
|
1595
|
-
}
|
|
1596
|
-
function Si() {
|
|
1597
|
-
var N, J;
|
|
1598
|
-
const [e, t] = W(0), n = F(_e), r = Re(n.activeRule$, n.activeRule), { unitId: o, subUnitId: i, rule: a } = r || {}, l = a.uid, s = F(Te), d = F(pe), u = F(In), h = F(oe), c = F(Sn), m = F(ge), I = Re(
|
|
1599
|
-
() => d.getCurrentTypeOfUnit$(H.UNIVER_SHEET),
|
|
1600
|
-
void 0,
|
|
1601
|
-
void 0,
|
|
1602
|
-
[]
|
|
1603
|
-
), V = Re(() => {
|
|
1604
|
-
var R;
|
|
1605
|
-
return (R = I == null ? void 0 : I.activeSheet$) != null ? R : fr(null);
|
|
1606
|
-
}, void 0, void 0, []), [v, C] = W(a), f = s.getValidatorItem(v.type), [w, M] = W(!1), g = s.getValidatorsByScope(fo.SHEET), [p, _] = W(() => v.ranges.map((R) => ({ unitId: "", sheetId: "", range: R }))), T = gt(() => fi(h), [h]), [A, P] = W(!1), [L, y] = W(!1), O = ft(null), U = F(er);
|
|
1607
|
-
if (Me(() => () => {
|
|
1608
|
-
const R = U.getCurrentLastSelection();
|
|
1609
|
-
R && U.setSelections([R]);
|
|
1610
|
-
}, [U]), Me(() => {
|
|
1611
|
-
h.onCommandExecuted((R) => {
|
|
1612
|
-
(R.id === jr.id || R.id === Yr.id) && setTimeout(() => {
|
|
1613
|
-
const B = c.getRuleById(o, i, l);
|
|
1614
|
-
t((z) => z + 1), B && (C(B), _(B.ranges.map((z) => ({ unitId: "", sheetId: "", range: z }))));
|
|
1615
|
-
}, 20);
|
|
1616
|
-
});
|
|
1617
|
-
}, [h, c, l, i, o]), !f)
|
|
1618
|
-
return null;
|
|
1619
|
-
const k = f.operators, x = f.operatorNames, te = v.operator ? _o.includes(v.operator) : !1, j = () => {
|
|
1620
|
-
(V == null ? void 0 : V.getSheetId()) !== i && h.syncExecuteCommand(oo.id, {
|
|
1621
|
-
unitId: o,
|
|
1622
|
-
subUnitId: i
|
|
1623
|
-
});
|
|
1624
|
-
}, se = () => {
|
|
1625
|
-
var R, B, z;
|
|
1626
|
-
(B = (R = O.current) == null ? void 0 : R.editor) != null && B.isFocus() && le((z = O.current) == null ? void 0 : z.getValue()), !(!v.ranges.length || A) && (f.validatorFormula(v, o, i).success ? n.setActiveRule(null) : M(!0), j());
|
|
1627
|
-
}, le = ln((R) => {
|
|
1628
|
-
const B = R.split(",").filter(Boolean).map(ko).map((ne) => {
|
|
1629
|
-
const En = ne.sheetName;
|
|
1630
|
-
if (En) {
|
|
1631
|
-
const Lr = _i(d, ne.unitId, En);
|
|
1632
|
-
return { ...ne, sheetId: Lr };
|
|
1633
|
-
}
|
|
1634
|
-
return {
|
|
1635
|
-
...ne,
|
|
1636
|
-
sheetId: ""
|
|
1637
|
-
};
|
|
1638
|
-
});
|
|
1639
|
-
if (Xr(B, p))
|
|
1640
|
-
return;
|
|
1641
|
-
_(B);
|
|
1642
|
-
const z = B.filter((ne) => (!ne.unitId || ne.unitId === o) && (!ne.sheetId || ne.sheetId === i)).map((ne) => ne.range);
|
|
1643
|
-
if (C({
|
|
1644
|
-
...v,
|
|
1645
|
-
ranges: z
|
|
1646
|
-
}), z.length === 0)
|
|
1647
|
-
return;
|
|
1648
|
-
const Ie = {
|
|
1649
|
-
unitId: o,
|
|
1650
|
-
subUnitId: i,
|
|
1651
|
-
ruleId: l,
|
|
1652
|
-
ranges: z
|
|
1653
|
-
};
|
|
1654
|
-
T(sr.id, Ie);
|
|
1655
|
-
}), de = (R) => {
|
|
1656
|
-
if (Dn(R, kn(v)))
|
|
1657
|
-
return;
|
|
1658
|
-
C({
|
|
1659
|
-
...v,
|
|
1660
|
-
...R
|
|
1661
|
-
});
|
|
1662
|
-
const B = {
|
|
1663
|
-
unitId: o,
|
|
1664
|
-
subUnitId: i,
|
|
1665
|
-
ruleId: l,
|
|
1666
|
-
setting: R
|
|
1667
|
-
};
|
|
1668
|
-
T(
|
|
1669
|
-
An.id,
|
|
1670
|
-
B,
|
|
1671
|
-
void 0
|
|
1672
|
-
);
|
|
1673
|
-
}, be = async () => {
|
|
1674
|
-
await h.executeCommand(dr.id, {
|
|
1675
|
-
ruleId: l,
|
|
1676
|
-
unitId: o,
|
|
1677
|
-
subUnitId: i
|
|
1678
|
-
}), n.setActiveRule(null), j();
|
|
1679
|
-
}, Q = {
|
|
1680
|
-
type: v.type,
|
|
1681
|
-
operator: v.operator,
|
|
1682
|
-
formula1: v.formula1,
|
|
1683
|
-
formula2: v.formula2,
|
|
1684
|
-
allowBlank: v.allowBlank
|
|
1685
|
-
}, G = (R) => {
|
|
1686
|
-
const B = s.getValidatorItem(R);
|
|
1687
|
-
if (!B)
|
|
1688
|
-
return;
|
|
1689
|
-
const z = B.operators, Ie = c.getRuleById(o, i, l), ne = R === (Ie == null ? void 0 : Ie.type) || R.includes("list") && (Ie != null && Ie.type.includes("list")) ? {
|
|
1690
|
-
...Ie,
|
|
1691
|
-
type: R
|
|
1692
|
-
} : {
|
|
1693
|
-
...v,
|
|
1694
|
-
type: R,
|
|
1695
|
-
operator: z[0],
|
|
1696
|
-
formula1: void 0,
|
|
1697
|
-
formula2: void 0
|
|
1698
|
-
};
|
|
1699
|
-
C(ne), h.executeCommand(An.id, {
|
|
1700
|
-
unitId: o,
|
|
1701
|
-
subUnitId: i,
|
|
1702
|
-
ruleId: v.uid,
|
|
1703
|
-
setting: kn(ne)
|
|
1704
|
-
});
|
|
1705
|
-
}, ce = u.get(f.formulaInput), ee = gt(() => p.map((R) => Cr(R.range)).join(","), []), q = Ln(v), b = (R) => {
|
|
1706
|
-
Dn(R, Ln(v)) || (C({
|
|
1707
|
-
...v,
|
|
1708
|
-
...R
|
|
1709
|
-
}), T(
|
|
1710
|
-
so.id,
|
|
1711
|
-
{
|
|
1712
|
-
unitId: o,
|
|
1713
|
-
subUnitId: i,
|
|
1714
|
-
ruleId: l,
|
|
1715
|
-
options: R
|
|
1716
|
-
}
|
|
1717
|
-
));
|
|
1718
|
-
}, $ = k.length && !v.operator;
|
|
1719
|
-
return /* @__PURE__ */ Y("div", { "data-u-comp": "data-validation-detail", className: "univer-py-2", children: [
|
|
1720
|
-
/* @__PURE__ */ S(
|
|
1721
|
-
Z,
|
|
1722
|
-
{
|
|
1723
|
-
label: m.t("dataValidation.panel.range"),
|
|
1724
|
-
error: !v.ranges.length || A ? m.t("dataValidation.panel.rangeError") : "",
|
|
1725
|
-
children: /* @__PURE__ */ S(
|
|
1726
|
-
No,
|
|
1727
|
-
{
|
|
1728
|
-
selectorRef: O,
|
|
1729
|
-
unitId: o,
|
|
1730
|
-
subUnitId: i,
|
|
1731
|
-
initialValue: ee,
|
|
1732
|
-
onChange: (R, B) => {
|
|
1733
|
-
var z;
|
|
1734
|
-
!L && ((z = O.current) != null && z.verify()) && le(B);
|
|
1735
|
-
},
|
|
1736
|
-
onFocusChange: (R, B) => {
|
|
1737
|
-
var z;
|
|
1738
|
-
y(R), !R && B && ((z = O.current) != null && z.verify()) && le(B);
|
|
1739
|
-
},
|
|
1740
|
-
onVerify: (R) => P(!R)
|
|
1741
|
-
}
|
|
1742
|
-
)
|
|
1743
|
-
}
|
|
1744
|
-
),
|
|
1745
|
-
/* @__PURE__ */ S(Z, { label: m.t("dataValidation.panel.type"), children: /* @__PURE__ */ S(
|
|
1746
|
-
$n,
|
|
1747
|
-
{
|
|
1748
|
-
className: "univer-w-full",
|
|
1749
|
-
value: v.type,
|
|
1750
|
-
options: (N = g == null ? void 0 : g.sort((R, B) => R.order - B.order)) == null ? void 0 : N.map((R) => ({
|
|
1751
|
-
label: m.t(R.title),
|
|
1752
|
-
value: R.id
|
|
1753
|
-
})),
|
|
1754
|
-
onChange: G
|
|
1755
|
-
}
|
|
1756
|
-
) }),
|
|
1757
|
-
k != null && k.length ? /* @__PURE__ */ S(Z, { label: m.t("dataValidation.panel.operator"), children: /* @__PURE__ */ S(
|
|
1758
|
-
$n,
|
|
1759
|
-
{
|
|
1760
|
-
className: "univer-w-full",
|
|
1761
|
-
value: `${v.operator}`,
|
|
1762
|
-
options: [
|
|
1763
|
-
{
|
|
1764
|
-
value: "",
|
|
1765
|
-
label: m.t("dataValidation.operators.legal")
|
|
1766
|
-
},
|
|
1767
|
-
...k.map((R, B) => ({
|
|
1768
|
-
value: `${R}`,
|
|
1769
|
-
label: x[B]
|
|
1770
|
-
}))
|
|
1771
|
-
],
|
|
1772
|
-
onChange: (R) => {
|
|
1773
|
-
de({
|
|
1774
|
-
...Q,
|
|
1775
|
-
operator: R
|
|
1776
|
-
});
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
) }) : null,
|
|
1780
|
-
ce && !$ ? /* @__PURE__ */ S(
|
|
1781
|
-
ce,
|
|
1782
|
-
{
|
|
1783
|
-
isTwoFormula: te,
|
|
1784
|
-
value: {
|
|
1785
|
-
formula1: v.formula1,
|
|
1786
|
-
formula2: v.formula2
|
|
1787
|
-
},
|
|
1788
|
-
onChange: (R) => {
|
|
1789
|
-
de({
|
|
1790
|
-
...Q,
|
|
1791
|
-
...R
|
|
1792
|
-
});
|
|
1793
|
-
},
|
|
1794
|
-
showError: w,
|
|
1795
|
-
validResult: f.validatorFormula(v, o, i),
|
|
1796
|
-
unitId: o,
|
|
1797
|
-
subUnitId: i,
|
|
1798
|
-
ruleId: l
|
|
1799
|
-
},
|
|
1800
|
-
e + v.type
|
|
1801
|
-
) : null,
|
|
1802
|
-
/* @__PURE__ */ S(Z, { children: /* @__PURE__ */ S(
|
|
1803
|
-
Ut,
|
|
1804
|
-
{
|
|
1805
|
-
checked: (J = v.allowBlank) != null ? J : !0,
|
|
1806
|
-
onChange: () => {
|
|
1807
|
-
var R;
|
|
1808
|
-
return de({
|
|
1809
|
-
...Q,
|
|
1810
|
-
allowBlank: !((R = v.allowBlank) == null || R)
|
|
1811
|
-
});
|
|
1812
|
-
},
|
|
1813
|
-
children: m.t("dataValidation.panel.allowBlank")
|
|
1814
|
-
}
|
|
1815
|
-
) }),
|
|
1816
|
-
/* @__PURE__ */ S(mi, { value: q, onChange: b, extraComponent: f.optionsInput }),
|
|
1817
|
-
/* @__PURE__ */ Y("div", { className: "univer-mt-5 univer-flex univer-flex-row univer-justify-end", children: [
|
|
1818
|
-
/* @__PURE__ */ S(Je, { className: "univer-ml-3", onClick: be, children: m.t("dataValidation.panel.removeRule") }),
|
|
1819
|
-
/* @__PURE__ */ S(Je, { className: "univer-ml-3", variant: "primary", onClick: se, children: m.t("dataValidation.panel.done") })
|
|
1820
|
-
] })
|
|
1821
|
-
] });
|
|
1822
|
-
}
|
|
1823
|
-
const Ci = (e) => {
|
|
1824
|
-
const { rule: t, onClick: n, unitId: r, subUnitId: o, disable: i } = e, a = F(Te), l = F(oe), s = F(Ao), d = a.getValidatorItem(t.type), u = ft(void 0), [h, c] = W(!1), m = F(Gn), I = Re(m.currentTheme$), V = gt(() => {
|
|
1825
|
-
var g;
|
|
1826
|
-
const C = m.getColorFromTheme("primary.600"), f = m.getColorFromTheme("loop-color.2"), w = (g = m.getColorFromTheme(f)) != null ? g : C, M = new Zr(w).toRgb();
|
|
1827
|
-
return {
|
|
1828
|
-
fill: `rgba(${M.r}, ${M.g}, ${M.b}, 0.1)`,
|
|
1829
|
-
stroke: w
|
|
1830
|
-
};
|
|
1831
|
-
}, [I]), v = (C) => {
|
|
1832
|
-
l.executeCommand(dr.id, {
|
|
1833
|
-
ruleId: t.uid,
|
|
1834
|
-
unitId: r,
|
|
1835
|
-
subUnitId: o
|
|
1836
|
-
}), C.stopPropagation();
|
|
1837
|
-
};
|
|
1838
|
-
return Me(() => () => {
|
|
1839
|
-
var C;
|
|
1840
|
-
u.current && ((C = u.current) == null || C.forEach((f) => {
|
|
1841
|
-
f && s.removeShape(f);
|
|
1842
|
-
}));
|
|
1843
|
-
}, [s]), /* @__PURE__ */ Y(
|
|
1844
|
-
"div",
|
|
1845
|
-
{
|
|
1846
|
-
className: Fe(
|
|
1847
|
-
`
|
|
1
|
+
import{CellValueType as e,ColorKit as t,CommandType as n,DEFAULT_STYLES as r,DataValidationErrorStyle as i,DataValidationRenderMode as a,DataValidationStatus as o,DataValidationType as s,DependentOn as c,Disposable as l,DisposableCollection as u,HorizontalAlign as d,ICommandService as f,IConfigService as p,IUniverInstanceService as m,Inject as h,Injector as g,InterceptorEffectEnum as _,LocaleService as v,ObjectMatrix as y,Optional as b,Plugin as x,Range as S,Rectangle as C,RedoCommand as w,RxDisposable as T,ThemeService as E,UndoCommand as D,UniverInstanceType as O,VerticalAlign as k,WrapStrategy as A,bufferDebounceTime as ee,dayjs as j,debounce as M,generateRandomId as te,isFormulaString as N,isUnitRangesEqual as ne,merge as P,numfmt as F,queryObjectMatrix as I,sequenceExecute as re,shallowEqual as ie,toDisposable as ae}from"@univerjs/core";import{CURSOR_TYPE as L,CheckboxShape as oe,DeviceInputEventType as R,DocSimpleSkeleton as z,FontCache as se,IRenderManagerService as B,Rect as ce,Shape as le,Text as ue,Transform as de,fixLineWidthByScale as fe,getCurrentTypeOfRenderer as pe,getFontStyleString as me}from"@univerjs/engine-render";import{AUTO_FILL_APPLY_TYPE as he,AutoFillTools as ge,IAutoFillService as _e,INTERCEPTOR_POINT as ve,InterceptCellContentPriority as ye,RangeProtectionPermissionEditPoint as be,SetRangeValuesCommand as xe,SetWorksheetActiveOperation as Se,SheetInterceptorService as Ce,SheetPermissionCheckController as we,SheetsSelectionsService as Te,VALIDATE_CELL as Ee,WorkbookEditablePermission as De,WorksheetEditPermission as Oe,WorksheetSetCellStylePermission as ke,checkRangesEditablePermission as Ae,getSheetCommandTarget as je,rangeToDiscreteRange as Me}from"@univerjs/sheets";import{AddSheetDataValidationCommand as Ne,BASE_FORMULA_INPUT_NAME as Pe,CHECKBOX_FORMULA_1 as Fe,CHECKBOX_FORMULA_2 as Ie,CHECKBOX_FORMULA_INPUT_NAME as Le,CUSTOM_FORMULA_INPUT_NAME as Re,DATA_VALIDATION_PLUGIN_NAME as ze,DataValidationCacheService as Be,DataValidationFormulaController as Ve,DataValidationFormulaService as He,LIST_FORMULA_INPUT_NAME as Ue,RemoveSheetAllDataValidationCommand as We,RemoveSheetDataValidationCommand as Ge,SheetDataValidationModel as V,SheetsDataValidationValidatorService as Ke,UniverSheetsDataValidationPlugin as qe,UpdateSheetDataValidationOptionsCommand as Je,UpdateSheetDataValidationRangeCommand as Ye,UpdateSheetDataValidationSettingCommand as Xe,createDefaultNewRule as Ze,deserializeListOptions as Qe,getCellValueOrigin as H,getDataValidationCellValue as $e,getDataValidationDiffMutations as et,getFormulaResult as tt,isLegalFormulaResult as nt,serializeListOptions as rt,transformCheckboxValue as it}from"@univerjs/sheets-data-validation";import{DataValidationModel as at,DataValidatorDropdownType as U,DataValidatorRegistryScope as ot,DataValidatorRegistryService as st,TWO_FORMULA_OPERATOR_COUNT as ct,getRuleOptions as lt,getRuleSetting as ut}from"@univerjs/data-validation";import{ComponentManager as dt,IDialogService as ft,IMenuManagerService as pt,ISidebarService as mt,IZenZoneService as ht,KeyCode as gt,MenuItemType as _t,RibbonDataGroup as vt,getMenuHiddenObservable as yt,useDependency as W,useEvent as bt,useObservable as xt,useSidebarClick as St}from"@univerjs/ui";import{BehaviorSubject as Ct,Subject as wt,bufferTime as Tt,debounceTime as Et,distinctUntilChanged as Dt,filter as Ot,of as kt}from"rxjs";import{getPatternType as At}from"@univerjs/sheets-numfmt";import{AutoHeightController as jt,COPY_TYPE as Mt,CellAlertManagerService as Nt,CellAlertType as Pt,HoverManagerService as Ft,IEditorBridgeService as It,IMarkSelectionService as Lt,ISheetCellDropdownManagerService as Rt,ISheetClipboardService as zt,PREDEFINED_HOOK_NAME_PASTE as Bt,SetCellEditVisibleOperation as Vt,SheetSkeletonManagerService as Ht,getCurrentRangeDisable$ as Ut,getRepeatRange as Wt,virtualizeDiscreteRanges as Gt}from"@univerjs/sheets-ui";import{Button as Kt,Checkbox as qt,DraggableList as Jt,Dropdown as Yt,FormLayout as G,Input as Xt,Radio as Zt,RadioGroup as Qt,Select as $t,borderClassName as en,clsx as tn}from"@univerjs/design";import{createElement as nn,useEffect as rn,useMemo as an,useRef as on,useState as K}from"react";import{DataValidationIcon as sn,DeleteIcon as cn,IncreaseIcon as ln,MoreDownIcon as un,MoreUpIcon as dn,SequenceIcon as fn}from"@univerjs/icons";import{deserializeRangeWithSheet as pn,serializeRange as mn}from"@univerjs/engine-formula";import{FormulaEditor as hn,RangeSelector as gn}from"@univerjs/sheets-formula-ui";import{Fragment as _n,jsx as q,jsxs as J}from"react/jsx-runtime";var vn=`@univerjs/sheets-data-validation-ui`,yn=`0.18.0`;function bn(e){"@babel/helpers - typeof";return bn=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},bn(e)}function xn(e,t){if(bn(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(bn(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Sn(e){var t=xn(e,`string`);return bn(t)==`symbol`?t:t+``}function Y(e,t,n){return(t=Sn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function X(e,t){return function(n,r){t(n,r,e)}}function Z(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let Q=class extends l{get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}constructor(e,t){super(),this._univerInstanceService=e,this._sidebarService=t,Y(this,`_open$`,new Ct(!1)),Y(this,`open$`,this._open$.pipe(Dt())),Y(this,`_activeRule`,void 0),Y(this,`_activeRule$`,new Ct(void 0)),Y(this,`activeRule$`,this._activeRule$.asObservable()),Y(this,`_closeDisposable`,null),Y(this,`_focusFormulaEditorActiveRuleSubUnitId`,null),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(O.UNIVER_SHEET).pipe(Ot(e=>!e)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.id===`DataValidationPanel`&&(e.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}dispose(){var e;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(e=this._closeDisposable)==null||e.dispose()}open(){this._open$.next(!0)}close(){var e;this._open$.next(!1),(e=this._closeDisposable)==null||e.dispose()}setCloseDisposable(e){this._closeDisposable=ae(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}setFocusFormulaEditorActiveRuleSubUnitId(e){this._focusFormulaEditorActiveRuleSubUnitId=e}getFocusFormulaEditorActiveRuleSubUnitId(){return this._focusFormulaEditorActiveRuleSubUnitId}};Q=Z([X(0,m),X(1,mt)],Q);const Cn=`sheets-data-validation-ui.config`;Symbol(Cn);const wn={};let Tn=class extends l{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=r,this._localeService=i,this._sheetsDataValidationValidatorService=a,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(Ee,{handler:async(e,t,n)=>{let r=await e,{row:a,col:s,unitId:c,subUnitId:l}=t,u=this._dataValidationModel.getRuleIdByLocation(c,l,a,s),d=u?this._dataValidationModel.getRuleById(c,l,u):void 0;if(r===!1)return n(Promise.resolve(!1));if(!d||d.errorStyle!==i.STOP)return n(Promise.resolve(!0));let f=this._dataValidatorRegistryService.getValidatorItem(d.type);return!f||await this._sheetsDataValidationValidatorService.validatorCell(c,l,a,s)===o.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t(`dataValidation.alert.title`)},id:`reject-input-dialog`,children:{title:f.getRuleFinalError(d,{row:a,col:s,unitId:c,subUnitId:l})},footer:{title:nn(Kt,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`dataValidation.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}}),n(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t(`dataValidation.alert.title`)},id:`reject-input-dialog`,children:{title:e},footer:{title:nn(Kt,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`dataValidation.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}})}};Tn=Z([X(0,h(Ce)),X(1,h(V)),X(2,h(st)),X(3,ft),X(4,h(v)),X(5,h(Ke))],Tn);const En=e=>{if(e==null||typeof e==`boolean`)return;if(e===``)return j();if(typeof e==`number`||!Number.isNaN(+e))return j(F.format(`yyyy-MM-dd HH:mm:ss`,Number(e)));let t=j(e);if(t.isValid())return t};function Dn(e,t){if(e===At(t))return t;switch(e){case`datetime`:return`yyyy-MM-dd hh:mm:ss`;case`date`:return`yyyy-MM-dd`;case`time`:return`HH:mm:ss`}}let On=class extends l{get activeDropdown(){return this._activeDropdown}constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this._univerInstanceService=e,this._dataValidatorRegistryService=t,this._zenZoneService=n,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=a,this._sheetDataValidationModel=o,this._commandService=s,this._editorBridgeService=c,this._injector=l,this._configService=u,Y(this,`_activeDropdown`,void 0),Y(this,`_activeDropdown$`,new wt),Y(this,`_currentPopup`,null),Y(this,`activeDropdown$`,this._activeDropdown$.asObservable()),Y(this,`_zenVisible`,!1),this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{this._zenVisible=e,e&&this.hideDropdown()}))}_getDropdownByCell(e,t,n,r){let i=e?this._univerInstanceService.getUnit(e,O.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(O.UNIVER_SHEET);if(!i)return;let a=t?i.getSheetBySheetId(t):i.getActiveSheet();if(!a)return;let o=this._dataValidationModel.getRuleByLocation(i.getUnitId(),a.getSheetId(),n,r);if(!o)return;let s=this._dataValidatorRegistryService.getValidatorItem(o.type);return s==null?void 0:s.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(e=>{e&&e.every(e=>!(e.primary&&this._getDropdownByCell(e.primary.unitId,e.primary.sheetId,e.primary.actualRow,e.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){let{location:n}=t,{row:r,col:o,unitId:s,subUnitId:c,workbook:l,worksheet:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);let f=this._sheetDataValidationModel.getRuleByLocation(s,c,r,o);if(!f)return;let p=this._dataValidatorRegistryService.getValidatorItem(f.type);if(!(p!=null&&p.dropdownType))return;let m,h=async(t,n)=>{var a,u,m;if(!t)return!0;let h=t,g=d.getCell(r,o),_=h.format(n===`date`?`YYYY-MM-DD 00:00:00`:`YYYY-MM-DD HH:mm:ss`),v=(a=F.parseDate(_))==null?void 0:a.v,y=n===`time`?v%1:v,b=l.getStyles().getStyleByCell(g),x=(u=b==null||(m=b.n)==null?void 0:m.pattern)==null?``:u;return f.errorStyle!==i.STOP||await p.validator({value:y,unitId:s,subUnitId:c,row:r,column:o,worksheet:d,workbook:l,interceptValue:_.replace(`Z`,``).replace(`T`,` `),t:e.NUMBER},f)?(await this._commandService.executeCommand(xe.id,{unitId:s,subUnitId:c,range:{startColumn:o,endColumn:o,startRow:r,endRow:r},value:{v:y,t:2,p:null,f:null,si:null,s:{n:{pattern:Dn(n,x)}}}}),await this._commandService.executeCommand(Vt.id,{visible:!1,eventType:R.Keyboard,unitId:s,keycode:gt.ESC}),!0):(this._injector.has(Tn)&&this._injector.get(Tn).showReject(p.getRuleFinalError(f,{row:r,col:o,unitId:s,subUnitId:c})),!1)},g;switch(p.dropdownType){case U.DATE:{var _;let e=En(H(d.getCellRaw(r,o))),t=!!((_=f.bizInfo)!=null&&_.showTime);g={location:n,type:`datepicker`,props:{showTime:t,onChange:e=>h(e,t?`datetime`:`date`),defaultValue:e,patternType:`date`}};break}case U.TIME:g={location:n,type:`datepicker`,props:{onChange:e=>h(e,`time`),defaultValue:En(H(d.getCellRaw(r,o))),patternType:`time`}};break;case U.DATETIME:g={location:n,type:`datepicker`,props:{onChange:e=>h(e,`datetime`),defaultValue:En(H(d.getCellRaw(r,o))),patternType:`datetime`}};break;case U.LIST:case U.MULTIPLE_LIST:{var v,y,b,x;let e=p.dropdownType===U.MULTIPLE_LIST,t=async t=>{let n=rt(t),i={unitId:s,subUnitId:c,range:{startColumn:o,endColumn:o,startRow:r,endRow:r},value:{v:n,p:null,f:null,si:null}};return this._commandService.executeCommand(xe.id,i),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(Vt.id,{visible:!1,eventType:R.Keyboard,unitId:s,keycode:gt.ESC}),!e},i=(f==null?void 0:f.renderMode)===a.CUSTOM||(f==null?void 0:f.renderMode)===void 0,l=p.getListWithColor(f,s,c),u=$e(d.getCellRaw(r,o));g={location:n,type:`list`,props:{onChange:e=>t(e),options:l.map(e=>({label:e.label,value:e.label,color:i||e.color?e.color||`#ECECEC`:`transparent`})),onEdit:()=>{this._commandService.executeCommand(An.id,{ruleId:f.uid}),m==null||m.dispose()},defaultValue:u,multiple:e,showEdit:(v=(y=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:y.showEditOnDropdown)==null?!0:v,showSearch:(b=(x=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:x.showSearchOnDropdown)==null?!0:b}};break}case U.CASCADE:var S;g={type:`cascader`,props:{onChange:e=>{let t={unitId:s,subUnitId:c,range:{startColumn:o,endColumn:o,startRow:r,endRow:r},value:{v:e.join(`/`),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(xe.id,t),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(Vt.id,{visible:!1,eventType:R.Keyboard,unitId:s,keycode:gt.ESC}),!0},defaultValue:$e(d.getCellRaw(r,o)).split(`/`),options:JSON.parse((S=f.formula1)==null?`[]`:S)},location:n};break;case U.COLOR:g={type:`color`,props:{onChange:e=>{let t={unitId:s,subUnitId:c,range:{startColumn:o,endColumn:o,startRow:r,endRow:r},value:{v:e,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(xe.id,t),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(Vt.id,{visible:!1,eventType:R.Keyboard,unitId:s,keycode:gt.ESC}),!0},defaultValue:$e(d.getCellRaw(r,o))},location:n};break;default:throw Error(`[DataValidationDropdownManagerService]: unknown type!`)}if(m=this._cellDropdownManagerService.showDropdown({...g,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!m)throw Error(`[DataValidationDropdownManagerService]: cannot show dropdown!`);let C=new u;C.add(m),C.add({dispose:()=>{var e,t;(e=this._activeDropdown)==null||(t=e.onHide)==null||t.call(e)}}),this._currentPopup=C}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(e,t,n,r,i){let a=this._univerInstanceService.getUnit(e,O.UNIVER_SHEET);if(!a)return;let o=a.getSheetBySheetId(t);if(!o)return;let s=this._dataValidationModel.getRuleByLocation(a.getUnitId(),o.getSheetId(),n,r);if(!s)return;let c=this._dataValidatorRegistryService.getValidatorItem(s.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:a,worksheet:o,row:n,col:r,unitId:e,subUnitId:t},onHide:i})}};On=Z([X(0,m),X(1,h(st)),X(2,ht),X(3,h(V)),X(4,h(Te)),X(5,h(Rt)),X(6,h(V)),X(7,f),X(8,It),X(9,h(g)),X(10,p)],On);const kn=`DataValidationPanel`,An={id:`data-validation.operation.open-validation-panel`,type:n.OPERATION,handler(e,t){if(!t)return!1;let{ruleId:n,isAdd:r}=t,i=e.get(Q),a=e.get(at),o=e.get(m),s=e.get(mt),c=je(o);if(!c)return!1;let{unitId:l,subUnitId:u}=c,d=n?a.getRuleById(l,u,n):void 0;i.open(),i.setActiveRule(d&&{unitId:l,subUnitId:u,rule:d});let f=s.open({id:kn,header:{title:r?`dataValidation.panel.addTitle`:`dataValidation.panel.title`},children:{label:kn},width:312,onClose:()=>i.close()});return i.setCloseDisposable(f),!0}},jn={id:`data-validation.operation.close-validation-panel`,type:n.OPERATION,handler(e){return e.get(Q).close(),!0}},Mn={id:`data-validation.operation.toggle-validation-panel`,type:n.OPERATION,handler(e){let t=e.get(f),n=e.get(Q);return n.open(),n.isOpen?t.executeCommand(jn.id):t.executeCommand(An.id),!0}},Nn={type:n.OPERATION,id:`sheet.operation.show-data-validation-dropdown`,handler(e,t){if(!t)return!1;let n=e.get(On),{unitId:r,subUnitId:i,row:a,column:o}=t,s=n.activeDropdown,c=s==null?void 0:s.location;return c&&c.unitId===r&&c.subUnitId===i&&c.row===a&&c.col===o||n.showDataValidationDropdown(r,i,a,o),!0}},Pn={type:n.OPERATION,id:`sheet.operation.hide-data-validation-dropdown`,handler(e,t){return t?(e.get(On).hideDropdown(),!0):!1}},Fn={type:n.COMMAND,id:`data-validation.command.addRuleAndOpen`,handler(e){let t=je(e.get(m));if(!t)return!1;let{workbook:n,worksheet:r}=t,i=Ze(e),a=e.get(f),o={rule:i,unitId:n.getUnitId(),subUnitId:r.getSheetId()};return a.syncExecuteCommand(Ne.id,o)?(a.syncExecuteCommand(An.id,{ruleId:i.uid,isAdd:!0}),!0):!1}},In=`SHEET_DATA_VALIDATION_ALERT`;let Ln=class extends l{constructor(e,t,n,r,i,a){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=r,this._zenZoneService=i,this._dataValidationModel=a,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(Et(100)).subscribe(e=>{if(e){let n=this._univerInstanceService.getUnit(e.location.unitId,O.UNIVER_SHEET),r=n.getSheetBySheetId(e.location.subUnitId);if(!r)return;let i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i){this._cellAlertManagerService.removeAlert(In);return}if(this._dataValidationModel.validator(i,{...e.location,workbook:n,worksheet:r})===o.INVALID){var t;let n=this._cellAlertManagerService.currentAlert.get(In),r=n==null||(t=n.alert)==null?void 0:t.location;if(r&&r.row===e.location.row&&r.col===e.location.col&&r.subUnitId===e.location.subUnitId&&r.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(In);return}let a=this._dataValidationModel.getValidator(i.type);if(!a){this._cellAlertManagerService.removeAlert(In);return}this._cellAlertManagerService.showAlert({type:Pt.ERROR,title:this._localeService.t(`dataValidation.error.title`),message:a==null?void 0:a.getRuleFinalError(i,e.location),location:e.location,width:200,height:74,key:In});return}}this._cellAlertManagerService.removeAlert(In)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(In)}))}};Ln=Z([X(0,h(Ft)),X(1,h(Nt)),X(2,m),X(3,h(v)),X(4,ht),X(5,h(V))],Ln);let Rn=class extends l{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),t=(e,t)=>{let{source:n,target:r,unitId:i,subUnitId:a}=e,o=this._sheetDataValidationModel.getRuleObjectMatrix(i,a).clone(),s=Gt([n,r]),[c,l]=s.ranges,{mapFunc:u}=s,d={row:c.startRow,col:c.startColumn},f=ge.getAutoFillRepeatRange(c,l),p=new y,m=new Set;f.forEach(e=>{let t=e.repeatStartCell,n=e.relativeRange,r={startRow:d.row,startColumn:d.col,endColumn:d.col,endRow:d.row},o={startRow:t.row,startColumn:t.col,endColumn:t.col,endRow:t.row};S.foreach(n,(e,t)=>{let n=C.getPositionRange({startRow:e,startColumn:t,endColumn:t,endRow:e},r),{row:s,col:c}=u(n.startRow,n.startColumn),l=this._sheetDataValidationModel.getRuleIdByLocation(i,a,s,c)||``,d=C.getPositionRange({startRow:e,startColumn:t,endColumn:t,endRow:e},o),{row:f,col:h}=u(d.startRow,d.startColumn);p.setValue(f,h,l),m.add(l)})});let h=Array.from(m).map(e=>({id:e,ranges:I(p,t=>t===e)}));o.addRangeRules(h);let{redoMutations:g,undoMutations:_}=et(i,a,o.diff(this._sheetDataValidationModel.getRules(i,a)),this._injector,`patched`,t===he.ONLY_FORMAT);return{undos:_,redos:g}},n={id:ze,onBeforeFillData:e=>{let{source:t,unitId:n,subUnitId:r}=e;for(let e of t.rows)for(let i of t.cols){let t=this._sheetDataValidationModel.getRuleByLocation(n,r,e,i);if(t&&t.type===s.CHECKBOX){this._autoFillService.setDisableApplyType(he.SERIES,!0);return}}},onFillData:(n,r,i)=>i===he.COPY||i===he.ONLY_FORMAT||i===he.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Rn=Z([X(0,_e),X(1,h(V)),X(2,h(g))],Rn);let zn=class extends l{constructor(e,t,n){super(),this._sheetClipboardService=e,this._sheetDataValidationModel=t,this._injector=n,Y(this,`_copyInfo`,void 0),this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:ze,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,r)=>{let{copyType:i=Mt.COPY,pasteType:a}=r,{range:o}=e||{},{range:s,unitId:c,subUnitId:l}=t;return this._generateMutations(s,{copyType:i,pasteType:a,copyRange:o,unitId:c,subUnitId:l})}})}_collect(e,t,n){let r=new y;this._copyInfo={unitId:e,subUnitId:t,matrix:r};let i=this._injector.invoke(r=>Me(n,r,e,t));if(!i)return;let{rows:a,cols:o}=i;a.forEach((n,i)=>{o.forEach((a,o)=>{let s=this._sheetDataValidationModel.getRuleIdByLocation(e,t,n,a);r.setValue(i,o,s==null?``:s)})})}_generateMutations(e,t){if(!this._copyInfo)return{redos:[],undos:[]};if(t.copyType===Mt.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!t.copyRange||[Bt.SPECIAL_PASTE_COL_WIDTH,Bt.SPECIAL_PASTE_VALUE,Bt.SPECIAL_PASTE_FORMAT,Bt.SPECIAL_PASTE_FORMULA].includes(t.pasteType))return{redos:[],undos:[]};let{unitId:n,subUnitId:r}=this._copyInfo;if(t.unitId!==n||r!==t.subUnitId){let i=this._sheetDataValidationModel.getRuleObjectMatrix(t.unitId,t.subUnitId).clone(),a=new y,o=new Set,{ranges:[s,c],mapFunc:l}=Gt([t.copyRange,e]),u=Wt(s,c,!0),d=new Map;u.forEach(({startRange:e})=>{var i;(i=this._copyInfo)==null||i.matrix.forValue((i,s,c)=>{let u=C.getPositionRange({startRow:i,endRow:i,startColumn:s,endColumn:s},e),f=`${r}-${c}`,p=this._sheetDataValidationModel.getRuleById(n,r,c);!this._sheetDataValidationModel.getRuleById(t.unitId,t.subUnitId,f)&&p&&d.set(f,{...p,uid:f});let{row:m,col:h}=l(u.startRow,u.startColumn);o.add(f),a.setValue(m,h,f)})});let f=Array.from(o).map(e=>({id:e,ranges:I(a,t=>t===e)}));i.addRangeRules(f);let{redoMutations:p,undoMutations:m}=et(t.unitId,t.subUnitId,i.diffWithAddition(this._sheetDataValidationModel.getRules(t.unitId,t.subUnitId),d.values()),this._injector,`patched`,!1);return{redos:p,undos:m}}else{let i=this._sheetDataValidationModel.getRuleObjectMatrix(n,r).clone(),a=new y,o=new Set,{ranges:[s,c],mapFunc:l}=Gt([t.copyRange,e]);Wt(s,c,!0).forEach(({startRange:e})=>{var t;(t=this._copyInfo)==null||t.matrix.forValue((t,n,r)=>{let i=C.getPositionRange({startRow:t,endRow:t,startColumn:n,endColumn:n},e),{row:s,col:c}=l(i.startRow,i.startColumn);a.setValue(s,c,r),o.add(r)})});let u=Array.from(o).map(e=>({id:e,ranges:I(a,t=>t===e)}));i.addRangeRules(u);let{redoMutations:d,undoMutations:f}=et(n,r,i.diff(this._sheetDataValidationModel.getRules(n,r)),this._injector,`patched`,!1);return{redos:d,undos:f}}}};zn=Z([X(0,zt),X(1,h(V)),X(2,h(g))],zn);let Bn=class extends l{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===Ne.id){let{unitId:t,subUnitId:n,rule:{ranges:r}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[De],rangeTypes:[be],worksheetTypes:[Oe,ke]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.setStyleErr`))}if(e.id===Ye.id){let{unitId:t,subUnitId:n,ranges:r}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[De],rangeTypes:[be],worksheetTypes:[Oe,ke]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.setStyleErr`))}}))}};Bn=Z([X(0,h(v)),X(1,f),X(2,h(we))],Bn);const Vn=`sheet.menu.data-validation`;function Hn(e){return{id:Vn,type:_t.SUBITEMS,icon:`DataValidationIcon`,tooltip:`dataValidation.title`,hidden$:yt(e,O.UNIVER_SHEET),disabled$:Ut(e,{workbookTypes:[De],worksheetTypes:[ke,Oe],rangeTypes:[be]})}}function Un(e){return{id:An.id,title:`dataValidation.panel.title`,type:_t.BUTTON}}function Wn(e){return{id:Fn.id,title:`dataValidation.panel.add`,type:_t.BUTTON}}const Gn={[vt.RULES]:{[Vn]:{order:0,menuItemFactory:Hn,[An.id]:{order:0,menuItemFactory:Un},[Fn.id]:{order:1,menuItemFactory:Wn}}}},Kn={tr:{size:6,color:`#fe4b4b`}};let qn=class extends T{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._autoHeightController=i,this._dropdownManagerService=a,this._sheetDataValidationModel=o,this._dataValidatorRegistryService=s,this._sheetInterceptorService=c,this._dataValidationCacheService=l,this._editorBridgeService=u,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Gn)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{if(!e.visible){var t;((t=this._dropdownManagerService.activeDropdown)==null?void 0:t.trigger)===`editor-bridge`&&this._dropdownManagerService.hideDropdown();return}let n=this._editorBridgeService.getEditCellState();if(n){let{unitId:e,sheetId:t,row:r,column:i}=n,a=this._univerInstanceService.getUniverSheetInstance(e);if(!a)return;let o=this._sheetDataValidationModel.getRuleByLocation(e,t,r,i);if(!o)return;let s=this._dataValidatorRegistryService.getValidatorItem(o.type);if(!(s!=null&&s.dropdownType))return;let c=a.getActiveSheet();if(!c)return;let l=this._dropdownManagerService.activeDropdown,u=l==null?void 0:l.location;if(u&&u.unitId===e&&u.subUnitId===t&&u.row===r&&u.col===i)return;this._dropdownManagerService.showDropdown({location:{unitId:e,subUnitId:t,row:r,col:i,workbook:a,worksheet:c},trigger:`editor-bridge`,closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(ve.CELL_CONTENT,{effect:_.Style,priority:ye.DATA_VALIDATION,handler:(e,t,n)=>{var r,i,a,c,l;let{row:u,col:d,unitId:f,subUnitId:p,workbook:m,worksheet:h}=t,g=this._sheetDataValidationModel.getRuleIdByLocation(f,p,u,d);if(!g)return n(e);let _=this._sheetDataValidationModel.getRuleById(f,p,g);if(!_)return n(e);let v=(r=this._dataValidationCacheService.getValue(f,p,u,d))==null?o.VALID:r,y=this._dataValidatorRegistryService.getValidatorItem(_.type),b=t.rawData,x,S={get value(){var e;return x===void 0&&(x=(e=H(b))==null?null:e),x}},C={get value(){var e;return`${(e=S.value)==null?``:e}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.INVALID?Kn:null},e.customRender=[...(i=e==null?void 0:e.customRender)==null?[]:i,...y!=null&&y.canvasRender?[y.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(a=e.fontRenderExtension)==null?void 0:a.isSkip)||(y==null||(c=y.skipDefaultFontRender)==null?void 0:c.call(y,_,S.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...y==null?void 0:y.getExtraStyle(_,C.value,{get style(){let t=m.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},u,d)},e.interceptorAutoHeight=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(f))==null||(t=t.with(Ht).getSkeletonParam(p))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(u,d),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?u:n,(r=s==null?void 0:s.startColumn)==null?d:r),unitId:f,subUnitId:p,row:u,col:d,workbook:m,worksheet:h};return y==null||(i=y.canvasRender)==null||(a=i.calcCellAutoHeight)==null?void 0:a.call(i,c)},e.interceptorAutoWidth=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(f))==null||(t=t.with(Ht).getSkeletonParam(p))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(u,d),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?u:n,(r=s==null?void 0:s.startColumn)==null?d:r),unitId:f,subUnitId:p,row:u,col:d,workbook:m,worksheet:h};return y==null||(i=y.canvasRender)==null||(a=i.calcCellAutoWidth)==null?void 0:a.call(i,c)},e.coverable=((l=e==null?void 0:e.coverable)==null?!0:l)&&!(_.type===s.LIST||_.type===s.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(Ot(e=>e.source===`command`),Tt(100)).subscribe(e=>{if(e.length===0)return;let t=[];e.forEach(e=>{if(e.rule.type===s.LIST_MULTIPLE||e.rule.type===s.LIST){var n;(n=e.rule)!=null&&n.ranges&&t.push(...e.rule.ranges)}}),t.length&&re(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};qn=Z([X(0,f),X(1,pt),X(2,B),X(3,m),X(4,h(jt)),X(5,h(On)),X(6,h(V)),X(7,h(st)),X(8,h(Ce)),X(9,h(Be)),X(10,b(It))],qn);let Jn=class extends T{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=r,this._sheetInterceptorService=i,this._sheetDataValidationModel=a,this._dataValidationCacheService=o,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(ve.CELL_CONTENT,{effect:_.Style,priority:ye.DATA_VALIDATION,handler:(e,t,n)=>{var r,i,a,c,l;let{row:u,col:d,unitId:f,subUnitId:p,workbook:m,worksheet:h}=t,g=this._sheetDataValidationModel.getRuleIdByLocation(f,p,u,d);if(!g)return n(e);let _=this._sheetDataValidationModel.getRuleById(f,p,g);if(!_)return n(e);let v=(r=this._dataValidationCacheService.getValue(f,p,u,d))==null?o.VALID:r,y=this._dataValidatorRegistryService.getValidatorItem(_.type),b=H(h.getCellRaw(u,d)),x=`${b==null?``:b}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.INVALID?Kn:null},e.customRender=[...(i=e==null?void 0:e.customRender)==null?[]:i,...y!=null&&y.canvasRender?[y.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(a=e.fontRenderExtension)==null?void 0:a.isSkip)||(y==null||(c=y.skipDefaultFontRender)==null?void 0:c.call(y,_,b,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...y==null?void 0:y.getExtraStyle(_,x,{get style(){let t=m.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},u,d)},e.interceptorAutoHeight=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(f))==null||(t=t.with(Ht).getSkeletonParam(p))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(u,d),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?u:n,(r=s==null?void 0:s.startColumn)==null?d:r),unitId:f,subUnitId:p,row:u,col:d,workbook:m,worksheet:h};return y==null||(i=y.canvasRender)==null||(a=i.calcCellAutoHeight)==null?void 0:a.call(i,c)},e.interceptorAutoWidth=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(f))==null||(t=t.with(Ht).getSkeletonParam(p))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(u,d),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?u:n,(r=s==null?void 0:s.startColumn)==null?d:r),unitId:f,subUnitId:p,row:u,col:d,workbook:m,worksheet:h};return y==null||(i=y.canvasRender)==null||(a=i.calcCellAutoWidth)==null?void 0:a.call(i,c)},e.coverable=((l=e==null?void 0:e.coverable)==null?!0:l)&&!(_.type===s.LIST||_.type===s.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(Ot(e=>e.source===`command`),Tt(16)).subscribe(e=>{let t=[];e.forEach(e=>{if(e.rule.type===s.LIST_MULTIPLE||e.rule.type===s.LIST){var n;(n=e.rule)!=null&&n.ranges&&t.push(...e.rule.ranges)}}),t.length&&re(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};Jn=Z([X(0,f),X(1,B),X(2,h(jt)),X(3,h(st)),X(4,h(Ce)),X(5,h(V)),X(6,h(Be))],Jn);let Yn=class extends l{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(ee(16)).subscribe(e=>{var t;if(!e.length)return;let n=new Set;e.forEach(e=>{n.add(e.subUnitId)}),n.forEach(e=>{var t;(t=this._sheetSkeletonManagerService.getSkeletonParam(e))==null||t.skeleton.makeDirty(!0)}),(t=this._context.mainComponent)==null||t.makeForceDirty()}))}};Yn=Z([X(1,h(V)),X(2,h(Ht))],Yn);function Xn(e){var t;let n=W(v),r=W(dt),{value:a,onChange:o,extraComponent:s}=e,[c,l]=K(!1),u=s?r.get(s):null;return J(_n,{children:[J(`div`,{className:`
|
|
2
|
+
univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900
|
|
3
|
+
dark:!univer-text-white
|
|
4
|
+
`,onClick:()=>l(!c),children:[n.t(`dataValidation.panel.options`),q(c?dn:un,{className:`univer-ml-1`})]}),c&&J(_n,{children:[u?q(u,{value:a,onChange:o}):null,q(G,{label:n.t(`dataValidation.panel.invalid`),children:J(Qt,{value:`${(t=a.errorStyle)==null?i.WARNING:t}`,onChange:e=>o({...a,errorStyle:+e}),children:[q(Zt,{value:`${i.WARNING}`,children:n.t(`dataValidation.panel.showWarning`)}),q(Zt,{value:`${i.STOP}`,children:n.t(`dataValidation.panel.rejectInput`)})]})}),q(G,{label:n.t(`dataValidation.panel.messageInfo`),children:q(qt,{checked:a.showErrorMessage,onChange:()=>o({...a,showErrorMessage:!a.showErrorMessage}),children:n.t(`dataValidation.panel.showInfo`)})}),a.showErrorMessage?q(G,{children:q(Xt,{value:a.error,onChange:e=>o({...a,error:e})})}):null]})]})}const Zn=e=>M(async(t,n,r,i)=>{let a=await e.executeCommand(t,n,r);i==null||i(a)},1e3);function Qn(e,t,n){var r;if(t){var i;return((i=e.getUnit(t))==null||(i=i.getSheetBySheetName(n))==null?void 0:i.getSheetId())||``}return((r=e.getCurrentUnitForType(O.UNIVER_SHEET))==null||(r=r.getSheetBySheetName(n))==null?void 0:r.getSheetId())||``}function $n(){var e,t;let[n,r]=K(0),i=W(Q),{unitId:a,subUnitId:o,rule:s}=xt(i.activeRule$,i.activeRule)||{},c=s.uid,l=W(st),u=W(m),d=W(dt),p=W(f),h=W(at),g=W(v),_=xt(()=>u.getCurrentTypeOfUnit$(O.UNIVER_SHEET),void 0,void 0,[]),y=xt(()=>{var e;return(e=_==null?void 0:_.activeSheet$)==null?kt(null):e},void 0,void 0,[]),[b,x]=K(s),S=l.getValidatorItem(b.type),[C,T]=K(!1),E=l.getValidatorsByScope(ot.SHEET),[k,A]=K(()=>b.ranges.map(e=>({unitId:``,sheetId:``,range:e}))),ee=an(()=>Zn(p),[p]),[j,M]=K(!1),[te,N]=K(!1),P=on(null),F=W(Te);if(rn(()=>()=>{let e=F.getCurrentLastSelection();e&&F.setSelections([e])},[F]),rn(()=>{p.onCommandExecuted(e=>{(e.id===D.id||e.id===w.id)&&setTimeout(()=>{let e=h.getRuleById(a,o,c);r(e=>e+1),e&&(x(e),A(e.ranges.map(e=>({unitId:``,sheetId:``,range:e}))))},20)})},[p,h,c,o,a]),!S)return null;let I=S.operators,re=S.operatorNames,ae=b.operator?ct.includes(b.operator):!1,L=()=>{(y==null?void 0:y.getSheetId())!==o&&p.syncExecuteCommand(Se.id,{unitId:a,subUnitId:o})},oe=()=>{var e;if(!((e=P.current)==null||(e=e.editor)==null)&&e.isFocus()){var t;R((t=P.current)==null?void 0:t.getValue())}!b.ranges.length||j||(S.validatorFormula(b,a,o).success?i.setActiveRule(null):T(!0),L())},R=bt(e=>{let t=e.split(`,`).filter(Boolean).map(pn).map(e=>{let t=e.sheetName;if(t){let n=Qn(u,e.unitId,t);return{...e,sheetId:n}}return{...e,sheetId:``}});if(ne(t,k))return;A(t);let n=t.filter(e=>(!e.unitId||e.unitId===a)&&(!e.sheetId||e.sheetId===o)).map(e=>e.range);if(x({...b,ranges:n}),n.length===0)return;let r={unitId:a,subUnitId:o,ruleId:c,ranges:n};ee(Ye.id,r)}),z=e=>{if(ie(e,ut(b)))return;x({...b,...e});let t={unitId:a,subUnitId:o,ruleId:c,setting:e};ee(Xe.id,t,void 0)},se=async()=>{await p.executeCommand(Ge.id,{ruleId:c,unitId:a,subUnitId:o}),i.setActiveRule(null),L()},B={type:b.type,operator:b.operator,formula1:b.formula1,formula2:b.formula2,allowBlank:b.allowBlank},ce=e=>{let t=l.getValidatorItem(e);if(!t)return;let n=t.operators,r=h.getRuleById(a,o,c),i=e===(r==null?void 0:r.type)||e.includes(`list`)&&r!=null&&r.type.includes(`list`)?{...r,type:e}:{...b,type:e,operator:n[0],formula1:void 0,formula2:void 0};x(i),p.executeCommand(Xe.id,{unitId:a,subUnitId:o,ruleId:b.uid,setting:ut(i)})},le=d.get(S.formulaInput),ue=an(()=>k.map(e=>mn(e.range)).join(`,`),[]),de=lt(b),fe=e=>{ie(e,lt(b))||(x({...b,...e}),ee(Je.id,{unitId:a,subUnitId:o,ruleId:c,options:e}))},pe=I.length&&!b.operator;return J(`div`,{"data-u-comp":`data-validation-detail`,className:`univer-py-2`,children:[q(G,{label:g.t(`dataValidation.panel.range`),error:!b.ranges.length||j?g.t(`dataValidation.panel.rangeError`):``,children:q(gn,{selectorRef:P,unitId:a,subUnitId:o,initialValue:ue,onChange:(e,t)=>{var n;!te&&(n=P.current)!=null&&n.verify()&&R(t)},onFocusChange:(e,t)=>{var n;N(e),!e&&t&&(n=P.current)!=null&&n.verify()&&R(t)},onVerify:e=>M(!e)})}),q(G,{label:g.t(`dataValidation.panel.type`),children:q($t,{className:`univer-w-full`,value:b.type,options:E==null||(e=E.sort((e,t)=>e.order-t.order))==null?void 0:e.map(e=>({label:g.t(e.title),value:e.id})),onChange:ce})}),I!=null&&I.length?q(G,{label:g.t(`dataValidation.panel.operator`),children:q($t,{className:`univer-w-full`,value:`${b.operator}`,options:[{value:``,label:g.t(`dataValidation.operators.legal`)},...I.map((e,t)=>({value:`${e}`,label:re[t]}))],onChange:e=>{z({...B,operator:e})}})}):null,le&&!pe?q(le,{isTwoFormula:ae,value:{formula1:b.formula1,formula2:b.formula2},onChange:e=>{z({...B,...e})},showError:C,validResult:S.validatorFormula(b,a,o),unitId:a,subUnitId:o,ruleId:c},n+b.type):null,q(G,{children:q(qt,{checked:(t=b.allowBlank)==null?!0:t,onChange:()=>{var e;return z({...B,allowBlank:!((e=b.allowBlank)==null||e)})},children:g.t(`dataValidation.panel.allowBlank`)})}),q(Xn,{value:de,onChange:fe,extraComponent:S.optionsInput}),J(`div`,{className:`univer-mt-5 univer-flex univer-flex-row univer-justify-end`,children:[q(Kt,{className:`univer-ml-3`,onClick:se,children:g.t(`dataValidation.panel.removeRule`)}),q(Kt,{className:`univer-ml-3`,variant:`primary`,onClick:oe,children:g.t(`dataValidation.panel.done`)})]})]})}const er=e=>{let{rule:n,onClick:r,unitId:i,subUnitId:a,disable:o}=e,s=W(st),c=W(f),l=W(Lt),u=s.getValidatorItem(n.type),d=on(void 0),[p,m]=K(!1),h=W(E),g=an(()=>{var e;let n=h.getColorFromTheme(`primary.600`),r=h.getColorFromTheme(`loop-color.2`),i=(e=h.getColorFromTheme(r))==null?n:e,a=new t(i).toRgb();return{fill:`rgba(${a.r}, ${a.g}, ${a.b}, 0.1)`,stroke:i}},[xt(h.currentTheme$)]),_=e=>{c.executeCommand(Ge.id,{ruleId:n.uid,unitId:i,subUnitId:a}),e.stopPropagation()};return rn(()=>()=>{if(d.current){var e;(e=d.current)==null||e.forEach(e=>{e&&l.removeShape(e)})}},[l]),J(`div`,{className:tn(`
|
|
1848
5
|
univer-bg-secondary univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px]
|
|
1849
6
|
univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md
|
|
1850
7
|
univer-p-2 univer-pr-9
|
|
1851
|
-
`,
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
]
|
|
1895
|
-
}
|
|
1896
|
-
);
|
|
1897
|
-
};
|
|
1898
|
-
function Ii(e) {
|
|
1899
|
-
const t = F(ae), n = F(pe), r = F(oe), o = F(Ve), i = F(_e), a = F(ge), [l, s] = W([]), { workbook: d } = e, u = Re(d.activeSheet$, void 0, !0), h = d.getUnitId(), c = u == null ? void 0 : u.getSheetId();
|
|
1900
|
-
Me(() => {
|
|
1901
|
-
s(t.getRules(h, c));
|
|
1902
|
-
const f = t.ruleChange$.subscribe((w) => {
|
|
1903
|
-
w.unitId === h && w.subUnitId === c && s(t.getRules(h, c));
|
|
1904
|
-
});
|
|
1905
|
-
return () => {
|
|
1906
|
-
f.unsubscribe();
|
|
1907
|
-
};
|
|
1908
|
-
}, [h, c, t]);
|
|
1909
|
-
const m = async () => {
|
|
1910
|
-
const f = ir(o), w = {
|
|
1911
|
-
unitId: h,
|
|
1912
|
-
subUnitId: c,
|
|
1913
|
-
rule: f
|
|
1914
|
-
};
|
|
1915
|
-
await r.executeCommand(fn.id, w), i.setActiveRule({
|
|
1916
|
-
unitId: h,
|
|
1917
|
-
subUnitId: c,
|
|
1918
|
-
rule: f
|
|
1919
|
-
});
|
|
1920
|
-
}, I = () => {
|
|
1921
|
-
r.executeCommand(lo.id, {
|
|
1922
|
-
unitId: h,
|
|
1923
|
-
subUnitId: c
|
|
1924
|
-
});
|
|
1925
|
-
}, v = ((f) => {
|
|
1926
|
-
const w = n.getCurrentUnitForType(H.UNIVER_SHEET), M = w.getActiveSheet(), g = w.getUnitId(), p = M.getSheetId();
|
|
1927
|
-
return f.map((T) => io(o, g, p, T.ranges) ? { ...T } : { ...T, disable: !0 });
|
|
1928
|
-
})(l), C = v == null ? void 0 : v.some((f) => f.disable);
|
|
1929
|
-
return /* @__PURE__ */ Y("div", { className: "univer-pb-4", children: [
|
|
1930
|
-
v == null ? void 0 : v.map((f) => {
|
|
1931
|
-
var w;
|
|
1932
|
-
return /* @__PURE__ */ S(
|
|
1933
|
-
Ci,
|
|
1934
|
-
{
|
|
1935
|
-
unitId: h,
|
|
1936
|
-
subUnitId: c,
|
|
1937
|
-
onClick: () => {
|
|
1938
|
-
f.disable || i.setActiveRule({
|
|
1939
|
-
unitId: h,
|
|
1940
|
-
subUnitId: c,
|
|
1941
|
-
rule: f
|
|
1942
|
-
});
|
|
1943
|
-
},
|
|
1944
|
-
rule: f,
|
|
1945
|
-
disable: (w = f.disable) != null ? w : !1
|
|
1946
|
-
},
|
|
1947
|
-
f.uid
|
|
1948
|
-
);
|
|
1949
|
-
}),
|
|
1950
|
-
/* @__PURE__ */ Y("div", { className: "univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2", children: [
|
|
1951
|
-
l.length && !C ? /* @__PURE__ */ S(Je, { onClick: I, children: a.t("dataValidation.panel.removeAll") }) : null,
|
|
1952
|
-
/* @__PURE__ */ S(Je, { variant: "primary", onClick: m, children: a.t("dataValidation.panel.add") })
|
|
1953
|
-
] })
|
|
1954
|
-
] });
|
|
1955
|
-
}
|
|
1956
|
-
const wi = () => {
|
|
1957
|
-
const e = F(_e), t = Re(e.activeRule$, e.activeRule), n = F(pe), r = Re(
|
|
1958
|
-
() => n.getCurrentTypeOfUnit$(H.UNIVER_SHEET),
|
|
1959
|
-
void 0,
|
|
1960
|
-
void 0,
|
|
1961
|
-
[]
|
|
1962
|
-
), o = Re(() => {
|
|
1963
|
-
var i;
|
|
1964
|
-
return (i = r == null ? void 0 : r.activeSheet$) != null ? i : fr(null);
|
|
1965
|
-
}, void 0, void 0, []);
|
|
1966
|
-
return !r || !o ? null : t && (t.subUnitId === o.getSheetId() || t.subUnitId === e.getFocusFormulaEditorActiveRuleSubUnitId()) ? /* @__PURE__ */ S(Si, {}, t.rule.uid) : /* @__PURE__ */ S(Ii, { workbook: r });
|
|
1967
|
-
}, Ri = (e) => {
|
|
1968
|
-
const { isTwoFormula: t = !1, value: n, onChange: r, showError: o, validResult: i } = e, a = F(ge), l = o ? i == null ? void 0 : i.formula1 : "", s = o ? i == null ? void 0 : i.formula2 : "";
|
|
1969
|
-
return t ? /* @__PURE__ */ Y(vt, { children: [
|
|
1970
|
-
/* @__PURE__ */ S(Z, { error: l, children: /* @__PURE__ */ S(
|
|
1971
|
-
Ue,
|
|
1972
|
-
{
|
|
1973
|
-
className: "univer-w-full",
|
|
1974
|
-
placeholder: a.t("dataValidation.panel.formulaPlaceholder"),
|
|
1975
|
-
value: n == null ? void 0 : n.formula1,
|
|
1976
|
-
onChange: (d) => {
|
|
1977
|
-
r == null || r({
|
|
1978
|
-
...n,
|
|
1979
|
-
formula1: d
|
|
1980
|
-
});
|
|
1981
|
-
}
|
|
1982
|
-
}
|
|
1983
|
-
) }),
|
|
1984
|
-
/* @__PURE__ */ S("div", { className: "-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400", children: a.t("dataValidation.panel.formulaAnd") }),
|
|
1985
|
-
/* @__PURE__ */ S(Z, { error: s, children: /* @__PURE__ */ S(
|
|
1986
|
-
Ue,
|
|
1987
|
-
{
|
|
1988
|
-
className: "univer-w-full",
|
|
1989
|
-
placeholder: a.t("dataValidation.panel.formulaPlaceholder"),
|
|
1990
|
-
value: n == null ? void 0 : n.formula2,
|
|
1991
|
-
onChange: (d) => {
|
|
1992
|
-
r == null || r({
|
|
1993
|
-
...n,
|
|
1994
|
-
formula2: d
|
|
1995
|
-
});
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
) })
|
|
1999
|
-
] }) : /* @__PURE__ */ S(Z, { error: l, children: /* @__PURE__ */ S(
|
|
2000
|
-
Ue,
|
|
2001
|
-
{
|
|
2002
|
-
className: "univer-w-full",
|
|
2003
|
-
placeholder: a.t("dataValidation.panel.formulaPlaceholder"),
|
|
2004
|
-
value: n == null ? void 0 : n.formula1,
|
|
2005
|
-
onChange: (d) => {
|
|
2006
|
-
r == null || r({ formula1: d });
|
|
2007
|
-
}
|
|
2008
|
-
}
|
|
2009
|
-
) });
|
|
2010
|
-
};
|
|
2011
|
-
function yi(e) {
|
|
2012
|
-
const { value: t, onChange: n, showError: r, validResult: o } = e, i = F(ge), a = r ? o == null ? void 0 : o.formula1 : "", l = r ? o == null ? void 0 : o.formula2 : "", [s, d] = W(!((t == null ? void 0 : t.formula1) === void 0 && (t == null ? void 0 : t.formula2) === void 0));
|
|
2013
|
-
return /* @__PURE__ */ Y(vt, { children: [
|
|
2014
|
-
/* @__PURE__ */ S(Z, { children: /* @__PURE__ */ S(
|
|
2015
|
-
Ut,
|
|
2016
|
-
{
|
|
2017
|
-
checked: s,
|
|
2018
|
-
onChange: (u) => {
|
|
2019
|
-
u ? d(!0) : (d(!1), n == null || n({
|
|
2020
|
-
...t,
|
|
2021
|
-
formula1: void 0,
|
|
2022
|
-
formula2: void 0
|
|
2023
|
-
}));
|
|
2024
|
-
},
|
|
2025
|
-
children: i.t("dataValidation.checkbox.tips")
|
|
2026
|
-
}
|
|
2027
|
-
) }),
|
|
2028
|
-
s ? /* @__PURE__ */ S(Z, { label: i.t("dataValidation.checkbox.checked"), error: a, children: /* @__PURE__ */ S(
|
|
2029
|
-
Ue,
|
|
2030
|
-
{
|
|
2031
|
-
className: "univer-w-full",
|
|
2032
|
-
placeholder: i.t("dataValidation.panel.valuePlaceholder"),
|
|
2033
|
-
value: t == null ? void 0 : t.formula1,
|
|
2034
|
-
onChange: (u) => {
|
|
2035
|
-
n == null || n({
|
|
2036
|
-
...t,
|
|
2037
|
-
formula1: u || void 0
|
|
2038
|
-
});
|
|
2039
|
-
}
|
|
2040
|
-
}
|
|
2041
|
-
) }) : null,
|
|
2042
|
-
s ? /* @__PURE__ */ S(Z, { label: i.t("dataValidation.checkbox.unchecked"), error: l, children: /* @__PURE__ */ S(
|
|
2043
|
-
Ue,
|
|
2044
|
-
{
|
|
2045
|
-
className: "univer-w-full",
|
|
2046
|
-
placeholder: i.t("dataValidation.panel.valuePlaceholder"),
|
|
2047
|
-
value: t == null ? void 0 : t.formula2,
|
|
2048
|
-
onChange: (u) => {
|
|
2049
|
-
n == null || n({
|
|
2050
|
-
...t,
|
|
2051
|
-
formula2: u || void 0
|
|
2052
|
-
});
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
) }) : null
|
|
2056
|
-
] });
|
|
2057
|
-
}
|
|
2058
|
-
function bi(e) {
|
|
2059
|
-
var h;
|
|
2060
|
-
const { unitId: t, subUnitId: n, value: r, onChange: o, showError: i, validResult: a } = e, l = i ? a == null ? void 0 : a.formula1 : void 0, s = ft(null), [d, u] = W(!1);
|
|
2061
|
-
return gr((c) => {
|
|
2062
|
-
var I;
|
|
2063
|
-
(I = s.current) != null && I.isClickOutSide(c) && u(!1);
|
|
2064
|
-
}), /* @__PURE__ */ S(Z, { error: l, children: /* @__PURE__ */ S(
|
|
2065
|
-
Ir,
|
|
2066
|
-
{
|
|
2067
|
-
ref: s,
|
|
2068
|
-
className: Fe("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", Et),
|
|
2069
|
-
initValue: (h = r == null ? void 0 : r.formula1) != null ? h : "=",
|
|
2070
|
-
unitId: t,
|
|
2071
|
-
subUnitId: n,
|
|
2072
|
-
isFocus: d,
|
|
2073
|
-
isSupportAcrossSheet: !0,
|
|
2074
|
-
onChange: (c) => {
|
|
2075
|
-
const m = (c != null ? c : "").trim();
|
|
2076
|
-
m !== (r == null ? void 0 : r.formula1) && (o == null || o({
|
|
2077
|
-
...r,
|
|
2078
|
-
formula1: m
|
|
2079
|
-
}));
|
|
2080
|
-
},
|
|
2081
|
-
onFocus: () => u(!0)
|
|
2082
|
-
}
|
|
2083
|
-
) });
|
|
2084
|
-
}
|
|
2085
|
-
const Mi = [
|
|
2086
|
-
"#FFFFFF",
|
|
2087
|
-
"#FEE7E7",
|
|
2088
|
-
"#FEF0E6",
|
|
2089
|
-
"#EFFBD0",
|
|
2090
|
-
"#E4F4FE",
|
|
2091
|
-
"#E8ECFD",
|
|
2092
|
-
"#F1EAFA",
|
|
2093
|
-
"#FDE8F3",
|
|
2094
|
-
"#E5E5E5",
|
|
2095
|
-
"#FDCECE",
|
|
2096
|
-
"#FDC49B",
|
|
2097
|
-
"#DEF6A2",
|
|
2098
|
-
"#9FDAFF",
|
|
2099
|
-
"#D0D9FB",
|
|
2100
|
-
"#E3D5F6",
|
|
2101
|
-
"#FBD0E8",
|
|
2102
|
-
"#656565",
|
|
2103
|
-
"#FE4B4B",
|
|
2104
|
-
"#FF8C51",
|
|
2105
|
-
"#8BBB11",
|
|
2106
|
-
"#0B9EFB",
|
|
2107
|
-
"#3A60F7",
|
|
2108
|
-
"#9E6DE3",
|
|
2109
|
-
"#F248A6"
|
|
2110
|
-
], Ei = (e) => {
|
|
2111
|
-
const { value: t, onChange: n, disabled: r } = e, [o, i] = W(!1);
|
|
2112
|
-
return /* @__PURE__ */ S(
|
|
2113
|
-
Lo,
|
|
2114
|
-
{
|
|
2115
|
-
align: "start",
|
|
2116
|
-
disabled: r,
|
|
2117
|
-
open: o,
|
|
2118
|
-
onOpenChange: i,
|
|
2119
|
-
overlay: /* @__PURE__ */ S(
|
|
2120
|
-
"div",
|
|
2121
|
-
{
|
|
2122
|
-
className: "univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",
|
|
2123
|
-
children: Mi.map(
|
|
2124
|
-
(a) => /* @__PURE__ */ S(
|
|
2125
|
-
"div",
|
|
2126
|
-
{
|
|
2127
|
-
className: Fe("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded", Et),
|
|
2128
|
-
style: { background: a },
|
|
2129
|
-
onClick: () => {
|
|
2130
|
-
n(a), i(!1);
|
|
2131
|
-
}
|
|
2132
|
-
},
|
|
2133
|
-
a
|
|
2134
|
-
)
|
|
2135
|
-
)
|
|
2136
|
-
}
|
|
2137
|
-
),
|
|
2138
|
-
children: /* @__PURE__ */ Y(
|
|
2139
|
-
"div",
|
|
2140
|
-
{
|
|
2141
|
-
className: Fe("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-white univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white", Et),
|
|
2142
|
-
children: [
|
|
2143
|
-
/* @__PURE__ */ S(
|
|
2144
|
-
"div",
|
|
2145
|
-
{
|
|
2146
|
-
className: "univer-box-border univer-size-4 univer-rounded univer-text-base",
|
|
2147
|
-
style: { background: t }
|
|
2148
|
-
}
|
|
2149
|
-
),
|
|
2150
|
-
/* @__PURE__ */ S(Mn, {})
|
|
2151
|
-
]
|
|
2152
|
-
}
|
|
2153
|
-
)
|
|
2154
|
-
}
|
|
2155
|
-
);
|
|
2156
|
-
}, Hn = (e) => {
|
|
2157
|
-
const { item: t, commonProps: n, className: r } = e, { onItemChange: o, onItemDelete: i } = n;
|
|
2158
|
-
return /* @__PURE__ */ Y("div", { className: Fe("univer-flex univer-items-center univer-gap-2", r), children: [
|
|
2159
|
-
!t.isRef && /* @__PURE__ */ S("div", { className: Fe("univer-cursor-move", "draggableHandle"), children: /* @__PURE__ */ S(Or, {}) }),
|
|
2160
|
-
/* @__PURE__ */ S(
|
|
2161
|
-
Ei,
|
|
2162
|
-
{
|
|
2163
|
-
value: t.color,
|
|
2164
|
-
onChange: (a) => {
|
|
2165
|
-
o(t.id, t.label, a);
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
),
|
|
2169
|
-
/* @__PURE__ */ S(
|
|
2170
|
-
Ue,
|
|
2171
|
-
{
|
|
2172
|
-
disabled: t.isRef,
|
|
2173
|
-
value: t.label,
|
|
2174
|
-
onChange: (a) => {
|
|
2175
|
-
o(t.id, a, t.color);
|
|
2176
|
-
}
|
|
2177
|
-
}
|
|
2178
|
-
),
|
|
2179
|
-
t.isRef ? null : /* @__PURE__ */ S(
|
|
2180
|
-
"div",
|
|
2181
|
-
{
|
|
2182
|
-
className: "univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",
|
|
2183
|
-
children: /* @__PURE__ */ S(bn, { onClick: () => i(t.id) })
|
|
2184
|
-
}
|
|
2185
|
-
)
|
|
2186
|
-
] });
|
|
2187
|
-
};
|
|
2188
|
-
function Di(e) {
|
|
2189
|
-
const { value: t, onChange: n = () => {
|
|
2190
|
-
}, unitId: r, subUnitId: o, validResult: i, showError: a, ruleId: l } = e, { formula1: s = "", formula2: d = "" } = t || {}, [u, h] = W(() => Pe(s) ? "1" : "0"), [c, m] = W(u === "1" ? s : "="), [I, V] = W(u === "1" ? s : "="), v = F(ge), C = F(Te), f = F(Sn), w = F(co), M = F(_e), [g, p] = W(() => d.split(",")), _ = C.getValidatorItem(X.LIST), [T, A] = W([]), [P, L] = W(""), y = a ? i == null ? void 0 : i.formula1 : "", O = gt(() => f.ruleChange$.pipe(vr(16)), []), U = Re(O), k = ln(n);
|
|
2191
|
-
Me(() => {
|
|
2192
|
-
(async () => {
|
|
2193
|
-
await new Promise((N) => {
|
|
2194
|
-
setTimeout(() => N(!0), 100);
|
|
2195
|
-
});
|
|
2196
|
-
const b = f.getRuleById(r, o, l), $ = b == null ? void 0 : b.formula1;
|
|
2197
|
-
if (Pe($) && _ && b) {
|
|
2198
|
-
const N = await _.getListAsync(b, r, o);
|
|
2199
|
-
A(N);
|
|
2200
|
-
}
|
|
2201
|
-
})();
|
|
2202
|
-
}, [f, U, _, l, o, r]), Me(() => {
|
|
2203
|
-
Pe(s) && s !== I && (m(s), V(I));
|
|
2204
|
-
}, [I, s]);
|
|
2205
|
-
const [x, te] = W(() => {
|
|
2206
|
-
const b = u !== "1" ? uo(s) : [], $ = d.split(",");
|
|
2207
|
-
return b.map((N, J) => ({
|
|
2208
|
-
label: N,
|
|
2209
|
-
color: $[J] || ke,
|
|
2210
|
-
isRef: !1,
|
|
2211
|
-
id: Vn(4)
|
|
2212
|
-
}));
|
|
2213
|
-
}), j = (b, $, N) => {
|
|
2214
|
-
const J = x.find((R) => R.id === b);
|
|
2215
|
-
J && (J.label = $, J.color = N, te([...x]));
|
|
2216
|
-
}, se = (b) => {
|
|
2217
|
-
const $ = x.findIndex((N) => N.id === b);
|
|
2218
|
-
$ !== -1 && (x.splice($, 1), te([...x]));
|
|
2219
|
-
}, le = d.split(","), de = gt(() => T.map((b, $) => ({
|
|
2220
|
-
label: b,
|
|
2221
|
-
color: le[$] || ke,
|
|
2222
|
-
id: `${$}`,
|
|
2223
|
-
isRef: !0
|
|
2224
|
-
})), [le, T]), be = (b, $, N) => {
|
|
2225
|
-
const J = [...g];
|
|
2226
|
-
J[+b] = N, p(J), k({
|
|
2227
|
-
formula1: s,
|
|
2228
|
-
formula2: J.join(",")
|
|
2229
|
-
});
|
|
2230
|
-
}, Q = () => {
|
|
2231
|
-
te([
|
|
2232
|
-
...x,
|
|
2233
|
-
{
|
|
2234
|
-
label: "",
|
|
2235
|
-
color: ke,
|
|
2236
|
-
isRef: !1,
|
|
2237
|
-
id: Vn(4)
|
|
2238
|
-
}
|
|
2239
|
-
]);
|
|
2240
|
-
};
|
|
2241
|
-
Me(() => {
|
|
2242
|
-
if (u === "1")
|
|
2243
|
-
return;
|
|
2244
|
-
const b = /* @__PURE__ */ new Set(), $ = [];
|
|
2245
|
-
x.map((N) => ({
|
|
2246
|
-
labelList: N.label.split(","),
|
|
2247
|
-
item: N
|
|
2248
|
-
})).forEach(({ item: N, labelList: J }) => {
|
|
2249
|
-
J.forEach((R) => {
|
|
2250
|
-
b.has(R) || (b.add(R), $.push({
|
|
2251
|
-
label: R,
|
|
2252
|
-
color: N.color
|
|
2253
|
-
}));
|
|
2254
|
-
});
|
|
2255
|
-
}), k({
|
|
2256
|
-
formula1: or($.map((N) => N.label)),
|
|
2257
|
-
formula2: $.map((N) => N.color === ke ? "" : N.color).join(",")
|
|
2258
|
-
});
|
|
2259
|
-
}, [x, k, u, I, g]);
|
|
2260
|
-
const G = ln(async (b) => {
|
|
2261
|
-
if (!Pe(b)) {
|
|
2262
|
-
k == null || k({
|
|
2263
|
-
formula1: "",
|
|
2264
|
-
formula2: d
|
|
2265
|
-
});
|
|
2266
|
-
return;
|
|
2267
|
-
}
|
|
2268
|
-
w.getFormulaRefCheck(b) ? (k == null || k({
|
|
2269
|
-
formula1: Pe(b) ? b : "",
|
|
2270
|
-
formula2: d
|
|
2271
|
-
}), L("")) : (k == null || k({
|
|
2272
|
-
formula1: "",
|
|
2273
|
-
formula2: d
|
|
2274
|
-
}), m("="), L(v.t("dataValidation.validFail.formulaError")));
|
|
2275
|
-
}), ce = ft(null), [ee, q] = W(!1);
|
|
2276
|
-
return gr((b) => {
|
|
2277
|
-
var N;
|
|
2278
|
-
(N = ce.current) != null && N.isClickOutSide(b) && q(!1);
|
|
2279
|
-
}), Me(() => {
|
|
2280
|
-
ee ? M.setFocusFormulaEditorActiveRuleSubUnitId(o) : M.setFocusFormulaEditorActiveRuleSubUnitId(null);
|
|
2281
|
-
}, [ee, o, M]), /* @__PURE__ */ Y(vt, { children: [
|
|
2282
|
-
/* @__PURE__ */ S(Z, { label: v.t("dataValidation.list.options"), children: /* @__PURE__ */ Y(
|
|
2283
|
-
Rn,
|
|
2284
|
-
{
|
|
2285
|
-
value: u,
|
|
2286
|
-
onChange: (b) => {
|
|
2287
|
-
h(b), m(I), b === "1" && k({
|
|
2288
|
-
formula1: I === "=" ? "" : I,
|
|
2289
|
-
formula2: g.join(",")
|
|
2290
|
-
});
|
|
2291
|
-
},
|
|
2292
|
-
children: [
|
|
2293
|
-
/* @__PURE__ */ S(Ne, { value: "0", children: v.t("dataValidation.list.customOptions") }),
|
|
2294
|
-
/* @__PURE__ */ S(Ne, { value: "1", children: v.t("dataValidation.list.refOptions") })
|
|
2295
|
-
]
|
|
2296
|
-
}
|
|
2297
|
-
) }),
|
|
2298
|
-
u === "1" ? /* @__PURE__ */ Y(Z, { error: y || P || void 0, children: [
|
|
2299
|
-
/* @__PURE__ */ S(
|
|
2300
|
-
Ir,
|
|
2301
|
-
{
|
|
2302
|
-
ref: ce,
|
|
2303
|
-
className: Fe("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", Et),
|
|
2304
|
-
initValue: c,
|
|
2305
|
-
unitId: r,
|
|
2306
|
-
subUnitId: o,
|
|
2307
|
-
isFocus: ee,
|
|
2308
|
-
isSupportAcrossSheet: !0,
|
|
2309
|
-
onFocus: () => q(!0),
|
|
2310
|
-
onChange: (b = "") => {
|
|
2311
|
-
const $ = (b != null ? b : "").trim();
|
|
2312
|
-
V($), G($);
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
),
|
|
2316
|
-
de.length > 0 && /* @__PURE__ */ S("div", { className: "univer-mt-3", children: de.map((b) => /* @__PURE__ */ S(
|
|
2317
|
-
Hn,
|
|
2318
|
-
{
|
|
2319
|
-
className: "univer-mb-3",
|
|
2320
|
-
item: b,
|
|
2321
|
-
commonProps: { onItemChange: be }
|
|
2322
|
-
},
|
|
2323
|
-
b.id
|
|
2324
|
-
)) })
|
|
2325
|
-
] }) : /* @__PURE__ */ S(Z, { error: y, children: /* @__PURE__ */ Y("div", { className: "-univer-mt-3", children: [
|
|
2326
|
-
/* @__PURE__ */ S(
|
|
2327
|
-
Po,
|
|
2328
|
-
{
|
|
2329
|
-
list: x,
|
|
2330
|
-
onListChange: te,
|
|
2331
|
-
rowHeight: 28,
|
|
2332
|
-
margin: [0, 12],
|
|
2333
|
-
draggableHandle: ".draggableHandle",
|
|
2334
|
-
itemRender: (b) => /* @__PURE__ */ S(
|
|
2335
|
-
Hn,
|
|
2336
|
-
{
|
|
2337
|
-
item: b,
|
|
2338
|
-
commonProps: {
|
|
2339
|
-
onItemChange: j,
|
|
2340
|
-
onItemDelete: se
|
|
2341
|
-
}
|
|
2342
|
-
},
|
|
2343
|
-
b.id
|
|
2344
|
-
),
|
|
2345
|
-
idKey: "id"
|
|
2346
|
-
}
|
|
2347
|
-
),
|
|
2348
|
-
/* @__PURE__ */ Y(
|
|
2349
|
-
"a",
|
|
2350
|
-
{
|
|
2351
|
-
className: "univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",
|
|
2352
|
-
onClick: Q,
|
|
2353
|
-
children: [
|
|
2354
|
-
/* @__PURE__ */ S(Vr, { className: "univer-mr-1" }),
|
|
2355
|
-
v.t("dataValidation.list.add")
|
|
2356
|
-
]
|
|
2357
|
-
}
|
|
2358
|
-
)
|
|
2359
|
-
] }) })
|
|
2360
|
-
] });
|
|
2361
|
-
}
|
|
2362
|
-
const Vi = [
|
|
2363
|
-
[
|
|
2364
|
-
cr,
|
|
2365
|
-
bi
|
|
2366
|
-
],
|
|
2367
|
-
[
|
|
2368
|
-
Nt,
|
|
2369
|
-
Ri
|
|
2370
|
-
],
|
|
2371
|
-
[
|
|
2372
|
-
_n,
|
|
2373
|
-
Di
|
|
2374
|
-
],
|
|
2375
|
-
[
|
|
2376
|
-
ur,
|
|
2377
|
-
yi
|
|
2378
|
-
]
|
|
2379
|
-
], Ti = "LIST_RENDER_MODE_OPTION_INPUT";
|
|
2380
|
-
function Pt(e) {
|
|
2381
|
-
var o;
|
|
2382
|
-
const { value: t, onChange: n } = e, r = F(ge);
|
|
2383
|
-
return /* @__PURE__ */ S(Z, { label: r.t("dataValidation.renderMode.label"), children: /* @__PURE__ */ Y(Rn, { value: `${(o = t.renderMode) != null ? o : ue.CUSTOM}`, onChange: (i) => n({ ...t, renderMode: +i }), children: [
|
|
2384
|
-
/* @__PURE__ */ S(Ne, { value: `${ue.CUSTOM}`, children: r.t("dataValidation.renderMode.chip") }),
|
|
2385
|
-
/* @__PURE__ */ S(Ne, { value: `${ue.ARROW}`, children: r.t("dataValidation.renderMode.arrow") }),
|
|
2386
|
-
/* @__PURE__ */ S(Ne, { value: `${ue.TEXT}`, children: r.t("dataValidation.renderMode.text") })
|
|
2387
|
-
] }) });
|
|
2388
|
-
}
|
|
2389
|
-
Pt.componentKey = Ti;
|
|
2390
|
-
const Oi = "DATE_SHOW_TIME_OPTION";
|
|
2391
|
-
function Lt(e) {
|
|
2392
|
-
var o;
|
|
2393
|
-
const { value: t, onChange: n } = e, r = F(ge);
|
|
2394
|
-
return /* @__PURE__ */ S(Z, { children: /* @__PURE__ */ S(
|
|
2395
|
-
Ut,
|
|
2396
|
-
{
|
|
2397
|
-
checked: (o = t.bizInfo) == null ? void 0 : o.showTime,
|
|
2398
|
-
onChange: (i) => {
|
|
2399
|
-
n({
|
|
2400
|
-
...t,
|
|
2401
|
-
bizInfo: {
|
|
2402
|
-
...t.bizInfo,
|
|
2403
|
-
showTime: i
|
|
2404
|
-
}
|
|
2405
|
-
});
|
|
2406
|
-
},
|
|
2407
|
-
children: r.t("dataValidation.showTime.label")
|
|
2408
|
-
}
|
|
2409
|
-
) });
|
|
2410
|
-
}
|
|
2411
|
-
Lt.componentKey = Oi;
|
|
2412
|
-
var Ai = Object.getOwnPropertyDescriptor, Pi = (e, t, n, r) => {
|
|
2413
|
-
for (var o = r > 1 ? void 0 : r ? Ai(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
2414
|
-
(a = e[i]) && (o = a(o) || o);
|
|
2415
|
-
return o;
|
|
2416
|
-
}, Ye = (e, t) => (n, r) => t(n, r, e);
|
|
2417
|
-
const wt = 6;
|
|
2418
|
-
let cn = class {
|
|
2419
|
-
constructor(e, t, n, r, o, i) {
|
|
2420
|
-
this._commandService = e, this._univerInstanceService = t, this._formulaService = n, this._themeService = r, this._renderManagerService = o, this._dataValidationModel = i;
|
|
2421
|
-
}
|
|
2422
|
-
_calc(e, t) {
|
|
2423
|
-
var d, u, h;
|
|
2424
|
-
const { vt: n, ht: r } = t || {}, o = e.endX - e.startX - wt * 2, i = e.endY - e.startY, a = ((d = t == null ? void 0 : t.fs) != null ? d : 10) * 1.6;
|
|
2425
|
-
let l = 0, s = 0;
|
|
2426
|
-
switch (n) {
|
|
2427
|
-
case he.TOP:
|
|
2428
|
-
s = 0;
|
|
2429
|
-
break;
|
|
2430
|
-
case he.BOTTOM:
|
|
2431
|
-
s = 0 + (i - a);
|
|
2432
|
-
break;
|
|
2433
|
-
default:
|
|
2434
|
-
s = 0 + (i - a) / 2;
|
|
2435
|
-
break;
|
|
2436
|
-
}
|
|
2437
|
-
switch (r) {
|
|
2438
|
-
case Ee.LEFT:
|
|
2439
|
-
l = wt;
|
|
2440
|
-
break;
|
|
2441
|
-
case Ee.RIGHT:
|
|
2442
|
-
l = wt + (o - a);
|
|
2443
|
-
break;
|
|
2444
|
-
default:
|
|
2445
|
-
l = wt + (o - a) / 2;
|
|
2446
|
-
break;
|
|
2447
|
-
}
|
|
2448
|
-
return {
|
|
2449
|
-
left: e.startX + l,
|
|
2450
|
-
top: e.startY + s,
|
|
2451
|
-
width: ((u = t == null ? void 0 : t.fs) != null ? u : 10) * 1.6,
|
|
2452
|
-
height: ((h = t == null ? void 0 : t.fs) != null ? h : 10) * 1.6
|
|
2453
|
-
};
|
|
2454
|
-
}
|
|
2455
|
-
calcCellAutoHeight(e) {
|
|
2456
|
-
var n;
|
|
2457
|
-
const { style: t } = e;
|
|
2458
|
-
return ((n = t == null ? void 0 : t.fs) != null ? n : 10) * 1.6;
|
|
2459
|
-
}
|
|
2460
|
-
calcCellAutoWidth(e) {
|
|
2461
|
-
var n;
|
|
2462
|
-
const { style: t } = e;
|
|
2463
|
-
return ((n = t == null ? void 0 : t.fs) != null ? n : 10) * 1.6;
|
|
2464
|
-
}
|
|
2465
|
-
async _parseFormula(e, t, n) {
|
|
2466
|
-
var d, u, h, c, m, I, V, v, C;
|
|
2467
|
-
const { formula1: r = go, formula2: o = po } = e, i = await this._formulaService.getRuleFormulaResult(t, n, e.uid), a = Ht((h = (u = (d = i == null ? void 0 : i[0]) == null ? void 0 : d.result) == null ? void 0 : u[0]) == null ? void 0 : h[0]), l = Ht((I = (m = (c = i == null ? void 0 : i[1]) == null ? void 0 : c.result) == null ? void 0 : m[0]) == null ? void 0 : I[0]), s = Pn(String(a)) && Pn(String(l));
|
|
2468
|
-
return {
|
|
2469
|
-
formula1: Pe(r) ? Ht((C = (v = (V = i == null ? void 0 : i[0]) == null ? void 0 : V.result) == null ? void 0 : v[0]) == null ? void 0 : C[0]) : r,
|
|
2470
|
-
formula2: Pe(o) ? l : o,
|
|
2471
|
-
isFormulaValid: s
|
|
2472
|
-
};
|
|
2473
|
-
}
|
|
2474
|
-
drawWith(e, t) {
|
|
2475
|
-
var L, y, O, U;
|
|
2476
|
-
const { style: n, primaryWithCoord: r, unitId: o, subUnitId: i, worksheet: a, row: l, col: s } = t, d = r.isMergedMainCell ? r.mergeInfo : r, u = ie(a.getCellRaw(l, s)), h = this._dataValidationModel.getRuleByLocation(o, i, l, s);
|
|
2477
|
-
if (!h)
|
|
2478
|
-
return;
|
|
2479
|
-
const c = this._dataValidationModel.getValidator(h.type);
|
|
2480
|
-
if (!c || !((L = c.skipDefaultFontRender) != null && L.call(c, h, u, { unitId: o, subUnitId: i, row: l, column: s })))
|
|
2481
|
-
return;
|
|
2482
|
-
const m = c.parseFormulaSync(h, o, i), { formula1: I } = m, V = this._calc(d, n), { a: v, d: C } = e.getTransform(), f = Tn(V.left, v), w = Tn(V.top, C), M = Kr.create().composeMatrix({
|
|
2483
|
-
left: f,
|
|
2484
|
-
top: w,
|
|
2485
|
-
scaleX: 1,
|
|
2486
|
-
scaleY: 1,
|
|
2487
|
-
angle: 0,
|
|
2488
|
-
skewX: 0,
|
|
2489
|
-
skewY: 0,
|
|
2490
|
-
flipX: !1,
|
|
2491
|
-
flipY: !1
|
|
2492
|
-
}), g = d.endX - d.startX, p = d.endY - d.startY;
|
|
2493
|
-
e.save(), e.beginPath(), e.rect(d.startX, d.startY, g, p), e.clip();
|
|
2494
|
-
const _ = M.getMatrix();
|
|
2495
|
-
e.transform(_[0], _[1], _[2], _[3], _[4], _[5]);
|
|
2496
|
-
const T = ((y = n == null ? void 0 : n.fs) != null ? y : 10) * 1.6, A = String(u) === String(I), P = this._themeService.getColorFromTheme("primary.600");
|
|
2497
|
-
Gr.drawWith(e, {
|
|
2498
|
-
checked: A,
|
|
2499
|
-
width: T,
|
|
2500
|
-
height: T,
|
|
2501
|
-
fill: (U = (O = n == null ? void 0 : n.cl) == null ? void 0 : O.rgb) != null ? U : P
|
|
2502
|
-
}), e.restore();
|
|
2503
|
-
}
|
|
2504
|
-
isHit(e, t) {
|
|
2505
|
-
const n = t.primaryWithCoord.isMergedMainCell ? t.primaryWithCoord.mergeInfo : t.primaryWithCoord, r = this._calc(n, t.style), o = r.top, i = r.top + r.height, a = r.left, l = r.left + r.width, { x: s, y: d } = e;
|
|
2506
|
-
return s <= l && s >= a && d <= i && d >= o;
|
|
2507
|
-
}
|
|
2508
|
-
async onPointerDown(e, t) {
|
|
2509
|
-
var I;
|
|
2510
|
-
if (t.button === 2)
|
|
2511
|
-
return;
|
|
2512
|
-
const { primaryWithCoord: n, unitId: r, subUnitId: o, worksheet: i, row: a, col: l } = e, s = ie(i.getCellRaw(a, l)), d = this._dataValidationModel.getRuleByLocation(r, o, a, l);
|
|
2513
|
-
if (!d)
|
|
2514
|
-
return;
|
|
2515
|
-
const u = this._dataValidationModel.getValidator(d.type);
|
|
2516
|
-
if (!u || !((I = u.skipDefaultFontRender) != null && I.call(u, d, s, { unitId: r, subUnitId: o, row: a, column: l })))
|
|
2517
|
-
return;
|
|
2518
|
-
const { formula1: h, formula2: c } = await this._parseFormula(d, r, o), m = {
|
|
2519
|
-
range: {
|
|
2520
|
-
startColumn: n.actualColumn,
|
|
2521
|
-
endColumn: n.actualColumn,
|
|
2522
|
-
startRow: n.actualRow,
|
|
2523
|
-
endRow: n.actualRow
|
|
2524
|
-
},
|
|
2525
|
-
value: {
|
|
2526
|
-
v: String(s) === vo(String(h)) ? c : h,
|
|
2527
|
-
p: null
|
|
2528
|
-
}
|
|
2529
|
-
};
|
|
2530
|
-
this._commandService.executeCommand(
|
|
2531
|
-
ut.id,
|
|
2532
|
-
m
|
|
2533
|
-
);
|
|
2534
|
-
}
|
|
2535
|
-
onPointerEnter(e, t) {
|
|
2536
|
-
var n, r;
|
|
2537
|
-
(r = (n = Ge(H.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : n.mainComponent) == null || r.setCursor(qe.POINTER);
|
|
2538
|
-
}
|
|
2539
|
-
onPointerLeave(e, t) {
|
|
2540
|
-
var n, r;
|
|
2541
|
-
(r = (n = Ge(H.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : n.mainComponent) == null || r.setCursor(qe.DEFAULT);
|
|
2542
|
-
}
|
|
2543
|
-
};
|
|
2544
|
-
cn = Pi([
|
|
2545
|
-
Ye(0, oe),
|
|
2546
|
-
Ye(1, pe),
|
|
2547
|
-
Ye(2, D(ho)),
|
|
2548
|
-
Ye(3, D(Gn)),
|
|
2549
|
-
Ye(4, D(xe)),
|
|
2550
|
-
Ye(5, D(ae))
|
|
2551
|
-
], cn);
|
|
2552
|
-
var Li = Object.getOwnPropertyDescriptor, ki = (e, t, n, r) => {
|
|
2553
|
-
for (var o = r > 1 ? void 0 : r ? Li(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
2554
|
-
(a = e[i]) && (o = a(o) || o);
|
|
2555
|
-
return o;
|
|
2556
|
-
}, Ni = (e, t) => (n, r) => t(n, r, e);
|
|
2557
|
-
let Ce = class {
|
|
2558
|
-
constructor(e) {
|
|
2559
|
-
E(this, "canvasRender", null);
|
|
2560
|
-
E(this, "dropdownType");
|
|
2561
|
-
E(this, "optionsInput");
|
|
2562
|
-
E(this, "formulaInput", _n);
|
|
2563
|
-
this.injector = e;
|
|
2564
|
-
}
|
|
2565
|
-
};
|
|
2566
|
-
Ce = ki([
|
|
2567
|
-
Ni(0, D(Ve))
|
|
2568
|
-
], Ce);
|
|
2569
|
-
class Ui extends Ce {
|
|
2570
|
-
constructor() {
|
|
2571
|
-
super(...arguments);
|
|
2572
|
-
E(this, "id", X.CHECKBOX);
|
|
2573
|
-
E(this, "canvasRender", this.injector.createInstance(cn));
|
|
2574
|
-
E(this, "formulaInput", ur);
|
|
2575
|
-
}
|
|
2576
|
-
}
|
|
2577
|
-
class Fi extends Ce {
|
|
2578
|
-
constructor() {
|
|
2579
|
-
super(...arguments);
|
|
2580
|
-
E(this, "id", X.CUSTOM);
|
|
2581
|
-
E(this, "formulaInput", cr);
|
|
2582
|
-
}
|
|
2583
|
-
}
|
|
2584
|
-
const $i = "data-validation.formula-input";
|
|
2585
|
-
class xi extends Ce {
|
|
2586
|
-
constructor() {
|
|
2587
|
-
super(...arguments);
|
|
2588
|
-
E(this, "id", X.DATE);
|
|
2589
|
-
E(this, "formulaInput", $i);
|
|
2590
|
-
E(this, "optionsInput", Lt.componentKey);
|
|
2591
|
-
E(this, "dropdownType", fe.DATE);
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
class Bi extends Ce {
|
|
2595
|
-
constructor() {
|
|
2596
|
-
super(...arguments);
|
|
2597
|
-
E(this, "id", X.DECIMAL);
|
|
2598
|
-
E(this, "formulaInput", Nt);
|
|
2599
|
-
}
|
|
2600
|
-
}
|
|
2601
|
-
const Ar = 4, Wi = 0, zt = 4, Pr = 4, un = 6, kt = 6, Ae = 14;
|
|
2602
|
-
function Hi(e, t) {
|
|
2603
|
-
const n = qr.getTextSize(e, t), r = n.width + Ar * 2, { ba: o, bd: i } = n, a = o + i;
|
|
2604
|
-
return {
|
|
2605
|
-
width: r,
|
|
2606
|
-
height: a + Wi * 2,
|
|
2607
|
-
ba: o
|
|
2608
|
-
};
|
|
2609
|
-
}
|
|
2610
|
-
function Kt(e, t, n, r) {
|
|
2611
|
-
const o = Ae + un * 2, i = n - o, a = r - kt * 2, l = e.map((c) => ({
|
|
2612
|
-
layout: Hi(c, t),
|
|
2613
|
-
text: c
|
|
2614
|
-
}));
|
|
2615
|
-
let s;
|
|
2616
|
-
const d = [];
|
|
2617
|
-
l.forEach((c) => {
|
|
2618
|
-
const { layout: m } = c, { width: I, height: V } = m;
|
|
2619
|
-
!s || s.width + I + zt > i ? (s = {
|
|
2620
|
-
width: I,
|
|
2621
|
-
height: V,
|
|
2622
|
-
items: [{
|
|
2623
|
-
...c,
|
|
2624
|
-
left: 0
|
|
2625
|
-
}]
|
|
2626
|
-
}, d.push(s)) : (s.items.push({
|
|
2627
|
-
...c,
|
|
2628
|
-
left: s.width + zt
|
|
2629
|
-
}), s.width = s.width + I + zt);
|
|
2630
|
-
});
|
|
2631
|
-
let u = 0, h = 0;
|
|
2632
|
-
return d.forEach((c, m) => {
|
|
2633
|
-
h = Math.max(h, c.width), m === d.length - 1 ? u += c.height : u += c.height + Pr;
|
|
2634
|
-
}), {
|
|
2635
|
-
lines: d,
|
|
2636
|
-
totalHeight: u,
|
|
2637
|
-
contentWidth: i,
|
|
2638
|
-
contentHeight: a,
|
|
2639
|
-
cellAutoHeight: u + kt * 2,
|
|
2640
|
-
calcAutoWidth: h + o
|
|
2641
|
-
};
|
|
2642
|
-
}
|
|
2643
|
-
const ji = 8;
|
|
2644
|
-
class Yi extends Jr {
|
|
2645
|
-
static drawWith(t, n) {
|
|
2646
|
-
const { fontString: r, info: o, fill: i, color: a } = n, { layout: l, text: s } = o;
|
|
2647
|
-
t.save(), Qn.drawWith(t, {
|
|
2648
|
-
width: l.width,
|
|
2649
|
-
height: l.height,
|
|
2650
|
-
radius: ji,
|
|
2651
|
-
fill: i || ke
|
|
2652
|
-
}), t.translateWithPrecision(Ar, l.ba), t.font = r, t.fillStyle = a, t.fillText(s, 0, 0), t.restore();
|
|
2653
|
-
}
|
|
2654
|
-
}
|
|
2655
|
-
var Xi = Object.getOwnPropertyDescriptor, Zi = (e, t, n, r) => {
|
|
2656
|
-
for (var o = r > 1 ? void 0 : r ? Xi(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
2657
|
-
(a = e[i]) && (o = a(o) || o);
|
|
2658
|
-
return o;
|
|
2659
|
-
}, Rt = (e, t) => (n, r) => t(n, r, e);
|
|
2660
|
-
const zi = 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");
|
|
2661
|
-
let hn = class {
|
|
2662
|
-
constructor(e, t, n, r) {
|
|
2663
|
-
E(this, "zIndex");
|
|
2664
|
-
E(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
|
|
2665
|
-
this._commandService = e, this._univerInstanceService = t, this._renderManagerService = n, this._dataValidationModel = r;
|
|
2666
|
-
}
|
|
2667
|
-
_ensureMap(e) {
|
|
2668
|
-
let t = this._dropdownInfoMap.get(e);
|
|
2669
|
-
return t || (t = /* @__PURE__ */ new Map(), this._dropdownInfoMap.set(e, t)), t;
|
|
2670
|
-
}
|
|
2671
|
-
_generateKey(e, t) {
|
|
2672
|
-
return `${e}.${t}`;
|
|
2673
|
-
}
|
|
2674
|
-
_drawDownIcon(e, t, n, r, o) {
|
|
2675
|
-
const i = n - Ae + 4;
|
|
2676
|
-
let a = 4;
|
|
2677
|
-
switch (o) {
|
|
2678
|
-
case he.MIDDLE:
|
|
2679
|
-
a = (r - Ae) / 2 + 4;
|
|
2680
|
-
break;
|
|
2681
|
-
case he.BOTTOM:
|
|
2682
|
-
a = r - Ae + 4;
|
|
2683
|
-
break;
|
|
2684
|
-
}
|
|
2685
|
-
e.save(), e.translateWithPrecision(t.startX + i, t.startY + a), e.fillStyle = "#565656", e.fill(zi), e.restore();
|
|
2686
|
-
}
|
|
2687
|
-
// eslint-disable-next-line max-lines-per-function
|
|
2688
|
-
drawWith(e, t, n, r) {
|
|
2689
|
-
var le, de;
|
|
2690
|
-
const { primaryWithCoord: o, row: i, col: a, style: l, data: s, subUnitId: d } = t, u = o.isMergedMainCell ? o.mergeInfo : o, h = s == null ? void 0 : s.fontRenderExtension, { leftOffset: c = 0, rightOffset: m = 0, topOffset: I = 0, downOffset: V = 0 } = h || {}, v = this._ensureMap(d), C = this._generateKey(i, a), f = o.isMergedMainCell ? o.mergeInfo.startRow : i, w = o.isMergedMainCell ? o.mergeInfo.startColumn : a, M = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, f, w);
|
|
2691
|
-
if (!M)
|
|
2692
|
-
return;
|
|
2693
|
-
const g = this._dataValidationModel.getValidator(M.type);
|
|
2694
|
-
if (!g)
|
|
2695
|
-
return;
|
|
2696
|
-
const p = {
|
|
2697
|
-
startX: u.startX + c,
|
|
2698
|
-
endX: u.endX - m,
|
|
2699
|
-
startY: u.startY + I,
|
|
2700
|
-
endY: u.endY - V
|
|
2701
|
-
}, _ = p.endX - p.startX, T = p.endY - p.startY, { cl: A } = l || {}, P = (le = typeof A == "object" ? A == null ? void 0 : A.rgb : A) != null ? le : "#000", L = Le(l != null ? l : void 0), { vt: y, ht: O } = l || {}, U = y != null ? y : he.MIDDLE, k = (de = ie(s)) != null ? de : "", x = g.parseCellValue(k), te = g.getListWithColorMap(M), j = Kt(x, L, _, T);
|
|
2702
|
-
this._drawDownIcon(e, p, _, T, U), e.save(), e.translateWithPrecision(p.startX, p.startY), e.beginPath(), e.rect(0, 0, _ - Ae, T), e.clip(), e.translateWithPrecision(un, kt);
|
|
2703
|
-
let se = 0;
|
|
2704
|
-
switch (U) {
|
|
2705
|
-
case he.MIDDLE:
|
|
2706
|
-
se = (j.contentHeight - j.totalHeight) / 2;
|
|
2707
|
-
break;
|
|
2708
|
-
case he.BOTTOM:
|
|
2709
|
-
se = j.contentHeight - j.totalHeight;
|
|
2710
|
-
break;
|
|
2711
|
-
}
|
|
2712
|
-
e.translateWithPrecision(0, se), j.lines.forEach((be, Q) => {
|
|
2713
|
-
e.save();
|
|
2714
|
-
const { width: G, height: ce, items: ee } = be;
|
|
2715
|
-
let q = 0;
|
|
2716
|
-
switch (O) {
|
|
2717
|
-
case Ee.RIGHT:
|
|
2718
|
-
q = j.contentWidth - G;
|
|
2719
|
-
break;
|
|
2720
|
-
case Ee.CENTER:
|
|
2721
|
-
q = (j.contentWidth - G) / 2;
|
|
2722
|
-
break;
|
|
2723
|
-
}
|
|
2724
|
-
e.translate(q, Q * (ce + Pr)), ee.forEach((b) => {
|
|
2725
|
-
e.save(), e.translateWithPrecision(b.left, 0), Yi.drawWith(e, {
|
|
2726
|
-
...L,
|
|
2727
|
-
info: b,
|
|
2728
|
-
color: P,
|
|
2729
|
-
fill: te[b.text]
|
|
2730
|
-
}), e.restore();
|
|
2731
|
-
}), e.restore();
|
|
2732
|
-
}), e.restore(), v.set(C, {
|
|
2733
|
-
left: p.startX,
|
|
2734
|
-
top: p.startY,
|
|
2735
|
-
width: j.contentWidth + un + Ae,
|
|
2736
|
-
height: j.contentHeight + kt * 2
|
|
2737
|
-
});
|
|
2738
|
-
}
|
|
2739
|
-
calcCellAutoHeight(e) {
|
|
2740
|
-
var g;
|
|
2741
|
-
const { primaryWithCoord: t, style: n, data: r, row: o, col: i } = e, a = r == null ? void 0 : r.fontRenderExtension, { leftOffset: l = 0, rightOffset: s = 0, topOffset: d = 0, downOffset: u = 0 } = a || {}, h = t.isMergedMainCell ? t.mergeInfo : t, c = {
|
|
2742
|
-
startX: h.startX + l,
|
|
2743
|
-
endX: h.endX - s,
|
|
2744
|
-
startY: h.startY + d,
|
|
2745
|
-
endY: h.endY - u
|
|
2746
|
-
}, m = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, o, i);
|
|
2747
|
-
if (!m)
|
|
2748
|
-
return;
|
|
2749
|
-
const I = this._dataValidationModel.getValidator(m.type);
|
|
2750
|
-
if (!I)
|
|
2751
|
-
return;
|
|
2752
|
-
const V = c.endX - c.startX, v = c.endY - c.startY, C = (g = ie(r)) != null ? g : "", f = I.parseCellValue(C), w = Le(n != null ? n : void 0);
|
|
2753
|
-
return Kt(f, w, V, v).cellAutoHeight;
|
|
2754
|
-
}
|
|
2755
|
-
calcCellAutoWidth(e) {
|
|
2756
|
-
var g;
|
|
2757
|
-
const { primaryWithCoord: t, style: n, data: r, row: o, col: i } = e, a = r == null ? void 0 : r.fontRenderExtension, { leftOffset: l = 0, rightOffset: s = 0, topOffset: d = 0, downOffset: u = 0 } = a || {}, h = t.isMergedMainCell ? t.mergeInfo : t, c = {
|
|
2758
|
-
startX: h.startX + l,
|
|
2759
|
-
endX: h.endX - s,
|
|
2760
|
-
startY: h.startY + d,
|
|
2761
|
-
endY: h.endY - u
|
|
2762
|
-
}, m = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, o, i);
|
|
2763
|
-
if (!m)
|
|
2764
|
-
return;
|
|
2765
|
-
const I = this._dataValidationModel.getValidator(m.type);
|
|
2766
|
-
if (!I)
|
|
2767
|
-
return;
|
|
2768
|
-
const V = c.endX - c.startX, v = c.endY - c.startY, C = (g = ie(r)) != null ? g : "", f = I.parseCellValue(C), w = Le(n != null ? n : void 0);
|
|
2769
|
-
return Kt(f, w, V, v).calcAutoWidth;
|
|
2770
|
-
}
|
|
2771
|
-
isHit(e, t) {
|
|
2772
|
-
const { primaryWithCoord: n } = t, r = n.isMergedMainCell ? n.mergeInfo : n, { endX: o } = r, { x: i } = e;
|
|
2773
|
-
return i >= o - Ae && i <= o;
|
|
2774
|
-
}
|
|
2775
|
-
onPointerDown(e, t) {
|
|
2776
|
-
if (t.button === 2)
|
|
2777
|
-
return;
|
|
2778
|
-
const { unitId: n, subUnitId: r, row: o, col: i } = e, a = {
|
|
2779
|
-
unitId: n,
|
|
2780
|
-
subUnitId: r,
|
|
2781
|
-
row: o,
|
|
2782
|
-
column: i
|
|
2783
|
-
};
|
|
2784
|
-
this._commandService.executeCommand(Ft.id, a);
|
|
2785
|
-
}
|
|
2786
|
-
onPointerEnter(e, t) {
|
|
2787
|
-
var n, r;
|
|
2788
|
-
return (r = (n = Ge(H.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : n.mainComponent) == null ? void 0 : r.setCursor(qe.POINTER);
|
|
2789
|
-
}
|
|
2790
|
-
onPointerLeave(e, t) {
|
|
2791
|
-
var n, r;
|
|
2792
|
-
return (r = (n = Ge(H.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : n.mainComponent) == null ? void 0 : r.setCursor(qe.DEFAULT);
|
|
2793
|
-
}
|
|
2794
|
-
};
|
|
2795
|
-
hn = Zi([
|
|
2796
|
-
Rt(0, oe),
|
|
2797
|
-
Rt(1, pe),
|
|
2798
|
-
Rt(2, D(xe)),
|
|
2799
|
-
Rt(3, D(ae))
|
|
2800
|
-
], hn);
|
|
2801
|
-
class Ki extends Ce {
|
|
2802
|
-
constructor() {
|
|
2803
|
-
super(...arguments);
|
|
2804
|
-
E(this, "id", X.LIST_MULTIPLE);
|
|
2805
|
-
E(this, "canvasRender", this.injector.createInstance(hn));
|
|
2806
|
-
E(this, "dropdownType", fe.MULTIPLE_LIST);
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2809
|
-
var Gi = Object.getOwnPropertyDescriptor, qi = (e, t, n, r) => {
|
|
2810
|
-
for (var o = r > 1 ? void 0 : r ? Gi(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
2811
|
-
(a = e[i]) && (o = a(o) || o);
|
|
2812
|
-
return o;
|
|
2813
|
-
}, ct = (e, t) => (n, r) => t(n, r, e);
|
|
2814
|
-
const Xe = 4, yt = 4, me = 14, Gt = 1, we = 6, ze = 3, qt = 8, Ji = "#565656", jn = 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");
|
|
2815
|
-
function Yn(e, t, n, r, o, i, a = !0) {
|
|
2816
|
-
let l = 0;
|
|
2817
|
-
const s = a ? ze : 0;
|
|
2818
|
-
switch (o) {
|
|
2819
|
-
case he.BOTTOM:
|
|
2820
|
-
l = t - r - s;
|
|
2821
|
-
break;
|
|
2822
|
-
case he.MIDDLE:
|
|
2823
|
-
l = (t - r) / 2;
|
|
2824
|
-
break;
|
|
2825
|
-
default:
|
|
2826
|
-
l = s;
|
|
2827
|
-
break;
|
|
2828
|
-
}
|
|
2829
|
-
l = Math.max(ze, l);
|
|
2830
|
-
let d = 0;
|
|
2831
|
-
switch (i) {
|
|
2832
|
-
case Ee.CENTER:
|
|
2833
|
-
d = (e - n) / 2;
|
|
2834
|
-
break;
|
|
2835
|
-
case Ee.RIGHT:
|
|
2836
|
-
d = e - n;
|
|
2837
|
-
break;
|
|
2838
|
-
}
|
|
2839
|
-
return d = Math.max(we, d), {
|
|
2840
|
-
paddingLeft: d,
|
|
2841
|
-
paddingTop: l
|
|
2842
|
-
};
|
|
2843
|
-
}
|
|
2844
|
-
let pn = class {
|
|
2845
|
-
constructor(e, t, n, r, o) {
|
|
2846
|
-
E(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
|
|
2847
|
-
E(this, "zIndex");
|
|
2848
|
-
this._univerInstanceService = e, this._localeService = t, this._commandService = n, this._renderManagerService = r, this._dataValidationModel = o;
|
|
2849
|
-
}
|
|
2850
|
-
_ensureMap(e) {
|
|
2851
|
-
let t = this._dropdownInfoMap.get(e);
|
|
2852
|
-
return t || (t = /* @__PURE__ */ new Map(), this._dropdownInfoMap.set(e, t)), t;
|
|
2853
|
-
}
|
|
2854
|
-
_generateKey(e, t) {
|
|
2855
|
-
return `${e}.${t}`;
|
|
2856
|
-
}
|
|
2857
|
-
_drawDownIcon(e, t, n, r, o, i, a) {
|
|
2858
|
-
const { t: l = re.pd.t, b: s = re.pd.b } = a, d = n - me;
|
|
2859
|
-
let u;
|
|
2860
|
-
switch (i) {
|
|
2861
|
-
case he.MIDDLE:
|
|
2862
|
-
u = (r - yt) / 2;
|
|
2863
|
-
break;
|
|
2864
|
-
case he.BOTTOM:
|
|
2865
|
-
u = r - s - o - ze + (o / 2 - yt / 2);
|
|
2866
|
-
break;
|
|
2867
|
-
default:
|
|
2868
|
-
u = l + ze + (o / 2 - yt / 2);
|
|
2869
|
-
break;
|
|
2870
|
-
}
|
|
2871
|
-
e.save(), e.translateWithPrecision(t.startX + d, t.startY + u), e.fillStyle = "#565656", e.fill(jn), e.restore();
|
|
2872
|
-
}
|
|
2873
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
2874
|
-
drawWith(e, t, n) {
|
|
2875
|
-
var te, j, se, le, de, be;
|
|
2876
|
-
const { primaryWithCoord: r, row: o, col: i, style: a, data: l, subUnitId: s } = t, d = r.isMergedMainCell ? r.mergeInfo : r, u = r.isMergedMainCell ? r.mergeInfo.startRow : o, h = r.isMergedMainCell ? r.mergeInfo.startColumn : i, c = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, u, h);
|
|
2877
|
-
if (!c)
|
|
2878
|
-
return;
|
|
2879
|
-
const m = this._dataValidationModel.getValidator(c.type);
|
|
2880
|
-
if (!m)
|
|
2881
|
-
return;
|
|
2882
|
-
const I = l == null ? void 0 : l.fontRenderExtension, { leftOffset: V = 0, rightOffset: v = 0, topOffset: C = 0, downOffset: f = 0 } = I || {};
|
|
2883
|
-
if (!c || !m || !m || m.id.indexOf(X.LIST) !== 0 || !m.skipDefaultFontRender(c))
|
|
2884
|
-
return;
|
|
2885
|
-
const w = {
|
|
2886
|
-
startX: d.startX + V,
|
|
2887
|
-
endX: d.endX - v,
|
|
2888
|
-
startY: d.startY + C,
|
|
2889
|
-
endY: d.endY - f
|
|
2890
|
-
}, M = w.endX - w.startX, g = w.endY - w.startY, p = this._ensureMap(s), _ = this._generateKey(o, i), T = m.getListWithColorMap(c), A = ie(l), P = `${A != null ? A : ""}`, L = T[P];
|
|
2891
|
-
let { tb: y, vt: O, ht: U, pd: k } = a || {};
|
|
2892
|
-
y = y != null ? y : Se.WRAP, O = O != null ? O : he.BOTTOM, U = U != null ? U : re.ht, k = k != null ? k : re.pd;
|
|
2893
|
-
const x = Le(a).fontCache;
|
|
2894
|
-
if (c.renderMode === ue.ARROW) {
|
|
2895
|
-
const { l: Q = re.pd.l, t: G = re.pd.t, r: ce = re.pd.r, b: ee = re.pd.b } = k, q = M - Q - ce - me - 4, b = new lt(
|
|
2896
|
-
P,
|
|
2897
|
-
x,
|
|
2898
|
-
y === Se.WRAP,
|
|
2899
|
-
q,
|
|
2900
|
-
1 / 0
|
|
2901
|
-
);
|
|
2902
|
-
b.calculate();
|
|
2903
|
-
const $ = b.getTotalWidth(), N = b.getTotalHeight(), { paddingTop: J, paddingLeft: R } = Yn(q, g - G - ee, $, N, O, U, !0);
|
|
2904
|
-
this._drawDownIcon(e, w, M, g, N, O, k), e.save(), e.translateWithPrecision(w.startX + Q, w.startY + G), e.beginPath(), e.rect(0, 0, M - Q - ce, g - G - ee), e.clip(), e.translateWithPrecision(0, J), e.save(), e.translateWithPrecision(R, 0), e.beginPath(), e.rect(0, 0, q, N), e.clip(), On.drawWith(e, {
|
|
2905
|
-
text: P,
|
|
2906
|
-
fontStyle: x,
|
|
2907
|
-
width: q,
|
|
2908
|
-
height: N,
|
|
2909
|
-
color: (te = a == null ? void 0 : a.cl) == null ? void 0 : te.rgb,
|
|
2910
|
-
strokeLine: !!((j = a == null ? void 0 : a.st) != null && j.s),
|
|
2911
|
-
underline: !!((se = a == null ? void 0 : a.ul) != null && se.s),
|
|
2912
|
-
warp: y === Se.WRAP,
|
|
2913
|
-
hAlign: Ee.LEFT
|
|
2914
|
-
}, b), e.restore(), e.restore(), p.set(_, {
|
|
2915
|
-
left: w.endX - me + n.rowHeaderWidth,
|
|
2916
|
-
top: w.startY + G + n.columnHeaderHeight,
|
|
2917
|
-
width: me,
|
|
2918
|
-
height: g - G - ee
|
|
2919
|
-
});
|
|
2920
|
-
} else {
|
|
2921
|
-
e.save(), e.translateWithPrecision(w.startX, w.startY), e.beginPath(), e.rect(0, 0, M, g), e.clip();
|
|
2922
|
-
const Q = M - we * 2 - Xe - me - 4, G = new lt(
|
|
2923
|
-
P,
|
|
2924
|
-
x,
|
|
2925
|
-
y === Se.WRAP,
|
|
2926
|
-
Q,
|
|
2927
|
-
1 / 0
|
|
2928
|
-
);
|
|
2929
|
-
G.calculate();
|
|
2930
|
-
const ce = G.getTotalWidth(), ee = G.getTotalHeight(), q = ee + Gt * 2, b = Math.max(M - we * 2, 1), { paddingTop: $ } = Yn(b, g, ce, q, O, U);
|
|
2931
|
-
e.translateWithPrecision(we, $), Qn.drawWith(e, {
|
|
2932
|
-
width: b,
|
|
2933
|
-
height: q,
|
|
2934
|
-
fill: L || ke,
|
|
2935
|
-
radius: qt
|
|
2936
|
-
}), e.save(), e.translateWithPrecision(Xe, Gt), e.beginPath(), e.rect(0, 0, Q, ee), e.clip(), On.drawWith(e, {
|
|
2937
|
-
text: P,
|
|
2938
|
-
fontStyle: x,
|
|
2939
|
-
width: Q,
|
|
2940
|
-
height: ee,
|
|
2941
|
-
color: (le = a == null ? void 0 : a.cl) == null ? void 0 : le.rgb,
|
|
2942
|
-
strokeLine: !!((de = a == null ? void 0 : a.st) != null && de.s),
|
|
2943
|
-
underline: !!((be = a == null ? void 0 : a.ul) != null && be.s),
|
|
2944
|
-
warp: y === Se.WRAP,
|
|
2945
|
-
hAlign: Ee.LEFT
|
|
2946
|
-
}, G), e.restore(), e.translateWithPrecision(Q + Xe + 4, (ee - yt) / 2), e.fillStyle = Ji, e.fill(jn), e.restore(), p.set(_, {
|
|
2947
|
-
left: w.startX + we + n.rowHeaderWidth,
|
|
2948
|
-
top: w.startY + $ + n.columnHeaderHeight,
|
|
2949
|
-
width: b,
|
|
2950
|
-
height: q
|
|
2951
|
-
});
|
|
2952
|
-
}
|
|
2953
|
-
}
|
|
2954
|
-
calcCellAutoHeight(e) {
|
|
2955
|
-
const { primaryWithCoord: t, style: n, data: r, row: o, col: i } = e, a = t.isMergedMainCell ? t.mergeInfo : t, l = r == null ? void 0 : r.fontRenderExtension, { leftOffset: s = 0, rightOffset: d = 0, topOffset: u = 0, downOffset: h = 0 } = l || {}, c = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, o, i);
|
|
2956
|
-
if (!c || c.renderMode === ue.TEXT)
|
|
2957
|
-
return;
|
|
2958
|
-
const m = {
|
|
2959
|
-
startX: a.startX + s,
|
|
2960
|
-
endX: a.endX - d,
|
|
2961
|
-
startY: a.startY + u,
|
|
2962
|
-
endY: a.endY - h
|
|
2963
|
-
}, I = m.endX - m.startX, V = ie(r), v = `${V != null ? V : ""}`;
|
|
2964
|
-
let { tb: C, pd: f } = n || {};
|
|
2965
|
-
const { t: w = re.pd.t, b: M = re.pd.b } = f != null ? f : {};
|
|
2966
|
-
if (C = C != null ? C : Se.WRAP, c.renderMode === ue.ARROW) {
|
|
2967
|
-
const { l: g = re.pd.l, r: p = re.pd.r } = f != null ? f : {}, _ = I - g - p - me - 4, T = new lt(
|
|
2968
|
-
v,
|
|
2969
|
-
Le(n).fontCache,
|
|
2970
|
-
C === Se.WRAP,
|
|
2971
|
-
_,
|
|
2972
|
-
1 / 0
|
|
2973
|
-
);
|
|
2974
|
-
return T.calculate(), T.getTotalHeight() + w + M + ze * 2;
|
|
2975
|
-
} else {
|
|
2976
|
-
const g = Math.max(I - we * 2 - Xe - me - 4, 10), p = new lt(
|
|
2977
|
-
v,
|
|
2978
|
-
Le(n).fontCache,
|
|
2979
|
-
C === Se.WRAP,
|
|
2980
|
-
g,
|
|
2981
|
-
1 / 0
|
|
2982
|
-
);
|
|
2983
|
-
return p.calculate(), p.getTotalHeight() + ze * 2 + Gt * 2;
|
|
2984
|
-
}
|
|
2985
|
-
}
|
|
2986
|
-
calcCellAutoWidth(e) {
|
|
2987
|
-
const { primaryWithCoord: t, style: n, data: r, row: o, col: i } = e, a = t.isMergedMainCell ? t.mergeInfo : t, l = r == null ? void 0 : r.fontRenderExtension, { leftOffset: s = 0, rightOffset: d = 0, topOffset: u = 0, downOffset: h = 0 } = l || {}, c = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, o, i);
|
|
2988
|
-
if (!c || c.renderMode === ue.TEXT)
|
|
2989
|
-
return;
|
|
2990
|
-
const m = {
|
|
2991
|
-
startX: a.startX + s,
|
|
2992
|
-
endX: a.endX - d,
|
|
2993
|
-
startY: a.startY + u,
|
|
2994
|
-
endY: a.endY - h
|
|
2995
|
-
}, I = m.endX - m.startX, V = ie(r), v = `${V != null ? V : ""}`;
|
|
2996
|
-
let { tb: C, pd: f } = n || {};
|
|
2997
|
-
const { l: w = re.pd.l, r: M = re.pd.r } = f != null ? f : {};
|
|
2998
|
-
C = C != null ? C : Se.WRAP;
|
|
2999
|
-
let g = we * 2 + me;
|
|
3000
|
-
switch (c.renderMode) {
|
|
3001
|
-
case ue.ARROW:
|
|
3002
|
-
g = me + 4 + M + w;
|
|
3003
|
-
break;
|
|
3004
|
-
case ue.CUSTOM:
|
|
3005
|
-
g = me + we * 2 + Xe * 2 + M + w + qt / 2 + 1;
|
|
3006
|
-
break;
|
|
3007
|
-
// default is CUSTOM
|
|
3008
|
-
default:
|
|
3009
|
-
g = me + we * 2 + Xe * 2 + M + w + qt / 2 + 1;
|
|
3010
|
-
}
|
|
3011
|
-
const p = I - g, _ = new lt(
|
|
3012
|
-
v,
|
|
3013
|
-
Le(n).fontCache,
|
|
3014
|
-
C === Se.WRAP,
|
|
3015
|
-
p,
|
|
3016
|
-
1 / 0
|
|
3017
|
-
);
|
|
3018
|
-
return _.calculate(), _.getTotalWidth() + g;
|
|
3019
|
-
}
|
|
3020
|
-
isHit(e, t) {
|
|
3021
|
-
const { subUnitId: n, row: r, col: o } = t, a = this._ensureMap(n).get(this._generateKey(r, o)), l = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, r, o);
|
|
3022
|
-
if (!l || !a || l.renderMode === ue.TEXT)
|
|
3023
|
-
return !1;
|
|
3024
|
-
const { top: s, left: d, width: u, height: h } = a, { x: c, y: m } = e;
|
|
3025
|
-
return c >= d && c <= d + u && m >= s && m <= s + h;
|
|
3026
|
-
}
|
|
3027
|
-
onPointerDown(e, t) {
|
|
3028
|
-
if (t.button === 2)
|
|
3029
|
-
return;
|
|
3030
|
-
const { unitId: n, subUnitId: r, row: o, col: i } = e, a = {
|
|
3031
|
-
unitId: n,
|
|
3032
|
-
subUnitId: r,
|
|
3033
|
-
row: o,
|
|
3034
|
-
column: i
|
|
3035
|
-
};
|
|
3036
|
-
this._commandService.executeCommand(Ft.id, a);
|
|
3037
|
-
}
|
|
3038
|
-
onPointerEnter(e, t) {
|
|
3039
|
-
var n, r;
|
|
3040
|
-
(r = (n = Ge(H.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : n.mainComponent) == null || r.setCursor(qe.POINTER);
|
|
3041
|
-
}
|
|
3042
|
-
onPointerLeave(e, t) {
|
|
3043
|
-
var n, r;
|
|
3044
|
-
(r = (n = Ge(H.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : n.mainComponent) == null || r.setCursor(qe.DEFAULT);
|
|
3045
|
-
}
|
|
3046
|
-
};
|
|
3047
|
-
pn = qi([
|
|
3048
|
-
ct(0, pe),
|
|
3049
|
-
ct(1, D(ge)),
|
|
3050
|
-
ct(2, oe),
|
|
3051
|
-
ct(3, D(xe)),
|
|
3052
|
-
ct(4, D(ae))
|
|
3053
|
-
], pn);
|
|
3054
|
-
class Qi extends Ce {
|
|
3055
|
-
constructor() {
|
|
3056
|
-
super(...arguments);
|
|
3057
|
-
E(this, "id", X.LIST);
|
|
3058
|
-
E(this, "canvasRender", this.injector.createInstance(pn));
|
|
3059
|
-
E(this, "dropdownType", fe.LIST);
|
|
3060
|
-
E(this, "optionsInput", Pt.componentKey);
|
|
3061
|
-
E(this, "formulaInput", _n);
|
|
3062
|
-
}
|
|
3063
|
-
}
|
|
3064
|
-
class ea extends Ce {
|
|
3065
|
-
constructor() {
|
|
3066
|
-
super(...arguments);
|
|
3067
|
-
E(this, "id", X.TEXT_LENGTH);
|
|
3068
|
-
E(this, "formulaInput", Nt);
|
|
3069
|
-
}
|
|
3070
|
-
}
|
|
3071
|
-
class ta extends Ce {
|
|
3072
|
-
constructor() {
|
|
3073
|
-
super(...arguments);
|
|
3074
|
-
E(this, "id", X.WHOLE);
|
|
3075
|
-
E(this, "formulaInput", Nt);
|
|
3076
|
-
}
|
|
3077
|
-
}
|
|
3078
|
-
var na = Object.getOwnPropertyDescriptor, ra = (e, t, n, r) => {
|
|
3079
|
-
for (var o = r > 1 ? void 0 : r ? na(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
3080
|
-
(a = e[i]) && (o = a(o) || o);
|
|
3081
|
-
return o;
|
|
3082
|
-
}, Jt = (e, t) => (n, r) => t(n, r, e);
|
|
3083
|
-
let ot = class extends vn {
|
|
3084
|
-
constructor(e, t, n) {
|
|
3085
|
-
super(), this._injector = e, this._componentManger = t, this._dataValidatorRegistryService = n, this._initComponents(), this._registerValidatorViews();
|
|
3086
|
-
}
|
|
3087
|
-
_initComponents() {
|
|
3088
|
-
[
|
|
3089
|
-
["DataValidationIcon", Dr],
|
|
3090
|
-
[Ot, wi],
|
|
3091
|
-
[Pt.componentKey, Pt],
|
|
3092
|
-
[Lt.componentKey, Lt],
|
|
3093
|
-
...Vi
|
|
3094
|
-
].forEach(([e, t]) => {
|
|
3095
|
-
this.disposeWithMe(this._componentManger.register(
|
|
3096
|
-
e,
|
|
3097
|
-
t
|
|
3098
|
-
));
|
|
3099
|
-
});
|
|
3100
|
-
}
|
|
3101
|
-
_registerValidatorViews() {
|
|
3102
|
-
[
|
|
3103
|
-
Bi,
|
|
3104
|
-
ta,
|
|
3105
|
-
ea,
|
|
3106
|
-
xi,
|
|
3107
|
-
Ui,
|
|
3108
|
-
Qi,
|
|
3109
|
-
Ki,
|
|
3110
|
-
Fi
|
|
3111
|
-
].forEach((e) => {
|
|
3112
|
-
const t = this._injector.createInstance(e), n = this._dataValidatorRegistryService.getValidatorItem(t.id);
|
|
3113
|
-
n && (n.formulaInput = t.formulaInput, n.canvasRender = t.canvasRender, n.dropdownType = t.dropdownType, n.optionsInput = t.optionsInput);
|
|
3114
|
-
});
|
|
3115
|
-
}
|
|
3116
|
-
};
|
|
3117
|
-
ot = ra([
|
|
3118
|
-
Jt(0, D(Ve)),
|
|
3119
|
-
Jt(1, D(In)),
|
|
3120
|
-
Jt(2, D(Te))
|
|
3121
|
-
], ot);
|
|
3122
|
-
var oa = Object.getOwnPropertyDescriptor, ia = (e, t, n, r) => {
|
|
3123
|
-
for (var o = r > 1 ? void 0 : r ? oa(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
3124
|
-
(a = e[i]) && (o = a(o) || o);
|
|
3125
|
-
return o;
|
|
3126
|
-
}, Qt = (e, t) => (n, r) => t(n, r, e), Ze;
|
|
3127
|
-
let Xn = (Ze = class extends qn {
|
|
3128
|
-
constructor(e = Tt, t, n, r) {
|
|
3129
|
-
super(), this._config = e, this._injector = t, this._commandService = n, this._configService = r;
|
|
3130
|
-
const { menu: o, ...i } = Jn(
|
|
3131
|
-
{},
|
|
3132
|
-
Tt,
|
|
3133
|
-
this._config
|
|
3134
|
-
);
|
|
3135
|
-
o && this._configService.setConfig("menu", o, { merge: !0 }), this._configService.setConfig(Vt, i);
|
|
3136
|
-
}
|
|
3137
|
-
onStarting() {
|
|
3138
|
-
[
|
|
3139
|
-
[_e],
|
|
3140
|
-
[$e],
|
|
3141
|
-
[mt],
|
|
3142
|
-
[et],
|
|
3143
|
-
[rt],
|
|
3144
|
-
[nt],
|
|
3145
|
-
[tt],
|
|
3146
|
-
[ot]
|
|
3147
|
-
].forEach((e) => {
|
|
3148
|
-
this._injector.add(e);
|
|
3149
|
-
}), [
|
|
3150
|
-
$t,
|
|
3151
|
-
Ft,
|
|
3152
|
-
Rr,
|
|
3153
|
-
yn,
|
|
3154
|
-
Be,
|
|
3155
|
-
wr
|
|
3156
|
-
].forEach((e) => {
|
|
3157
|
-
this._commandService.registerCommand(e);
|
|
3158
|
-
});
|
|
3159
|
-
}
|
|
3160
|
-
onReady() {
|
|
3161
|
-
this._injector.get(tt), this._injector.get(nt), this._injector.get(xe).registerRenderModule(
|
|
3162
|
-
H.UNIVER_SHEET,
|
|
3163
|
-
[At]
|
|
3164
|
-
);
|
|
3165
|
-
}
|
|
3166
|
-
onRendered() {
|
|
3167
|
-
this._injector.get(ot), this._injector.get(rt);
|
|
3168
|
-
}
|
|
3169
|
-
onSteady() {
|
|
3170
|
-
this._injector.get(et);
|
|
3171
|
-
}
|
|
3172
|
-
}, E(Ze, "pluginName", "SHEET_DATA_VALIDATION_UI_PLUGIN"), E(Ze, "packageName", Dt.name), E(Ze, "version", Dt.version), E(Ze, "type", H.UNIVER_SHEET), Ze);
|
|
3173
|
-
Xn = ia([
|
|
3174
|
-
Qt(1, D(Ve)),
|
|
3175
|
-
Qt(2, oe),
|
|
3176
|
-
Qt(3, gn)
|
|
3177
|
-
], Xn);
|
|
3178
|
-
var aa = Object.defineProperty, sa = Object.getOwnPropertyDescriptor, la = (e, t, n) => t in e ? aa(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, da = (e, t, n, r) => {
|
|
3179
|
-
for (var o = r > 1 ? void 0 : r ? sa(t, n) : t, i = e.length - 1, a; i >= 0; i--)
|
|
3180
|
-
(a = e[i]) && (o = a(o) || o);
|
|
3181
|
-
return o;
|
|
3182
|
-
}, en = (e, t) => (n, r) => t(n, r, e), xt = (e, t, n) => la(e, typeof t != "symbol" ? t + "" : t, n);
|
|
3183
|
-
let it = class extends qn {
|
|
3184
|
-
constructor(e = Tt, t, n, r) {
|
|
3185
|
-
super(), this._config = e, this._injector = t, this._commandService = n, this._configService = r;
|
|
3186
|
-
const { menu: o, ...i } = Jn(
|
|
3187
|
-
{},
|
|
3188
|
-
Tt,
|
|
3189
|
-
this._config
|
|
3190
|
-
);
|
|
3191
|
-
o && this._configService.setConfig("menu", o, { merge: !0 }), this._configService.setConfig(Vt, i);
|
|
3192
|
-
}
|
|
3193
|
-
onStarting() {
|
|
3194
|
-
[
|
|
3195
|
-
[_e],
|
|
3196
|
-
[$e],
|
|
3197
|
-
[mt],
|
|
3198
|
-
[et],
|
|
3199
|
-
[rt],
|
|
3200
|
-
[nt],
|
|
3201
|
-
[tt],
|
|
3202
|
-
[Qe],
|
|
3203
|
-
[ot]
|
|
3204
|
-
].forEach((e) => {
|
|
3205
|
-
this._injector.add(e);
|
|
3206
|
-
}), [
|
|
3207
|
-
$t,
|
|
3208
|
-
Ft,
|
|
3209
|
-
Rr,
|
|
3210
|
-
yn,
|
|
3211
|
-
Be,
|
|
3212
|
-
wr
|
|
3213
|
-
].forEach((e) => {
|
|
3214
|
-
this._commandService.registerCommand(e);
|
|
3215
|
-
});
|
|
3216
|
-
}
|
|
3217
|
-
onReady() {
|
|
3218
|
-
this._injector.get(tt), this._injector.get(nt), this._injector.get(Qe), this._injector.get(mt), this._injector.get(xe).registerRenderModule(
|
|
3219
|
-
H.UNIVER_SHEET,
|
|
3220
|
-
[At]
|
|
3221
|
-
);
|
|
3222
|
-
}
|
|
3223
|
-
onRendered() {
|
|
3224
|
-
this._injector.get(ot), this._injector.get(rt);
|
|
3225
|
-
}
|
|
3226
|
-
onSteady() {
|
|
3227
|
-
this._injector.get(et);
|
|
3228
|
-
}
|
|
3229
|
-
};
|
|
3230
|
-
xt(it, "pluginName", "SHEET_DATA_VALIDATION_UI_PLUGIN");
|
|
3231
|
-
xt(it, "packageName", Dt.name);
|
|
3232
|
-
xt(it, "version", Dt.version);
|
|
3233
|
-
xt(it, "type", H.UNIVER_SHEET);
|
|
3234
|
-
it = da([
|
|
3235
|
-
zr(mo),
|
|
3236
|
-
en(1, D(Ve)),
|
|
3237
|
-
en(2, oe),
|
|
3238
|
-
en(3, gn)
|
|
3239
|
-
], it);
|
|
3240
|
-
export {
|
|
3241
|
-
Ce as BaseSheetDataValidatorView,
|
|
3242
|
-
Xn as UniverSheetsDataValidationMobileUIPlugin,
|
|
3243
|
-
it as UniverSheetsDataValidationUIPlugin
|
|
3244
|
-
};
|
|
8
|
+
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!o,"univer-opacity-50":o}),onClick:r,onMouseEnter:()=>{o||(m(!0),d.current=n.ranges.map(e=>l.addShape({range:e,style:g,primary:null})))},onMouseLeave:()=>{var e;m(!1),(e=d.current)==null||e.forEach(e=>{e&&l.removeShape(e)}),d.current=void 0},children:[q(`div`,{className:`
|
|
9
|
+
univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900
|
|
10
|
+
dark:!univer-text-white
|
|
11
|
+
`,children:u==null?void 0:u.generateRuleName(n)}),q(`div`,{className:`
|
|
12
|
+
univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px]
|
|
13
|
+
dark:!univer-text-gray-300
|
|
14
|
+
`,children:n.ranges.map(e=>mn(e)).join(`,`)}),p?q(`div`,{className:`
|
|
15
|
+
univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-size-5 univer-items-center
|
|
16
|
+
univer-justify-center univer-rounded
|
|
17
|
+
hover:univer-bg-gray-200
|
|
18
|
+
dark:!univer-text-gray-300
|
|
19
|
+
dark:hover:!univer-bg-gray-700
|
|
20
|
+
`,onClick:_,children:q(cn,{})}):null]})};function tr(e){let t=W(V),n=W(m),r=W(f),i=W(g),a=W(Q),o=W(v),[s,c]=K([]),{workbook:l}=e,u=xt(l.activeSheet$,void 0,!0),d=l.getUnitId(),p=u==null?void 0:u.getSheetId();rn(()=>{c(t.getRules(d,p));let e=t.ruleChange$.subscribe(e=>{e.unitId===d&&e.subUnitId===p&&c(t.getRules(d,p))});return()=>{e.unsubscribe()}},[d,p,t]);let h=async()=>{let e=Ze(i),t={unitId:d,subUnitId:p,rule:e};await r.executeCommand(Ne.id,t),a.setActiveRule({unitId:d,subUnitId:p,rule:e})},_=()=>{r.executeCommand(We.id,{unitId:d,subUnitId:p})},y=(e=>{let t=n.getCurrentUnitForType(O.UNIVER_SHEET),r=t.getActiveSheet(),a=t.getUnitId(),o=r.getSheetId();return e.map(e=>Ae(i,a,o,e.ranges)?{...e}:{...e,disable:!0})})(s),b=y==null?void 0:y.some(e=>e.disable);return J(`div`,{className:`univer-pb-4`,children:[y==null?void 0:y.map(e=>{var t;return q(er,{unitId:d,subUnitId:p,onClick:()=>{e.disable||a.setActiveRule({unitId:d,subUnitId:p,rule:e})},rule:e,disable:(t=e.disable)==null?!1:t},e.uid)}),J(`div`,{className:`univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[s.length&&!b?q(Kt,{onClick:_,children:o.t(`dataValidation.panel.removeAll`)}):null,q(Kt,{variant:`primary`,onClick:h,children:o.t(`dataValidation.panel.add`)})]})]})}const nr=()=>{let e=W(Q),t=xt(e.activeRule$,e.activeRule),n=W(m),r=xt(()=>n.getCurrentTypeOfUnit$(O.UNIVER_SHEET),void 0,void 0,[]),i=xt(()=>{var e;return(e=r==null?void 0:r.activeSheet$)==null?kt(null):e},void 0,void 0,[]);return!r||!i?null:t&&(t.subUnitId===i.getSheetId()||t.subUnitId===e.getFocusFormulaEditorActiveRuleSubUnitId())?q($n,{},t.rule.uid):q(tr,{workbook:r})},rr=e=>{let{isTwoFormula:t=!1,value:n,onChange:r,showError:i,validResult:a}=e,o=W(v),s=i?a==null?void 0:a.formula1:``,c=i?a==null?void 0:a.formula2:``;return t?J(_n,{children:[q(G,{error:s,children:q(Xt,{className:`univer-w-full`,placeholder:o.t(`dataValidation.panel.formulaPlaceholder`),value:n==null?void 0:n.formula1,onChange:e=>{r==null||r({...n,formula1:e})}})}),q(`div`,{className:`-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400`,children:o.t(`dataValidation.panel.formulaAnd`)}),q(G,{error:c,children:q(Xt,{className:`univer-w-full`,placeholder:o.t(`dataValidation.panel.formulaPlaceholder`),value:n==null?void 0:n.formula2,onChange:e=>{r==null||r({...n,formula2:e})}})})]}):q(G,{error:s,children:q(Xt,{className:`univer-w-full`,placeholder:o.t(`dataValidation.panel.formulaPlaceholder`),value:n==null?void 0:n.formula1,onChange:e=>{r==null||r({formula1:e})}})})};function ir(e){let{value:t,onChange:n,showError:r,validResult:i}=e,a=W(v),o=r?i==null?void 0:i.formula1:``,s=r?i==null?void 0:i.formula2:``,[c,l]=K(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return J(_n,{children:[q(G,{children:q(qt,{checked:c,onChange:e=>{e?l(!0):(l(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:a.t(`dataValidation.checkbox.tips`)})}),c?q(G,{label:a.t(`dataValidation.checkbox.checked`),error:o,children:q(Xt,{className:`univer-w-full`,placeholder:a.t(`dataValidation.panel.valuePlaceholder`),value:t==null?void 0:t.formula1,onChange:e=>{n==null||n({...t,formula1:e||void 0})}})}):null,c?q(G,{label:a.t(`dataValidation.checkbox.unchecked`),error:s,children:q(Xt,{className:`univer-w-full`,placeholder:a.t(`dataValidation.panel.valuePlaceholder`),value:t==null?void 0:t.formula2,onChange:e=>{n==null||n({...t,formula2:e||void 0})}})}):null]})}function ar(e){var t;let{unitId:n,subUnitId:r,value:i,onChange:a,showError:o,validResult:s}=e,c=o?s==null?void 0:s.formula1:void 0,l=on(null),[u,d]=K(!1);return St(e=>{var t;(t=l.current)!=null&&t.isClickOutSide(e)&&d(!1)}),q(G,{error:c,children:q(hn,{ref:l,className:tn(`
|
|
21
|
+
univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg
|
|
22
|
+
univer-bg-white univer-pt-2 univer-transition-colors
|
|
23
|
+
hover:univer-border-primary-600
|
|
24
|
+
dark:!univer-bg-gray-700 dark:!univer-text-white
|
|
25
|
+
[&>div:first-child]:univer-px-2.5
|
|
26
|
+
[&>div]:univer-h-5 [&>div]:univer-ring-transparent
|
|
27
|
+
`,en),initValue:(t=i==null?void 0:i.formula1)==null?`=`:t,unitId:n,subUnitId:r,isFocus:u,isSupportAcrossSheet:!0,onChange:e=>{let t=(e==null?``:e).trim();t!==(i==null?void 0:i.formula1)&&(a==null||a({...i,formula1:t}))},onFocus:()=>d(!0)})})}const or=[`#FFFFFF`,`#FEE7E7`,`#FEF0E6`,`#EFFBD0`,`#E4F4FE`,`#E8ECFD`,`#F1EAFA`,`#FDE8F3`,`#E5E5E5`,`#FDCECE`,`#FDC49B`,`#DEF6A2`,`#9FDAFF`,`#D0D9FB`,`#E3D5F6`,`#FBD0E8`,`#656565`,`#FE4B4B`,`#FF8C51`,`#8BBB11`,`#0B9EFB`,`#3A60F7`,`#9E6DE3`,`#F248A6`],sr=e=>{let{value:t,onChange:n,disabled:r}=e,[i,a]=K(!1);return q(Yt,{align:`start`,disabled:r,open:i,onOpenChange:a,overlay:q(`div`,{className:`
|
|
28
|
+
univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2
|
|
29
|
+
univer-p-1.5
|
|
30
|
+
`,children:or.map(e=>q(`div`,{className:tn(`univer-box-border univer-size-4 univer-cursor-pointer univer-rounded`,en),style:{background:e},onClick:()=>{n(e),a(!1)}},e))}),children:J(`div`,{className:tn(`
|
|
31
|
+
univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center
|
|
32
|
+
univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5
|
|
33
|
+
univer-transition-colors univer-duration-200
|
|
34
|
+
hover:univer-border-primary-600
|
|
35
|
+
dark:!univer-bg-gray-700 dark:!univer-text-white
|
|
36
|
+
`,en),children:[q(`div`,{className:`univer-box-border univer-size-4 univer-rounded univer-text-base`,style:{background:t}}),q(un,{})]})})},cr=e=>{let{item:t,commonProps:n,className:r}=e,{onItemChange:i,onItemDelete:a}=n;return J(`div`,{className:tn(`univer-flex univer-items-center univer-gap-2`,r),children:[!t.isRef&&q(`div`,{className:tn(`univer-cursor-move`,`draggableHandle`),children:q(fn,{})}),q(sr,{value:t.color,onChange:e=>{i(t.id,t.label,e)}}),q(Xt,{disabled:t.isRef,value:t.label,onChange:e=>{i(t.id,e,t.color)}}),t.isRef?null:q(`div`,{className:`
|
|
37
|
+
univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base
|
|
38
|
+
hover:univer-bg-gray-200
|
|
39
|
+
`,children:q(cn,{onClick:()=>a(t.id)})})]})};function lr(e){let{value:t,onChange:n=()=>{},unitId:r,subUnitId:i,validResult:a,showError:o,ruleId:c}=e,{formula1:l=``,formula2:u=``}=t||{},[d,f]=K(()=>N(l)?`1`:`0`),[p,m]=K(d===`1`?l:`=`),[h,g]=K(d===`1`?l:`=`),_=W(v),y=W(st),b=W(at),x=W(Ve),S=W(Q),[C,w]=K(()=>u.split(`,`)),T=y.getValidatorItem(s.LIST),[E,D]=K([]),[O,k]=K(``),A=o?a==null?void 0:a.formula1:``,ee=xt(an(()=>b.ruleChange$.pipe(Et(16)),[])),j=bt(n);rn(()=>{(async()=>{await new Promise(e=>{setTimeout(()=>e(!0),100)});let e=b.getRuleById(r,i,c);N(e==null?void 0:e.formula1)&&T&&e&&D(await T.getListAsync(e,r,i))})()},[b,ee,T,c,i,r]),rn(()=>{N(l)&&l!==h&&(m(l),g(h))},[h,l]);let[M,ne]=K(()=>{let e=d===`1`?[]:Qe(l),t=u.split(`,`);return e.map((e,n)=>({label:e,color:t[n]||`#ECECEC`,isRef:!1,id:te(4)}))}),P=(e,t,n)=>{let r=M.find(t=>t.id===e);r&&(r.label=t,r.color=n,ne([...M]))},F=e=>{let t=M.findIndex(t=>t.id===e);t!==-1&&(M.splice(t,1),ne([...M]))},I=u.split(`,`),re=an(()=>E.map((e,t)=>({label:e,color:I[t]||`#ECECEC`,id:`${t}`,isRef:!0})),[I,E]),ie=(e,t,n)=>{let r=[...C];r[+e]=n,w(r),j({formula1:l,formula2:r.join(`,`)})},ae=()=>{ne([...M,{label:``,color:`#ECECEC`,isRef:!1,id:te(4)}])};rn(()=>{if(d===`1`)return;let e=new Set,t=[];M.map(e=>({labelList:e.label.split(`,`),item:e})).forEach(({item:n,labelList:r})=>{r.forEach(r=>{e.has(r)||(e.add(r),t.push({label:r,color:n.color}))})}),j({formula1:rt(t.map(e=>e.label)),formula2:t.map(e=>e.color===`#ECECEC`?``:e.color).join(`,`)})},[M,j,d,h,C]);let L=bt(async e=>{if(!N(e)){j==null||j({formula1:``,formula2:u});return}x.getFormulaRefCheck(e)?(j==null||j({formula1:N(e)?e:``,formula2:u}),k(``)):(j==null||j({formula1:``,formula2:u}),m(`=`),k(_.t(`dataValidation.validFail.formulaError`)))}),oe=on(null),[R,z]=K(!1);return St(e=>{var t;(t=oe.current)!=null&&t.isClickOutSide(e)&&z(!1)}),rn(()=>{R?S.setFocusFormulaEditorActiveRuleSubUnitId(i):S.setFocusFormulaEditorActiveRuleSubUnitId(null)},[R,i,S]),J(_n,{children:[q(G,{label:_.t(`dataValidation.list.options`),children:J(Qt,{value:d,onChange:e=>{f(e),m(h),e===`1`&&j({formula1:h===`=`?``:h,formula2:C.join(`,`)})},children:[q(Zt,{value:`0`,children:_.t(`dataValidation.list.customOptions`)}),q(Zt,{value:`1`,children:_.t(`dataValidation.list.refOptions`)})]})}),d===`1`?J(G,{error:A||O||void 0,children:[q(hn,{ref:oe,className:tn(`
|
|
40
|
+
univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center
|
|
41
|
+
univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors
|
|
42
|
+
hover:univer-border-primary-600
|
|
43
|
+
dark:!univer-bg-gray-700 dark:!univer-text-white
|
|
44
|
+
[&>div:first-child]:univer-px-2.5
|
|
45
|
+
[&>div]:univer-h-5 [&>div]:univer-ring-transparent
|
|
46
|
+
`,en),initValue:p,unitId:r,subUnitId:i,isFocus:R,isSupportAcrossSheet:!0,onFocus:()=>z(!0),onChange:(e=``)=>{let t=(e==null?``:e).trim();g(t),L(t)}}),re.length>0&&q(`div`,{className:`univer-mt-3`,children:re.map(e=>q(cr,{className:`univer-mb-3`,item:e,commonProps:{onItemChange:ie}},e.id))})]}):q(G,{error:A,children:J(`div`,{className:`-univer-mt-3`,children:[q(Jt,{list:M,onListChange:ne,rowHeight:28,margin:[0,12],draggableHandle:`.draggableHandle`,itemRender:e=>q(cr,{item:e,commonProps:{onItemChange:P,onItemDelete:F}},e.id),idKey:`id`}),J(`a`,{className:`
|
|
47
|
+
univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row
|
|
48
|
+
univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm
|
|
49
|
+
hover:univer-bg-primary-50
|
|
50
|
+
dark:hover:!univer-bg-gray-800
|
|
51
|
+
`,onClick:ae,children:[q(ln,{className:`univer-mr-1`}),_.t(`dataValidation.list.add`)]})]})})]})}const ur=[[Re,ar],[Pe,rr],[Ue,lr],[Le,ir]];function dr(e){var t;let{value:n,onChange:r}=e,i=W(v);return q(G,{label:i.t(`dataValidation.renderMode.label`),children:J(Qt,{value:`${(t=n.renderMode)==null?a.CUSTOM:t}`,onChange:e=>r({...n,renderMode:+e}),children:[q(Zt,{value:`${a.CUSTOM}`,children:i.t(`dataValidation.renderMode.chip`)}),q(Zt,{value:`${a.ARROW}`,children:i.t(`dataValidation.renderMode.arrow`)}),q(Zt,{value:`${a.TEXT}`,children:i.t(`dataValidation.renderMode.text`)})]})})}dr.componentKey=`LIST_RENDER_MODE_OPTION_INPUT`;function fr(e){var t;let{value:n,onChange:r}=e,i=W(v);return q(G,{children:q(qt,{checked:(t=n.bizInfo)==null?void 0:t.showTime,onChange:e=>{r({...n,bizInfo:{...n.bizInfo,showTime:e}})},children:i.t(`dataValidation.showTime.label`)})})}fr.componentKey=`DATE_SHOW_TIME_OPTION`;let pr=class{_calc(e,t){var n,r,i;let{vt:a,ht:o}=t||{},s=e.endX-e.startX-12,c=e.endY-e.startY,l=((n=t==null?void 0:t.fs)==null?10:n)*1.6,u=0,f=0;switch(a){case k.TOP:f=0;break;case k.BOTTOM:f=0+(c-l);break;default:f=0+(c-l)/2;break}switch(o){case d.LEFT:u=6;break;case d.RIGHT:u=6+(s-l);break;default:u=6+(s-l)/2;break}return{left:e.startX+u,top:e.startY+f,width:((r=t==null?void 0:t.fs)==null?10:r)*1.6,height:((i=t==null?void 0:t.fs)==null?10:i)*1.6}}constructor(e,t,n,r,i,a){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=r,this._renderManagerService=i,this._dataValidationModel=a}calcCellAutoHeight(e){var t;let{style:n}=e;return((t=n==null?void 0:n.fs)==null?10:t)*1.6}calcCellAutoWidth(e){var t;let{style:n}=e;return((t=n==null?void 0:n.fs)==null?10:t)*1.6}async _parseFormula(e,t,n){var r,i,a;let{formula1:o=Fe,formula2:s=Ie}=e,c=await this._formulaService.getRuleFormulaResult(t,n,e.uid),l=tt(c==null||(r=c[0])==null||(r=r.result)==null||(r=r[0])==null?void 0:r[0]),u=tt(c==null||(i=c[1])==null||(i=i.result)==null||(i=i[0])==null?void 0:i[0]),d=nt(String(l))&&nt(String(u));return{formula1:N(o)?tt(c==null||(a=c[0])==null||(a=a.result)==null||(a=a[0])==null?void 0:a[0]):o,formula2:N(s)?u:s,isFormulaValid:d}}drawWith(e,t){var n,r,i,a;let{style:o,primaryWithCoord:s,unitId:c,subUnitId:l,worksheet:u,row:d,col:f}=t,p=s.isMergedMainCell?s.mergeInfo:s,m=H(u.getCellRaw(d,f)),h=this._dataValidationModel.getRuleByLocation(c,l,d,f);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g||!((n=g.skipDefaultFontRender)!=null&&n.call(g,h,m,{unitId:c,subUnitId:l,row:d,column:f})))return;let{formula1:_}=g.parseFormulaSync(h,c,l),v=this._calc(p,o),{a:y,d:b}=e.getTransform(),x=fe(v.left,y),S=fe(v.top,b),C=de.create().composeMatrix({left:x,top:S,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),w=p.endX-p.startX,T=p.endY-p.startY;e.save(),e.beginPath(),e.rect(p.startX,p.startY,w,T),e.clip();let E=C.getMatrix();e.transform(E[0],E[1],E[2],E[3],E[4],E[5]);let D=((r=o==null?void 0:o.fs)==null?10:r)*1.6,O=String(m)===String(_),k=this._themeService.getColorFromTheme(`primary.600`);oe.drawWith(e,{checked:O,width:D,height:D,fill:(i=o==null||(a=o.cl)==null?void 0:a.rgb)==null?k:i}),e.restore()}isHit(e,t){let n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,r=this._calc(n,t.style),i=r.top,a=r.top+r.height,o=r.left,s=r.left+r.width,{x:c,y:l}=e;return c<=s&&c>=o&&l<=a&&l>=i}async onPointerDown(e,t){var n;if(t.button===2)return;let{primaryWithCoord:r,unitId:i,subUnitId:a,worksheet:o,row:s,col:c}=e,l=H(o.getCellRaw(s,c)),u=this._dataValidationModel.getRuleByLocation(i,a,s,c);if(!u)return;let d=this._dataValidationModel.getValidator(u.type);if(!d||!((n=d.skipDefaultFontRender)!=null&&n.call(d,u,l,{unitId:i,subUnitId:a,row:s,column:c})))return;let{formula1:f,formula2:p}=await this._parseFormula(u,i,a),m={range:{startColumn:r.actualColumn,endColumn:r.actualColumn,startRow:r.actualRow,endRow:r.actualRow},value:{v:String(l)===it(String(f))?p:f,p:null}};this._commandService.executeCommand(xe.id,m)}onPointerEnter(e,t){var n;(n=pe(O.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null||n.setCursor(L.POINTER)}onPointerLeave(e,t){var n;(n=pe(O.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null||n.setCursor(L.DEFAULT)}};pr=Z([X(0,f),X(1,m),X(2,h(He)),X(3,h(E)),X(4,h(B)),X(5,h(V))],pr);let $=class{constructor(e){this.injector=e,Y(this,`canvasRender`,null),Y(this,`dropdownType`,void 0),Y(this,`optionsInput`,void 0),Y(this,`formulaInput`,Ue)}};$=Z([X(0,h(g))],$);var mr=class extends ${constructor(...e){super(...e),Y(this,`id`,s.CHECKBOX),Y(this,`canvasRender`,this.injector.createInstance(pr)),Y(this,`formulaInput`,Le)}},hr=class extends ${constructor(...e){super(...e),Y(this,`id`,s.CUSTOM),Y(this,`formulaInput`,Re)}},gr=class extends ${constructor(...e){super(...e),Y(this,`id`,s.DATE),Y(this,`formulaInput`,`data-validation.formula-input`),Y(this,`optionsInput`,fr.componentKey),Y(this,`dropdownType`,U.DATE)}},_r=class extends ${constructor(...e){super(...e),Y(this,`id`,s.DECIMAL),Y(this,`formulaInput`,Pe)}};function vr(e,t){let n=se.getTextSize(e,t),r=n.width+8,{ba:i,bd:a}=n;return{width:r,height:i+a+0,ba:i}}function yr(e,t,n,r){let i=n-26,a=r-12,o=e.map(e=>({layout:vr(e,t),text:e})),s,c=[];o.forEach(e=>{let{layout:t}=e,{width:n,height:r}=t;!s||s.width+n+4>i?(s={width:n,height:r,items:[{...e,left:0}]},c.push(s)):(s.items.push({...e,left:s.width+4}),s.width=s.width+n+4)});let l=0,u=0;return c.forEach((e,t)=>{u=Math.max(u,e.width),t===c.length-1?l+=e.height:l+=e.height+4}),{lines:c,totalHeight:l,contentWidth:i,contentHeight:a,cellAutoHeight:l+12,calcAutoWidth:u+26}}var br=class extends le{static drawWith(e,t){let{fontString:n,info:r,fill:i,color:a}=t,{layout:o,text:s}=r;e.save(),ce.drawWith(e,{width:o.width,height:o.height,radius:8,fill:i||`#ECECEC`}),e.translateWithPrecision(4,o.ba),e.font=n,e.fillStyle=a,e.fillText(s,0,0),e.restore()}};const xr=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`);let Sr=class{constructor(e,t,n,r){this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r,Y(this,`zIndex`,void 0),Y(this,`_dropdownInfoMap`,new Map)}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,r,i){let a=n-14+4,o=4;switch(i){case k.MIDDLE:o=(r-14)/2+4;break;case k.BOTTOM:o=r-14+4;break;default:break}e.save(),e.translateWithPrecision(t.startX+a,t.startY+o),e.fillStyle=`#565656`,e.fill(xr),e.restore()}drawWith(e,t,n,r){var i,a;let{primaryWithCoord:o,row:s,col:c,style:l,data:u,subUnitId:f}=t,p=o.isMergedMainCell?o.mergeInfo:o,{leftOffset:m=0,rightOffset:h=0,topOffset:g=0,downOffset:_=0}=(u==null?void 0:u.fontRenderExtension)||{},v=this._ensureMap(f),y=this._generateKey(s,c),b=o.isMergedMainCell?o.mergeInfo.startRow:s,x=o.isMergedMainCell?o.mergeInfo.startColumn:c,S=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,b,x);if(!S)return;let C=this._dataValidationModel.getValidator(S.type);if(!C)return;let w={startX:p.startX+m,endX:p.endX-h,startY:p.startY+g,endY:p.endY-_},T=w.endX-w.startX,E=w.endY-w.startY,{cl:D}=l||{},O=(i=typeof D==`object`?D==null?void 0:D.rgb:D)==null?`#000`:i,A=me(l==null?void 0:l),{vt:ee,ht:j}=l||{},M=ee==null?k.MIDDLE:ee,te=(a=H(u))==null?``:a,N=C.parseCellValue(te),ne=C.getListWithColorMap(S),P=yr(N,A,T,E);this._drawDownIcon(e,w,T,E,M),e.save(),e.translateWithPrecision(w.startX,w.startY),e.beginPath(),e.rect(0,0,T-14,E),e.clip(),e.translateWithPrecision(6,6);let F=0;switch(M){case k.MIDDLE:F=(P.contentHeight-P.totalHeight)/2;break;case k.BOTTOM:F=P.contentHeight-P.totalHeight;break;default:break}e.translateWithPrecision(0,F),P.lines.forEach((t,n)=>{e.save();let{width:r,height:i,items:a}=t,o=0;switch(j){case d.RIGHT:o=P.contentWidth-r;break;case d.CENTER:o=(P.contentWidth-r)/2;break;default:break}e.translate(o,n*(i+4)),a.forEach(t=>{e.save(),e.translateWithPrecision(t.left,0),br.drawWith(e,{...A,info:t,color:O,fill:ne[t.text]}),e.restore()}),e.restore()}),e.restore(),v.set(y,{left:w.startX,top:w.startY,width:P.contentWidth+6+14,height:P.contentHeight+12})}calcCellAutoHeight(e){var t;let{primaryWithCoord:n,style:r,data:i,row:a,col:o}=e,{leftOffset:s=0,rightOffset:c=0,topOffset:l=0,downOffset:u=0}=(i==null?void 0:i.fontRenderExtension)||{},d=n.isMergedMainCell?n.mergeInfo:n,f={startX:d.startX+s,endX:d.endX-c,startY:d.startY+l,endY:d.endY-u},p=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,o);if(!p)return;let m=this._dataValidationModel.getValidator(p.type);if(!m)return;let h=f.endX-f.startX,g=f.endY-f.startY,_=(t=H(i))==null?``:t;return yr(m.parseCellValue(_),me(r==null?void 0:r),h,g).cellAutoHeight}calcCellAutoWidth(e){var t;let{primaryWithCoord:n,style:r,data:i,row:a,col:o}=e,{leftOffset:s=0,rightOffset:c=0,topOffset:l=0,downOffset:u=0}=(i==null?void 0:i.fontRenderExtension)||{},d=n.isMergedMainCell?n.mergeInfo:n,f={startX:d.startX+s,endX:d.endX-c,startY:d.startY+l,endY:d.endY-u},p=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,o);if(!p)return;let m=this._dataValidationModel.getValidator(p.type);if(!m)return;let h=f.endX-f.startX,g=f.endY-f.startY,_=(t=H(i))==null?``:t;return yr(m.parseCellValue(_),me(r==null?void 0:r),h,g).calcAutoWidth}isHit(e,t){let{primaryWithCoord:n}=t,{endX:r}=n.isMergedMainCell?n.mergeInfo:n,{x:i}=e;return i>=r-14&&i<=r}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(Nn.id,o)}onPointerEnter(e,t){var n;return(n=pe(O.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null?void 0:n.setCursor(L.POINTER)}onPointerLeave(e,t){var n;return(n=pe(O.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null?void 0:n.setCursor(L.DEFAULT)}};Sr=Z([X(0,f),X(1,m),X(2,h(B)),X(3,h(V))],Sr);var Cr=class extends ${constructor(...e){super(...e),Y(this,`id`,s.LIST_MULTIPLE),Y(this,`canvasRender`,this.injector.createInstance(Sr)),Y(this,`dropdownType`,U.MULTIPLE_LIST)}};const wr=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`);function Tr(e,t,n,r,i,a,o=!0){let s=0,c=o?3:0;switch(i){case k.BOTTOM:s=t-r-c;break;case k.MIDDLE:s=(t-r)/2;break;default:s=c;break}s=Math.max(3,s);let l=0;switch(a){case d.CENTER:l=(e-n)/2;break;case d.RIGHT:l=e-n;break;default:break}return l=Math.max(6,l),{paddingLeft:l,paddingTop:s}}let Er=class{constructor(e,t,n,r,i){this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=i,Y(this,`_dropdownInfoMap`,new Map),Y(this,`zIndex`,void 0)}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,i,a,o,s){let{t:c=r.pd.t,b:l=r.pd.b}=s,u=n-14,d;switch(o){case k.MIDDLE:d=(i-4)/2;break;case k.BOTTOM:d=i-l-a-3+(a/2-4/2);break;default:d=c+3+(a/2-4/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+d),e.fillStyle=`#565656`,e.fill(wr),e.restore()}drawWith(e,t,n){var i,o,c,l;let{primaryWithCoord:u,row:f,col:p,style:m,data:h,subUnitId:g}=t,_=u.isMergedMainCell?u.mergeInfo:u,v=u.isMergedMainCell?u.mergeInfo.startRow:f,y=u.isMergedMainCell?u.mergeInfo.startColumn:p,b=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,v,y);if(!b)return;let x=this._dataValidationModel.getValidator(b.type);if(!x)return;let{leftOffset:S=0,rightOffset:C=0,topOffset:w=0,downOffset:T=0}=(h==null?void 0:h.fontRenderExtension)||{};if(!b||!x||!x||x.id.indexOf(s.LIST)!==0||!x.skipDefaultFontRender(b))return;let E={startX:_.startX+S,endX:_.endX-C,startY:_.startY+w,endY:_.endY-T},D=E.endX-E.startX,O=E.endY-E.startY,ee=this._ensureMap(g),j=this._generateKey(f,p),M=x.getListWithColorMap(b),te=H(h),N=`${te==null?``:te}`,ne=M[N],{tb:P,vt:F,ht:I,pd:re}=m||{};P=(i=P)==null?A.WRAP:i,F=(o=F)==null?k.BOTTOM:o,I=(c=I)==null?r.ht:c,re=(l=re)==null?r.pd:l;let ie=me(m).fontCache;if(b.renderMode===a.ARROW){var ae,L,oe;let{l:t=r.pd.l,t:i=r.pd.t,r:a=r.pd.r,b:o=r.pd.b}=re,s=D-t-a-14-4,c=new z(N,ie,P===A.WRAP,s,1/0);c.calculate();let l=c.getTotalWidth(),u=c.getTotalHeight(),{paddingTop:f,paddingLeft:p}=Tr(s,O-i-o,l,u,F,I,!0);this._drawDownIcon(e,E,D,O,u,F,re),e.save(),e.translateWithPrecision(E.startX+t,E.startY+i),e.beginPath(),e.rect(0,0,D-t-a,O-i-o),e.clip(),e.translateWithPrecision(0,f),e.save(),e.translateWithPrecision(p,0),e.beginPath(),e.rect(0,0,s,u),e.clip(),ue.drawWith(e,{text:N,fontStyle:ie,width:s,height:u,color:m==null||(ae=m.cl)==null?void 0:ae.rgb,strokeLine:!!(!(m==null||(L=m.st)==null)&&L.s),underline:!!(!(m==null||(oe=m.ul)==null)&&oe.s),warp:P===A.WRAP,hAlign:d.LEFT},c),e.restore(),e.restore(),ee.set(j,{left:E.endX-14+n.rowHeaderWidth,top:E.startY+i+n.columnHeaderHeight,width:14,height:O-i-o})}else{var R,se,B;e.save(),e.translateWithPrecision(E.startX,E.startY),e.beginPath(),e.rect(0,0,D,O),e.clip();let t=D-12-4-14-4,r=new z(N,ie,P===A.WRAP,t,1/0);r.calculate();let i=r.getTotalWidth(),a=r.getTotalHeight(),o=a+2,s=Math.max(D-12,1),{paddingTop:c}=Tr(s,O,i,o,F,I);e.translateWithPrecision(6,c),ce.drawWith(e,{width:s,height:o,fill:ne||`#ECECEC`,radius:8}),e.save(),e.translateWithPrecision(4,1),e.beginPath(),e.rect(0,0,t,a),e.clip(),ue.drawWith(e,{text:N,fontStyle:ie,width:t,height:a,color:m==null||(R=m.cl)==null?void 0:R.rgb,strokeLine:!!(!(m==null||(se=m.st)==null)&&se.s),underline:!!(!(m==null||(B=m.ul)==null)&&B.s),warp:P===A.WRAP,hAlign:d.LEFT},r),e.restore(),e.translateWithPrecision(t+4+4,(a-4)/2),e.fillStyle=`#565656`,e.fill(wr),e.restore(),ee.set(j,{left:E.startX+6+n.rowHeaderWidth,top:E.startY+c+n.columnHeaderHeight,width:s,height:o})}}calcCellAutoHeight(e){var t;let{primaryWithCoord:n,style:i,data:o,row:s,col:c}=e,l=n.isMergedMainCell?n.mergeInfo:n,{leftOffset:u=0,rightOffset:d=0,topOffset:f=0,downOffset:p=0}=(o==null?void 0:o.fontRenderExtension)||{},m=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,s,c);if(!m||m.renderMode===a.TEXT)return;let h={startX:l.startX+u,endX:l.endX-d,startY:l.startY+f,endY:l.endY-p},g=h.endX-h.startX,_=H(o),v=`${_==null?``:_}`,{tb:y,pd:b}=i||{},{t:x=r.pd.t,b:S=r.pd.b}=b==null?{}:b;if(y=(t=y)==null?A.WRAP:t,m.renderMode===a.ARROW){let{l:e=r.pd.l,r:t=r.pd.r}=b==null?{}:b,n=g-e-t-14-4,a=new z(v,me(i).fontCache,y===A.WRAP,n,1/0);return a.calculate(),a.getTotalHeight()+x+S+6}else{let e=Math.max(g-12-4-14-4,10),t=new z(v,me(i).fontCache,y===A.WRAP,e,1/0);return t.calculate(),t.getTotalHeight()+6+2}}calcCellAutoWidth(e){var t;let{primaryWithCoord:n,style:i,data:o,row:s,col:c}=e,l=n.isMergedMainCell?n.mergeInfo:n,{leftOffset:u=0,rightOffset:d=0,topOffset:f=0,downOffset:p=0}=(o==null?void 0:o.fontRenderExtension)||{},m=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,s,c);if(!m||m.renderMode===a.TEXT)return;let h={startX:l.startX+u,endX:l.endX-d,startY:l.startY+f,endY:l.endY-p},g=h.endX-h.startX,_=H(o),v=`${_==null?``:_}`,{tb:y,pd:b}=i||{},{l:x=r.pd.l,r:S=r.pd.r}=b==null?{}:b;y=(t=y)==null?A.WRAP:t;let C=26;switch(m.renderMode){case a.ARROW:C=18+S+x;break;case a.CUSTOM:C=34+S+x+8/2+1;break;default:C=34+S+x+8/2+1}let w=g-C,T=new z(v,me(i).fontCache,y===A.WRAP,w,1/0);return T.calculate(),T.getTotalWidth()+C}isHit(e,t){let{subUnitId:n,row:r,col:i}=t,o=this._ensureMap(n).get(this._generateKey(r,i)),s=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,i);if(!s||!o||s.renderMode===a.TEXT)return!1;let{top:c,left:l,width:u,height:d}=o,{x:f,y:p}=e;return f>=l&&f<=l+u&&p>=c&&p<=c+d}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(Nn.id,o)}onPointerEnter(e,t){var n;(n=pe(O.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null||n.setCursor(L.POINTER)}onPointerLeave(e,t){var n;(n=pe(O.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null||n.setCursor(L.DEFAULT)}};Er=Z([X(0,m),X(1,h(v)),X(2,f),X(3,h(B)),X(4,h(V))],Er);var Dr=class extends ${constructor(...e){super(...e),Y(this,`id`,s.LIST),Y(this,`canvasRender`,this.injector.createInstance(Er)),Y(this,`dropdownType`,U.LIST),Y(this,`optionsInput`,dr.componentKey),Y(this,`formulaInput`,Ue)}},Or=class extends ${constructor(...e){super(...e),Y(this,`id`,s.TEXT_LENGTH),Y(this,`formulaInput`,Pe)}},kr=class extends ${constructor(...e){super(...e),Y(this,`id`,s.WHOLE),Y(this,`formulaInput`,Pe)}};let Ar=class extends T{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[`DataValidationIcon`,sn],[kn,nr],[dr.componentKey,dr],[fr.componentKey,fr],...ur].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[_r,kr,Or,gr,mr,Dr,Cr,hr].forEach(e=>{let t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Ar=Z([X(0,h(g)),X(1,h(dt)),X(2,h(st))],Ar);let jr=class extends x{constructor(e=wn,t,n,r){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=r;let{menu:i,...a}=P({},wn,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(Cn,a)}onStarting(){[[Q],[On],[Ln],[Rn],[qn],[Bn],[zn],[Ar]].forEach(e=>{this._injector.add(e)}),[Fn,Nn,Pn,jn,An,Mn].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(zn),this._injector.get(Bn),this._injector.get(B).registerRenderModule(O.UNIVER_SHEET,[Yn])}onRendered(){this._injector.get(Ar),this._injector.get(qn)}onSteady(){this._injector.get(Rn)}};Y(jr,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),Y(jr,`packageName`,vn),Y(jr,`version`,yn),Y(jr,`type`,O.UNIVER_SHEET),jr=Z([X(1,h(g)),X(2,f),X(3,p)],jr);let Mr=class extends x{constructor(e=wn,t,n,r){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=r;let{menu:i,...a}=P({},wn,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(Cn,a)}onStarting(){[[Q],[On],[Ln],[Rn],[qn],[Bn],[zn],[Tn],[Ar]].forEach(e=>{this._injector.add(e)}),[Fn,Nn,Pn,jn,An,Mn].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(zn),this._injector.get(Bn),this._injector.get(Tn),this._injector.get(Ln),this._injector.get(B).registerRenderModule(O.UNIVER_SHEET,[Yn])}onRendered(){this._injector.get(Ar),this._injector.get(qn)}onSteady(){this._injector.get(Rn)}};Y(Mr,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),Y(Mr,`packageName`,vn),Y(Mr,`version`,yn),Y(Mr,`type`,O.UNIVER_SHEET),Mr=Z([c(qe),X(1,h(g)),X(2,f),X(3,p)],Mr);export{$ as BaseSheetDataValidatorView,jr as UniverSheetsDataValidationMobileUIPlugin,Mr as UniverSheetsDataValidationUIPlugin};
|