@univerjs/sheets-numfmt-ui 0.5.4 → 0.5.5-experimental.20250123-34738ff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -9
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +739 -744
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/lib/index.css +1 -1
- package/lib/types/controllers/numfmt.controller.d.ts +4 -1
- package/lib/types/views/components/custom-format/index.d.ts +1 -2
- package/lib/types/views/components/more-numfmt-type/MoreNumfmtType.d.ts +17 -3
- package/lib/umd/index.js +1 -9
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +14 -14
- package/LICENSE +0 -176
- package/lib/types/controllers/__tests__/cell-content.controller.spec.d.ts +0 -16
- package/lib/types/controllers/__tests__/editor.controller.spec.d.ts +0 -16
- package/lib/types/controllers/__tests__/test.util.d.ts +0 -15
package/lib/es/index.js
CHANGED
|
@@ -1,61 +1,64 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key2] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 != "symbol" ? key2 + "" : key2, value);
|
|
5
|
+
import { Inject, LocaleService, Disposable, isRealNum, CommandType, ILocalStorageService, useDependency, numfmt, UniverInstanceType, CellValueType, Range, toDisposable, DisposableCollection, InterceptorEffectEnum, ThemeService, IUniverInstanceService, ICommandService, Injector, Optional, DependentOn, Plugin, merge as merge$1, registerDependencies, touchDependencies, IConfigService } from "@univerjs/core";
|
|
6
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
7
|
+
import { currencySymbols, getDecimalFromPattern, getCurrencyType, setPatternDecimal, getCurrencyFormatOptions, isPatternEqualWithoutDecimal, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, getDateFormatOptions, getNumberFormatOptions, isPatternHasDecimal, getPatternType, SetNumfmtCommand, getPatternPreviewIgnoreGeneral, SheetsNumfmtCellContentController, MenuCurrencyService, countryCurrencyMap, SetCurrencyCommand, AddDecimalCommand, SubtractDecimalCommand, SetPercentCommand, getPatternPreview, UniverSheetsNumfmtPlugin } from "@univerjs/sheets-numfmt";
|
|
8
|
+
import { HoverManagerService, CellAlertManagerService, CellAlertType, SheetSkeletonManagerService, IEditorBridgeService, getCurrentRangeDisable$, deriveStateFromActiveSheet$, UniverSheetsUIPlugin } from "@univerjs/sheets-ui";
|
|
9
|
+
import { IZenZoneService, ComponentManager, ISidebarService, MenuItemType, getMenuHiddenObservable, ILayoutService, RibbonStartGroup, IMenuManagerService, UI_PLUGIN_CONFIG_KEY } from "@univerjs/ui";
|
|
10
|
+
import { FormulaDataModel } from "@univerjs/engine-formula";
|
|
11
|
+
import { DEFAULT_TEXT_FORMAT } from "@univerjs/engine-numfmt";
|
|
12
|
+
import { INumfmtService, INTERCEPTOR_POINT, RemoveNumfmtMutation, SetNumfmtMutation, SheetInterceptorService, SheetsSelectionsService, BEFORE_CELL_EDIT, AFTER_CELL_EDIT, SetRangeValuesCommand, transformCellsToRange, factorySetNumfmtUndoMutation, factoryRemoveNumfmtUndoMutation, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, RangeProtectionPermissionEditPoint } from "@univerjs/sheets";
|
|
13
|
+
import { debounceTime, merge, Observable, combineLatest } from "rxjs";
|
|
14
|
+
import { map, switchMap, tap, debounceTime as debounceTime$1 } from "rxjs/operators";
|
|
15
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
16
|
+
import { createContext, useState, useEffect, useRef, useContext, useMemo, forwardRef, createElement } from "react";
|
|
17
|
+
import { InputNumber, Select, SelectList, Input, Button } from "@univerjs/design";
|
|
18
|
+
const defaultPluginConfig = {};
|
|
19
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
20
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
21
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
22
|
+
return kind && result && __defProp$5(target, key2, result), result;
|
|
23
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$5");
|
|
24
|
+
const ALERT_KEY = "SHEET_NUMFMT_ALERT";
|
|
25
|
+
var _a;
|
|
26
|
+
let NumfmtAlertRenderController = (_a = class extends Disposable {
|
|
27
|
+
constructor(_context, _hoverManagerService, _cellAlertManagerService, _localeService, _formulaDataModel, _zenZoneService, _numfmtService) {
|
|
28
|
+
super(), this._context = _context, this._hoverManagerService = _hoverManagerService, this._cellAlertManagerService = _cellAlertManagerService, this._localeService = _localeService, this._formulaDataModel = _formulaDataModel, this._zenZoneService = _zenZoneService, this._numfmtService = _numfmtService, this._init();
|
|
26
29
|
}
|
|
27
30
|
_init() {
|
|
28
31
|
this._initCellAlertPopup(), this._initZenService();
|
|
29
32
|
}
|
|
30
33
|
_initCellAlertPopup() {
|
|
31
|
-
this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(
|
|
32
|
-
var
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
36
|
-
const
|
|
37
|
-
let
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
41
|
-
|
|
34
|
+
this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((cellPos) => {
|
|
35
|
+
var _a7;
|
|
36
|
+
if (cellPos) {
|
|
37
|
+
const location = cellPos.location, workbook = this._context.unit, worksheet = workbook.getActiveSheet();
|
|
38
|
+
if (!worksheet) return;
|
|
39
|
+
const unitId = location.unitId, sheetId = location.subUnitId;
|
|
40
|
+
let numfmtValue;
|
|
41
|
+
const cellData = worksheet.getCell(location.row, location.col);
|
|
42
|
+
if (cellData != null && cellData.s) {
|
|
43
|
+
const style = workbook.getStyles().get(cellData.s);
|
|
44
|
+
style != null && style.n && (numfmtValue = style.n);
|
|
42
45
|
}
|
|
43
|
-
if (
|
|
46
|
+
if (numfmtValue || (numfmtValue = this._numfmtService.getValue(unitId, sheetId, location.row, location.col)), !numfmtValue) {
|
|
44
47
|
this._hideAlert();
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
+
if (numfmtValue.pattern === DEFAULT_TEXT_FORMAT && (cellData != null && cellData.v) && isRealNum(cellData.v)) {
|
|
51
|
+
const currentAlert = this._cellAlertManagerService.currentAlert.get(ALERT_KEY), currentLoc = (_a7 = currentAlert == null ? void 0 : currentAlert.alert) == null ? void 0 : _a7.location;
|
|
52
|
+
if (currentLoc && currentLoc.row === location.row && currentLoc.col === location.col && currentLoc.subUnitId === location.subUnitId && currentLoc.unitId === location.unitId)
|
|
50
53
|
return;
|
|
51
54
|
this._cellAlertManagerService.showAlert({
|
|
52
|
-
type:
|
|
55
|
+
type: CellAlertType.ERROR,
|
|
53
56
|
title: this._localeService.t("info.error"),
|
|
54
57
|
message: this._localeService.t("info.forceStringInfo"),
|
|
55
|
-
location
|
|
58
|
+
location,
|
|
56
59
|
width: 200,
|
|
57
60
|
height: 74,
|
|
58
|
-
key:
|
|
61
|
+
key: ALERT_KEY
|
|
59
62
|
});
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
@@ -64,396 +67,376 @@ let Se = class extends oe {
|
|
|
64
67
|
}));
|
|
65
68
|
}
|
|
66
69
|
_initZenService() {
|
|
67
|
-
this.disposeWithMe(this._zenZoneService.visible$.subscribe((
|
|
68
|
-
|
|
70
|
+
this.disposeWithMe(this._zenZoneService.visible$.subscribe((visible) => {
|
|
71
|
+
visible && this._hideAlert();
|
|
69
72
|
}));
|
|
70
73
|
}
|
|
71
74
|
_hideAlert() {
|
|
72
|
-
this._cellAlertManagerService.removeAlert(
|
|
75
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
73
76
|
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
],
|
|
83
|
-
const
|
|
77
|
+
}, __name(_a, "NumfmtAlertRenderController"), _a);
|
|
78
|
+
NumfmtAlertRenderController = __decorateClass$5([
|
|
79
|
+
__decorateParam$5(1, Inject(HoverManagerService)),
|
|
80
|
+
__decorateParam$5(2, Inject(CellAlertManagerService)),
|
|
81
|
+
__decorateParam$5(3, Inject(LocaleService)),
|
|
82
|
+
__decorateParam$5(4, Inject(FormulaDataModel)),
|
|
83
|
+
__decorateParam$5(5, IZenZoneService),
|
|
84
|
+
__decorateParam$5(6, Inject(INumfmtService))
|
|
85
|
+
], NumfmtAlertRenderController);
|
|
86
|
+
const CloseNumfmtPanelOperator = {
|
|
84
87
|
id: "sheet.operation.close.numfmt.panel",
|
|
85
|
-
type:
|
|
86
|
-
handler: () => (
|
|
88
|
+
type: CommandType.OPERATION,
|
|
89
|
+
handler: /* @__PURE__ */ __name(() => (
|
|
87
90
|
// do nothing, just notify panel is closed
|
|
88
91
|
!0
|
|
89
|
-
)
|
|
90
|
-
},
|
|
92
|
+
), "handler")
|
|
93
|
+
}, OpenNumfmtPanelOperator = {
|
|
91
94
|
id: "sheet.operation.open.numfmt.panel",
|
|
92
|
-
type:
|
|
93
|
-
handler: (
|
|
95
|
+
type: CommandType.OPERATION,
|
|
96
|
+
handler: /* @__PURE__ */ __name((accessor) => (accessor.get(SheetNumfmtUIController).openPanel(), !0), "handler")
|
|
94
97
|
};
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
var Fe;
|
|
106
|
-
function pn() {
|
|
107
|
-
if (Fe) return L;
|
|
108
|
-
Fe = 1;
|
|
109
|
-
var t = ln, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
110
|
-
function o(c, a, m) {
|
|
111
|
-
var d, u = {}, h = null, p = null;
|
|
112
|
-
m !== void 0 && (h = "" + m), a.key !== void 0 && (h = "" + a.key), a.ref !== void 0 && (p = a.ref);
|
|
113
|
-
for (d in a) r.call(a, d) && !i.hasOwnProperty(d) && (u[d] = a[d]);
|
|
114
|
-
if (c && c.defaultProps) for (d in a = c.defaultProps, a) u[d] === void 0 && (u[d] = a[d]);
|
|
115
|
-
return { $$typeof: e, type: c, key: h, ref: p, props: u, _owner: s.current };
|
|
116
|
-
}
|
|
117
|
-
return L.Fragment = n, L.jsx = o, L.jsxs = o, L;
|
|
118
|
-
}
|
|
119
|
-
var Le;
|
|
120
|
-
function vn() {
|
|
121
|
-
return Le || (Le = 1, fe.exports = pn()), fe.exports;
|
|
122
|
-
}
|
|
123
|
-
var l = vn(), _n = Object.defineProperty, gn = Object.getOwnPropertyDescriptor, Sn = (t, e, n, r) => {
|
|
124
|
-
for (var s = r > 1 ? void 0 : r ? gn(e, n) : e, i = t.length - 1, o; i >= 0; i--)
|
|
125
|
-
(o = t[i]) && (s = (r ? o(e, n, s) : o(s)) || s);
|
|
126
|
-
return r && s && _n(e, n, s), s;
|
|
127
|
-
}, yn = (t, e) => (n, r) => e(n, r, t);
|
|
128
|
-
const we = mn([]);
|
|
129
|
-
let k = class {
|
|
130
|
-
constructor(t) {
|
|
131
|
-
this._localStorageService = t;
|
|
98
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
99
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
100
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
101
|
+
return kind && result && __defProp$4(target, key2, result), result;
|
|
102
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$4");
|
|
103
|
+
const UserHabitCurrencyContext = createContext([]);
|
|
104
|
+
var _a2;
|
|
105
|
+
let UserHabitController = (_a2 = class {
|
|
106
|
+
constructor(_localStorageService) {
|
|
107
|
+
this._localStorageService = _localStorageService;
|
|
132
108
|
}
|
|
133
|
-
_getKey(
|
|
134
|
-
return `userHabitController_${
|
|
109
|
+
_getKey(habit) {
|
|
110
|
+
return `userHabitController_${habit}`;
|
|
135
111
|
}
|
|
136
|
-
async addHabit(
|
|
137
|
-
const
|
|
138
|
-
return this._localStorageService.getItem(
|
|
139
|
-
|
|
112
|
+
async addHabit(habit, initValue) {
|
|
113
|
+
const key2 = this._getKey(habit);
|
|
114
|
+
return this._localStorageService.getItem(key2).then((item) => {
|
|
115
|
+
item || this._localStorageService.setItem(key2, initValue);
|
|
140
116
|
});
|
|
141
117
|
}
|
|
142
|
-
markHabit(
|
|
143
|
-
const
|
|
144
|
-
this._localStorageService.getItem(
|
|
145
|
-
if (
|
|
146
|
-
const
|
|
147
|
-
|
|
118
|
+
markHabit(habit, value) {
|
|
119
|
+
const key2 = this._getKey(habit);
|
|
120
|
+
this._localStorageService.getItem(key2).then((list) => {
|
|
121
|
+
if (list) {
|
|
122
|
+
const index = list.findIndex((item) => item === value);
|
|
123
|
+
index > -1 && list.splice(index, 1), list.unshift(value), this._localStorageService.setItem(key2, list);
|
|
148
124
|
}
|
|
149
125
|
});
|
|
150
126
|
}
|
|
151
|
-
async getHabit(
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
const
|
|
155
|
-
const
|
|
127
|
+
async getHabit(habit, sortList) {
|
|
128
|
+
const key2 = this._getKey(habit), result = await this._localStorageService.getItem(key2);
|
|
129
|
+
if (sortList && result) {
|
|
130
|
+
const priority = result.map((item, index, arr) => {
|
|
131
|
+
const length = arr.length;
|
|
156
132
|
return {
|
|
157
|
-
value:
|
|
158
|
-
priority:
|
|
133
|
+
value: item,
|
|
134
|
+
priority: length - index
|
|
159
135
|
};
|
|
160
136
|
});
|
|
161
|
-
return
|
|
162
|
-
var
|
|
163
|
-
const
|
|
164
|
-
return (((
|
|
137
|
+
return sortList.sort((a, b) => {
|
|
138
|
+
var _a7, _b;
|
|
139
|
+
const ap = ((_a7 = priority.find((item) => item.value === a)) == null ? void 0 : _a7.priority) || -1;
|
|
140
|
+
return (((_b = priority.find((item) => item.value === b)) == null ? void 0 : _b.priority) || -1) - ap;
|
|
165
141
|
});
|
|
166
142
|
}
|
|
167
|
-
return
|
|
143
|
+
return result || [];
|
|
168
144
|
}
|
|
169
|
-
deleteHabit(
|
|
170
|
-
this._localStorageService.removeItem(
|
|
145
|
+
deleteHabit(habit) {
|
|
146
|
+
this._localStorageService.removeItem(habit);
|
|
171
147
|
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
],
|
|
176
|
-
const
|
|
177
|
-
const
|
|
178
|
-
return
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
148
|
+
}, __name(_a2, "UserHabitController"), _a2);
|
|
149
|
+
UserHabitController = __decorateClass$4([
|
|
150
|
+
__decorateParam$4(0, Inject(ILocalStorageService))
|
|
151
|
+
], UserHabitController);
|
|
152
|
+
const key$1 = "numfmtCurrency", useCurrencyOptions = /* @__PURE__ */ __name((onOptionChange) => {
|
|
153
|
+
const userHabitController = useDependency(UserHabitController), [options, optionsSet] = useState(currencySymbols);
|
|
154
|
+
return useEffect(() => {
|
|
155
|
+
userHabitController.addHabit("numfmtCurrency", []).then(() => {
|
|
156
|
+
userHabitController.getHabit(key$1, [...currencySymbols]).then((list) => {
|
|
157
|
+
optionsSet(list), onOptionChange(list);
|
|
182
158
|
});
|
|
183
159
|
});
|
|
184
|
-
}, []), { userHabitCurrency:
|
|
185
|
-
|
|
186
|
-
} };
|
|
187
|
-
},
|
|
188
|
-
const
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}),
|
|
193
|
-
}, [
|
|
194
|
-
|
|
195
|
-
};
|
|
196
|
-
},
|
|
197
|
-
const { defaultPattern
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
},
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
};
|
|
205
|
-
return /* @__PURE__ */
|
|
206
|
-
/* @__PURE__ */
|
|
207
|
-
/* @__PURE__ */
|
|
208
|
-
/* @__PURE__ */
|
|
209
|
-
/* @__PURE__ */
|
|
160
|
+
}, []), { userHabitCurrency: options, mark: /* @__PURE__ */ __name((v) => {
|
|
161
|
+
userHabitController.markHabit(key$1, v);
|
|
162
|
+
}, "mark") };
|
|
163
|
+
}, "useCurrencyOptions"), useNextTick = /* @__PURE__ */ __name(() => {
|
|
164
|
+
const effectList = useRef([]), [value, dispatch] = useState({});
|
|
165
|
+
return useEffect(() => {
|
|
166
|
+
effectList.current.forEach((fn) => {
|
|
167
|
+
fn();
|
|
168
|
+
}), effectList.current = [];
|
|
169
|
+
}, [value]), /* @__PURE__ */ __name((fn) => {
|
|
170
|
+
effectList.current.push(fn), dispatch({});
|
|
171
|
+
}, "nextTick");
|
|
172
|
+
}, "useNextTick"), isAccountingPanel = /* @__PURE__ */ __name((pattern) => !!getCurrencyType(pattern) && pattern.startsWith("_("), "isAccountingPanel"), AccountingPanel = /* @__PURE__ */ __name((props) => {
|
|
173
|
+
const { defaultPattern, action, onChange } = props, [decimal, decimalSet] = useState(() => getDecimalFromPattern(defaultPattern || "", 2)), userHabitCurrency = useContext(UserHabitCurrencyContext), [suffix, suffixSet] = useState(() => getCurrencyType(defaultPattern) || userHabitCurrency[0]), options = useMemo(() => userHabitCurrency.map((key2) => ({ label: key2, value: key2 })), []), t = useDependency(LocaleService).t;
|
|
174
|
+
action.current = () => setPatternDecimal(`_("${suffix}"* #,##0${decimal > 0 ? ".0" : ""}_)`, decimal);
|
|
175
|
+
const onSelect = /* @__PURE__ */ __name((v) => {
|
|
176
|
+
suffixSet(v), onChange(setPatternDecimal(`_("${v}"* #,##0${decimal > 0 ? ".0" : ""}_)`, decimal));
|
|
177
|
+
}, "onSelect"), onDecimalChange = /* @__PURE__ */ __name((v) => {
|
|
178
|
+
const decimal2 = v || 0;
|
|
179
|
+
decimalSet(decimal2), onChange(setPatternDecimal(`_("${suffix}"* #,##0${decimal2 > 0 ? ".0" : ""}_)`, decimal2));
|
|
180
|
+
}, "onDecimalChange");
|
|
181
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
182
|
+
/* @__PURE__ */ jsxs("div", { className: "m-t-16 options", children: [
|
|
183
|
+
/* @__PURE__ */ jsxs("div", { className: "option", children: [
|
|
184
|
+
/* @__PURE__ */ jsx("div", { className: "label", children: t("sheet.numfmt.decimalLength") }),
|
|
185
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-8 w-120", children: /* @__PURE__ */ jsx(InputNumber, { value: decimal, max: 20, min: 0, onChange: onDecimalChange }) })
|
|
210
186
|
] }),
|
|
211
|
-
/* @__PURE__ */
|
|
212
|
-
/* @__PURE__ */
|
|
213
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ jsxs("div", { className: "option", children: [
|
|
188
|
+
/* @__PURE__ */ jsx("div", { className: "label", children: t("sheet.numfmt.currencyType") }),
|
|
189
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-8 w-140", children: /* @__PURE__ */ jsx(Select, { onChange: onSelect, options, value: suffix }) })
|
|
214
190
|
] })
|
|
215
191
|
] }),
|
|
216
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ jsx("div", { className: "describe m-t-14", children: t("sheet.numfmt.accountingDes") })
|
|
217
193
|
] });
|
|
218
|
-
},
|
|
219
|
-
const
|
|
220
|
-
var
|
|
221
|
-
const
|
|
222
|
-
return ((
|
|
223
|
-
}),
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
if (
|
|
194
|
+
}, "AccountingPanel"), isCurrencyPanel = /* @__PURE__ */ __name((pattern) => !!getCurrencyType(pattern) && !pattern.startsWith("_("), "isCurrencyPanel"), CurrencyPanel = /* @__PURE__ */ __name((props) => {
|
|
195
|
+
const t = useDependency(LocaleService).t, userHabitCurrency = useContext(UserHabitCurrencyContext), [suffix, suffixSet] = useState(() => getCurrencyType(props.defaultPattern) || userHabitCurrency[0]), [decimal, decimalSet] = useState(() => getDecimalFromPattern(props.defaultPattern || "", 2)), [pattern, patternSet] = useState(() => {
|
|
196
|
+
var _a7;
|
|
197
|
+
const negativeOptions2 = getCurrencyFormatOptions(suffix);
|
|
198
|
+
return ((_a7 = negativeOptions2.find((item) => isPatternEqualWithoutDecimal(item.value, props.defaultPattern))) == null ? void 0 : _a7.value) || negativeOptions2[0].value;
|
|
199
|
+
}), negativeOptions = useMemo(() => getCurrencyFormatOptions(suffix), [suffix]), options = useMemo(() => userHabitCurrency.map((key2) => ({ label: key2, value: key2 })), [userHabitCurrency]);
|
|
200
|
+
props.action.current = () => setPatternDecimal(pattern, decimal);
|
|
201
|
+
const onSelect = /* @__PURE__ */ __name((value) => {
|
|
202
|
+
if (value === void 0)
|
|
227
203
|
return;
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
};
|
|
236
|
-
return /* @__PURE__ */
|
|
237
|
-
/* @__PURE__ */
|
|
238
|
-
/* @__PURE__ */
|
|
239
|
-
/* @__PURE__ */
|
|
240
|
-
/* @__PURE__ */
|
|
204
|
+
suffixSet(value);
|
|
205
|
+
const pattern2 = getCurrencyFormatOptions(value)[0].value;
|
|
206
|
+
patternSet(pattern2), props.onChange(setPatternDecimal(pattern2, decimal));
|
|
207
|
+
}, "onSelect"), onChange = /* @__PURE__ */ __name((value) => {
|
|
208
|
+
value !== void 0 && (patternSet(value), props.onChange(setPatternDecimal(value, decimal)));
|
|
209
|
+
}, "onChange"), onDecimalChange = /* @__PURE__ */ __name((v) => {
|
|
210
|
+
decimalSet(v || 0), props.onChange(setPatternDecimal(pattern, v || 0));
|
|
211
|
+
}, "onDecimalChange");
|
|
212
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
213
|
+
/* @__PURE__ */ jsxs("div", { className: "m-t-16 options", children: [
|
|
214
|
+
/* @__PURE__ */ jsxs("div", { className: "option", children: [
|
|
215
|
+
/* @__PURE__ */ jsx("div", { className: "label", children: t("sheet.numfmt.decimalLength") }),
|
|
216
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-8 w-120", children: /* @__PURE__ */ jsx(InputNumber, { value: decimal, max: 20, min: 0, onChange: onDecimalChange }) })
|
|
241
217
|
] }),
|
|
242
|
-
/* @__PURE__ */
|
|
243
|
-
/* @__PURE__ */
|
|
244
|
-
/* @__PURE__ */
|
|
218
|
+
/* @__PURE__ */ jsxs("div", { className: "option", children: [
|
|
219
|
+
/* @__PURE__ */ jsx("div", { className: "label", children: t("sheet.numfmt.currencyType") }),
|
|
220
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-8 w-140", children: /* @__PURE__ */ jsx(Select, { onChange: onSelect, options, value: suffix }) })
|
|
245
221
|
] })
|
|
246
222
|
] }),
|
|
247
|
-
/* @__PURE__ */
|
|
248
|
-
/* @__PURE__ */
|
|
249
|
-
/* @__PURE__ */
|
|
223
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-16 label", children: t("sheet.numfmt.negType") }),
|
|
224
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-8", children: /* @__PURE__ */ jsx(SelectList, { onChange, options: negativeOptions, value: pattern }) }),
|
|
225
|
+
/* @__PURE__ */ jsx("div", { className: "describe m-t-14", children: t("sheet.numfmt.currencyDes") })
|
|
250
226
|
] });
|
|
251
|
-
};
|
|
252
|
-
var
|
|
253
|
-
return
|
|
254
|
-
for (var
|
|
255
|
-
|
|
256
|
-
for (var
|
|
227
|
+
}, "CurrencyPanel");
|
|
228
|
+
var __assign = function() {
|
|
229
|
+
return __assign = Object.assign || function(t) {
|
|
230
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
231
|
+
s = arguments[i];
|
|
232
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
257
233
|
}
|
|
258
234
|
return t;
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
var
|
|
262
|
-
for (var
|
|
263
|
-
if (
|
|
264
|
-
for (var
|
|
265
|
-
e.indexOf(
|
|
266
|
-
return
|
|
267
|
-
},
|
|
268
|
-
var
|
|
269
|
-
return
|
|
235
|
+
}, __assign.apply(this, arguments);
|
|
236
|
+
}, __rest = function(s, e) {
|
|
237
|
+
var t = {};
|
|
238
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
239
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
240
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
241
|
+
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
242
|
+
return t;
|
|
243
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
244
|
+
var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
|
|
245
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
270
246
|
});
|
|
271
|
-
function
|
|
272
|
-
return
|
|
273
|
-
return
|
|
247
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
248
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
249
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
274
250
|
}));
|
|
275
251
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
252
|
+
__name(render, "render");
|
|
253
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
254
|
+
var attrs = __assign({}, node.attrs);
|
|
255
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
256
|
+
var defIds = runtimeProps.defIds;
|
|
257
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a7) {
|
|
258
|
+
var key2 = _a7[0], value = _a7[1];
|
|
259
|
+
typeof value == "string" && (attrs[key2] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
260
|
+
})), attrs;
|
|
284
261
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
262
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
263
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
264
|
+
var _a7, defIds = runtimeProps.defIds;
|
|
265
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a7 = node.children) === null || _a7 === void 0) && _a7.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
266
|
+
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
267
|
+
}) }) : node;
|
|
290
268
|
}
|
|
291
|
-
|
|
269
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
270
|
+
function generateShortUuid() {
|
|
292
271
|
return Math.random().toString(36).substring(2, 8);
|
|
293
272
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
273
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
274
|
+
IconBase.displayName = "UniverIcon";
|
|
275
|
+
var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, CheckMarkSingle = forwardRef(function(props, ref) {
|
|
276
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
297
277
|
id: "check-mark-single",
|
|
298
|
-
ref
|
|
299
|
-
icon:
|
|
278
|
+
ref,
|
|
279
|
+
icon: element
|
|
300
280
|
}));
|
|
301
281
|
});
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
customFormatTitle
|
|
305
|
-
customFormatInput
|
|
306
|
-
customFormatHistoryList
|
|
307
|
-
customFormatHistoryListItem
|
|
308
|
-
customFormatHistoryListItemIconWrap
|
|
309
|
-
customFormatDes
|
|
310
|
-
},
|
|
311
|
-
function
|
|
312
|
-
const { defaultPattern
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
}),
|
|
317
|
-
const [
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
...
|
|
322
|
-
...
|
|
323
|
-
...
|
|
282
|
+
CheckMarkSingle.displayName = "CheckMarkSingle";
|
|
283
|
+
const customFormatTitle = "univer-custom-format-title", customFormatInput = "univer-custom-format-input", customFormatHistoryList = "univer-custom-format-history-list", customFormatHistoryListItem = "univer-custom-format-history-list-item", customFormatHistoryListItemIconWrap = "univer-custom-format-history-list-item-icon-wrap", customFormatDes = "univer-custom-format-des", styles = {
|
|
284
|
+
customFormatTitle,
|
|
285
|
+
customFormatInput,
|
|
286
|
+
customFormatHistoryList,
|
|
287
|
+
customFormatHistoryListItem,
|
|
288
|
+
customFormatHistoryListItemIconWrap,
|
|
289
|
+
customFormatDes
|
|
290
|
+
}, key = "customFormat", historyPatternKey = "numfmt_custom_pattern";
|
|
291
|
+
function CustomFormat(props) {
|
|
292
|
+
const { defaultPattern, action, onChange } = props, userHabitController = useDependency(UserHabitController), localStorageService = useDependency(ILocalStorageService), localeService = useDependency(LocaleService), [pattern, patternSet] = useState(defaultPattern);
|
|
293
|
+
action.current = () => (userHabitController.markHabit(key, pattern), localStorageService.getItem(historyPatternKey).then((list = []) => {
|
|
294
|
+
const _list = [.../* @__PURE__ */ new Set([pattern, ...list || []])].splice(0, 10).filter((e) => !!e);
|
|
295
|
+
localStorageService.setItem(historyPatternKey, _list);
|
|
296
|
+
}), pattern);
|
|
297
|
+
const [options, optionsSet] = useState([]);
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
localStorageService.getItem(historyPatternKey).then((historyList) => {
|
|
300
|
+
const list = [
|
|
301
|
+
...CURRENCYFORMAT.map((item) => item.suffix("$")),
|
|
302
|
+
...DATEFMTLISG.map((item) => item.suffix),
|
|
303
|
+
...NUMBERFORMAT.map((item) => item.suffix)
|
|
324
304
|
];
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
305
|
+
list.push(...historyList || []), userHabitController.addHabit(key, []).finally(() => {
|
|
306
|
+
userHabitController.getHabit(key, list).then((list2) => {
|
|
307
|
+
optionsSet([...new Set(list2)]);
|
|
328
308
|
});
|
|
329
309
|
});
|
|
330
310
|
});
|
|
331
311
|
}, []);
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
},
|
|
335
|
-
|
|
336
|
-
};
|
|
337
|
-
return /* @__PURE__ */
|
|
338
|
-
/* @__PURE__ */
|
|
339
|
-
/* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */
|
|
341
|
-
/* @__PURE__ */
|
|
342
|
-
/* @__PURE__ */
|
|
312
|
+
const handleClick = /* @__PURE__ */ __name((p) => {
|
|
313
|
+
patternSet(p), onChange(p);
|
|
314
|
+
}, "handleClick"), handleBlur = /* @__PURE__ */ __name(() => {
|
|
315
|
+
onChange(pattern);
|
|
316
|
+
}, "handleBlur");
|
|
317
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.customFormat, children: [
|
|
318
|
+
/* @__PURE__ */ jsx("div", { className: styles.customFormatTitle, children: localeService.t("sheet.numfmt.customFormat") }),
|
|
319
|
+
/* @__PURE__ */ jsx(Input, { placeholder: localeService.t("sheet.numfmt.customFormat"), onBlur: handleBlur, value: pattern, onChange: patternSet, className: styles.customFormatInput }),
|
|
320
|
+
/* @__PURE__ */ jsx("div", { className: styles.customFormatHistoryList, children: options.map((p) => /* @__PURE__ */ jsxs("div", { onClick: /* @__PURE__ */ __name(() => handleClick(p), "onClick"), className: styles.customFormatHistoryListItem, children: [
|
|
321
|
+
/* @__PURE__ */ jsx("div", { className: styles.customFormatHistoryListItemIconWrap, children: pattern === p && /* @__PURE__ */ jsx(CheckMarkSingle, {}) }),
|
|
322
|
+
/* @__PURE__ */ jsx("div", { children: p })
|
|
343
323
|
] }, p)) }),
|
|
344
|
-
/* @__PURE__ */
|
|
324
|
+
/* @__PURE__ */ jsx("div", { className: styles.customFormatDes, children: localeService.t("sheet.numfmt.customFormatDes") })
|
|
345
325
|
] });
|
|
346
326
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
327
|
+
__name(CustomFormat, "CustomFormat");
|
|
328
|
+
const isDatePanel = /* @__PURE__ */ __name((pattern) => {
|
|
329
|
+
const info = numfmt.getInfo(pattern);
|
|
330
|
+
return getDateFormatOptions().map((item) => item.value).includes(pattern) || ["date", "datetime", "time"].includes(info.type);
|
|
331
|
+
}, "isDatePanel"), DatePanel = /* @__PURE__ */ __name((props) => {
|
|
332
|
+
const options = useMemo(getDateFormatOptions, []), t = useDependency(LocaleService).t, [suffix, suffixSet] = useState(() => {
|
|
333
|
+
if (props.defaultPattern) {
|
|
334
|
+
const item = options.find((item2) => item2.value === props.defaultPattern);
|
|
335
|
+
if (item)
|
|
336
|
+
return item.value;
|
|
356
337
|
}
|
|
357
|
-
return
|
|
338
|
+
return options[0].value;
|
|
358
339
|
});
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
};
|
|
363
|
-
return /* @__PURE__ */
|
|
364
|
-
/* @__PURE__ */
|
|
365
|
-
/* @__PURE__ */
|
|
366
|
-
/* @__PURE__ */
|
|
340
|
+
props.action.current = () => suffix;
|
|
341
|
+
const onChange = /* @__PURE__ */ __name((v) => {
|
|
342
|
+
v !== void 0 && (suffixSet(v), props.onChange(v));
|
|
343
|
+
}, "onChange");
|
|
344
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
345
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-16 label", children: t("sheet.numfmt.dateType") }),
|
|
346
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-8", children: /* @__PURE__ */ jsx(SelectList, { value: suffix, options, onChange }) }),
|
|
347
|
+
/* @__PURE__ */ jsx("div", { className: "describe m-t-14", children: t("sheet.numfmt.dateDes") })
|
|
367
348
|
] });
|
|
368
|
-
},
|
|
369
|
-
const
|
|
370
|
-
return
|
|
371
|
-
},
|
|
372
|
-
const
|
|
373
|
-
const
|
|
374
|
-
return (
|
|
375
|
-
}),
|
|
376
|
-
|
|
377
|
-
},
|
|
378
|
-
|
|
379
|
-
};
|
|
380
|
-
return
|
|
381
|
-
/* @__PURE__ */
|
|
382
|
-
/* @__PURE__ */
|
|
383
|
-
|
|
349
|
+
}, "DatePanel"), isGeneralPanel = /* @__PURE__ */ __name((pattern) => !pattern, "isGeneralPanel"), GeneralPanel = /* @__PURE__ */ __name((props) => {
|
|
350
|
+
const t = useDependency(LocaleService).t;
|
|
351
|
+
return props.action.current = () => "", /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "describe m-t-14", children: t("sheet.numfmt.generalDes") }) });
|
|
352
|
+
}, "GeneralPanel"), isThousandthPercentilePanel = /* @__PURE__ */ __name((pattern) => getNumberFormatOptions().some((item) => isPatternEqualWithoutDecimal(item.value, pattern)), "isThousandthPercentilePanel"), ThousandthPercentilePanel = /* @__PURE__ */ __name((props) => {
|
|
353
|
+
const localeService = useDependency(LocaleService), options = useMemo(getNumberFormatOptions, []), [decimal, decimalSet] = useState(() => getDecimalFromPattern(props.defaultPattern || "", 0)), [suffix, suffixSet] = useState(() => {
|
|
354
|
+
const item = options.find((item2) => isPatternEqualWithoutDecimal(item2.value, props.defaultPattern || ""));
|
|
355
|
+
return (item == null ? void 0 : item.value) || options[0].value;
|
|
356
|
+
}), pattern = useMemo(() => setPatternDecimal(suffix, Number(decimal || 0)), [suffix, decimal]), isInputDisable = useMemo(() => !isPatternHasDecimal(suffix), [suffix]), handleDecimalChange = /* @__PURE__ */ __name((decimal2) => {
|
|
357
|
+
decimalSet(decimal2 || 0), props.onChange(setPatternDecimal(suffix, Number(decimal2 || 0)));
|
|
358
|
+
}, "handleDecimalChange"), handleClick = /* @__PURE__ */ __name((v) => {
|
|
359
|
+
v !== void 0 && (decimalSet(getDecimalFromPattern(v, 0)), suffixSet(v), props.onChange(v));
|
|
360
|
+
}, "handleClick");
|
|
361
|
+
return props.action.current = () => pattern, /* @__PURE__ */ jsxs("div", { children: [
|
|
362
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-16 label", children: localeService.t("sheet.numfmt.decimalLength") }),
|
|
363
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-8", children: /* @__PURE__ */ jsx(
|
|
364
|
+
InputNumber,
|
|
384
365
|
{
|
|
385
|
-
disabled:
|
|
386
|
-
value:
|
|
366
|
+
disabled: isInputDisable,
|
|
367
|
+
value: decimal,
|
|
387
368
|
max: 20,
|
|
388
369
|
min: 0,
|
|
389
|
-
onChange:
|
|
370
|
+
onChange: handleDecimalChange
|
|
390
371
|
}
|
|
391
372
|
) }),
|
|
392
|
-
/* @__PURE__ */
|
|
373
|
+
/* @__PURE__ */ jsxs("div", { className: "m-t-16 label", children: [
|
|
393
374
|
" ",
|
|
394
|
-
|
|
375
|
+
localeService.t("sheet.numfmt.negType")
|
|
395
376
|
] }),
|
|
396
|
-
/* @__PURE__ */
|
|
397
|
-
/* @__PURE__ */
|
|
377
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-8", children: /* @__PURE__ */ jsx(SelectList, { onChange: handleClick, options, value: suffix }) }),
|
|
378
|
+
/* @__PURE__ */ jsx("div", { className: "describe m-t-14", children: localeService.t("sheet.numfmt.thousandthPercentileDes") })
|
|
398
379
|
] });
|
|
399
|
-
},
|
|
400
|
-
const { defaultValue
|
|
380
|
+
}, "ThousandthPercentilePanel"), SheetNumfmtPanel = /* @__PURE__ */ __name((props) => {
|
|
381
|
+
const { defaultValue, defaultPattern, row, col } = props.value, localeService = useDependency(LocaleService), getCurrentPattern = useRef(() => ""), t = localeService.t, nextTick = useNextTick(), typeOptions = useMemo(
|
|
401
382
|
() => [
|
|
402
|
-
{ label: "sheet.numfmt.general", component:
|
|
403
|
-
{ label: "sheet.numfmt.accounting", component:
|
|
404
|
-
{ label: "sheet.numfmt.currency", component:
|
|
405
|
-
{ label: "sheet.numfmt.date", component:
|
|
406
|
-
{ label: "sheet.numfmt.thousandthPercentile", component:
|
|
407
|
-
{ label: "sheet.numfmt.customFormat", component:
|
|
408
|
-
].map((
|
|
383
|
+
{ label: "sheet.numfmt.general", component: GeneralPanel },
|
|
384
|
+
{ label: "sheet.numfmt.accounting", component: AccountingPanel },
|
|
385
|
+
{ label: "sheet.numfmt.currency", component: CurrencyPanel },
|
|
386
|
+
{ label: "sheet.numfmt.date", component: DatePanel },
|
|
387
|
+
{ label: "sheet.numfmt.thousandthPercentile", component: ThousandthPercentilePanel },
|
|
388
|
+
{ label: "sheet.numfmt.customFormat", component: CustomFormat }
|
|
389
|
+
].map((item) => ({ ...item, label: t(item.label) })),
|
|
409
390
|
[]
|
|
410
|
-
), [
|
|
411
|
-
var
|
|
412
|
-
return (
|
|
413
|
-
}, [
|
|
414
|
-
function
|
|
415
|
-
return [
|
|
391
|
+
), [type, typeSet] = useState(findDefaultType), [key2, keySet] = useState(() => `${row}_${col}`), { mark, userHabitCurrency } = useCurrencyOptions(() => keySet(`${row}_${col}_userCurrency'`)), BusinessComponent = useMemo(() => {
|
|
392
|
+
var _a7;
|
|
393
|
+
return (_a7 = typeOptions.find((item) => item.label === type)) == null ? void 0 : _a7.component;
|
|
394
|
+
}, [type]);
|
|
395
|
+
function findDefaultType() {
|
|
396
|
+
return [isGeneralPanel, isAccountingPanel, isCurrencyPanel, isDatePanel, isThousandthPercentilePanel].reduce((pre, curFn, index) => pre || (curFn(defaultPattern) ? typeOptions[index].label : ""), "") || typeOptions[0].label;
|
|
416
397
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
398
|
+
__name(findDefaultType, "findDefaultType");
|
|
399
|
+
const selectOptions = typeOptions.map((option) => ({
|
|
400
|
+
label: option.label,
|
|
401
|
+
value: option.label
|
|
402
|
+
})), handleSelect = /* @__PURE__ */ __name((value) => {
|
|
403
|
+
typeSet(value), nextTick(() => props.onChange({ type: "change", value: getCurrentPattern.current() || "" }));
|
|
404
|
+
}, "handleSelect"), handleChange = /* @__PURE__ */ __name((v) => {
|
|
405
|
+
props.onChange({ type: "change", value: v });
|
|
406
|
+
}, "handleChange"), handleConfirm = /* @__PURE__ */ __name(() => {
|
|
407
|
+
const pattern = getCurrentPattern.current() || "", currency = getCurrencyType(pattern);
|
|
408
|
+
currency && mark(currency), props.onChange({ type: "confirm", value: pattern });
|
|
409
|
+
}, "handleConfirm"), handleCancel = /* @__PURE__ */ __name(() => {
|
|
410
|
+
props.onChange({ type: "cancel", value: "" });
|
|
411
|
+
}, "handleCancel"), subProps = {
|
|
412
|
+
onChange: handleChange,
|
|
413
|
+
defaultValue,
|
|
414
|
+
defaultPattern,
|
|
415
|
+
action: getCurrentPattern
|
|
434
416
|
};
|
|
435
|
-
return
|
|
436
|
-
|
|
437
|
-
}, [
|
|
438
|
-
/* @__PURE__ */
|
|
439
|
-
/* @__PURE__ */
|
|
440
|
-
/* @__PURE__ */
|
|
441
|
-
/* @__PURE__ */
|
|
417
|
+
return useEffect(() => {
|
|
418
|
+
typeSet(findDefaultType()), keySet(`${row}_${col}`);
|
|
419
|
+
}, [row, col]), /* @__PURE__ */ jsxs("div", { className: "numfmt-panel p-b-20", children: [
|
|
420
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
421
|
+
/* @__PURE__ */ jsx("div", { className: "label m-t-14", children: t("sheet.numfmt.numfmtType") }),
|
|
422
|
+
/* @__PURE__ */ jsx("div", { className: "m-t-8", children: /* @__PURE__ */ jsx(Select, { onChange: handleSelect, options: selectOptions, value: type, style: { width: "100%" } }) }),
|
|
423
|
+
/* @__PURE__ */ jsx("div", { children: BusinessComponent && /* @__PURE__ */ jsx(UserHabitCurrencyContext.Provider, { value: userHabitCurrency, children: /* @__PURE__ */ createElement(BusinessComponent, { ...subProps, key: key2 }) }) })
|
|
442
424
|
] }),
|
|
443
|
-
/* @__PURE__ */
|
|
444
|
-
/* @__PURE__ */
|
|
445
|
-
/* @__PURE__ */
|
|
425
|
+
/* @__PURE__ */ jsxs("div", { className: "btn-list m-t-14 m-b-20", children: [
|
|
426
|
+
/* @__PURE__ */ jsx(Button, { size: "small", onClick: handleCancel, className: "m-r-12", children: t("sheet.numfmt.cancel") }),
|
|
427
|
+
/* @__PURE__ */ jsx(Button, { type: "primary", size: "small", onClick: handleConfirm, children: t("sheet.numfmt.confirm") })
|
|
446
428
|
] })
|
|
447
429
|
] });
|
|
448
|
-
};
|
|
449
|
-
var
|
|
450
|
-
for (var
|
|
451
|
-
(
|
|
452
|
-
return
|
|
453
|
-
},
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
430
|
+
}, "SheetNumfmtPanel");
|
|
431
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
432
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
433
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
434
|
+
return kind && result && __defProp$3(target, key2, result), result;
|
|
435
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$3");
|
|
436
|
+
const SHEET_NUMFMT_PANEL = "SHEET_NUMFMT_PANEL";
|
|
437
|
+
var _a3;
|
|
438
|
+
let SheetNumfmtUIController = (_a3 = class extends Disposable {
|
|
439
|
+
constructor(_sheetInterceptorService, _themeService, _univerInstanceService, _commandService, _selectionManagerService, _renderManagerService, _numfmtService, _componentManager, _sidebarService, _localeService, _sheetsNumfmtCellContentController) {
|
|
457
440
|
super();
|
|
458
441
|
/**
|
|
459
442
|
* If _previewPattern is null ,the realTimeRenderingInterceptor will skip and if it is '',realTimeRenderingInterceptor will clear numfmt.
|
|
@@ -461,225 +444,235 @@ let B = class extends oe {
|
|
|
461
444
|
* @type {(string | null)}
|
|
462
445
|
* @memberof NumfmtController
|
|
463
446
|
*/
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
this._sheetInterceptorService =
|
|
447
|
+
__publicField(this, "_previewPattern", "");
|
|
448
|
+
__publicField(this, "_sidebarDisposable", null);
|
|
449
|
+
this._sheetInterceptorService = _sheetInterceptorService, this._themeService = _themeService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._selectionManagerService = _selectionManagerService, this._renderManagerService = _renderManagerService, this._numfmtService = _numfmtService, this._componentManager = _componentManager, this._sidebarService = _sidebarService, this._localeService = _localeService, this._sheetsNumfmtCellContentController = _sheetsNumfmtCellContentController, this._initRealTimeRenderingInterceptor(), this._initPanel(), this._initCommands(), this._initCloseListener(), this._commandExecutedListener(), this._initNumfmtLocalChange();
|
|
450
|
+
}
|
|
451
|
+
_initNumfmtLocalChange() {
|
|
452
|
+
this.disposeWithMe(merge(this._sheetsNumfmtCellContentController.local$, this._localeService.currentLocale$).subscribe(() => {
|
|
453
|
+
this._forceUpdate();
|
|
454
|
+
}));
|
|
467
455
|
}
|
|
468
456
|
openPanel() {
|
|
469
|
-
var
|
|
470
|
-
const
|
|
471
|
-
if (!
|
|
457
|
+
var _a7;
|
|
458
|
+
const sidebarService = this._sidebarService, selectionManagerService = this._selectionManagerService, commandService = this._commandService, univerInstanceService = this._univerInstanceService, numfmtService = this._numfmtService, localeService = this._localeService, range = (((_a7 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a7.map((s) => s.range)) || [])[0];
|
|
459
|
+
if (!range)
|
|
472
460
|
return !1;
|
|
473
|
-
const
|
|
474
|
-
if (!
|
|
461
|
+
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), sheet = workbook.getActiveSheet();
|
|
462
|
+
if (!sheet)
|
|
475
463
|
return !1;
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
464
|
+
const cellValue = sheet.getCellRaw(range.startRow, range.startColumn), numfmtValue = numfmtService.getValue(
|
|
465
|
+
workbook.getUnitId(),
|
|
466
|
+
sheet.getSheetId(),
|
|
467
|
+
range.startRow,
|
|
468
|
+
range.startColumn
|
|
481
469
|
);
|
|
482
|
-
let
|
|
483
|
-
|
|
484
|
-
const
|
|
485
|
-
onChange: (
|
|
486
|
-
var
|
|
487
|
-
if (
|
|
488
|
-
this._previewPattern =
|
|
489
|
-
else if (
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
row
|
|
495
|
-
col
|
|
496
|
-
pattern:
|
|
497
|
-
type:
|
|
470
|
+
let pattern = "";
|
|
471
|
+
numfmtValue && (pattern = numfmtValue.pattern);
|
|
472
|
+
const defaultValue = (cellValue == null ? void 0 : cellValue.t) === CellValueType.NUMBER ? cellValue.v : 12345678, props = {
|
|
473
|
+
onChange: /* @__PURE__ */ __name((config) => {
|
|
474
|
+
var _a8;
|
|
475
|
+
if (config.type === "change")
|
|
476
|
+
this._previewPattern = config.value, this._forceUpdate();
|
|
477
|
+
else if (config.type === "confirm") {
|
|
478
|
+
const selections2 = ((_a8 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a8.map((s) => s.range)) || [], params = { values: [] }, patternType = getPatternType(config.value);
|
|
479
|
+
selections2.forEach((rangeInfo) => {
|
|
480
|
+
Range.foreach(rangeInfo, (row, col) => {
|
|
481
|
+
params.values.push({
|
|
482
|
+
row,
|
|
483
|
+
col,
|
|
484
|
+
pattern: config.value,
|
|
485
|
+
type: patternType
|
|
498
486
|
});
|
|
499
487
|
});
|
|
500
|
-
}),
|
|
501
|
-
} else
|
|
502
|
-
},
|
|
503
|
-
value: { defaultPattern:
|
|
488
|
+
}), commandService.executeCommand(SetNumfmtCommand.id, params), sidebarService.close();
|
|
489
|
+
} else config.type === "cancel" && sidebarService.close();
|
|
490
|
+
}, "onChange"),
|
|
491
|
+
value: { defaultPattern: pattern, defaultValue, row: range.startRow, col: range.startColumn }
|
|
504
492
|
};
|
|
505
|
-
return this._sidebarDisposable =
|
|
506
|
-
header: { title:
|
|
493
|
+
return this._sidebarDisposable = sidebarService.open({
|
|
494
|
+
header: { title: localeService.t("sheet.numfmt.title") },
|
|
507
495
|
children: {
|
|
508
|
-
label:
|
|
509
|
-
...
|
|
496
|
+
label: SHEET_NUMFMT_PANEL,
|
|
497
|
+
...props
|
|
510
498
|
// need passthrough to react props.
|
|
511
499
|
},
|
|
512
|
-
onClose: () => {
|
|
513
|
-
this._forceUpdate(),
|
|
514
|
-
}
|
|
500
|
+
onClose: /* @__PURE__ */ __name(() => {
|
|
501
|
+
this._forceUpdate(), commandService.executeCommand(CloseNumfmtPanelOperator.id);
|
|
502
|
+
}, "onClose")
|
|
515
503
|
}), !0;
|
|
516
504
|
}
|
|
517
|
-
_forceUpdate(
|
|
518
|
-
var
|
|
519
|
-
const
|
|
520
|
-
|
|
505
|
+
_forceUpdate(unitId) {
|
|
506
|
+
var _a7;
|
|
507
|
+
const renderUnit = this._renderManagerService.getRenderById(
|
|
508
|
+
unitId != null ? unitId : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId()
|
|
521
509
|
);
|
|
522
|
-
|
|
510
|
+
renderUnit == null || renderUnit.with(SheetSkeletonManagerService).reCalculate(), (_a7 = renderUnit == null ? void 0 : renderUnit.mainComponent) == null || _a7.makeDirty();
|
|
523
511
|
}
|
|
524
512
|
_initCommands() {
|
|
525
513
|
[
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
].forEach((
|
|
529
|
-
this.disposeWithMe(this._commandService.registerCommand(
|
|
514
|
+
OpenNumfmtPanelOperator,
|
|
515
|
+
CloseNumfmtPanelOperator
|
|
516
|
+
].forEach((config) => {
|
|
517
|
+
this.disposeWithMe(this._commandService.registerCommand(config));
|
|
530
518
|
});
|
|
531
519
|
}
|
|
532
520
|
_initPanel() {
|
|
533
|
-
this._componentManager.register(
|
|
521
|
+
this._componentManager.register(SHEET_NUMFMT_PANEL, SheetNumfmtPanel);
|
|
534
522
|
}
|
|
523
|
+
// eslint-disable-next-line max-lines-per-function
|
|
535
524
|
_initRealTimeRenderingInterceptor() {
|
|
536
|
-
const
|
|
537
|
-
this._commandService.onCommandExecuted((
|
|
538
|
-
|
|
525
|
+
const isPanelOpenObserver = new Observable((subscriber) => {
|
|
526
|
+
this._commandService.onCommandExecuted((commandInfo) => {
|
|
527
|
+
commandInfo.id === OpenNumfmtPanelOperator.id && subscriber.next(!0), commandInfo.id === CloseNumfmtPanelOperator.id && subscriber.next(!1);
|
|
539
528
|
});
|
|
540
|
-
}),
|
|
541
|
-
|
|
529
|
+
}), combineOpenAndSelection$ = combineLatest([
|
|
530
|
+
isPanelOpenObserver,
|
|
542
531
|
this._selectionManagerService.selectionMoveEnd$.pipe(
|
|
543
|
-
|
|
532
|
+
map((selectionInfos) => selectionInfos ? selectionInfos.map((selectionInfo) => selectionInfo.range) : [])
|
|
544
533
|
)
|
|
545
534
|
]);
|
|
546
535
|
this.disposeWithMe(
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
([
|
|
551
|
-
const
|
|
552
|
-
return
|
|
553
|
-
|
|
536
|
+
toDisposable(
|
|
537
|
+
combineOpenAndSelection$.pipe(
|
|
538
|
+
switchMap(
|
|
539
|
+
([isOpen, selectionRanges]) => new Observable((subscribe) => {
|
|
540
|
+
const disposableCollection = new DisposableCollection();
|
|
541
|
+
return isOpen && selectionRanges.length && subscribe.next({ selectionRanges, disposableCollection }), () => {
|
|
542
|
+
disposableCollection.dispose();
|
|
554
543
|
};
|
|
555
544
|
})
|
|
556
545
|
),
|
|
557
|
-
|
|
546
|
+
tap(() => {
|
|
558
547
|
this._previewPattern = null;
|
|
559
548
|
})
|
|
560
|
-
).subscribe(({ disposableCollection
|
|
561
|
-
var
|
|
562
|
-
const
|
|
563
|
-
this.openPanel(),
|
|
564
|
-
this._sheetInterceptorService.intercept(
|
|
549
|
+
).subscribe(({ disposableCollection, selectionRanges }) => {
|
|
550
|
+
var _a7, _b;
|
|
551
|
+
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
552
|
+
this.openPanel(), disposableCollection.add(
|
|
553
|
+
this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
565
554
|
priority: 99,
|
|
566
|
-
effect:
|
|
567
|
-
handler: (
|
|
568
|
-
const { row
|
|
569
|
-
if (
|
|
570
|
-
(
|
|
555
|
+
effect: InterceptorEffectEnum.Value | InterceptorEffectEnum.Style,
|
|
556
|
+
handler: /* @__PURE__ */ __name((cell, location, next) => {
|
|
557
|
+
const { row, col } = location, defaultValue = next(cell) || {};
|
|
558
|
+
if (selectionRanges.find(
|
|
559
|
+
(range) => range.startColumn <= col && range.endColumn >= col && range.startRow <= row && range.endRow >= row
|
|
571
560
|
)) {
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
574
|
-
return
|
|
575
|
-
const
|
|
576
|
-
if (
|
|
577
|
-
const
|
|
561
|
+
const rawValue = location.worksheet.getCellRaw(row, col), value = rawValue == null ? void 0 : rawValue.v, type = rawValue == null ? void 0 : rawValue.t;
|
|
562
|
+
if (value == null || type !== CellValueType.NUMBER || this._previewPattern === null)
|
|
563
|
+
return defaultValue;
|
|
564
|
+
const info = getPatternPreviewIgnoreGeneral(this._previewPattern, value, this._sheetsNumfmtCellContentController.local);
|
|
565
|
+
if (info.color) {
|
|
566
|
+
const color = this._themeService.getCurrentTheme()[`${info.color}500`];
|
|
578
567
|
return {
|
|
579
|
-
...
|
|
580
|
-
v:
|
|
581
|
-
t:
|
|
582
|
-
s: { cl: { rgb:
|
|
568
|
+
...defaultValue,
|
|
569
|
+
v: info.result,
|
|
570
|
+
t: CellValueType.STRING,
|
|
571
|
+
s: { cl: { rgb: color } }
|
|
583
572
|
};
|
|
584
573
|
}
|
|
585
574
|
return {
|
|
586
|
-
...
|
|
587
|
-
v:
|
|
588
|
-
t:
|
|
575
|
+
...defaultValue,
|
|
576
|
+
v: info.result,
|
|
577
|
+
t: CellValueType.STRING
|
|
589
578
|
};
|
|
590
579
|
}
|
|
591
|
-
return
|
|
592
|
-
}
|
|
580
|
+
return defaultValue;
|
|
581
|
+
}, "handler")
|
|
593
582
|
})
|
|
594
|
-
), (
|
|
583
|
+
), (_b = (_a7 = this._renderManagerService.getRenderById(workbook.getUnitId())) == null ? void 0 : _a7.mainComponent) == null || _b.makeDirty();
|
|
595
584
|
})
|
|
596
585
|
)
|
|
597
586
|
);
|
|
598
587
|
}
|
|
599
588
|
_commandExecutedListener() {
|
|
600
|
-
const
|
|
589
|
+
const commandList = [RemoveNumfmtMutation.id, SetNumfmtMutation.id];
|
|
601
590
|
this.disposeWithMe(
|
|
602
|
-
new
|
|
603
|
-
const
|
|
604
|
-
if (
|
|
605
|
-
const
|
|
606
|
-
|
|
591
|
+
new Observable((subscribe) => {
|
|
592
|
+
const disposable = this._commandService.onCommandExecuted((command) => {
|
|
593
|
+
if (commandList.includes(command.id)) {
|
|
594
|
+
const params = command.params;
|
|
595
|
+
subscribe.next(params.unitId);
|
|
607
596
|
}
|
|
608
597
|
});
|
|
609
|
-
return () =>
|
|
610
|
-
}).pipe(
|
|
598
|
+
return () => disposable.dispose();
|
|
599
|
+
}).pipe(debounceTime$1(16)).subscribe((unitId) => this._forceUpdate(unitId))
|
|
611
600
|
);
|
|
612
601
|
}
|
|
613
602
|
_initCloseListener() {
|
|
614
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(
|
|
615
|
-
var
|
|
616
|
-
|
|
603
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).subscribe((unit) => {
|
|
604
|
+
var _a7;
|
|
605
|
+
unit || ((_a7 = this._sidebarDisposable) == null || _a7.dispose(), this._sidebarDisposable = null);
|
|
617
606
|
});
|
|
618
607
|
}
|
|
619
|
-
};
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
608
|
+
}, __name(_a3, "SheetNumfmtUIController"), _a3);
|
|
609
|
+
SheetNumfmtUIController = __decorateClass$3([
|
|
610
|
+
__decorateParam$3(0, Inject(SheetInterceptorService)),
|
|
611
|
+
__decorateParam$3(1, Inject(ThemeService)),
|
|
612
|
+
__decorateParam$3(2, IUniverInstanceService),
|
|
613
|
+
__decorateParam$3(3, ICommandService),
|
|
614
|
+
__decorateParam$3(4, Inject(SheetsSelectionsService)),
|
|
615
|
+
__decorateParam$3(5, IRenderManagerService),
|
|
616
|
+
__decorateParam$3(6, INumfmtService),
|
|
617
|
+
__decorateParam$3(7, Inject(ComponentManager)),
|
|
618
|
+
__decorateParam$3(8, ISidebarService),
|
|
619
|
+
__decorateParam$3(9, Inject(LocaleService)),
|
|
620
|
+
__decorateParam$3(10, Inject(SheetsNumfmtCellContentController))
|
|
621
|
+
], SheetNumfmtUIController);
|
|
622
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
623
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
624
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
625
|
+
return kind && result && __defProp$2(target, key2, result), result;
|
|
626
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$2");
|
|
627
|
+
const createCollectEffectMutation = /* @__PURE__ */ __name(() => {
|
|
628
|
+
let list = [];
|
|
639
629
|
return {
|
|
640
|
-
add: (
|
|
641
|
-
getEffects: () =>
|
|
642
|
-
clean: () => {
|
|
643
|
-
|
|
644
|
-
}
|
|
630
|
+
add: /* @__PURE__ */ __name((unitId, subUnitId, row, col, value) => list.push({ unitId, subUnitId, row, col, value }), "add"),
|
|
631
|
+
getEffects: /* @__PURE__ */ __name(() => list, "getEffects"),
|
|
632
|
+
clean: /* @__PURE__ */ __name(() => {
|
|
633
|
+
list = [];
|
|
634
|
+
}, "clean")
|
|
645
635
|
};
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
|
|
636
|
+
}, "createCollectEffectMutation");
|
|
637
|
+
var _a4;
|
|
638
|
+
let NumfmtEditorController = (_a4 = class extends Disposable {
|
|
639
|
+
constructor(_sheetInterceptorService, _numfmtService, _univerInstanceService, _injector, _editorBridgeService) {
|
|
649
640
|
super();
|
|
650
641
|
// collect effect mutations when edit end and push this to commands stack in next commands progress
|
|
651
|
-
|
|
652
|
-
this._sheetInterceptorService =
|
|
642
|
+
__publicField(this, "_collectEffectMutation", createCollectEffectMutation());
|
|
643
|
+
this._sheetInterceptorService = _sheetInterceptorService, this._numfmtService = _numfmtService, this._univerInstanceService = _univerInstanceService, this._injector = _injector, this._editorBridgeService = _editorBridgeService, this._initInterceptorEditorStart(), this._initInterceptorEditorEnd(), this._initInterceptorCommands();
|
|
653
644
|
}
|
|
654
645
|
_initInterceptorEditorStart() {
|
|
655
646
|
this._editorBridgeService && this.disposeWithMe(
|
|
656
|
-
|
|
647
|
+
toDisposable(
|
|
657
648
|
this._sheetInterceptorService.writeCellInterceptor.intercept(
|
|
658
|
-
|
|
649
|
+
BEFORE_CELL_EDIT,
|
|
659
650
|
{
|
|
660
|
-
handler: (
|
|
661
|
-
const
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
651
|
+
handler: /* @__PURE__ */ __name((value, context, next) => {
|
|
652
|
+
const row = context.row, col = context.col, numfmtCell = this._numfmtService.getValue(
|
|
653
|
+
context.unitId,
|
|
654
|
+
context.subUnitId,
|
|
655
|
+
row,
|
|
656
|
+
col
|
|
666
657
|
);
|
|
667
|
-
if (
|
|
668
|
-
switch (
|
|
658
|
+
if (numfmtCell)
|
|
659
|
+
switch (getPatternType(numfmtCell.pattern)) {
|
|
669
660
|
case "scientific":
|
|
670
661
|
case "currency":
|
|
671
662
|
case "grouped":
|
|
672
|
-
case "number":
|
|
673
|
-
|
|
663
|
+
case "number": {
|
|
664
|
+
const cell = context.worksheet.getCellRaw(row, col);
|
|
665
|
+
return next && next(cell);
|
|
666
|
+
}
|
|
674
667
|
case "percent":
|
|
675
668
|
case "date":
|
|
676
669
|
case "time":
|
|
677
670
|
case "datetime":
|
|
678
671
|
default:
|
|
679
|
-
return
|
|
672
|
+
return next && next(value);
|
|
680
673
|
}
|
|
681
|
-
return
|
|
682
|
-
}
|
|
674
|
+
return next(value);
|
|
675
|
+
}, "handler")
|
|
683
676
|
}
|
|
684
677
|
)
|
|
685
678
|
)
|
|
@@ -692,115 +685,115 @@ let re = class extends oe {
|
|
|
692
685
|
*/
|
|
693
686
|
_initInterceptorEditorEnd() {
|
|
694
687
|
this.disposeWithMe(
|
|
695
|
-
|
|
688
|
+
toDisposable(
|
|
696
689
|
this._sheetInterceptorService.writeCellInterceptor.intercept(
|
|
697
|
-
|
|
690
|
+
AFTER_CELL_EDIT,
|
|
698
691
|
{
|
|
699
692
|
// eslint-disable-next-line complexity
|
|
700
|
-
handler: (
|
|
701
|
-
var
|
|
693
|
+
handler: /* @__PURE__ */ __name((value, context, next) => {
|
|
694
|
+
var _a7, _b, _c, _d;
|
|
702
695
|
this._collectEffectMutation.clean();
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
),
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
696
|
+
const currentNumfmtValue = this._numfmtService.getValue(
|
|
697
|
+
context.unitId,
|
|
698
|
+
context.subUnitId,
|
|
699
|
+
context.row,
|
|
700
|
+
context.col
|
|
701
|
+
), currentNumfmtType = (_a7 = currentNumfmtValue && getPatternType(currentNumfmtValue.pattern)) != null ? _a7 : "", clean = /* @__PURE__ */ __name(() => {
|
|
702
|
+
currentNumfmtValue && this._collectEffectMutation.add(
|
|
703
|
+
context.unitId,
|
|
704
|
+
context.subUnitId,
|
|
705
|
+
context.row,
|
|
706
|
+
context.col,
|
|
714
707
|
null
|
|
715
708
|
);
|
|
716
|
-
};
|
|
717
|
-
if (!(
|
|
718
|
-
return
|
|
719
|
-
const
|
|
720
|
-
if (
|
|
721
|
-
if (
|
|
722
|
-
const { dataStream
|
|
723
|
-
if (Number.isNaN(
|
|
724
|
-
return
|
|
709
|
+
}, "clean");
|
|
710
|
+
if (!(value != null && value.v) && !(value != null && value.p) || (currentNumfmtValue == null ? void 0 : currentNumfmtValue.pattern) === DEFAULT_TEXT_FORMAT || value.t === CellValueType.FORCE_STRING)
|
|
711
|
+
return next(value);
|
|
712
|
+
const body = (_b = value.p) == null ? void 0 : _b.body, content = (_d = (_c = value == null ? void 0 : value.p) == null ? void 0 : _c.body) != null && _d.dataStream ? value.p.body.dataStream.replace(/\r\n$/, "") : String(value.v), numfmtInfo = numfmt.parseDate(content) || numfmt.parseTime(content) || numfmt.parseNumber(content);
|
|
713
|
+
if (body)
|
|
714
|
+
if (canConvertRichTextToNumfmt(body)) {
|
|
715
|
+
const { dataStream } = body, dataStreamWithoutEnd = dataStream.replace(/\r\n$/, ""), num = Number(dataStreamWithoutEnd);
|
|
716
|
+
if (Number.isNaN(num) && !numfmtInfo)
|
|
717
|
+
return next(value);
|
|
725
718
|
} else
|
|
726
|
-
return
|
|
727
|
-
if (
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
719
|
+
return next(value);
|
|
720
|
+
if (numfmtInfo) {
|
|
721
|
+
numfmtInfo.z && this._collectEffectMutation.add(
|
|
722
|
+
context.unitId,
|
|
723
|
+
context.subUnitId,
|
|
724
|
+
context.row,
|
|
725
|
+
context.col,
|
|
733
726
|
{
|
|
734
|
-
pattern:
|
|
727
|
+
pattern: numfmtInfo.z
|
|
735
728
|
}
|
|
736
729
|
);
|
|
737
|
-
const v = Number(
|
|
738
|
-
return
|
|
739
|
-
} else (["date", "time", "datetime", "percent"].includes(
|
|
740
|
-
return
|
|
741
|
-
}
|
|
730
|
+
const v = Number(numfmtInfo.v);
|
|
731
|
+
return next({ ...value, p: void 0, v, t: CellValueType.NUMBER });
|
|
732
|
+
} else (["date", "time", "datetime", "percent"].includes(currentNumfmtType) || !isNumeric(content)) && clean();
|
|
733
|
+
return next(value);
|
|
734
|
+
}, "handler")
|
|
742
735
|
}
|
|
743
736
|
)
|
|
744
737
|
)
|
|
745
738
|
);
|
|
746
739
|
}
|
|
747
740
|
_initInterceptorCommands() {
|
|
748
|
-
const
|
|
741
|
+
const self = this;
|
|
749
742
|
this.disposeWithMe(
|
|
750
743
|
this._sheetInterceptorService.interceptCommand({
|
|
751
|
-
getMutations(
|
|
752
|
-
var
|
|
753
|
-
switch (
|
|
754
|
-
case
|
|
755
|
-
const
|
|
756
|
-
if (!
|
|
744
|
+
getMutations(command) {
|
|
745
|
+
var _a7;
|
|
746
|
+
switch (command.id) {
|
|
747
|
+
case SetRangeValuesCommand.id: {
|
|
748
|
+
const workbook = self._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), subUnitId = (_a7 = workbook.getActiveSheet()) == null ? void 0 : _a7.getSheetId();
|
|
749
|
+
if (!subUnitId)
|
|
757
750
|
return {
|
|
758
751
|
redos: [],
|
|
759
752
|
undos: []
|
|
760
753
|
};
|
|
761
|
-
const
|
|
762
|
-
if (
|
|
754
|
+
const list = self._collectEffectMutation.getEffects();
|
|
755
|
+
if (self._collectEffectMutation.clean(), !list.length)
|
|
763
756
|
return {
|
|
764
757
|
redos: [],
|
|
765
758
|
undos: []
|
|
766
759
|
};
|
|
767
|
-
const
|
|
768
|
-
var
|
|
769
|
-
return !!((
|
|
770
|
-
}).map((
|
|
771
|
-
row:
|
|
772
|
-
col:
|
|
773
|
-
pattern:
|
|
774
|
-
})),
|
|
775
|
-
var
|
|
776
|
-
return !((
|
|
777
|
-
}).map((
|
|
778
|
-
startRow:
|
|
779
|
-
endColumn:
|
|
780
|
-
startColumn:
|
|
781
|
-
endRow:
|
|
782
|
-
})),
|
|
783
|
-
if (
|
|
784
|
-
const
|
|
785
|
-
id:
|
|
786
|
-
params:
|
|
760
|
+
const cells = list.filter((item) => {
|
|
761
|
+
var _a8;
|
|
762
|
+
return !!((_a8 = item.value) != null && _a8.pattern);
|
|
763
|
+
}).map((item) => ({
|
|
764
|
+
row: item.row,
|
|
765
|
+
col: item.col,
|
|
766
|
+
pattern: item.value.pattern
|
|
767
|
+
})), removeCells = list.filter((item) => {
|
|
768
|
+
var _a8;
|
|
769
|
+
return !((_a8 = item.value) != null && _a8.pattern);
|
|
770
|
+
}).map((item) => ({
|
|
771
|
+
startRow: item.row,
|
|
772
|
+
endColumn: item.col,
|
|
773
|
+
startColumn: item.col,
|
|
774
|
+
endRow: item.row
|
|
775
|
+
})), redos = [], undos = [];
|
|
776
|
+
if (cells.length) {
|
|
777
|
+
const redo = {
|
|
778
|
+
id: SetNumfmtMutation.id,
|
|
779
|
+
params: transformCellsToRange(unitId, subUnitId, cells)
|
|
787
780
|
};
|
|
788
|
-
|
|
781
|
+
redos.push(redo), undos.push(...factorySetNumfmtUndoMutation(self._injector, redo.params));
|
|
789
782
|
}
|
|
790
|
-
if (
|
|
791
|
-
const
|
|
792
|
-
id:
|
|
783
|
+
if (removeCells.length) {
|
|
784
|
+
const redo = {
|
|
785
|
+
id: RemoveNumfmtMutation.id,
|
|
793
786
|
params: {
|
|
794
|
-
unitId
|
|
795
|
-
subUnitId
|
|
796
|
-
ranges:
|
|
787
|
+
unitId,
|
|
788
|
+
subUnitId,
|
|
789
|
+
ranges: removeCells
|
|
797
790
|
}
|
|
798
791
|
};
|
|
799
|
-
|
|
792
|
+
redos.push(redo), undos.push(...factoryRemoveNumfmtUndoMutation(self._injector, redo.params));
|
|
800
793
|
}
|
|
801
794
|
return {
|
|
802
|
-
redos
|
|
803
|
-
undos:
|
|
795
|
+
redos,
|
|
796
|
+
undos: undos.reverse()
|
|
804
797
|
};
|
|
805
798
|
}
|
|
806
799
|
}
|
|
@@ -812,29 +805,31 @@ let re = class extends oe {
|
|
|
812
805
|
})
|
|
813
806
|
);
|
|
814
807
|
}
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
],
|
|
823
|
-
function
|
|
824
|
-
return /^-?\d+(\.\d+)?$/.test(
|
|
808
|
+
}, __name(_a4, "NumfmtEditorController"), _a4);
|
|
809
|
+
NumfmtEditorController = __decorateClass$2([
|
|
810
|
+
__decorateParam$2(0, Inject(SheetInterceptorService)),
|
|
811
|
+
__decorateParam$2(1, Inject(INumfmtService)),
|
|
812
|
+
__decorateParam$2(2, Inject(IUniverInstanceService)),
|
|
813
|
+
__decorateParam$2(3, Inject(Injector)),
|
|
814
|
+
__decorateParam$2(4, Optional(IEditorBridgeService))
|
|
815
|
+
], NumfmtEditorController);
|
|
816
|
+
function isNumeric(str) {
|
|
817
|
+
return /^-?\d+(\.\d+)?$/.test(str);
|
|
825
818
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
819
|
+
__name(isNumeric, "isNumeric");
|
|
820
|
+
function canConvertRichTextToNumfmt(body) {
|
|
821
|
+
const { textRuns = [], paragraphs = [], customRanges, customBlocks = [] } = body, richTextStyle = ["va"];
|
|
822
|
+
return !(textRuns.some((textRun) => !!(textRun.ts && Object.keys(textRun.ts).some((property) => richTextStyle.includes(property)))) || paragraphs.some((paragraph) => paragraph.bullet) || paragraphs.length >= 2 || customRanges != null && customRanges.length || customBlocks.length > 0);
|
|
829
823
|
}
|
|
830
|
-
|
|
824
|
+
__name(canConvertRichTextToNumfmt, "canConvertRichTextToNumfmt");
|
|
825
|
+
const MENU_OPTIONS = [
|
|
831
826
|
{
|
|
832
827
|
label: "sheet.numfmt.general",
|
|
833
828
|
pattern: null
|
|
834
829
|
},
|
|
835
830
|
{
|
|
836
831
|
label: "sheet.numfmt.text",
|
|
837
|
-
pattern:
|
|
832
|
+
pattern: DEFAULT_TEXT_FORMAT
|
|
838
833
|
},
|
|
839
834
|
"|",
|
|
840
835
|
{
|
|
@@ -880,223 +875,223 @@ const ee = [
|
|
|
880
875
|
label: "sheet.numfmt.moreFmt",
|
|
881
876
|
pattern: ""
|
|
882
877
|
}
|
|
883
|
-
],
|
|
884
|
-
icon: new
|
|
885
|
-
const
|
|
886
|
-
function
|
|
878
|
+
], CurrencyMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
879
|
+
icon: new Observable((subscribe) => {
|
|
880
|
+
const menuCurrencyService = accessor.get(MenuCurrencyService);
|
|
881
|
+
function getIconKey(symbol2) {
|
|
887
882
|
return {
|
|
888
|
-
[
|
|
889
|
-
[
|
|
890
|
-
[
|
|
891
|
-
[
|
|
892
|
-
}[
|
|
883
|
+
[countryCurrencyMap.US]: "DollarSingle",
|
|
884
|
+
[countryCurrencyMap.RU]: "RoubleSingle",
|
|
885
|
+
[countryCurrencyMap.CN]: "RmbSingle",
|
|
886
|
+
[countryCurrencyMap.AT]: "EuroSingle"
|
|
887
|
+
}[symbol2] || "DollarSingle";
|
|
893
888
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
889
|
+
__name(getIconKey, "getIconKey");
|
|
890
|
+
const symbol = countryCurrencyMap[menuCurrencyService.getCurrencySymbol()] || "$";
|
|
891
|
+
return subscribe.next(getIconKey(symbol)), menuCurrencyService.currencySymbol$.subscribe((code) => {
|
|
892
|
+
const symbol2 = countryCurrencyMap[code] || "$";
|
|
893
|
+
subscribe.next(getIconKey(symbol2));
|
|
898
894
|
});
|
|
899
895
|
}),
|
|
900
|
-
id:
|
|
896
|
+
id: SetCurrencyCommand.id,
|
|
901
897
|
title: "sheet.numfmt.currency",
|
|
902
898
|
tooltip: "sheet.numfmt.currency",
|
|
903
|
-
type:
|
|
904
|
-
hidden$:
|
|
905
|
-
disabled$:
|
|
906
|
-
}),
|
|
899
|
+
type: MenuItemType.BUTTON,
|
|
900
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
901
|
+
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
902
|
+
}), "CurrencyMenuItem"), AddDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
907
903
|
icon: "AddDigitsSingle",
|
|
908
|
-
id:
|
|
904
|
+
id: AddDecimalCommand.id,
|
|
909
905
|
title: "sheet.numfmt.addDecimal",
|
|
910
906
|
tooltip: "sheet.numfmt.addDecimal",
|
|
911
|
-
type:
|
|
912
|
-
hidden$:
|
|
913
|
-
disabled$:
|
|
914
|
-
}),
|
|
907
|
+
type: MenuItemType.BUTTON,
|
|
908
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
909
|
+
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
910
|
+
}), "AddDecimalMenuItem"), SubtractDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
915
911
|
icon: "ReduceDigitsSingle",
|
|
916
|
-
id:
|
|
912
|
+
id: SubtractDecimalCommand.id,
|
|
917
913
|
title: "sheet.numfmt.subtractDecimal",
|
|
918
914
|
tooltip: "sheet.numfmt.subtractDecimal",
|
|
919
|
-
type:
|
|
920
|
-
hidden$:
|
|
921
|
-
disabled$:
|
|
922
|
-
}),
|
|
915
|
+
type: MenuItemType.BUTTON,
|
|
916
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
917
|
+
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
918
|
+
}), "SubtractDecimalMenuItem"), PercentMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
923
919
|
icon: "PercentSingle",
|
|
924
|
-
id:
|
|
920
|
+
id: SetPercentCommand.id,
|
|
925
921
|
title: "sheet.numfmt.percent",
|
|
926
922
|
tooltip: "sheet.numfmt.percent",
|
|
927
|
-
type:
|
|
928
|
-
hidden$:
|
|
929
|
-
disabled$:
|
|
930
|
-
}),
|
|
931
|
-
const
|
|
932
|
-
(
|
|
933
|
-
|
|
934
|
-
new
|
|
935
|
-
const
|
|
936
|
-
|
|
923
|
+
type: MenuItemType.BUTTON,
|
|
924
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
925
|
+
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
926
|
+
}), "PercentMenuItem"), FactoryOtherMenuItem = /* @__PURE__ */ __name((accessor) => {
|
|
927
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), localeService = accessor.get(LocaleService), selectionManagerService = accessor.get(SheetsSelectionsService), value$ = deriveStateFromActiveSheet$(univerInstanceService, "", ({ workbook, worksheet }) => new Observable(
|
|
928
|
+
(subscribe) => merge(
|
|
929
|
+
selectionManagerService.selectionMoveEnd$,
|
|
930
|
+
new Observable((commandSubscribe) => {
|
|
931
|
+
const commandList = [RemoveNumfmtMutation.id, SetNumfmtMutation.id], disposable = commandService.onCommandExecuted((commandInfo) => {
|
|
932
|
+
commandList.includes(commandInfo.id) && commandSubscribe.next(null);
|
|
937
933
|
});
|
|
938
|
-
return () =>
|
|
934
|
+
return () => disposable.dispose();
|
|
939
935
|
})
|
|
940
936
|
).subscribe(() => {
|
|
941
|
-
var
|
|
942
|
-
const
|
|
943
|
-
if (
|
|
944
|
-
const
|
|
945
|
-
let
|
|
946
|
-
if (
|
|
947
|
-
const
|
|
948
|
-
(
|
|
937
|
+
var _a7, _b;
|
|
938
|
+
const selections = selectionManagerService.getCurrentSelections();
|
|
939
|
+
if (selections && selections[0]) {
|
|
940
|
+
const range = selections[0].range, row = range.startRow, col = range.startColumn, numfmtValue = (_b = workbook.getStyles().get((_a7 = worksheet.getCell(row, col)) == null ? void 0 : _a7.s)) == null ? void 0 : _b.n, pattern = numfmtValue == null ? void 0 : numfmtValue.pattern;
|
|
941
|
+
let value = localeService.t("sheet.numfmt.general");
|
|
942
|
+
if (pattern) {
|
|
943
|
+
const item = MENU_OPTIONS.filter((item2) => typeof item2 == "object" && item2.pattern).find(
|
|
944
|
+
(item2) => isPatternEqualWithoutDecimal(pattern, item2.pattern)
|
|
949
945
|
);
|
|
950
|
-
|
|
946
|
+
item && typeof item == "object" && item.pattern ? value = localeService.t(item.label) : value = localeService.t("sheet.numfmt.moreFmt");
|
|
951
947
|
}
|
|
952
|
-
|
|
948
|
+
subscribe.next(value);
|
|
953
949
|
}
|
|
954
950
|
})
|
|
955
951
|
));
|
|
956
952
|
return {
|
|
957
|
-
label:
|
|
958
|
-
id:
|
|
953
|
+
label: MORE_NUMFMT_TYPE_KEY,
|
|
954
|
+
id: OpenNumfmtPanelOperator.id,
|
|
959
955
|
tooltip: "sheet.numfmt.title",
|
|
960
|
-
type:
|
|
956
|
+
type: MenuItemType.SELECTOR,
|
|
961
957
|
selections: [
|
|
962
958
|
{
|
|
963
959
|
label: {
|
|
964
|
-
name:
|
|
960
|
+
name: OPTIONS_KEY,
|
|
965
961
|
hoverable: !1
|
|
966
962
|
}
|
|
967
963
|
}
|
|
968
964
|
],
|
|
969
|
-
value
|
|
970
|
-
hidden$:
|
|
971
|
-
disabled$:
|
|
965
|
+
value$,
|
|
966
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
967
|
+
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
972
968
|
};
|
|
973
|
-
},
|
|
974
|
-
var
|
|
975
|
-
const
|
|
976
|
-
return /* @__PURE__ */
|
|
977
|
-
},
|
|
978
|
-
const
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
const a = r.getCurrentLastSelection();
|
|
982
|
-
if (!a)
|
|
969
|
+
}, "FactoryOtherMenuItem"), MORE_NUMFMT_TYPE_KEY = "sheet.numfmt.moreNumfmtType", OPTIONS_KEY = "sheet.numfmt.moreNumfmtType.options", MoreNumfmtType = /* @__PURE__ */ __name((props) => {
|
|
970
|
+
var _a7;
|
|
971
|
+
const localeService = useDependency(LocaleService), value = (_a7 = props.value) != null ? _a7 : localeService.t("sheet.numfmt.general");
|
|
972
|
+
return /* @__PURE__ */ jsx("span", { className: "more-numfmt-type", children: value });
|
|
973
|
+
}, "MoreNumfmtType"), Options = /* @__PURE__ */ __name(() => {
|
|
974
|
+
const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), layoutService = useDependency(ILayoutService), sheetsNumfmtCellContentController = useDependency(SheetsNumfmtCellContentController), selectionManagerService = useDependency(SheetsSelectionsService), setNumfmt = /* @__PURE__ */ __name((pattern) => {
|
|
975
|
+
const selection = selectionManagerService.getCurrentLastSelection();
|
|
976
|
+
if (!selection)
|
|
983
977
|
return;
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
}),
|
|
988
|
-
},
|
|
989
|
-
if (
|
|
990
|
-
|
|
991
|
-
else if (
|
|
992
|
-
|
|
978
|
+
const range = selection.range, values = [];
|
|
979
|
+
Range.foreach(range, (row, col) => {
|
|
980
|
+
pattern ? values.push({ row, col, pattern, type: getPatternType(pattern) }) : values.push({ row, col });
|
|
981
|
+
}), commandService.executeCommand(SetNumfmtCommand.id, { values }), layoutService.focus();
|
|
982
|
+
}, "setNumfmt"), handleOnclick = /* @__PURE__ */ __name((index) => {
|
|
983
|
+
if (index === 0)
|
|
984
|
+
setNumfmt(null);
|
|
985
|
+
else if (index === MENU_OPTIONS.length - 1)
|
|
986
|
+
commandService.executeCommand(OpenNumfmtPanelOperator.id);
|
|
993
987
|
else {
|
|
994
|
-
const
|
|
995
|
-
|
|
988
|
+
const item = MENU_OPTIONS[index];
|
|
989
|
+
item.pattern && setNumfmt(item.pattern);
|
|
996
990
|
}
|
|
997
|
-
},
|
|
998
|
-
return /* @__PURE__ */
|
|
991
|
+
}, "handleOnclick"), defaultValue = 1220;
|
|
992
|
+
return /* @__PURE__ */ jsx("div", { className: "more-numfmt-type-options", children: MENU_OPTIONS.map((item, index) => item === "|" ? /* @__PURE__ */ jsx("div", { className: "line m-t-4", onClick: /* @__PURE__ */ __name((e) => e.stopPropagation(), "onClick") }, index) : /* @__PURE__ */ jsxs(
|
|
999
993
|
"div",
|
|
1000
994
|
{
|
|
1001
995
|
className: "option-item m-t-4",
|
|
1002
|
-
onClick: () => {
|
|
1003
|
-
|
|
1004
|
-
},
|
|
996
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
997
|
+
handleOnclick(index);
|
|
998
|
+
}, "onClick"),
|
|
1005
999
|
children: [
|
|
1006
|
-
/* @__PURE__ */
|
|
1007
|
-
/* @__PURE__ */
|
|
1000
|
+
/* @__PURE__ */ jsx("div", { children: localeService.t(item.label) }),
|
|
1001
|
+
/* @__PURE__ */ jsx("div", { className: "m-l-26", children: item.pattern ? getPatternPreview(item.pattern || "", defaultValue, sheetsNumfmtCellContentController.local).result : "" })
|
|
1008
1002
|
]
|
|
1009
1003
|
},
|
|
1010
|
-
|
|
1004
|
+
index
|
|
1011
1005
|
)) });
|
|
1012
|
-
},
|
|
1013
|
-
[
|
|
1014
|
-
[
|
|
1006
|
+
}, "Options"), menuSchema = {
|
|
1007
|
+
[RibbonStartGroup.FORMULAS_INSERT]: {
|
|
1008
|
+
[SetCurrencyCommand.id]: {
|
|
1015
1009
|
order: 4,
|
|
1016
|
-
menuItemFactory:
|
|
1010
|
+
menuItemFactory: CurrencyMenuItem
|
|
1017
1011
|
},
|
|
1018
|
-
[
|
|
1012
|
+
[AddDecimalCommand.id]: {
|
|
1019
1013
|
order: 5,
|
|
1020
|
-
menuItemFactory:
|
|
1014
|
+
menuItemFactory: AddDecimalMenuItem
|
|
1021
1015
|
},
|
|
1022
|
-
[
|
|
1016
|
+
[SubtractDecimalCommand.id]: {
|
|
1023
1017
|
order: 6,
|
|
1024
|
-
menuItemFactory:
|
|
1018
|
+
menuItemFactory: SubtractDecimalMenuItem
|
|
1025
1019
|
},
|
|
1026
|
-
[
|
|
1020
|
+
[SetPercentCommand.id]: {
|
|
1027
1021
|
order: 7,
|
|
1028
|
-
menuItemFactory:
|
|
1022
|
+
menuItemFactory: PercentMenuItem
|
|
1029
1023
|
},
|
|
1030
|
-
[
|
|
1024
|
+
[OpenNumfmtPanelOperator.id]: {
|
|
1031
1025
|
order: 8,
|
|
1032
|
-
menuItemFactory:
|
|
1026
|
+
menuItemFactory: FactoryOtherMenuItem
|
|
1033
1027
|
}
|
|
1034
1028
|
}
|
|
1035
1029
|
};
|
|
1036
|
-
var
|
|
1037
|
-
for (var
|
|
1038
|
-
(
|
|
1039
|
-
return
|
|
1040
|
-
},
|
|
1041
|
-
let
|
|
1042
|
-
constructor(
|
|
1043
|
-
super(), this._componentManager =
|
|
1030
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1031
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1032
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1033
|
+
return kind && result && __defProp$1(target, key2, result), result;
|
|
1034
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$1"), _a5;
|
|
1035
|
+
let NumfmtMenuController = (_a5 = class extends Disposable {
|
|
1036
|
+
constructor(_componentManager, _menuManagerService) {
|
|
1037
|
+
super(), this._componentManager = _componentManager, this._menuManagerService = _menuManagerService, this._initMenu();
|
|
1044
1038
|
}
|
|
1045
1039
|
_initMenu() {
|
|
1046
|
-
this._menuManagerService.mergeMenu(
|
|
1040
|
+
this._menuManagerService.mergeMenu(menuSchema), this.disposeWithMe(this._componentManager.register(MORE_NUMFMT_TYPE_KEY, MoreNumfmtType)), this.disposeWithMe(this._componentManager.register(OPTIONS_KEY, Options));
|
|
1047
1041
|
}
|
|
1048
|
-
};
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
],
|
|
1053
|
-
var
|
|
1054
|
-
for (var
|
|
1055
|
-
(
|
|
1056
|
-
return
|
|
1057
|
-
},
|
|
1058
|
-
const
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1042
|
+
}, __name(_a5, "NumfmtMenuController"), _a5);
|
|
1043
|
+
NumfmtMenuController = __decorateClass$1([
|
|
1044
|
+
__decorateParam$1(0, Inject(ComponentManager)),
|
|
1045
|
+
__decorateParam$1(1, IMenuManagerService)
|
|
1046
|
+
], NumfmtMenuController);
|
|
1047
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key2, value) => key2 in obj ? __defProp2(obj, key2, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key2] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1048
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1049
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1050
|
+
return kind && result && __defProp2(target, key2, result), result;
|
|
1051
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key2, value) => __defNormalProp2(obj, typeof key2 != "symbol" ? key2 + "" : key2, value), "__publicField");
|
|
1052
|
+
const SHEET_NUMFMT_UI_PLUGIN = "SHEET_NUMFMT_UI_PLUGIN";
|
|
1053
|
+
var _a6;
|
|
1054
|
+
let UniverSheetsNumfmtUIPlugin = (_a6 = class extends Plugin {
|
|
1055
|
+
constructor(_config = defaultPluginConfig, _injector, _configService, _renderManagerService) {
|
|
1056
|
+
super(), this._config = _config, this._injector = _injector, this._configService = _configService, this._renderManagerService = _renderManagerService;
|
|
1057
|
+
const { menu, ...rest } = merge$1(
|
|
1063
1058
|
{},
|
|
1064
|
-
|
|
1059
|
+
defaultPluginConfig,
|
|
1065
1060
|
this._config
|
|
1066
1061
|
);
|
|
1067
|
-
|
|
1062
|
+
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(UI_PLUGIN_CONFIG_KEY, rest);
|
|
1068
1063
|
}
|
|
1069
1064
|
onStarting() {
|
|
1070
|
-
|
|
1071
|
-
[
|
|
1072
|
-
[
|
|
1073
|
-
[
|
|
1074
|
-
[
|
|
1065
|
+
registerDependencies(this._injector, [
|
|
1066
|
+
[SheetNumfmtUIController],
|
|
1067
|
+
[NumfmtEditorController],
|
|
1068
|
+
[UserHabitController],
|
|
1069
|
+
[NumfmtMenuController]
|
|
1075
1070
|
]);
|
|
1076
1071
|
}
|
|
1077
1072
|
onRendered() {
|
|
1078
|
-
this._registerRenderModules(),
|
|
1079
|
-
[
|
|
1080
|
-
[
|
|
1081
|
-
[
|
|
1073
|
+
this._registerRenderModules(), touchDependencies(this._injector, [
|
|
1074
|
+
[SheetNumfmtUIController],
|
|
1075
|
+
[NumfmtEditorController],
|
|
1076
|
+
[NumfmtMenuController]
|
|
1082
1077
|
]);
|
|
1083
1078
|
}
|
|
1084
1079
|
_registerRenderModules() {
|
|
1085
1080
|
[
|
|
1086
|
-
[
|
|
1087
|
-
].forEach((
|
|
1088
|
-
this.disposeWithMe(this._renderManagerService.registerRenderModule(
|
|
1081
|
+
[NumfmtAlertRenderController]
|
|
1082
|
+
].forEach((m) => {
|
|
1083
|
+
this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, m));
|
|
1089
1084
|
});
|
|
1090
1085
|
}
|
|
1091
|
-
};
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
],
|
|
1086
|
+
}, __name(_a6, "UniverSheetsNumfmtUIPlugin"), _a6);
|
|
1087
|
+
__publicField2(UniverSheetsNumfmtUIPlugin, "pluginName", SHEET_NUMFMT_UI_PLUGIN);
|
|
1088
|
+
__publicField2(UniverSheetsNumfmtUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
1089
|
+
UniverSheetsNumfmtUIPlugin = __decorateClass([
|
|
1090
|
+
DependentOn(UniverSheetsUIPlugin, UniverSheetsNumfmtPlugin),
|
|
1091
|
+
__decorateParam(1, Inject(Injector)),
|
|
1092
|
+
__decorateParam(2, IConfigService),
|
|
1093
|
+
__decorateParam(3, IRenderManagerService)
|
|
1094
|
+
], UniverSheetsNumfmtUIPlugin);
|
|
1100
1095
|
export {
|
|
1101
|
-
|
|
1096
|
+
UniverSheetsNumfmtUIPlugin
|
|
1102
1097
|
};
|