@univerjs/sheets-data-validation-ui 0.16.1 → 0.17.0-insiders.20260318-d69dc16

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