@univerjs/sheets-numfmt 0.4.2 → 0.5.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/lib/cjs/facade.js +1 -0
- package/lib/cjs/index.js +1 -9
- package/lib/es/facade.js +12 -0
- package/lib/es/index.js +361 -1311
- package/lib/types/{controllers/__tests__/editor.controller.spec.d.ts → facade/f-range.d.ts} +12 -0
- package/lib/types/{controllers/__tests__/cell-content.controller.spec.d.ts → facade/index.d.ts} +1 -1
- package/lib/types/index.d.ts +7 -3
- package/lib/types/numfmt-plugin.d.ts +3 -4
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +1 -9
- package/package.json +26 -26
- package/lib/index.css +0 -1
- package/lib/locale/en-US.json +0 -38
- package/lib/locale/fa-IR.json +0 -38
- package/lib/locale/ru-RU.json +0 -38
- package/lib/locale/vi-VN.json +0 -38
- package/lib/locale/zh-CN.json +0 -38
- package/lib/locale/zh-TW.json +0 -38
- package/lib/types/base/const/MENU-OPTIONS.d.ts +0 -19
- package/lib/types/base/types/index.d.ts +0 -7
- package/lib/types/commands/operations/close.numfmt.panel.operation.d.ts +0 -2
- package/lib/types/commands/operations/open.numfmt.panel.operation.d.ts +0 -2
- package/lib/types/components/accounting/index.d.ts +0 -4
- package/lib/types/components/currency/index.d.ts +0 -4
- package/lib/types/components/custom-format/index.d.ts +0 -3
- package/lib/types/components/date/index.d.ts +0 -4
- package/lib/types/components/general/index.d.ts +0 -4
- package/lib/types/components/index.d.ts +0 -14
- package/lib/types/components/more-numfmt-type/MoreNumfmtType.d.ts +0 -7
- package/lib/types/components/stories/Panel.stories.d.ts +0 -5
- package/lib/types/components/thousandth-percentile/index.d.ts +0 -4
- package/lib/types/context/user-habit.d.ts +0 -16
- package/lib/types/controllers/__tests__/test.util.d.ts +0 -15
- package/lib/types/controllers/config.schema.d.ts +0 -7
- package/lib/types/controllers/menu.schema.d.ts +0 -2
- package/lib/types/controllers/numfmt.controller.d.ts +0 -33
- package/lib/types/controllers/numfmt.editor.controller.d.ts +0 -20
- package/lib/types/controllers/numfmt.menu.controller.d.ts +0 -8
- package/lib/types/controllers/user-habit.controller.d.ts +0 -18
- package/lib/types/hooks/useCurrencyOptions.d.ts +0 -19
- package/lib/types/hooks/useNextTick.d.ts +0 -16
- package/lib/types/locale/en-US.d.ts +0 -3
- package/lib/types/locale/fa-IR.d.ts +0 -3
- package/lib/types/locale/ru-RU.d.ts +0 -3
- package/lib/types/locale/vi-VN.d.ts +0 -3
- package/lib/types/locale/zh-CN.d.ts +0 -54
- package/lib/types/locale/zh-TW.d.ts +0 -3
- package/lib/types/menu/menu.d.ts +0 -40
- /package/lib/types/controllers/{numfmt.cell-content.controller.d.ts → numfmt-cell-content.controller.d.ts} +0 -0
- /package/lib/types/controllers/{numfmt.currency.controller.d.ts → numfmt-currency.controller.d.ts} +0 -0
package/lib/es/index.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { switchMap, of, skip, BehaviorSubject, Observable, combineLatest, merge } from "rxjs";
|
|
9
|
-
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
10
|
-
import { ComponentManager, ISidebarService, ILayoutService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, IMenuManagerService } from "@univerjs/ui";
|
|
11
|
-
import { map, switchMap as switchMap$1, tap, debounceTime } from "rxjs/operators";
|
|
12
|
-
import require$$0, { createContext, useState, useEffect, useRef, useContext, useMemo, forwardRef, createElement } from "react";
|
|
13
|
-
import { InputNumber, Select, SelectList, Input, Button } from "@univerjs/design";
|
|
14
|
-
import { DEFAULT_TEXT_FORMAT } from "@univerjs/engine-numfmt";
|
|
15
|
-
const currencySymbols = [
|
|
1
|
+
var te = Object.defineProperty;
|
|
2
|
+
var ne = (e, t, n) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var N = (e, t, n) => ne(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { numfmt as $, CommandType as E, ICommandService as b, IUniverInstanceService as D, IUndoRedoService as re, sequenceExecute as se, Range as C, CellValueType as V, LocaleType as oe, Inject as M, ThemeService as ce, LocaleService as ie, Disposable as K, ObjectMatrix as F, InterceptorEffectEnum as B, UniverInstanceType as Y, DependentOn as ae, Injector as le, Plugin as ue, registerDependencies as me, touchDependencies as L } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as w, transformCellsToRange as fe, rangeMerge as G, SetNumfmtMutation as z, factorySetNumfmtUndoMutation as de, RemoveNumfmtMutation as he, factoryRemoveNumfmtUndoMutation as ge, SheetsSelectionsService as O, INumfmtService as A, SheetInterceptorService as ve, INTERCEPTOR_POINT as pe, InterceptCellContentPriority as Se, SetRangeValuesMutation as ye, UniverSheetsPlugin as Ce } from "@univerjs/sheets";
|
|
6
|
+
import { BehaviorSubject as J, switchMap as be, of as _e, skip as Me } from "rxjs";
|
|
7
|
+
const Z = [
|
|
16
8
|
"$",
|
|
17
9
|
"£",
|
|
18
10
|
"¥",
|
|
@@ -40,7 +32,7 @@ const currencySymbols = [
|
|
|
40
32
|
"₽",
|
|
41
33
|
"₾",
|
|
42
34
|
"₿"
|
|
43
|
-
],
|
|
35
|
+
], $e = {
|
|
44
36
|
US: "$",
|
|
45
37
|
// United States Dollar
|
|
46
38
|
CA: "C$",
|
|
@@ -80,215 +72,7 @@ const currencySymbols = [
|
|
|
80
72
|
SI: "€",
|
|
81
73
|
ES: "€"
|
|
82
74
|
// Add more mappings as needed
|
|
83
|
-
},
|
|
84
|
-
const info = numfmt.getInfo(pattern), locale = _locale === LocaleType.ZH_CN ? "zh-CN" : "en", negInfo = info._partitions[1], result = numfmt.format(pattern, value, { locale, throws: !1 });
|
|
85
|
-
return value < 0 ? {
|
|
86
|
-
result,
|
|
87
|
-
color: negInfo.color
|
|
88
|
-
} : {
|
|
89
|
-
result
|
|
90
|
-
};
|
|
91
|
-
}, "getPatternPreview"), getPatternPreviewIgnoreGeneral = /* @__PURE__ */ __name((pattern, value, _locale) => pattern === "General" ? {
|
|
92
|
-
result: String(value)
|
|
93
|
-
} : getPatternPreview(pattern, value, _locale), "getPatternPreviewIgnoreGeneral");
|
|
94
|
-
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
95
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
96
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
97
|
-
return kind && result && __defProp$5(target, key2, result), result;
|
|
98
|
-
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$5"), _a;
|
|
99
|
-
let SheetsNumfmtCellContentController = (_a = class extends Disposable {
|
|
100
|
-
constructor(_instanceService, _sheetInterceptorService, _themeService, _commandService, _numfmtService, _localeService) {
|
|
101
|
-
super(), this._instanceService = _instanceService, this._sheetInterceptorService = _sheetInterceptorService, this._themeService = _themeService, this._commandService = _commandService, this._numfmtService = _numfmtService, this._localeService = _localeService, this._initInterceptorCellContent();
|
|
102
|
-
}
|
|
103
|
-
// eslint-disable-next-line max-lines-per-function
|
|
104
|
-
_initInterceptorCellContent() {
|
|
105
|
-
const renderCache = new ObjectMatrix();
|
|
106
|
-
this.disposeWithMe(this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
107
|
-
effect: InterceptorEffectEnum.Value | InterceptorEffectEnum.Style,
|
|
108
|
-
handler: /* @__PURE__ */ __name((cell, location, next) => {
|
|
109
|
-
const unitId = location.unitId, sheetId = location.subUnitId;
|
|
110
|
-
let numfmtValue;
|
|
111
|
-
const originCellValue = cell;
|
|
112
|
-
if (!originCellValue || originCellValue.t !== CellValueType.NUMBER || originCellValue.v == null || Number.isNaN(originCellValue.v))
|
|
113
|
-
return next(cell);
|
|
114
|
-
if (cell != null && cell.s) {
|
|
115
|
-
const style = location.workbook.getStyles().get(cell.s);
|
|
116
|
-
style != null && style.n && (numfmtValue = style.n);
|
|
117
|
-
}
|
|
118
|
-
if (numfmtValue || (numfmtValue = this._numfmtService.getValue(unitId, sheetId, location.row, location.col)), !numfmtValue)
|
|
119
|
-
return next(cell);
|
|
120
|
-
let numfmtRes = "";
|
|
121
|
-
const cache = renderCache.getValue(location.row, location.col);
|
|
122
|
-
if (cache && cache.parameters === `${originCellValue.v}_${numfmtValue.pattern}`)
|
|
123
|
-
return next({ ...cell, ...cache.result });
|
|
124
|
-
const info = getPatternPreviewIgnoreGeneral(numfmtValue.pattern, Number(originCellValue.v), this._localeService.getCurrentLocale());
|
|
125
|
-
if (numfmtRes = info.result, !numfmtRes)
|
|
126
|
-
return next(cell);
|
|
127
|
-
const res = { v: numfmtRes };
|
|
128
|
-
if (info.color) {
|
|
129
|
-
const color = this._themeService.getCurrentTheme()[`${info.color}500`];
|
|
130
|
-
color && (res.interceptorStyle = { cl: { rgb: color } });
|
|
131
|
-
}
|
|
132
|
-
return renderCache.setValue(location.row, location.col, {
|
|
133
|
-
result: res,
|
|
134
|
-
parameters: `${originCellValue.v}_${numfmtValue.pattern}`
|
|
135
|
-
}), next({ ...cell, ...res });
|
|
136
|
-
}, "handler"),
|
|
137
|
-
priority: InterceptCellContentPriority.NUMFMT
|
|
138
|
-
})), this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
139
|
-
if (commandInfo.id === SetNumfmtMutation.id) {
|
|
140
|
-
const params = commandInfo.params;
|
|
141
|
-
Object.keys(params.values).forEach((key2) => {
|
|
142
|
-
params.values[key2].ranges.forEach((range) => {
|
|
143
|
-
Range.foreach(range, (row, col) => {
|
|
144
|
-
renderCache.realDeleteValue(row, col);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
} else if (commandInfo.id === SetRangeValuesMutation.id) {
|
|
149
|
-
const params = commandInfo.params;
|
|
150
|
-
new ObjectMatrix(params.cellValue).forValue((row, col) => {
|
|
151
|
-
renderCache.realDeleteValue(row, col);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
})), this.disposeWithMe(
|
|
155
|
-
this._instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(
|
|
156
|
-
switchMap((workbook) => {
|
|
157
|
-
var _a7;
|
|
158
|
-
return (_a7 = workbook == null ? void 0 : workbook.activeSheet$) != null ? _a7 : of(null);
|
|
159
|
-
}),
|
|
160
|
-
skip(1)
|
|
161
|
-
).subscribe(() => renderCache.reset())
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
}, __name(_a, "SheetsNumfmtCellContentController"), _a);
|
|
165
|
-
SheetsNumfmtCellContentController = __decorateClass$5([
|
|
166
|
-
__decorateParam$5(0, IUniverInstanceService),
|
|
167
|
-
__decorateParam$5(1, Inject(SheetInterceptorService)),
|
|
168
|
-
__decorateParam$5(2, Inject(ThemeService)),
|
|
169
|
-
__decorateParam$5(3, Inject(ICommandService)),
|
|
170
|
-
__decorateParam$5(4, Inject(INumfmtService)),
|
|
171
|
-
__decorateParam$5(5, Inject(LocaleService))
|
|
172
|
-
], SheetsNumfmtCellContentController);
|
|
173
|
-
const getDecimalFromPattern = /* @__PURE__ */ __name((pattern, defaultValue = 0) => {
|
|
174
|
-
var _a7;
|
|
175
|
-
return pattern && (_a7 = numfmt.getInfo(pattern).maxDecimals) != null ? _a7 : defaultValue;
|
|
176
|
-
}, "getDecimalFromPattern"), isPatternEqualWithoutDecimal = /* @__PURE__ */ __name((patternA, patternB) => {
|
|
177
|
-
if (patternA && !patternB || !patternA && patternB)
|
|
178
|
-
return !1;
|
|
179
|
-
const getString = /* @__PURE__ */ __name((tokens) => tokens.reduce(
|
|
180
|
-
(pre, cur) => {
|
|
181
|
-
if (pre.isEnd)
|
|
182
|
-
return pre;
|
|
183
|
-
const str = cur.value || cur.num;
|
|
184
|
-
return cur.type === "point" ? (pre.isEnd = !0, pre) : { ...pre, result: pre.result + str };
|
|
185
|
-
},
|
|
186
|
-
{ isEnd: !1, result: "" }
|
|
187
|
-
).result, "getString"), partitionsA = numfmt.getInfo(patternA)._partitions, partitionsB = numfmt.getInfo(patternB)._partitions, A1 = getString(partitionsA[0].tokens), B1 = getString(partitionsB[0].tokens), A2 = getString(partitionsA[1].tokens), B2 = getString(partitionsB[1].tokens);
|
|
188
|
-
return A1 === B1 && A2 === B2 && partitionsA[1].color === partitionsB[1].color;
|
|
189
|
-
}, "isPatternEqualWithoutDecimal"), getDecimalString = /* @__PURE__ */ __name((length) => new Array(Math.min(Math.max(0, Number(length)), 30)).fill(0).join(""), "getDecimalString"), setPatternDecimal = /* @__PURE__ */ __name((patterns, decimalLength) => patterns.split(";").map((pattern) => /\.0?/.test(pattern) ? pattern.replace(
|
|
190
|
-
/\.0*/g,
|
|
191
|
-
`${decimalLength > 0 ? "." : ""}${getDecimalString(Number(decimalLength || 0))}`
|
|
192
|
-
) : /0([^0]?)|0$/.test(pattern) ? pattern.replace(
|
|
193
|
-
/0([^0]+)|0$/,
|
|
194
|
-
`0${decimalLength > 0 ? "." : ""}${getDecimalString(Number(decimalLength || 0))}$1`
|
|
195
|
-
) : pattern).join(";"), "setPatternDecimal"), isPatternHasDecimal = /* @__PURE__ */ __name((pattern) => /\.0?/.test(pattern) || /0([^0]?)|0$/.test(pattern), "isPatternHasDecimal"), SetNumfmtCommand = {
|
|
196
|
-
id: "sheet.command.numfmt.set.numfmt",
|
|
197
|
-
type: CommandType.COMMAND,
|
|
198
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
199
|
-
if (!params)
|
|
200
|
-
return !1;
|
|
201
|
-
const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), undoRedoService = accessor.get(IUndoRedoService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
202
|
-
if (!target) return !1;
|
|
203
|
-
const { unitId, subUnitId } = target, setCells = params.values.filter((value) => !!value.pattern), removeCells = params.values.filter((value) => !value.pattern), setRedos = transformCellsToRange(unitId, subUnitId, setCells), removeRedos = {
|
|
204
|
-
unitId,
|
|
205
|
-
subUnitId,
|
|
206
|
-
ranges: removeCells.map((cell) => ({
|
|
207
|
-
startColumn: cell.col,
|
|
208
|
-
startRow: cell.row,
|
|
209
|
-
endColumn: cell.col,
|
|
210
|
-
endRow: cell.row
|
|
211
|
-
}))
|
|
212
|
-
}, redos = [], undos = [];
|
|
213
|
-
if (setCells.length) {
|
|
214
|
-
Object.keys(setRedos.values).forEach((key2) => {
|
|
215
|
-
const v = setRedos.values[key2];
|
|
216
|
-
v.ranges = rangeMerge(v.ranges);
|
|
217
|
-
}), redos.push({
|
|
218
|
-
id: SetNumfmtMutation.id,
|
|
219
|
-
params: setRedos
|
|
220
|
-
});
|
|
221
|
-
const undo = factorySetNumfmtUndoMutation(accessor, setRedos);
|
|
222
|
-
undos.push(...undo);
|
|
223
|
-
}
|
|
224
|
-
if (removeCells.length) {
|
|
225
|
-
removeRedos.ranges = rangeMerge(removeRedos.ranges), redos.push({
|
|
226
|
-
id: RemoveNumfmtMutation.id,
|
|
227
|
-
params: removeRedos
|
|
228
|
-
});
|
|
229
|
-
const undo = factoryRemoveNumfmtUndoMutation(accessor, removeRedos);
|
|
230
|
-
undos.push(...undo);
|
|
231
|
-
}
|
|
232
|
-
const result = sequenceExecute(redos, commandService).result;
|
|
233
|
-
return result && undoRedoService.pushUndoRedo({
|
|
234
|
-
unitID: unitId,
|
|
235
|
-
undoMutations: undos,
|
|
236
|
-
redoMutations: redos
|
|
237
|
-
}), result;
|
|
238
|
-
}, "handler")
|
|
239
|
-
}, AddDecimalCommand = {
|
|
240
|
-
id: "sheet.command.numfmt.add.decimal.command",
|
|
241
|
-
type: CommandType.COMMAND,
|
|
242
|
-
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
243
|
-
const commandService = accessor.get(ICommandService), selectionManagerService = accessor.get(SheetsSelectionsService), numfmtService = accessor.get(INumfmtService), univerInstanceService = accessor.get(IUniverInstanceService), selections = selectionManagerService.getCurrentSelections();
|
|
244
|
-
if (!selections || !selections.length)
|
|
245
|
-
return !1;
|
|
246
|
-
const target = getSheetCommandTarget(univerInstanceService);
|
|
247
|
-
if (!target) return !1;
|
|
248
|
-
const { unitId, subUnitId } = target;
|
|
249
|
-
let maxDecimals = 0;
|
|
250
|
-
selections.forEach((selection) => {
|
|
251
|
-
Range.foreach(selection.range, (row, col) => {
|
|
252
|
-
const numfmtValue = numfmtService.getValue(unitId, subUnitId, row, col);
|
|
253
|
-
if (!numfmtValue) {
|
|
254
|
-
const cell = target.worksheet.getCellRaw(row, col);
|
|
255
|
-
if (!maxDecimals && cell && cell.t === CellValueType.NUMBER && cell.v) {
|
|
256
|
-
const regResult = /\.(\d*)$/.exec(String(cell.v));
|
|
257
|
-
if (regResult) {
|
|
258
|
-
const length = regResult[1].length;
|
|
259
|
-
if (!length)
|
|
260
|
-
return;
|
|
261
|
-
maxDecimals = Math.max(maxDecimals, length);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
const decimals2 = getDecimalFromPattern(numfmtValue.pattern);
|
|
267
|
-
maxDecimals = decimals2 > maxDecimals ? decimals2 : maxDecimals;
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
const decimals = maxDecimals + 1, defaultPattern = setPatternDecimal(`0${decimals > 0 ? ".0" : ""}`, decimals), values = [];
|
|
271
|
-
return selections.forEach((selection) => {
|
|
272
|
-
Range.foreach(selection.range, (row, col) => {
|
|
273
|
-
const numfmtValue = numfmtService.getValue(unitId, subUnitId, row, col);
|
|
274
|
-
if (!numfmtValue)
|
|
275
|
-
values.push({
|
|
276
|
-
row,
|
|
277
|
-
col,
|
|
278
|
-
pattern: defaultPattern
|
|
279
|
-
});
|
|
280
|
-
else {
|
|
281
|
-
const decimals2 = getDecimalFromPattern(numfmtValue.pattern), pattern = setPatternDecimal(numfmtValue.pattern, decimals2 + 1);
|
|
282
|
-
pattern !== numfmtValue.pattern && values.push({
|
|
283
|
-
row,
|
|
284
|
-
col,
|
|
285
|
-
pattern
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
}), values.length ? await commandService.executeCommand(SetNumfmtCommand.id, { values }) : !1;
|
|
290
|
-
}, "handler")
|
|
291
|
-
}, DATEFMTLISG = [
|
|
75
|
+
}, Ie = [
|
|
292
76
|
{
|
|
293
77
|
label: "1930-08-05",
|
|
294
78
|
suffix: "yyyy-MM-dd"
|
|
@@ -333,7 +117,7 @@ const getDecimalFromPattern = /* @__PURE__ */ __name((pattern, defaultValue = 0)
|
|
|
333
117
|
label: "08-05 下午 01:30",
|
|
334
118
|
suffix: "MM-dd A/P hh:mm"
|
|
335
119
|
}
|
|
336
|
-
],
|
|
120
|
+
], Ne = [
|
|
337
121
|
{
|
|
338
122
|
label: "(1,235)",
|
|
339
123
|
suffix: "#,##0_);(#,##0)"
|
|
@@ -361,1157 +145,423 @@ const getDecimalFromPattern = /* @__PURE__ */ __name((pattern, defaultValue = 0)
|
|
|
361
145
|
suffix: "#,##0.00_);[Red]-#,##0.00",
|
|
362
146
|
color: "red"
|
|
363
147
|
}
|
|
364
|
-
],
|
|
148
|
+
], Q = [
|
|
365
149
|
{
|
|
366
|
-
label:
|
|
367
|
-
suffix:
|
|
150
|
+
label: (e) => `${e}1,235`,
|
|
151
|
+
suffix: (e) => `"${e}"#,##0.00_);"${e}"#,##0.00`
|
|
368
152
|
},
|
|
369
153
|
{
|
|
370
|
-
label:
|
|
371
|
-
suffix:
|
|
154
|
+
label: (e) => `${e}1,235`,
|
|
155
|
+
suffix: (e) => `"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,
|
|
372
156
|
color: "red"
|
|
373
157
|
},
|
|
374
158
|
{
|
|
375
|
-
label:
|
|
376
|
-
suffix:
|
|
159
|
+
label: (e) => `(${e}1,235)`,
|
|
160
|
+
suffix: (e) => `"${e}"#,##0.00_);("${e}"#,##0.00)`
|
|
377
161
|
},
|
|
378
162
|
{
|
|
379
|
-
label:
|
|
380
|
-
suffix:
|
|
163
|
+
label: (e) => `(${e}1,235)`,
|
|
164
|
+
suffix: (e) => `"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,
|
|
381
165
|
color: "red"
|
|
382
166
|
},
|
|
383
167
|
{
|
|
384
|
-
label:
|
|
385
|
-
suffix:
|
|
168
|
+
label: (e) => `-${e}1,235`,
|
|
169
|
+
suffix: (e) => `"${e}"#,##0.00_);-"${e}"#,##0.00`
|
|
386
170
|
},
|
|
387
171
|
{
|
|
388
|
-
label:
|
|
389
|
-
suffix:
|
|
172
|
+
label: (e) => `-${e}1,235`,
|
|
173
|
+
suffix: (e) => `"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,
|
|
390
174
|
color: "red"
|
|
391
175
|
}
|
|
392
|
-
],
|
|
176
|
+
], Ee = "SHEET_NUMFMT_PLUGIN", x = (e, t = 0) => {
|
|
177
|
+
var r;
|
|
178
|
+
return e && (r = $.getInfo(e).maxDecimals) != null ? r : t;
|
|
179
|
+
}, We = (e, t) => {
|
|
180
|
+
if (e && !t || !e && t)
|
|
181
|
+
return !1;
|
|
182
|
+
const n = (i) => i.reduce(
|
|
183
|
+
(u, f) => {
|
|
184
|
+
if (u.isEnd)
|
|
185
|
+
return u;
|
|
186
|
+
const m = f.value || f.num;
|
|
187
|
+
return f.type === "point" ? (u.isEnd = !0, u) : { ...u, result: u.result + m };
|
|
188
|
+
},
|
|
189
|
+
{ isEnd: !1, result: "" }
|
|
190
|
+
).result, r = $.getInfo(e)._partitions, s = $.getInfo(t)._partitions, c = n(r[0].tokens), o = n(s[0].tokens), l = n(r[1].tokens), d = n(s[1].tokens);
|
|
191
|
+
return c === o && l === d && r[1].color === s[1].color;
|
|
192
|
+
}, H = (e) => new Array(Math.min(Math.max(0, Number(e)), 30)).fill(0).join(""), P = (e, t) => e.split(";").map((r) => /\.0?/.test(r) ? r.replace(
|
|
193
|
+
/\.0*/g,
|
|
194
|
+
`${t > 0 ? "." : ""}${H(Number(t || 0))}`
|
|
195
|
+
) : /0([^0]?)|0$/.test(r) ? r.replace(
|
|
196
|
+
/0([^0]+)|0$/,
|
|
197
|
+
`0${t > 0 ? "." : ""}${H(Number(t || 0))}$1`
|
|
198
|
+
) : r).join(";"), qe = (e) => /\.0?/.test(e) || /0([^0]?)|0$/.test(e), R = {
|
|
199
|
+
id: "sheet.command.numfmt.set.numfmt",
|
|
200
|
+
type: E.COMMAND,
|
|
201
|
+
handler: (e, t) => {
|
|
202
|
+
if (!t)
|
|
203
|
+
return !1;
|
|
204
|
+
const n = e.get(b), r = e.get(D), s = e.get(re), c = w(r, t);
|
|
205
|
+
if (!c) return !1;
|
|
206
|
+
const { unitId: o, subUnitId: l } = c, d = t.values.filter((a) => !!a.pattern), i = t.values.filter((a) => !a.pattern), u = fe(o, l, d), f = {
|
|
207
|
+
unitId: o,
|
|
208
|
+
subUnitId: l,
|
|
209
|
+
ranges: i.map((a) => ({
|
|
210
|
+
startColumn: a.col,
|
|
211
|
+
startRow: a.row,
|
|
212
|
+
endColumn: a.col,
|
|
213
|
+
endRow: a.row
|
|
214
|
+
}))
|
|
215
|
+
}, m = [], S = [];
|
|
216
|
+
if (d.length) {
|
|
217
|
+
Object.keys(u.values).forEach((h) => {
|
|
218
|
+
const g = u.values[h];
|
|
219
|
+
g.ranges = G(g.ranges);
|
|
220
|
+
}), m.push({
|
|
221
|
+
id: z.id,
|
|
222
|
+
params: u
|
|
223
|
+
});
|
|
224
|
+
const a = de(e, u);
|
|
225
|
+
S.push(...a);
|
|
226
|
+
}
|
|
227
|
+
if (i.length) {
|
|
228
|
+
f.ranges = G(f.ranges), m.push({
|
|
229
|
+
id: he.id,
|
|
230
|
+
params: f
|
|
231
|
+
});
|
|
232
|
+
const a = ge(e, f);
|
|
233
|
+
S.push(...a);
|
|
234
|
+
}
|
|
235
|
+
const v = se(m, n).result;
|
|
236
|
+
return v && s.pushUndoRedo({
|
|
237
|
+
unitID: o,
|
|
238
|
+
undoMutations: S,
|
|
239
|
+
redoMutations: m
|
|
240
|
+
}), v;
|
|
241
|
+
}
|
|
242
|
+
}, Re = {
|
|
243
|
+
id: "sheet.command.numfmt.add.decimal.command",
|
|
244
|
+
type: E.COMMAND,
|
|
245
|
+
handler: async (e) => {
|
|
246
|
+
const t = e.get(b), n = e.get(O), r = e.get(A), s = e.get(D), c = n.getCurrentSelections();
|
|
247
|
+
if (!c || !c.length)
|
|
248
|
+
return !1;
|
|
249
|
+
const o = w(s);
|
|
250
|
+
if (!o) return !1;
|
|
251
|
+
const { unitId: l, subUnitId: d } = o;
|
|
252
|
+
let i = 0;
|
|
253
|
+
c.forEach((S) => {
|
|
254
|
+
C.foreach(S.range, (v, a) => {
|
|
255
|
+
const h = r.getValue(l, d, v, a);
|
|
256
|
+
if (!h) {
|
|
257
|
+
const p = o.worksheet.getCellRaw(v, a);
|
|
258
|
+
if (!i && p && p.t === V.NUMBER && p.v) {
|
|
259
|
+
const y = /\.(\d*)$/.exec(String(p.v));
|
|
260
|
+
if (y) {
|
|
261
|
+
const I = y[1].length;
|
|
262
|
+
if (!I)
|
|
263
|
+
return;
|
|
264
|
+
i = Math.max(i, I);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const g = x(h.pattern);
|
|
270
|
+
i = g > i ? g : i;
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
const u = i + 1, f = P(`0${u > 0 ? ".0" : ""}`, u), m = [];
|
|
274
|
+
return c.forEach((S) => {
|
|
275
|
+
C.foreach(S.range, (v, a) => {
|
|
276
|
+
const h = r.getValue(l, d, v, a);
|
|
277
|
+
if (!h)
|
|
278
|
+
m.push({
|
|
279
|
+
row: v,
|
|
280
|
+
col: a,
|
|
281
|
+
pattern: f
|
|
282
|
+
});
|
|
283
|
+
else {
|
|
284
|
+
const g = x(h.pattern), p = P(h.pattern, g + 1);
|
|
285
|
+
p !== h.pattern && m.push({
|
|
286
|
+
row: v,
|
|
287
|
+
col: a,
|
|
288
|
+
pattern: p
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}), m.length ? await t.executeCommand(R.id, { values: m }) : !1;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
class X {
|
|
393
296
|
constructor() {
|
|
394
|
-
|
|
395
|
-
|
|
297
|
+
N(this, "_currencySymbol$", new J("US"));
|
|
298
|
+
N(this, "currencySymbol$", this._currencySymbol$.asObservable());
|
|
396
299
|
}
|
|
397
300
|
/**
|
|
398
301
|
* Set the currency symbol by setting the country code.
|
|
399
302
|
*/
|
|
400
|
-
setCurrencySymbolByCountryCode(
|
|
401
|
-
this._currencySymbol$.next(
|
|
303
|
+
setCurrencySymbolByCountryCode(t) {
|
|
304
|
+
this._currencySymbol$.next(t);
|
|
402
305
|
}
|
|
403
306
|
getCurrencySymbol() {
|
|
404
307
|
return this._currencySymbol$.getValue();
|
|
405
308
|
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
let MenuCurrencyService = _MenuCurrencyService;
|
|
409
|
-
const SetCurrencyCommand = {
|
|
309
|
+
}
|
|
310
|
+
const xe = {
|
|
410
311
|
id: "sheet.command.numfmt.set.currency",
|
|
411
|
-
type:
|
|
412
|
-
handler:
|
|
413
|
-
const
|
|
414
|
-
if (!
|
|
312
|
+
type: E.COMMAND,
|
|
313
|
+
handler: async (e) => {
|
|
314
|
+
const t = e.get(b), n = e.get(O), r = e.get(X), s = $e[r.getCurrencySymbol()] || "$", c = n.getCurrentSelections();
|
|
315
|
+
if (!c || !c.length)
|
|
415
316
|
return !1;
|
|
416
|
-
const
|
|
417
|
-
return
|
|
418
|
-
|
|
419
|
-
|
|
317
|
+
const o = [], l = Q[4].suffix(s);
|
|
318
|
+
return c.forEach((i) => {
|
|
319
|
+
C.foreach(i.range, (u, f) => {
|
|
320
|
+
o.push({ row: u, col: f, pattern: l, type: "currency" });
|
|
420
321
|
});
|
|
421
|
-
}), await
|
|
422
|
-
}
|
|
423
|
-
},
|
|
322
|
+
}), await t.executeCommand(R.id, { values: o });
|
|
323
|
+
}
|
|
324
|
+
}, Pe = {
|
|
424
325
|
id: "sheet.command.numfmt.set.percent",
|
|
425
|
-
type:
|
|
426
|
-
handler:
|
|
427
|
-
const
|
|
428
|
-
if (!
|
|
326
|
+
type: E.COMMAND,
|
|
327
|
+
handler: async (e) => {
|
|
328
|
+
const t = e.get(b), r = e.get(O).getCurrentSelections();
|
|
329
|
+
if (!r || !r.length)
|
|
429
330
|
return !1;
|
|
430
|
-
const
|
|
431
|
-
return
|
|
432
|
-
|
|
433
|
-
|
|
331
|
+
const s = [], c = "0%";
|
|
332
|
+
return r.forEach((l) => {
|
|
333
|
+
C.foreach(l.range, (d, i) => {
|
|
334
|
+
s.push({ row: d, col: i, pattern: c, type: "percent" });
|
|
434
335
|
});
|
|
435
|
-
}), await
|
|
436
|
-
}
|
|
437
|
-
},
|
|
336
|
+
}), await t.executeCommand(R.id, { values: s });
|
|
337
|
+
}
|
|
338
|
+
}, Te = {
|
|
438
339
|
id: "sheet.command.numfmt.subtract.decimal.command",
|
|
439
|
-
type:
|
|
440
|
-
handler:
|
|
441
|
-
const
|
|
442
|
-
if (!
|
|
340
|
+
type: E.COMMAND,
|
|
341
|
+
handler: async (e) => {
|
|
342
|
+
const t = e.get(b), n = e.get(O), r = e.get(A), s = e.get(D), c = n.getCurrentSelections();
|
|
343
|
+
if (!c || !c.length)
|
|
443
344
|
return !1;
|
|
444
|
-
const
|
|
445
|
-
if (!
|
|
446
|
-
const { unitId, subUnitId } =
|
|
447
|
-
let
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
if (!
|
|
452
|
-
const
|
|
453
|
-
if (!
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
const
|
|
457
|
-
if (!
|
|
345
|
+
const o = w(s);
|
|
346
|
+
if (!o) return !1;
|
|
347
|
+
const { unitId: l, subUnitId: d } = o;
|
|
348
|
+
let i = 0;
|
|
349
|
+
c.forEach((v) => {
|
|
350
|
+
C.foreach(v.range, (a, h) => {
|
|
351
|
+
const g = r.getValue(l, d, a, h);
|
|
352
|
+
if (!g) {
|
|
353
|
+
const y = o.worksheet.getCellRaw(a, h);
|
|
354
|
+
if (!i && y && y.t === V.NUMBER && y.v) {
|
|
355
|
+
const I = /\.(\d*)$/.exec(String(y.v));
|
|
356
|
+
if (I) {
|
|
357
|
+
const j = I[1].length;
|
|
358
|
+
if (!j)
|
|
458
359
|
return;
|
|
459
|
-
|
|
360
|
+
i = Math.max(i, j);
|
|
460
361
|
}
|
|
461
362
|
}
|
|
462
363
|
return;
|
|
463
364
|
}
|
|
464
|
-
const
|
|
465
|
-
|
|
365
|
+
const p = x(g.pattern);
|
|
366
|
+
i = p > i ? p : i;
|
|
466
367
|
});
|
|
467
368
|
});
|
|
468
|
-
const
|
|
469
|
-
return
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
if (!
|
|
473
|
-
|
|
474
|
-
row,
|
|
475
|
-
col,
|
|
476
|
-
pattern:
|
|
369
|
+
const u = i - 1, f = P(`0${u > 0 ? ".0" : "."}`, u), m = [];
|
|
370
|
+
return c.forEach((v) => {
|
|
371
|
+
C.foreach(v.range, (a, h) => {
|
|
372
|
+
const g = r.getValue(l, d, a, h);
|
|
373
|
+
if (!g)
|
|
374
|
+
m.push({
|
|
375
|
+
row: a,
|
|
376
|
+
col: h,
|
|
377
|
+
pattern: f
|
|
477
378
|
});
|
|
478
379
|
else {
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
row,
|
|
482
|
-
col,
|
|
483
|
-
pattern:
|
|
380
|
+
const p = x(g.pattern);
|
|
381
|
+
m.push({
|
|
382
|
+
row: a,
|
|
383
|
+
col: h,
|
|
384
|
+
pattern: P(g.pattern, p - 1)
|
|
484
385
|
});
|
|
485
386
|
}
|
|
486
387
|
});
|
|
487
|
-
}), await
|
|
488
|
-
}, "handler")
|
|
489
|
-
}, CloseNumfmtPanelOperator = {
|
|
490
|
-
id: "sheet.operation.close.numfmt.panel",
|
|
491
|
-
type: CommandType.OPERATION,
|
|
492
|
-
handler: /* @__PURE__ */ __name(() => (
|
|
493
|
-
// do nothing,just notify panel is closed
|
|
494
|
-
!0
|
|
495
|
-
), "handler")
|
|
496
|
-
}, INumfmtController = createIdentifier("INumfmtController"), OpenNumfmtPanelOperator = {
|
|
497
|
-
id: "sheet.operation.open.numfmt.panel",
|
|
498
|
-
type: CommandType.OPERATION,
|
|
499
|
-
handler: /* @__PURE__ */ __name((accessor) => (accessor.get(INumfmtController).openPanel(), !0), "handler")
|
|
500
|
-
};
|
|
501
|
-
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
502
|
-
/**
|
|
503
|
-
* @license React
|
|
504
|
-
* react-jsx-runtime.production.min.js
|
|
505
|
-
*
|
|
506
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
507
|
-
*
|
|
508
|
-
* This source code is licensed under the MIT license found in the
|
|
509
|
-
* LICENSE file in the root directory of this source tree.
|
|
510
|
-
*/
|
|
511
|
-
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
512
|
-
function q(c, a, g) {
|
|
513
|
-
var b, d = {}, e = null, h = null;
|
|
514
|
-
g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
|
|
515
|
-
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
516
|
-
if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
|
|
517
|
-
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
518
|
-
}
|
|
519
|
-
__name(q, "q");
|
|
520
|
-
reactJsxRuntime_production_min.Fragment = l;
|
|
521
|
-
reactJsxRuntime_production_min.jsx = q;
|
|
522
|
-
reactJsxRuntime_production_min.jsxs = q;
|
|
523
|
-
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
524
|
-
var jsxRuntimeExports = jsxRuntime.exports;
|
|
525
|
-
const UserHabitCurrencyContext = createContext([]);
|
|
526
|
-
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
527
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
528
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
529
|
-
return kind && result && __defProp$4(target, key2, result), result;
|
|
530
|
-
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$4"), _a2;
|
|
531
|
-
let UserHabitController = (_a2 = class {
|
|
532
|
-
constructor(_localStorageService) {
|
|
533
|
-
this._localStorageService = _localStorageService;
|
|
534
|
-
}
|
|
535
|
-
_getKey(habit) {
|
|
536
|
-
return `userHabitController_${habit}`;
|
|
537
|
-
}
|
|
538
|
-
async addHabit(habit, initValue) {
|
|
539
|
-
const key2 = this._getKey(habit);
|
|
540
|
-
return this._localStorageService.getItem(key2).then((item) => {
|
|
541
|
-
item || this._localStorageService.setItem(key2, initValue);
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
markHabit(habit, value) {
|
|
545
|
-
const key2 = this._getKey(habit);
|
|
546
|
-
this._localStorageService.getItem(key2).then((list) => {
|
|
547
|
-
if (list) {
|
|
548
|
-
const index = list.findIndex((item) => item === value);
|
|
549
|
-
index > -1 && list.splice(index, 1), list.unshift(value), this._localStorageService.setItem(key2, list);
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
async getHabit(habit, sortList) {
|
|
554
|
-
const key2 = this._getKey(habit), result = await this._localStorageService.getItem(key2);
|
|
555
|
-
if (sortList && result) {
|
|
556
|
-
const priority = result.map((item, index, arr) => {
|
|
557
|
-
const length = arr.length;
|
|
558
|
-
return {
|
|
559
|
-
value: item,
|
|
560
|
-
priority: length - index
|
|
561
|
-
};
|
|
562
|
-
});
|
|
563
|
-
return sortList.sort((a, b) => {
|
|
564
|
-
var _a7, _b;
|
|
565
|
-
const ap = ((_a7 = priority.find((item) => item.value === a)) == null ? void 0 : _a7.priority) || -1;
|
|
566
|
-
return (((_b = priority.find((item) => item.value === b)) == null ? void 0 : _b.priority) || -1) - ap;
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
return result || [];
|
|
570
|
-
}
|
|
571
|
-
deleteHabit(habit) {
|
|
572
|
-
this._localStorageService.removeItem(habit);
|
|
573
|
-
}
|
|
574
|
-
}, __name(_a2, "UserHabitController"), _a2);
|
|
575
|
-
UserHabitController = __decorateClass$4([
|
|
576
|
-
__decorateParam$4(0, Inject(ILocalStorageService))
|
|
577
|
-
], UserHabitController);
|
|
578
|
-
const key$1 = "numfmtCurrency", useCurrencyOptions = /* @__PURE__ */ __name((onOptionChange) => {
|
|
579
|
-
const userHabitController = useDependency(UserHabitController), [options, optionsSet] = useState(currencySymbols);
|
|
580
|
-
return useEffect(() => {
|
|
581
|
-
userHabitController.addHabit("numfmtCurrency", []).then(() => {
|
|
582
|
-
userHabitController.getHabit(key$1, [...currencySymbols]).then((list) => {
|
|
583
|
-
optionsSet(list), onOptionChange && onOptionChange(list);
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
}, []), { userHabitCurrency: options, mark: /* @__PURE__ */ __name((v) => {
|
|
587
|
-
userHabitController.markHabit(key$1, v);
|
|
588
|
-
}, "mark") };
|
|
589
|
-
}, "useCurrencyOptions"), useNextTick = /* @__PURE__ */ __name(() => {
|
|
590
|
-
const effectList = useRef([]), [value, dispatch] = useState({});
|
|
591
|
-
return useEffect(() => {
|
|
592
|
-
effectList.current.forEach((fn) => {
|
|
593
|
-
fn();
|
|
594
|
-
}), effectList.current = [];
|
|
595
|
-
}, [value]), /* @__PURE__ */ __name((fn) => {
|
|
596
|
-
effectList.current.push(fn), dispatch({});
|
|
597
|
-
}, "nextTick");
|
|
598
|
-
}, "useNextTick"), getCurrencyType = /* @__PURE__ */ __name((pattern) => currencySymbols.find((code) => pattern.includes(code)), "getCurrencyType"), isAccountingPanel = /* @__PURE__ */ __name((pattern) => !!getCurrencyType(pattern) && pattern.startsWith("_("), "isAccountingPanel"), AccountingPanel = /* @__PURE__ */ __name((props) => {
|
|
599
|
-
const [decimal, decimalSet] = useState(() => getDecimalFromPattern(props.defaultPattern || "", 2)), userHabitCurrency = useContext(UserHabitCurrencyContext), [suffix, suffixSet] = useState(() => getCurrencyType(props.defaultPattern) || userHabitCurrency[0]), options = useMemo(() => userHabitCurrency.map((key2) => ({ label: key2, value: key2 })), []), t = useDependency(LocaleService).t;
|
|
600
|
-
props.action.current = () => setPatternDecimal(`_("${suffix}"* #,##0${decimal > 0 ? ".0" : ""}_)`, decimal);
|
|
601
|
-
const onSelect = /* @__PURE__ */ __name((v) => {
|
|
602
|
-
suffixSet(v), props.onChange(setPatternDecimal(`_("${v}"* #,##0${decimal > 0 ? ".0" : ""}_)`, decimal));
|
|
603
|
-
}, "onSelect"), onDecimalChange = /* @__PURE__ */ __name((v) => {
|
|
604
|
-
const decimal2 = v || 0;
|
|
605
|
-
decimalSet(decimal2), props.onChange(setPatternDecimal(`_("${suffix}"* #,##0${decimal2 > 0 ? ".0" : ""}_)`, decimal2));
|
|
606
|
-
}, "onDecimalChange");
|
|
607
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
608
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "m-t-16 options ", children: [
|
|
609
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "option", children: [
|
|
610
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "label", children: t("sheet.numfmt.decimalLength") }),
|
|
611
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-8 w-120", children: /* @__PURE__ */ jsxRuntimeExports.jsx(InputNumber, { value: decimal, max: 20, min: 0, onChange: onDecimalChange }) })
|
|
612
|
-
] }),
|
|
613
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "option", children: [
|
|
614
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "label", children: t("sheet.numfmt.currencyType") }),
|
|
615
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-8 w-140", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { onChange: onSelect, options, value: suffix }) })
|
|
616
|
-
] })
|
|
617
|
-
] }),
|
|
618
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "describe m-t-14", children: t("sheet.numfmt.accountingDes") })
|
|
619
|
-
] });
|
|
620
|
-
}, "AccountingPanel"), getCurrencyFormatOptions = /* @__PURE__ */ __name((suffix) => CURRENCYFORMAT.map((item) => ({
|
|
621
|
-
label: item.label(suffix),
|
|
622
|
-
value: item.suffix(suffix),
|
|
623
|
-
color: item.color
|
|
624
|
-
})), "getCurrencyFormatOptions"), getDateFormatOptions = /* @__PURE__ */ __name(() => DATEFMTLISG.map((item) => ({ label: item.label, value: item.suffix })), "getDateFormatOptions"), getNumberFormatOptions = /* @__PURE__ */ __name(() => NUMBERFORMAT.map((item) => ({ label: item.label, value: item.suffix, color: item.color })), "getNumberFormatOptions"), isCurrencyPanel = /* @__PURE__ */ __name((pattern) => !!getCurrencyType(pattern) && !pattern.startsWith("_("), "isCurrencyPanel"), CurrencyPanel = /* @__PURE__ */ __name((props) => {
|
|
625
|
-
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(() => {
|
|
626
|
-
var _a7;
|
|
627
|
-
const negativeOptions2 = getCurrencyFormatOptions(suffix);
|
|
628
|
-
return ((_a7 = negativeOptions2.find((item) => isPatternEqualWithoutDecimal(item.value, props.defaultPattern))) == null ? void 0 : _a7.value) || negativeOptions2[0].value;
|
|
629
|
-
}), negativeOptions = useMemo(() => getCurrencyFormatOptions(suffix), [suffix]), options = useMemo(() => userHabitCurrency.map((key2) => ({ label: key2, value: key2 })), [userHabitCurrency]);
|
|
630
|
-
props.action.current = () => setPatternDecimal(pattern, decimal);
|
|
631
|
-
const onSelect = /* @__PURE__ */ __name((value) => {
|
|
632
|
-
if (value === void 0)
|
|
633
|
-
return;
|
|
634
|
-
suffixSet(value);
|
|
635
|
-
const pattern2 = getCurrencyFormatOptions(value)[0].value;
|
|
636
|
-
patternSet(pattern2), props.onChange(setPatternDecimal(pattern2, decimal));
|
|
637
|
-
}, "onSelect"), onChange = /* @__PURE__ */ __name((value) => {
|
|
638
|
-
value !== void 0 && (patternSet(value), props.onChange(setPatternDecimal(value, decimal)));
|
|
639
|
-
}, "onChange"), onDecimalChange = /* @__PURE__ */ __name((v) => {
|
|
640
|
-
decimalSet(v || 0), props.onChange(setPatternDecimal(pattern, v || 0));
|
|
641
|
-
}, "onDecimalChange");
|
|
642
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
643
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "m-t-16 options ", children: [
|
|
644
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "option", children: [
|
|
645
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "label", children: t("sheet.numfmt.decimalLength") }),
|
|
646
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-8 w-120", children: /* @__PURE__ */ jsxRuntimeExports.jsx(InputNumber, { value: decimal, max: 20, min: 0, onChange: onDecimalChange }) })
|
|
647
|
-
] }),
|
|
648
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "option", children: [
|
|
649
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "label", children: t("sheet.numfmt.currencyType") }),
|
|
650
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-8 w-140", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { onChange: onSelect, options, value: suffix }) })
|
|
651
|
-
] })
|
|
652
|
-
] }),
|
|
653
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-16 label", children: t("sheet.numfmt.negType") }),
|
|
654
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-8", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectList, { onChange, options: negativeOptions, value: pattern }) }),
|
|
655
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "describe m-t-14", children: t("sheet.numfmt.currencyDes") })
|
|
656
|
-
] });
|
|
657
|
-
}, "CurrencyPanel");
|
|
658
|
-
var __assign = function() {
|
|
659
|
-
return __assign = Object.assign || function(t) {
|
|
660
|
-
for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
|
|
661
|
-
s = arguments[i];
|
|
662
|
-
for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
|
|
663
|
-
}
|
|
664
|
-
return t;
|
|
665
|
-
}, __assign.apply(this, arguments);
|
|
666
|
-
}, __rest = function(s, e) {
|
|
667
|
-
var t = {};
|
|
668
|
-
for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
|
|
669
|
-
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
670
|
-
for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
|
|
671
|
-
e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
|
|
672
|
-
return t;
|
|
673
|
-
}, IconBase = forwardRef(function(props, ref) {
|
|
674
|
-
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()));
|
|
675
|
-
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
676
|
-
});
|
|
677
|
-
function render(node, id, runtimeProps, rootProps, extend) {
|
|
678
|
-
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
679
|
-
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
680
|
-
}));
|
|
681
|
-
}
|
|
682
|
-
__name(render, "render");
|
|
683
|
-
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
684
|
-
var attrs = __assign({}, node.attrs);
|
|
685
|
-
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
686
|
-
var defIds = runtimeProps.defIds;
|
|
687
|
-
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) {
|
|
688
|
-
var key2 = _a7[0], value = _a7[1];
|
|
689
|
-
typeof value == "string" && (attrs[key2] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
690
|
-
})), attrs;
|
|
691
|
-
}
|
|
692
|
-
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
693
|
-
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
694
|
-
var _a7, defIds = runtimeProps.defIds;
|
|
695
|
-
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) {
|
|
696
|
-
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;
|
|
697
|
-
}) }) : node;
|
|
698
|
-
}
|
|
699
|
-
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
700
|
-
function generateShortUuid() {
|
|
701
|
-
return Math.random().toString(36).substring(2, 8);
|
|
702
|
-
}
|
|
703
|
-
__name(generateShortUuid, "generateShortUuid");
|
|
704
|
-
IconBase.displayName = "UniverIcon";
|
|
705
|
-
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) {
|
|
706
|
-
return createElement(IconBase, Object.assign({}, props, {
|
|
707
|
-
id: "check-mark-single",
|
|
708
|
-
ref,
|
|
709
|
-
icon: element
|
|
710
|
-
}));
|
|
711
|
-
});
|
|
712
|
-
CheckMarkSingle.displayName = "CheckMarkSingle";
|
|
713
|
-
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 = {
|
|
714
|
-
customFormatTitle,
|
|
715
|
-
customFormatInput,
|
|
716
|
-
customFormatHistoryList,
|
|
717
|
-
customFormatHistoryListItem,
|
|
718
|
-
customFormatHistoryListItemIconWrap,
|
|
719
|
-
customFormatDes
|
|
720
|
-
}, key = "customFormat", historyPatternKey = "numfmt_custom_pattern";
|
|
721
|
-
function CustomFormat(props) {
|
|
722
|
-
const { defaultPattern, action, onChange } = props, userHabitController = useDependency(UserHabitController), localStorageService = useDependency(ILocalStorageService), localeService = useDependency(LocaleService), [pattern, patternSet] = useState(defaultPattern);
|
|
723
|
-
action.current = () => (userHabitController.markHabit(key, pattern), localStorageService.getItem(historyPatternKey).then((list = []) => {
|
|
724
|
-
const _list = [.../* @__PURE__ */ new Set([pattern, ...list || []])].splice(0, 10).filter((e) => !!e);
|
|
725
|
-
localStorageService.setItem(historyPatternKey, _list);
|
|
726
|
-
}), pattern);
|
|
727
|
-
const [options, optionsSet] = useState([]);
|
|
728
|
-
useEffect(() => {
|
|
729
|
-
localStorageService.getItem(historyPatternKey).then((historyList) => {
|
|
730
|
-
const list = [
|
|
731
|
-
...CURRENCYFORMAT.map((item) => item.suffix("$")),
|
|
732
|
-
...DATEFMTLISG.map((item) => item.suffix),
|
|
733
|
-
...NUMBERFORMAT.map((item) => item.suffix)
|
|
734
|
-
];
|
|
735
|
-
list.push(...historyList || []), userHabitController.addHabit(key, []).finally(() => {
|
|
736
|
-
userHabitController.getHabit(key, list).then((list2) => {
|
|
737
|
-
optionsSet([...new Set(list2)]);
|
|
738
|
-
});
|
|
739
|
-
});
|
|
740
|
-
});
|
|
741
|
-
}, []);
|
|
742
|
-
const handleClick = /* @__PURE__ */ __name((p2) => {
|
|
743
|
-
patternSet(p2), onChange(p2);
|
|
744
|
-
}, "handleClick"), handleBlur = /* @__PURE__ */ __name(() => {
|
|
745
|
-
onChange(pattern);
|
|
746
|
-
}, "handleBlur");
|
|
747
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.customFormat, children: [
|
|
748
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.customFormatTitle, children: localeService.t("sheet.numfmt.customFormat") }),
|
|
749
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Input, { placeholder: localeService.t("sheet.numfmt.customFormat"), onBlur: handleBlur, value: pattern, onChange: patternSet, className: styles.customFormatInput }),
|
|
750
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.customFormatHistoryList, children: options.map((p2) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { onClick: /* @__PURE__ */ __name(() => handleClick(p2), "onClick"), className: styles.customFormatHistoryListItem, children: [
|
|
751
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.customFormatHistoryListItemIconWrap, children: pattern === p2 && /* @__PURE__ */ jsxRuntimeExports.jsx(CheckMarkSingle, {}) }),
|
|
752
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: p2 })
|
|
753
|
-
] }, p2)) }),
|
|
754
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.customFormatDes, children: localeService.t("sheet.numfmt.customFormatDes") })
|
|
755
|
-
] });
|
|
756
|
-
}
|
|
757
|
-
__name(CustomFormat, "CustomFormat");
|
|
758
|
-
const isDatePanel = /* @__PURE__ */ __name((pattern) => {
|
|
759
|
-
const info = numfmt.getInfo(pattern);
|
|
760
|
-
return getDateFormatOptions().map((item) => item.value).includes(pattern) || ["date", "datetime", "time"].includes(info.type);
|
|
761
|
-
}, "isDatePanel"), DatePanel = /* @__PURE__ */ __name((props) => {
|
|
762
|
-
const options = useMemo(getDateFormatOptions, []), t = useDependency(LocaleService).t, [suffix, suffixSet] = useState(() => {
|
|
763
|
-
if (props.defaultPattern) {
|
|
764
|
-
const item = options.find((item2) => item2.value === props.defaultPattern);
|
|
765
|
-
if (item)
|
|
766
|
-
return item.value;
|
|
767
|
-
}
|
|
768
|
-
return options[0].value;
|
|
769
|
-
});
|
|
770
|
-
props.action.current = () => suffix;
|
|
771
|
-
const onChange = /* @__PURE__ */ __name((v) => {
|
|
772
|
-
v !== void 0 && (suffixSet(v), props.onChange(v));
|
|
773
|
-
}, "onChange");
|
|
774
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
775
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-16 label", children: t("sheet.numfmt.dateType") }),
|
|
776
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-8", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectList, { value: suffix, options, onChange }) }),
|
|
777
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "describe m-t-14", children: t("sheet.numfmt.dateDes") })
|
|
778
|
-
] });
|
|
779
|
-
}, "DatePanel"), isGeneralPanel = /* @__PURE__ */ __name((pattern) => !pattern, "isGeneralPanel"), GeneralPanel = /* @__PURE__ */ __name((props) => {
|
|
780
|
-
const t = useDependency(LocaleService).t;
|
|
781
|
-
return props.action.current = () => "", /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "describe m-t-14", children: t("sheet.numfmt.generalDes") }) });
|
|
782
|
-
}, "GeneralPanel"), isThousandthPercentilePanel = /* @__PURE__ */ __name((pattern) => getNumberFormatOptions().some((item) => isPatternEqualWithoutDecimal(item.value, pattern)), "isThousandthPercentilePanel"), ThousandthPercentilePanel = /* @__PURE__ */ __name((props) => {
|
|
783
|
-
const localeService = useDependency(LocaleService), options = useMemo(getNumberFormatOptions, []), [decimal, decimalSet] = useState(() => getDecimalFromPattern(props.defaultPattern || "", 0)), [suffix, suffixSet] = useState(() => {
|
|
784
|
-
const item = options.find((item2) => isPatternEqualWithoutDecimal(item2.value, props.defaultPattern || ""));
|
|
785
|
-
return (item == null ? void 0 : item.value) || options[0].value;
|
|
786
|
-
}), pattern = useMemo(() => setPatternDecimal(suffix, Number(decimal || 0)), [suffix, decimal]), isInputDisable = useMemo(() => !isPatternHasDecimal(suffix), [suffix]), handleDecimalChange = /* @__PURE__ */ __name((decimal2) => {
|
|
787
|
-
decimalSet(decimal2 || 0), props.onChange(setPatternDecimal(suffix, Number(decimal2 || 0)));
|
|
788
|
-
}, "handleDecimalChange"), handleClick = /* @__PURE__ */ __name((v) => {
|
|
789
|
-
v !== void 0 && (decimalSet(getDecimalFromPattern(v, 0)), suffixSet(v), props.onChange(v));
|
|
790
|
-
}, "handleClick");
|
|
791
|
-
return props.action.current = () => pattern, /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
792
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-16 label", children: localeService.t("sheet.numfmt.decimalLength") }),
|
|
793
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-8", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
794
|
-
InputNumber,
|
|
795
|
-
{
|
|
796
|
-
disabled: isInputDisable,
|
|
797
|
-
value: decimal,
|
|
798
|
-
max: 20,
|
|
799
|
-
min: 0,
|
|
800
|
-
onChange: handleDecimalChange
|
|
801
|
-
}
|
|
802
|
-
) }),
|
|
803
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "m-t-16 label", children: [
|
|
804
|
-
" ",
|
|
805
|
-
localeService.t("sheet.numfmt.negType")
|
|
806
|
-
] }),
|
|
807
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-t-8", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectList, { onChange: handleClick, options, value: suffix }) }),
|
|
808
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "describe m-t-14", children: localeService.t("sheet.numfmt.thousandthPercentileDes") })
|
|
809
|
-
] });
|
|
810
|
-
}, "ThousandthPercentilePanel"), SheetNumfmtPanel = /* @__PURE__ */ __name((props) => {
|
|
811
|
-
const { defaultValue, defaultPattern, row, col } = props.value, localeService = useDependency(LocaleService), getCurrentPattern = useRef(() => ""), t = localeService.t, nextTick = useNextTick(), typeOptions = useMemo(
|
|
812
|
-
() => [
|
|
813
|
-
{ label: "sheet.numfmt.general", component: GeneralPanel },
|
|
814
|
-
{ label: "sheet.numfmt.accounting", component: AccountingPanel },
|
|
815
|
-
{ label: "sheet.numfmt.currency", component: CurrencyPanel },
|
|
816
|
-
{ label: "sheet.numfmt.date", component: DatePanel },
|
|
817
|
-
{ label: "sheet.numfmt.thousandthPercentile", component: ThousandthPercentilePanel },
|
|
818
|
-
{ label: "sheet.numfmt.customFormat", component: CustomFormat }
|
|
819
|
-
].map((item) => ({ ...item, label: t(item.label) })),
|
|
820
|
-
[]
|
|
821
|
-
), [type, typeSet] = useState(findDefaultType), [key2, keySet] = useState(() => `${row}_${col}`), { mark, userHabitCurrency } = useCurrencyOptions(() => keySet(`${row}_${col}_userCurrency'`)), BusinessComponent = useMemo(() => {
|
|
822
|
-
var _a7;
|
|
823
|
-
return (_a7 = typeOptions.find((item) => item.label === type)) == null ? void 0 : _a7.component;
|
|
824
|
-
}, [type]);
|
|
825
|
-
function findDefaultType() {
|
|
826
|
-
return [isGeneralPanel, isAccountingPanel, isCurrencyPanel, isDatePanel, isThousandthPercentilePanel].reduce((pre, curFn, index) => pre || (curFn(defaultPattern) ? typeOptions[index].label : ""), "") || typeOptions[0].label;
|
|
388
|
+
}), await t.executeCommand(R.id, { values: m });
|
|
827
389
|
}
|
|
828
|
-
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
props.onChange({ type: "change", value: v });
|
|
836
|
-
}, "handleChange"), handleConfirm = /* @__PURE__ */ __name(() => {
|
|
837
|
-
const pattern = getCurrentPattern.current() || "", currency = getCurrencyType(pattern);
|
|
838
|
-
currency && mark(currency), props.onChange({ type: "confirm", value: pattern });
|
|
839
|
-
}, "handleConfirm"), handleCancel = /* @__PURE__ */ __name(() => {
|
|
840
|
-
props.onChange({ type: "cancel", value: "" });
|
|
841
|
-
}, "handleCancel"), subProps = {
|
|
842
|
-
onChange: handleChange,
|
|
843
|
-
defaultValue,
|
|
844
|
-
defaultPattern,
|
|
845
|
-
action: getCurrentPattern
|
|
390
|
+
}, Ke = (e) => $.getInfo(e).type || "unknown", Ue = (e, t, n) => {
|
|
391
|
+
const r = $.getInfo(e), s = n === oe.ZH_CN ? "zh-CN" : "en", c = r._partitions[1], o = $.format(e, t, { locale: s, throws: !1 });
|
|
392
|
+
return t < 0 ? {
|
|
393
|
+
result: o,
|
|
394
|
+
color: c.color
|
|
395
|
+
} : {
|
|
396
|
+
result: o
|
|
846
397
|
};
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
] })
|
|
859
|
-
] });
|
|
860
|
-
}, "SheetNumfmtPanel");
|
|
861
|
-
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
862
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
863
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
864
|
-
return kind && result && __defProp$3(target, key2, result), result;
|
|
865
|
-
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$3"), _a3;
|
|
866
|
-
let NumfmtController = (_a3 = class extends Disposable {
|
|
867
|
-
constructor(_sheetInterceptorService, _themeService, _univerInstanceService, _commandService, _selectionManagerService, _renderManagerService, _numfmtService, _componentManager, _sidebarService, _localeService) {
|
|
868
|
-
super();
|
|
869
|
-
/**
|
|
870
|
-
* If _previewPattern is null ,the realTimeRenderingInterceptor will skip and if it is '',realTimeRenderingInterceptor will clear numfmt.
|
|
871
|
-
* @private
|
|
872
|
-
* @type {(string | null)}
|
|
873
|
-
* @memberof NumfmtController
|
|
874
|
-
*/
|
|
875
|
-
__publicField(this, "_previewPattern", "");
|
|
876
|
-
__publicField(this, "_sidebarDisposable", null);
|
|
877
|
-
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._initRealTimeRenderingInterceptor(), this._initPanel(), this._initCommands(), this._initCloseListener(), this._commandExecutedListener();
|
|
398
|
+
}, De = (e, t, n) => e === "General" ? {
|
|
399
|
+
result: String(t)
|
|
400
|
+
} : Ue(e, t, n);
|
|
401
|
+
var Oe = Object.defineProperty, Ve = Object.getOwnPropertyDescriptor, we = (e, t, n, r) => {
|
|
402
|
+
for (var s = r > 1 ? void 0 : r ? Ve(t, n) : t, c = e.length - 1, o; c >= 0; c--)
|
|
403
|
+
(o = e[c]) && (s = (r ? o(t, n, s) : o(s)) || s);
|
|
404
|
+
return r && s && Oe(t, n, s), s;
|
|
405
|
+
}, _ = (e, t) => (n, r) => t(n, r, e);
|
|
406
|
+
let T = class extends K {
|
|
407
|
+
constructor(e, t, n, r, s, c) {
|
|
408
|
+
super(), this._instanceService = e, this._sheetInterceptorService = t, this._themeService = n, this._commandService = r, this._numfmtService = s, this._localeService = c, this._initInterceptorCellContent();
|
|
878
409
|
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
if (
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
} else config.type === "cancel" && sidebarService.close();
|
|
913
|
-
}, "onChange"),
|
|
914
|
-
value: { defaultPattern: pattern, defaultValue, row: range.startRow, col: range.startColumn }
|
|
915
|
-
};
|
|
916
|
-
return this._sidebarDisposable = sidebarService.open({
|
|
917
|
-
header: { title: localeService.t("sheet.numfmt.title") },
|
|
918
|
-
children: {
|
|
919
|
-
label: SHEET_NUMFMT_PLUGIN,
|
|
920
|
-
...props
|
|
921
|
-
// need passthrough to react props.
|
|
410
|
+
// eslint-disable-next-line max-lines-per-function
|
|
411
|
+
_initInterceptorCellContent() {
|
|
412
|
+
const e = new F();
|
|
413
|
+
this.disposeWithMe(this._sheetInterceptorService.intercept(pe.CELL_CONTENT, {
|
|
414
|
+
effect: B.Value | B.Style,
|
|
415
|
+
handler: (t, n, r) => {
|
|
416
|
+
const s = n.unitId, c = n.subUnitId;
|
|
417
|
+
let o;
|
|
418
|
+
const l = t;
|
|
419
|
+
if (!l || l.t !== V.NUMBER || l.v == null || Number.isNaN(l.v))
|
|
420
|
+
return r(t);
|
|
421
|
+
if (t != null && t.s) {
|
|
422
|
+
const m = n.workbook.getStyles().get(t.s);
|
|
423
|
+
m != null && m.n && (o = m.n);
|
|
424
|
+
}
|
|
425
|
+
if (o || (o = this._numfmtService.getValue(s, c, n.row, n.col)), !o)
|
|
426
|
+
return r(t);
|
|
427
|
+
let d = "";
|
|
428
|
+
const i = e.getValue(n.row, n.col);
|
|
429
|
+
if (i && i.parameters === `${l.v}_${o.pattern}`)
|
|
430
|
+
return r({ ...t, ...i.result });
|
|
431
|
+
const u = De(o.pattern, Number(l.v), this._localeService.getCurrentLocale());
|
|
432
|
+
if (d = u.result, !d)
|
|
433
|
+
return r(t);
|
|
434
|
+
const f = { v: d };
|
|
435
|
+
if (u.color) {
|
|
436
|
+
const m = this._themeService.getCurrentTheme()[`${u.color}500`];
|
|
437
|
+
m && (f.interceptorStyle = { cl: { rgb: m } });
|
|
438
|
+
}
|
|
439
|
+
return e.setValue(n.row, n.col, {
|
|
440
|
+
result: f,
|
|
441
|
+
parameters: `${l.v}_${o.pattern}`
|
|
442
|
+
}), r({ ...t, ...f });
|
|
922
443
|
},
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
renderUnit == null || renderUnit.with(SheetSkeletonManagerService).reCalculate(), (_a7 = renderUnit == null ? void 0 : renderUnit.mainComponent) == null || _a7.makeDirty();
|
|
934
|
-
}
|
|
935
|
-
_initCommands() {
|
|
936
|
-
[
|
|
937
|
-
AddDecimalCommand,
|
|
938
|
-
SubtractDecimalCommand,
|
|
939
|
-
SetCurrencyCommand,
|
|
940
|
-
SetPercentCommand,
|
|
941
|
-
OpenNumfmtPanelOperator,
|
|
942
|
-
CloseNumfmtPanelOperator,
|
|
943
|
-
SetNumfmtCommand
|
|
944
|
-
].forEach((config) => {
|
|
945
|
-
this.disposeWithMe(this._commandService.registerCommand(config));
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
_initPanel() {
|
|
949
|
-
this._componentManager.register(SHEET_NUMFMT_PLUGIN, SheetNumfmtPanel);
|
|
950
|
-
}
|
|
951
|
-
_initRealTimeRenderingInterceptor() {
|
|
952
|
-
const isPanelOpenObserver = new Observable((subscriber) => {
|
|
953
|
-
this._commandService.onCommandExecuted((commandInfo) => {
|
|
954
|
-
commandInfo.id === OpenNumfmtPanelOperator.id && subscriber.next(!0), commandInfo.id === CloseNumfmtPanelOperator.id && subscriber.next(!1);
|
|
955
|
-
});
|
|
956
|
-
}), combineOpenAndSelection$ = combineLatest([
|
|
957
|
-
isPanelOpenObserver,
|
|
958
|
-
this._selectionManagerService.selectionMoveEnd$.pipe(
|
|
959
|
-
map((selectionInfos) => selectionInfos ? selectionInfos.map((selectionInfo) => selectionInfo.range) : [])
|
|
960
|
-
)
|
|
961
|
-
]);
|
|
962
|
-
this.disposeWithMe(
|
|
963
|
-
toDisposable(
|
|
964
|
-
combineOpenAndSelection$.pipe(
|
|
965
|
-
switchMap$1(
|
|
966
|
-
([isOpen, selectionRanges]) => new Observable((subscribe) => {
|
|
967
|
-
const disposableCollection = new DisposableCollection();
|
|
968
|
-
return isOpen && selectionRanges.length && subscribe.next({ selectionRanges, disposableCollection }), () => {
|
|
969
|
-
disposableCollection.dispose();
|
|
970
|
-
};
|
|
971
|
-
})
|
|
972
|
-
),
|
|
973
|
-
tap(() => {
|
|
974
|
-
this._previewPattern = null;
|
|
975
|
-
})
|
|
976
|
-
).subscribe(({ disposableCollection, selectionRanges }) => {
|
|
977
|
-
var _a7, _b;
|
|
978
|
-
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
979
|
-
this.openPanel(), disposableCollection.add(
|
|
980
|
-
this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
981
|
-
priority: 99,
|
|
982
|
-
effect: InterceptorEffectEnum.Value | InterceptorEffectEnum.Style,
|
|
983
|
-
handler: /* @__PURE__ */ __name((cell, location, next) => {
|
|
984
|
-
const { row, col } = location, defaultValue = next(cell) || {};
|
|
985
|
-
if (selectionRanges.find(
|
|
986
|
-
(range) => range.startColumn <= col && range.endColumn >= col && range.startRow <= row && range.endRow >= row
|
|
987
|
-
)) {
|
|
988
|
-
const rawValue = location.worksheet.getCellRaw(row, col), value = rawValue == null ? void 0 : rawValue.v, type = rawValue == null ? void 0 : rawValue.t;
|
|
989
|
-
if (value == null || type !== CellValueType.NUMBER || this._previewPattern === null)
|
|
990
|
-
return defaultValue;
|
|
991
|
-
const info = getPatternPreviewIgnoreGeneral(this._previewPattern, value, this._localeService.getCurrentLocale());
|
|
992
|
-
if (info.color) {
|
|
993
|
-
const color = this._themeService.getCurrentTheme()[`${info.color}500`];
|
|
994
|
-
return {
|
|
995
|
-
...defaultValue,
|
|
996
|
-
v: info.result,
|
|
997
|
-
t: CellValueType.STRING,
|
|
998
|
-
s: { cl: { rgb: color } }
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
return {
|
|
1002
|
-
...defaultValue,
|
|
1003
|
-
v: info.result,
|
|
1004
|
-
t: CellValueType.STRING
|
|
1005
|
-
};
|
|
1006
|
-
}
|
|
1007
|
-
return defaultValue;
|
|
1008
|
-
}, "handler")
|
|
1009
|
-
})
|
|
1010
|
-
), (_b = (_a7 = this._renderManagerService.getRenderById(workbook.getUnitId())) == null ? void 0 : _a7.mainComponent) == null || _b.makeDirty();
|
|
1011
|
-
})
|
|
1012
|
-
)
|
|
1013
|
-
);
|
|
1014
|
-
}
|
|
1015
|
-
_commandExecutedListener() {
|
|
1016
|
-
const commandList = [RemoveNumfmtMutation.id, SetNumfmtMutation.id];
|
|
1017
|
-
this.disposeWithMe(
|
|
1018
|
-
new Observable((subscribe) => {
|
|
1019
|
-
const disposable = this._commandService.onCommandExecuted((command) => {
|
|
1020
|
-
if (commandList.includes(command.id)) {
|
|
1021
|
-
const params = command.params;
|
|
1022
|
-
subscribe.next(params.unitId);
|
|
1023
|
-
}
|
|
444
|
+
priority: Se.NUMFMT
|
|
445
|
+
})), this.disposeWithMe(this._commandService.onCommandExecuted((t) => {
|
|
446
|
+
if (t.id === z.id) {
|
|
447
|
+
const n = t.params;
|
|
448
|
+
Object.keys(n.values).forEach((r) => {
|
|
449
|
+
n.values[r].ranges.forEach((c) => {
|
|
450
|
+
C.foreach(c, (o, l) => {
|
|
451
|
+
e.realDeleteValue(o, l);
|
|
452
|
+
});
|
|
453
|
+
});
|
|
1024
454
|
});
|
|
1025
|
-
|
|
1026
|
-
|
|
455
|
+
} else if (t.id === ye.id) {
|
|
456
|
+
const n = t.params;
|
|
457
|
+
new F(n.cellValue).forValue((r, s) => {
|
|
458
|
+
e.realDeleteValue(r, s);
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
})), this.disposeWithMe(
|
|
462
|
+
this._instanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET).pipe(
|
|
463
|
+
be((t) => {
|
|
464
|
+
var n;
|
|
465
|
+
return (n = t == null ? void 0 : t.activeSheet$) != null ? n : _e(null);
|
|
466
|
+
}),
|
|
467
|
+
Me(1)
|
|
468
|
+
).subscribe(() => e.reset())
|
|
1027
469
|
);
|
|
1028
470
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
__decorateParam$3(2, IUniverInstanceService),
|
|
1040
|
-
__decorateParam$3(3, ICommandService),
|
|
1041
|
-
__decorateParam$3(4, Inject(SheetsSelectionsService)),
|
|
1042
|
-
__decorateParam$3(5, IRenderManagerService),
|
|
1043
|
-
__decorateParam$3(6, INumfmtService),
|
|
1044
|
-
__decorateParam$3(7, Inject(ComponentManager)),
|
|
1045
|
-
__decorateParam$3(8, ISidebarService),
|
|
1046
|
-
__decorateParam$3(9, Inject(LocaleService))
|
|
1047
|
-
], NumfmtController);
|
|
1048
|
-
const _NumfmtCurrencyController = class _NumfmtCurrencyController extends Disposable {
|
|
471
|
+
};
|
|
472
|
+
T = we([
|
|
473
|
+
_(0, D),
|
|
474
|
+
_(1, M(ve)),
|
|
475
|
+
_(2, M(ce)),
|
|
476
|
+
_(3, M(b)),
|
|
477
|
+
_(4, M(A)),
|
|
478
|
+
_(5, M(ie))
|
|
479
|
+
], T);
|
|
480
|
+
class W extends K {
|
|
1049
481
|
constructor() {
|
|
1050
482
|
super(...arguments);
|
|
1051
|
-
|
|
1052
|
-
|
|
483
|
+
N(this, "_currencySymbol$", new J("US"));
|
|
484
|
+
N(this, "currencySymbol$", this._currencySymbol$.asObservable());
|
|
1053
485
|
}
|
|
1054
486
|
/**
|
|
1055
487
|
* Set the currency symbol by setting the country code.
|
|
1056
488
|
*/
|
|
1057
|
-
setCurrencySymbolByCountryCode(
|
|
1058
|
-
this._currencySymbol$.next(
|
|
489
|
+
setCurrencySymbolByCountryCode(n) {
|
|
490
|
+
this._currencySymbol$.next(n);
|
|
1059
491
|
}
|
|
1060
492
|
getCurrencySymbol() {
|
|
1061
493
|
return this._currencySymbol$.getValue();
|
|
1062
494
|
}
|
|
1063
|
-
};
|
|
1064
|
-
__name(_NumfmtCurrencyController, "NumfmtCurrencyController");
|
|
1065
|
-
let NumfmtCurrencyController = _NumfmtCurrencyController;
|
|
1066
|
-
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1067
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1068
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1069
|
-
return kind && result && __defProp$2(target, key2, result), result;
|
|
1070
|
-
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$2");
|
|
1071
|
-
const createCollectEffectMutation = /* @__PURE__ */ __name(() => {
|
|
1072
|
-
let list = [];
|
|
1073
|
-
return {
|
|
1074
|
-
add: /* @__PURE__ */ __name((unitId, subUnitId, row, col, value) => list.push({ unitId, subUnitId, row, col, value }), "add"),
|
|
1075
|
-
getEffects: /* @__PURE__ */ __name(() => list, "getEffects"),
|
|
1076
|
-
clean: /* @__PURE__ */ __name(() => {
|
|
1077
|
-
list = [];
|
|
1078
|
-
}, "clean")
|
|
1079
|
-
};
|
|
1080
|
-
}, "createCollectEffectMutation");
|
|
1081
|
-
var _a4;
|
|
1082
|
-
let NumfmtEditorController = (_a4 = class extends Disposable {
|
|
1083
|
-
constructor(_sheetInterceptorService, _numfmtService, _univerInstanceService, _injector, _editorBridgeService) {
|
|
1084
|
-
super();
|
|
1085
|
-
// collect effect mutations when edit end and push this to commands stack in next commands progress
|
|
1086
|
-
__publicField(this, "_collectEffectMutation", createCollectEffectMutation());
|
|
1087
|
-
this._sheetInterceptorService = _sheetInterceptorService, this._numfmtService = _numfmtService, this._univerInstanceService = _univerInstanceService, this._injector = _injector, this._editorBridgeService = _editorBridgeService, this._initInterceptorEditorStart(), this._initInterceptorEditorEnd(), this._initInterceptorCommands();
|
|
1088
|
-
}
|
|
1089
|
-
_initInterceptorEditorStart() {
|
|
1090
|
-
this._editorBridgeService && this.disposeWithMe(
|
|
1091
|
-
toDisposable(
|
|
1092
|
-
this._editorBridgeService.interceptor.intercept(
|
|
1093
|
-
this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,
|
|
1094
|
-
{
|
|
1095
|
-
handler: /* @__PURE__ */ __name((value, context, next) => {
|
|
1096
|
-
const row = context.row, col = context.col, numfmtCell = this._numfmtService.getValue(
|
|
1097
|
-
context.unitId,
|
|
1098
|
-
context.subUnitId,
|
|
1099
|
-
row,
|
|
1100
|
-
col
|
|
1101
|
-
);
|
|
1102
|
-
if (numfmtCell)
|
|
1103
|
-
switch (getPatternType(numfmtCell.pattern)) {
|
|
1104
|
-
case "scientific":
|
|
1105
|
-
case "currency":
|
|
1106
|
-
case "grouped":
|
|
1107
|
-
case "number":
|
|
1108
|
-
return context.worksheet.getCellRaw(row, col);
|
|
1109
|
-
case "percent":
|
|
1110
|
-
case "date":
|
|
1111
|
-
case "time":
|
|
1112
|
-
case "datetime":
|
|
1113
|
-
default:
|
|
1114
|
-
return next && next(value);
|
|
1115
|
-
}
|
|
1116
|
-
return next(value);
|
|
1117
|
-
}, "handler")
|
|
1118
|
-
}
|
|
1119
|
-
)
|
|
1120
|
-
)
|
|
1121
|
-
);
|
|
1122
|
-
}
|
|
1123
|
-
/**
|
|
1124
|
-
* Process the values after edit
|
|
1125
|
-
* @private
|
|
1126
|
-
* @memberof NumfmtService
|
|
1127
|
-
*/
|
|
1128
|
-
_initInterceptorEditorEnd() {
|
|
1129
|
-
this._editorBridgeService && this.disposeWithMe(
|
|
1130
|
-
toDisposable(
|
|
1131
|
-
this._editorBridgeService.interceptor.intercept(
|
|
1132
|
-
this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,
|
|
1133
|
-
{
|
|
1134
|
-
handler: /* @__PURE__ */ __name((value, context, next) => {
|
|
1135
|
-
var _a7;
|
|
1136
|
-
this._collectEffectMutation.clean();
|
|
1137
|
-
const currentNumfmtValue = this._numfmtService.getValue(
|
|
1138
|
-
context.unitId,
|
|
1139
|
-
context.subUnitId,
|
|
1140
|
-
context.row,
|
|
1141
|
-
context.col
|
|
1142
|
-
), currentNumfmtType = (_a7 = currentNumfmtValue && getPatternType(currentNumfmtValue.pattern)) != null ? _a7 : "", clean = /* @__PURE__ */ __name(() => {
|
|
1143
|
-
currentNumfmtValue && this._collectEffectMutation.add(
|
|
1144
|
-
context.unitId,
|
|
1145
|
-
context.subUnitId,
|
|
1146
|
-
context.row,
|
|
1147
|
-
context.col,
|
|
1148
|
-
null
|
|
1149
|
-
);
|
|
1150
|
-
}, "clean");
|
|
1151
|
-
if (!(value != null && value.v) || (currentNumfmtValue == null ? void 0 : currentNumfmtValue.pattern) === DEFAULT_TEXT_FORMAT)
|
|
1152
|
-
return next(value);
|
|
1153
|
-
const content = String(value.v), numfmtInfo = numfmt.parseDate(content) || numfmt.parseTime(content) || numfmt.parseNumber(content);
|
|
1154
|
-
if (numfmtInfo) {
|
|
1155
|
-
if (numfmtInfo.z) {
|
|
1156
|
-
const v = Number(numfmtInfo.v);
|
|
1157
|
-
return this._collectEffectMutation.add(
|
|
1158
|
-
context.unitId,
|
|
1159
|
-
context.subUnitId,
|
|
1160
|
-
context.row,
|
|
1161
|
-
context.col,
|
|
1162
|
-
{
|
|
1163
|
-
pattern: numfmtInfo.z
|
|
1164
|
-
}
|
|
1165
|
-
), { ...value, v, t: CellValueType.NUMBER };
|
|
1166
|
-
}
|
|
1167
|
-
} else (["date", "time", "datetime", "percent"].includes(currentNumfmtType) || !isNumeric(content)) && clean();
|
|
1168
|
-
return next(value);
|
|
1169
|
-
}, "handler")
|
|
1170
|
-
}
|
|
1171
|
-
)
|
|
1172
|
-
)
|
|
1173
|
-
);
|
|
1174
|
-
}
|
|
1175
|
-
_initInterceptorCommands() {
|
|
1176
|
-
const self = this;
|
|
1177
|
-
this.disposeWithMe(
|
|
1178
|
-
this._sheetInterceptorService.interceptCommand({
|
|
1179
|
-
getMutations(command) {
|
|
1180
|
-
var _a7;
|
|
1181
|
-
switch (command.id) {
|
|
1182
|
-
case SetRangeValuesCommand.id: {
|
|
1183
|
-
const workbook = self._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), subUnitId = (_a7 = workbook.getActiveSheet()) == null ? void 0 : _a7.getSheetId();
|
|
1184
|
-
if (!subUnitId)
|
|
1185
|
-
return {
|
|
1186
|
-
redos: [],
|
|
1187
|
-
undos: []
|
|
1188
|
-
};
|
|
1189
|
-
const list = self._collectEffectMutation.getEffects();
|
|
1190
|
-
if (self._collectEffectMutation.clean(), !list.length)
|
|
1191
|
-
return {
|
|
1192
|
-
redos: [],
|
|
1193
|
-
undos: []
|
|
1194
|
-
};
|
|
1195
|
-
const cells = list.filter((item) => {
|
|
1196
|
-
var _a8;
|
|
1197
|
-
return !!((_a8 = item.value) != null && _a8.pattern);
|
|
1198
|
-
}).map((item) => ({
|
|
1199
|
-
row: item.row,
|
|
1200
|
-
col: item.col,
|
|
1201
|
-
pattern: item.value.pattern
|
|
1202
|
-
})), removeCells = list.filter((item) => {
|
|
1203
|
-
var _a8;
|
|
1204
|
-
return !((_a8 = item.value) != null && _a8.pattern);
|
|
1205
|
-
}).map((item) => ({
|
|
1206
|
-
startRow: item.row,
|
|
1207
|
-
endColumn: item.col,
|
|
1208
|
-
startColumn: item.col,
|
|
1209
|
-
endRow: item.row
|
|
1210
|
-
})), redos = [], undos = [];
|
|
1211
|
-
if (cells.length) {
|
|
1212
|
-
const redo = {
|
|
1213
|
-
id: SetNumfmtMutation.id,
|
|
1214
|
-
params: transformCellsToRange(unitId, subUnitId, cells)
|
|
1215
|
-
};
|
|
1216
|
-
redos.push(redo), undos.push(...factorySetNumfmtUndoMutation(self._injector, redo.params));
|
|
1217
|
-
}
|
|
1218
|
-
if (removeCells.length) {
|
|
1219
|
-
const redo = {
|
|
1220
|
-
id: RemoveNumfmtMutation.id,
|
|
1221
|
-
params: {
|
|
1222
|
-
unitId,
|
|
1223
|
-
subUnitId,
|
|
1224
|
-
ranges: removeCells
|
|
1225
|
-
}
|
|
1226
|
-
};
|
|
1227
|
-
redos.push(redo), undos.push(...factoryRemoveNumfmtUndoMutation(self._injector, redo.params));
|
|
1228
|
-
}
|
|
1229
|
-
return {
|
|
1230
|
-
redos,
|
|
1231
|
-
undos: undos.reverse()
|
|
1232
|
-
};
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
return {
|
|
1236
|
-
redos: [],
|
|
1237
|
-
undos: []
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
|
-
})
|
|
1241
|
-
);
|
|
1242
|
-
}
|
|
1243
|
-
}, __name(_a4, "NumfmtEditorController"), _a4);
|
|
1244
|
-
NumfmtEditorController = __decorateClass$2([
|
|
1245
|
-
__decorateParam$2(0, Inject(SheetInterceptorService)),
|
|
1246
|
-
__decorateParam$2(1, Inject(INumfmtService)),
|
|
1247
|
-
__decorateParam$2(2, Inject(IUniverInstanceService)),
|
|
1248
|
-
__decorateParam$2(3, Inject(Injector)),
|
|
1249
|
-
__decorateParam$2(4, Optional(IEditorBridgeService))
|
|
1250
|
-
], NumfmtEditorController);
|
|
1251
|
-
function isNumeric(str) {
|
|
1252
|
-
return /^-?\d+(\.\d+)?$/.test(str);
|
|
1253
495
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
{
|
|
1261
|
-
|
|
1262
|
-
pattern: DEFAULT_TEXT_FORMAT
|
|
1263
|
-
},
|
|
1264
|
-
"|",
|
|
1265
|
-
{
|
|
1266
|
-
label: "sheet.numfmt.number",
|
|
1267
|
-
pattern: "0"
|
|
1268
|
-
},
|
|
1269
|
-
"|",
|
|
1270
|
-
{
|
|
1271
|
-
label: "sheet.numfmt.accounting",
|
|
1272
|
-
pattern: '"¥" #,##0.00_);[Red]("¥"#,##0.00)'
|
|
1273
|
-
},
|
|
1274
|
-
{
|
|
1275
|
-
label: "sheet.numfmt.financialValue",
|
|
1276
|
-
pattern: "#,##0.00;[Red]#,##0.00"
|
|
1277
|
-
},
|
|
1278
|
-
{
|
|
1279
|
-
label: "sheet.numfmt.currency",
|
|
1280
|
-
pattern: '"¥"#,##0.00_);[Red]("¥"#,##0.00)'
|
|
1281
|
-
},
|
|
1282
|
-
{
|
|
1283
|
-
label: "sheet.numfmt.roundingCurrency",
|
|
1284
|
-
pattern: '"¥"#,##0;[Red]"¥"#,##0'
|
|
1285
|
-
},
|
|
1286
|
-
"|",
|
|
1287
|
-
{
|
|
1288
|
-
label: "sheet.numfmt.date",
|
|
1289
|
-
pattern: "yyyy-mm-dd;@"
|
|
1290
|
-
},
|
|
1291
|
-
{
|
|
1292
|
-
label: "sheet.numfmt.time",
|
|
1293
|
-
pattern: 'am/pm h":"mm":"ss'
|
|
1294
|
-
},
|
|
1295
|
-
{
|
|
1296
|
-
label: "sheet.numfmt.dateTime",
|
|
1297
|
-
pattern: "yyyy-m-d am/pm h:mm"
|
|
1298
|
-
},
|
|
1299
|
-
{
|
|
1300
|
-
label: "sheet.numfmt.timeDuration",
|
|
1301
|
-
pattern: "h:mm:ss"
|
|
1302
|
-
},
|
|
1303
|
-
"|",
|
|
1304
|
-
{
|
|
1305
|
-
label: "sheet.numfmt.moreFmt",
|
|
1306
|
-
pattern: ""
|
|
1307
|
-
}
|
|
1308
|
-
], MORE_NUMFMT_TYPE_KEY = "sheet.numfmt.moreNumfmtType", OPTIONS_KEY = "sheet.numfmt.moreNumfmtType.options", MoreNumfmtType = /* @__PURE__ */ __name((props) => {
|
|
1309
|
-
var _a7;
|
|
1310
|
-
const localeService = useDependency(LocaleService), value = (_a7 = props.value) != null ? _a7 : localeService.t("sheet.numfmt.general");
|
|
1311
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "more-numfmt-type", children: value });
|
|
1312
|
-
}, "MoreNumfmtType"), Options = /* @__PURE__ */ __name(() => {
|
|
1313
|
-
const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), layoutService = useDependency(ILayoutService);
|
|
1314
|
-
useInjector();
|
|
1315
|
-
const selectionManagerService = useDependency(SheetsSelectionsService), setNumfmt = /* @__PURE__ */ __name((pattern) => {
|
|
1316
|
-
const selection = selectionManagerService.getCurrentLastSelection();
|
|
1317
|
-
if (!selection)
|
|
1318
|
-
return;
|
|
1319
|
-
const range = selection.range, values = [];
|
|
1320
|
-
Range.foreach(range, (row, col) => {
|
|
1321
|
-
pattern ? values.push({ row, col, pattern, type: getPatternType(pattern) }) : values.push({ row, col });
|
|
1322
|
-
}), commandService.executeCommand(SetNumfmtCommand.id, { values }), layoutService.focus();
|
|
1323
|
-
}, "setNumfmt"), handleOnclick = /* @__PURE__ */ __name((index) => {
|
|
1324
|
-
if (index === 0)
|
|
1325
|
-
setNumfmt(null);
|
|
1326
|
-
else if (index === MENU_OPTIONS.length - 1)
|
|
1327
|
-
commandService.executeCommand(OpenNumfmtPanelOperator.id);
|
|
1328
|
-
else {
|
|
1329
|
-
const item = MENU_OPTIONS[index];
|
|
1330
|
-
item.pattern && setNumfmt(item.pattern);
|
|
1331
|
-
}
|
|
1332
|
-
}, "handleOnclick"), defaultValue = 1220;
|
|
1333
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "more-numfmt-type-options", children: MENU_OPTIONS.map((item, index) => item === "|" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "line m-t-4", onClick: /* @__PURE__ */ __name((e) => e.stopPropagation(), "onClick") }, index) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1334
|
-
"div",
|
|
1335
|
-
{
|
|
1336
|
-
className: "option-item m-t-4",
|
|
1337
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
1338
|
-
handleOnclick(index);
|
|
1339
|
-
}, "onClick"),
|
|
1340
|
-
children: [
|
|
1341
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: localeService.t(item.label) }),
|
|
1342
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-l-26", children: item.pattern ? getPatternPreview(item.pattern || "", defaultValue, localeService.getCurrentLocale()).result : "" })
|
|
1343
|
-
]
|
|
1344
|
-
},
|
|
1345
|
-
index
|
|
1346
|
-
)) });
|
|
1347
|
-
}, "Options"), CurrencyMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
1348
|
-
icon: new Observable((subscribe) => {
|
|
1349
|
-
const menuCurrencyService = accessor.get(MenuCurrencyService);
|
|
1350
|
-
function getIconKey(symbol2) {
|
|
1351
|
-
return {
|
|
1352
|
-
[countryCurrencyMap.US]: "DollarSingle",
|
|
1353
|
-
[countryCurrencyMap.RU]: "RoubleSingle",
|
|
1354
|
-
[countryCurrencyMap.CN]: "RmbSingle",
|
|
1355
|
-
[countryCurrencyMap.AT]: "EuroSingle"
|
|
1356
|
-
}[symbol2] || "DollarSingle";
|
|
1357
|
-
}
|
|
1358
|
-
__name(getIconKey, "getIconKey");
|
|
1359
|
-
const symbol = countryCurrencyMap[menuCurrencyService.getCurrencySymbol()] || "$";
|
|
1360
|
-
return subscribe.next(getIconKey(symbol)), menuCurrencyService.currencySymbol$.subscribe((code) => {
|
|
1361
|
-
const symbol2 = countryCurrencyMap[code] || "$";
|
|
1362
|
-
subscribe.next(getIconKey(symbol2));
|
|
1363
|
-
});
|
|
1364
|
-
}),
|
|
1365
|
-
id: SetCurrencyCommand.id,
|
|
1366
|
-
title: "sheet.numfmt.currency",
|
|
1367
|
-
tooltip: "sheet.numfmt.currency",
|
|
1368
|
-
type: MenuItemType.BUTTON,
|
|
1369
|
-
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1370
|
-
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1371
|
-
}), "CurrencyMenuItem"), AddDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
1372
|
-
icon: "AddDigitsSingle",
|
|
1373
|
-
id: AddDecimalCommand.id,
|
|
1374
|
-
title: "sheet.numfmt.addDecimal",
|
|
1375
|
-
tooltip: "sheet.numfmt.addDecimal",
|
|
1376
|
-
type: MenuItemType.BUTTON,
|
|
1377
|
-
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1378
|
-
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1379
|
-
}), "AddDecimalMenuItem"), SubtractDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
1380
|
-
icon: "ReduceDigitsSingle",
|
|
1381
|
-
id: SubtractDecimalCommand.id,
|
|
1382
|
-
title: "sheet.numfmt.subtractDecimal",
|
|
1383
|
-
tooltip: "sheet.numfmt.subtractDecimal",
|
|
1384
|
-
type: MenuItemType.BUTTON,
|
|
1385
|
-
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1386
|
-
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1387
|
-
}), "SubtractDecimalMenuItem"), PercentMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
1388
|
-
icon: "PercentSingle",
|
|
1389
|
-
id: SetPercentCommand.id,
|
|
1390
|
-
title: "sheet.numfmt.percent",
|
|
1391
|
-
tooltip: "sheet.numfmt.percent",
|
|
1392
|
-
type: MenuItemType.BUTTON,
|
|
1393
|
-
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1394
|
-
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1395
|
-
}), "PercentMenuItem"), FactoryOtherMenuItem = /* @__PURE__ */ __name((accessor) => {
|
|
1396
|
-
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), localeService = accessor.get(LocaleService), selectionManagerService = accessor.get(SheetsSelectionsService), value$ = deriveStateFromActiveSheet$(univerInstanceService, "", ({ workbook, worksheet }) => new Observable(
|
|
1397
|
-
(subscribe) => merge(
|
|
1398
|
-
selectionManagerService.selectionMoveEnd$,
|
|
1399
|
-
new Observable((commandSubscribe) => {
|
|
1400
|
-
const commandList = [RemoveNumfmtMutation.id, SetNumfmtMutation.id], disposable = commandService.onCommandExecuted((commandInfo) => {
|
|
1401
|
-
commandList.includes(commandInfo.id) && commandSubscribe.next(null);
|
|
1402
|
-
});
|
|
1403
|
-
return () => disposable.dispose();
|
|
1404
|
-
})
|
|
1405
|
-
).subscribe(() => {
|
|
1406
|
-
var _a7, _b;
|
|
1407
|
-
const selections = selectionManagerService.getCurrentSelections();
|
|
1408
|
-
if (selections && selections[0]) {
|
|
1409
|
-
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;
|
|
1410
|
-
let value = localeService.t("sheet.numfmt.general");
|
|
1411
|
-
if (pattern) {
|
|
1412
|
-
const item = MENU_OPTIONS.filter((item2) => typeof item2 == "object" && item2.pattern).find(
|
|
1413
|
-
(item2) => isPatternEqualWithoutDecimal(pattern, item2.pattern)
|
|
1414
|
-
);
|
|
1415
|
-
item && typeof item == "object" && item.pattern ? value = localeService.t(item.label) : value = localeService.t("sheet.numfmt.moreFmt");
|
|
1416
|
-
}
|
|
1417
|
-
subscribe.next(value);
|
|
1418
|
-
}
|
|
1419
|
-
})
|
|
1420
|
-
));
|
|
1421
|
-
return {
|
|
1422
|
-
label: MORE_NUMFMT_TYPE_KEY,
|
|
1423
|
-
id: OpenNumfmtPanelOperator.id,
|
|
1424
|
-
tooltip: "sheet.numfmt.title",
|
|
1425
|
-
type: MenuItemType.SELECTOR,
|
|
1426
|
-
selections: [
|
|
1427
|
-
{
|
|
1428
|
-
label: {
|
|
1429
|
-
name: OPTIONS_KEY,
|
|
1430
|
-
hoverable: !1
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
],
|
|
1434
|
-
value$,
|
|
1435
|
-
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1436
|
-
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1437
|
-
};
|
|
1438
|
-
}, "FactoryOtherMenuItem"), menuSchema = {
|
|
1439
|
-
[RibbonStartGroup.FORMULAS_INSERT]: {
|
|
1440
|
-
[SetCurrencyCommand.id]: {
|
|
1441
|
-
order: 4,
|
|
1442
|
-
menuItemFactory: CurrencyMenuItem
|
|
1443
|
-
},
|
|
1444
|
-
[AddDecimalCommand.id]: {
|
|
1445
|
-
order: 5,
|
|
1446
|
-
menuItemFactory: AddDecimalMenuItem
|
|
1447
|
-
},
|
|
1448
|
-
[SubtractDecimalCommand.id]: {
|
|
1449
|
-
order: 6,
|
|
1450
|
-
menuItemFactory: SubtractDecimalMenuItem
|
|
1451
|
-
},
|
|
1452
|
-
[SetPercentCommand.id]: {
|
|
1453
|
-
order: 7,
|
|
1454
|
-
menuItemFactory: PercentMenuItem
|
|
1455
|
-
},
|
|
1456
|
-
[OpenNumfmtPanelOperator.id]: {
|
|
1457
|
-
order: 8,
|
|
1458
|
-
menuItemFactory: FactoryOtherMenuItem
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
};
|
|
1462
|
-
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1463
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1464
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1465
|
-
return kind && result && __defProp$1(target, key2, result), result;
|
|
1466
|
-
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$1"), _a5;
|
|
1467
|
-
let NumfmtMenuController = (_a5 = class extends Disposable {
|
|
1468
|
-
constructor(_componentManager, _menuManagerService) {
|
|
1469
|
-
super(), this._componentManager = _componentManager, this._menuManagerService = _menuManagerService, this._initMenu();
|
|
1470
|
-
}
|
|
1471
|
-
_initMenu() {
|
|
1472
|
-
this._menuManagerService.mergeMenu(menuSchema), this.disposeWithMe(this._componentManager.register(MORE_NUMFMT_TYPE_KEY, MoreNumfmtType)), this.disposeWithMe(this._componentManager.register(OPTIONS_KEY, Options));
|
|
1473
|
-
}
|
|
1474
|
-
}, __name(_a5, "NumfmtMenuController"), _a5);
|
|
1475
|
-
NumfmtMenuController = __decorateClass$1([
|
|
1476
|
-
__decorateParam$1(0, Inject(ComponentManager)),
|
|
1477
|
-
__decorateParam$1(1, IMenuManagerService)
|
|
1478
|
-
], NumfmtMenuController);
|
|
1479
|
-
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) => {
|
|
1480
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1481
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1482
|
-
return kind && result && __defProp2(target, key2, result), result;
|
|
1483
|
-
}, "__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"), _a6;
|
|
1484
|
-
let UniverSheetsNumfmtPlugin = (_a6 = class extends Plugin {
|
|
1485
|
-
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
1486
|
-
super(), this._config = _config, this._injector = _injector, this._configService = _configService;
|
|
1487
|
-
const { menu, ...rest } = this._config;
|
|
1488
|
-
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
|
|
496
|
+
var k = Object.defineProperty, Ae = Object.getOwnPropertyDescriptor, je = (e, t, n) => t in e ? k(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Fe = (e, t, n, r) => {
|
|
497
|
+
for (var s = r > 1 ? void 0 : r ? Ae(t, n) : t, c = e.length - 1, o; c >= 0; c--)
|
|
498
|
+
(o = e[c]) && (s = (r ? o(t, n, s) : o(s)) || s);
|
|
499
|
+
return r && s && k(t, n, s), s;
|
|
500
|
+
}, q = (e, t) => (n, r) => t(n, r, e), ee = (e, t, n) => je(e, typeof t != "symbol" ? t + "" : t, n);
|
|
501
|
+
let U = class extends ue {
|
|
502
|
+
constructor(e = void 0, t, n) {
|
|
503
|
+
super(), this._config = e, this._injector = t, this._commandService = n;
|
|
1489
504
|
}
|
|
1490
505
|
onStarting() {
|
|
1491
|
-
|
|
506
|
+
me(this._injector, [
|
|
507
|
+
[T],
|
|
508
|
+
[X],
|
|
509
|
+
[W]
|
|
510
|
+
]), L(this._injector, [
|
|
511
|
+
[T]
|
|
512
|
+
]);
|
|
1492
513
|
}
|
|
1493
514
|
onRendered() {
|
|
1494
|
-
|
|
515
|
+
L(this._injector, [
|
|
516
|
+
[W]
|
|
517
|
+
]), [
|
|
518
|
+
Re,
|
|
519
|
+
Te,
|
|
520
|
+
xe,
|
|
521
|
+
Pe,
|
|
522
|
+
R
|
|
523
|
+
].forEach((e) => {
|
|
524
|
+
this.disposeWithMe(this._commandService.registerCommand(e));
|
|
525
|
+
});
|
|
1495
526
|
}
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
],
|
|
527
|
+
};
|
|
528
|
+
ee(U, "pluginName", Ee);
|
|
529
|
+
ee(U, "type", Y.UNIVER_SHEET);
|
|
530
|
+
U = Fe([
|
|
531
|
+
ae(Ce),
|
|
532
|
+
q(1, M(le)),
|
|
533
|
+
q(2, b)
|
|
534
|
+
], U);
|
|
535
|
+
const Ye = (e) => Z.find((n) => e.includes(n)), ze = () => Z.map((e) => ({ label: e, value: e })), Je = (e) => Q.map((t) => ({
|
|
536
|
+
label: t.label(e),
|
|
537
|
+
value: t.suffix(e),
|
|
538
|
+
color: t.color
|
|
539
|
+
})), Ze = () => Ie.map((e) => ({ label: e.label, value: e.suffix })), Qe = () => Ne.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
|
|
1504
540
|
export {
|
|
1505
|
-
AddDecimalCommand,
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
541
|
+
Re as AddDecimalCommand,
|
|
542
|
+
Q as CURRENCYFORMAT,
|
|
543
|
+
Ie as DATEFMTLISG,
|
|
544
|
+
X as MenuCurrencyService,
|
|
545
|
+
Ne as NUMBERFORMAT,
|
|
546
|
+
xe as SetCurrencyCommand,
|
|
547
|
+
R as SetNumfmtCommand,
|
|
548
|
+
Pe as SetPercentCommand,
|
|
549
|
+
T as SheetsNumfmtCellContentController,
|
|
550
|
+
Te as SubtractDecimalCommand,
|
|
551
|
+
U as UniverSheetsNumfmtPlugin,
|
|
552
|
+
$e as countryCurrencyMap,
|
|
553
|
+
Z as currencySymbols,
|
|
554
|
+
Je as getCurrencyFormatOptions,
|
|
555
|
+
ze as getCurrencyOptions,
|
|
556
|
+
Ye as getCurrencyType,
|
|
557
|
+
Ze as getDateFormatOptions,
|
|
558
|
+
x as getDecimalFromPattern,
|
|
559
|
+
H as getDecimalString,
|
|
560
|
+
Qe as getNumberFormatOptions,
|
|
561
|
+
Ue as getPatternPreview,
|
|
562
|
+
De as getPatternPreviewIgnoreGeneral,
|
|
563
|
+
Ke as getPatternType,
|
|
564
|
+
We as isPatternEqualWithoutDecimal,
|
|
565
|
+
qe as isPatternHasDecimal,
|
|
566
|
+
P as setPatternDecimal
|
|
1517
567
|
};
|